@amityco/ts-sdk 7.5.3-d6ee46d.0 → 7.5.3

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 (366) hide show
  1. package/.env +26 -26
  2. package/dist/@types/core/events.d.ts +0 -7
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/model.d.ts +1 -5
  5. package/dist/@types/core/model.d.ts.map +1 -1
  6. package/dist/@types/core/payload.d.ts +5 -38
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/client.d.ts +0 -10
  9. package/dist/@types/domains/client.d.ts.map +1 -1
  10. package/dist/@types/domains/community.d.ts +1 -51
  11. package/dist/@types/domains/community.d.ts.map +1 -1
  12. package/dist/@types/domains/notification.d.ts +2 -4
  13. package/dist/@types/domains/notification.d.ts.map +1 -1
  14. package/dist/@types/domains/post.d.ts +18 -1
  15. package/dist/@types/domains/post.d.ts.map +1 -1
  16. package/dist/@types/index.d.ts +0 -3
  17. package/dist/@types/index.d.ts.map +1 -1
  18. package/dist/client/api/enableUnreadCount.d.ts.map +1 -1
  19. package/dist/client/api/login.d.ts.map +1 -1
  20. package/dist/client/utils/markerSyncEngine.d.ts +1 -1
  21. package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
  22. package/dist/communityRepository/api/createCommunity.d.ts +2 -2
  23. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  24. package/dist/communityRepository/api/getCommunities.d.ts +1 -1
  25. package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
  26. package/dist/communityRepository/api/getCommunity.d.ts +1 -1
  27. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  28. package/dist/communityRepository/api/getRecommendedCommunities.d.ts +1 -3
  29. package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
  30. package/dist/communityRepository/api/getTrendingCommunities.d.ts +1 -3
  31. package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
  32. package/dist/communityRepository/api/joinCommunity.d.ts +0 -3
  33. package/dist/communityRepository/api/joinCommunity.d.ts.map +1 -1
  34. package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
  35. package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
  36. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  37. package/dist/communityRepository/communityMembership/events/index.d.ts +0 -1
  38. package/dist/communityRepository/communityMembership/events/index.d.ts.map +1 -1
  39. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
  40. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
  41. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
  42. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
  43. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
  44. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
  45. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
  46. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
  47. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
  48. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
  49. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
  50. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
  51. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
  52. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
  53. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
  54. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
  55. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
  56. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
  57. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
  58. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
  59. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
  60. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
  61. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
  62. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
  63. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
  64. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
  65. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
  66. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
  67. package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
  68. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  69. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
  70. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
  71. package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts +1 -2
  72. package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts.map +1 -1
  73. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
  74. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
  75. package/dist/communityRepository/communityMembership/observers/searchMembers/enums.d.ts +0 -1
  76. package/dist/communityRepository/communityMembership/observers/searchMembers/enums.d.ts.map +1 -1
  77. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
  78. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
  79. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
  80. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
  81. package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
  82. package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
  83. package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
  84. package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
  85. package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
  86. package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
  87. package/dist/communityRepository/events/utils.d.ts +1 -1
  88. package/dist/communityRepository/events/utils.d.ts.map +1 -1
  89. package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
  90. package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.d.ts.map +1 -1
  91. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
  92. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
  93. package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
  94. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
  95. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.d.ts.map +1 -1
  96. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
  97. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
  98. package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts +1 -2
  99. package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts.map +1 -1
  100. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -1
  101. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.d.ts.map +1 -1
  102. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
  103. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
  104. package/dist/communityRepository/observers/index.d.ts +0 -1
  105. package/dist/communityRepository/observers/index.d.ts.map +1 -1
  106. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts.map +1 -1
  107. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts.map +1 -1
  108. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
  109. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
  110. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.d.ts.map +1 -1
  111. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.d.ts.map +1 -1
  112. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
  113. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
  114. package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
  115. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  116. package/dist/communityRepository/utils/payload.d.ts +1 -2
  117. package/dist/communityRepository/utils/payload.d.ts.map +1 -1
  118. package/dist/core/events.d.ts +3 -3
  119. package/dist/core/events.d.ts.map +1 -1
  120. package/dist/core/model/idResolvers.d.ts.map +1 -1
  121. package/dist/core/model/index.d.ts.map +1 -1
  122. package/dist/index.cjs.js +1768 -3340
  123. package/dist/index.d.ts +0 -1
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.esm.js +1944 -3515
  126. package/dist/index.umd.js +4 -4
  127. package/dist/postRepository/api/getPost.d.ts +2 -2
  128. package/dist/postRepository/api/getPost.d.ts.map +1 -1
  129. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -1
  130. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  131. package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
  132. package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
  133. package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
  134. package/dist/utils/linkedObject/index.d.ts +0 -3
  135. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  136. package/dist/utils/tests/dummy/post.d.ts +3 -3
  137. package/package.json +1 -1
  138. package/src/@types/core/events.ts +0 -10
  139. package/src/@types/core/model.ts +1 -8
  140. package/src/@types/core/payload.ts +5 -48
  141. package/src/@types/domains/client.ts +0 -12
  142. package/src/@types/domains/community.ts +3 -82
  143. package/src/@types/domains/notification.ts +0 -2
  144. package/src/@types/domains/post.ts +25 -8
  145. package/src/@types/index.ts +0 -3
  146. package/src/client/api/enableUnreadCount.ts +0 -22
  147. package/src/client/api/login.ts +0 -4
  148. package/src/client/utils/markerSyncEngine.ts +3 -24
  149. package/src/commentRepository/api/createComment.ts +1 -1
  150. package/src/commentRepository/api/deleteComment.ts +1 -1
  151. package/src/communityRepository/api/createCommunity.ts +2 -5
  152. package/src/communityRepository/api/getCommunities.ts +2 -9
  153. package/src/communityRepository/api/getCommunity.ts +2 -13
  154. package/src/communityRepository/api/getRecommendedCommunities.ts +4 -11
  155. package/src/communityRepository/api/getTrendingCommunities.ts +4 -11
  156. package/src/communityRepository/api/joinCommunity.ts +1 -4
  157. package/src/communityRepository/api/queryCommunities.ts +1 -7
  158. package/src/communityRepository/api/updateCommunity.ts +3 -13
  159. package/src/communityRepository/communityMembership/events/index.ts +0 -1
  160. package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
  161. package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
  162. package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
  163. package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
  164. package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
  165. package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
  166. package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
  167. package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
  168. package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
  169. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
  170. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
  171. package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
  172. package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
  173. package/src/communityRepository/communityMembership/events/onUserDeleted.ts +1 -3
  174. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  175. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +2 -8
  176. package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +0 -1
  177. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +2 -8
  178. package/src/communityRepository/communityMembership/observers/searchMembers/enums.ts +0 -1
  179. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
  180. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
  181. package/src/communityRepository/events/onCommunityCreated.ts +1 -1
  182. package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
  183. package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
  184. package/src/communityRepository/events/utils.ts +1 -1
  185. package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +0 -6
  186. package/src/communityRepository/observers/getCommunities/CommunitiesPaginationController.ts +0 -1
  187. package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
  188. package/src/communityRepository/observers/getCommunity.ts +0 -3
  189. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +1 -8
  190. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.ts +1 -6
  191. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
  192. package/src/communityRepository/observers/getRecommendedCommunities/enums.ts +0 -1
  193. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +1 -9
  194. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.ts +1 -6
  195. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
  196. package/src/communityRepository/observers/index.ts +0 -1
  197. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.ts +0 -6
  198. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +0 -1
  199. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
  200. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.ts +0 -6
  201. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.ts +0 -1
  202. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
  203. package/src/communityRepository/utils/communityWithMembership.ts +5 -9
  204. package/src/communityRepository/utils/payload.ts +2 -28
  205. package/src/core/liveCollection/PaginationController.ts +1 -1
  206. package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
  207. package/src/core/model/idResolvers.ts +0 -3
  208. package/src/core/model/index.ts +0 -3
  209. package/src/index.ts +0 -2
  210. package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
  211. package/src/postRepository/api/getPost.ts +6 -4
  212. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +1 -7
  213. package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +1 -7
  214. package/src/postRepository/observers/getPost.ts +2 -2
  215. package/src/reactionRepository/api/addReaction.ts +1 -1
  216. package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +0 -4
  217. package/src/userRepository/observers/getBlockedUsers.ts +4 -4
  218. package/src/utils/linkedObject/index.ts +0 -6
  219. package/src/utils/linkedObject/streamLinkedObject.ts +1 -1
  220. package/dist/@types/domains/invitation.d.ts +0 -92
  221. package/dist/@types/domains/invitation.d.ts.map +0 -1
  222. package/dist/@types/domains/joinRequest.d.ts +0 -53
  223. package/dist/@types/domains/joinRequest.d.ts.map +0 -1
  224. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts +0 -2
  225. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts.map +0 -1
  226. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts +0 -16
  227. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts.map +0 -1
  228. package/dist/communityRepository/internalAPI/joinCommunity.d.ts +0 -16
  229. package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +0 -1
  230. package/dist/communityRepository/joinRequest/events/index.d.ts +0 -4
  231. package/dist/communityRepository/joinRequest/events/index.d.ts.map +0 -1
  232. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts +0 -17
  233. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts.map +0 -1
  234. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts +0 -17
  235. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts.map +0 -1
  236. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts +0 -17
  237. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts.map +0 -1
  238. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts +0 -16
  239. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +0 -1
  240. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts +0 -16
  241. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +0 -1
  242. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts +0 -16
  243. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +0 -1
  244. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts +0 -14
  245. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts.map +0 -1
  246. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts +0 -9
  247. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts.map +0 -1
  248. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts +0 -15
  249. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts.map +0 -1
  250. package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts +0 -6
  251. package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts.map +0 -1
  252. package/dist/communityRepository/observers/getJoinRequestList.d.ts +0 -12
  253. package/dist/communityRepository/observers/getJoinRequestList.d.ts.map +0 -1
  254. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts +0 -14
  255. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts.map +0 -1
  256. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts +0 -9
  257. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +0 -1
  258. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts +0 -15
  259. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts.map +0 -1
  260. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts +0 -6
  261. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts.map +0 -1
  262. package/dist/communityRepository/observers/getJoinRequests.d.ts +0 -12
  263. package/dist/communityRepository/observers/getJoinRequests.d.ts.map +0 -1
  264. package/dist/invitationRepository/events/index.d.ts +0 -4
  265. package/dist/invitationRepository/events/index.d.ts.map +0 -1
  266. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +0 -17
  267. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +0 -1
  268. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +0 -17
  269. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +0 -1
  270. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +0 -17
  271. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +0 -1
  272. package/dist/invitationRepository/index.d.ts +0 -3
  273. package/dist/invitationRepository/index.d.ts.map +0 -1
  274. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +0 -16
  275. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +0 -1
  276. package/dist/invitationRepository/internalApi/createInvitations.d.ts +0 -21
  277. package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +0 -1
  278. package/dist/invitationRepository/internalApi/getInvitation.d.ts +0 -17
  279. package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +0 -1
  280. package/dist/invitationRepository/internalApi/index.d.ts +0 -4
  281. package/dist/invitationRepository/internalApi/index.d.ts.map +0 -1
  282. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +0 -16
  283. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +0 -1
  284. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +0 -14
  285. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
  286. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +0 -5
  287. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
  288. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +0 -15
  289. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
  290. package/dist/invitationRepository/observers/getInvitations/enums.d.ts +0 -6
  291. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
  292. package/dist/invitationRepository/observers/getInvitations.d.ts +0 -12
  293. package/dist/invitationRepository/observers/getInvitations.d.ts.map +0 -1
  294. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts +0 -12
  295. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts.map +0 -1
  296. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts +0 -14
  297. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts.map +0 -1
  298. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts +0 -5
  299. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +0 -1
  300. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +0 -15
  301. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +0 -1
  302. package/dist/invitationRepository/observers/index.d.ts +0 -2
  303. package/dist/invitationRepository/observers/index.d.ts.map +0 -1
  304. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts +0 -2
  305. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts.map +0 -1
  306. package/dist/invitationRepository/utils/index.d.ts +0 -2
  307. package/dist/invitationRepository/utils/index.d.ts.map +0 -1
  308. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +0 -2
  309. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +0 -1
  310. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts +0 -2
  311. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts.map +0 -1
  312. package/dist/utils/linkedObject/communityLinkedObject.d.ts +0 -2
  313. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +0 -1
  314. package/dist/utils/linkedObject/invitationLinkedObject.d.ts +0 -2
  315. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +0 -1
  316. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts +0 -2
  317. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +0 -1
  318. package/src/@types/domains/invitation.ts +0 -119
  319. package/src/@types/domains/joinRequest.ts +0 -66
  320. package/src/communityRepository/communityMembership/events/onLocalCommunityJoin.ts +0 -20
  321. package/src/communityRepository/internalAPI/getMyJoinRequest.ts +0 -43
  322. package/src/communityRepository/internalAPI/joinCommunity.ts +0 -66
  323. package/src/communityRepository/joinRequest/events/index.ts +0 -3
  324. package/src/communityRepository/joinRequest/events/onJoinRequestCreated.ts +0 -33
  325. package/src/communityRepository/joinRequest/events/onJoinRequestDeleted.ts +0 -33
  326. package/src/communityRepository/joinRequest/events/onJoinRequestUpdated.ts +0 -33
  327. package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +0 -52
  328. package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +0 -49
  329. package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +0 -52
  330. package/src/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.ts +0 -135
  331. package/src/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.ts +0 -30
  332. package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts +0 -116
  333. package/src/communityRepository/observers/getJoinRequestList/enum.ts +0 -5
  334. package/src/communityRepository/observers/getJoinRequestList.ts +0 -51
  335. package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts +0 -126
  336. package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +0 -26
  337. package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts +0 -108
  338. package/src/communityRepository/observers/getJoinRequests/enum.ts +0 -5
  339. package/src/communityRepository/observers/getJoinRequests.ts +0 -44
  340. package/src/invitationRepository/events/index.ts +0 -3
  341. package/src/invitationRepository/events/onLocalInvitationCreated.ts +0 -33
  342. package/src/invitationRepository/events/onLocalInvitationDeleted.ts +0 -33
  343. package/src/invitationRepository/events/onLocalInvitationUpdated.ts +0 -33
  344. package/src/invitationRepository/index.ts +0 -2
  345. package/src/invitationRepository/internalApi/acceptInvitation.ts +0 -45
  346. package/src/invitationRepository/internalApi/createInvitations.ts +0 -52
  347. package/src/invitationRepository/internalApi/getInvitation.ts +0 -47
  348. package/src/invitationRepository/internalApi/index.ts +0 -3
  349. package/src/invitationRepository/internalApi/rejectInvitation.ts +0 -45
  350. package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +0 -148
  351. package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +0 -19
  352. package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +0 -97
  353. package/src/invitationRepository/observers/getInvitations/enums.ts +0 -5
  354. package/src/invitationRepository/observers/getInvitations.ts +0 -44
  355. package/src/invitationRepository/observers/getMyCommunityInvitations.ts +0 -48
  356. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.ts +0 -148
  357. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +0 -22
  358. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.ts +0 -105
  359. package/src/invitationRepository/observers/index.ts +0 -1
  360. package/src/invitationRepository/utils/convertRawInvitationToInternalInvitation.ts +0 -8
  361. package/src/invitationRepository/utils/index.ts +0 -1
  362. package/src/invitationRepository/utils/prepareInvitationPayload.ts +0 -12
  363. package/src/invitationRepository/utils/prepareMyInvitationsPayload.ts +0 -12
  364. package/src/utils/linkedObject/communityLinkedObject.ts +0 -57
  365. package/src/utils/linkedObject/invitationLinkedObject.ts +0 -37
  366. package/src/utils/linkedObject/joinRequestLinkedObject.ts +0 -31
