@amityco/ts-sdk 7.4.0 → 7.4.1-18d364a3.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 (303) hide show
  1. package/.env +26 -26
  2. package/dist/@types/core/events.d.ts +7 -0
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/model.d.ts +5 -1
  5. package/dist/@types/core/model.d.ts.map +1 -1
  6. package/dist/@types/core/payload.d.ts +38 -5
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/client.d.ts +10 -0
  9. package/dist/@types/domains/client.d.ts.map +1 -1
  10. package/dist/@types/domains/community.d.ts +37 -1
  11. package/dist/@types/domains/community.d.ts.map +1 -1
  12. package/dist/@types/domains/invitation.d.ts +88 -0
  13. package/dist/@types/domains/invitation.d.ts.map +1 -0
  14. package/dist/@types/domains/joinRequest.d.ts +53 -0
  15. package/dist/@types/domains/joinRequest.d.ts.map +1 -0
  16. package/dist/@types/domains/notification.d.ts +4 -2
  17. package/dist/@types/domains/notification.d.ts.map +1 -1
  18. package/dist/@types/index.d.ts +3 -0
  19. package/dist/@types/index.d.ts.map +1 -1
  20. package/dist/communityRepository/api/createCommunity.d.ts +2 -2
  21. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  22. package/dist/communityRepository/api/getCommunities.d.ts +1 -1
  23. package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
  24. package/dist/communityRepository/api/getCommunity.d.ts +1 -1
  25. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  26. package/dist/communityRepository/api/getRecommendedCommunities.d.ts +3 -1
  27. package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
  28. package/dist/communityRepository/api/getTrendingCommunities.d.ts +3 -1
  29. package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
  30. package/dist/communityRepository/api/joinCommunity.d.ts +3 -0
  31. package/dist/communityRepository/api/joinCommunity.d.ts.map +1 -1
  32. package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
  33. package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
  34. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  35. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
  36. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
  37. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
  38. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
  39. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
  40. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
  41. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
  42. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
  43. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
  44. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
  45. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
  46. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
  47. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
  48. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
  49. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
  50. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
  51. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
  52. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
  53. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
  54. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
  55. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
  56. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
  57. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
  58. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
  59. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
  60. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
  61. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
  62. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
  63. package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
  64. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  65. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
  66. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
  67. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
  68. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
  69. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
  70. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
  71. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
  72. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
  73. package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
  74. package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
  75. package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
  76. package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
  77. package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
  78. package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
  79. package/dist/communityRepository/events/utils.d.ts +1 -1
  80. package/dist/communityRepository/events/utils.d.ts.map +1 -1
  81. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts +16 -0
  82. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts.map +1 -0
  83. package/dist/communityRepository/internalAPI/joinCommunity.d.ts +16 -0
  84. package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +1 -0
  85. package/dist/communityRepository/joinRequest/events/index.d.ts +4 -0
  86. package/dist/communityRepository/joinRequest/events/index.d.ts.map +1 -0
  87. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts +17 -0
  88. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts.map +1 -0
  89. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts +17 -0
  90. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts.map +1 -0
  91. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts +17 -0
  92. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts.map +1 -0
  93. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts +16 -0
  94. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +1 -0
  95. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts +16 -0
  96. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +1 -0
  97. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts +16 -0
  98. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +1 -0
  99. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
  100. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
  101. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts +14 -0
  102. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts.map +1 -0
  103. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts +9 -0
  104. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -0
  105. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts +15 -0
  106. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts.map +1 -0
  107. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts +6 -0
  108. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts.map +1 -0
  109. package/dist/communityRepository/observers/getJoinRequests.d.ts +12 -0
  110. package/dist/communityRepository/observers/getJoinRequests.d.ts.map +1 -0
  111. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
  112. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
  113. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
  114. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -1
  115. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
  116. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
  117. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts.map +1 -1
  118. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
  119. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
  120. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
  121. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
  122. package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
  123. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  124. package/dist/communityRepository/utils/payload.d.ts +2 -1
  125. package/dist/communityRepository/utils/payload.d.ts.map +1 -1
  126. package/dist/core/events.d.ts +3 -3
  127. package/dist/core/events.d.ts.map +1 -1
  128. package/dist/core/model/idResolvers.d.ts.map +1 -1
  129. package/dist/core/model/index.d.ts.map +1 -1
  130. package/dist/index.cjs.js +2679 -1419
  131. package/dist/index.d.ts +1 -0
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.esm.js +2937 -1678
  134. package/dist/index.umd.js +4 -4
  135. package/dist/invitationRepository/events/index.d.ts +4 -0
  136. package/dist/invitationRepository/events/index.d.ts.map +1 -0
  137. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
  138. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
  139. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
  140. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
  141. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
  142. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
  143. package/dist/invitationRepository/index.d.ts +3 -0
  144. package/dist/invitationRepository/index.d.ts.map +1 -0
  145. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
  146. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
  147. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +16 -0
  148. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +1 -0
  149. package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
  150. package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
  151. package/dist/invitationRepository/internalApi/getInvitation.d.ts +17 -0
  152. package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -0
  153. package/dist/invitationRepository/internalApi/index.d.ts +5 -0
  154. package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
  155. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
  156. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
  157. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +14 -0
  158. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  159. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +5 -0
  160. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  161. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +15 -0
  162. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  163. package/dist/invitationRepository/observers/getInvitations/enums.d.ts +6 -0
  164. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +1 -0
  165. package/dist/invitationRepository/observers/getInvitations.d.ts +12 -0
  166. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -0
  167. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts +12 -0
  168. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts.map +1 -0
  169. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts +14 -0
  170. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts.map +1 -0
  171. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts +5 -0
  172. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +1 -0
  173. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +15 -0
  174. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -0
  175. package/dist/invitationRepository/observers/index.d.ts +2 -0
  176. package/dist/invitationRepository/observers/index.d.ts.map +1 -0
  177. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts +2 -0
  178. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts.map +1 -0
  179. package/dist/invitationRepository/utils/index.d.ts +2 -0
  180. package/dist/invitationRepository/utils/index.d.ts.map +1 -0
  181. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +2 -0
  182. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +1 -0
  183. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts +2 -0
  184. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts.map +1 -0
  185. package/dist/messageRepository/api/flagMessage.d.ts +3 -2
  186. package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
  187. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -1
  188. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  189. package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
  190. package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
  191. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
  192. package/dist/utils/linkedObject/index.d.ts +3 -0
  193. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  194. package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
  195. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
  196. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts +2 -0
  197. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +1 -0
  198. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  199. package/dist/utils/tests/dummy/post.d.ts +3 -3
  200. package/package.json +1 -1
  201. package/src/@types/core/events.ts +11 -1
  202. package/src/@types/core/model.ts +8 -1
  203. package/src/@types/core/payload.ts +48 -5
  204. package/src/@types/domains/client.ts +12 -0
  205. package/src/@types/domains/community.ts +56 -1
  206. package/src/@types/domains/invitation.ts +116 -0
  207. package/src/@types/domains/joinRequest.ts +66 -0
  208. package/src/@types/domains/notification.ts +2 -0
  209. package/src/@types/index.ts +3 -0
  210. package/src/communityRepository/api/createCommunity.ts +5 -2
  211. package/src/communityRepository/api/getCommunities.ts +7 -2
  212. package/src/communityRepository/api/getCommunity.ts +13 -2
  213. package/src/communityRepository/api/getRecommendedCommunities.ts +11 -4
  214. package/src/communityRepository/api/getTrendingCommunities.ts +11 -4
  215. package/src/communityRepository/api/joinCommunity.ts +4 -1
  216. package/src/communityRepository/api/queryCommunities.ts +6 -1
  217. package/src/communityRepository/api/updateCommunity.ts +13 -3
  218. package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
  219. package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
  220. package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
  221. package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
  222. package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
  223. package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
  224. package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
  225. package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
  226. package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
  227. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
  228. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
  229. package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
  230. package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
  231. package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
  232. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  233. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
  234. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
  235. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
  236. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
  237. package/src/communityRepository/events/onCommunityCreated.ts +1 -1
  238. package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
  239. package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
  240. package/src/communityRepository/events/utils.ts +1 -1
  241. package/src/communityRepository/internalAPI/getMyJoinRequest.ts +43 -0
  242. package/src/communityRepository/internalAPI/joinCommunity.ts +51 -0
  243. package/src/communityRepository/joinRequest/events/index.ts +3 -0
  244. package/src/communityRepository/joinRequest/events/onJoinRequestCreated.ts +33 -0
  245. package/src/communityRepository/joinRequest/events/onJoinRequestDeleted.ts +33 -0
  246. package/src/communityRepository/joinRequest/events/onJoinRequestUpdated.ts +33 -0
  247. package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +52 -0
  248. package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +46 -0
  249. package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +52 -0
  250. package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
  251. package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts +126 -0
  252. package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +26 -0
  253. package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts +108 -0
  254. package/src/communityRepository/observers/getJoinRequests/enum.ts +5 -0
  255. package/src/communityRepository/observers/getJoinRequests.ts +44 -0
  256. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +2 -1
  257. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
  258. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +2 -1
  259. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
  260. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +1 -0
  261. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
  262. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
  263. package/src/communityRepository/utils/communityWithMembership.ts +9 -5
  264. package/src/communityRepository/utils/payload.ts +28 -2
  265. package/src/core/liveCollection/PaginationController.ts +1 -1
  266. package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
  267. package/src/core/model/idResolvers.ts +3 -0
  268. package/src/core/model/index.ts +3 -0
  269. package/src/index.ts +2 -0
  270. package/src/invitationRepository/events/index.ts +3 -0
  271. package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
  272. package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
  273. package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
  274. package/src/invitationRepository/index.ts +2 -0
  275. package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
  276. package/src/invitationRepository/internalApi/cancelInvitation.ts +44 -0
  277. package/src/invitationRepository/internalApi/createInvitations.ts +52 -0
  278. package/src/invitationRepository/internalApi/getInvitation.ts +47 -0
  279. package/src/invitationRepository/internalApi/index.ts +4 -0
  280. package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
  281. package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +148 -0
  282. package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +19 -0
  283. package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +97 -0
  284. package/src/invitationRepository/observers/getInvitations/enums.ts +5 -0
  285. package/src/invitationRepository/observers/getInvitations.ts +44 -0
  286. package/src/invitationRepository/observers/getMyCommunityInvitations.ts +48 -0
  287. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.ts +148 -0
  288. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +22 -0
  289. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.ts +105 -0
  290. package/src/invitationRepository/observers/index.ts +1 -0
  291. package/src/invitationRepository/utils/convertRawInvitationToInternalInvitation.ts +8 -0
  292. package/src/invitationRepository/utils/index.ts +1 -0
  293. package/src/invitationRepository/utils/prepareInvitationPayload.ts +12 -0
  294. package/src/invitationRepository/utils/prepareMyInvitationsPayload.ts +12 -0
  295. package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
  296. package/src/messageRepository/api/flagMessage.ts +19 -2
  297. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +7 -1
  298. package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +7 -1
  299. package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +4 -0
  300. package/src/utils/linkedObject/communityLinkedObject.ts +58 -0
  301. package/src/utils/linkedObject/index.ts +6 -0
  302. package/src/utils/linkedObject/invitationLinkedObject.ts +44 -0
  303. package/src/utils/linkedObject/joinRequestLinkedObject.ts +31 -0
