@amityco/ts-sdk 0.0.1-655cb77.0 → 0.0.1-65645.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 (453) hide show
  1. package/.eslintrc.json +2 -0
  2. package/README.md +3 -1
  3. package/dist/@types/core/events.d.ts +22 -22
  4. package/dist/@types/core/events.d.ts.map +1 -1
  5. package/dist/@types/core/model.d.ts +5 -2
  6. package/dist/@types/core/model.d.ts.map +1 -1
  7. package/dist/@types/core/payload.d.ts +87 -34
  8. package/dist/@types/core/payload.d.ts.map +1 -1
  9. package/dist/@types/domains/channel.d.ts +3 -3
  10. package/dist/@types/domains/channel.d.ts.map +1 -1
  11. package/dist/@types/domains/client.d.ts +1 -1
  12. package/dist/@types/domains/client.d.ts.map +1 -1
  13. package/dist/@types/domains/comment.d.ts +5 -0
  14. package/dist/@types/domains/comment.d.ts.map +1 -1
  15. package/dist/@types/domains/community.d.ts +11 -0
  16. package/dist/@types/domains/community.d.ts.map +1 -1
  17. package/dist/@types/domains/content.d.ts +7 -1
  18. package/dist/@types/domains/content.d.ts.map +1 -1
  19. package/dist/@types/domains/feed.d.ts +1 -2
  20. package/dist/@types/domains/feed.d.ts.map +1 -1
  21. package/dist/@types/domains/group.d.ts +2 -2
  22. package/dist/@types/domains/message.d.ts +1 -1
  23. package/dist/@types/domains/message.d.ts.map +1 -1
  24. package/dist/@types/domains/post.d.ts +1 -1
  25. package/dist/@types/domains/post.d.ts.map +1 -1
  26. package/dist/@types/domains/user.d.ts +8 -0
  27. package/dist/@types/domains/user.d.ts.map +1 -1
  28. package/dist/@types/global.d.ts +8 -0
  29. package/dist/@types/global.d.ts.map +1 -1
  30. package/dist/cache/api/ingestInCache.d.ts +2 -1
  31. package/dist/cache/api/ingestInCache.d.ts.map +1 -1
  32. package/dist/category/api/queryCategories.d.ts.map +1 -1
  33. package/dist/channel/api/addChannelMembers.d.ts.map +1 -1
  34. package/dist/channel/api/addChannelMembersRole.d.ts.map +1 -1
  35. package/dist/channel/api/banChannelMembers.d.ts.map +1 -1
  36. package/dist/channel/api/createChannel.d.ts.map +1 -1
  37. package/dist/channel/api/getChannel.d.ts.map +1 -1
  38. package/dist/channel/api/joinChannel.d.ts.map +1 -1
  39. package/dist/channel/api/leaveChannel.d.ts.map +1 -1
  40. package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
  41. package/dist/channel/api/queryChannels.d.ts.map +1 -1
  42. package/dist/channel/api/removeChannelMembers.d.ts.map +1 -1
  43. package/dist/channel/api/removeChannelMembersRole.d.ts +1 -1
  44. package/dist/channel/api/removeChannelMembersRole.d.ts.map +1 -1
  45. package/dist/channel/api/startReading.d.ts +3 -3
  46. package/dist/channel/api/startReading.d.ts.map +1 -1
  47. package/dist/channel/api/stopReading.d.ts +2 -2
  48. package/dist/channel/api/stopReading.d.ts.map +1 -1
  49. package/dist/channel/api/unbanChannelMembers.d.ts.map +1 -1
  50. package/dist/channel/api/updateChannel.d.ts.map +1 -1
  51. package/dist/channel/events/onChannelJoined.d.ts.map +1 -1
  52. package/dist/channel/events/onChannelLeft.d.ts.map +1 -1
  53. package/dist/channel/events/onChannelMemberAdded.d.ts.map +1 -1
  54. package/dist/channel/events/onChannelMemberBanned.d.ts.map +1 -1
  55. package/dist/channel/events/onChannelMemberRemoved.d.ts.map +1 -1
  56. package/dist/channel/events/onChannelMemberUnbanned.d.ts.map +1 -1
  57. package/dist/channel/observers/liveChannels.d.ts.map +1 -1
  58. package/dist/channel/utils/index.d.ts +2 -2
  59. package/dist/channel/utils/index.d.ts.map +1 -1
  60. package/dist/client/api/connectClient.d.ts.map +1 -1
  61. package/dist/client/api/disconnectClient.d.ts.map +1 -1
  62. package/dist/client/api/renewal.d.ts.map +1 -1
  63. package/dist/comment/api/createComment.d.ts +1 -1
  64. package/dist/comment/api/createComment.d.ts.map +1 -1
  65. package/dist/comment/api/deleteComment.d.ts.map +1 -1
  66. package/dist/comment/api/getComment.d.ts.map +1 -1
  67. package/dist/comment/api/getComments.d.ts.map +1 -1
  68. package/dist/comment/api/queryComments.d.ts.map +1 -1
  69. package/dist/comment/api/tests/updateComment.test.d.ts +2 -0
  70. package/dist/comment/api/tests/updateComment.test.d.ts.map +1 -0
  71. package/dist/comment/api/updateComment.d.ts.map +1 -1
  72. package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
  73. package/dist/community/api/addCommunityMembersRoles.d.ts +1 -1
  74. package/dist/community/api/addCommunityMembersRoles.d.ts.map +1 -1
  75. package/dist/community/api/createCommunity.d.ts.map +1 -1
  76. package/dist/community/api/deleteCommunity.d.ts.map +1 -1
  77. package/dist/community/api/getCommunity.d.ts.map +1 -1
  78. package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -1
  79. package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -1
  80. package/dist/community/api/joinCommunity.d.ts.map +1 -1
  81. package/dist/community/api/leaveCommunity.d.ts.map +1 -1
  82. package/dist/community/api/queryCommunities.d.ts.map +1 -1
  83. package/dist/community/api/queryCommunityMembers.d.ts +1 -7
  84. package/dist/community/api/queryCommunityMembers.d.ts.map +1 -1
  85. package/dist/community/api/removeCommunityMembers.d.ts.map +1 -1
  86. package/dist/community/api/removeCommunityMembersRoles.d.ts +1 -1
  87. package/dist/community/api/removeCommunityMembersRoles.d.ts.map +1 -1
  88. package/dist/community/api/updateCommunity.d.ts.map +1 -1
  89. package/dist/community/events/index.d.ts +2 -0
  90. package/dist/community/events/index.d.ts.map +1 -1
  91. package/dist/community/events/onCommunityUserRoleAdded.d.ts +17 -0
  92. package/dist/community/events/onCommunityUserRoleAdded.d.ts.map +1 -0
  93. package/dist/community/events/onCommunityUserRoleRemoved.d.ts +17 -0
  94. package/dist/community/events/onCommunityUserRoleRemoved.d.ts.map +1 -0
  95. package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts +2 -0
  96. package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts.map +1 -0
  97. package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts +2 -0
  98. package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts.map +1 -0
  99. package/dist/community/events/utils.d.ts.map +1 -1
  100. package/dist/community/observers/index.d.ts +2 -0
  101. package/dist/community/observers/index.d.ts.map +1 -1
  102. package/dist/community/observers/liveCommunity.d.ts +21 -0
  103. package/dist/community/observers/liveCommunity.d.ts.map +1 -0
  104. package/dist/community/observers/liveCommunityMembers.d.ts +20 -0
  105. package/dist/community/observers/liveCommunityMembers.d.ts.map +1 -0
  106. package/dist/community/observers/tests/liveCommunity.test.d.ts +2 -0
  107. package/dist/community/observers/tests/liveCommunity.test.d.ts.map +1 -0
  108. package/dist/community/observers/tests/liveCommunityMembers.test.d.ts +2 -0
  109. package/dist/community/observers/tests/liveCommunityMembers.test.d.ts.map +1 -0
  110. package/dist/community/utils/payload.d.ts +3 -5
  111. package/dist/community/utils/payload.d.ts.map +1 -1
  112. package/dist/core/device.d.ts.map +1 -1
  113. package/dist/core/events.d.ts +3 -3
  114. package/dist/core/events.d.ts.map +1 -1
  115. package/dist/core/model/idResolvers.d.ts +2 -4
  116. package/dist/core/model/idResolvers.d.ts.map +1 -1
  117. package/dist/core/model/identifyModel.d.ts +2 -2
  118. package/dist/core/model/identifyModel.d.ts.map +1 -1
  119. package/dist/core/model/index.d.ts.map +1 -1
  120. package/dist/core/query/filtering.d.ts +10 -0
  121. package/dist/core/query/filtering.d.ts.map +1 -1
  122. package/dist/core/query/paging.d.ts +2 -2
  123. package/dist/core/query/paging.d.ts.map +1 -1
  124. package/dist/core/query/query.d.ts.map +1 -1
  125. package/dist/core/query/tests/paging.test.d.ts +2 -0
  126. package/dist/core/query/tests/paging.test.d.ts.map +1 -0
  127. package/dist/external/api/tests/createUserToken.test.d.ts +2 -0
  128. package/dist/external/api/tests/createUserToken.test.d.ts.map +1 -0
  129. package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
  130. package/dist/file/api/createFile.d.ts.map +1 -1
  131. package/dist/file/api/createImage.d.ts.map +1 -1
  132. package/dist/file/api/createVideo.d.ts.map +1 -1
  133. package/dist/file/api/deleteFile.d.ts.map +1 -1
  134. package/dist/file/api/getFile.d.ts.map +1 -1
  135. package/dist/follow/api/acceptFollower.d.ts.map +1 -1
  136. package/dist/follow/api/declineFollower.d.ts.map +1 -1
  137. package/dist/follow/api/follow.d.ts.map +1 -1
  138. package/dist/follow/api/getFollowInfo.d.ts.map +1 -1
  139. package/dist/follow/api/queryFollowers.d.ts.map +1 -1
  140. package/dist/follow/api/queryFollowings.d.ts.map +1 -1
  141. package/dist/follow/api/unfollow.d.ts.map +1 -1
  142. package/dist/group/utils/withUser.d.ts.map +1 -1
  143. package/dist/index.cjs.js +1076 -331
  144. package/dist/index.esm.js +1069 -330
  145. package/dist/index.umd.js +4 -4
  146. package/dist/message/api/createMessage.d.ts.map +1 -1
  147. package/dist/message/api/deleteMessage.d.ts.map +1 -1
  148. package/dist/message/api/getMessage.d.ts.map +1 -1
  149. package/dist/message/api/queryMessages.d.ts +2 -2
  150. package/dist/message/api/queryMessages.d.ts.map +1 -1
  151. package/dist/message/api/updateMessage.d.ts.map +1 -1
  152. package/dist/message/utils/index.d.ts +3 -3
  153. package/dist/message/utils/index.d.ts.map +1 -1
  154. package/dist/poll/api/closePoll.d.ts.map +1 -1
  155. package/dist/poll/api/createPoll.d.ts.map +1 -1
  156. package/dist/poll/api/deletePoll.d.ts.map +1 -1
  157. package/dist/poll/api/getPoll.d.ts.map +1 -1
  158. package/dist/poll/api/tests/closePoll.test.d.ts +2 -0
  159. package/dist/poll/api/tests/closePoll.test.d.ts.map +1 -0
  160. package/dist/poll/api/tests/createPoll.test.d.ts +2 -0
  161. package/dist/poll/api/tests/createPoll.test.d.ts.map +1 -0
  162. package/dist/poll/api/tests/getPoll.test.d.ts +2 -0
  163. package/dist/poll/api/tests/getPoll.test.d.ts.map +1 -0
  164. package/dist/poll/api/tests/votePoll.test.d.ts +2 -0
  165. package/dist/poll/api/tests/votePoll.test.d.ts.map +1 -0
  166. package/dist/poll/api/votePoll.d.ts.map +1 -1
  167. package/dist/post/api/approvePost.d.ts.map +1 -1
  168. package/dist/post/api/createPost.d.ts.map +1 -1
  169. package/dist/post/api/declinePost.d.ts.map +1 -1
  170. package/dist/post/api/deletePost.d.ts.map +1 -1
  171. package/dist/post/api/getPost.d.ts.map +1 -1
  172. package/dist/post/api/getPosts.d.ts.map +1 -1
  173. package/dist/post/api/queryPosts.d.ts.map +1 -1
  174. package/dist/post/api/updatePost.d.ts.map +1 -1
  175. package/dist/post/events/utils.d.ts.map +1 -1
  176. package/dist/post/observers/livePosts.d.ts +2 -2
  177. package/dist/post/observers/livePosts.d.ts.map +1 -1
  178. package/dist/reaction/api/addReaction.d.ts.map +1 -1
  179. package/dist/reaction/api/queryReactions.d.ts.map +1 -1
  180. package/dist/reaction/api/removeReaction.d.ts.map +1 -1
  181. package/dist/reaction/events/onReactorAdded.d.ts.map +1 -1
  182. package/dist/reaction/events/onReactorRemoved.d.ts.map +1 -1
  183. package/dist/reaction/utils/dispatchReactable.d.ts +1 -1
  184. package/dist/reaction/utils/dispatchReactable.d.ts.map +1 -1
  185. package/dist/report/api/createReport.d.ts.map +1 -1
  186. package/dist/report/api/deleteReport.d.ts.map +1 -1
  187. package/dist/report/api/isReportedByMe.d.ts.map +1 -1
  188. package/dist/report/api/tests/createReport.test.d.ts +2 -0
  189. package/dist/report/api/tests/createReport.test.d.ts.map +1 -0
  190. package/dist/report/api/tests/deleteReport.test.d.ts +2 -0
  191. package/dist/report/api/tests/deleteReport.test.d.ts.map +1 -0
  192. package/dist/stream/api/createStream.d.ts.map +1 -1
  193. package/dist/stream/api/deleteStream.d.ts.map +1 -1
  194. package/dist/stream/api/getStream.d.ts.map +1 -1
  195. package/dist/stream/api/queryStreams.d.ts.map +1 -1
  196. package/dist/stream/api/updateStream.d.ts.map +1 -1
  197. package/dist/subChannel/api/createSubChannel.d.ts.map +1 -1
  198. package/dist/subChannel/api/deleteSubChannel.d.ts.map +1 -1
  199. package/dist/subChannel/api/getSubChannel.d.ts.map +1 -1
  200. package/dist/subChannel/api/querySubChannels.d.ts.map +1 -1
  201. package/dist/subChannel/api/updateSubChannel.d.ts.map +1 -1
  202. package/dist/subChannel/utils/index.d.ts +1 -1
  203. package/dist/subChannel/utils/index.d.ts.map +1 -1
  204. package/dist/user/api/getUser.d.ts.map +1 -1
  205. package/dist/user/api/getUsers.d.ts.map +1 -1
  206. package/dist/user/api/queryUsers.d.ts +1 -6
  207. package/dist/user/api/queryUsers.d.ts.map +1 -1
  208. package/dist/user/api/updateUser.d.ts.map +1 -1
  209. package/dist/user/observers/index.d.ts +1 -0
  210. package/dist/user/observers/index.d.ts.map +1 -1
  211. package/dist/user/observers/liveUsers.d.ts +18 -0
  212. package/dist/user/observers/liveUsers.d.ts.map +1 -0
  213. package/dist/user/observers/tests/liveUsers.test.d.ts +2 -0
  214. package/dist/user/observers/tests/liveUsers.test.d.ts.map +1 -0
  215. package/dist/utils/index.d.ts +2 -2
  216. package/dist/utils/index.d.ts.map +1 -1
  217. package/dist/utils/liveObject.d.ts +1 -1
  218. package/dist/utils/liveObject.d.ts.map +1 -1
  219. package/dist/utils/tests/dummy/channel.d.ts +31 -35
  220. package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
  221. package/dist/utils/tests/dummy/community.d.ts +35 -84
  222. package/dist/utils/tests/dummy/community.d.ts.map +1 -1
  223. package/dist/utils/tests/dummy/feed.d.ts +5 -0
  224. package/dist/utils/tests/dummy/feed.d.ts.map +1 -0
  225. package/dist/utils/tests/dummy/index.d.ts +1 -0
  226. package/dist/utils/tests/dummy/index.d.ts.map +1 -1
  227. package/dist/utils/tests/dummy/member.d.ts +1 -1
  228. package/dist/utils/tests/dummy/post.d.ts +30 -20
  229. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  230. package/dist/utils/tests/dummy/user.d.ts +63 -0
  231. package/dist/utils/tests/dummy/user.d.ts.map +1 -1
  232. package/dist/version.d.ts.map +1 -1
  233. package/package.json +1 -1
  234. package/src/@types/core/events.ts +22 -20
  235. package/src/@types/core/model.ts +7 -2
  236. package/src/@types/core/payload.ts +102 -38
  237. package/src/@types/domains/channel.ts +3 -3
  238. package/src/@types/domains/client.ts +1 -1
  239. package/src/@types/domains/comment.ts +7 -0
  240. package/src/@types/domains/community.ts +25 -0
  241. package/src/@types/domains/content.ts +9 -1
  242. package/src/@types/domains/feed.ts +1 -3
  243. package/src/@types/domains/group.ts +2 -2
  244. package/src/@types/domains/message.ts +4 -1
  245. package/src/@types/domains/post.ts +1 -1
  246. package/src/@types/domains/user.ts +14 -0
  247. package/src/@types/global.ts +10 -0
  248. package/src/cache/api/ingestInCache.ts +3 -6
  249. package/src/cache/api/tests/ingestInCache.test.ts +14 -9
  250. package/src/category/api/queryCategories.ts +3 -0
  251. package/src/channel/api/addChannelMembers.ts +9 -5
  252. package/src/channel/api/addChannelMembersRole.ts +4 -0
  253. package/src/channel/api/banChannelMembers.ts +5 -3
  254. package/src/channel/api/createChannel.ts +4 -0
  255. package/src/channel/api/getChannel.ts +5 -1
  256. package/src/channel/api/joinChannel.ts +4 -0
  257. package/src/channel/api/leaveChannel.ts +4 -0
  258. package/src/channel/api/queryChannelMembers.ts +5 -3
  259. package/src/channel/api/queryChannels.ts +4 -0
  260. package/src/channel/api/removeChannelMembers.ts +9 -5
  261. package/src/channel/api/removeChannelMembersRole.ts +5 -1
  262. package/src/channel/api/startReading.ts +7 -3
  263. package/src/channel/api/stopReading.ts +6 -2
  264. package/src/channel/api/tests/addChannelMembers.test.ts +4 -3
  265. package/src/channel/api/tests/createChannel.test.ts +5 -3
  266. package/src/channel/api/tests/getChannel.test.ts +2 -1
  267. package/src/channel/api/tests/joinChannel.test.ts +2 -2
  268. package/src/channel/api/tests/leaveChannel.test.ts +2 -2
  269. package/src/channel/api/tests/queryChannelMembers.test.ts +2 -5
  270. package/src/channel/api/tests/queryChannels.test.ts +4 -3
  271. package/src/channel/api/tests/removeChannelMembers.test.ts +16 -5
  272. package/src/channel/api/unbanChannelMembers.ts +5 -3
  273. package/src/channel/api/updateChannel.ts +4 -0
  274. package/src/channel/events/onChannelJoined.ts +1 -3
  275. package/src/channel/events/onChannelLeft.ts +1 -3
  276. package/src/channel/events/onChannelMemberAdded.ts +1 -3
  277. package/src/channel/events/onChannelMemberBanned.ts +1 -3
  278. package/src/channel/events/onChannelMemberRemoved.ts +1 -3
  279. package/src/channel/events/onChannelMemberUnbanned.ts +1 -3
  280. package/src/channel/observers/liveChannels.ts +29 -24
  281. package/src/channel/observers/tests/liveChannelMembers.test.ts +5 -12
  282. package/src/channel/observers/tests/liveChannels.test.ts +3 -1
  283. package/src/channel/utils/index.ts +9 -6
  284. package/src/client/api/connectClient.ts +4 -2
  285. package/src/client/api/disconnectClient.ts +4 -0
  286. package/src/client/api/getToken.ts +1 -1
  287. package/src/client/api/renewal.ts +4 -0
  288. package/src/client/api/tests/getToken.test.ts +2 -2
  289. package/src/comment/api/createComment.ts +22 -2
  290. package/src/comment/api/deleteComment.ts +23 -2
  291. package/src/comment/api/getComment.ts +4 -0
  292. package/src/comment/api/getComments.ts +4 -0
  293. package/src/comment/api/queryComments.ts +4 -0
  294. package/src/comment/api/tests/createComment.test.ts +169 -9
  295. package/src/comment/api/tests/updateComment.test.ts +189 -0
  296. package/src/comment/api/updateComment.ts +4 -0
  297. package/src/comment/events/tests/onCommentCreated.test.ts +3 -3
  298. package/src/comment/events/tests/onCommentDeleted.test.ts +3 -3
  299. package/src/comment/observers/tests/liveComment.test.ts +18 -2
  300. package/src/community/api/addCommunityMembers.ts +10 -3
  301. package/src/community/api/addCommunityMembersRoles.ts +9 -2
  302. package/src/community/api/createCommunity.ts +9 -5
  303. package/src/community/api/deleteCommunity.ts +13 -1
  304. package/src/community/api/getCommunities.ts +2 -2
  305. package/src/community/api/getCommunity.ts +6 -2
  306. package/src/community/api/getRecommendedCommunities.ts +6 -2
  307. package/src/community/api/getTopTrendingCommunities.ts +6 -2
  308. package/src/community/api/joinCommunity.ts +10 -3
  309. package/src/community/api/leaveCommunity.ts +10 -3
  310. package/src/community/api/queryCommunities.ts +7 -3
  311. package/src/community/api/queryCommunityMembers.ts +7 -7
  312. package/src/community/api/removeCommunityMembers.ts +11 -3
  313. package/src/community/api/removeCommunityMembersRoles.ts +9 -2
  314. package/src/community/api/test/queryCommunityMembers.test.ts +2 -1
  315. package/src/community/api/test/removeCommunityMemberRole.test.ts +4 -1
  316. package/src/community/api/updateCommunity.ts +9 -5
  317. package/src/community/events/index.ts +2 -0
  318. package/src/community/events/onCommunityUserRoleAdded.ts +20 -0
  319. package/src/community/events/onCommunityUserRoleRemoved.ts +20 -0
  320. package/src/community/events/test/onCommunityDeleted.test.ts +8 -1
  321. package/src/community/events/test/onCommunityUserRoleAdded.test.ts +50 -0
  322. package/src/community/events/test/onCommunityUserRoleRemoved.test.ts +50 -0
  323. package/src/community/events/utils.ts +4 -8
  324. package/src/community/observers/index.ts +4 -0
  325. package/src/community/observers/liveCommunity.ts +45 -0
  326. package/src/community/observers/liveCommunityMembers.ts +187 -0
  327. package/src/community/observers/tests/liveCommunities.test.ts +38 -18
  328. package/src/community/observers/tests/liveCommunity.test.ts +147 -0
  329. package/src/community/observers/tests/liveCommunityMembers.test.ts +195 -0
  330. package/src/community/utils/payload.ts +28 -22
  331. package/src/core/device.ts +2 -4
  332. package/src/core/model/idResolvers.ts +6 -3
  333. package/src/core/model/identifyModel.ts +4 -3
  334. package/src/core/model/index.ts +3 -0
  335. package/src/core/query/filtering.ts +33 -3
  336. package/src/core/query/paging.ts +5 -4
  337. package/src/core/query/query.ts +7 -0
  338. package/src/core/query/tests/paging.test.ts +66 -0
  339. package/src/core/tests/query/query/runQuery.test.ts +8 -3
  340. package/src/core/tests/subscription.test.ts +80 -2
  341. package/src/external/api/tests/createUserToken.test.ts +29 -0
  342. package/src/feed/api/queryGlobalFeed.ts +12 -4
  343. package/src/file/api/createFile.ts +4 -0
  344. package/src/file/api/createImage.ts +4 -0
  345. package/src/file/api/createVideo.ts +4 -0
  346. package/src/file/api/deleteFile.ts +4 -0
  347. package/src/file/api/getFile.ts +4 -0
  348. package/src/follow/api/acceptFollower.ts +4 -0
  349. package/src/follow/api/declineFollower.ts +4 -0
  350. package/src/follow/api/follow.ts +4 -0
  351. package/src/follow/api/getFollowInfo.ts +4 -0
  352. package/src/follow/api/queryFollowers.ts +4 -0
  353. package/src/follow/api/queryFollowings.ts +4 -0
  354. package/src/follow/api/unfollow.ts +4 -0
  355. package/src/group/utils/test/withUsers.test.ts +5 -5
  356. package/src/group/utils/withUser.ts +20 -14
  357. package/src/message/api/createMessage.ts +19 -13
  358. package/src/message/api/deleteMessage.ts +4 -0
  359. package/src/message/api/getMessage.ts +6 -2
  360. package/src/message/api/getMessages.ts +1 -1
  361. package/src/message/api/queryMessages.ts +13 -9
  362. package/src/message/api/tests/createMessage.test.ts +21 -1
  363. package/src/message/api/tests/queryMessages.test.ts +6 -6
  364. package/src/message/api/updateMessage.ts +5 -1
  365. package/src/message/events/onMessageCreated.ts +1 -1
  366. package/src/message/events/onMessageDeleted.ts +1 -1
  367. package/src/message/events/onMessageFetched.ts +1 -1
  368. package/src/message/events/onMessageFlagCleared.ts +1 -1
  369. package/src/message/events/onMessageFlagged.ts +1 -1
  370. package/src/message/events/onMessageReactionAdded.ts +1 -1
  371. package/src/message/events/onMessageReactionRemoved.ts +1 -1
  372. package/src/message/events/onMessageUnflagged.ts +1 -1
  373. package/src/message/events/onMessageUpdated.ts +1 -1
  374. package/src/message/observers/liveMessages.ts +1 -1
  375. package/src/message/tests/events.test.ts +10 -2
  376. package/src/message/tests/observers/liveMessage.test.ts +6 -1
  377. package/src/message/tests/observers/liveMessages.test.ts +20 -7
  378. package/src/message/utils/index.ts +5 -3
  379. package/src/poll/api/closePoll.ts +4 -0
  380. package/src/poll/api/createPoll.ts +4 -0
  381. package/src/poll/api/deletePoll.ts +4 -0
  382. package/src/poll/api/getPoll.ts +4 -0
  383. package/src/poll/api/tests/closePoll.test.ts +50 -0
  384. package/src/poll/api/tests/createPoll.test.ts +70 -0
  385. package/src/poll/api/tests/getPoll.test.ts +31 -0
  386. package/src/poll/api/tests/votePoll.test.ts +41 -0
  387. package/src/poll/api/votePoll.ts +4 -0
  388. package/src/poll/events/onPollDeleted.ts +1 -1
  389. package/src/poll/events/onPollUpdated.ts +1 -1
  390. package/src/post/api/approvePost.ts +14 -10
  391. package/src/post/api/createPost.ts +10 -3
  392. package/src/post/api/declinePost.ts +15 -11
  393. package/src/post/api/deletePost.ts +23 -2
  394. package/src/post/api/getPost.ts +9 -2
  395. package/src/post/api/getPosts.ts +7 -1
  396. package/src/post/api/queryPosts.ts +7 -1
  397. package/src/post/api/tests/queryPosts.test.ts +5 -4
  398. package/src/post/api/updatePost.ts +8 -1
  399. package/src/post/events/onPostReactionAdded.ts +1 -1
  400. package/src/post/events/onPostReactionRemoved.ts +1 -1
  401. package/src/post/events/utils.ts +12 -2
  402. package/src/post/observers/livePosts.ts +14 -22
  403. package/src/post/observers/tests/livePost.test.ts +10 -3
  404. package/src/post/observers/tests/livePosts.test.ts +76 -11
  405. package/src/post/tests/api/getPost.test.ts +13 -3
  406. package/src/post/tests/api/queryPosts.test.ts +5 -4
  407. package/src/reaction/api/addReaction.ts +7 -3
  408. package/src/reaction/api/queryReactions.ts +6 -0
  409. package/src/reaction/api/removeReaction.ts +8 -3
  410. package/src/reaction/events/onReactionAdded.ts +3 -3
  411. package/src/reaction/events/onReactionRemoved.ts +3 -3
  412. package/src/reaction/events/onReactorAdded.ts +8 -2
  413. package/src/reaction/events/onReactorRemoved.ts +8 -2
  414. package/src/reaction/utils/dispatchReactable.ts +1 -1
  415. package/src/reaction/utils/fetchReference.ts +1 -1
  416. package/src/report/api/createReport.ts +18 -13
  417. package/src/report/api/deleteReport.ts +19 -13
  418. package/src/report/api/isReportedByMe.ts +4 -0
  419. package/src/report/api/tests/createReport.test.ts +93 -0
  420. package/src/report/api/tests/deleteReport.test.ts +93 -0
  421. package/src/stream/api/createStream.ts +4 -0
  422. package/src/stream/api/deleteStream.ts +3 -0
  423. package/src/stream/api/getStream.ts +4 -0
  424. package/src/stream/api/queryStreams.ts +4 -0
  425. package/src/stream/api/updateStream.ts +3 -0
  426. package/src/subChannel/api/createSubChannel.ts +5 -1
  427. package/src/subChannel/api/deleteSubChannel.ts +4 -0
  428. package/src/subChannel/api/getSubChannel.ts +5 -1
  429. package/src/subChannel/api/getSubChannels.ts +1 -1
  430. package/src/subChannel/api/querySubChannels.ts +6 -2
  431. package/src/subChannel/api/updateSubChannel.ts +5 -1
  432. package/src/subChannel/events/onSubChannelCreated.ts +1 -1
  433. package/src/subChannel/events/onSubChannelDeleted.ts +1 -1
  434. package/src/subChannel/events/onSubChannelUpdated.ts +1 -1
  435. package/src/subChannel/utils/index.ts +2 -2
  436. package/src/user/api/getUser.ts +4 -0
  437. package/src/user/api/getUsers.ts +3 -0
  438. package/src/user/api/queryUsers.ts +5 -6
  439. package/src/user/api/updateUser.ts +4 -0
  440. package/src/user/observers/index.ts +1 -0
  441. package/src/user/observers/liveUsers.ts +162 -0
  442. package/src/user/observers/tests/liveUsers.test.ts +204 -0
  443. package/src/user/tests/api/getUser.test.ts +17 -3
  444. package/src/utils/index.ts +2 -2
  445. package/src/utils/liveObject.ts +1 -1
  446. package/src/utils/tests/dummy/channel.ts +19 -11
  447. package/src/utils/tests/dummy/community.ts +68 -6
  448. package/src/utils/tests/dummy/feed.ts +13 -0
  449. package/src/utils/tests/dummy/index.ts +2 -0
  450. package/src/utils/tests/dummy/member.ts +1 -1
  451. package/src/utils/tests/dummy/post.ts +98 -10
  452. package/src/utils/tests/dummy/user.ts +36 -0
  453. package/src/version.ts +9 -3
