@amityco/ts-sdk 7.3.1-e2dead4.0 → 7.4.1-0e170b02.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 (305) hide show
  1. package/dist/@types/core/events.d.ts +7 -0
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +5 -1
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +38 -5
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/client.d.ts +10 -0
  8. package/dist/@types/domains/client.d.ts.map +1 -1
  9. package/dist/@types/domains/community.d.ts +37 -1
  10. package/dist/@types/domains/community.d.ts.map +1 -1
  11. package/dist/@types/domains/invitation.d.ts +88 -0
  12. package/dist/@types/domains/invitation.d.ts.map +1 -0
  13. package/dist/@types/domains/joinRequest.d.ts +53 -0
  14. package/dist/@types/domains/joinRequest.d.ts.map +1 -0
  15. package/dist/@types/index.d.ts +3 -0
  16. package/dist/@types/index.d.ts.map +1 -1
  17. package/dist/commentRepository/api/flagComment.d.ts +3 -2
  18. package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
  19. package/dist/communityRepository/api/createCommunity.d.ts +2 -2
  20. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  21. package/dist/communityRepository/api/getCommunities.d.ts +1 -1
  22. package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
  23. package/dist/communityRepository/api/getCommunity.d.ts +1 -1
  24. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  25. package/dist/communityRepository/api/getRecommendedCommunities.d.ts +3 -1
  26. package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
  27. package/dist/communityRepository/api/getTrendingCommunities.d.ts +3 -1
  28. package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
  29. package/dist/communityRepository/api/joinCommunity.d.ts +3 -0
  30. package/dist/communityRepository/api/joinCommunity.d.ts.map +1 -1
  31. package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
  32. package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
  33. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  34. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
  35. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
  36. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
  37. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
  38. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
  39. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
  40. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
  41. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
  42. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
  43. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
  44. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
  45. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
  46. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
  47. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
  48. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
  49. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
  50. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
  51. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
  52. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
  53. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
  54. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
  55. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
  56. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
  57. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
  58. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
  59. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
  60. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
  61. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
  62. package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
  63. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  64. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
  65. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
  66. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
  67. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
  68. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
  69. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
  70. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
  71. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
  72. package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
  73. package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
  74. package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
  75. package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
  76. package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
  77. package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
  78. package/dist/communityRepository/events/utils.d.ts +1 -1
  79. package/dist/communityRepository/events/utils.d.ts.map +1 -1
  80. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts +16 -0
  81. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts.map +1 -0
  82. package/dist/communityRepository/internalAPI/joinCommunity.d.ts +16 -0
  83. package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +1 -0
  84. package/dist/communityRepository/joinRequest/events/index.d.ts +4 -0
  85. package/dist/communityRepository/joinRequest/events/index.d.ts.map +1 -0
  86. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts +17 -0
  87. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts.map +1 -0
  88. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts +17 -0
  89. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts.map +1 -0
  90. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts +17 -0
  91. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts.map +1 -0
  92. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts +16 -0
  93. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +1 -0
  94. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts +16 -0
  95. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +1 -0
  96. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts +16 -0
  97. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +1 -0
  98. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
  99. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
  100. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts +14 -0
  101. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts.map +1 -0
  102. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts +9 -0
  103. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -0
  104. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts +15 -0
  105. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts.map +1 -0
  106. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts +6 -0
  107. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts.map +1 -0
  108. package/dist/communityRepository/observers/getJoinRequests.d.ts +12 -0
  109. package/dist/communityRepository/observers/getJoinRequests.d.ts.map +1 -0
  110. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
  111. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
  112. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
  113. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -1
  114. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
  115. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
  116. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts.map +1 -1
  117. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
  118. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
  119. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
  120. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
  121. package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
  122. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  123. package/dist/communityRepository/utils/payload.d.ts +2 -1
  124. package/dist/communityRepository/utils/payload.d.ts.map +1 -1
  125. package/dist/core/events.d.ts +3 -3
  126. package/dist/core/events.d.ts.map +1 -1
  127. package/dist/core/model/idResolvers.d.ts.map +1 -1
  128. package/dist/core/model/index.d.ts.map +1 -1
  129. package/dist/index.cjs.js +2686 -1421
  130. package/dist/index.d.ts +1 -0
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.esm.js +2948 -1684
  133. package/dist/index.umd.js +4 -4
  134. package/dist/invitationRepository/events/index.d.ts +4 -0
  135. package/dist/invitationRepository/events/index.d.ts.map +1 -0
  136. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
  137. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
  138. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
  139. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
  140. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
  141. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
  142. package/dist/invitationRepository/index.d.ts +3 -0
  143. package/dist/invitationRepository/index.d.ts.map +1 -0
  144. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
  145. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
  146. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +16 -0
  147. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +1 -0
  148. package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
  149. package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
  150. package/dist/invitationRepository/internalApi/getInvitation.d.ts +17 -0
  151. package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -0
  152. package/dist/invitationRepository/internalApi/index.d.ts +5 -0
  153. package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
  154. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
  155. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
  156. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +14 -0
  157. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  158. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +5 -0
  159. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  160. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +15 -0
  161. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  162. package/dist/invitationRepository/observers/getInvitations/enums.d.ts +6 -0
  163. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +1 -0
  164. package/dist/invitationRepository/observers/getInvitations.d.ts +12 -0
  165. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -0
  166. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts +12 -0
  167. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts.map +1 -0
  168. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts +14 -0
  169. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts.map +1 -0
  170. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts +5 -0
  171. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +1 -0
  172. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +15 -0
  173. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -0
  174. package/dist/invitationRepository/observers/index.d.ts +2 -0
  175. package/dist/invitationRepository/observers/index.d.ts.map +1 -0
  176. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts +2 -0
  177. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts.map +1 -0
  178. package/dist/invitationRepository/utils/index.d.ts +2 -0
  179. package/dist/invitationRepository/utils/index.d.ts.map +1 -0
  180. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +2 -0
  181. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +1 -0
  182. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts +2 -0
  183. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts.map +1 -0
  184. package/dist/messageRepository/api/flagMessage.d.ts +1 -1
  185. package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
  186. package/dist/postRepository/api/flagPost.d.ts +3 -2
  187. package/dist/postRepository/api/flagPost.d.ts.map +1 -1
  188. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -1
  189. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  190. package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
  191. package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
  192. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
  193. package/dist/utils/linkedObject/index.d.ts +3 -0
  194. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  195. package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
  196. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
  197. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts +2 -0
  198. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +1 -0
  199. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  200. package/dist/utils/tests/dummy/post.d.ts +3 -3
  201. package/package.json +1 -1
  202. package/src/@types/core/events.ts +11 -1
  203. package/src/@types/core/model.ts +8 -1
  204. package/src/@types/core/payload.ts +48 -5
  205. package/src/@types/domains/client.ts +12 -0
  206. package/src/@types/domains/community.ts +56 -1
  207. package/src/@types/domains/invitation.ts +116 -0
  208. package/src/@types/domains/joinRequest.ts +66 -0
  209. package/src/@types/index.ts +3 -0
  210. package/src/commentRepository/api/flagComment.ts +20 -3
  211. package/src/communityRepository/api/createCommunity.ts +5 -2
  212. package/src/communityRepository/api/getCommunities.ts +7 -2
  213. package/src/communityRepository/api/getCommunity.ts +13 -2
  214. package/src/communityRepository/api/getRecommendedCommunities.ts +11 -4
  215. package/src/communityRepository/api/getTrendingCommunities.ts +11 -4
  216. package/src/communityRepository/api/joinCommunity.ts +4 -1
  217. package/src/communityRepository/api/queryCommunities.ts +6 -1
  218. package/src/communityRepository/api/updateCommunity.ts +13 -3
  219. package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
  220. package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
  221. package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
  222. package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
  223. package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
  224. package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
  225. package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
  226. package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
  227. package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
  228. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
  229. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
  230. package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
  231. package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
  232. package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
  233. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  234. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
  235. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
  236. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
  237. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
  238. package/src/communityRepository/events/onCommunityCreated.ts +1 -1
  239. package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
  240. package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
  241. package/src/communityRepository/events/utils.ts +1 -1
  242. package/src/communityRepository/internalAPI/getMyJoinRequest.ts +43 -0
  243. package/src/communityRepository/internalAPI/joinCommunity.ts +49 -0
  244. package/src/communityRepository/joinRequest/events/index.ts +3 -0
  245. package/src/communityRepository/joinRequest/events/onJoinRequestCreated.ts +33 -0
  246. package/src/communityRepository/joinRequest/events/onJoinRequestDeleted.ts +33 -0
  247. package/src/communityRepository/joinRequest/events/onJoinRequestUpdated.ts +33 -0
  248. package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +56 -0
  249. package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +51 -0
  250. package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +49 -0
  251. package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
  252. package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts +126 -0
  253. package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +26 -0
  254. package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts +108 -0
  255. package/src/communityRepository/observers/getJoinRequests/enum.ts +5 -0
  256. package/src/communityRepository/observers/getJoinRequests.ts +44 -0
  257. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +2 -1
  258. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
  259. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +2 -1
  260. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
  261. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +1 -0
  262. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
  263. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
  264. package/src/communityRepository/utils/communityWithMembership.ts +9 -5
  265. package/src/communityRepository/utils/payload.ts +28 -2
  266. package/src/core/liveCollection/PaginationController.ts +1 -1
  267. package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
  268. package/src/core/model/idResolvers.ts +3 -0
  269. package/src/core/model/index.ts +2 -0
  270. package/src/index.ts +2 -0
  271. package/src/invitationRepository/events/index.ts +3 -0
  272. package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
  273. package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
  274. package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
  275. package/src/invitationRepository/index.ts +2 -0
  276. package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
  277. package/src/invitationRepository/internalApi/cancelInvitation.ts +44 -0
  278. package/src/invitationRepository/internalApi/createInvitations.ts +52 -0
  279. package/src/invitationRepository/internalApi/getInvitation.ts +47 -0
  280. package/src/invitationRepository/internalApi/index.ts +4 -0
  281. package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
  282. package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +148 -0
  283. package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +19 -0
  284. package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +97 -0
  285. package/src/invitationRepository/observers/getInvitations/enums.ts +5 -0
  286. package/src/invitationRepository/observers/getInvitations.ts +44 -0
  287. package/src/invitationRepository/observers/getMyCommunityInvitations.ts +48 -0
  288. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.ts +148 -0
  289. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +22 -0
  290. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.ts +105 -0
  291. package/src/invitationRepository/observers/index.ts +1 -0
  292. package/src/invitationRepository/utils/convertRawInvitationToInternalInvitation.ts +8 -0
  293. package/src/invitationRepository/utils/index.ts +1 -0
  294. package/src/invitationRepository/utils/prepareInvitationPayload.ts +12 -0
  295. package/src/invitationRepository/utils/prepareMyInvitationsPayload.ts +12 -0
  296. package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
  297. package/src/messageRepository/api/flagMessage.ts +7 -5
  298. package/src/postRepository/api/flagPost.ts +19 -3
  299. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +7 -1
  300. package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +7 -1
  301. package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +4 -0
  302. package/src/utils/linkedObject/communityLinkedObject.ts +58 -0
  303. package/src/utils/linkedObject/index.ts +6 -0
  304. package/src/utils/linkedObject/invitationLinkedObject.ts +44 -0
  305. package/src/utils/linkedObject/joinRequestLinkedObject.ts +27 -0
