@amityco/ts-sdk 7.5.3 → 7.5.4-2d34fd5f.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 (388) 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 +51 -1
  11. package/dist/@types/domains/community.d.ts.map +1 -1
  12. package/dist/@types/domains/content.d.ts +11 -2
  13. package/dist/@types/domains/content.d.ts.map +1 -1
  14. package/dist/@types/domains/feed.d.ts +2 -1
  15. package/dist/@types/domains/feed.d.ts.map +1 -1
  16. package/dist/@types/domains/file.d.ts +3 -1
  17. package/dist/@types/domains/file.d.ts.map +1 -1
  18. package/dist/@types/domains/invitation.d.ts +92 -0
  19. package/dist/@types/domains/invitation.d.ts.map +1 -0
  20. package/dist/@types/domains/joinRequest.d.ts +53 -0
  21. package/dist/@types/domains/joinRequest.d.ts.map +1 -0
  22. package/dist/@types/domains/notification.d.ts +4 -2
  23. package/dist/@types/domains/notification.d.ts.map +1 -1
  24. package/dist/@types/domains/pinnedPost.d.ts +1 -1
  25. package/dist/@types/domains/pinnedPost.d.ts.map +1 -1
  26. package/dist/@types/domains/post.d.ts +3 -0
  27. package/dist/@types/domains/post.d.ts.map +1 -1
  28. package/dist/@types/index.d.ts +5 -0
  29. package/dist/@types/index.d.ts.map +1 -1
  30. package/dist/communityRepository/api/createCommunity.d.ts +2 -2
  31. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  32. package/dist/communityRepository/api/deleteCommunity.d.ts.map +1 -1
  33. package/dist/communityRepository/api/getCommunities.d.ts +1 -1
  34. package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
  35. package/dist/communityRepository/api/getCommunity.d.ts +2 -2
  36. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  37. package/dist/communityRepository/api/getRecommendedCommunities.d.ts +3 -1
  38. package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
  39. package/dist/communityRepository/api/getTrendingCommunities.d.ts +3 -1
  40. package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
  41. package/dist/communityRepository/api/joinCommunity.d.ts +3 -0
  42. package/dist/communityRepository/api/joinCommunity.d.ts.map +1 -1
  43. package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
  44. package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
  45. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  46. package/dist/communityRepository/communityMembership/events/index.d.ts +1 -0
  47. package/dist/communityRepository/communityMembership/events/index.d.ts.map +1 -1
  48. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
  49. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
  50. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
  51. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
  52. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
  53. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
  54. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
  55. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
  56. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
  57. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
  58. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
  59. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
  60. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
  61. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
  62. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
  63. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
  64. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
  65. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
  66. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts +2 -0
  67. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts.map +1 -0
  68. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
  69. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
  70. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
  71. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
  72. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
  73. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
  74. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
  75. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
  76. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
  77. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
  78. package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
  79. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  80. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
  81. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
  82. package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts +2 -1
  83. package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts.map +1 -1
  84. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
  85. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
  86. package/dist/communityRepository/communityMembership/observers/searchMembers/enums.d.ts +1 -0
  87. package/dist/communityRepository/communityMembership/observers/searchMembers/enums.d.ts.map +1 -1
  88. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
  89. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
  90. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
  91. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
  92. package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
  93. package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
  94. package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
  95. package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
  96. package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
  97. package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
  98. package/dist/communityRepository/events/utils.d.ts +1 -1
  99. package/dist/communityRepository/events/utils.d.ts.map +1 -1
  100. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts +16 -0
  101. package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts.map +1 -0
  102. package/dist/communityRepository/internalAPI/joinCommunity.d.ts +16 -0
  103. package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +1 -0
  104. package/dist/communityRepository/joinRequest/events/index.d.ts +4 -0
  105. package/dist/communityRepository/joinRequest/events/index.d.ts.map +1 -0
  106. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts +17 -0
  107. package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts.map +1 -0
  108. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts +17 -0
  109. package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts.map +1 -0
  110. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts +17 -0
  111. package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts.map +1 -0
  112. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts +16 -0
  113. package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +1 -0
  114. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts +16 -0
  115. package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +1 -0
  116. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts +16 -0
  117. package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +1 -0
  118. package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
  119. package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.d.ts.map +1 -1
  120. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
  121. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
  122. package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
  123. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts +14 -0
  124. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts.map +1 -0
  125. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts +9 -0
  126. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts.map +1 -0
  127. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts +15 -0
  128. package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts.map +1 -0
  129. package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts +6 -0
  130. package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts.map +1 -0
  131. package/dist/communityRepository/observers/getJoinRequestList.d.ts +12 -0
  132. package/dist/communityRepository/observers/getJoinRequestList.d.ts.map +1 -0
  133. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts +14 -0
  134. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts.map +1 -0
  135. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts +9 -0
  136. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -0
  137. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts +15 -0
  138. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts.map +1 -0
  139. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts +6 -0
  140. package/dist/communityRepository/observers/getJoinRequests/enum.d.ts.map +1 -0
  141. package/dist/communityRepository/observers/getJoinRequests.d.ts +12 -0
  142. package/dist/communityRepository/observers/getJoinRequests.d.ts.map +1 -0
  143. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
  144. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.d.ts.map +1 -1
  145. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
  146. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
  147. package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts +2 -1
  148. package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts.map +1 -1
  149. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -1
  150. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.d.ts.map +1 -1
  151. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
  152. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
  153. package/dist/communityRepository/observers/index.d.ts +1 -0
  154. package/dist/communityRepository/observers/index.d.ts.map +1 -1
  155. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts.map +1 -1
  156. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts.map +1 -1
  157. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
  158. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
  159. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.d.ts.map +1 -1
  160. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.d.ts.map +1 -1
  161. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
  162. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
  163. package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
  164. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  165. package/dist/communityRepository/utils/payload.d.ts +2 -1
  166. package/dist/communityRepository/utils/payload.d.ts.map +1 -1
  167. package/dist/core/events.d.ts +3 -3
  168. package/dist/core/events.d.ts.map +1 -1
  169. package/dist/core/model/idResolvers.d.ts.map +1 -1
  170. package/dist/core/model/index.d.ts.map +1 -1
  171. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
  172. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
  173. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  174. package/dist/fileRepository/api/index.d.ts +1 -0
  175. package/dist/fileRepository/api/index.d.ts.map +1 -1
  176. package/dist/fileRepository/api/uploadClip.d.ts +17 -0
  177. package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
  178. package/dist/index.cjs.js +3047 -1474
  179. package/dist/index.d.ts +1 -0
  180. package/dist/index.d.ts.map +1 -1
  181. package/dist/index.esm.js +3265 -1693
  182. package/dist/index.umd.js +4 -4
  183. package/dist/invitationRepository/events/index.d.ts +4 -0
  184. package/dist/invitationRepository/events/index.d.ts.map +1 -0
  185. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
  186. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
  187. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
  188. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
  189. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
  190. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
  191. package/dist/invitationRepository/index.d.ts +3 -0
  192. package/dist/invitationRepository/index.d.ts.map +1 -0
  193. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
  194. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
  195. package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
  196. package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
  197. package/dist/invitationRepository/internalApi/getInvitation.d.ts +17 -0
  198. package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +1 -0
  199. package/dist/invitationRepository/internalApi/index.d.ts +4 -0
  200. package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
  201. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
  202. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
  203. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +14 -0
  204. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  205. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +5 -0
  206. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  207. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +15 -0
  208. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  209. package/dist/invitationRepository/observers/getInvitations/enums.d.ts +6 -0
  210. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +1 -0
  211. package/dist/invitationRepository/observers/getInvitations.d.ts +12 -0
  212. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -0
  213. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts +12 -0
  214. package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts.map +1 -0
  215. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts +14 -0
  216. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts.map +1 -0
  217. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts +5 -0
  218. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +1 -0
  219. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +15 -0
  220. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +1 -0
  221. package/dist/invitationRepository/observers/index.d.ts +2 -0
  222. package/dist/invitationRepository/observers/index.d.ts.map +1 -0
  223. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts +2 -0
  224. package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts.map +1 -0
  225. package/dist/invitationRepository/utils/index.d.ts +2 -0
  226. package/dist/invitationRepository/utils/index.d.ts.map +1 -0
  227. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +2 -0
  228. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +1 -0
  229. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts +2 -0
  230. package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts.map +1 -0
  231. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  232. package/dist/postRepository/api/createClipPost.d.ts +32 -0
  233. package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
  234. package/dist/postRepository/api/index.d.ts +1 -0
  235. package/dist/postRepository/api/index.d.ts.map +1 -1
  236. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -1
  237. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  238. package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
  239. package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
  240. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
  241. package/dist/utils/linkedObject/index.d.ts +3 -0
  242. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  243. package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
  244. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
  245. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts +2 -0
  246. package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +1 -0
  247. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  248. package/dist/utils/postTypePredicate.d.ts +1 -0
  249. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  250. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  251. package/dist/utils/tests/dummy/post.d.ts +3 -3
  252. package/package.json +1 -1
  253. package/src/@types/core/events.ts +10 -0
  254. package/src/@types/core/model.ts +8 -1
  255. package/src/@types/core/payload.ts +48 -5
  256. package/src/@types/domains/client.ts +12 -0
  257. package/src/@types/domains/community.ts +82 -3
  258. package/src/@types/domains/content.ts +25 -1
  259. package/src/@types/domains/feed.ts +2 -1
  260. package/src/@types/domains/file.ts +5 -0
  261. package/src/@types/domains/invitation.ts +119 -0
  262. package/src/@types/domains/joinRequest.ts +66 -0
  263. package/src/@types/domains/notification.ts +2 -0
  264. package/src/@types/domains/pinnedPost.ts +1 -1
  265. package/src/@types/domains/post.ts +4 -0
  266. package/src/@types/index.ts +5 -0
  267. package/src/communityRepository/api/createCommunity.ts +5 -2
  268. package/src/communityRepository/api/deleteCommunity.ts +2 -1
  269. package/src/communityRepository/api/getCommunities.ts +9 -2
  270. package/src/communityRepository/api/getCommunity.ts +12 -3
  271. package/src/communityRepository/api/getRecommendedCommunities.ts +11 -4
  272. package/src/communityRepository/api/getTrendingCommunities.ts +11 -4
  273. package/src/communityRepository/api/joinCommunity.ts +4 -1
  274. package/src/communityRepository/api/queryCommunities.ts +7 -1
  275. package/src/communityRepository/api/updateCommunity.ts +13 -3
  276. package/src/communityRepository/communityMembership/events/index.ts +1 -0
  277. package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
  278. package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
  279. package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
  280. package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
  281. package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
  282. package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
  283. package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
  284. package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
  285. package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
  286. package/src/communityRepository/communityMembership/events/onLocalCommunityJoin.ts +20 -0
  287. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
  288. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
  289. package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
  290. package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
  291. package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
  292. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  293. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
  294. package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +1 -0
  295. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
  296. package/src/communityRepository/communityMembership/observers/searchMembers/enums.ts +1 -0
  297. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
  298. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
  299. package/src/communityRepository/events/onCommunityCreated.ts +1 -1
  300. package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
  301. package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
  302. package/src/communityRepository/events/utils.ts +1 -1
  303. package/src/communityRepository/internalAPI/getMyJoinRequest.ts +43 -0
  304. package/src/communityRepository/internalAPI/joinCommunity.ts +66 -0
  305. package/src/communityRepository/joinRequest/events/index.ts +3 -0
  306. package/src/communityRepository/joinRequest/events/onJoinRequestCreated.ts +33 -0
  307. package/src/communityRepository/joinRequest/events/onJoinRequestDeleted.ts +33 -0
  308. package/src/communityRepository/joinRequest/events/onJoinRequestUpdated.ts +33 -0
  309. package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +52 -0
  310. package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +49 -0
  311. package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +52 -0
  312. package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +6 -0
  313. package/src/communityRepository/observers/getCommunities/CommunitiesPaginationController.ts +1 -0
  314. package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
  315. package/src/communityRepository/observers/getCommunity.ts +26 -11
  316. package/src/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.ts +135 -0
  317. package/src/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.ts +30 -0
  318. package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts +116 -0
  319. package/src/communityRepository/observers/getJoinRequestList/enum.ts +5 -0
  320. package/src/communityRepository/observers/getJoinRequestList.ts +51 -0
  321. package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts +126 -0
  322. package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +25 -0
  323. package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts +108 -0
  324. package/src/communityRepository/observers/getJoinRequests/enum.ts +5 -0
  325. package/src/communityRepository/observers/getJoinRequests.ts +44 -0
  326. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +8 -1
  327. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.ts +6 -1
  328. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
  329. package/src/communityRepository/observers/getRecommendedCommunities/enums.ts +1 -0
  330. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +9 -1
  331. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.ts +6 -1
  332. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
  333. package/src/communityRepository/observers/index.ts +1 -0
  334. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.ts +6 -0
  335. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +1 -0
  336. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
  337. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.ts +6 -0
  338. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.ts +1 -0
  339. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
  340. package/src/communityRepository/utils/communityWithMembership.ts +9 -5
  341. package/src/communityRepository/utils/payload.ts +28 -2
  342. package/src/core/liveCollection/PaginationController.ts +1 -1
  343. package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
  344. package/src/core/model/idResolvers.ts +3 -0
  345. package/src/core/model/index.ts +3 -0
  346. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
  347. package/src/feedRepository/api/queryGlobalFeed.ts +3 -1
  348. package/src/fileRepository/api/index.ts +1 -0
  349. package/src/fileRepository/api/uploadClip.ts +71 -0
  350. package/src/index.ts +2 -0
  351. package/src/invitationRepository/events/index.ts +3 -0
  352. package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
  353. package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
  354. package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
  355. package/src/invitationRepository/index.ts +2 -0
  356. package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
  357. package/src/invitationRepository/internalApi/createInvitations.ts +52 -0
  358. package/src/invitationRepository/internalApi/getInvitation.ts +47 -0
  359. package/src/invitationRepository/internalApi/index.ts +3 -0
  360. package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
  361. package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +148 -0
  362. package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +19 -0
  363. package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +97 -0
  364. package/src/invitationRepository/observers/getInvitations/enums.ts +5 -0
  365. package/src/invitationRepository/observers/getInvitations.ts +44 -0
  366. package/src/invitationRepository/observers/getMyCommunityInvitations.ts +48 -0
  367. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.ts +148 -0
  368. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +22 -0
  369. package/src/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.ts +105 -0
  370. package/src/invitationRepository/observers/index.ts +1 -0
  371. package/src/invitationRepository/utils/convertRawInvitationToInternalInvitation.ts +8 -0
  372. package/src/invitationRepository/utils/index.ts +1 -0
  373. package/src/invitationRepository/utils/prepareInvitationPayload.ts +12 -0
  374. package/src/invitationRepository/utils/prepareMyInvitationsPayload.ts +12 -0
  375. package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
  376. package/src/postRepository/api/createClipPost.ts +62 -0
  377. package/src/postRepository/api/index.ts +2 -0
  378. package/src/postRepository/api/queryPosts.ts +1 -1
  379. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +7 -1
  380. package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +7 -1
  381. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  382. package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +4 -0
  383. package/src/utils/linkedObject/communityLinkedObject.ts +57 -0
  384. package/src/utils/linkedObject/index.ts +6 -0
  385. package/src/utils/linkedObject/invitationLinkedObject.ts +37 -0
  386. package/src/utils/linkedObject/joinRequestLinkedObject.ts +31 -0
  387. package/src/utils/linkedObject/postLinkedObject.ts +12 -1
  388. package/src/utils/postTypePredicate.ts +10 -0
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
60
60
  }