package/dist/index.cjs.js CHANGED
@@ -93,16 +93,16 @@ const PostContentType = Object.freeze({
93
93
  POLL: 'poll',
94
94
  });
95
95
 
96
- var _a$1;
97
- /* eslint-disable no-undef */
98
- const theGlobal =
99
- // eslint-disable-next-line no-nested-ternary
100
- typeof globalThis === 'object' ? globalThis : typeof global === 'object' ? global : window;
101
- const { process: safeProcess = {} } = theGlobal;
102
- const isProduction = ((_a$1 = safeProcess.env) === null || _a$1 === void 0 ? void 0 : _a$1.NODE_ENV) === 'production';
103
-
104
- var _a, _b;
105
- const VERSION$1 = (_b = (_a = safeProcess.env) === null || _a === void 0 ? void 0 : _a.VERSION) !== null && _b !== void 0 ? _b : '__dev__';
96
+ function getVersion() {
97
+ try {
98
+ // the string ''v0.0.1-beta.41-cjs'' should be replaced by actual value by @rollup/plugin-replace
99
+ return 'v0.0.1-beta.41-cjs';
100
+ }
101
+ catch (error) {
102
+ return '__dev__';
103
+ }
104
+ }
105
+ const VERSION = getVersion();
106
106
 
107
107
  // cache constants
108
108
  const CACHE_KEY_GET = 'get';