@@ -0,0 +1,48 @@
1
+ import { dropFromCache } from '~/cache/api';
2
+ import { ENABLE_CACHE_MESSAGE } from '~/utils/constants';
3
+ import { getActiveClient } from '~/client/api/activeClient';
4
+ import { MyInvitationsLiveCollectionController } from './getMyInvitations/MyInvitationsLiveCollectionController';
5
+ import { InvitationStatusEnum } from '~/@types';
6
+
7
+ /**
8
+ * Get my community invitations
9
+ *
10
+ * @param params the query parameters
11
+ * @param callback the callback to be called when the invitations are fetched
12
+ * @returns invitations
13
+ *
14
+ * @category My Community Invitations Live Collection
15
+ *
16
+ */
17
+ export const getMyCommunityInvitations = (
18
+ params: Amity.MyInvitationsLiveCollection,
19
+ callback: Amity.LiveCollectionCallback<Amity.Invitation>,
20
+ config?: Amity.LiveCollectionConfig,
21
+ ) => {
22
+ const { log, cache } = getActiveClient();
23
+
24
+ if (!cache) {
25
+ console.log(ENABLE_CACHE_MESSAGE);
26
+ }
27
+
28
+ const timestamp = Date.now();
29
+ log(`getMyCommunityInvitations: (tmpid: ${timestamp}) > listen`);
30
+
31
+ const invitationsLiveCollection = new MyInvitationsLiveCollectionController(
32
+ { ...params, targetType: 'community', statuses: [InvitationStatusEnum.Pending] },
33
+ callback,
34
+ );
35
+
36
+ const disposers = invitationsLiveCollection.startSubscription();
37
+
38
+ const cacheKey = invitationsLiveCollection.getCacheKey();
39
+
40
+ disposers.push(() => {
41
+ dropFromCache(cacheKey);
42
+ });
43
+
44
+ return () => {
45
+ log(`getInvitations (tmpid: ${timestamp}) > dispose`);
46
+ disposers.forEach(fn => fn());
47
+ };
48
+ };
@@ -0,0 +1,148 @@
1
+ import hash from 'object-hash';
2
+ import { isNonNullable } from '~/utils';
3
+ import { invitationLinkedObject } from '~/utils/linkedObject/invitationLinkedObject';
4
+ import { pullFromCache, pushToCache } from '~/cache/api';
5
+ import { sortByFirstCreated, sortByLastCreated } from '~/core/query';
6
+ import { MyInvitationsPaginationController } from './MyInvitationsPaginationController';
7
+ import { MyInvitationsQueryStreamController } from './MyInvitationsQueryStreamController';
8
+ import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
9
+ import {
10
+ onLocalInvitationCreated,
11
+ onLocalInvitationDeleted,
12
+ onLocalInvitationUpdated,
13
+ } from '~/invitationRepository/events';
14
+ import { prepareMyInvitationsPayload } from '~/invitationRepository/utils/prepareMyInvitationsPayload';
15
+ import { InvitationActionsEnum } from '../getInvitations/enums';
16
+
17
+ export class MyInvitationsLiveCollectionController extends LiveCollectionController<
18
+ 'myInvitation',
19
+ Amity.MyInvitationsLiveCollection,
20
+ Amity.Invitation,
21
+ MyInvitationsPaginationController
22
+ > {
23
+ private queryStreamController: MyInvitationsQueryStreamController;
24
+
25
+ private query: Amity.MyInvitationsLiveCollection;
26
+
27
+ constructor(
28
+ query: Amity.MyInvitationsLiveCollection,
29
+ callback: Amity.LiveCollectionCallback<Amity.Invitation>,
30
+ ) {
31
+ const queryStreamId = hash(query);
32
+ const cacheKey = ['invitation', 'collection', queryStreamId];
33
+ const paginationController = new MyInvitationsPaginationController(query);
34
+
35
+ super(paginationController, queryStreamId, cacheKey, callback);
36
+
37
+ this.query = query;
38
+ this.queryStreamController = new MyInvitationsQueryStreamController(
39
+ this.query,
40
+ this.cacheKey,
41
+ this.notifyChange.bind(this),
42
+ prepareMyInvitationsPayload,
43
+ );
44
+
45
+ this.callback = callback.bind(this);
46
+ this.loadPage({ initial: true });
47
+ }
48
+
49
+ protected setup() {
50
+ const collection = pullFromCache<Amity.MyInvitationsLiveCollectionCache>(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.MyInvitationsPayload & Amity.Pagination) {
60
+ await this.queryStreamController.saveToMainDB(queryPayload);
61
+ }
62
+
63
+ protected persistQueryStream({
64
+ response,
65
+ direction,
66
+ refresh,
67
+ }: Amity.LiveCollectionPersistQueryStreamParams<'myInvitation'>) {
68
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
69
+ }
70
+
71
+ startSubscription() {
72
+ return this.queryStreamController.subscribeRTE([
73
+ {
74
+ fn: onLocalInvitationCreated,
75
+ action: InvitationActionsEnum.OnLocalInvitationCreated,
76
+ },
77
+ {
78
+ fn: onLocalInvitationUpdated,
79
+ action: InvitationActionsEnum.OnLocalInvitationUpdated,
80
+ },
81
+ {
82
+ fn: onLocalInvitationDeleted,
83
+ action: InvitationActionsEnum.OnLocalInvitationDeleted,
84
+ },
85
+ ]);
86
+ }
87
+
88
+ notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
89
+ const collection = pullFromCache<Amity.MyInvitationsLiveCollectionCache>(this.cacheKey)?.data;
90
+ if (!collection) return;
91
+
92
+ const data = this.applyFilter(
93
+ collection.data
94
+ .map(id => pullFromCache<Amity.InternalInvitation>(['invitation', 'get', id])!)
95
+ .filter(isNonNullable)
96
+ .map(({ data }) => invitationLinkedObject(data)) ?? [],
97
+ );
98
+
99
+ if (!this.shouldNotify(data) && origin === 'event') return;
100
+
101
+ this.callback({
102
+ onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
103
+ data,
104
+ hasNextPage: !!this.paginationController.getNextToken(),
105
+ loading,
106
+ error,
107
+ });
108
+ }
109
+
110
+ applyFilter(data: Amity.Invitation[]) {
111
+ let invitations = data;
112
+
113
+ if (this.query.targetId) {
114
+ invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
115
+ }
116
+
117
+ if (this.query.statuses) {
118
+ invitations = invitations.filter(invitation =>
119
+ this.query.statuses?.includes(invitation.status),
120
+ );
121
+ }
122
+
123
+ if (this.query.targetType) {
124
+ invitations = invitations.filter(
125
+ invitation => invitation.targetType === this.query.targetType,
126
+ );
127
+ }
128
+
129
+ if (this.query.type) {
130
+ invitations = invitations.filter(invitation => invitation.type === this.query.type);
131
+ }
132
+
133
+ const sortFn = (() => {
134
+ switch (this.query.sortBy) {
135
+ case 'firstCreated':
136
+ return sortByFirstCreated;
137
+ case 'lastCreated':
138
+ return sortByLastCreated;
139
+ default:
140
+ return sortByLastCreated;
141
+ }
142
+ })();
143
+
144
+ invitations = invitations.sort(sortFn);
145
+
146
+ return invitations;
147
+ }
148
+ }
@@ -0,0 +1,22 @@
1
+ import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
2
+ import { PaginationController } from '~/core/liveCollection/PaginationController';
3
+ import { getCommunityByIds } from '~/communityRepository';
4
+
5
+ export class MyInvitationsPaginationController extends PaginationController<
6
+ 'myInvitation',
7
+ Amity.MyInvitationsLiveCollection
8
+ > {
9
+ async getRequest(queryParams: Amity.MyInvitationsLiveCollection, token: string | undefined) {
10
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, ...params } = queryParams;
11
+ const options = token ? { token } : { limit };
12
+
13
+ const { data } = await this.http.get<Amity.MyInvitationsPayload & Amity.Pagination>(
14
+ '/api/v1/invitations/me',
15
+ { params: { ...params, options } },
16
+ );
17
+
18
+ await getCommunityByIds(data.invitations.map(invitation => invitation.targetId));
19
+
20
+ return data;
21
+ }
22
+ }
@@ -0,0 +1,105 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { getResolver } from '~/core/model';
3
+ import { pullFromCache, pushToCache } from '~/cache/api';
4
+ import { ingestInCache } from '~/cache/api/ingestInCache';
5
+ import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
6
+ import { InvitationActionsEnum } from '../getInvitations/enums';
7
+
8
+ export class MyInvitationsQueryStreamController extends QueryStreamController<
9
+ Amity.MyInvitationsPayload,
10
+ Amity.MyInvitationsLiveCollection
11
+ > {
12
+ private notifyChange: (params: Amity.LiveCollectionNotifyParams) => void;
13
+
14
+ private preparePayload: (
15
+ response: Amity.MyInvitationsPayload,
16
+ ) => Amity.ProcessedMyInvitationsPayload;
17
+
18
+ constructor(
19
+ query: Amity.MyInvitationsLiveCollection,
20
+ cacheKey: string[],
21
+ notifyChange: (params: Amity.LiveCollectionNotifyParams) => void,
22
+ preparePayload: (response: Amity.MyInvitationsPayload) => Amity.ProcessedMyInvitationsPayload,
23
+ ) {
24
+ super(query, cacheKey);
25
+ this.notifyChange = notifyChange;
26
+ this.preparePayload = preparePayload;
27
+ }
28
+
29
+ async saveToMainDB(response: Amity.MyInvitationsPayload) {
30
+ const processedPayload = await this.preparePayload(response);
31
+
32
+ const client = getActiveClient();
33
+ const cachedAt = client.cache && Date.now();
34
+
35
+ if (client.cache) {
36
+ ingestInCache(processedPayload, { cachedAt });
37
+ }
38
+ }
39
+
40
+ appendToQueryStream(
41
+ response: Amity.MyInvitationsPayload & Partial<Amity.Pagination>,
42
+ direction: Amity.LiveCollectionPageDirection,
43
+ refresh = false,
44
+ ) {
45
+ if (refresh) {
46
+ pushToCache(this.cacheKey, {
47
+ data: response.invitations.map(getResolver('invitation')),
48
+ });
49
+ } else {
50
+ const collection = pullFromCache<Amity.MyInvitationsLiveCollectionCache>(this.cacheKey)?.data;
51
+
52
+ const invitations = collection?.data ?? [];
53
+
54
+ pushToCache(this.cacheKey, {
55
+ ...collection,
56
+ data: [
57
+ ...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
58
+ ],
59
+ });
60
+ }
61
+ }
62
+
63
+ reactor(action: InvitationActionsEnum) {
64
+ return (invitations: Amity.InternalInvitation[]) => {
65
+ const collection = pullFromCache<Amity.InvitationLiveCollectionCache>(this.cacheKey)?.data;
66
+ if (!collection) return;
67
+
68
+ if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
69
+ const isExist = collection.data.find(id => id === invitations[0].invitationId);
70
+ if (!isExist) return;
71
+ }
72
+
73
+ if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
74
+ const client = getActiveClient();
75
+
76
+ const myInvitations = invitations.filter(
77
+ invitation => invitation.invitedUserId === client.userId,
78
+ );
79
+
80
+ collection.data = [
81
+ ...new Set([
82
+ ...myInvitations.map(invitation => invitation.invitationId),
83
+ ...collection.data,
84
+ ]),
85
+ ];
86
+ }
87
+
88
+ if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
89
+ collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
90
+ }
91
+
92
+ pushToCache(this.cacheKey, collection);
93
+ this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
94
+ };
95
+ }
96
+
97
+ subscribeRTE(
98
+ createSubscriber: {
99
+ fn: (reactor: Amity.Listener<Amity.InternalInvitation[]>) => Amity.Unsubscriber;
100
+ action: InvitationActionsEnum;
101
+ }[],
102
+ ) {
103
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
104
+ }
105
+ }
@@ -0,0 +1 @@
1
+ export * from './getMyCommunityInvitations';
@@ -0,0 +1,8 @@
1
+ export const convertRawInvitationToInternalInvitation = (
2
+ rawInvitation: Amity.RawInvitation,
3
+ ): Amity.InternalInvitation => {
4
+ return {
5
+ ...rawInvitation,
6
+ createdById: rawInvitation.createdBy,
7
+ };
8
+ };
@@ -0,0 +1 @@
1
+ export * from './prepareInvitationPayload';
@@ -0,0 +1,12 @@
1
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
2
+ import { convertRawInvitationToInternalInvitation } from './convertRawInvitationToInternalInvitation';
3
+
4
+ export const prepareInvitationPayload = (
5
+ rawPayload: Amity.InvitationPayload,
6
+ ): Amity.ProcessedInvitationPayload => {
7
+ return {
8
+ ...rawPayload,
9
+ invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation),
10
+ users: rawPayload.users.map(convertRawUserToInternalUser),
11
+ };
12
+ };
@@ -0,0 +1,12 @@
1
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
2
+ import { convertRawInvitationToInternalInvitation } from './convertRawInvitationToInternalInvitation';
3
+
4
+ export const prepareMyInvitationsPayload = (
5
+ rawPayload: Amity.MyInvitationsPayload,
6
+ ): Amity.ProcessedMyInvitationsPayload => {
7
+ return {
8
+ ...rawPayload,
9
+ users: rawPayload.users.map(convertRawUserToInternalUser),
10
+ invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation),
11
+ };
12
+ };
@@ -1,6 +1,6 @@
1
- import { pullFromCache } from '~/cache/api';
1
+ import { pullFromCache } from '~/cache/api/pullFromCache';
2
2
  import { getChannelMessagePreview } from './getChannelMessagePreview';