61
61
 
62
62
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
63
- return (community: Amity.Community) => {
63
+ return (community: Amity.InternalCommunity) => {
64
64
  const collection = pullFromCache<Amity.SearchCommunityLiveCollectionCache>(
65
65
  this.cacheKey,
66
66
  )?.data;
@@ -73,7 +73,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
73
73
 
74
74
  subscribeRTE(
75
75
  createSubscriber: {
76
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
76
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
77
77
  action: EnumCommunityActions | EnumCommunityMemberActions;
78
78
  }[],
79
79
  ) {
@@ -15,6 +15,7 @@ import {
15
15
  onLocalCommunityJoined,
16
16
  onLocalCommunityLeft,
17
17
  onCommunityUserChanged,
18
+ onLocalCommunityJoin,
18
19
  } from '~/communityRepository/communityMembership';
19
20
 
20
21
  import { isNonNullable } from '~/utils';
@@ -24,6 +25,7 @@ import { prepareSemanticSearchCommunityPayload } from '~/communityRepository/uti
24
25
  import { getActiveClient } from '~/client';
25
26
  import { EnumCommunityMemberActions } from '~/communityRepository/communityMembership/observers/getMembers/enums';
26
27
  import { filterByCommunityMembership } from '~/core/query';
28
+ import { convertEventPayload } from '~/utils/event';
27
29
 
28
30
  export class SemanticSearchCommunityLiveCollectionController extends LiveCollectionController<
29
31
  'semanticSearchCommunity',
@@ -94,6 +96,10 @@ export class SemanticSearchCommunityLiveCollectionController extends LiveCollect
94
96
  { fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnMemberCountChanged },
95
97
  { fn: onLocalCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
96
98
  { fn: onLocalCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
99
+ {
100
+ fn: convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
101
+ action: EnumCommunityActions.OnCommunityUpdated,
102
+ },
97
103
  ]);
98
104
  }
99
105
 
@@ -29,6 +29,7 @@ export class SemanticSearchCommunityPaginationController extends PaginationContr
29
29
  ...params,
30
30
  filter: communityMembershipStatus ?? AmityCommunityMemberStatusFilter.ALL,
31
31
  options,
32
+ includeDiscoverablePrivateCommunity: params.includeDiscoverablePrivateCommunity ?? true,
32
33
  },
33
34
  });