@@ -177,14 +177,14 @@ const partialMatch = (predicate, candidate) => {
177
177
  const checkIfShouldGoesToTombstone = (errorCode) => [400400 /* Amity.ServerError.ITEM_NOT_FOUND */, 400300 /* Amity.ServerError.FORBIDDEN */].includes(errorCode);
178
178
 
179
179
  /**
180
- * Type guard to find if the a given decoded backend token uses "skip/limit" pagination style
180
+ * Type guard to find if the a given decoded backend token uses "skip" pagination style
181
181
  *
182
182
  * @param json any json object as extracted from the backend
183
183
  * @returns success boolean if the token has either "skip" or "limit" props
184
184
  *
185
185
  * @hidden
186
186
  */
187
- const isSkipLimit = (json) => ['skip', 'limit'].some(prop => prop in json);
187
+ const isSkip = (json) => ['skip'].some(prop => prop in json);
188
188
  /**
189
189
  * Type guard to find if the a given decoded backend token uses "after/before" pagination style
190
190
  *
@@ -284,7 +284,7 @@ const toPage = (token) => {
284
284
  return undefined;
285
285
  // don't try catch, let it throw
286
286
  const json = JSON.parse(jsBase64.decode(token));
287
- if (isSkipLimit(json)) {
287
+ if (isSkip(json)) {
288
288
  return {
289
289
  after: json.skip,
290
290
  limit: json.limit,
@@ -440,6 +440,8 @@ const queryOptions = (policy, lifeSpan = CACHE_LIFESPAN) => {
440
440
  * @category Query
441
441
  */
442
442
  const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_server')) => {
443
+ console.warn('Deprecation Notice: After 1 April 2023, CreateQuery/RunQuery will no longer be supported. You will be able to use the API without either methods. Check https://docs.amity.co/ for details');
444
+ console.warn('Deprecation Notice: After 1 March 2023, individual module imoprts will no longer be supported. All public APIs will need to be imported from their respective repositories. Ex: CommunityRepository, UserRepository, etc. Check https://docs.amity.co/ for detailed info.');
443
445
  let local;
444
446
  const { lifeSpan } = queryOptions('cache_then_server', options.lifeSpan);
445
447
  // offline first
@@ -511,6 +513,7 @@ const idResolvers = {
511
513
  stream: ({ streamId }) => streamId,
512
514
  follow: ({ from, to }) => `${from}#${to}`,
513
515
  followCount: ({ userId }) => userId,
516
+ feed: ({ targetId, feedId }) => `${targetId}#${feedId}`,
514
517
  };
515
518
  /**
516
519
  * Retrieve the id resolver matching a domain name
@@ -548,6 +551,7 @@ const CRITERIAS = {
548
551
  stream: ['streamId'],
549
552
  follow: ['from', 'to'],
550
553
  followCount: ['userId', 'followerCount'],
554
+ feed: ['feedId', 'feedType'],
551
555
  };
552
556
  /** @hidden */
553
557
  const hasKeys = (object, needles) => {
@@ -557,7 +561,7 @@ const hasKeys = (object, needles) => {
557
561
  /**
558
562
  * Finds the name of the store for a given unknown model
559
563
  *
560
- * @param model one of the {@link Amity.Model} to identify
564
+ * @param model one of the {@link Amity.Models} to identify
561
565
  * @returns the name of the corresponding store
562
566
  */
563
567
  const identifyModel = (model) => {
@@ -608,6 +612,7 @@ const PAYLOAD2MODEL = {
608
612
  videoStreamings: 'stream',
609
613
  follows: 'follow',
610
614
  followCounts: 'followCount',
615
+ feeds: 'feed',
611
616
  };
612
617
  /** hidden */
613
618
  const hasUpdates = (prevData, nextData) => {
@@ -1074,10 +1079,36 @@ const filterByChannelMembership = (collection, membership, userId) => {
1074
1079
  'get',
1075
1080
  channelUserCacheKey,
1076
1081
  ])) === null || _a === void 0 ? void 0 : _a.data;
1077
- if (membership === 'member' && channelUser && channelUser.membership !== 'none') {
1078
- return true;
1082
+ if (membership === 'member') {
1083
+ return channelUser && channelUser.membership !== 'none';
1079
1084
  }
1080
- return membership === 'notMember' && (!channelUser || channelUser.membership === 'none');
1085
+ // only membership value remainging is 'notMember'
1086
+ return !channelUser || channelUser.membership === 'none';
1087
+ });
1088
+ };
1089
+ /**
1090
+ * Filter a channel collection by membership of the userId
1091
+ *
1092
+ * @param collection the channel collection to filter
1093
+ * @param feedType to be filtered by
1094
+ * @returns a filtered collection with items only matching the criteria
1095
+ *
1096
+ * @hidden
1097
+ */
1098
+ const filterByFeedType = (collection, feedType) => {
1099
+ /*
1100
+ * It is possible that the targetId & feedId are the same for most of the posts
1101
+ * But since cache is in-memory, i've avoided memoizing, to avoid premature
1102
+ * optimization. Can be revisited if performance issues arise
1103
+ */
1104
+ return collection.filter(({ targetId, feedId }) => {
1105
+ var _a;
1106
+ const feed = (_a = pullFromCache([
1107
+ 'feed',
1108
+ 'get',
1109
+ getResolver('feed')({ targetId, feedId }),
1110
+ ])) === null || _a === void 0 ? void 0 : _a.data;
1111
+ return feed && feed.feedType === feedType;
1081
1112
  });
1082
1113
  };
1083
1114
 
@@ -1345,6 +1376,14 @@ function subscribeTopic(topic, callback) {
1345
1376
  return mqtt.subscribe(topic, callback);
1346
1377
  }
1347
1378
 
1379
+ var _a;
1380
+ /* eslint-disable no-undef */
1381
+ const theGlobal =
1382
+ // eslint-disable-next-line no-nested-ternary
1383
+ typeof globalThis === 'object' ? globalThis : typeof global === 'object' ? global : window;
1384
+ const { process: safeProcess = {} } = theGlobal;
1385
+ const isProduction = ((_a = safeProcess.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === 'production';
1386
+
1348
1387
  /**
1349
1388
  * Creates a pre-configured logger instance
1350
1389
  *
@@ -20339,8 +20378,6 @@ const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
20339
20378
 
20340
20379
  // TODO: find a way to uniquely identify the device
20341
20380
  /** @hidden */
20342
- const VERSION = '11.0.0';
20343
- /** @hidden */
20344
20381
  const getDeviceId = () => {
20345
20382
  // here maybe put some auto detection of the device id based on if it's react or not?
20346
20383
  // anyhow we let consumer branch out if they want, but it doesn't mean we shouldn't try to be nice
@@ -20362,10 +20399,10 @@ const getDeviceModel = () => {
20362
20399
  const getDeviceInfo = () => {
20363
20400
  const model = getDeviceModel();
20364
20401
  return {
20365
- version: VERSION,
20366
20402
  // TODO: replace with: kind: process.versions ? 'node' : 'web', when backend has fixed this
20367
20403
  kind: 'web',
20368
20404
  model,
20405
+ sdkVersion: VERSION,
20369
20406
  };
20370
20407
  };
20371
20408
 
@@ -20441,7 +20478,7 @@ const getToken = async (params) => {
20441
20478
  const client = getActiveClient();
20442
20479
  client.log('client/api/getToken', params);
20443
20480
  const deviceInfo = getDeviceInfo();
20444
- const { data } = await client.http.post('/api/v3/sessions', Object.assign(Object.assign({}, params), { deviceInfo }), {
20481
+ const { data } = await client.http.post('/api/v4/sessions', Object.assign(Object.assign({}, params), { deviceInfo }), {
20445
20482
  // @ts-ignore
20446
20483
  headers: { 'X-API-Key': client.apiKey },
20447
20484
  });
@@ -20477,6 +20514,9 @@ const setClientToken = async (params) => {
20477
20514
  return { accessToken, users, refreshToken };
20478
20515
  };
20479
20516
 
20517
+ /* begin_public_function
20518
+ id: client.logout
20519
+ */
20480
20520
  /**
20481
20521
  * ```js
20482
20522
  * import { disconnectClient } from '@amityco/ts-sdk'
@@ -20525,7 +20565,8 @@ const disconnectClient = async () => {
20525
20565
  client.cache = { data: {} };
20526
20566
  }
20527
20567
  return !client.ws.connected;
20528
- };
20568
+ };
20569
+ /* end_public_function */
20529
20570
 
20530
20571
  /**
20531
20572
  * Ingest a payload (v3) into the cache
@@ -20542,9 +20583,10 @@ const ingestInCache = (payload = {}, options) => {
20542
20583
  if (!type)
20543
20584
  return;
20544
20585
  const resolver = getResolver(type);
20586
+ if (!resolver)
20587
+ return;
20545
20588
  models.forEach(model => {
20546
- upsertInCache([type, 'get', resolver(model)], // this 'any' cannot be avoided, sorry.
20547
- model, options);
20589
+ upsertInCache([type, 'get', resolver(model)], model, options);
20548
20590
  });
20549
20591
  });
20550
20592
  };
@@ -20728,6 +20770,9 @@ const onTokenTerminated = (callback) => {
20728
20770
  * to be cleared
20729
20771
  */
20730
20772
  const subscriptions = [];
20773
+ /* begin_public_function
20774
+ id: client.login
20775
+ */
20731
20776
  /**
20732
20777
  * ```js
20733
20778
  * import { connectClient } from '@amityco/ts-sdk/client/api'
@@ -20820,10 +20865,14 @@ const connectClient = async (params, sessionHandler, config) => {
20820
20865
  setSessionState(state);
20821
20866
  disconnectClient();
20822
20867
  subscriptions.forEach(fn => fn());
20823
- }), onUserDeleted(() => null));
20868
+ }));
20824
20869
  return client.ws.connected;
20825
- };
20870
+ };
20871
+ /* end_public_function */
20826
20872
 
20873
+ /* begin_public_function
20874
+ id: client.renew_access_token
20875
+ */
20827
20876
  /*
20828
20877
  * Renewal defintion accepted by SessionHandler interface
20829
20878
  *
@@ -20882,7 +20931,8 @@ const renewal = () => {
20882
20931
  }, ACCESS_TOKEN_WATCHER_INTERVAL);
20883
20932
  },
20884
20933
  };
20885
- };
20934
+ };
20935
+ /* end_public_function */
20886
20936
 
20887
20937
  const ABOUT_TO_EXPIRE_THRESHOLD = 80 / 100;
20888
20938
  const COMPENSATED_DELAY = 5 * MINUTE;
@@ -20979,7 +21029,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
20979
21029
  const sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
20980
21030
  const sessionHandler = undefined;
20981
21031
  const client = {
20982
- version: `${VERSION$1}`,
21032
+ version: `${VERSION}`,
20983
21033
  apiKey,
20984
21034
  log,
20985
21035
  http,
@@ -21077,6 +21127,9 @@ const pushToTombstone = (model, modelId) => {
21077
21127
  pushToCache(cacheKey, data);
21078
21128
  };
21079
21129
 
21130
+ /* begin_public_function
21131
+ id: user.get
21132
+ */
21080
21133
  /**
21081
21134
  * ```js
21082
21135
  * import { getUser } from '@amityco/ts-sdk'
@@ -21119,6 +21172,7 @@ const getUser = async (userId, isLive = false) => {
21119
21172
  cachedAt,
21120
21173
  };
21121
21174
  };
21175
+ /* end_public_function */
21122
21176
  /**
21123
21177
  * ```js
21124
21178
  * import { getUser } from '@amityco/ts-sdk'
@@ -21138,6 +21192,9 @@ getUser.locally = (userId) => {
21138
21192
  return client.cache && pullFromCache(['user', 'get', userId]);
21139
21193
  };
21140
21194
 
21195
+ /* begin_public_function
21196
+ id: user.get_by_ids
21197
+ */
21141
21198
  /**
21142
21199
  * ```js
21143
21200
  * import { getUsers } from '@amityco/ts-sdk'
@@ -21228,6 +21285,9 @@ function __rest(s, e) {
21228
21285
  return t;
21229
21286
  }
21230
21287
 
21288
+ /* begin_public_function
21289
+ id: user.query, user.search
21290
+ */
21231
21291
  /**
21232
21292
  * ```js
21233
21293
  * import { queryUsers } from '@amityco/ts-sdk'
@@ -21271,6 +21331,7 @@ const queryUsers = async (query = {}) => {
21271
21331
  const nextPage = toPage(paging.next);
21272
21332
  return { data: users, cachedAt, prevPage, nextPage };
21273
21333
  };
21334
+ /* end_public_function */
21274
21335
  /**
21275
21336
  * ```js
21276
21337
  * import { queryUsers } from '@amityco/ts-sdk'
@@ -21306,6 +21367,9 @@ queryUsers.locally = (query = {}) => {
21306
21367
  : undefined;
21307
21368
  };
21308
21369
 
21370
+ /* begin_public_function
21371
+ id: client.update_user
21372
+ */
21309
21373
  /**
21310
21374
  * ```js
21311
21375
  * import { updateUser } from '@amityco/ts-sdk'
@@ -21340,7 +21404,8 @@ const updateUser = async (userId, patch) => {
21340
21404
  data: users.find(user => user.userId === userId),
21341
21405
  cachedAt,
21342
21406
  };
21343
- };
21407
+ };
21408
+ /* end_public_function */
21344
21409
 
21345
21410
  /**
21346
21411
  * ```js
@@ -21509,6 +21574,101 @@ const liveUser = (userId, callback) => {
21509
21574
  ]);
21510
21575
  };
21511
21576
 
21577
+ /**
21578
+ * ```js
21579
+ * import { liveUsers } from '@amityco/ts-sdk'
21580
+ *
21581
+ * let users = []
21582
+ * const unsub = liveUsers({}, response => merge(users, response.data))
21583
+ * ```
21584
+ *
21585
+ * Observe all mutations on a list of {@link Amity.User}s
21586
+ *
21587
+ * @param params for querying users
21588
+ * @param callback the function to call when new data are available
21589
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the users
21590
+ *
21591
+ * @category Category Live Collection
21592
+ */
21593
+ const liveUsers = (params, callback, config) => {
21594
+ const { log, cache } = getActiveClient();
21595
+ if (!cache) {
21596
+ console.log(ENABLE_CACHE_MESSAGE);
21597
+ }
21598
+ const timestamp = Date.now();
21599
+ log(`liveUsers(tmpid: ${timestamp}) > listen`);
21600
+ const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
21601
+ const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
21602
+ const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
21603
+ const disposers = [];
21604
+ const cacheKey = ['user', 'collection', {}];
21605
+ const responder = (data) => {
21606
+ var _a, _b;
21607
+ let users = (_a = data.data
21608
+ .map(userId => pullFromCache(['user', 'get', userId]))
21609
+ .filter(Boolean)
21610
+ .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
21611
+ users = filterByPropEquality(users, 'displayName', params.displayName);
21612
+ switch (params.sortBy) {
21613
+ case 'firstCreated':
21614
+ users = users.sort(sortByFirstCreated);
21615
+ break;
21616
+ case 'lastCreated':
21617
+ users = users.sort(sortByLastCreated);
21618
+ break;
21619
+ default:
21620
+ users = users
21621
+ // this needs to be aligned with the backend data type
21622
+ .map(u => (u.displayName ? u : Object.assign(Object.assign({}, u), { displayName: '' })))
21623
+ // @ts-ignore
21624
+ .sort(sortByDisplayName);
21625
+ }
21626
+ callback({
21627
+ onNextPage: onFetch,
21628
+ data: users,
21629
+ hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
21630
+ loading: data.loading,
21631
+ error: data.error,
21632
+ });
21633
+ };
21634
+ const realtimeRouter = (_) => (user) => {
21635
+ var _a;
21636
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
21637
+ if (!collection)
21638
+ return;
21639
+ collection.data = [...new Set([user.userId, ...collection.data])];
21640
+ pushToCache(cacheKey, collection);
21641
+ responder(collection);
21642
+ };
21643
+ const onFetch = () => {
21644
+ var _a, _b, _c;
21645
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
21646
+ const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
21647
+ if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
21648
+ return;
21649
+ const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
21650
+ runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
21651
+ const data = {
21652
+ loading,
21653
+ error,
21654
+ params: { page },
21655
+ data: users,
21656
+ };
21657
+ if (result) {
21658
+ data.data = [...new Set([...users, ...result.map(getResolver('user'))])];
21659
+ }
21660
+ pushToCache(cacheKey, data);
21661
+ responder(data);
21662
+ }, queryOptions(policy));
21663
+ };
21664
+ disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
21665
+ onFetch();
21666
+ return () => {
21667
+ log(`liveUsers(tmpid: ${timestamp}) > dispose`);
21668
+ disposers.forEach(fn => fn());
21669
+ };
21670
+ };
21671
+
21512
21672
  /**
21513
21673
  * ```js
21514
21674
  * import { observeUser } from '@amityco/ts-sdk'
@@ -21550,6 +21710,9 @@ const observeUser = (userId, callback) => {
21550
21710
  };
21551
21711
  };
21552
21712
 
21713
+ /* begin_public_function
21714
+ id: file.get
21715
+ */
21553
21716
  /**
21554
21717
  * ```js
21555
21718
  * import { getFile } from '@amityco/ts-sdk'
@@ -21578,6 +21741,7 @@ const getFile = async (fileId) => {
21578
21741
  cachedAt,
21579
21742
  };
21580
21743
  };
21744
+ /* end_public_function */
21581
21745
  /**
21582
21746
  * ```js
21583
21747
  * import { getFile } from '@amityco/ts-sdk'
@@ -21605,6 +21769,9 @@ getFile.locally = (fileId) => {
21605
21769
  };
21606
21770
  };
21607
21771
 
21772
+ /* begin_public_function
21773
+ id: file.upload.file
21774
+ */
21608
21775
  /**
21609
21776
  * ```js
21610
21777
  * import { createFile } from '@amityco/ts-sdk'
@@ -21644,8 +21811,12 @@ const createFile = async (formData, onProgress) => {
21644
21811
  cachedAt,
21645
21812
  };
21646
21813
  };
21814
+ /* end_public_function */
21647
21815
  // TODO: consider doing local creation with URL.createObjectURL()
21648
21816
 
21817
+ /* begin_public_function
21818
+ id: file.delete
21819
+ */
21649
21820
  /**
21650
21821
  * ```js
21651
21822
  * import { deleteFile } from '@amityco/ts-sdk'
@@ -21667,7 +21838,8 @@ const deleteFile = async (fileId) => {
21667
21838
  await client.http.delete(`/api/v3/files/${fileId}`);
21668
21839
  dropFromCache(['file', 'get', fileId], true);
21669
21840
  return { success: true };
21670
- };
21841
+ };
21842
+ /* end_public_function */
21671
21843
 
21672
21844
  /**
21673
21845
  * Allow to query a file url with a selected size
@@ -21680,6 +21852,9 @@ const fileUrlWithSize = (fileUrl, size) => {
21680
21852
  return `${fileUrl}?size=${size}`;
21681
21853
  };
21682
21854
 
21855
+ /* begin_public_function
21856
+ id: file.upload.video
21857
+ */
21683
21858
  /**
21684
21859
  * ```js
21685
21860
  * import { createVideo } from '@amityco/ts-sdk'
@@ -21723,8 +21898,12 @@ const createVideo = async (formData, feedType, onProgress) => {
21723
21898
  cachedAt,
21724
21899
  };
21725
21900
  };
21901
+ /* end_public_function */
21726
21902
  // TODO: consider doing local creation with URL.createObjectURL()
21727
21903
 
21904
+ /* begin_public_function
21905
+ id: file.upload.image
21906
+ */
21728
21907
  /**
21729
21908
  * ```js
21730
21909
  * import { createImage } from '@amityco/ts-sdk'
@@ -21764,6 +21943,7 @@ const createImage = async (formData, onProgress) => {
21764
21943
  cachedAt,
21765
21944
  };
21766
21945
  };
21946
+ /* end_public_function */
21767
21947
  // TODO: consider doing local creation with URL.createObjectURL()
21768
21948
 
21769
21949
  /**
@@ -22018,6 +22198,9 @@ function convertQueryParams$1(_a) {
22018
22198
  return out;
22019
22199
  }
22020
22200
 
22201
+ /* begin_public_function
22202
+ id: message.get
22203
+ */
22021
22204
  /**
22022
22205
  * ```js
22023
22206
  * import { getMessage } from '@amityco/ts-sdk'
@@ -22063,6 +22246,7 @@ const getMessage = async (messageId, isLive = false) => {
22063
22246
  cachedAt,
22064
22247
  };
22065
22248
  };
22249
+ /* end_public_function */
22066
22250
  /**
22067
22251
  * ```js
22068
22252
  * import { getMessage } from '@amityco/ts-sdk'
@@ -22154,6 +22338,9 @@ getMessages.locally = (messageIds) => {
22154
22338
  };
22155
22339
  };
22156
22340
 
22341
+ /* begin_public_function
22342
+ id: message.query
22343
+ */
22157
22344
  /**
22158
22345
  * ```js
22159
22346
  * import { queryMessages } from '@amityco/ts-sdk'
@@ -22190,10 +22377,11 @@ const queryMessages = async (query) => {
22190
22377
  pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
22191
22378
  }
22192
22379
  fireEvent('local.message.fetched', { messages });
22193
- const nextPage = toPage(paging.next);
22194
- const prevPage = toPage(paging.previous);
22380
+ const nextPage = toPageRaw(paging.next);
22381
+ const prevPage = toPageRaw(paging.previous);
22195
22382
  return { data: messages, cachedAt, prevPage, nextPage };
22196
22383
  };
22384
+ /* end_public_function */
22197
22385
  /**
22198
22386
  * ```js
22199
22387
  * import { queryMessages } from '@amityco/ts-sdk'
@@ -22222,8 +22410,8 @@ queryMessages.locally = (query) => {
22222
22410
  .map(messageId => pullFromCache(['message', 'get', messageId]))
22223
22411
  .filter(Boolean)
22224
22412
  .map(({ data }) => data);
22225
- const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
22226
- const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
22413
+ const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
22414
+ const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
22227
22415
  return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
22228
22416
  ? { data: messages, cachedAt, prevPage, nextPage }
22229
22417
  : undefined;
@@ -22231,8 +22419,12 @@ queryMessages.locally = (query) => {
22231
22419
 
22232
22420
  const uuid = () => nativeIdGenerator__default["default"].v4().toString();
22233
22421
 
22422
+ const getLocalId = () => `LOCAL_${uuid()}`;
22234
22423
  // FIXME: temp solution
22235
22424
  let uniqueId;
22425
+ /* begin_public_function
22426
+ id: message.create.text_message, message.create.image_message, message.create.file_message, message.create.video_message, message.create.audio_message, message.create.custom_message
22427
+ */
22236
22428
  /**
22237
22429
  * ```js
22238
22430
  * import { createMessage, createQuery, runQuery } from '@amityco/ts-sdk'
@@ -22258,17 +22450,16 @@ let uniqueId;
22258
22450
  const createMessage = async (bundle) => {
22259
22451
  const client = getActiveClient();
22260
22452
  client.log('message/createMessage', bundle);
22261
- const referenceId = uniqueId;
22453
+ const referenceId = uniqueId || getLocalId();
22262
22454
  uniqueId = undefined;
22263
- const { data } = await client.http
22264
- .post('/api/v5/messages', Object.assign(Object.assign({}, convertParams(bundle)), { referenceId }))
22265
- .then(convertResponseFromRaw);
22455
+ const { data: payload } = await client.http.post('/api/v5/messages', Object.assign(Object.assign({}, convertParams(bundle)), { referenceId }));
22456
+ const data = prepareMessagePayload(payload);
22457
+ const { messages } = data;
22266
22458
  const cachedAt = client.cache && Date.now();
22267
22459
  if (client.cache) {
22268
22460
  dropFromCache(['message', 'get', referenceId]);
22269
22461
  ingestInCache(data, { cachedAt });
22270
22462
  }
22271
- const { messages } = data;
22272
22463
  fireEvent('local.message.created', { messages });
22273
22464
  return {
22274
22465
  data: messages[0],
@@ -22304,9 +22495,8 @@ createMessage.optimistically = (bundle) => {
22304
22495
  * Updated to handle client requirement to add messageId while uploading
22305
22496
  * message with image. Temporary!
22306
22497
  */
22307
- const localId = `LOCAL_${uuid()}`;
22308
- uniqueId = localId;
22309
- const bundleWithMessageId = Object.assign({ messageId: localId, uniqueId: localId }, bundle);
22498
+ uniqueId = getLocalId();
22499
+ const bundleWithMessageId = Object.assign({ messageId: uniqueId, uniqueId }, bundle);
22310
22500
  client.log('message/createMessage.optimistically', bundleWithMessageId);
22311
22501
  const subChannel = pullFromCache(['subChannel', 'get', bundle.subChannelId]);
22312
22502
  if (subChannel) {
@@ -22328,8 +22518,12 @@ createMessage.optimistically = (bundle) => {
22328
22518
  cachedAt,
22329
22519
  data: message,
22330
22520
  };
22331
- };
22521
+ };
22522
+ /* end_public_function */
22332
22523
 
22524
+ /* begin_public_function
22525
+ id: message.edit
22526
+ */
22333
22527
  /**
22334
22528
  * ```js
22335
22529
  * import { updateMessage } from '@amityco/ts-sdk'
@@ -22395,8 +22589,12 @@ updateMessage.optimistically = (messageId, patch) => {
22395
22589
  data: updated,
22396
22590
  cachedAt,
22397
22591
  };
22398
- };
22592
+ };
22593
+ /* end_public_function */
22399
22594
 
22595
+ /* begin_public_function
22596
+ id: message.soft_delete
22597
+ */
22400
22598
  /**
22401
22599
  * ```js
22402
22600
  * import { deleteMessage } from '@amityco/ts-sdk'
@@ -22447,8 +22645,72 @@ deleteMessage.optimistically = (messageId) => {
22447
22645
  data: deleted,
22448
22646
  cachedAt,
22449
22647
  };
22648
+ };
22649
+ /* end_public_function */
22650
+
22651
+ /**
22652
+ * Attach user object to membership model
22653
+ * - If cache is not enabled, set user to undefined ({..., user: undefined})
22654
+ * - If user object is not found in cache, set user to undefined
22655
+ * ({..., user: undefined})
22656
+ * - If a user is found in the cache, it attaches the user from the cache
22657
+ * ({..., user: { userId, displayName,... }})
22658
+ *
22659
+ * @param member The membership model object
22660
+ * @param userIdProp The user ID prop name of membership object
22661
+ * @param userProp The user prop name of destination object
22662
+ * @returns The membership model object that is already mapped to user
22663
+ * @hidden
22664
+ */
22665
+ const withUser = (member, userIdProp = 'userId', userProp = 'user') => {
22666
+ // If the user prop already exists, do not overwrite.
22667
+ if (member[userProp])
22668
+ return member;
22669
+ return Object.assign({ get [userProp]() {
22670
+ var _a;
22671
+ const client = getActiveClient();
22672
+ if (!client.cache)
22673
+ return undefined;
22674
+ const userCache = (_a = pullFromCache(['user', 'get', member[userIdProp]])) === null || _a === void 0 ? void 0 : _a.data;
22675
+ if (!userCache) {
22676
+ return undefined;
22677
+ }
22678
+ return userCache;
22679
+ } }, member);
22680
+ };
22681
+ /**
22682
+ * Mapping membership model with user object
22683
+ *
22684
+ * @param members The membership model objects
22685
+ * @param userIdProp The user ID prop name of membership object
22686
+ * @param userProp The user prop name of destination object
22687
+ * @returns The membership model objects that is already
22688
+ * mapped to users
22689
+ * @hidden
22690
+ */
22691
+ const withUsers = (members, userIdProp = 'userId', userProp = 'user') => {
22692
+ var _a;
22693
+ return (_a = members === null || members === void 0 ? void 0 : members.map(member => withUser(member, userIdProp, userProp))) !== null && _a !== void 0 ? _a : members;
22694
+ };
22695
+ /**
22696
+ * Transform members prop in any payload with attached users members
22697
+ *
22698
+ * @param payload The payload contain members prop
22699
+ * @param memberProp A name of members prop
22700
+ * @param userIdProp The user ID prop name of membership object
22701
+ * @param userProp The user prop name of destination object
22702
+ * @returns The transforming payload
22703
+ * @hidden
22704
+ */
22705
+ const prepareMembershipPayload = (payload, memberProp, userIdProp = 'userId', userProp = 'user') => {
22706
+ const _a = payload, _b = memberProp, memberPayload = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
22707
+ const members = withUsers(memberPayload, userIdProp, userProp);
22708
+ return Object.assign(Object.assign({}, rest), { [memberProp]: members });
22450
22709
  };
22451
22710
 
22711
+ /* begin_public_function
22712
+ id: post.query, feed.query.community_feed, feed.query.user_feed
22713
+ */
22452
22714
  /**
22453
22715
  * ```js
22454
22716
  * import { queryPosts } from '@amityco/ts-sdk'
@@ -22488,10 +22750,11 @@ const queryPosts = async (query) => {
22488
22750
  // const { paging, posts } = unwrapPayload(data)
22489
22751
  // unpacking
22490
22752
  const { paging } = data, payload = __rest(data, ["paging"]);
22753
+ const paperedPayload = prepareMembershipPayload(payload, 'communityUsers');
22491
22754
  const { posts } = payload;
22492
22755
  const cachedAt = client.cache && Date.now();
22493
22756
  if (client.cache) {
22494
- ingestInCache(payload, { cachedAt });
22757
+ ingestInCache(paperedPayload, { cachedAt });
22495
22758
  const cacheKey = ['post', 'query', Object.assign(Object.assign({}, params), { options: Object.assign({}, page) })];
22496
22759
  pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
22497
22760
  }
@@ -22499,6 +22762,7 @@ const queryPosts = async (query) => {
22499
22762
  const prevPage = toPageRaw(paging.previous);
22500
22763
  return { data: posts, cachedAt, prevPage, nextPage };
22501
22764
  };
22765
+ /* end_public_function */
22502
22766
  /**
22503
22767
  * ```js
22504
22768
  * import { queryPosts } from '@amityco/ts-sdk'
@@ -22534,6 +22798,9 @@ queryPosts.locally = (query) => {
22534
22798
  : undefined;
22535
22799
  };
22536
22800
 
22801
+ /* begin_public_function
22802
+ id: post.get_by_ids
22803
+ */
22537
22804
  /**
22538
22805
  * ```js
22539
22806
  * import { getPosts } from '@amityco/ts-sdk'
@@ -22553,9 +22820,10 @@ const getPosts = async (postIds) => {
22553
22820
  client.log('post/getPosts', postIds);
22554
22821
  const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
22555
22822
  // API-FIX: endpoint should not be /list, parameters should be querystring.
22556
- const { data } = await client.http.get(`/api/v3/posts/list`, {
22823
+ const { data: payload } = await client.http.get(`/api/v3/posts/list`, {
22557
22824
  params: { postIds: encodedPostIds },
22558
22825
  });
22826
+ const data = prepareMembershipPayload(payload, 'communityUsers');
22559
22827
  const cachedAt = client.cache && Date.now();
22560
22828
  if (client.cache)
22561
22829
  ingestInCache(data, { cachedAt });
@@ -22596,6 +22864,9 @@ getPosts.locally = (postIds) => {
22596
22864
  };
22597
22865
  };
22598
22866
 
22867
+ /* begin_public_function
22868
+ id: post.get
22869
+ */
22599
22870
  /**
22600
22871
  * ```js
22601
22872
  * import { getPost } from '@amityco/ts-sdk'
@@ -22614,11 +22885,11 @@ const getPost = async (postId) => {
22614
22885
  const client = getActiveClient();
22615
22886
  client.log('post/getPost', postId);
22616
22887
  isInTombstone('post', postId);
22617
- let data;
22888
+ let payload;
22618
22889
  try {
22619
22890
  // API-FIX: endpoint should not be /list, parameters should be querystring.
22620
22891
  const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
22621
- data = response.data;
22892
+ payload = response.data;
22622
22893
  }
22623
22894
  catch (error) {
22624
22895
  if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
@@ -22626,6 +22897,7 @@ const getPost = async (postId) => {
22626
22897
  }
22627
22898
  throw error;
22628
22899
  }
22900
+ const data = prepareMembershipPayload(payload, 'communityUsers');
22629
22901
  const cachedAt = client.cache && Date.now();
22630
22902
  if (client.cache)
22631
22903
  ingestInCache(data, { cachedAt });
@@ -22635,6 +22907,7 @@ const getPost = async (postId) => {
22635
22907
  cachedAt,
22636
22908
  };
22637
22909
  };
22910
+ /* end_public_function */
22638
22911
  /**
22639
22912
  * ```js
22640
22913
  * import { getPost } from '@amityco/ts-sdk'
@@ -22662,6 +22935,9 @@ getPost.locally = (postId) => {
22662
22935
  };
22663
22936
  };
22664
22937
 
22938
+ /* begin_public_function
22939
+ id: post.create.text_post, post.create.image_post, post.create.file_post, post.create.video_post, post.create.poll_post, post.create.livestream_post, post.create.custom_post
22940
+ */
22665
22941
  /**
22666
22942
  * ```js
22667
22943
  * import { createPost } from '@amityco/ts-sdk'
@@ -22688,18 +22964,23 @@ const createPost = async (bundle) => {
22688
22964
  // eslint-disable-next-line no-param-reassign
22689
22965
  delete bundle.dataType;
22690
22966
  }
22691
- const { data } = await client.http.post('/api/v4/posts', bundle);
22967
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
22968
+ fireEvent('post.created', payload);
22969
+ const data = prepareMembershipPayload(payload, 'communityUsers');
22692
22970
  const cachedAt = client.cache && Date.now();
22693
22971
  if (client.cache)
22694
22972
  ingestInCache(data, { cachedAt });
22695
- fireEvent('post.created', data);
22696
22973
  const { posts } = data;
22697
22974
  return {
22698
22975
  data: posts[0],
22699
22976
  cachedAt,
22700
22977
  };
22701
- };
22978
+ };
22979
+ /* end_public_function */
22702
22980
 
22981
+ /* begin_public_function
22982
+ id: post.edit
22983
+ */
22703
22984
  /**
22704
22985
  * ```js
22705
22986
  * import { updatePost } from '@amityco/ts-sdk'
@@ -22720,7 +23001,8 @@ const createPost = async (bundle) => {
22720
23001
  const updatePost = async (postId, patch) => {
22721
23002
  const client = getActiveClient();
22722
23003
  client.log('user/updatePost', patch);
22723
- const { data } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
23004
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
23005
+ const data = prepareMembershipPayload(payload, 'communityUsers');
22724
23006
  const cachedAt = client.cache && Date.now();
22725
23007
  if (client.cache)
22726
23008
  ingestInCache(data, { cachedAt });
@@ -22730,7 +23012,8 @@ const updatePost = async (postId, patch) => {
22730
23012
  data: posts.find(post => post.postId === postId),
22731
23013
  cachedAt,
22732
23014
  };
22733
- };
23015
+ };
23016
+ /* end_public_function */
22734
23017
 
22735
23018
  const getMatchPostSetting = (value) => {
22736
23019
  var _a;
@@ -22738,27 +23021,27 @@ const getMatchPostSetting = (value) => {
22738
23021
  CommunityPostSettingMaps[key].needApprovalOnPostCreation &&
22739
23022
  value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost)) !== null && _a !== void 0 ? _a : DefaultCommunityPostSetting;
22740
23023
  };
22741
- /*
22742
- * Unpack community payload by mapping payload field to postSetting value.
22743
- */
22744
- const unpackCommunityPayload = (_a) => {
22745
- var { communities } = _a, restPayload = __rest(_a, ["communities"]);
22746
- return (Object.assign({ communities: communities.map((_a) => {
22747
- var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
22748
- return (Object.assign({ postSetting: getMatchPostSetting({
22749
- needApprovalOnPostCreation,
22750
- onlyAdminCanPost,
22751
- }) }, restCommunityPayload));
22752
- }) }, restPayload));
23024
+ const prepareCommunityPayload = (rawPayload) => {
23025
+ // Unpack community payload by mapping payload field to postSetting value.
23026
+ const communities = rawPayload.communities.map((_a) => {
23027
+ var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
23028
+ return (Object.assign({ postSetting: getMatchPostSetting({
23029
+ needApprovalOnPostCreation,
23030
+ onlyAdminCanPost,
23031
+ }) }, restCommunityPayload));
23032
+ });
23033
+ const communityUsers = withUsers(rawPayload.communityUsers);
23034
+ return Object.assign(Object.assign({}, rawPayload), { communities,
23035
+ communityUsers });
22753
23036
  };
22754
- /*
22755
- * Repack community payload by mapping postSetting to the actual value.
22756
- */
22757
- const packCommunityPayload = (_a) => {
22758
- var { postSetting = undefined } = _a, restParam = __rest(_a, ["postSetting"]);
22759
- return (Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)));
23037
+ const prepareCommunityRequest = (params) => {
23038
+ const { postSetting = undefined } = params, restParam = __rest(params, ["postSetting"]);
23039
+ return Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined));
22760
23040
  };
22761
23041
 
23042
+ /* begin_public_function
23043
+ id: community.query
23044
+ */
22762
23045
  /**
22763
23046
  * ```js
22764
23047
  * import { queryCommunities } from '@amityco/ts-sdk'
@@ -22789,7 +23072,7 @@ const queryCommunities = async (query) => {
22789
23072
  } }),
22790
23073
  });
22791
23074
  const { paging } = data, payload = __rest(data, ["paging"]);
22792
- const unpackedPayload = unpackCommunityPayload(payload);
23075
+ const unpackedPayload = prepareCommunityPayload(payload);
22793
23076
  const { communities } = unpackedPayload;
22794
23077
  const cachedAt = client.cache && Date.now();
22795
23078
  if (client.cache) {
@@ -22805,6 +23088,7 @@ const queryCommunities = async (query) => {
22805
23088
  const prevPage = toPage(paging.previous);
22806
23089
  return { data: communities, cachedAt, prevPage, nextPage };
22807
23090
  };
23091
+ /* end_public_function */
22808
23092
  /**
22809
23093
  * ```js
22810
23094
  * import { queryCommunities } from '@amityco/ts-sdk'
@@ -22845,7 +23129,7 @@ const getCommunities = async (communityIds) => {
22845
23129
  const { data: payload } = await client.http.get(`/api/v3/communities/list`, {
22846
23130
  params: { communityIds },
22847
23131
  });
22848
- const data = unpackCommunityPayload(payload);
23132
+ const data = prepareCommunityPayload(payload);
22849
23133
  const cachedAt = client.cache && Date.now();
22850
23134
  if (client.cache)
22851
23135
  ingestInCache(data, { cachedAt });
@@ -22886,6 +23170,9 @@ getCommunities.locally = (communityIds) => {
22886
23170
  };
22887
23171
  };
22888
23172
 
23173
+ /* begin_public_function
23174
+ id: community.get
23175
+ */
22889
23176
  /**
22890
23177
  * ```js
22891
23178
  * import { getCommunity } from '@amityco/ts-sdk'
@@ -22905,7 +23192,7 @@ const getCommunity = async (communityId) => {
22905
23192
  client.log('community/getCommunity', communityId);
22906
23193
  // API-FIX: endpoint should not be /list, parameters should be querystring.
22907
23194
  const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
22908
- const data = unpackCommunityPayload(payload);
23195
+ const data = prepareCommunityPayload(payload);
22909
23196
  const cachedAt = client.cache && Date.now();
22910
23197
  if (client.cache)
22911
23198
  ingestInCache(data, { cachedAt });
@@ -22915,6 +23202,7 @@ const getCommunity = async (communityId) => {
22915
23202
  cachedAt,
22916
23203
  };
22917
23204
  };
23205
+ /* end_public_function */
22918
23206
  /**
22919
23207
  * ```js
22920
23208
  * import { getCommunity } from '@amityco/ts-sdk'
@@ -22942,6 +23230,9 @@ getCommunity.locally = (communityId) => {
22942
23230
  };
22943
23231
  };
22944
23232
 
23233
+ /* begin_public_function
23234
+ id: community.create
23235
+ */
22945
23236
  /**
22946
23237
  * ```js
22947
23238
  * import { createCommunity } from '@amityco/ts-sdk'
@@ -22959,19 +23250,23 @@ getCommunity.locally = (communityId) => {
22959
23250
  const createCommunity = async (bundle) => {
22960
23251
  const client = getActiveClient();
22961
23252
  client.log('user/createCommunity', bundle);
22962
- const { data: payload } = await client.http.post('/api/v3/communities/', packCommunityPayload(bundle));
22963
- const data = unpackCommunityPayload(payload);
23253
+ const { data: payload } = await client.http.post('/api/v3/communities/', prepareCommunityRequest(bundle));
23254
+ fireEvent('community.created', payload);
23255
+ const data = prepareCommunityPayload(payload);
22964
23256
  const cachedAt = client.cache && Date.now();
22965
23257
  if (client.cache)
22966
23258
  ingestInCache(data, { cachedAt });
22967
- fireEvent('community.created', data);
22968
23259
  const { communities } = data;
22969
23260
  return {
22970
23261
  data: communities[0],
22971
23262
  cachedAt,
22972
23263
  };
22973
- };
23264
+ };
23265
+ /* end_public_function */
22974
23266
 
23267
+ /* begin_public_function
23268
+ id: community.update
23269
+ */
22975
23270
  /**
22976
23271
  * ```js
22977
23272
  * import { updateCommunity } from '@amityco/ts-sdk'
@@ -22990,19 +23285,23 @@ const createCommunity = async (bundle) => {
22990
23285
  const updateCommunity = async (communityId, patch) => {
22991
23286
  const client = getActiveClient();
22992
23287
  client.log('community/updateCommunity', communityId, patch);
22993
- const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}`, packCommunityPayload(patch));
22994
- const data = unpackCommunityPayload(payload);
23288
+ const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}`, prepareCommunityRequest(patch));
23289
+ fireEvent('community.updated', payload);
23290
+ const data = prepareCommunityPayload(payload);
22995
23291
  const cachedAt = client.cache && Date.now();
22996
23292
  if (client.cache)
22997
23293
  ingestInCache(data, { cachedAt });
22998
- fireEvent('community.updated', data);
22999
23294
  const { communities } = data;
23000
23295
  return {
23001
23296
  data: communities.find(community => community.communityId === communityId),
23002
23297
  cachedAt,
23003
23298
  };
23004
- };
23299
+ };
23300
+ /* end_public_function */
23005
23301
 
23302
+ /* begin_public_function
23303
+ id: community.delete
23304
+ */
23006
23305
  /**
23007
23306
  * ```js
23008
23307
  * import { deleteCommunity } from '@amityco/ts-sdk'
@@ -23023,10 +23322,21 @@ const deleteCommunity = async (communityId) => {
23023
23322
  // API-FIX: This endpoint has not been implemented yet.
23024
23323
  await client.http.delete(`/api/v3/communities/${communityId}`);
23025
23324
  const deleted = await getCommunity(communityId);
23026
- fireEvent('community.deleted', { communities: [deleted.data] });
23325
+ fireEvent('community.deleted', {
23326
+ communities: [deleted.data],
23327
+ categories: [],
23328
+ communityUsers: [],
23329
+ feeds: [],
23330
+ files: [],
23331
+ users: [],
23332
+ });
23027
23333
  return deleted.data;
23028
- };
23334
+ };
23335
+ /* end_public_function */
23029
23336
 
23337
+ /* begin_public_function
23338
+ id: community.join
23339
+ */
23030
23340
  /**
23031
23341
  * ```js
23032
23342
  * import { joinCommunity } from '@amityco/ts-sdk'
@@ -23044,15 +23354,20 @@ const deleteCommunity = async (communityId) => {
23044
23354
  const joinCommunity = async (communityId) => {
23045
23355
  const client = getActiveClient();
23046
23356
  client.log('community/joinCommunity', communityId);
23047
- const { data } = await client.http.post(`/api/v3/communities/${communityId}/join`);
23357
+ const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/join`);
23358
+ fireEvent('community.joined', payload);
23359
+ const data = prepareCommunityPayload(payload);
23048
23360
  const cachedAt = client.cache && Date.now();
23049
23361
  if (client.cache)
23050
23362
  ingestInCache(data, { cachedAt });
23051
- fireEvent('community.joined', data);
23052
23363
  const { communityUsers } = data;
23053
23364
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
23054
- };
23365
+ };
23366
+ /* end_public_function */
23055
23367
 
23368
+ /* begin_public_function
23369
+ id: community.leave
23370
+ */
23056
23371
  /**
23057
23372
  * ```js
23058
23373
  * import { leaveCommunity } from '@amityco/ts-sdk'
@@ -23070,67 +23385,20 @@ const joinCommunity = async (communityId) => {
23070
23385
  const leaveCommunity = async (communityId) => {
23071
23386
  const client = getActiveClient();
23072
23387
  client.log('community/leaveCommunity', communityId);
23073
- const { data } = await client.http.delete(`/api/v3/communities/${communityId}/leave`);
23388
+ const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/leave`);
23389
+ fireEvent('community.left', payload);
23390
+ const data = prepareCommunityPayload(payload);
23074
23391
  const cachedAt = client.cache && Date.now();
23075
23392
  if (client.cache)
23076
23393
  ingestInCache(data, { cachedAt });
23077
- fireEvent('community.left', data);
23078
23394
  const { communityUsers } = data;
23079
23395
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
23080
- };
23081
-
23082
- /**
23083
- * Attach user object to membership model
23084
- * - If cache is not enabled, set user to undefined ({..., user: undefined})
23085
- * - If user object is not found in cache, set user to undefined
23086
- * ({..., user: undefined})
23087
- * - If a user is found in the cache, it attaches the user from the cache
23088
- * ({..., user: { userId, displayName,... }})
23089
- *
23090
- * @param member The membership model object
23091
- * @param userIdProp The user ID prop name of membership object
23092
- * @param userProp The user prop name of destination object
23093
- * @returns The membership model object that is already mapped to user
23094
- * @hidden
23095
- */
23096
- const withUser = (member, userIdProp = 'userId', userProp = 'user') => (Object.assign({ get [userProp]() {
23097
- var _a;
23098
- const client = getActiveClient();
23099
- if (!client.cache)
23100
- return undefined;
23101
- const userCache = (_a = pullFromCache(['user', 'get', member[userIdProp]])) === null || _a === void 0 ? void 0 : _a.data;
23102
- if (!userCache) {
23103
- return undefined;
23104
- }
23105
- return userCache;
23106
- } }, member));
23107
- /**
23108
- * Mapping membership model with user object
23109
- *
23110
- * @param members The membership model objects
23111
- * @param userIdProp The user ID prop name of membership object
23112
- * @param userProp The user prop name of destination object
23113
- * @returns The membership model objects that is already
23114
- * mapped to users
23115
- * @hidden
23116
- */
23117
- const withUsers = (members, userIdProp = 'userId', userProp = 'user') => members.map(member => withUser(member, userIdProp, userProp));
23118
- /**
23119
- * Transform members prop in any payload with attached users members
23120
- *
23121
- * @param payload The payload contain members prop
23122
- * @param memberProp A name of members prop
23123
- * @param userIdProp The user ID prop name of membership object
23124
- * @param userProp The user prop name of destination object
23125
- * @returns The transforming payload
23126
- * @hidden
23127
- */
23128
- const prepareMembershipPayload = (payload, memberProp, userIdProp = 'userId', userProp = 'user') => {
23129
- const _a = payload, _b = memberProp, memberPayload = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
23130
- const members = withUsers(memberPayload, userIdProp, userProp);
23131
- return Object.assign(Object.assign({}, rest), { [memberProp]: members });
23132
- };
23396
+ };
23397
+ /* end_public_function */
23133
23398
 
23399
+ /* begin_public_function
23400
+ id: community.membership.query
23401
+ */
23134
23402
  /**
23135
23403
  * ```js
23136
23404
  * import { queryCommunityMembers } from '@amityco/ts-sdk'
@@ -23174,6 +23442,7 @@ const queryCommunityMembers = async (query) => {
23174
23442
  const prevPage = toPage(paging.previous);
23175
23443
  return { data: communityUsers, cachedAt, nextPage, prevPage };
23176
23444
  };
23445
+ /* end_public_function */
23177
23446
  /**
23178
23447
  * ```js
23179
23448
  * import { queryCommunityMembers } from '@amityco/ts-sdk'
@@ -23213,6 +23482,9 @@ queryCommunityMembers.locally = (query) => {
23213
23482
  : undefined;
23214
23483
  };
23215
23484
 
23485
+ /* begin_public_function
23486
+ id: community.membership.add_members
23487
+ */
23216
23488
  /**
23217
23489
  * ```js
23218
23490
  * import { addCommunityMembers } from '@amityco/ts-sdk'
@@ -23231,14 +23503,19 @@ queryCommunityMembers.locally = (query) => {
23231
23503
  const addCommunityMembers = async (communityId, userIds) => {
23232
23504
  const client = getActiveClient();
23233
23505
  client.log('community/addCommunityMembers', communityId, userIds);
23234
- const { data } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
23506
+ const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
23507
+ fireEvent('community.userAdded', payload);
23508
+ const data = prepareMembershipPayload(payload, 'communityUsers');
23235
23509
  if (client.cache)
23236
23510
  ingestInCache(data);
23237
- fireEvent('community.userAdded', data);
23238
23511
  const { communityUsers } = data;
23239
23512
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
23240
- };
23513
+ };
23514
+ /* end_public_function */
23241
23515
 
23516
+ /* begin_public_function
23517
+ id: community.membership.remove_member
23518
+ */
23242
23519
  /**
23243
23520
  * ```js
23244
23521
  * import { removeCommunityMembers } from '@amityco/ts-sdk'
@@ -23257,14 +23534,19 @@ const addCommunityMembers = async (communityId, userIds) => {
23257
23534
  const removeCommunityMembers = async (communityId, userIds) => {
23258
23535
  const client = getActiveClient();
23259
23536
  client.log('community/removeCommunityMembers', communityId, userIds);
23260
- const { data } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
23537
+ const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
23538
+ fireEvent('community.userRemoved', payload);
23539
+ const data = prepareMembershipPayload(payload, 'communityUsers');
23261
23540
  if (client.cache)
23262
23541
  ingestInCache(data);
23263
- fireEvent('community.userRemoved', data);
23264
23542
  const { communityUsers } = data;
23265
23543
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
23266
- };
23544
+ };
23545
+ /* end_public_function */
23267
23546
 
23547
+ /* begin_public_function
23548
+ id: community.moderation.add_roles
23549
+ */
23268
23550
  /**
23269
23551
  * ```js
23270
23552
  * import { addCommunityMembersRoles } from '@amityco/ts-sdk'
@@ -23275,7 +23557,7 @@ const removeCommunityMembers = async (communityId, userIds) => {
23275
23557
  *
23276
23558
  * @param communityId The ID of the {@link Amity.Community} to perform
23277
23559
  * @param roleIds Array of IDs of the {@link Amity.Role} to apply
23278
- * @param userId Array of IDs of the {@link Amity.User} to perform
23560
+ * @param userIds Array of IDs of the {@link Amity.User} to perform
23279
23561
  * @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
23280
23562
  *
23281
23563
  * @category Community API
@@ -23284,14 +23566,19 @@ const removeCommunityMembers = async (communityId, userIds) => {
23284
23566
  const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
23285
23567
  const client = getActiveClient();
23286
23568
  client.log('community/addCommunityMembersRoles', communityId, roleIds, userIds);
23287
- const { data } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
23569
+ const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
23570
+ const data = prepareMembershipPayload(payload, 'communityUsers');
23288
23571
  if (client.cache)
23289
23572
  ingestInCache(data);
23290
23573
  const { communityUsers } = data;
23291
23574
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
23292
23575
  roleIds.some(role => communityUser.roles.includes(role)));
23293
- };
23576
+ };
23577
+ /* end_public_function */
23294
23578
 
23579
+ /* begin_public_function
23580
+ id: community.moderation.remove_roles
23581
+ */
23295
23582
  /**
23296
23583
  * ```js
23297
23584
  * import { removeCommunityMembersRoles } from '@amityco/ts-sdk'
@@ -23302,7 +23589,7 @@ const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
23302
23589
  *
23303
23590
  * @param communityId The ID of the {@link Amity.Community} to perform
23304
23591
  * @param roleIds Array of IDs of the {@link Amity.Role} to apply
23305
- * @param userId Array of IDs of the {@link Amity.User} to perform
23592
+ * @param userIds Array of IDs of the {@link Amity.User} to perform
23306
23593
  * @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
23307
23594
  *
23308
23595
  * @category Community API
@@ -23311,14 +23598,19 @@ const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
23311
23598
  const removeCommunityMembersRoles = async (communityId, roleIds, userIds) => {
23312
23599
  const client = getActiveClient();
23313
23600
  client.log('community/removeCommunityMembersRoles', communityId, roleIds, userIds);
23314
- const { data } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
23601
+ const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
23602
+ const data = prepareMembershipPayload(payload, 'communityUsers');
23315
23603
  if (client.cache)
23316
23604
  ingestInCache(data);
23317
23605
  const { communityUsers } = data;
23318
23606
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
23319
23607
  !roleIds.some(role => communityUser.roles.includes(role)));
23320
- };
23608
+ };
23609
+ /* end_public_function */
23321
23610
 
23611
+ /* begin_public_function
23612
+ id: community.query.trending_communities
23613
+ */
23322
23614
  /**
23323
23615
  * ```js
23324
23616
  * import { getTopTrendingCommunities } from '@amityco/ts-sdk'
@@ -23340,7 +23632,7 @@ const getTopTrendingCommunities = async (query) => {
23340
23632
  // API-FIX: backend doesnt answer Amity.Response
23341
23633
  // const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
23342
23634
  const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
23343
- const data = unpackCommunityPayload(payload);
23635
+ const data = prepareCommunityPayload(payload);
23344
23636
  const { communities } = data;
23345
23637
  const cachedAt = client.cache && Date.now();
23346
23638
  if (client.cache) {
@@ -23350,6 +23642,7 @@ const getTopTrendingCommunities = async (query) => {
23350
23642
  }
23351
23643
  return { data: communities, cachedAt };
23352
23644
  };
23645
+ /* end_public_function */
23353
23646
  /**
23354
23647
  * ```js
23355
23648
  * import { getTopTrendingCommunities } from '@amityco/ts-sdk'
@@ -23383,6 +23676,9 @@ getTopTrendingCommunities.locally = (query) => {
23383
23676
  : undefined;
23384
23677
  };
23385
23678
 
23679
+ /* begin_public_function
23680
+ id: community.query.recommended_communities
23681
+ */
23386
23682
  /**
23387
23683
  * ```js
23388
23684
  * import { getRecommendedCommunities } from '@amityco/ts-sdk'
@@ -23404,7 +23700,7 @@ const getRecommendedCommunities = async (query) => {
23404
23700
  // API-FIX: backend doesnt answer Amity.Response
23405
23701
  // const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
23406
23702
  const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
23407
- const data = unpackCommunityPayload(payload);
23703
+ const data = prepareCommunityPayload(payload);
23408
23704
  const { communities } = data;
23409
23705
  const cachedAt = client.cache && Date.now();
23410
23706
  if (client.cache) {
@@ -23414,6 +23710,7 @@ const getRecommendedCommunities = async (query) => {
23414
23710
  }
23415
23711
  return { data: communities, cachedAt };
23416
23712
  };
23713
+ /* end_public_function */
23417
23714
  /**
23418
23715
  * ```js
23419
23716
  * import { getRecommendedCommunities } from '@amityco/ts-sdk'
@@ -23447,6 +23744,9 @@ getRecommendedCommunities.locally = (query) => {
23447
23744
  : undefined;
23448
23745
  };
23449
23746
 
23747
+ /* begin_public_function
23748
+ id: post.soft_delete, post.hard_delete
23749
+ */
23450
23750
  /**
23451
23751
  * ```js
23452
23752
  * import { deletePost } from '@amityco/ts-sdk'
@@ -23478,11 +23778,28 @@ const deletePost = async (postId, permanent = false) => {
23478
23778
  // later when realtime events covers that for us.
23479
23779
  if (post.data.targetType === 'community') {
23480
23780
  const community = await getCommunity(post.data.targetId);
23481
- fireEvent('community.updated', { communities: [community.data] });
23781
+ fireEvent('community.updated', {
23782
+ communities: [community.data],
23783
+ categories: [],
23784
+ communityUsers: [],
23785
+ feeds: [],
23786
+ files: [],
23787
+ users: [],
23788
+ });
23482
23789
  }
23483
23790
  // to support hard deletion
23484
23791
  const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
23485
- fireEvent('post.deleted', { posts: [deleted] });
23792
+ fireEvent('post.deleted', {
23793
+ posts: [deleted],
23794
+ categories: [],
23795
+ comments: [],
23796
+ communities: [],
23797
+ communityUsers: [],
23798
+ feeds: [],
23799
+ files: [],
23800
+ postChildren: [],
23801
+ users: [],
23802
+ });
23486
23803
  if (permanent) {
23487
23804
  setTimeout(() => {
23488
23805
  pushToTombstone('post', postId);
@@ -23492,8 +23809,12 @@ const deletePost = async (postId, permanent = false) => {
23492
23809
  upsertInCache(['post', 'get', postId], { isDeleted: true });
23493
23810
  }
23494
23811
  return deleted;
23495
- };
23812
+ };
23813
+ /* end_public_function */
23496
23814
 
23815
+ /* begin_public_function
23816
+ id: post.approve
23817
+ */
23497
23818
  /**
23498
23819
  * ```js
23499
23820
  * import { approvePost } from '@amityco/ts-sdk'
@@ -23510,26 +23831,28 @@ const deletePost = async (postId, permanent = false) => {
23510
23831
  * @async
23511
23832
  */
23512
23833
  const approvePost = async (postId) => {
23513
- var _a;
23514
23834
  const client = getActiveClient();
23515
23835
  client.log('post/approvePost', postId);
23516
- const { data: approved } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
23517
- const cachedAt = client.cache && Date.now();
23518
- if (client.cache)
23519
- ingestInCache(approved, { cachedAt });
23836
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
23837
+ fireEvent('post.approved', payload);
23520
23838
  // fire virtual event for community update
23521
- if (approved.posts[0].targetType === 'community') {
23522
- const community = (_a = approved.communities) === null || _a === void 0 ? void 0 : _a[0];
23523
- // @ts-ignore as communities is optional currently in PostPayload
23524
- fireEvent('community.updated', { communities: [community] });
23839
+ if (payload.posts[0].targetType === 'community') {
23840
+ fireEvent('community.updated', payload);
23525
23841
  }
23526
- fireEvent('post.approved', { posts: [approved.posts[0]] });
23842
+ const data = prepareMembershipPayload(payload, 'communityUsers');
23843
+ const cachedAt = client.cache && Date.now();
23844
+ if (client.cache)
23845
+ ingestInCache(data, { cachedAt });
23527
23846
  return {
23528
- data: approved.posts.find(post => post.postId === postId),
23847
+ data: data.posts.find(post => post.postId === postId),
23529
23848
  cachedAt,
23530
23849
  };
23531
- };
23850
+ };
23851
+ /* end_public_function */
23532
23852
 
23853
+ /* begin_public_function
23854
+ id: post.decline
23855
+ */
23533
23856
  /**
23534
23857
  * ```js
23535
23858
  * import { declinePost } from '@amityco/ts-sdk'
@@ -23546,26 +23869,28 @@ const approvePost = async (postId) => {
23546
23869
  * @async
23547
23870
  */
23548
23871
  const declinePost = async (postId) => {
23549
- var _a;
23550
23872
  const client = getActiveClient();
23551
23873
  client.log('post/declinePost', postId);
23552
- const { data: declined } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
23553
- const cachedAt = client.cache && Date.now();
23554
- if (client.cache)
23555
- ingestInCache(declined, { cachedAt });
23874
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
23556
23875
  // fire virtual event
23557
- if (declined.posts[0].targetType === 'community') {
23558
- const community = (_a = declined.communities) === null || _a === void 0 ? void 0 : _a[0];
23559
- // @ts-ignore as communities is optional currently in PostPayload
23560
- fireEvent('community.updated', { communities: [community] });
23876
+ if (payload.posts[0].targetType === 'community') {
23877
+ fireEvent('community.updated', payload);
23561
23878
  }
23562
- fireEvent('post.declined', { posts: [declined.posts[0]] });
23879
+ fireEvent('post.declined', payload);
23880
+ const data = prepareMembershipPayload(payload, 'communityUsers');
23881
+ const cachedAt = client.cache && Date.now();
23882
+ if (client.cache)
23883
+ ingestInCache(data, { cachedAt });
23563
23884
  return {
23564
- data: declined.posts.find(post => post.postId === postId),
23885
+ data: payload.posts.find(post => post.postId === postId),
23565
23886
  cachedAt,
23566
23887
  };
23567
- };
23888
+ };
23889
+ /* end_public_function */
23568
23890
 
23891
+ /* begin_public_function
23892
+ id: comment.query
23893
+ */
23569
23894
  /**
23570
23895
  * ```js
23571
23896
  * import { queryComments } from '@amityco/ts-sdk'
@@ -23615,6 +23940,7 @@ const queryComments = async (query) => {
23615
23940
  const prevPage = toPage(paging.previous);
23616
23941
  return { data: comments, cachedAt, prevPage, nextPage };
23617
23942
  };
23943
+ /* end_public_function */
23618
23944
  /**
23619
23945
  * ```js
23620
23946
  * import { queryComments } from '@amityco/ts-sdk'
@@ -23650,6 +23976,9 @@ queryComments.locally = (query) => {
23650
23976
  : undefined;
23651
23977
  };
23652
23978
 
23979
+ /* begin_public_function
23980
+ id: comment.get_by_ids
23981
+ */
23653
23982
  /**
23654
23983
  * ```js
23655
23984
  * import { getComments } from '@amityco/ts-sdk'
@@ -23680,6 +24009,7 @@ const getComments = async (commentIds) => {
23680
24009
  cachedAt,
23681
24010
  };
23682
24011
  };
24012
+ /* end_public_function */
23683
24013
  /**
23684
24014
  * ```js
23685
24015
  * import { getComments } from '@amityco/ts-sdk'
@@ -23712,6 +24042,9 @@ getComments.locally = (commentIds) => {
23712
24042
  };
23713
24043
  };
23714
24044
 
24045
+ /* begin_public_function
24046
+ id: comment.get
24047
+ */
23715
24048
  /**
23716
24049
  * ```js
23717
24050
  * import { getComment } from '@amityco/ts-sdk'
@@ -23751,6 +24084,7 @@ const getComment = async (commentId) => {
23751
24084
  cachedAt,
23752
24085
  };
23753
24086
  };
24087
+ /* end_public_function */
23754
24088
  /**
23755
24089
  * ```js
23756
24090
  * import { getComment } from '@amityco/ts-sdk'
@@ -23778,6 +24112,9 @@ getComment.locally = (commentId) => {
23778
24112
  };
23779
24113
  };
23780
24114
 
24115
+ /* begin_public_function
24116
+ id: comment.create
24117
+ */
23781
24118
  /**
23782
24119
  * ```js
23783
24120
  * import { createComment } from '@amityco/ts-sdk'
@@ -23800,15 +24137,29 @@ const createComment = async (bundle) => {
23800
24137
  if (client.cache)
23801
24138
  ingestInCache(data, { cachedAt });
23802
24139
  const post = await getPost(bundle.referenceId);
23803
- fireEvent('post.updated', { posts: [post.data] });
24140
+ fireEvent('post.updated', {
24141
+ posts: [post.data],
24142
+ categories: [],
24143
+ comments: [],
24144
+ communities: [],
24145
+ communityUsers: [],
24146
+ feeds: [],
24147
+ files: [],
24148
+ postChildren: [],
24149
+ users: [],
24150
+ });
23804
24151
  fireEvent('comment.created', data);
23805
24152
  const { comments } = data;
23806
24153
  return {
23807
24154
  data: comments[0],
23808
24155
  cachedAt,
23809
24156
  };
23810
- };
24157
+ };
24158
+ /* end_public_function */
23811
24159
 
24160
+ /* begin_public_function
24161
+ id: comment.update_comment
24162
+ */
23812
24163
  /**
23813
24164
  * ```js
23814
24165
  * import { updateComment } from '@amityco/ts-sdk'
@@ -23839,8 +24190,12 @@ const updateComment = async (commentId, patch) => {
23839
24190
  data: comments.find(comment => comment.commentId === commentId),
23840
24191
  cachedAt,
23841
24192
  };
23842
- };
24193
+ };
24194
+ /* end_public_function */
23843
24195
 
24196
+ /* begin_public_function
24197
+ id: comment.soft_delete, comment.hard_delete
24198
+ */
23844
24199
  /**
23845
24200
  * ```js
23846
24201
  * import { deleteComment } from '@amityco/ts-sdk'
@@ -23869,8 +24224,23 @@ const deleteComment = async (commentId, permanent = false) => {
23869
24224
  // to support hard deletion
23870
24225
  const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
23871
24226
  const post = await getPost(comment.data.referenceId);
23872
- fireEvent('post.updated', { posts: [post.data] });
23873
- fireEvent('comment.deleted', { comments: [deleted] });
24227
+ fireEvent('post.updated', {
24228
+ posts: [post.data],
24229
+ categories: [],
24230
+ comments: [],
24231
+ communities: [],
24232
+ communityUsers: [],
24233
+ feeds: [],
24234
+ files: [],
24235
+ postChildren: [],
24236
+ users: [],
24237
+ });
24238
+ fireEvent('comment.deleted', {
24239
+ comments: [deleted],
24240
+ commentChildren: [],
24241
+ files: [],
24242
+ users: [],
24243
+ });
23874
24244
  if (permanent) {
23875
24245
  scheduleTask(() => pushToTombstone('comment', commentId));
23876
24246
  }
@@ -23878,7 +24248,8 @@ const deleteComment = async (commentId, permanent = false) => {
23878
24248
  upsertInCache(['comment', 'get', commentId], { isDeleted: true });
23879
24249
  }
23880
24250
  return deleted;
23881
- };
24251
+ };
24252
+ /* end_public_function */
23882
24253
 
23883
24254
  /** @hidden */
23884
24255
  const preparePayloadForCache = (event, payload) => {
@@ -23918,6 +24289,9 @@ const preparePayloadForCache = (event, payload) => {
23918
24289
  }
23919
24290
  };
23920
24291
 
24292
+ /* begin_public_function
24293
+ id: reaction.add
24294
+ */
23921
24295
  /**
23922
24296
  * ```js
23923
24297
  * import { addReaction } from '@amityco/ts-sdk'
@@ -23958,6 +24332,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
23958
24332
  }
23959
24333
  return true;
23960
24334
  };
24335
+ /* end_public_function */
23961
24336
  /**
23962
24337
  * ```js
23963
24338
  * import { addReaction } from '@amityco/ts-sdk'
@@ -23998,6 +24373,9 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
23998
24373
  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;
23999
24374
  };
24000
24375
 
24376
+ /* begin_public_function
24377
+ id: reaction.remove
24378
+ */
24001
24379
  /**
24002
24380
  * ```js
24003
24381
  * import { deleteReaction } from '@amityco/ts-sdk'
@@ -24040,6 +24418,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
24040
24418
  }
24041
24419
  return true;
24042
24420
  };
24421
+ /* end_public_function */
24043
24422
  /**
24044
24423
  * ```js
24045
24424
  * import { removeReaction } from '@amityco/ts-sdk'
@@ -24080,6 +24459,9 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
24080
24459
  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;
24081
24460
  };
24082
24461
 
24462
+ /* begin_public_function
24463
+ id: reaction.query
24464
+ */
24083
24465
  /**
24084
24466
  * ```js
24085
24467
  * import { queryReactions } from '@amityco/ts-sdk'
@@ -24108,11 +24490,14 @@ const queryReactions = async (query) => {
24108
24490
  });
24109
24491
  const { paging } = data, payload = __rest(data, ["paging"]);
24110
24492
  const { reactions } = payload;
24493
+ // FIXME: correct reactions type in model
24494
+ // @ts-ignore
24111
24495
  ingestInCache(Object.assign(Object.assign({}, payload), { reactions: reactions[0].reactors }));
24112
24496
  const nextPage = toPageRaw(paging.next);
24113
24497
  const prevPage = toPageRaw(paging.previous);
24114
24498
  return { data: reactions, prevPage, nextPage };
24115
- };
24499
+ };
24500
+ /* end_public_function */
24116
24501
 
24117
24502
  const createPostEventSubscriber = (event, callback) => {
24118
24503
  const client = getActiveClient();
@@ -24123,9 +24508,17 @@ const createPostEventSubscriber = (event, callback) => {
24123
24508
  }
24124
24509
  else {
24125
24510
  const { communities } = payload, others = __rest(payload, ["communities"]);
24126
- ingestInCache(others);
24511
+ const data = prepareMembershipPayload(others, 'communityUsers');
24512
+ ingestInCache(data);
24127
24513
  if ((communities === null || communities === void 0 ? void 0 : communities[0]) && !['post.updated'].includes(event)) {
24128
- fireEvent('community.updated', { communities });
24514
+ fireEvent('community.updated', {
24515
+ communities,
24516
+ categories: [],
24517
+ communityUsers: [],
24518
+ feeds: [],
24519
+ files: [],
24520
+ users: [],
24521
+ });
24129
24522
  }
24130
24523
  const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
24131
24524
  if (['post.created', 'post.approved', 'post.declined'].includes(event)) {
@@ -24642,6 +25035,8 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
24642
25035
  if (eventName !== 'add')
24643
25036
  return;
24644
25037
  ingestInCache(payload);
25038
+ // FIXME: correct reactions type in model
25039
+ // @ts-ignore
24645
25040
  ingestInCache({ reactions: [reactor] });
24646
25041
  callbackWrapper('message', payload.messages[0].messageId, reactor);
24647
25042
  };
@@ -24651,6 +25046,8 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
24651
25046
  const filter = (payload) => {
24652
25047
  const { reactor } = payload, rest = __rest(payload, ["reactor"]);
24653
25048
  ingestInCache(rest);
25049
+ // FIXME: correct reactions type in model
25050
+ // @ts-ignore
24654
25051
  ingestInCache({ reactions: [reactor] });
24655
25052
  callbackWrapper('post', payload.posts[0].postId, reactor);
24656
25053
  };
@@ -24659,6 +25056,8 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
24659
25056
  const filter = (payload) => {
24660
25057
  const { reactor } = payload, rest = __rest(payload, ["reactor"]);
24661
25058
  ingestInCache(rest);
25059
+ // FIXME: correct reactions type in model
25060
+ // @ts-ignore
24662
25061
  ingestInCache({ reactions: [reactor] });
24663
25062
  callbackWrapper('comment', payload.comments[0].commentId, reactor);
24664
25063
  };
@@ -24698,6 +25097,8 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
24698
25097
  if (eventName !== 'remove')
24699
25098
  return;
24700
25099
  ingestInCache(payload);
25100
+ // FIXME: correct reactions type in model
25101
+ // @ts-ignore
24701
25102
  ingestInCache({ reactions: [reactor] });
24702
25103
  callbackWrapper('message', payload.messages[0].messageId, reactor);
24703
25104
  };
@@ -24707,6 +25108,8 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
24707
25108
  const filter = (payload) => {
24708
25109
  const { reactor } = payload, rest = __rest(payload, ["reactor"]);
24709
25110
  ingestInCache(rest);
25111
+ // FIXME: correct reactions type in model
25112
+ // @ts-ignore
24710
25113
  ingestInCache({ reactions: [reactor] });
24711
25114
  callbackWrapper('post', payload.posts[0].postId, reactor);
24712
25115
  };
@@ -24715,6 +25118,8 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
24715
25118
  const filter = (payload) => {
24716
25119
  const { reactor } = payload, rest = __rest(payload, ["reactor"]);
24717
25120
  ingestInCache(rest);
25121
+ // FIXME: correct reactions type in model
25122
+ // @ts-ignore
24718
25123
  ingestInCache({ reactions: [reactor] });
24719
25124
  callbackWrapper('comment', payload.comments[0].commentId, reactor);
24720
25125
  };
@@ -24839,6 +25244,9 @@ var REFERENCE_TYPES = {
24839
25244
  },
24840
25245
  };
24841
25246
 
25247
+ /* begin_public_function
25248
+ id: user.flag, message.flag, post.flag, comment.flag
25249
+ */
24842
25250
  /**
24843
25251
  * ```js
24844
25252
  * import { createReport } from '@amityco/ts-sdk'
@@ -24865,19 +25273,26 @@ const createReport = async (referenceType, referenceId) => {
24865
25273
  const { domainName } = REFERENCE_TYPES[referenceType];
24866
25274
  return `/api/v3/${domainName}/${encodeURIComponent(referenceId)}/flag`;
24867
25275
  };
24868
- const { data } = await client.http.post(getAPIUrl());
24869
- if (client.cache)
24870
- ingestInCache(referenceType === 'message' ? prepareMessagePayload(data) : data);
24871
- if (referenceType === 'message') {
24872
- fireEvent('message.flagged', data);
24873
- }
24874
- else {
24875
- // @ts-ignore
24876
- fireEvent(`${referenceType}.flagged`, data);
25276
+ const { data: payload } = await client.http.post(getAPIUrl());
25277
+ if (client.cache) {
25278
+ if (referenceType === 'message') {
25279
+ ingestInCache(prepareMessagePayload(payload));
25280
+ }
25281
+ else if (referenceType === 'post') {
25282
+ ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
25283
+ }
25284
+ else {
25285
+ ingestInCache(payload);
25286
+ }
24877
25287
  }
24878
- return !!data;
24879
- };
25288
+ fireEvent(`${referenceType}.flagged`, payload);
25289
+ return !!payload;
25290
+ };
25291
+ /* end_public_function */
24880
25292
 
25293
+ /* begin_public_function
25294
+ id: user.unflag, message.unflag, post.unflag, comment.unflag
25295
+ */
24881
25296
  /**
24882
25297
  * ```js
24883
25298
  * import { deleteReport } from '@amityco/ts-sdk'
@@ -24904,19 +25319,27 @@ const deleteReport = async (referenceType, referenceId) => {
24904
25319
  const { domainName } = REFERENCE_TYPES[referenceType];
24905
25320
  return `/api/v3/${domainName}/${encodeURIComponent(referenceId)}/unflag`;
24906
25321
  };
24907
- const { data } = await client.http.delete(getAPIUrl());
24908
- if (client.cache)
24909
- ingestInCache(referenceType === 'message' ? prepareMessagePayload(data) : data);
24910
- if (referenceType === 'message') {
24911
- fireEvent('message.unflagged', data);
24912
- }
24913
- else {
24914
- // @ts-ignore
24915
- fireEvent(`${referenceType}.unflagged`, data);
25322
+ const { data: payload } = await client.http.delete(getAPIUrl());
25323
+ if (client.cache) {
25324
+ if (referenceType === 'message') {
25325
+ ingestInCache(prepareMessagePayload(payload));
25326
+ }
25327
+ else if (referenceType === 'post') {
25328
+ ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
25329
+ }
25330
+ else {
25331
+ ingestInCache(payload);
25332
+ }
24916
25333
  }
24917
- return !!data;
24918
- };
25334
+ // @ts-ignore
25335
+ fireEvent(`${referenceType}.unflagged`, payload);
25336
+ return !!payload;
25337
+ };
25338
+ /* end_public_function */
24919
25339
 
25340
+ /* begin_public_function
25341
+ id: user.check_flag_by_me, message.check_flag_by_me, post.check_flag_by_me, comment.check_flag_by_me
25342
+ */
24920
25343
  /**
24921
25344
  * ```js
24922
25345
  * import { isReportedByMe } from '@amityco/ts-sdk'
@@ -24943,7 +25366,8 @@ const isReportedByMe = async (referenceType, referenceId) => {
24943
25366
  [primaryKey]: referenceId,
24944
25367
  }))) !== null && _a !== void 0 ? _a : {};
24945
25368
  return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
24946
- };
25369
+ };
25370
+ /* end_public_function */
24947
25371
 
24948
25372
  function convertFromRaw$1(_a, params) {
24949
25373
  var { _id } = _a, rest = __rest(_a, ["_id"]);
@@ -24972,11 +25396,15 @@ function getSegmentParams(rawChannel) {
24972
25396
  localLastMentionSegment: 0,
24973
25397
  };
24974
25398
  }
24975
- const prepareChannelPayload = (payload) => {
24976
- const channels = payload.channels.map(channel => convertFromRaw$1(channel, getSegmentParams(channel)));
24977
- return Object.assign(Object.assign({}, payload), { channels });
25399
+ const prepareChannelPayload = (rawPayload) => {
25400
+ const channels = rawPayload.channels.map(channel => convertFromRaw$1(channel, getSegmentParams(channel)));
25401
+ const channelUsers = withUsers(rawPayload.channelUsers);
25402
+ return Object.assign(Object.assign({}, rawPayload), { channels, channelUsers });
24978
25403
  };
24979
25404
 
25405
+ /* begin_public_function
25406
+ id: channel.query
25407
+ */
24980
25408
  /**
24981
25409
  * ```js
24982
25410
  * import { queryChannels } from '@amityco/ts-sdk'
@@ -25022,6 +25450,7 @@ const queryChannels = async (query) => {
25022
25450
  const prevPage = toPage(paging.previous);
25023
25451
  return { data: channels, cachedAt, prevPage, nextPage };
25024
25452
  };
25453
+ /* end_public_function */
25025
25454
  /**
25026
25455
  * ```js
25027
25456
  * import { queryChannels } from '@amityco/ts-sdk'
@@ -25119,6 +25548,9 @@ getChannels.locally = (channelIds) => {
25119
25548
  };
25120
25549
  };
25121
25550
 
25551
+ /* begin_public_function
25552
+ id: channel.get
25553
+ */
25122
25554
  /**
25123
25555
  * ```js
25124
25556
  * import { getChannel } from '@amityco/ts-sdk'
@@ -25157,6 +25589,7 @@ const getChannel = async (channelId) => {
25157
25589
  cachedAt,
25158
25590
  };
25159
25591
  };
25592
+ /* end_public_function */
25160
25593
  /**
25161
25594
  * ```js
25162
25595
  * import { getChannel } from '@amityco/ts-sdk'
@@ -25184,6 +25617,9 @@ getChannel.locally = (channelId) => {
25184
25617
  };
25185
25618
  };
25186
25619
 
25620
+ /* begin_public_function
25621
+ id: channel.create
25622
+ */
25187
25623
  /**
25188
25624
  * ```js
25189
25625
  * import { createChannel } from '@amityco/ts-sdk'
@@ -25217,8 +25653,12 @@ const createChannel = async (bundle) => {
25217
25653
  data: channels[0],
25218
25654
  cachedAt,
25219
25655
  };
25220
- };
25656
+ };
25657
+ /* end_public_function */
25221
25658
 
25659
+ /* begin_public_function
25660
+ id: channel.update
25661
+ */
25222
25662
  /**
25223
25663
  * ```js
25224
25664
  * import { updateChannel } from '@amityco/ts-sdk'
@@ -25247,7 +25687,8 @@ const updateChannel = async (channelId, patch) => {
25247
25687
  data: channels.find(channel => channel.channelId === channelId),
25248
25688
  cachedAt,
25249
25689
  };
25250
- };
25690
+ };
25691
+ /* end_public_function */
25251
25692
 
25252
25693
  /**
25253
25694
  * ```js
@@ -25272,6 +25713,9 @@ const deleteChannel = async (channelId) => {
25272
25713
  return deleted.data;
25273
25714
  };
25274
25715
 
25716
+ /* begin_public_function
25717
+ id: channel.join
25718
+ */
25275
25719
  /**
25276
25720
  * ```js
25277
25721
  * import { joinChannel } from '@amityco/ts-sdk'
@@ -25295,8 +25739,12 @@ const joinChannel = async (channelId) => {
25295
25739
  ingestInCache(data);
25296
25740
  const { channelUsers } = data;
25297
25741
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
25298
- };
25742
+ };
25743
+ /* end_public_function */
25299
25744
 
25745
+ /* begin_public_function
25746
+ id: channel.leave
25747
+ */
25300
25748
  /**
25301
25749
  * ```js
25302
25750
  * import { leaveChannel } from '@amityco/ts-sdk'
@@ -25320,8 +25768,12 @@ const leaveChannel = async (channelId) => {
25320
25768
  ingestInCache(data);
25321
25769
  const { channelUsers } = data;
25322
25770
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership !== 'member');
25323
- };
25771
+ };
25772
+ /* end_public_function */
25324
25773
 
25774
+ /* begin_public_function
25775
+ id: channel.member.query, channel.member.search
25776
+ */
25325
25777
  /**
25326
25778
  * ```js
25327
25779
  * import { queryChannelMembers } from '@amityco/ts-sdk'
@@ -25346,8 +25798,7 @@ const queryChannelMembers = async (query) => {
25346
25798
  } }),
25347
25799
  });
25348
25800
  const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
25349
- const channelPayload = prepareChannelPayload(payload);
25350
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
25801
+ const preparedPayload = prepareChannelPayload(payload);
25351
25802
  const { channelUsers } = preparedPayload;
25352
25803
  const cachedAt = client.cache && Date.now();
25353
25804
  if (client.cache) {
@@ -25371,6 +25822,7 @@ const queryChannelMembers = async (query) => {
25371
25822
  prevPage,
25372
25823
  };
25373
25824
  };
25825
+ /* end_public_function */
25374
25826
  /**
25375
25827
  * ```js
25376
25828
  * import { queryChannelMembers } from '@amityco/ts-sdk'
@@ -25411,6 +25863,9 @@ queryChannelMembers.locally = (query) => {
25411
25863
  : undefined;
25412
25864
  };
25413
25865
 
25866
+ /* begin_public_function
25867
+ id: channel.member.add
25868
+ */
25414
25869
  /**
25415
25870
  * ```js
25416
25871
  * import { addChannelMembers } from '@amityco/ts-sdk'
@@ -25430,17 +25885,21 @@ const addChannelMembers = async (channelId, userIds) => {
25430
25885
  const client = getActiveClient();
25431
25886
  client.log('channel/addChannelMembers', channelId, userIds);
25432
25887
  const { data: payload } = await client.http.post(`/api/v3/channels/${encodeURIComponent(channelId)}/users`, { channelId, userIds });
25433
- const data = prepareChannelPayload(payload);
25434
- if (client.cache)
25435
- ingestInCache(data);
25436
25888
  /*
25437
25889
  * should fire event for each user that was added
25438
25890
  */
25439
- userIds.forEach(id => fireEvent('channel.membersAdded', Object.assign(Object.assign({}, payload), { channelUsers: data.channelUsers.filter(u => u.userId === id) })));
25891
+ userIds.forEach(id => fireEvent('channel.membersAdded', Object.assign(Object.assign({}, payload), { channelUsers: payload.channelUsers.filter(u => u.userId === id) })));
25892
+ const data = prepareChannelPayload(payload);
25893
+ if (client.cache)
25894
+ ingestInCache(data);
25440
25895
  const { channelUsers } = data;
25441
25896
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
25442
- };
25897
+ };
25898
+ /* end_public_function */
25443
25899
 
25900
+ /* begin_public_function
25901
+ id: channel.member.remove
25902
+ */
25444
25903
  /**
25445
25904
  * ```js
25446
25905
  * import { removeChannelMembers } from '@amityco/ts-sdk'
@@ -25460,17 +25919,21 @@ const removeChannelMembers = async (channelId, userIds) => {
25460
25919
  const client = getActiveClient();
25461
25920
  client.log('channel/removeChannelMembers', channelId, userIds);
25462
25921
  const { data: payload } = await client.http.delete(`/api/v3/channels/${encodeURIComponent(channelId)}/users`, { data: { channelId, userIds } });
25463
- const data = prepareChannelPayload(payload);
25464
- if (client.cache)
25465
- ingestInCache(data);
25466
25922
  /*
25467
25923
  * should fire event for each user that was removed
25468
25924
  */
25469
- userIds.forEach(id => fireEvent('channel.membersRemoved', Object.assign(Object.assign({}, payload), { channelUsers: data.channelUsers.filter(u => u.userId === id) })));
25925
+ userIds.forEach(id => fireEvent('channel.membersRemoved', Object.assign(Object.assign({}, payload), { channelUsers: payload.channelUsers.filter(u => u.userId === id) })));
25926
+ const data = prepareChannelPayload(payload);
25927
+ if (client.cache)
25928
+ ingestInCache(data);
25470
25929
  const { channelUsers } = data;
25471
25930
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership !== 'member');
25472
- };
25931
+ };
25932
+ /* end_public_function */
25473
25933
 