@@ -0,0 +1,51 @@
1
+ import { fireEvent } from '~/core/events';
2
+ import { dropFromCache, pullFromCache } from '~/cache/api';
3
+ import { getActiveClient } from '~/client/api/activeClient';
4
+
5
+ /* begin_public_function
6
+ id: joinRequest.cancel
7
+ */
8
+ /**
9
+ * ```js
10
+ * import { joinRequest } from '@amityco/ts-sdk'
11
+ * const isCanceled = await joinRequest.cancel()
12
+ * ```
13
+ *
14
+ * Cancels a {@link Amity.JoinRequest} object
15
+ *
16
+ * @param joinRequest the {@link Amity.JoinRequest} to cancel
17
+ * @returns A success boolean if the {@link Amity.JoinRequest} was canceled
18
+ *
19
+ * @category Join Request API
20
+ * @async
21
+ */
22
+ export const cancelJoinRequest = async (
23
+ joinRequest: Amity.InternalJoinRequest,
24
+ ): Promise<boolean> => {
25
+ const client = getActiveClient();
26
+ client.log('joinRequest/cancelJoinRequest', joinRequest.joinRequestId);
27
+
28
+ const { data } = await client.http.delete<{ success: boolean }>(
29
+ `/api/v4/communities/${joinRequest.targetId}/join`,
30
+ {
31
+ params: {
32
+ userId: joinRequest.userId,
33
+ },
34
+ },
35
+ );
36
+
37
+ const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
38
+ 'joinRequest',
39
+ 'get',
40
+ joinRequest.joinRequestId,
41
+ ])?.data;
42
+
43
+ if (joinRequestCache) {
44
+ dropFromCache(['joinRequest', 'get', joinRequest.joinRequestId]);
45
+
46
+ fireEvent('local.joinRequest.deleted', [joinRequestCache]);
47
+ }
48
+
49
+ return data.success;
50
+ };
51
+ /* end_public_function */
@@ -0,0 +1,49 @@
1
+ import { fireEvent } from '~/core/events';
2
+ import { pullFromCache, upsertInCache } from '~/cache/api';
3
+ import { getActiveClient } from '~/client/api/activeClient';
4
+ import { JoinRequestStatusEnum } from '~/@types/domains/joinRequest';
5
+
6
+ /* begin_public_function
7
+ id: joinRequest.reject
8
+ */
9
+ /**
10
+ * ```js
11
+ * import { joinRequest } from '@amityco/ts-sdk'
12
+ * const isRejected = await joinRequest.reject()
13
+ * ```
14
+ *
15
+ * Rejects a {@link Amity.JoinRequest} object
16
+ *
17
+ * @param joinRequest the {@link Amity.JoinRequest} to reject
18
+ * @returns A success boolean if the {@link Amity.JoinRequest} was rejected
19
+ *
20
+ * @category Join Request API
21
+ * @async
22
+ */
23
+ export const rejectJoinRequest = async (
24
+ joinRequest: Amity.InternalJoinRequest,
25
+ ): Promise<boolean> => {
26
+ const client = getActiveClient();
27
+ client.log('joinRequest/rejectJoinRequest', joinRequest.joinRequestId);
28
+
29
+ const { data } = await client.http.post<{ success: boolean }>(
30
+ `/api/v4/communities/${joinRequest.targetId}/join/reject`,
31
+ );
32
+
33
+ const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
34
+ 'joinRequest',
35
+ 'get',
36
+ joinRequest.joinRequestId,
37
+ ])?.data;
38
+
39
+ if (joinRequestCache) {
40
+ upsertInCache(['joinRequest', 'get', joinRequest.joinRequestId], {
41
+ status: JoinRequestStatusEnum.Rejected,
42
+ });
43
+
44
+ fireEvent('local.joinRequest.updated', [joinRequestCache]);
45
+ }
46
+
47
+ return data.success;
48
+ };
49
+ /* end_public_function */
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
60
60
  }