3
- import { LinkedObject } from '~/utils/linkedObject';
3
+ import { userLinkedObject } from '~/utils/linkedObject/userLinkedObject';
4
4
 
5
5
  export const getChannelMessagePreviewWithUser = (
6
6
  channel: Amity.StaticInternalChannel,
@@ -20,7 +20,7 @@ export const getChannelMessagePreviewWithUser = (
20
20
  const messagePreviewWithUser = messagePreview
21
21
  ? {
22
22
  ...messagePreview,
23
- user: internalUser ? LinkedObject.user(internalUser) : undefined,
23
+ user: internalUser ? userLinkedObject(internalUser) : undefined,
24
24
  }
25
25
  : null;
26
26
 
@@ -1,4 +1,5 @@
1
1
  import { fireEvent } from '~/core/events';
2
+ import { ContentFlagReasonEnum } from '~/@types';
2
3
  import { ingestInCache } from '~/cache/api/ingestInCache';
3
4
  import { getActiveClient } from '~/client/api/activeClient';
4
5
  import { prepareMessagePayload } from '~/messageRepository/utils';
@@ -9,21 +10,37 @@ import { prepareMessagePayload } from '~/messageRepository/utils';
9
10
  /**
10
11
  * ```js
11
12
  * import { MessageRepository } from '@amityco/ts-sdk'
12
- * const flagged = await MessageRepository.flagMessage(messageId)
13
+ * const flagged = await MessageRepository.flagMessage(messageId, reason)
13
14
  * ```
14
15
  *
15
16
  * @param messageId of the message to flag
17
+ * @param reason the reason to flag the message
16
18
  * @returns the created report result
17
19
  *
18
20
  * @category Message API
19
21
  * @async
20
22
  * */
21
- export const flagMessage = async (messageId: Amity.Message['messageId']): Promise<boolean> => {
23
+ export const flagMessage = async (
24
+ messageId: Amity.Message['messageId'],
25
+ reason?: Amity.ContentFlagReason,
26
+ ): Promise<boolean> => {
22
27
  const client = getActiveClient();
23
28
  client.log('message/flag', messageId);
24
29
 
30
+ const isPredefinedReason =
31
+ reason &&
32
+ Object.entries(ContentFlagReasonEnum).some(
33
+ ([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
34
+ );
35
+
36
+ const body = {
37
+ reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
38
+ detail: !isPredefinedReason ? reason : '',
39
+ };
40
+
25
41
  const { data: payload } = await client.http.post<Amity.MessagePayload>(
26
42
  `/api/v5/messages/${encodeURIComponent(messageId)}/flags`,
43
+ body,
27
44
  );
28
45
 
29
46
  if (client.cache) {
@@ -4,6 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
  import { getResolver } from '~/core/model';
5
5
  import { getActiveClient } from '~/client';
6
6
  import { EnumPostActions } from '../enums';
7
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
7
8
 
8
9
  export class GlobalPinnedPostQueryStreamController extends QueryStreamController<
9
10
  Amity.PinnedPostPayload,
@@ -30,7 +31,12 @@ export class GlobalPinnedPostQueryStreamController extends QueryStreamController
30
31
  const cachedAt = client.cache && Date.now();
31
32
 
32
33
  if (client.cache) {
33
- ingestInCache(response, { cachedAt });
34
+ const processedPayload = {
35
+ ...response,
36
+ users: response.users.map(convertRawUserToInternalUser),
37
+ };
38
+
39
+ ingestInCache(processedPayload, { cachedAt });
34
40
  }
35
41
  }
36
42
 
@@ -3,6 +3,7 @@ import { pullFromCache, pushToCache } from '~/cache/api';
3
3
  import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
  import { getResolver } from '~/core/model';
5
5
  import { getActiveClient } from '~/client';
6
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
6
7
 
7
8
  export class PinnedPostQueryStreamController extends QueryStreamController<
8
9
  Amity.PinnedPostPayload,
@@ -29,7 +30,12 @@ export class PinnedPostQueryStreamController extends QueryStreamController<
29
30
  const cachedAt = client.cache && Date.now();
30
31
 
31
32
  if (client.cache) {
32
- ingestInCache(response, { cachedAt });
33
+ const processedPayload = {
34
+ ...response,
35
+ users: response.users ? response.users.map(convertRawUserToInternalUser) : [],
36
+ };
37
+
38
+ ingestInCache(processedPayload, { cachedAt });
33
39
  }
34
40
  }
35
41
 
@@ -4,6 +4,7 @@ import { convertFromRaw as convertMessageFromRaw } from '~/messageRepository/uti
4
4
  import { convertFromRaw as convertSubChannelFromRaw } from './convertSubChannelFromRaw';
5
5
 
6
6
  import { updateSubChannelMessagePreviewCache } from '../../messagePreview/utils/updateSubChannelMessagePreviewCache';
7
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
7
8
 
8
9
  export const MARKER_INCLUDED_SUB_CHANNEL_TYPE = ['broadcast', 'conversation', 'community'];
9
10
 
@@ -44,10 +45,13 @@ export const prepareSubChannelPayload = async (
44
45
 
45
46
  const messages = rawPayload.messages.map(m => convertMessageFromRaw(m));
46
47
 
48
+ const user = rawPayload.users.map(convertRawUserToInternalUser);
49
+
47
50
  return {
48
51
  ...rawPayload,
49
52
  messageFeeds,
50
53
  messages,
54
+ users: user,
51
55
  };
52
56
  };
53
57
 
@@ -0,0 +1,58 @@
1
+ import { InvitationTypeEnum } from '~/@types';
2
+ import { getMyJoinRequest } from '~/communityRepository/internalAPI/getMyJoinRequest';
3
+ import { joinRequest } from '~/communityRepository/internalAPI/joinCommunity';
4
+ import { getJoinRequests } from '~/communityRepository/observers/getJoinRequests';
5
+ import { createInvitations } from '~/invitationRepository/internalApi';
6
+ import { getInvitation } from '~/invitationRepository/internalApi/getInvitation';
7
+ import { getInvitations } from '~/invitationRepository/observers/getInvitations';
8
+
9
+ export const communityLinkedObject = (community: Amity.InternalCommunity): Amity.Community => {
10
+ return {
11
+ ...community,
12
+ createInvitations: async (userIds: string[]): Promise<void> => {
13
+ await createInvitations({
14
+ type: InvitationTypeEnum.CommunityMemberInvite,
15
+ targetType: 'community',
16
+ targetId: community.communityId,
17
+ userIds,
18
+ });
19
+ },
20
+ getMemberInvitations: (
21
+ params: Pick<Amity.InvitationLiveCollection, 'limit' | 'sortBy' | 'statuses'>,
22
+ callback: Amity.LiveCollectionCallback<Amity.Invitation>,
23
+ ): Amity.Unsubscriber => {
24
+ return getInvitations(
25
+ {
26
+ ...params,
27
+ targetId: community.communityId,
28
+ targetType: 'community',
29
+ type: InvitationTypeEnum.CommunityMemberInvite,
30
+ },
31
+ callback,
32
+ );
33
+ },
34
+ getInvitation: async () => {
35
+ const { data } = await getInvitation('community', community.communityId);
36
+ return data;
37
+ },
38
+ join: async (): Promise<Amity.JoinResult> => {
39
+ return joinRequest(community.communityId);
40
+ },
41
+ getJoinRequests: (
42
+ params: Omit<Amity.QueryJoinRequest, 'communityId'>,
43
+ callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
44
+ ): Amity.Unsubscriber => {
45
+ return getJoinRequests(
46
+ {
47
+ ...params,
48
+ communityId: community.communityId,
49
+ },
50
+ callback,
51
+ );
52
+ },
53
+ getMyJoinRequest: async () => {
54
+ const { data } = await getMyJoinRequest(community.communityId);
55
+ return data;
56
+ },
57
+ };
58
+ };
@@ -11,6 +11,9 @@ import { channelLinkedObject } from './channelLinkedObject';
11
11
  import { adLinkedObject } from './adLinkedObject';
12
12
  import { pinnedPostLinkedObject } from './pinnedPostLinkedObject';
13
13
  import { notificationTrayLinkedObject } from './notificationTrayLinkedObject';
14
+ import { communityLinkedObject } from './communityLinkedObject';
15
+ import { invitationLinkedObject } from './invitationLinkedObject';
16
+ import { joinRequestLinkedObject } from './joinRequestLinkedObject';
14
17
 
15
18
  export const LinkedObject = {
16
19
  ad: adLinkedObject,
@@ -26,4 +29,7 @@ export const LinkedObject = {
26
29
  channel: channelLinkedObject,
27
30
  pinnedPost: pinnedPostLinkedObject,
28
31
  notificationTray: notificationTrayLinkedObject,
32
+ community: communityLinkedObject,
33
+ invitation: invitationLinkedObject,
34
+ joinRequest: joinRequestLinkedObject,
29
35
  };
@@ -0,0 +1,44 @@
1
+ import { pullFromCache } from '~/cache/api';
2
+ import { userLinkedObject } from './userLinkedObject';
3
+ import {
4
+ acceptInvitation,
5
+ cancelInvitation,
6
+ rejectInvitation,
7
+ } from '~/invitationRepository/internalApi';
8
+
9
+ export const invitationLinkedObject = (invitation: Amity.InternalInvitation): Amity.Invitation => {
10
+ return {
11
+ ...invitation,
12
+ get user(): Amity.User | undefined {
13
+ const cacheData = pullFromCache<Amity.User>(['user', 'get', invitation.invitedUserPublicId]);
14
+ if (cacheData?.data) return userLinkedObject(cacheData.data);
15
+ return undefined;
16
+ },
17
+ get createdBy(): Amity.User | undefined {
18
+ const cacheData = pullFromCache<Amity.User>(['user', 'get', invitation.inviterUserPublicId]);
19
+ if (cacheData?.data) return userLinkedObject(cacheData.data);
20
+ return undefined;
21
+ },
22
+ get target(): Amity.InvitationTarget<Amity.InvitationTargetType> | undefined {
23
+ if (invitation.targetType === 'community') {
24
+ const cacheData = pullFromCache<Amity.InternalCommunity>([
25
+ 'community',
26
+ 'get',
27
+ invitation.targetId,
28
+ ]);
29
+ if (cacheData?.data) return cacheData.data;
30
+ return undefined;
31
+ }
32
+ return undefined;
33
+ },
34
+ accept: async () => {
35
+ await acceptInvitation(invitation._id);
36
+ },
37
+ reject: async () => {
38
+ await rejectInvitation(invitation._id);
39
+ },
40
+ cancel: async () => {
41
+ await cancelInvitation(invitation._id);
42
+ },
43
+ };
44
+ };
@@ -0,0 +1,31 @@
1
+ import { pullFromCache } from '~/cache/api';
2
+ import { userLinkedObject } from './userLinkedObject';
3
+ import { approveJoinRequest } from '~/communityRepository/joinRequest/internalAPI/approveJoinRequest';
4
+ import { cancelJoinRequest } from '~/communityRepository/joinRequest/internalAPI/cancelJoinRequest';
5
+ import { rejectJoinRequest } from '~/communityRepository/joinRequest/internalAPI/rejectJoinRequest';
6
+
7
+ export const joinRequestLinkedObject = (
8
+ joinRequest: Amity.InternalJoinRequest,
9
+ ): Amity.JoinRequest => {
10
+ return {
11
+ ...joinRequest,
12
+ get user(): Amity.User | undefined {
13
+ const user = pullFromCache<Amity.InternalUser>([
14
+ 'user',
15
+ 'get',
16
+ joinRequest.requestorPublicId,
17
+ ])?.data;
18
+ if (!user) return undefined;
19
+ return userLinkedObject(user);
20
+ },
21
+ cancel: async () => {
22
+ await cancelJoinRequest(joinRequest);
23
+ },
24
+ approve: async () => {
25
+ await approveJoinRequest(joinRequest);
26
+ },
27
+ reject: async () => {
28
+ await rejectJoinRequest(joinRequest);
29
+ },
30
+ };
31
+ };