25934
+ /* begin_public_function
25935
+ id: channel.moderation.add_roles
25936
+ */
25474
25937
  /**
25475
25938
  * ```js
25476
25939
  * import { addChannelMembersRole } from '@amityco/ts-sdk'
@@ -25496,8 +25959,12 @@ const addChannelMembersRole = async (channelId, roleId, userIds) => {
25496
25959
  ingestInCache(data);
25497
25960
  const { channelUsers } = data;
25498
25961
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.roles.includes(roleId));
25499
- };
25962
+ };
25963
+ /* end_public_function */
25500
25964
 
25965
+ /* begin_public_function
25966
+ id: channel.moderation.remove_roles
25967
+ */
25501
25968
  /**
25502
25969
  * ```js
25503
25970
  * import { removeChannelMembersRole } from '@amityco/ts-sdk'
@@ -25508,7 +25975,7 @@ const addChannelMembersRole = async (channelId, roleId, userIds) => {
25508
25975
  *
25509
25976
  * @param channelId The ID of the {@link Amity.Channel} to perform
25510
25977
  * @param roleId The ID of the {@link Amity.Role} to apply
25511
- * @param userId Array of IDs of the {@link Amity.User} to perform
25978
+ * @param userIds Array of IDs of the {@link Amity.User} to perform
25512
25979
  * @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Channel}
25513
25980
  *
25514
25981
  * @category Channel API
@@ -25523,8 +25990,12 @@ const removeChannelMembersRole = async (channelId, roleId, userIds) => {
25523
25990
  ingestInCache(data);
25524
25991
  const { channelUsers } = data;
25525
25992
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && !channelUser.roles.includes(roleId));
25526
- };
25993
+ };
25994
+ /* end_public_function */
25527
25995
 