61
61
 
62
62
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
63
- return (community: Amity.Community) => {
63
+ return (community: Amity.InternalCommunity) => {
64
64
  const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
65
65
  if (!collection) return;
66
66
 
@@ -76,7 +76,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
76
76
 
77
77
  subscribeRTE(
78
78
  createSubscriber: {
79
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
79
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
80
80
  action: EnumCommunityActions | EnumCommunityMemberActions;
81
81
  }[],
82
82
  ) {
@@ -0,0 +1,126 @@
1
+ import hash from 'object-hash';
2
+ import { pullFromCache, pushToCache } from '~/cache/api';
3
+ import { JoinRequestsPaginationController } from './JoinRequestsPaginationController';
4
+ import { JoinRequestsQueryStreamController } from './JoinRequestsQueryStreamController';
5
+ import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
6
+ import { sortByFirstCreated, sortByLastCreated } from '~/core/query';
7
+ import { prepareCommunityJoinRequestPayload } from '~/communityRepository/utils';
8
+ import { EnumJoinRequestAction } from './enum';
9
+ import { isNonNullable } from '~/utils';
10
+ import { joinRequestLinkedObject } from '~/utils/linkedObject/joinRequestLinkedObject';
11
+ import {
12
+ onJoinRequestCreated,
13
+ onJoinRequestDeleted,
14
+ onJoinRequestUpdated,
15
+ } from '~/communityRepository/joinRequest/events/';
16
+
17
+ export class JoinRequestsLiveCollectionController extends LiveCollectionController<
18
+ 'joinRequest',
19
+ Amity.JoinRequestLiveCollection,
20
+ Amity.JoinRequest,
21
+ JoinRequestsPaginationController
22
+ > {
23
+ private queryStreamController: JoinRequestsQueryStreamController;
24
+
25
+ private query: Amity.JoinRequestLiveCollection;
26
+
27
+ constructor(
28
+ query: Amity.JoinRequestLiveCollection,
29
+ callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
30
+ ) {
31
+ const queryStreamId = hash(query);
32
+ const cacheKey = ['joinRequest', 'collection', queryStreamId];
33
+ const paginationController = new JoinRequestsPaginationController(query);
34
+
35
+ super(paginationController, queryStreamId, cacheKey, callback);
36
+
37
+ this.query = query;
38
+ this.queryStreamController = new JoinRequestsQueryStreamController(
39
+ this.query,
40
+ this.cacheKey,
41
+ this.notifyChange.bind(this),
42
+ prepareCommunityJoinRequestPayload,
43
+ );
44
+
45
+ this.callback = callback.bind(this);
46
+ this.loadPage({ initial: true });
47
+ }
48
+
49
+ protected setup() {
50
+ const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
51
+ if (!collection) {
52
+ pushToCache(this.cacheKey, {
53
+ data: [],
54
+ params: this.query,
55
+ });
56
+ }
57
+ }
58
+
59
+ protected async persistModel(queryPayload: Amity.CommunityJoinRequestPayload & Amity.Pagination) {
60
+ await this.queryStreamController.saveToMainDB(queryPayload);
61
+ }
62
+
63
+ protected persistQueryStream({
64
+ response,
65
+ direction,
66
+ refresh,
67
+ }: Amity.LiveCollectionPersistQueryStreamParams<'joinRequest'>) {
68
+ const joinRequestResponse = response as unknown as Amity.CommunityJoinRequestPayload &
69
+ Partial<Amity.Pagination>;
70
+ this.queryStreamController.appendToQueryStream(joinRequestResponse, direction, refresh);
71
+ }
72
+
73
+ startSubscription() {
74
+ return this.queryStreamController.subscribeRTE([
75
+ { fn: onJoinRequestCreated, action: EnumJoinRequestAction.OnLocalJoinRequestCreated },
76
+ { fn: onJoinRequestUpdated, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
77
+ { fn: onJoinRequestDeleted, action: EnumJoinRequestAction.OnLocalJoinRequestDeleted },
78
+ ]);
79
+ }
80
+
81
+ notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
82
+ const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
83
+ if (!collection) return;
84
+
85
+ const data = this.applyFilter(
86
+ collection.data
87
+ .map(id => pullFromCache<Amity.InternalJoinRequest>(['joinRequest', 'get', id])!)
88
+ .filter(isNonNullable)
89
+ .map(({ data }) => data)
90
+ .map(joinRequestLinkedObject),
91
+ );
92
+
93
+ if (!this.shouldNotify(data) && origin === 'event') return;
94
+
95
+ this.callback({
96
+ onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
97
+ data,
98
+ hasNextPage: !!this.paginationController.getNextToken(),
99
+ loading,
100
+ error,
101
+ });
102
+ }
103
+
104
+ applyFilter(data: Amity.JoinRequest[]) {
105
+ let joinRequest = data;
106
+
107
+ if (this.query.status) {
108
+ joinRequest = joinRequest.filter(joinRequest => joinRequest.status === this.query.status);
109
+ }
110
+
111
+ const sortFn = (() => {
112
+ switch (this.query.sortBy) {
113
+ case 'firstCreated':
114
+ return sortByFirstCreated;
115
+ case 'lastCreated':
116
+ return sortByLastCreated;
117
+ default:
118
+ return sortByLastCreated;
119
+ }
120
+ })();
121
+
122
+ joinRequest = joinRequest.sort(sortFn);
123
+
124
+ return joinRequest;
125
+ }
126
+ }
@@ -0,0 +1,26 @@
1
+ import { PaginationController } from '~/core/liveCollection/PaginationController';
2
+ import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
3
+
4
+ /**
5
+ * TODO: handle cache receive cache option, and cache policy
6
+ * TODO: check if querybyIds is supported
7
+ */
8
+ export class JoinRequestsPaginationController extends PaginationController<
9
+ 'joinRequest',
10
+ Amity.JoinRequestLiveCollection
11
+ > {
12
+ async getRequest(queryParams: Amity.JoinRequestLiveCollection, token: string | undefined) {
13
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityId, ...params } = queryParams;
14
+ const options = token ? { token } : { limit };
15
+
16
+ const { data: queryResponse } = await this.http.get<
17
+ Amity.CommunityJoinRequestPayload & Amity.Pagination
18
+ >(`/api/v4/communities/${communityId}/join`, {
19
+ params: {
20
+ ...params,
21
+ options,
22
+ },
23
+ });
24
+ return queryResponse;
25
+ }
26
+ }
@@ -0,0 +1,108 @@
1
+ import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
2
+ import { pullFromCache, pushToCache } from '~/cache/api';
3
+ import { ingestInCache } from '~/cache/api/ingestInCache';
4
+ import { getResolver } from '~/core/model';
5
+ import { getActiveClient } from '~/client/api/activeClient';
6
+ import { EnumJoinRequestAction } from './enum';
7
+
8
+ export class JoinRequestsQueryStreamController extends QueryStreamController<
9
+ Amity.CommunityJoinRequestPayload,
10
+ Amity.JoinRequestLiveCollection
11
+ > {
12
+ private notifyChange: (params: Amity.LiveCollectionNotifyParams) => void;
13
+
14
+ private preparePayload: (
15
+ response: Amity.CommunityJoinRequestPayload,
16
+ ) => Amity.ProcessedJoinRequestPayload;
17
+
18
+ constructor(
19
+ query: Amity.JoinRequestLiveCollection,
20
+ cacheKey: string[],
21
+ notifyChange: (params: Amity.LiveCollectionNotifyParams) => void,
22
+ preparePayload: (
23
+ response: Amity.CommunityJoinRequestPayload,
24
+ ) => Amity.ProcessedJoinRequestPayload,
25
+ ) {
26
+ super(query, cacheKey);
27
+ this.notifyChange = notifyChange;
28
+ this.preparePayload = preparePayload;
29
+ }
30
+
31
+ async saveToMainDB(response: Amity.CommunityJoinRequestPayload) {
32
+ const processedPayload = await this.preparePayload(response);
33
+
34
+ const client = getActiveClient();
35
+ const cachedAt = client.cache && Date.now();
36
+
37
+ if (client.cache) {
38
+ ingestInCache(processedPayload, { cachedAt });
39
+ }
40
+ }
41
+
42
+ appendToQueryStream(
43
+ response: Amity.CommunityJoinRequestPayload & Partial<Amity.Pagination>,
44
+ direction: Amity.LiveCollectionPageDirection,
45
+ refresh = false,
46
+ ) {
47
+ if (refresh) {
48
+ pushToCache(this.cacheKey, {
49
+ data: response.joinRequests.map(joinRequest =>
50
+ getResolver('joinRequest')({ joinRequestId: joinRequest._id }),
51
+ ),
52
+ });
53
+ } else {
54
+ const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
55
+
56
+ const joinRequests = collection?.data ?? [];
57
+
58
+ pushToCache(this.cacheKey, {
59
+ ...collection,
60
+ data: [
61
+ ...new Set([
62
+ ...joinRequests,
63
+ ...response.joinRequests.map(joinRequest =>
64
+ getResolver('joinRequest')({ joinRequestId: joinRequest._id }),
65
+ ),
66
+ ]),
67
+ ],
68
+ });
69
+ }
70
+ }
71
+
72
+ reactor(action: EnumJoinRequestAction) {
73
+ return (joinRequest: Amity.InternalJoinRequest[]) => {
74
+ const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
75
+ if (!collection) return;
76
+
77
+ if (action === EnumJoinRequestAction.OnLocalJoinRequestUpdated) {
78
+ const isExist = collection.data.find(id => id === joinRequest[0].joinRequestId);
79
+ if (!isExist) return;
80
+ }
81
+
82
+ if (action === EnumJoinRequestAction.OnLocalJoinRequestCreated) {
83
+ collection.data = [
84
+ ...new Set([
85
+ ...joinRequest.map(joinRequest => joinRequest.joinRequestId),
86
+ ...collection.data,
87
+ ]),
88
+ ];
89
+ }
90
+
91
+ if (action === EnumJoinRequestAction.OnLocalJoinRequestDeleted) {
92
+ collection.data = collection.data.filter(id => id !== joinRequest[0].joinRequestId);
93
+ }
94
+
95
+ pushToCache(this.cacheKey, collection);
96
+ this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
97
+ };
98
+ }
99
+
100
+ subscribeRTE(
101
+ createSubscriber: {
102
+ fn: (reactor: Amity.Listener<Amity.InternalJoinRequest[]>) => Amity.Unsubscriber;
103
+ action: EnumJoinRequestAction;
104
+ }[],
105
+ ) {
106
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
107
+ }
108
+ }
@@ -0,0 +1,5 @@
1
+ export enum EnumJoinRequestAction {
2
+ OnLocalJoinRequestCreated = 'OnLocalJoinRequestCreated',
3
+ OnLocalJoinRequestUpdated = 'OnLocalJoinRequestUpdated',
4
+ OnLocalJoinRequestDeleted = 'OnLocalJoinRequestDeleted',
5
+ }
@@ -0,0 +1,44 @@
1
+ import { dropFromCache } from '~/cache/api/dropFromCache';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
+ import { ENABLE_CACHE_MESSAGE } from '~/utils/constants';
4
+ import { JoinRequestsLiveCollectionController } from './getJoinRequests/JoinRequestsLiveCollectionController';
5
+
6
+ /**
7
+ * Get Join Requests
8
+ *
9
+ * @param params the query parameters
10
+ * @param callback the callback to be called when the join request are updated
11
+ * @returns joinRequests
12
+ *
13
+ * @category joinRequest Live Collection
14
+ *
15
+ */
16
+ export const getJoinRequests = (
17
+ params: Amity.JoinRequestLiveCollection,
18
+ callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
19
+ config?: Amity.LiveCollectionConfig,
20
+ ) => {
21
+ const { log, cache } = getActiveClient();
22
+
23
+ if (!cache) {
24
+ console.log(ENABLE_CACHE_MESSAGE);
25
+ }
26
+
27
+ const timestamp = Date.now();
28
+ log(`getJoinRequests: (tmpid: ${timestamp}) > listen`);
29
+
30
+ const joinRequestLiveCollection = new JoinRequestsLiveCollectionController(params, callback);
31
+
32
+ const disposers = joinRequestLiveCollection.startSubscription();
33
+
34
+ const cacheKey = joinRequestLiveCollection.getCacheKey();
35
+
36
+ disposers.push(() => {
37
+ dropFromCache(cacheKey);
38
+ });
39
+
40
+ return () => {
41
+ log(`getJoinRequests (tmpid: ${timestamp}) > dispose`);
42
+ disposers.forEach(fn => fn());
43
+ };
44
+ };
@@ -15,6 +15,7 @@ import {
15
15
  onCommunityUserChanged,
16
16
  } from '~/communityRepository/communityMembership';
17
17
  import { isNonNullable } from '~/utils';
18
+ import { communityLinkedObject } from '~/utils/linkedObject/communityLinkedObject';
18
19
 
19
20
  export class RecommendedCommunityLiveCollectionController extends LiveCollectionController<
20
21
  'community',
@@ -94,7 +95,7 @@ export class RecommendedCommunityLiveCollectionController extends LiveCollection
94
95
  collection.data
95
96
  .map(id => pullFromCache<Amity.Community>(['community', 'get', id]))
96
97
  .filter(isNonNullable)
97
- .map(({ data }) => data) ?? [];
98
+ .map(({ data }) => communityLinkedObject(data)) ?? [];
98
99
 
99
100
  if (!this.shouldNotify(data) && origin === 'event') return;
100
101
 
@@ -66,7 +66,7 @@ export class RecommendedCommunitiesQueryStreamController extends QueryStreamCont
66
66
  }
67
67
 
68
68
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
69
- return (community: Amity.Community) => {
69
+ return (community: Amity.InternalCommunity) => {
70
70
  const collection = pullFromCache<Amity.RecommendedCommunityLiveCollectionCache>(
71
71
  this.cacheKey,
72
72
  )?.data;
@@ -79,7 +79,7 @@ export class RecommendedCommunitiesQueryStreamController extends QueryStreamCont
79
79
 
80
80
  subscribeRTE(
81
81
  createSubscriber: {
82
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
82
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
83
83
  action: EnumCommunityActions | EnumCommunityMemberActions;
84
84
  }[],
85
85
  ) {
@@ -15,6 +15,7 @@ import {
15
15
  onCommunityUserChanged,
16
16
  } from '~/communityRepository/communityMembership';
17
17
  import { isNonNullable } from '~/utils';
18
+ import { communityLinkedObject } from '~/utils/linkedObject/communityLinkedObject';
18
19
 
19
20
  export class TrendingCommunityLiveCollectionController extends LiveCollectionController<
20
21
  'community',
@@ -94,7 +95,7 @@ export class TrendingCommunityLiveCollectionController extends LiveCollectionCon
94
95
  collection.data
95
96
  .map(id => pullFromCache<Amity.Community>(['community', 'get', id]))
96
97
  .filter(isNonNullable)
97
- .map(({ data }) => data) ?? [];
98
+ .map(({ data }) => communityLinkedObject(data)) ?? [];
98
99
 
99
100
  if (!this.shouldNotify(data) && origin === 'event') return;
100
101
 
@@ -64,7 +64,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
64
64
  }
65
65
 
66
66
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
67
- return (community: Amity.Community) => {
67
+ return (community: Amity.InternalCommunity) => {
68
68
  const collection = pullFromCache<Amity.TrendingCommunityLiveCollectionCache>(
69
69
  this.cacheKey,
70
70
  )?.data;
@@ -77,7 +77,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
77
77
 
78
78
  subscribeRTE(
79
79
  createSubscriber: {
80
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
81
81
  action: EnumCommunityActions | EnumCommunityMemberActions;
82
82
  }[],
83
83
  ) {
@@ -22,6 +22,7 @@ export class CommunitiesPaginationController extends PaginationController<
22
22
  isDeleted: inferIsDeleted(params.includeDeleted),
23
23
  keyword: params.displayName,
24
24
  filter: params.membership,
25
+ includeDiscoverablePrivateCommunity: params.includeDiscoverablePrivateCommunity ?? true,
25
26
  options,
26
27
  },
27
28
  },
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
60
60
  }
61
61
 
62
62
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
63
- return (community: Amity.Community) => {
63
+ return (community: Amity.InternalCommunity) => {
64
64
  const collection = pullFromCache<Amity.SearchCommunityLiveCollectionCache>(
65
65
  this.cacheKey,
66
66
  )?.data;
@@ -73,7 +73,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
73
73
 
74
74
  subscribeRTE(
75
75
  createSubscriber: {
76
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
76
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
77
77
  action: EnumCommunityActions | EnumCommunityMemberActions;
78
78
  }[],
79
79
  ) {
@@ -63,7 +63,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
63
63
  }
64
64
 
65
65
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
66
- return (community: Amity.Community) => {
66
+ return (community: Amity.InternalCommunity) => {
67
67
  const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
68
68
  if (!collection) return;
69
69
 
@@ -77,7 +77,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
77
77
 
78
78
  subscribeRTE(
79
79
  createSubscriber: {
80
- fn: (reactor: (community: Amity.Community) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (community: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
81
81
  action: EnumCommunityActions | EnumCommunityMemberActions;
82
82
  }[],
83
83
  ) {
@@ -1,5 +1,5 @@
1
1
  import { pullFromCache } from '~/cache/api';
2
- import { getActiveUser } from '~/client';
2
+ import { getActiveUser } from '~/client/api/activeUser';
3
3
 
4
4
  /*
5
5
  * verifies membership status
@@ -12,7 +12,7 @@ function isMember(membership: Amity.Membership<'community'>['communityMembership
12
12
  * checks if currently logged in user is part of the community
13
13
  */
14
14
  function isCurrentUserPartOfCommunity(
15
- c: Amity.Community,
15
+ c: Amity.InternalCommunity,
16
16
  m: Amity.Membership<'community'>,
17
17
  ): boolean {
18
18
  const { userId } = getActiveUser();
@@ -28,11 +28,15 @@ function isCurrentUserPartOfCommunity(
28
28
  * Althought this can be calculated, it's not scalable.
29
29
  */
30
30
  export function updateMembershipStatus(
31
- communities: Amity.Community[],
31
+ communities: Amity.RawCommunity[],
32
32
  communityUsers: Amity.Membership<'community'>[],
33
- ): Amity.Community[] {
33
+ ): Amity.InternalCommunity[] {
34
34
  return communities.map(c => {
35
- const cachedCommunity = pullFromCache<Amity.Community>(['community', 'get', c.communityId]);
35
+ const cachedCommunity = pullFromCache<Amity.InternalCommunity>([
36
+ 'community',
37
+ 'get',
38
+ c.communityId,
39
+ ]);
36
40
  if (cachedCommunity?.data && cachedCommunity?.data.hasOwnProperty('isJoined')) {
37
41
  return {
38
42
  ...cachedCommunity.data,
@@ -1,5 +1,6 @@
1
1
  import { CommunityPostSettingMaps, DefaultCommunityPostSetting } from '~/@types';
2
2
  import { updateMembershipStatus } from './communityWithMembership';
3
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
3
4
 
4
5
  const getMatchPostSetting = (value: {
5
6
  needApprovalOnPostCreation: Amity.RawCommunity['needApprovalOnPostCreation'];
@@ -13,7 +14,7 @@ const getMatchPostSetting = (value: {
13
14
  ) ?? DefaultCommunityPostSetting;
14
15
 
15
16
  export function addPostSetting({ communities }: { communities: Amity.RawCommunity[] }) {
16
- return communities.map<Amity.Community>(
17
+ return communities.map<Amity.InternalCommunity>(
17
18
  ({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
18
19
  postSetting: getMatchPostSetting({
19
20
  needApprovalOnPostCreation,
@@ -29,10 +30,13 @@ export const prepareCommunityPayload = (
29
30
  ): Amity.ProcessedCommunityPayload => {
30
31
  const communitiesWithPostSetting = addPostSetting({ communities: rawPayload.communities });
31
32
 
33
+ // Convert users to internal format
34
+ const internalUsers = rawPayload.users.map(convertRawUserToInternalUser);
35
+
32
36
  // map users with community
33
37
  const mappedCommunityUsers: Array<Amity.Membership<'community'>> = rawPayload.communityUsers.map(
34
38
  communityUser => {
35
- const user = rawPayload.users.find(user => user.userId === communityUser.userId)!;
39
+ const user = internalUsers.find(user => user.userId === communityUser.userId)!;
36
40
 
37
41
  return {
38
42
  ...communityUser,
@@ -48,11 +52,33 @@ export const prepareCommunityPayload = (
48
52
 
49
53
  return {
50
54
  ...rawPayload,
55
+ users: rawPayload.users.map(convertRawUserToInternalUser),
51
56
  communities: communityWithMembershipStatus,
52
57
  communityUsers: mappedCommunityUsers,
53
58
  };
54
59
  };
55
60
 
61
+ export const prepareCommunityJoinRequestPayload = (
62
+ rawPayload: Amity.CommunityJoinRequestPayload,
63
+ ): Amity.ProcessedJoinRequestPayload => {
64
+ const mappedJoinRequests: Array<Amity.InternalJoinRequest> = rawPayload.joinRequests.map(
65
+ joinRequest => {
66
+ return {
67
+ ...joinRequest,
68
+ joinRequestId: joinRequest._id,
69
+ };
70
+ },
71
+ );
72
+
73
+ const users = rawPayload.users.map(convertRawUserToInternalUser);
74
+
75
+ return {
76
+ ...rawPayload,
77
+ joinRequests: mappedJoinRequests,
78
+ users,
79
+ };
80
+ };
81
+
56
82
  export const prepareCommunityMembershipPayload = (
57
83
  rawPayload: Amity.CommunityMembershipPayload,
58
84
  ): Amity.ProcessedCommunityMembershipPayload => {
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { getActiveClient } from '~/client/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
3
 
4
4
  export abstract class PaginationController<
5
5
  TPayloadDomain extends keyof Amity.Payloads,
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { getActiveClient } from '~/client/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
3
 
4
4
  export abstract class PaginationNoPageController<
5
5
  TPayloadDomain extends keyof Amity.Payloads,