@@ -1,148 +0,0 @@
1
- import hash from 'object-hash';
2
- import { isNonNullable } from '~/utils';
3
- import { InvitationActionsEnum } from './enums';
4
- import { invitationLinkedObject } from '~/utils/linkedObject/invitationLinkedObject';
5
- import { pullFromCache, pushToCache } from '~/cache/api';
6
- import { sortByFirstCreated, sortByLastCreated } from '~/core/query';
7
- import { InvitationsPaginationController } from './InvitationsPaginationController';
8
- import { InvitationsQueryStreamController } from './InvitationsQueryStreamController';
9
- import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
10
- import { prepareInvitationPayload } from '~/invitationRepository/utils';
11
- import {
12
- onLocalInvitationCreated,
13
- onLocalInvitationDeleted,
14
- onLocalInvitationUpdated,
15
- } from '~/invitationRepository/events';
16
-
17
- export class InvitationsLiveCollectionController extends LiveCollectionController<
18
- 'invitation',
19
- Amity.InvitationLiveCollection,
20
- Amity.Invitation,
21
- InvitationsPaginationController
22
- > {
23
- private queryStreamController: InvitationsQueryStreamController;
24
-
25
- private query: Amity.InvitationLiveCollection;
26
-
27
- constructor(
28
- query: Amity.InvitationLiveCollection,
29
- callback: Amity.LiveCollectionCallback<Amity.Invitation>,
30
- ) {
31
- const queryStreamId = hash(query);
32
- const cacheKey = ['invitation', 'collection', queryStreamId];
33
- const paginationController = new InvitationsPaginationController(query);
34
-
35
- super(paginationController, queryStreamId, cacheKey, callback);
36
-
37
- this.query = query;
38
- this.queryStreamController = new InvitationsQueryStreamController(
39
- this.query,
40
- this.cacheKey,
41
- this.notifyChange.bind(this),
42
- prepareInvitationPayload,
43
- );
44
-
45
- this.callback = callback.bind(this);
46
- this.loadPage({ initial: true });
47
- }
48
-
49
- protected setup() {
50
- const collection = pullFromCache<Amity.InvitationLiveCollectionCache>(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.InvitationPayload & Amity.Pagination) {
60
- await this.queryStreamController.saveToMainDB(queryPayload);
61
- }
62
-
63
- protected persistQueryStream({
64
- response,
65
- direction,
66
- refresh,
67
- }: Amity.LiveCollectionPersistQueryStreamParams<'invitation'>) {
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.InvitationLiveCollectionCache>(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
- }
@@ -1,19 +0,0 @@
1
- import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
2
- import { PaginationController } from '~/core/liveCollection/PaginationController';
3
-
4
- export class InvitationsPaginationController extends PaginationController<
5
- 'invitation',
6
- Amity.InvitationLiveCollection
7
- > {
8
- async getRequest(queryParams: Amity.InvitationLiveCollection, token: string | undefined) {
9
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, ...params } = queryParams;
10
- const options = token ? { token } : { limit };
11
-
12
- const { data } = await this.http.get<Amity.InvitationPayload & Amity.Pagination>(
13
- '/api/v1/invitations',
14
- { params: { ...params, options } },
15
- );
16
-
17
- return data;
18
- }
19
- }
@@ -1,97 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
- import { getResolver } from '~/core/model';
3
- import { InvitationActionsEnum } from './enums';
4
- import { pullFromCache, pushToCache } from '~/cache/api';
5
- import { ingestInCache } from '~/cache/api/ingestInCache';
6
- import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
7
-
8
- export class InvitationsQueryStreamController extends QueryStreamController<
9
- Amity.InvitationPayload,
10
- Amity.InvitationLiveCollection
11
- > {
12
- private notifyChange: (params: Amity.LiveCollectionNotifyParams) => void;
13
-
14
- private preparePayload: (response: Amity.InvitationPayload) => Amity.ProcessedInvitationPayload;
15
-
16
- constructor(
17
- query: Amity.InvitationLiveCollection,
18
- cacheKey: string[],
19
- notifyChange: (params: Amity.LiveCollectionNotifyParams) => void,
20
- preparePayload: (response: Amity.InvitationPayload) => Amity.ProcessedInvitationPayload,
21
- ) {
22
- super(query, cacheKey);
23
- this.notifyChange = notifyChange;
24
- this.preparePayload = preparePayload;
25
- }
26
-
27
- async saveToMainDB(response: Amity.InvitationPayload) {
28
- const processedPayload = await this.preparePayload(response);
29
-
30
- const client = getActiveClient();
31
- const cachedAt = client.cache && Date.now();
32
-
33
- if (client.cache) {
34
- ingestInCache(processedPayload, { cachedAt });
35
- }
36
- }
37
-
38
- appendToQueryStream(
39
- response: Amity.InvitationPayload & Partial<Amity.Pagination>,
40
- direction: Amity.LiveCollectionPageDirection,
41
- refresh = false,
42
- ) {
43
- if (refresh) {
44
- pushToCache(this.cacheKey, {
45
- data: response.invitations.map(getResolver('invitation')),
46
- });
47
- } else {
48
- const collection = pullFromCache<Amity.InvitationLiveCollectionCache>(this.cacheKey)?.data;
49
-
50
- const invitations = collection?.data ?? [];
51
-
52
- pushToCache(this.cacheKey, {
53
- ...collection,
54
- data: [
55
- ...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
56
- ],
57
- });
58
- }
59
- }
60
-
61
- reactor(action: InvitationActionsEnum) {
62
- return (invitations: Amity.InternalInvitation[]) => {
63
- const collection = pullFromCache<Amity.InvitationLiveCollectionCache>(this.cacheKey)?.data;
64
- if (!collection) return;
65
-
66
- if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
67
- const isExist = collection.data.find(id => id === invitations[0].invitationId);
68
- if (!isExist) return;
69
- }
70
-
71
- if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
72
- collection.data = [
73
- ...new Set([
74
- ...invitations.map(invitation => invitation.invitationId),
75
- ...collection.data,
76
- ]),
77
- ];
78
- }
79
-
80
- if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
81
- collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
82
- }
83
-
84
- pushToCache(this.cacheKey, collection);
85
- this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
86
- };
87
- }
88
-
89
- subscribeRTE(
90
- createSubscriber: {
91
- fn: (reactor: Amity.Listener<Amity.InternalInvitation[]>) => Amity.Unsubscriber;
92
- action: InvitationActionsEnum;
93
- }[],
94
- ) {
95
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
96
- }
97
- }
@@ -1,5 +0,0 @@
1
- export enum InvitationActionsEnum {
2
- OnLocalInvitationCreated = 'onLocalInvitationCreated',
3
- OnLocalInvitationUpdated = 'onLocalInvitationUpdated',
4
- OnLocalInvitationDeleted = 'onLocalInvitationDeleted',
5
- }
@@ -1,44 +0,0 @@
1
- import { dropFromCache } from '~/cache/api';
2
- import { getActiveClient } from '~/client/api/activeClient';
3
- import { ENABLE_CACHE_MESSAGE } from '~/utils/constants';
4
- import { InvitationsLiveCollectionController } from './getInvitations/InvitationsLiveCollectionController';
5
-
6
- /**
7
- * Get invitations
8
- *
9
- * @param params the query parameters
10
- * @param callback the callback to be called when the invitations are updated
11
- * @returns invitations
12
- *
13
- * @category Invitation Live Collection
14
- *
15
- */
16
- export const getInvitations = (
17
- params: Amity.InvitationLiveCollection,
18
- callback: Amity.LiveCollectionCallback<Amity.Invitation>,
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(`getInvitations: (tmpid: ${timestamp}) > listen`);
29
-
30
- const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
31
-
32
- const disposers = invitationsLiveCollection.startSubscription();
33
-
34
- const cacheKey = invitationsLiveCollection.getCacheKey();
35
-
36
- disposers.push(() => {
37
- dropFromCache(cacheKey);
38
- });
39
-
40
- return () => {
41
- log(`getInvitations (tmpid: ${timestamp}) > dispose`);
42
- disposers.forEach(fn => fn());
43
- };
44
- };
@@ -1,48 +0,0 @@
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
- };
@@ -1,148 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
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.communityId));
19
-
20
- return data;
21
- }
22
- }
@@ -1,105 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export * from './getMyCommunityInvitations';
@@ -1,8 +0,0 @@
1
- export const convertRawInvitationToInternalInvitation = (
2
- rawInvitation: Amity.RawInvitation,
3
- ): Amity.InternalInvitation => {
4
- return {
5
- ...rawInvitation,
6
- createdById: rawInvitation.createdBy,
7
- };
8
- };
@@ -1 +0,0 @@
1
- export * from './prepareInvitationPayload';
@@ -1,12 +0,0 @@
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
- };
@@ -1,12 +0,0 @@
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
- };