25996
+ /* begin_public_function
25997
+ id: channel.moderation.ban_members
25998
+ */
25528
25999
  /**
25529
26000
  * ```js
25530
26001
  * import { banChannelMembers } from '@amityco/ts-sdk'
@@ -25545,8 +26016,7 @@ const banChannelMembers = async (channelId, userIds) => {
25545
26016
  const { data: payload } = await client.http.put(`/api/v3/channels/${channelId}/users/ban`, {
25546
26017
  userIds,
25547
26018
  });
25548
- const channelPayload = prepareChannelPayload(payload);
25549
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26019
+ const preparedPayload = prepareChannelPayload(payload);
25550
26020
  const { channelUsers } = preparedPayload;
25551
26021
  const cachedAt = client.cache && Date.now();
25552
26022
  if (client.cache)
@@ -25555,8 +26025,12 @@ const banChannelMembers = async (channelId, userIds) => {
25555
26025
  data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'banned'),
25556
26026
  cachedAt,
25557
26027
  };
25558
- };
26028
+ };
26029
+ /* end_public_function */
25559
26030
 
26031
+ /* begin_public_function
26032
+ id: channel.moderation.unban_members
26033
+ */
25560
26034
  /**
25561
26035
  * ```js
25562
26036
  * import { unbanChannelMembers } from '@amityco/ts-sdk'
@@ -25577,8 +26051,7 @@ const unbanChannelMembers = async (channelId, userIds) => {
25577
26051
  const { data: payload } = await client.http.put(`/api/v3/channels/${encodeURIComponent(channelId)}/users/unban`, {
25578
26052
  userIds,
25579
26053
  });
25580
- const channelPayload = prepareChannelPayload(payload);
25581
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26054
+ const preparedPayload = prepareChannelPayload(payload);
25582
26055
  const cachedAt = client.cache && Date.now();
25583
26056
  if (client.cache)
25584
26057
  ingestInCache(preparedPayload, { cachedAt });
@@ -25587,8 +26060,12 @@ const unbanChannelMembers = async (channelId, userIds) => {
25587
26060
  data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'member'),
25588
26061
  cachedAt,
25589
26062
  };
25590
- };
26063
+ };
26064
+ /* end_public_function */
25591
26065
 