34
35
  return queryResponse;
@@ -63,7 +63,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
63
63
  }
64
64
 
65
65
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
66
- return (community: Amity.Community) => {
66
+ return (community: Amity.InternalCommunity) => {
67
67
  const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
68
68
  if (!collection) return;
69
69
 
@@ -77,7 +77,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
77
77
 
78
78
  subscribeRTE(
79
79
  createSubscriber: {
80
- fn: (reactor: (community: Amity.Community) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (community: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
81
81
  action: EnumCommunityActions | EnumCommunityMemberActions;
82
82
  }[],
83
83
  ) {
@@ -1,5 +1,5 @@
1
1
  import { pullFromCache } from '~/cache/api';
2
- import { getActiveUser } from '~/client';
2
+ import { getActiveUser } from '~/client/api/activeUser';
3
3
 
4
4
  /*
5
5
  * verifies membership status
@@ -12,7 +12,7 @@ function isMember(membership: Amity.Membership<'community'>['communityMembership
12
12
  * checks if currently logged in user is part of the community
13
13
  */
14
14
  function isCurrentUserPartOfCommunity(
15
- c: Amity.Community,
15
+ c: Amity.InternalCommunity,
16
16
  m: Amity.Membership<'community'>,
17
17
  ): boolean {
18
18
  const { userId } = getActiveUser();
@@ -28,11 +28,15 @@ function isCurrentUserPartOfCommunity(
28
28
  * Althought this can be calculated, it's not scalable.
29
29
  */
30
30
  export function updateMembershipStatus(
31
- communities: Amity.Community[],
31
+ communities: Amity.RawCommunity[],
32
32
  communityUsers: Amity.Membership<'community'>[],
33
- ): Amity.Community[] {
33
+ ): Amity.InternalCommunity[] {
34
34
  return communities.map(c => {
35
- const cachedCommunity = pullFromCache<Amity.Community>(['community', 'get', c.communityId]);
35
+ const cachedCommunity = pullFromCache<Amity.InternalCommunity>([
36
+ 'community',
37
+ 'get',
38
+ c.communityId,
39
+ ]);
36
40
  if (cachedCommunity?.data && cachedCommunity?.data.hasOwnProperty('isJoined')) {
37
41
  return {
38
42
  ...cachedCommunity.data,
@@ -1,5 +1,6 @@
1
1
  import { CommunityPostSettingMaps, DefaultCommunityPostSetting } from '~/@types';
2
2
  import { updateMembershipStatus } from './communityWithMembership';
3
+ import { convertRawUserToInternalUser } from '~/userRepository/utils/convertRawUserToInternalUser';
3
4
 
4
5
  const getMatchPostSetting = (value: {
5
6
  needApprovalOnPostCreation: Amity.RawCommunity['needApprovalOnPostCreation'];
@@ -13,7 +14,7 @@ const getMatchPostSetting = (value: {
13
14
  ) ?? DefaultCommunityPostSetting;
14
15
 
15
16
  export function addPostSetting({ communities }: { communities: Amity.RawCommunity[] }) {
16
- return communities.map<Amity.Community>(
17
+ return communities.map<Amity.InternalCommunity>(
17
18
  ({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
18
19
  postSetting: getMatchPostSetting({
19
20
  needApprovalOnPostCreation,
@@ -29,10 +30,13 @@ export const prepareCommunityPayload = (
29
30
  ): Amity.ProcessedCommunityPayload => {
30
31
  const communitiesWithPostSetting = addPostSetting({ communities: rawPayload.communities });
31
32
 
33
+ // Convert users to internal format
34
+ const internalUsers = rawPayload.users.map(convertRawUserToInternalUser);
35
+
32
36
  // map users with community
33
37
  const mappedCommunityUsers: Array<Amity.Membership<'community'>> = rawPayload.communityUsers.map(
34
38
  communityUser => {
35
- const user = rawPayload.users.find(user => user.userId === communityUser.userId)!;
39
+ const user = internalUsers.find(user => user.userId === communityUser.userId)!;
36
40
 
37
41
  return {
38
42
  ...communityUser,
@@ -48,11 +52,33 @@ export const prepareCommunityPayload = (
48
52
 
49
53
  return {
50
54
  ...rawPayload,
55
+ users: rawPayload.users.map(convertRawUserToInternalUser),
51
56
  communities: communityWithMembershipStatus,
52
57
  communityUsers: mappedCommunityUsers,
53
58
  };
54
59
  };
55
60
 
61
+ export const prepareCommunityJoinRequestPayload = (
62
+ rawPayload: Amity.CommunityJoinRequestPayload,
63
+ ): Amity.ProcessedJoinRequestPayload => {
64
+ const mappedJoinRequests: Array<Amity.InternalJoinRequest> = rawPayload.joinRequests.map(
65
+ joinRequest => {
66
+ return {
67
+ ...joinRequest,
68
+ joinRequestId: joinRequest._id,
69
+ };
70
+ },
71
+ );
72
+
73
+ const users = rawPayload.users.map(convertRawUserToInternalUser);
74
+
75
+ return {
76
+ ...rawPayload,
77
+ joinRequests: mappedJoinRequests,
78
+ users,
79
+ };
80
+ };
81
+
56
82
  export const prepareCommunityMembershipPayload = (
57
83
  rawPayload: Amity.CommunityMembershipPayload,
58
84
  ): Amity.ProcessedCommunityMembershipPayload => {
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { getActiveClient } from '~/client/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
3
 
4
4
  export abstract class PaginationController<
5
5
  TPayloadDomain extends keyof Amity.Payloads,
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { getActiveClient } from '~/client/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
3
 
4
4
  export abstract class PaginationNoPageController<
5
5
  TPayloadDomain extends keyof Amity.Payloads,
@@ -64,6 +64,9 @@ const idResolvers: Resolvers = {
64
64
 
65
65
  notificationTrayItem: ({ _id }) => _id,
66
66
  notificationTraySeen: ({ userId }) => userId,
67
+
68
+ invitation: ({ _id }) => _id,
69
+ joinRequest: ({ joinRequestId }) => joinRequestId,
67
70
  };
68
71
 
69
72
  /**
@@ -54,6 +54,9 @@ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = {
54
54
  pins: 'pin',
55
55
 
56
56
  notificationTrayItems: 'notificationTrayItem',
57
+
58
+ invitations: 'invitation',
59
+ joinRequests: 'joinRequest',
57
60
  };
58
61
 
59
62
  /** hidden */
@@ -23,7 +23,7 @@ import { LinkedObject } from '~/utils/linkedObject';
23
23
  * @async
24
24
  * */
25
25
  export const getCustomRankingGlobalFeed = async (query?: {
26
- dataTypes?: ('video' | 'image' | 'file' | 'liveStream')[];
26
+ dataTypes?: ('video' | 'image' | 'file' | 'liveStream' | 'clip')[];
27
27
  limit?: number;
28
28
  queryToken?: string;
29
29
  }): Promise<
@@ -32,7 +32,7 @@ export const queryGlobalFeed = async (
32
32
  const client = getActiveClient();
33
33
  client.log('feed/queryGlobalFeed', query);
34
34
 
35
- const { queryToken, ...params } = query ?? {};
35
+ const { queryToken, dataTypes, resolveParent, ...params } = query ?? {};
36
36
 
37
37
  const options = (() => {
38
38
  if (queryToken) return { token: queryToken };
@@ -44,6 +44,8 @@ export const queryGlobalFeed = async (
44
44
  {
45
45
  params: {
46
46
  ...params,
47
+ dataTypes,
48
+ resolveParent: resolveParent ?? true,
47
49
  options,
48
50
  },
49
51
  },
@@ -5,3 +5,4 @@ export * from './fileUrlWithSize';
5
5
  export * from './uploadVideo';
6
6
  export * from './uploadImage';
7
7
  export * from './updateAltText';
8
+ export * from './uploadClip';
@@ -0,0 +1,71 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { ingestInCache } from '~/cache/api/ingestInCache';
3
+ import GlobalFileAccessType from '~/client/utils/GlobalFileAccessType';
4
+
5
+ /* begin_public_function
6
+ id: file.upload.clip
7
+ */
8
+ /**
9
+ * ```js
10
+ * import { FileRepository } from '@amityco/ts-sdk'
11
+ * const created = await FileRepository.uploadClip(formData)
12
+ * ```
13
+ *
14
+ * Creates an {@link Amity.File}
15
+ *
16
+ * @param formData The data necessary to create a new {@link Amity.File}
17
+ * @param onProgress The callback to track the upload progress
18
+ * @returns The newly created {@link Amity.File}
19
+ *
20
+ * @category File API
21
+ * @async
22
+ */
23
+ export const uploadClip = async (
24
+ formData: FormData,
25
+ feedType?: Amity.ContentFeedType,
26
+ onProgress?: (percent: number) => void,
27
+ ): Promise<Amity.Cached<Amity.File<'clip'>[]>> => {
28
+ const client = getActiveClient();
29
+ client.log('file/uploadClip', formData);
30
+
31
+ const file = formData.get('files');
32
+
33
+ if (!file) throw new Error('The formData object must have a `files` key.');
34
+
35
+ const accessType = GlobalFileAccessType.getInstance().getFileAccessType();
36
+ formData.append('accessType', accessType);
37
+
38
+ formData.append('preferredFilename', (file as File).name);
39
+
40
+ if (feedType) {
41
+ formData.append('feedType', feedType);
42
+ }
43
+
44
+ const headers =
45
+ 'getHeaders' in formData
46
+ ? (formData as any).getHeaders()
47
+ : { 'content-type': 'multipart/form-data' };
48
+
49
+ const { data } = await client.upload.post<Amity.CreateFilePayload<'clip'>>(
50
+ '/api/v4/clips',
51
+ formData,
52
+ {
53
+ headers,
54
+ onUploadProgress({ loaded, total = 100 }) {
55
+ onProgress && onProgress(Math.round((loaded * 100) / total));
56
+ },
57
+ },
58
+ );
59
+
60
+ // API-FIX: payload should be serialized properly
61
+ // const { files } = data
62
+
63
+ const cachedAt = client.cache && Date.now();
64
+ if (client.cache) ingestInCache({ files: data }, { cachedAt });
65
+
66
+ return {
67
+ data,
68
+ cachedAt,
69
+ };
70
+ };
71
+ /* end_public_function */
package/src/index.ts CHANGED
@@ -51,3 +51,5 @@ export * as AdRepository from './adRepository';
51
51
  export * from './external/api';
52
52
 
53
53
  export * as notificationTray from './notificationTray';
54
+
55
+ export * as InvitationRepository from './invitationRepository';
@@ -0,0 +1,3 @@
1
+ export * from './onLocalInvitationCreated';
2
+ export * from './onLocalInvitationUpdated';
3
+ export * from './onLocalInvitationDeleted';
@@ -0,0 +1,33 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { createEventSubscriber } from '~/core/events';
3
+
4
+ /**
5
+ * ```js
6
+ * import { onLocalInvitationCreated } from '@amityco/ts-sdk'
7
+ * const dispose = onLocalInvitationCreated(data => {
8
+ * // ...
9
+ * })
10
+ * ```
11
+ *
12
+ * Fired when an {@link Amity.InvitationPayload} has been created
13
+ *
14
+ * @param callback The function to call when the event was fired
15
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
16
+ *
17
+ * @category Invitation Events
18
+ */
19
+ export const onLocalInvitationCreated = (
20
+ callback: Amity.Listener<Amity.InternalInvitation[]>,
21
+ ): Amity.Unsubscriber => {
22
+ const client = getActiveClient();
23
+
24
+ const disposers = [
25
+ createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload =>
26
+ callback(payload),
27
+ ),
28
+ ];
29
+
30
+ return () => {
31
+ disposers.forEach(fn => fn());
32
+ };
33
+ };
@@ -0,0 +1,33 @@
1
+ import { createEventSubscriber } from '~/core/events';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
+
4
+ /**
5
+ * ```js
6
+ * import { onLocalInvitationDeleted } from '@amityco/ts-sdk'
7
+ * const dispose = onLocalInvitationDeleted(data => {
8
+ * // ...
9
+ * })
10
+ * ```
11
+ *
12
+ * Fired when an {@link Amity.InvitationPayload} has been deleted
13
+ *
14
+ * @param callback The function to call when the event was fired
15
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
16
+ *
17
+ * @category Invitation Events
18
+ */
19
+ export const onLocalInvitationDeleted = (
20
+ callback: Amity.Listener<Amity.InternalInvitation[]>,
21
+ ): Amity.Unsubscriber => {
22
+ const client = getActiveClient();
23
+
24
+ const disposers = [
25
+ createEventSubscriber(client, 'onLocalInvitationDeleted', 'local.invitation.deleted', payload =>
26
+ callback(payload),
27
+ ),
28
+ ];
29
+
30
+ return () => {
31
+ disposers.forEach(fn => fn());
32
+ };
33
+ };
@@ -0,0 +1,33 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { createEventSubscriber } from '~/core/events';
3
+
4
+ /**
5
+ * ```js
6
+ * import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
7
+ * const dispose = onLocalInvitationUpdated(data => {
8
+ * // ...
9
+ * })
10
+ * ```
11
+ *
12
+ * Fired when an {@link Amity.InvitationPayload} has been updated
13
+ *
14
+ * @param callback The function to call when the event was fired
15
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
16
+ *
17
+ * @category Invitation Events
18
+ */
19
+ export const onLocalInvitationUpdated = (
20
+ callback: Amity.Listener<Amity.InternalInvitation[]>,
21
+ ): Amity.Unsubscriber => {
22
+ const client = getActiveClient();
23
+
24
+ const disposers = [
25
+ createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload =>
26
+ callback(payload),
27
+ ),
28
+ ];
29
+
30
+ return () => {
31
+ disposers.forEach(fn => fn());
32
+ };
33
+ };
@@ -0,0 +1,2 @@
1
+ export * from './events';
2
+ export * from './observers';
@@ -0,0 +1,45 @@
1
+ import { fireEvent } from '~/core/events';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
+ import { pullFromCache, upsertInCache } from '~/cache/api';
4
+ import { InvitationStatusEnum } from '~/@types';
5
+
6
+ /* begin_public_function
7
+ id: invitation.accept
8
+ */
9
+ /**
10
+ * ```js
11
+ * import { acceptInvitation } from '@amityco/ts-sdk'
12
+ * const isAccepted = await acceptInvitation(invitationId)
13
+ * ```
14
+ *
15
+ * Accepts a {@link Amity.Invitation} object
16
+ *
17
+ * @param invitationId the {@link Amity.Invitation} to accept
18
+ * @returns A success boolean if the {@link Amity.Invitation} was accepted
19
+ *
20
+ * @category Invitation API
21
+ * @async
22
+ */
23
+ export const acceptInvitation = async (invitationId: Amity.Invitation['_id']): Promise<boolean> => {
24
+ const client = getActiveClient();
25
+ client.log('invitation/acceptInvitation', invitationId);
26
+
27
+ const { data } = await client.http.post<{ success: boolean }>(
28
+ `/api/v1/invitations/${invitationId}/accept`,
29
+ );
30
+
31
+ const invitation = pullFromCache<Amity.InternalInvitation>([
32
+ 'invitation',
33
+ 'get',
34
+ invitationId,
35
+ ])?.data;
36
+
37
+ if (invitation) {
38
+ upsertInCache(['invitation', 'get', invitationId], { status: InvitationStatusEnum.Approved });
39
+
40
+ fireEvent('local.invitation.updated', [invitation]);
41
+ }
42
+
43
+ return data.success;
44
+ };
45
+ /* end_public_function */
@@ -0,0 +1,52 @@
1
+ import { fireEvent } from '~/core/events';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
+ import { ingestInCache } from '~/cache/api/ingestInCache';
4
+ import { prepareInvitationPayload } from '../utils';
5
+
6
+ /* begin_public_function
7
+ id: invitation.createInvitations
8
+ */
9
+ /**
10
+ * ```js
11
+ * import { createInvitations } from '@amityco/ts-sdk'
12
+ * const created = await createInvitations({
13
+ * type: string,
14
+ * targetType: string,
15
+ * targetId: string,
16
+ * userIds: string[]
17
+ * }))
18
+ * ```
19
+ *
20
+ * Creates an {@link Amity.Invitation}
21
+ *
22
+ * @param bundle The data necessary to create a new {@link Amity.Invitation}
23
+ * @returns The newly created {@link Amity.Invitation}
24
+ *
25
+ * @category Invitation API
26
+ * @async
27
+ */
28
+ export const createInvitations = async (
29
+ bundle: Amity.CreateInvitations,
30
+ ): Promise<Amity.Cached<Amity.InternalInvitation[]>> => {
31
+ const client = getActiveClient();
32
+ client.log('invitation/createInvitations', bundle);
33
+
34
+ const { data: payload } = await client.http.post<Amity.InvitationPayload>(
35
+ '/api/v1/invitations',
36
+ bundle,
37
+ );
38
+
39
+ const data = prepareInvitationPayload(payload);
40
+
41
+ const cachedAt = client.cache && Date.now();
42
+
43
+ if (client.cache) ingestInCache(data, { cachedAt });
44
+
45
+ fireEvent('local.invitation.created', data.invitations);
46
+
47
+ return {
48
+ data: data.invitations,
49
+ cachedAt,
50
+ };
51
+ };
52
+ /* end_public_function */
@@ -0,0 +1,47 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { ingestInCache } from '~/cache/api/ingestInCache';
3
+ import { prepareMyInvitationsPayload } from '../utils/prepareMyInvitationsPayload';
4
+ import { invitationLinkedObject } from '~/utils/linkedObject/invitationLinkedObject';
5
+
6
+ /* begin_public_function
7
+ id: invitation.get
8
+ */
9
+ /**
10
+ * ```js
11
+ * import { getInvitation } from '@amityco/ts-sdk'
12
+ * const { invitation } = await getInvitation(targetType, targetId)
13
+ * ```
14
+ *
15
+ * Get a {@link Amity.Invitation} object
16
+ *
17
+ * @param targetType The type of the target of the {@link Amity.Invitation}
18
+ * @param targetId The ID of the target of the {@link Amity.Invitation}
19
+ * @returns A {@link Amity.Invitation} object
20
+ *
21
+ * @category Invitation API
22
+ * @async
23
+ */
24
+ export const getInvitation = async (
25
+ targetType: Amity.Invitation['targetType'],
26
+ targetId: Amity.Invitation['targetId'],
27
+ ): Promise<Amity.Cached<Amity.Invitation | undefined>> => {
28
+ const client = getActiveClient();
29
+ client.log('invitation/getInvitation', targetType, targetId);
30
+
31
+ const { data: payload } = await client.http.get<Amity.MyInvitationsPayload>(
32
+ `/api/v1/invitations/me`,
33
+ { params: { targetType, targetId } },
34
+ );
35
+
36
+ const data = prepareMyInvitationsPayload(payload);
37
+
38
+ const cachedAt = client.cache && Date.now();
39
+
40
+ if (client.cache) ingestInCache(data, { cachedAt });
41
+
42
+ return {
43
+ data: data.invitations[0] ? invitationLinkedObject(data.invitations[0]) : undefined,
44
+ cachedAt,
45
+ };
46
+ };
47
+ /* end_public_function */
@@ -0,0 +1,3 @@
1
+ export * from './createInvitations';
2
+ export * from './acceptInvitation';
3
+ export * from './rejectInvitation';
@@ -0,0 +1,45 @@
1
+ import { fireEvent } from '~/core/events';
2
+ import { InvitationStatusEnum } from '~/@types';
3
+ import { pullFromCache, upsertInCache } from '~/cache/api';
4
+ import { getActiveClient } from '~/client/api/activeClient';
5
+
6
+ /* begin_public_function
7
+ id: invitation.reject
8
+ */
9
+ /**
10
+ * ```js
11
+ * import { rejectInvitation } from '@amityco/ts-sdk'
12
+ * const isRejected = await rejectInvitation(invitationId)
13
+ * ```
14
+ *
15
+ * Rejects a {@link Amity.Invitation} object
16
+ *
17
+ * @param invitationId the {@link Amity.Invitation} to reject
18
+ * @returns A success boolean if the {@link Amity.Invitation} was rejected
19
+ *
20
+ * @category Invitation API
21
+ * @async
22
+ */
23
+ export const rejectInvitation = async (invitationId: Amity.Invitation['_id']): Promise<boolean> => {
24
+ const client = getActiveClient();
25
+ client.log('invitation/rejectInvitation', invitationId);
26
+
27
+ const { data } = await client.http.post<{ success: boolean }>(
28
+ `/api/v1/invitations/${invitationId}/reject`,
29
+ );
30
+
31
+ const invitation = pullFromCache<Amity.InternalInvitation>([
32
+ 'invitation',
33
+ 'get',
34
+ invitationId,
35
+ ])?.data;
36
+
37
+ if (invitation) {
38
+ upsertInCache(['invitation', 'get', invitationId], { status: InvitationStatusEnum.Rejected });
39
+
40
+ fireEvent('local.invitation.updated', [invitation]);
41
+ }
42
+
43
+ return data.success;
44
+ };
45
+ /* end_public_function */