26066
+ /* begin_public_function
26067
+ id: channel.start_reading
26068
+ */
25592
26069
  /**
25593
26070
  * ```js
25594
26071
  * import { startReading } from '@amityco/ts-sdk'
@@ -25597,9 +26074,9 @@ const unbanChannelMembers = async (channelId, userIds) => {
25597
26074
  *
25598
26075
  * Mark all messages as read and start reading message inside channel
25599
26076
  *
25600
- * @param {string} subChannelId - The channel ID to start reading.
25601
- * @param {string} userId - The user ID of channel member.
25602
- * @return {Promise<boolean>>} A success boolean if the channel reading of the sub channel had begun.
26077
+ * @param subChannelId - The channel ID to start reading.
26078
+ * @param userId - The user ID of channel member.
26079
+ * @return A success boolean if the channel reading of the sub channel had begun.
25603
26080
  *
25604
26081
  * @category Message API
25605
26082
  * @async
@@ -25625,8 +26102,12 @@ const startReading = async (subChannelId, userId = getActiveClient().userId) =>
25625
26102
  channelId,
25626
26103
  });
25627
26104
  return !!result;
25628
- };
26105
+ };
26106
+ /* end_public_function */
25629
26107
 
26108
+ /* begin_public_function
26109
+ id: channel.stop_reading
26110
+ */
25630
26111
  /**
25631
26112
  * ```js
25632
26113
  * import { stopReading } from '@amityco/ts-sdk'
@@ -25635,8 +26116,8 @@ const startReading = async (subChannelId, userId = getActiveClient().userId) =>
25635
26116
  *
25636
26117
  * Stop reading message inside channel
25637
26118
  *
25638
- * @param {string} subChannelId - The channel ID to stop reading.
25639
- * @return {Promise<boolean>>} A success boolean if the sub channel reading was halted.
26119
+ * @param subChannelId - The channel ID to stop reading.
26120
+ * @return A success boolean if the sub channel reading was halted.
25640
26121
  *
25641
26122
  * @category Message API
25642
26123
  * @async
@@ -25661,7 +26142,8 @@ const stopReading = async (subChannelId) => {
25661
26142
  channelId,
25662
26143
  });
25663
26144
  return !!result;
25664
- };
26145
+ };
26146
+ /* end_public_function */
25665
26147
 
25666
26148
  /**
25667
26149
  * ```js
@@ -25762,8 +26244,7 @@ const onChannelDeleted = (callback) => {
25762
26244
  const onChannelJoined = (callback) => {
25763
26245
  const client = getActiveClient();
25764
26246
  const filter = (payload) => {
25765
- const channelPayload = prepareChannelPayload(payload);
25766
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26247
+ const preparedPayload = prepareChannelPayload(payload);
25767
26248
  const { channels, channelUsers } = preparedPayload;
25768
26249
  ingestInCache(preparedPayload);
25769
26250
  callback(channels[0], channelUsers[0]);
@@ -25789,8 +26270,7 @@ const onChannelJoined = (callback) => {
25789
26270
  const onChannelLeft = (callback) => {
25790
26271
  const client = getActiveClient();
25791
26272
  const filter = (payload) => {
25792
- const channelPayload = prepareChannelPayload(payload);
25793
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26273
+ const preparedPayload = prepareChannelPayload(payload);
25794
26274
  const { channels, channelUsers } = preparedPayload;
25795
26275
  ingestInCache(preparedPayload);
25796
26276
  callback(channels[0], channelUsers[0]);
@@ -25841,8 +26321,7 @@ const onChannelMuted = (callback) => {
25841
26321
  const onChannelMemberAdded = (callback) => {
25842
26322
  const client = getActiveClient();
25843
26323
  const filter = (payload) => {
25844
- const channelPayload = prepareChannelPayload(payload);
25845
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26324
+ const preparedPayload = prepareChannelPayload(payload);
25846
26325
  const { channels, channelUsers } = preparedPayload;
25847
26326
  ingestInCache(preparedPayload);
25848
26327
  callback(channels[0], channelUsers.find(cu => cu.membership === 'member'));
@@ -25868,8 +26347,7 @@ const onChannelMemberAdded = (callback) => {
25868
26347
  const onChannelMemberRemoved = (callback) => {
25869
26348
  const client = getActiveClient();
25870
26349
  const filter = (payload) => {
25871
- const channelPayload = prepareChannelPayload(payload);
25872
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26350
+ const preparedPayload = prepareChannelPayload(payload);
25873
26351
  const { channels, channelUsers } = preparedPayload;
25874
26352
  ingestInCache(preparedPayload);
25875
26353
  callback(channels[0], channelUsers[0]);
@@ -25895,8 +26373,7 @@ const onChannelMemberRemoved = (callback) => {
25895
26373
  const onChannelMemberBanned = (callback) => {
25896
26374
  const client = getActiveClient();
25897
26375
  const filter = (payload) => {
25898
- const channelPayload = prepareChannelPayload(payload);
25899
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26376
+ const preparedPayload = prepareChannelPayload(payload);
25900
26377
  const { channels, channelUsers } = preparedPayload;
25901
26378
  ingestInCache(preparedPayload);
25902
26379
  callback(channels[0], channelUsers.find(cu => cu.membership === 'banned'));
@@ -25922,8 +26399,7 @@ const onChannelMemberBanned = (callback) => {
25922
26399
  const onChannelMemberUnbanned = (callback) => {
25923
26400
  const client = getActiveClient();
25924
26401
  const filter = (payload) => {
25925
- const channelPayload = prepareChannelPayload(payload);
25926
- const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
26402
+ const preparedPayload = prepareChannelPayload(payload);
25927
26403
  const { channels, channelUsers } = preparedPayload;
25928
26404
  ingestInCache(preparedPayload);
25929
26405
  callback(channels[0], channelUsers.find(cu => cu.membership === 'none'));
@@ -26355,22 +26831,29 @@ const liveChannels = (params, callback, config) => {
26355
26831
  if (params.membership && userId) {
26356
26832
  channels = filterByChannelMembership(channels, params.membership, userId);
26357
26833
  }
26358
- const sortBy = params.sortBy || 'lastCreated';
26359
- if (sortBy === 'lastCreated' || sortBy === 'firstCreated') {
26360
- channels = channels.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
26361
- }
26362
- /*
26363
- * The server returns channels with empty | null displayName's first before
26364
- * returning sorted list of channels with displayNames
26365
- *
26366
- * This section needs to be updated as displayNames can be null as well
26367
- */
26368
- if (sortBy === 'displayName') {
26369
- channels = channels
26370
- // this needs to be aligned with the backend data type
26371
- .map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
26372
- // @ts-ignore
26373
- .sort(sortByDisplayName);
26834
+ switch (params.sortBy) {
26835
+ case 'firstCreated':
26836
+ channels = channels.sort(sortByFirstCreated);
26837
+ break;
26838
+ case 'lastCreated':
26839
+ channels = channels.sort(sortByLastCreated);
26840
+ break;
26841
+ case 'displayName':
26842
+ /*
26843
+ * The server returns channels with empty | null displayName's first before
26844
+ * returning sorted list of channels with displayNames
26845
+ *
26846
+ * This section needs to be updated as displayNames can be null as well
26847
+ */
26848
+ channels = channels
26849
+ // this needs to be aligned with the backend data type
26850
+ .map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
26851
+ // @ts-ignore
26852
+ .sort(sortByDisplayName);
26853
+ break;
26854
+ default:
26855
+ channels = channels.sort(sortByLastActivity);
26856
+ break;
26374
26857
  }
26375
26858
  callback({
26376
26859
  onNextPage: onFetch,
@@ -26380,17 +26863,12 @@ const liveChannels = (params, callback, config) => {
26380
26863
  error: data.error,
26381
26864
  });
26382
26865
  };
26383
- const realtimeRouter = (action) => (channel) => {
26866
+ const realtimeRouter = (_) => (channel) => {
26384
26867
  var _a;
26385
26868
  const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26386
26869
  if (!collection)
26387
26870
  return;
26388
- if (action === 'onDelete' && params.isDeleted === false) {
26389
- collection.data = collection.data.filter(c => c !== channel.channelId);
26390
- }
26391
- else {
26392
- collection.data = [...new Set([channel.channelId, ...collection.data])];
26393
- }
26871
+ collection.data = [...new Set([channel.channelId, ...collection.data])];
26394
26872
  pushToCache(cacheKey, collection);
26395
26873
  responder(collection);
26396
26874
  };
@@ -26415,7 +26893,7 @@ const liveChannels = (params, callback, config) => {
26415
26893
  responder(data);
26416
26894
  }, queryOptions(policy));
26417
26895
  };
26418
- disposers.push(onChannelCreated(realtimeRouter('onCreate')), onChannelDeleted(realtimeRouter('onDelete')), onChannelUpdated(realtimeRouter('onUpdate')), onChannelMuted(realtimeRouter('onMute')), onChannelJoined(realtimeRouter('onJoin')), onChannelLeft(realtimeRouter('onLeft')), onChannelMemberAdded(realtimeRouter('onMemberAdded')), onChannelMemberRemoved(realtimeRouter('onMemberRemoved')), onMessageCreated(() => null));
26896
+ disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
26419
26897
  onFetch();
26420
26898
  return () => {
26421
26899
  log(`liveChannels(tmpid: ${timestamp}) > dispose`);
@@ -26557,6 +27035,9 @@ function convertQueryParams(_a) {
26557
27035
  return out;
26558
27036
  }
26559
27037
 
27038
+ /* begin_public_function
27039
+ id: subchannel.query
27040
+ */
26560
27041
  /**
26561
27042
  * ```js
26562
27043
  * import { querySubChannels } from '@amityco/ts-sdk'
@@ -26598,6 +27079,7 @@ const querySubChannels = async (query) => {
26598
27079
  const prevPage = toPage(paging.previous);
26599
27080
  return { data: subChannels, cachedAt, prevPage, nextPage };
26600
27081
  };
27082
+ /* end_public_function */
26601
27083
  /**
26602
27084
  * ```js
26603
27085
  * import { querySubChannels } from '@amityco/ts-sdk'
@@ -26698,6 +27180,9 @@ getSubChannels.locally = (subChannelIds) => {
26698
27180
  };
26699
27181
  };
26700
27182
 
27183
+ /* begin_public_function
27184
+ id: subchannel.get
27185
+ */
26701
27186
  /**
26702
27187
  * ```js
26703
27188
  * import { getSubChannel } from '@amityco/ts-sdk'
@@ -26735,6 +27220,7 @@ const getSubChannel = async (subChannelId) => {
26735
27220
  throw error;
26736
27221
  }
26737
27222
  };
27223
+ /* end_public_function */
26738
27224
  /**
26739
27225
  * ```js
26740
27226
  * import { getSubChannel } from '@amityco/ts-sdk'
@@ -26762,6 +27248,9 @@ getSubChannel.locally = (subChannelId) => {
26762
27248
  };
26763
27249
  };
26764
27250
 
27251
+ /* begin_public_function
27252
+ id: subchannel.create
27253
+ */
26765
27254
  /**
26766
27255
  * ```js
26767
27256
  * import { createSubChannel } from '@amityco/ts-sdk'
@@ -26792,8 +27281,12 @@ const createSubChannel = async (bundle) => {
26792
27281
  data: data.messageFeeds[0],
26793
27282
  cachedAt,
26794
27283
  };
26795
- };
27284
+ };
27285
+ /* end_public_function */
26796
27286
 
27287
+ /* begin_public_function
27288
+ id: subchannel.update
27289
+ */
26797
27290
  /**
26798
27291
  * ```js
26799
27292
  * import { updateSubChannel } from '@amityco/ts-sdk'
@@ -26822,8 +27315,12 @@ const updateSubChannel = async (subChannelId, patch) => {
26822
27315
  data: data.messageFeeds[0],
26823
27316
  cachedAt,
26824
27317
  };
26825
- };
27318
+ };
27319
+ /* end_public_function */
26826
27320
 
27321
+ /* begin_public_function
27322
+ id: subchannel.soft_delete, subchannel.hard_delete
27323
+ */
26827
27324
  /**
26828
27325
  * ```js
26829
27326
  * import { deleteSubChannel } from '@amityco/ts-sdk'
@@ -26854,7 +27351,8 @@ const deleteSubChannel = async (subChannelId, permanent = false) => {
26854
27351
  }
26855
27352
  fireEvent('local.message-feed.deleted', { messageFeeds: [deleted] });
26856
27353
  return deleted;
26857
- };
27354
+ };
27355
+ /* end_public_function */
26858
27356
 
26859
27357
  /**
26860
27358
  * ```js
@@ -27180,7 +27678,7 @@ const liveMessages = (params, callback, config) => {
27180
27678
  if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
27181
27679
  return;
27182
27680
  const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (_e = (_d = collection === null || collection === void 0 ? void 0 : collection.params) === null || _d === void 0 ? void 0 : _d.page) !== null && _e !== void 0 ? _e : { limit } }));
27183
- runQuery(query, ({ data: result, error, loading, prevPage: page }) => {
27681
+ runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
27184
27682
  const data = {
27185
27683
  loading,
27186
27684
  error,
@@ -27290,7 +27788,7 @@ const observeMessages = (subChannelId, callback) => {
27290
27788
  const createCommunityEventSubscriber = (event, callback) => {
27291
27789
  const client = getActiveClient();
27292
27790
  const filter = (payload) => {
27293
- const unpackedPayload = unpackCommunityPayload(payload);
27791
+ const unpackedPayload = prepareCommunityPayload(payload);
27294
27792
  if (!client.cache) {
27295
27793
  // TODO: here we are missing specific properties here!
27296
27794
  callback(unpackedPayload.communities[0]);
@@ -27360,10 +27858,8 @@ function getEventRelatedMember(event, payload) {
27360
27858
  const createCommunityMemberEventSubscriber = (event, callback) => {
27361
27859
  const client = getActiveClient();
27362
27860
  const filter = (payload) => {
27363
- const communityPayload = unpackCommunityPayload(payload);
27364
- const { communities } = communityPayload;
27365
- const preparedPayload = prepareMembershipPayload(communityPayload, 'communityUsers');
27366
- const { communityUsers } = preparedPayload;
27861
+ const preparedPayload = prepareCommunityPayload(payload);
27862
+ const { communities, communityUsers } = preparedPayload;
27367
27863
  /*
27368
27864
  * community.isJoined is not part of the communityMembership payload, and needs
27369
27865
  * to be calculated based on the communityMembership value
@@ -27562,6 +28058,40 @@ const onCommunityUserBanned = (callback) => createCommunityMemberEventSubscriber
27562
28058
  */
27563
28059
  const onCommunityUserUnbanned = (callback) => createCommunityMemberEventSubscriber('community.userUnbanned', callback);
27564
28060
 
28061
+ /**
28062
+ * ```js
28063
+ * import { onCommunityUserRoleAdded } from '@amityco/ts-sdk'
28064
+ * const dispose = onCommunityUserRoleAdded((community, member) => {
28065
+ * // ...
28066
+ * })
28067
+ * ```
28068
+ *
28069
+ * Fired when a role has been added to {@link Amity.CommunityUser}
28070
+ *
28071
+ * @param callback The function to call when the event was fired
28072
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
28073
+ *
28074
+ * @category Community Events
28075
+ */
28076
+ const onCommunityUserRoleAdded = (callback) => createCommunityMemberEventSubscriber('community.roleAdded', callback);
28077
+
28078
+ /**
28079
+ * ```js
28080
+ * import { onCommunityUserRoleRemoved } from '@amityco/ts-sdk'
28081
+ * const dispose = onCommunityUserRoleRemoved((community, member) => {
28082
+ * // ...
28083
+ * })
28084
+ * ```
28085
+ *
28086
+ * Fired when a role has been removed from {@link Amity.CommunityUser}
28087
+ *
28088
+ * @param callback The function to call when the event was fired
28089
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
28090
+ *
28091
+ * @category Community Events
28092
+ */
28093
+ const onCommunityUserRoleRemoved = (callback) => createCommunityMemberEventSubscriber('community.roleRemoved', callback);
28094
+
27565
28095
  /**
27566
28096
  * ```js
27567
28097
  * import { observeCommunity } from '@amityco/ts-sdk'
@@ -27722,6 +28252,152 @@ const liveCommunities = (params, callback, config) => {
27722
28252
  };
27723
28253
  };
27724
28254
 
28255
+ /**
28256
+ * ```js
28257
+ * import { liveCommunity } from '@amityco/ts-sdk';
28258
+ *
28259
+ * let community;
28260
+ *
28261
+ * const unsubscribe = liveCommunity(communityId, response => {
28262
+ * community = response.data;
28263
+ * });
28264
+ * ```
28265
+ *
28266
+ * Observe all mutation on a given {@link Amity.Community}
28267
+ *
28268
+ * @param communityId the ID of the message to observe
28269
+ * @param callback the function to call when new data are available
28270
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the community
28271
+ *
28272
+ * @category Community Live Object
28273
+ */
28274
+ const liveCommunity = (communityId, callback) => {
28275
+ return liveObject(communityId, callback, 'communityId', getCommunity, [
28276
+ onCommunityUpdated,
28277
+ onCommunityDeleted,
28278
+ onCommunityJoined,
28279
+ onCommunityLeft,
28280
+ onCommunityUserBanned,
28281
+ onCommunityUserUnbanned,
28282
+ onCommunityUserChanged,
28283
+ ]);
28284
+ };
28285
+
28286
+ /**
28287
+ * ```js
28288
+ * import { liveCommunityMembers } from '@amityco/ts-sdk'
28289
+ *
28290
+ * let communityMembers = []
28291
+ * const unsub = liveCommunityMembers({
28292
+ * communityId: Amity.Community['communityId'],
28293
+ * }, response => merge(communityMembers, response.data))
28294
+ * ```
28295
+ *
28296
+ * Observe all mutations on a list of {@link Amity.CommunityUser}s
28297
+ *
28298
+ * @param params for querying community users
28299
+ * @param callback the function to call when new data are available
28300
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the community users
28301
+ *
28302
+ * @category Community Live Collection
28303
+ */
28304
+ const liveCommunityMembers = (params, callback, config) => {
28305
+ const { log, cache } = getActiveClient();
28306
+ if (!cache) {
28307
+ console.log(ENABLE_CACHE_MESSAGE);
28308
+ }
28309
+ const timestamp = Date.now();
28310
+ log(`liveCommunityMembers(tmpid: ${timestamp}) > listen`);
28311
+ const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
28312
+ const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
28313
+ const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
28314
+ const disposers = [];
28315
+ const cacheKey = ['communityUsers', 'collection', { communityId: params.communityId }];
28316
+ const responder = (data) => {
28317
+ var _a, _b;
28318
+ let communityMembers = (_a = data.data
28319
+ .map(id => pullFromCache(['communityUsers', 'get', id]))
28320
+ .filter(Boolean)
28321
+ .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
28322
+ if (params.roles)
28323
+ communityMembers = communityMembers.filter(c => { var _a; return (_a = c.roles) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.roles) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
28324
+ if (params.membership) {
28325
+ communityMembers = communityMembers.filter(({ communityMembership }) =>
28326
+ // @ts-ignore
28327
+ params.membership.includes(communityMembership));
28328
+ }
28329
+ if (params.search) {
28330
+ /*
28331
+ * Search by userId | displayName
28332
+ */
28333
+ const containsMatcher = new RegExp(params.search);
28334
+ communityMembers = communityMembers.filter(m => {
28335
+ var _a;
28336
+ if (m.userId.match(containsMatcher))
28337
+ return true;
28338
+ return m.user && ((_a = m.user.displayName) === null || _a === void 0 ? void 0 : _a.match(containsMatcher));
28339
+ });
28340
+ }
28341
+ const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
28342
+ communityMembers = communityMembers.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
28343
+ callback({
28344
+ onNextPage: onFetch,
28345
+ data: communityMembers,
28346
+ hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
28347
+ loading: data.loading,
28348
+ error: data.error,
28349
+ });
28350
+ };
28351
+ const realtimeRouter = (_) => (_, communityMember) => {
28352
+ var _a;
28353
+ if (params.communityId !== communityMember.communityId) {
28354
+ return;
28355
+ }
28356
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28357
+ if (!collection)
28358
+ return;
28359
+ const communityMemberCacheId = getResolver('communityUsers')({
28360
+ communityId: params.communityId,
28361
+ userId: communityMember.userId,
28362
+ });
28363
+ collection.data = [...new Set([communityMemberCacheId, ...collection.data])];
28364
+ pushToCache(cacheKey, collection);
28365
+ responder(collection);
28366
+ };
28367
+ const onFetch = () => {
28368
+ var _a, _b, _c;
28369
+ const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28370
+ const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
28371
+ if (communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
28372
+ return;
28373
+ const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
28374
+ runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
28375
+ const data = {
28376
+ loading,
28377
+ error,
28378
+ params: { page },
28379
+ data: communityMembers,
28380
+ };
28381
+ if (result) {
28382
+ data.data = [
28383
+ ...new Set([...communityMembers, ...result.map(getResolver('communityUsers'))]),
28384
+ ];
28385
+ }
28386
+ pushToCache(cacheKey, data);
28387
+ responder(data);
28388
+ }, queryOptions(policy));
28389
+ };
28390
+ disposers.push(onCommunityLeft(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityUserBanned(realtimeRouter()), onCommunityUserUnbanned(realtimeRouter()), onCommunityUserChanged(realtimeRouter()), onCommunityUserRoleAdded(realtimeRouter()), onCommunityUserRoleRemoved(realtimeRouter()));
28391
+ onFetch();
28392
+ return () => {
28393
+ log(`liveCommunityMembers(tmpid: ${timestamp}) > dispose`);
28394
+ disposers.forEach(fn => fn());
28395
+ };
28396
+ };
28397
+
28398
+ /* begin_public_function
28399
+ id: community.category.query
28400
+ */
27725
28401
  /**
27726
28402
  * ```js
27727
28403
  * import { queryCategories } from '@amityco/ts-sdk'
@@ -27940,6 +28616,9 @@ const liveCategories = (params, callback, config) => {
27940
28616
  };
27941
28617
  };
27942
28618
 
28619
+ /* begin_public_function
28620
+ id: feed.query.global_feed
28621
+ */
27943
28622
  /**
27944
28623
  * ```js
27945
28624
  * import { queryGlobalFeed } from '@amityco/ts-sdk'
@@ -27958,16 +28637,17 @@ const queryGlobalFeed = async (query) => {
27958
28637
  const client = getActiveClient();
27959
28638
  client.log('feed/queryGlobalFeed', query);
27960
28639
  const _a = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _a, params = __rest(_a, ["useCustomRanking", "page"]);
27961
- const { data } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
28640
+ const { data: queryPayload } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
27962
28641
  params: Object.assign(Object.assign({}, params), { options: {
27963
28642
  token: toToken(page, 'skiplimit'),
27964
28643
  } }),
27965
28644
  });
27966
- const { paging } = data, payload = __rest(data, ["paging"]);
27967
- const { posts } = payload;
28645
+ const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
28646
+ const data = prepareMembershipPayload(payload, 'communityUsers');
28647
+ const { posts } = data;
27968
28648
  const cachedAt = client.cache && Date.now();
27969
28649
  if (client.cache) {
27970
- ingestInCache(payload);
28650
+ ingestInCache(data);
27971
28651
  const cacheKey = [
27972
28652
  'globalFeed',
27973
28653
  'query',
@@ -27979,6 +28659,7 @@ const queryGlobalFeed = async (query) => {
27979
28659
  const prevPage = toPage(paging.previous);
27980
28660
  return { data: posts, cachedAt, prevPage, nextPage };
27981
28661
  };
28662
+ /* end_public_function */
27982
28663
  /**
27983
28664
  * ```js
27984
28665
  * import { queryGlobalFeed } from '@amityco/ts-sdk'
@@ -28069,6 +28750,9 @@ queryFollows.locally = (key, query) => {
28069
28750
  : undefined;
28070
28751
  };
28071
28752
 
28753
+ /* begin_public_function
28754
+ id: user.relationship.query_my_followers, user.relationship.query_followers
28755
+ */
28072
28756
  /**
28073
28757
  * ```js
28074
28758
  * import { queryFollowers } from '@amityco/ts-sdk'
@@ -28084,6 +28768,7 @@ queryFollows.locally = (key, query) => {
28084
28768
  * @async
28085
28769
  */
28086
28770
  const queryFollowers = async (query) => queryFollows('followers', query);
28771
+ /* end_public_function */
28087
28772
  /**
28088
28773
  * ```js
28089
28774
  * import { queryFollowers } from '@amityco/ts-sdk'
@@ -28099,6 +28784,9 @@ const queryFollowers = async (query) => queryFollows('followers', query);
28099
28784
  */
28100
28785
  queryFollowers.locally = (query) => queryFollows.locally('followers', query);
28101
28786
 
28787
+ /* begin_public_function
28788
+ id: user.relationship.query_my_followings, user.relationship.query_followings
28789
+ */
28102
28790
  /**
28103
28791
  * ```js
28104
28792
  * import { queryFollowings } from '@amityco/ts-sdk'
@@ -28114,6 +28802,7 @@ queryFollowers.locally = (query) => queryFollows.locally('followers', query);
28114
28802
  * @async
28115
28803
  */
28116
28804
  const queryFollowings = async (query) => queryFollows('following', query);
28805
+ /* end_public_function */
28117
28806
  /**
28118
28807
  * ```js
28119
28808
  * import { queryFollowings } from '@amityco/ts-sdk'
@@ -28134,6 +28823,9 @@ const getCacheKey = (userId) => [
28134
28823
  'get',
28135
28824
  `${getActiveClient().userId}#${userId}`,
28136
28825
  ];
28826
+ /* begin_public_function
28827
+ id: user.relationship.get_follow_info, user.relationship.get_my_follow_info
28828
+ */
28137
28829
  /**
28138
28830
  * ```js
28139
28831
  * import { getFollowInfo } from '@amityco/ts-sdk'
@@ -28164,6 +28856,7 @@ const getFollowInfo = async (userId) => {
28164
28856
  cachedAt,
28165
28857
  };
28166
28858
  };
28859
+ /* end_public_function */
28167
28860
  /**
28168
28861
  * ```js
28169
28862
  * import { getFollowInfo } from '@amityco/ts-sdk'
@@ -28193,6 +28886,9 @@ getFollowInfo.locally = (userId) => {
28193
28886
  };
28194
28887
  };
28195
28888
 
28889
+ /* begin_public_function
28890
+ id: user.relationship.follow
28891
+ */
28196
28892
  /**
28197
28893
  * ```js
28198
28894
  * import { follow } from '@amityco/ts-sdk'
@@ -28220,8 +28916,12 @@ const follow = async (userId) => {
28220
28916
  data: data.follows[0],
28221
28917
  cachedAt,
28222
28918
  };
28223
- };
28919
+ };
28920
+ /* end_public_function */
28224
28921
 
28922
+ /* begin_public_function
28923
+ id: user.relationship.unfollow
28924
+ */
28225
28925
  /**
28226
28926
  * ```js
28227
28927
  * import { unfollow } from '@amityco/ts-sdk'
@@ -28245,8 +28945,12 @@ const unfollow = async (userId) => {
28245
28945
  }
28246
28946
  fireEvent('follow.unfollowed', data);
28247
28947
  return true;
28248
- };
28948
+ };
28949
+ /* end_public_function */
28249
28950
 
28951
+ /* begin_public_function
28952
+ id: user.relationship.accept_follow
28953
+ */
28250
28954
  /**
28251
28955
  * ```js
28252
28956
  * import { acceptFollower } from '@amityco/ts-sdk'
@@ -28270,8 +28974,12 @@ const acceptFollower = async (userId) => {
28270
28974
  }
28271
28975
  fireEvent('follow.accepted', data);
28272
28976
  return true;
28273
- };
28977
+ };
28978
+ /* end_public_function */
28274
28979
 
28980
+ /* begin_public_function
28981
+ id: user.relationship.decline_follow
28982
+ */
28275
28983
  /**
28276
28984
  * ```js
28277
28985
  * import { declineFollower } from '@amityco/ts-sdk'
@@ -28295,7 +29003,8 @@ const declineFollower = async (userId) => {
28295
29003
  }
28296
29004
  fireEvent('follow.requestDeclined', data);
28297
29005
  return true;
28298
- };
29006
+ };
29007
+ /* end_public_function */
28299
29008
 
28300
29009
  const createFollowEventSubscriber = (event, callback) => {
28301
29010
  const client = getActiveClient();
@@ -28909,8 +29618,8 @@ const livePost = (postId, callback) => {
28909
29618
  *
28910
29619
  * Observe all mutations on a list of {@link Amity.Post} for a given target object
28911
29620
  *
28912
- * @param targetType the type of the target
28913
- * @param targetId the ID of the target
29621
+ * @param param.targetType the type of the target
29622
+ * @param param.targetId the ID of the target
28914
29623
  * @param callback the function to call when new data are available
28915
29624
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
28916
29625
  *
@@ -28944,6 +29653,9 @@ const livePosts = (params, callback, config) => {
28944
29653
  if (params.tags) {
28945
29654
  posts = posts.filter(p => { var _a; return (_a = p.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
28946
29655
  }
29656
+ if (params.targetType === 'community' && params.feedType) {
29657
+ posts = filterByFeedType(posts, params.feedType);
29658
+ }
28947
29659
  callback({
28948
29660
  onNextPage: onFetch,
28949
29661
  data: posts,
@@ -28957,27 +29669,16 @@ const livePosts = (params, callback, config) => {
28957
29669
  const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28958
29670
  if (params.targetId !== post.targetId || params.targetType !== post.targetType || !collection)
28959
29671
  return;
28960
- if (['onCreate', 'onApproved'].includes(action)) {
28961
- collection.data = [...new Set([post.postId, ...collection.data])];
28962
- }
28963
- else if (['onDelete', 'onDeclined'].includes(action)) {
28964
- collection.data = collection.data.filter(p => p !== post.postId);
28965
- /*
28966
- * if isDeleted is true, collection should add deleted items to the
28967
- * begining of the collection
28968
- */
28969
- if (params.isDeleted)
28970
- collection.data.unshift(post.postId);
28971
- }
28972
29672
  /*
28973
- * FIX-ME
28974
- * This is a shortcoming as the feed object is not saved to the cache.
28975
- * The responder should pull the feed from cache once available and should
28976
- * match the collection to feedType param
28977
- * https://ekoapp.atlassian.net/browse/ASC-9382
29673
+ * This is not ideal, but currently this is the only way to update the
29674
+ * collection on post declined
28978
29675
  */
28979
- if (params.feedType === 'reviewing' && action === 'onApproved')
28980
- collection.data = collection.data.filter(p => p !== post.postId);
29676
+ if (action === 'onDeclined') {
29677
+ collection.data = collection.data.filter(postId => postId !== post.postId);
29678
+ }
29679
+ else {
29680
+ collection.data = [...new Set([post.postId, ...collection.data])];
29681
+ }
28981
29682
  pushToCache(cacheKey, collection);
28982
29683
  responder(collection);
28983
29684
  };
@@ -29221,6 +29922,9 @@ const liveComments = (params, callback, config) => {
29221
29922
  };
29222
29923
  };
29223
29924
 
29925
+ /* begin_public_function
29926
+ id: poll.get
29927
+ */
29224
29928
  /**
29225
29929
  * ```js
29226
29930
  * import { getPoll } from '@amityco/ts-sdk'
@@ -29248,6 +29952,7 @@ const getPoll = async (pollId) => {
29248
29952
  cachedAt,
29249
29953
  };
29250
29954
  };
29955
+ /* end_public_function */
29251
29956
  /**
29252
29957
  * ```js
29253
29958
  * import { getPoll } from '@amityco/ts-sdk'
@@ -29275,6 +29980,9 @@ getPoll.locally = (pollId) => {
29275
29980
  };
29276
29981
  };
29277
29982
 
29983
+ /* begin_public_function
29984
+ id: poll.create
29985
+ */
29278
29986
  /**
29279
29987
  * ```js
29280
29988
  * import { createPoll } from '@amityco/ts-sdk'
@@ -29308,8 +30016,12 @@ const createPoll = async (bundle) => {
29308
30016
  data: polls[0],
29309
30017
  cachedAt,
29310
30018
  };
29311
- };
30019
+ };
30020
+ /* end_public_function */
29312
30021
 
30022
+ /* begin_public_function
30023
+ id: poll.close
30024
+ */
29313
30025
  /**
29314
30026
  * ```js
29315
30027
  * import { closePoll } from '@amityco/ts-sdk'
@@ -29337,8 +30049,12 @@ const closePoll = async (pollId) => {
29337
30049
  data: polls.find(poll => poll.pollId === pollId),
29338
30050
  cachedAt,
29339
30051
  };
29340
- };
30052
+ };
30053
+ /* end_public_function */
29341
30054
 
30055
+ /* begin_public_function
30056
+ id: poll.delete
30057
+ */
29342
30058
  /**
29343
30059
  * ```js
29344
30060
  * import { deletePoll } from '@amityco/ts-sdk'
@@ -29364,8 +30080,12 @@ const deletePoll = async (pollId) => {
29364
30080
  upsertInCache(['poll', 'get', pollId], deleted);
29365
30081
  fireEvent('poll.deleted', { polls: [deleted], users: [] });
29366
30082
  return success;
29367
- };
30083
+ };
30084
+ /* end_public_function */
29368
30085
 
30086
+ /* begin_public_function
30087
+ id: poll.vote
30088
+ */
29369
30089
  /**
29370
30090
  * ```js
29371
30091
  * import { votePoll } from '@amityco/ts-sdk'
@@ -29394,7 +30114,8 @@ const votePoll = async (pollId, answerIds) => {
29394
30114
  data: polls.find(poll => poll.pollId === pollId),
29395
30115
  cachedAt,
29396
30116
  };
29397
- };
30117
+ };
30118
+ /* end_public_function */
29398
30119
 
29399
30120
  /**
29400
30121
  * ```js
@@ -29490,6 +30211,9 @@ const observePoll = (pollId, callback, policy = 'cache_then_server') => {
29490
30211
  };
29491
30212
  };
29492
30213
 
30214
+ /* begin_public_function
30215
+ id: stream.get
30216
+ */
29493
30217
  /**
29494
30218
  * ```js
29495
30219
  * import { getStream } from '@amityco/ts-sdk'
@@ -29517,6 +30241,7 @@ const getStream = async (streamId) => {
29517
30241
  cachedAt,
29518
30242
  };
29519
30243
  };
30244
+ /* end_public_function */
29520
30245
  /**
29521
30246
  * ```js
29522
30247
  * import { getStream } from '@amityco/ts-sdk'
@@ -29544,6 +30269,9 @@ getStream.locally = (streamId) => {
29544
30269
  };
29545
30270
  };
29546
30271
 
30272
+ /* begin_public_function
30273
+ id: stream.query
30274
+ */
29547
30275
  /**
29548
30276
  * ```js
29549
30277
  * import { queryStreams } from '@amityco/ts-sdk'
@@ -29578,6 +30306,7 @@ const queryStreams = async (query) => {
29578
30306
  const prevPage = toPage(paging.previous);
29579
30307
  return { data: videoStreamings, cachedAt, prevPage, nextPage };
29580
30308
  };
30309
+ /* end_public_function */
29581
30310
  /**
29582
30311
  * ```js
29583
30312
  * import { queryStreams } from '@amityco/ts-sdk'
@@ -29597,6 +30326,9 @@ queryStreams.locally = (query) => {
29597
30326
  // TODO
29598
30327
  };
29599
30328
 
30329
+ /* begin_public_function
30330
+ id: stream.create
30331
+ */
29600
30332
  /**
29601
30333
  * ```js
29602
30334
  * import { createStream } from '@amityco/ts-sdk'
@@ -29623,8 +30355,12 @@ const createStream = async (bundle) => {
29623
30355
  data: videoStreamings[0],
29624
30356
  cachedAt,
29625
30357
  };
29626
- };
30358
+ };
30359
+ /* end_public_function */
29627
30360
 
30361
+ /* begin_public_function
30362
+ id: stream.update
30363
+ */
29628
30364
  /**
29629
30365
  * ```js
29630
30366
  * import { updateStream } from '@amityco/ts-sdk'
@@ -29655,6 +30391,9 @@ const updateStream = async (streamId, patch) => {
29655
30391
  };
29656
30392
 
29657
30393
  // import { unwrapPayload } from '~/core/transports'
30394
+ /* begin_public_function
30395
+ id: stream.delete
30396
+ */
29658
30397
  /**
29659
30398
  * ```js
29660
30399
  * import { deleteStream } from '@amityco/ts-sdk'
@@ -29813,7 +30552,7 @@ exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
29813
30552
  exports.FileType = FileType;
29814
30553
  exports.MessageContentType = MessageContentType;
29815
30554
  exports.PostContentType = PostContentType;
29816
- exports.VERSION = VERSION$1;
30555
+ exports.VERSION = VERSION;
29817
30556
  exports.VideoResolution = VideoResolution;
29818
30557
  exports.VideoSize = VideoSize;
29819
30558
  exports.VideoTranscodingStatus = VideoTranscodingStatus;
@@ -29862,6 +30601,7 @@ exports.dropFromCache = dropFromCache;
29862
30601
  exports.enableCache = enableCache;
29863
30602
  exports.fileUrlWithSize = fileUrlWithSize;
29864
30603
  exports.filterByChannelMembership = filterByChannelMembership;
30604
+ exports.filterByFeedType = filterByFeedType;
29865
30605
  exports.filterByPropEquality = filterByPropEquality;
29866
30606
  exports.filterByPropInclusion = filterByPropInclusion;
29867
30607
  exports.follow = follow;
@@ -29913,7 +30653,7 @@ exports.isMutator = isMutator;
29913
30653
  exports.isOffline = isOffline;
29914
30654
  exports.isPaged = isPaged;
29915
30655
  exports.isReportedByMe = isReportedByMe;
29916
- exports.isSkipLimit = isSkipLimit;
30656
+ exports.isSkip = isSkip;
29917
30657
  exports.joinChannel = joinChannel;
29918
30658
  exports.joinCommunity = joinCommunity;
29919
30659
  exports.leaveChannel = leaveChannel;
@@ -29925,6 +30665,8 @@ exports.liveChannels = liveChannels;
29925
30665
  exports.liveComment = liveComment;
29926
30666
  exports.liveComments = liveComments;
29927
30667
  exports.liveCommunities = liveCommunities;
30668
+ exports.liveCommunity = liveCommunity;
30669
+ exports.liveCommunityMembers = liveCommunityMembers;
29928
30670
  exports.liveFollowers = liveFollowers;
29929
30671
  exports.liveFollowings = liveFollowings;
29930
30672
  exports.liveMessage = liveMessage;
@@ -29935,6 +30677,7 @@ exports.liveReactions = liveReactions;
29935
30677
  exports.liveSubChannel = liveSubChannel;
29936
30678
  exports.liveSubChannels = liveSubChannels;
29937
30679
  exports.liveUser = liveUser;
30680
+ exports.liveUsers = liveUsers;
29938
30681
  exports.mergeInCache = mergeInCache;
29939
30682
  exports.observeChannel = observeChannel;
29940
30683
  exports.observeChannels = observeChannels;
@@ -29979,6 +30722,8 @@ exports.onCommunityUserAdded = onCommunityUserAdded;
29979
30722
  exports.onCommunityUserBanned = onCommunityUserBanned;
29980
30723
  exports.onCommunityUserChanged = onCommunityUserChanged;
29981
30724
  exports.onCommunityUserRemoved = onCommunityUserRemoved;
30725
+ exports.onCommunityUserRoleAdded = onCommunityUserRoleAdded;
30726
+ exports.onCommunityUserRoleRemoved = onCommunityUserRoleRemoved;
29982
30727
  exports.onCommunityUserUnbanned = onCommunityUserUnbanned;
29983
30728
  exports.onConnectionError = onConnectionError;
29984
30729
  exports.onFollowInfoUpdated = onFollowInfoUpdated;