@amityco/ts-sdk-react-native 6.12.1 → 6.13.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.
- package/README.md +8 -9
- package/dist/@types/core/marker.d.ts +4 -4
- package/dist/@types/core/marker.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +6 -6
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +21 -21
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/analytics.d.ts +31 -0
- package/dist/@types/domains/analytics.d.ts.map +1 -0
- package/dist/@types/domains/block.d.ts +1 -1
- package/dist/@types/domains/block.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts +5 -2
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +3 -3
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +2 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +5 -5
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +4 -4
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -2
- package/dist/@types/domains/group.d.ts.map +1 -1
- package/dist/@types/domains/messagePreview.d.ts +2 -2
- package/dist/@types/domains/messagePreview.d.ts.map +1 -1
- package/dist/@types/domains/poll.d.ts +1 -1
- package/dist/@types/domains/poll.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +15 -7
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/reaction.d.ts +1 -1
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +2 -2
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +7 -3
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/analytic/api/queryReachUser.d.ts +6 -0
- package/dist/analytic/api/queryReachUser.d.ts.map +1 -0
- package/dist/analytic/api/syncEvent.d.ts +2 -0
- package/dist/analytic/api/syncEvent.d.ts.map +1 -0
- package/dist/analytic/constant.d.ts +2 -0
- package/dist/analytic/constant.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +15 -0
- package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +9 -0
- package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts +8 -0
- package/dist/analytic/service/analytic/AnalyticsEventSyncer.d.ts.map +1 -0
- package/dist/analytic/service/analytic/AnalyticsService.d.ts +10 -0
- package/dist/analytic/service/analytic/AnalyticsService.d.ts.map +1 -0
- package/dist/analytic/utils/analyticsEngineOnLoginHandler.d.ts +3 -0
- package/dist/analytic/utils/analyticsEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/cache/api/pushToCache.d.ts +1 -1
- package/dist/cache/api/upsertInCache.d.ts +1 -1
- package/dist/categoryRepository/api/getCategory.d.ts.map +1 -1
- package/dist/categoryRepository/api/queryCategories.d.ts.map +1 -1
- package/dist/categoryRepository/observers/getCategories.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts +4 -4
- package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelMembership/api/queryChannelMembers.d.ts +1 -1
- package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts +4 -4
- package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts +4 -4
- package/dist/channelRepsitory/channelModeration/api/addRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts +2 -2
- package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts +4 -4
- package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts.map +1 -1
- package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts +2 -2
- package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/channelRepsitory/events/onChannelMemberAdded.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberBanned.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberRemoved.d.ts +1 -1
- package/dist/channelRepsitory/events/onChannelMemberUnbanned.d.ts +1 -1
- package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts.map +1 -0
- package/dist/channelRepsitory/observers/tests/getChannelWithMessagePreview.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannelWithMessagePreview.test.d.ts.map +1 -0
- package/dist/channelRepsitory/observers/tests/getChannelsWithMessagePreview.test.d.ts +2 -0
- package/dist/channelRepsitory/observers/tests/getChannelsWithMessagePreview.test.d.ts.map +1 -0
- package/dist/client/api/getToken.d.ts +3 -3
- package/dist/client/api/getToken.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts +1 -1
- package/dist/commentRepository/api/getComment.d.ts +8 -8
- package/dist/commentRepository/api/getComment.d.ts.map +1 -1
- package/dist/commentRepository/api/getCommentByIds.d.ts +8 -8
- package/dist/commentRepository/api/getCommentByIds.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentCreated.d.ts +2 -2
- package/dist/commentRepository/events/onCommentCreated.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentDeleted.d.ts +2 -2
- package/dist/commentRepository/events/onCommentDeleted.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentFlagged.d.ts +2 -2
- package/dist/commentRepository/events/onCommentFlagged.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentReactionAdded.d.ts +2 -2
- package/dist/commentRepository/events/onCommentReactionAdded.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts +2 -2
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentUnflagged.d.ts +2 -2
- package/dist/commentRepository/events/onCommentUnflagged.d.ts.map +1 -1
- package/dist/commentRepository/events/onCommentUpdated.d.ts +2 -2
- package/dist/commentRepository/events/onCommentUpdated.d.ts.map +1 -1
- package/dist/commentRepository/events/utils.d.ts +1 -1
- package/dist/commentRepository/events/utils.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComment.d.ts +2 -2
- package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/addMembers.d.ts +4 -4
- package/dist/communityRepository/communityMembership/api/addMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/queryCommunityMembers.d.ts +1 -1
- package/dist/communityRepository/communityMembership/api/removeMembers.d.ts +4 -4
- package/dist/communityRepository/communityMembership/api/removeMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts +4 -4
- package/dist/communityRepository/communityModeration/api/addRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts +4 -4
- package/dist/communityRepository/communityModeration/api/removeRoles.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts +2 -2
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts.map +1 -1
- package/dist/core/device.d.ts +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +4 -4
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/external/api/createUserToken.d.ts +2 -2
- package/dist/external/api/createUserToken.d.ts.map +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/group/utils/withUser.d.ts +3 -3
- package/dist/group/utils/withUser.d.ts.map +1 -1
- package/dist/index.cjs.js +567 -217
- package/dist/index.esm.js +567 -217
- package/dist/index.umd.js +2 -2
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/messagePreview/utils/updateMessagePreviewFromMessage.d.ts.map +1 -1
- package/dist/messageRepository/api/getDeliveredUsers.d.ts +6 -6
- package/dist/messageRepository/api/getDeliveredUsers.d.ts.map +1 -1
- package/dist/messageRepository/api/getReadUsers.d.ts +6 -6
- package/dist/messageRepository/api/getReadUsers.d.ts.map +1 -1
- package/dist/messageRepository/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/postRepository/api/approvePost.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts +1 -1
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/declinePost.d.ts.map +1 -1
- package/dist/postRepository/api/deletePost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts.map +1 -1
- package/dist/postRepository/api/getPost.d.ts.map +1 -1
- package/dist/postRepository/api/getPostByIds.d.ts.map +1 -1
- package/dist/postRepository/api/hardDeletePost.d.ts.map +1 -1
- package/dist/postRepository/api/queryPosts.d.ts.map +1 -1
- package/dist/postRepository/api/softDeletePost.d.ts.map +1 -1
- package/dist/postRepository/api/tests/getPost.test.d.ts.map +1 -0
- package/dist/postRepository/api/updatePost.d.ts.map +1 -1
- package/dist/postRepository/events/onPostApproved.d.ts +2 -2
- package/dist/postRepository/events/onPostApproved.d.ts.map +1 -1
- package/dist/postRepository/events/onPostCreated.d.ts +2 -2
- package/dist/postRepository/events/onPostCreated.d.ts.map +1 -1
- package/dist/postRepository/events/onPostDeclined.d.ts +2 -2
- package/dist/postRepository/events/onPostDeclined.d.ts.map +1 -1
- package/dist/postRepository/events/onPostDeleted.d.ts +2 -2
- package/dist/postRepository/events/onPostDeleted.d.ts.map +1 -1
- package/dist/postRepository/events/onPostFlagged.d.ts +2 -2
- package/dist/postRepository/events/onPostFlagged.d.ts.map +1 -1
- package/dist/postRepository/events/onPostReactionAdded.d.ts +2 -2
- package/dist/postRepository/events/onPostReactionAdded.d.ts.map +1 -1
- package/dist/postRepository/events/onPostReactionRemoved.d.ts +2 -2
- package/dist/postRepository/events/onPostReactionRemoved.d.ts.map +1 -1
- package/dist/postRepository/events/onPostUnflagged.d.ts +2 -2
- package/dist/postRepository/events/onPostUnflagged.d.ts.map +1 -1
- package/dist/postRepository/events/onPostUpdated.d.ts +2 -2
- package/dist/postRepository/events/onPostUpdated.d.ts.map +1 -1
- package/dist/postRepository/events/utils.d.ts +1 -1
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts.d.ts +3 -2
- package/dist/postRepository/observers/getPosts.d.ts.map +1 -1
- package/dist/postRepository/observers/observePost.d.ts +2 -2
- package/dist/postRepository/observers/observePost.d.ts.map +1 -1
- package/dist/postRepository/observers/observePosts.d.ts +2 -3
- package/dist/postRepository/observers/observePosts.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactionAdded.d.ts +1 -1
- package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactionRemoved.d.ts +1 -1
- package/dist/reactionRepository/events/onReactionRemoved.d.ts.map +1 -1
- package/dist/reactionRepository/utils/fetchReference.d.ts +1 -1
- package/dist/reactionRepository/utils/fetchReference.d.ts.map +1 -1
- package/dist/streamRepository/api/getStreams.d.ts +1 -1
- package/dist/streamRepository/api/getStreams.d.ts.map +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts.map +1 -1
- package/dist/subChannelRepository/observers/tests/getSubChannelWithMessagePreview.test.d.ts +2 -0
- package/dist/subChannelRepository/observers/tests/getSubChannelWithMessagePreview.test.d.ts.map +1 -0
- package/dist/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.d.ts +2 -0
- package/dist/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.d.ts.map +1 -0
- package/dist/subChannelRepository/utils/updateSubChannelCache.d.ts +1 -1
- package/dist/subChannelRepository/utils/updateSubChannelCache.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +1 -1
- package/dist/userRepository/api/flagUser.d.ts.map +1 -1
- package/dist/userRepository/api/getUser.d.ts.map +1 -1
- package/dist/userRepository/api/getUserByIds.d.ts +1 -1
- package/dist/userRepository/api/getUserByIds.d.ts.map +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
- package/dist/userRepository/api/queryBlockedUsers.d.ts +5 -5
- package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/api/queryUsers.d.ts +6 -6
- package/dist/userRepository/api/queryUsers.d.ts.map +1 -1
- package/dist/userRepository/api/unflagUser.d.ts +1 -1
- package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
- package/dist/userRepository/api/updateUser.d.ts +4 -4
- package/dist/userRepository/api/updateUser.d.ts.map +1 -1
- package/dist/userRepository/events/onUserDeleted.d.ts +2 -2
- package/dist/userRepository/events/onUserDeleted.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFetched.d.ts +2 -2
- package/dist/userRepository/events/onUserFetched.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFlagCleared.d.ts +2 -2
- package/dist/userRepository/events/onUserFlagCleared.d.ts.map +1 -1
- package/dist/userRepository/events/onUserFlagged.d.ts +2 -2
- package/dist/userRepository/events/onUserFlagged.d.ts.map +1 -1
- package/dist/userRepository/events/onUserUnflagged.d.ts +2 -2
- package/dist/userRepository/events/onUserUnflagged.d.ts.map +1 -1
- package/dist/userRepository/events/onUserUpdated.d.ts +2 -2
- package/dist/userRepository/events/onUserUpdated.d.ts.map +1 -1
- package/dist/userRepository/events/utils.d.ts +1 -1
- package/dist/userRepository/events/utils.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getUser.d.ts +2 -2
- package/dist/userRepository/observers/getUser.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getViewedUsers.d.ts +2 -0
- package/dist/userRepository/observers/getViewedUsers.d.ts.map +1 -0
- package/dist/userRepository/observers/index.d.ts +1 -0
- package/dist/userRepository/observers/index.d.ts.map +1 -1
- package/dist/userRepository/observers/observeUser.d.ts +2 -2
- package/dist/userRepository/observers/observeUser.d.ts.map +1 -1
- package/dist/userRepository/observers/searchUserByDisplayName.d.ts +2 -2
- package/dist/userRepository/observers/searchUserByDisplayName.d.ts.map +1 -1
- package/dist/userRepository/observers/tests/getViewedUsers.test.d.ts +2 -0
- package/dist/userRepository/observers/tests/getViewedUsers.test.d.ts.map +1 -0
- package/dist/userRepository/relationship/block/api/blockUser.d.ts +4 -4
- package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts +4 -4
- package/dist/userRepository/relationship/block/api/unBlockUser.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/follow.d.ts +2 -2
- package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts +4 -4
- package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts +3 -3
- package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts +1 -1
- package/dist/userRepository/relationship/follow/api/utils.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +2 -2
- package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +1 -1
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +2 -2
- package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +1 -1
- package/dist/utils/linkedObject/categoryLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/categoryLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +3 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/userLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/client.d.ts.map +1 -1
- package/dist/utils/tests/dummy/block.d.ts +4 -4
- package/dist/utils/tests/dummy/block.d.ts.map +1 -1
- package/dist/utils/tests/dummy/category.d.ts +7 -0
- package/dist/utils/tests/dummy/category.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +61 -1
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +7 -7
- package/dist/utils/tests/dummy/comment.d.ts.map +1 -1
- package/dist/utils/tests/dummy/follow.d.ts +1 -1
- package/dist/utils/tests/dummy/follow.d.ts.map +1 -1
- package/dist/utils/tests/dummy/message.d.ts.map +1 -1
- package/dist/utils/tests/dummy/messagePreviewChannel.d.ts +3 -0
- package/dist/utils/tests/dummy/messagePreviewChannel.d.ts.map +1 -0
- package/dist/utils/tests/dummy/post.d.ts +15 -2
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/utils/tests/dummy/subChannel.d.ts +29 -0
- package/dist/utils/tests/dummy/subChannel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/user.d.ts +12 -1
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/@types/core/marker.ts +4 -4
- package/src/@types/core/model.ts +6 -6
- package/src/@types/core/payload.ts +22 -21
- package/src/@types/domains/analytics.ts +39 -0
- package/src/@types/domains/block.ts +1 -1
- package/src/@types/domains/category.ts +6 -2
- package/src/@types/domains/client.ts +3 -3
- package/src/@types/domains/comment.ts +5 -2
- package/src/@types/domains/community.ts +5 -5
- package/src/@types/domains/follow.ts +4 -4
- package/src/@types/domains/group.ts +2 -2
- package/src/@types/domains/messagePreview.ts +2 -2
- package/src/@types/domains/poll.ts +1 -1
- package/src/@types/domains/post.ts +18 -7
- package/src/@types/domains/reaction.ts +1 -1
- package/src/@types/domains/stream.ts +2 -2
- package/src/@types/domains/user.ts +8 -3
- package/src/analytic/api/queryReachUser.ts +31 -0
- package/src/analytic/api/syncEvent.ts +12 -0
- package/src/analytic/constant.ts +1 -0
- package/src/analytic/service/analytic/AnalyticsEngine.ts +54 -0
- package/src/analytic/service/analytic/AnalyticsEventCapturer.ts +48 -0
- package/src/analytic/service/analytic/AnalyticsEventSyncer.ts +45 -0
- package/src/analytic/service/analytic/AnalyticsService.ts +23 -0
- package/src/analytic/utils/analyticsEngineOnLoginHandler.ts +19 -0
- package/src/cache/api/pushToCache.ts +1 -1
- package/src/cache/api/upsertInCache.ts +1 -1
- package/src/categoryRepository/api/getCategory.ts +3 -2
- package/src/categoryRepository/api/queryCategories.ts +7 -1
- package/src/categoryRepository/observers/getCategories.ts +3 -2
- package/src/categoryRepository/observers/tests/getCategories.test.ts +2 -1
- package/src/channelRepsitory/api/createChannel.ts +1 -1
- package/src/channelRepsitory/channelMembership/api/addMembers.ts +4 -4
- package/src/channelRepsitory/channelMembership/api/queryChannelMembers.ts +1 -1
- package/src/channelRepsitory/channelMembership/api/removeMembers.ts +4 -4
- package/src/channelRepsitory/channelMembership/observers/tests/getMembers.test.ts +1 -1
- package/src/channelRepsitory/channelMembership/observers/tests/searchMembers.test.ts +1 -3
- package/src/channelRepsitory/channelModeration/api/addRole.ts +4 -4
- package/src/channelRepsitory/channelModeration/api/banMembers.ts +2 -2
- package/src/channelRepsitory/channelModeration/api/removeRole.ts +4 -4
- package/src/channelRepsitory/channelModeration/api/unbanMembers.ts +2 -2
- package/src/channelRepsitory/events/onChannelMemberAdded.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberBanned.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberRemoved.ts +1 -1
- package/src/channelRepsitory/events/onChannelMemberUnbanned.ts +1 -1
- package/src/channelRepsitory/observers/tests/getChannel.test.ts +73 -0
- package/src/channelRepsitory/observers/tests/getChannelWithMessagePreview.test.ts +575 -0
- package/src/channelRepsitory/observers/tests/getChannels.test.ts +505 -68
- package/src/channelRepsitory/observers/tests/getChannelsWithMessagePreview.test.ts +592 -0
- package/src/client/api/getToken.ts +3 -3
- package/src/client/api/login.ts +3 -1
- package/src/commentRepository/api/getComment.ts +11 -11
- package/src/commentRepository/api/getCommentByIds.ts +13 -12
- package/src/commentRepository/events/onCommentCreated.ts +4 -3
- package/src/commentRepository/events/onCommentDeleted.ts +4 -3
- package/src/commentRepository/events/onCommentFlagged.ts +4 -3
- package/src/commentRepository/events/onCommentReactionAdded.ts +2 -2
- package/src/commentRepository/events/onCommentReactionRemoved.ts +2 -2
- package/src/commentRepository/events/onCommentUnflagged.ts +4 -3
- package/src/commentRepository/events/onCommentUpdated.ts +4 -3
- package/src/commentRepository/events/utils.ts +1 -1
- package/src/commentRepository/observers/getComment.ts +2 -2
- package/src/communityRepository/communityMembership/api/addMembers.ts +4 -4
- package/src/communityRepository/communityMembership/api/queryCommunityMembers.ts +1 -1
- package/src/communityRepository/communityMembership/api/removeMembers.ts +4 -4
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/getMembers.ts +2 -2
- package/src/communityRepository/communityMembership/observers/tests/getMembers.test.ts +1 -1
- package/src/communityRepository/communityModeration/api/addRoles.ts +4 -4
- package/src/communityRepository/communityModeration/api/banMembers.ts +2 -2
- package/src/communityRepository/communityModeration/api/removeRoles.ts +4 -4
- package/src/communityRepository/communityModeration/api/unbanMembers.ts +2 -2
- package/src/core/device.ts +1 -1
- package/src/core/query/filtering.ts +6 -4
- package/src/core/query/tests/filtering.test.ts +2 -2
- package/src/core/query/tests/runQuery.test.ts +35 -22
- package/src/external/api/createUserToken.ts +2 -2
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +8 -5
- package/src/feedRepository/api/queryGlobalFeed.ts +7 -4
- package/src/feedRepository/api/test/getCustomRankingGlobalFeed.test.ts +22 -14
- package/src/feedRepository/api/test/queryGlobalFeed.test.ts +21 -15
- package/src/group/utils/withUser.ts +8 -4
- package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +1 -1
- package/src/messagePreview/utils/getSubChannelMessagePreviewWithUser.ts +1 -1
- package/src/messagePreview/utils/updateMessagePreviewFromMessage.ts +8 -4
- package/src/messageRepository/api/getDeliveredUsers.ts +11 -9
- package/src/messageRepository/api/getReadUsers.ts +11 -9
- package/src/messageRepository/observers/tests/getMessages.test.ts +766 -0
- package/src/messageRepository/utils/prepareMessagePayload.ts +19 -2
- package/src/postRepository/api/approvePost.ts +2 -1
- package/src/postRepository/api/createPost.ts +8 -6
- package/src/postRepository/api/declinePost.ts +2 -1
- package/src/postRepository/api/deletePost.ts +2 -1
- package/src/postRepository/api/editPost.ts +2 -1
- package/src/postRepository/api/getPost.ts +6 -3
- package/src/postRepository/api/getPostByIds.ts +4 -3
- package/src/postRepository/api/hardDeletePost.ts +2 -1
- package/src/postRepository/api/queryPosts.ts +5 -4
- package/src/postRepository/api/softDeletePost.ts +2 -1
- package/src/postRepository/api/tests/getPost.test.ts +114 -0
- package/src/postRepository/api/tests/queryPosts.test.ts +2 -2
- package/src/postRepository/api/updatePost.ts +2 -1
- package/src/postRepository/events/onPostApproved.ts +2 -2
- package/src/postRepository/events/onPostCreated.ts +2 -2
- package/src/postRepository/events/onPostDeclined.ts +2 -2
- package/src/postRepository/events/onPostDeleted.ts +2 -2
- package/src/postRepository/events/onPostFlagged.ts +2 -2
- package/src/postRepository/events/onPostReactionAdded.ts +5 -3
- package/src/postRepository/events/onPostReactionRemoved.ts +5 -3
- package/src/postRepository/events/onPostUnflagged.ts +2 -2
- package/src/postRepository/events/onPostUpdated.ts +2 -2
- package/src/postRepository/events/utils.ts +2 -2
- package/src/postRepository/observers/getPosts.ts +7 -5
- package/src/postRepository/observers/observePost.ts +24 -9
- package/src/postRepository/observers/observePosts.ts +11 -12
- package/src/postRepository/observers/tests/getPost.test.ts +2 -2
- package/src/postRepository/observers/tests/getPosts.test.ts +36 -11
- package/src/streamRepository/api/getStreams.ts +1 -1
- package/src/streamRepository/api/queryStreams.ts +1 -1
- package/src/subChannelRepository/observers/getSubChannel.ts +1 -1
- package/src/subChannelRepository/observers/getSubChannels.ts +6 -6
- package/src/subChannelRepository/observers/tests/getSubChannelWithMessagePreview.test.ts +591 -0
- package/src/subChannelRepository/observers/tests/getSubChannels.test.ts +322 -14
- package/src/subChannelRepository/observers/tests/getSubChannelsWithMessagePreview.test.ts +643 -0
- package/src/subChannelRepository/utils/updateSubChannelCache.ts +3 -2
- package/src/userRepository/api/flagUser.ts +1 -1
- package/src/userRepository/api/getUser.ts +12 -2
- package/src/userRepository/api/getUserByIds.ts +5 -4
- package/src/userRepository/api/isUserFlaggedByMe.ts +1 -1
- package/src/userRepository/api/queryBlockedUsers.ts +10 -8
- package/src/userRepository/api/queryUsers.ts +12 -10
- package/src/userRepository/api/unflagUser.ts +1 -1
- package/src/userRepository/api/updateUser.ts +6 -6
- package/src/userRepository/events/onUserDeleted.ts +2 -2
- package/src/userRepository/events/onUserFetched.ts +2 -2
- package/src/userRepository/events/onUserFlagCleared.ts +2 -2
- package/src/userRepository/events/onUserFlagged.ts +2 -2
- package/src/userRepository/events/onUserUnflagged.ts +2 -2
- package/src/userRepository/events/onUserUpdated.ts +2 -2
- package/src/userRepository/events/utils.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers.ts +8 -7
- package/src/userRepository/observers/getUser.ts +3 -3
- package/src/userRepository/observers/getUsers.ts +2 -2
- package/src/userRepository/observers/getViewedUsers.ts +93 -0
- package/src/userRepository/observers/index.ts +1 -0
- package/src/userRepository/observers/observeUser.ts +9 -6
- package/src/userRepository/observers/searchUserByDisplayName.ts +2 -2
- package/src/userRepository/observers/tests/getUser.test.ts +1 -1
- package/src/userRepository/observers/tests/getUsers.test.ts +12 -11
- package/src/userRepository/observers/tests/getViewedUsers.test.ts +39 -0
- package/src/userRepository/observers/tests/searchUserByDisplayName.test.ts +1 -1
- package/src/userRepository/relationship/block/api/blockUser.ts +6 -4
- package/src/userRepository/relationship/block/api/unBlockUser.ts +6 -4
- package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +1 -1
- package/src/userRepository/relationship/follow/api/acceptFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/acceptMyFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/declineFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/declineMyFollower.ts +2 -2
- package/src/userRepository/relationship/follow/api/follow.ts +2 -2
- package/src/userRepository/relationship/follow/api/getFollowInfo.ts +4 -4
- package/src/userRepository/relationship/follow/api/unfollow.ts +3 -3
- package/src/userRepository/relationship/follow/api/utils.ts +1 -1
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +1 -1
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +1 -1
- package/src/userRepository/relationship/follow/observers/observeFollowInfo.ts +1 -1
- package/src/userRepository/relationship/follow/observers/observeFollowers.ts +2 -16
- package/src/userRepository/relationship/follow/observers/observeFollowings.ts +2 -16
- package/src/utils/linkedObject/categoryLinkedObject.ts +40 -0
- package/src/utils/linkedObject/commentLinkedObject.ts +4 -0
- package/src/utils/linkedObject/index.ts +6 -0
- package/src/utils/linkedObject/postLinkedObject.ts +37 -0
- package/src/utils/linkedObject/userLinkedObject.ts +36 -0
- package/src/utils/tests/client.ts +2 -1
- package/src/utils/tests/dummy/block.ts +3 -3
- package/src/utils/tests/dummy/category.ts +5 -0
- package/src/utils/tests/dummy/channel.ts +150 -1
- package/src/utils/tests/dummy/comment.ts +1 -1
- package/src/utils/tests/dummy/community.ts +1 -1
- package/src/utils/tests/dummy/follow.ts +1 -1
- package/src/utils/tests/dummy/message.ts +0 -1
- package/src/utils/tests/dummy/messagePreviewChannel.ts +37 -0
- package/src/utils/tests/dummy/post.ts +45 -3
- package/src/utils/tests/dummy/subChannel.ts +29 -0
- package/src/utils/tests/dummy/user.ts +11 -1
- package/tsconfig.json +18 -23
- package/dist/postRepository/tests/api/getPost.test.d.ts.map +0 -1
- package/src/postRepository/tests/api/getPost.test.ts +0 -98
- /package/dist/postRepository/{tests/api → api/tests}/getPost.test.d.ts +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client';
|
|
2
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
3
|
+
|
|
4
|
+
export const queryReachUser = async ({
|
|
5
|
+
postId,
|
|
6
|
+
limit,
|
|
7
|
+
token,
|
|
8
|
+
}: {
|
|
9
|
+
postId: Amity.InternalPost['postId'];
|
|
10
|
+
limit: number;
|
|
11
|
+
token?: string;
|
|
12
|
+
}) => {
|
|
13
|
+
const client = getActiveClient();
|
|
14
|
+
|
|
15
|
+
const params: { token?: string; limit?: number } = {};
|
|
16
|
+
if (token) {
|
|
17
|
+
// If it's not a first query, we can use token to get next user list from previous query.
|
|
18
|
+
params.token = token;
|
|
19
|
+
} else {
|
|
20
|
+
// First query.
|
|
21
|
+
params.limit = limit;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const response = await client.http.get(`/api/v1/analytics/views/posts/${postId}/users`, {
|
|
25
|
+
params,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
ingestInCache(response.data);
|
|
29
|
+
|
|
30
|
+
return response.data;
|
|
31
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
|
|
3
|
+
export const syncEvent = async (events: Amity.AnalyticEventModel[]) => {
|
|
4
|
+
const client = getActiveClient();
|
|
5
|
+
const params: Record<string, any> = {
|
|
6
|
+
activities: events,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
await client.http.post<Amity.ChannelPayload>('/api/v1/analytics/activities', {
|
|
10
|
+
activities: events,
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ANALYTIC_CACHE_KEY = ['analytic', 'post'];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { dropFromCache } from '~/cache/api';
|
|
3
|
+
import { AnalyticsEventSyncer } from './AnalyticsEventSyncer';
|
|
4
|
+
import { AnalyticsEventCapturer } from './AnalyticsEventCapturer';
|
|
5
|
+
import { ANALYTIC_CACHE_KEY } from '../../constant';
|
|
6
|
+
|
|
7
|
+
class AnalyticsEngine {
|
|
8
|
+
private _client: Amity.Client;
|
|
9
|
+
|
|
10
|
+
private _eventCapturer;
|
|
11
|
+
|
|
12
|
+
private _eventSyncer;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this._client = getActiveClient();
|
|
16
|
+
this._eventCapturer = new AnalyticsEventCapturer();
|
|
17
|
+
this._eventSyncer = new AnalyticsEventSyncer();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
markPostAsViewed(postId: Amity.InternalPost['postId']) {
|
|
21
|
+
if (
|
|
22
|
+
this._client.sessionState === Amity.SessionStates.ESTABLISHED ||
|
|
23
|
+
this._client.sessionState === Amity.SessionStates.TOKEN_EXPIRED // For case token_expired, we assume token is expired and gonna re-connect soon
|
|
24
|
+
) {
|
|
25
|
+
this._eventCapturer.markPostAsViewed(postId);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
established() {
|
|
30
|
+
this._eventSyncer.start();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
handleTokenExpired() {
|
|
34
|
+
this._eventSyncer.stop();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
destroy() {
|
|
38
|
+
this._eventSyncer.stop();
|
|
39
|
+
|
|
40
|
+
// query and destroy all objects.
|
|
41
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let instance: AnalyticsEngine;
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
getInstance: () => {
|
|
49
|
+
if (!instance) {
|
|
50
|
+
instance = new AnalyticsEngine();
|
|
51
|
+
}
|
|
52
|
+
return instance;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { upsertInCache } from '~/cache/api/upsertInCache';
|
|
3
|
+
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
4
|
+
import { MINUTE } from '~/utils/constants';
|
|
5
|
+
import { ANALYTIC_CACHE_KEY } from '../../constant';
|
|
6
|
+
|
|
7
|
+
export class AnalyticsEventCapturer {
|
|
8
|
+
_expireTime = 5 * MINUTE;
|
|
9
|
+
|
|
10
|
+
_poolLimit = 1000;
|
|
11
|
+
|
|
12
|
+
_recentViewed: { [key: Amity.InternalPost['postId']]: Date } = {};
|
|
13
|
+
|
|
14
|
+
markPostAsViewed(postId: Amity.InternalPost['postId']) {
|
|
15
|
+
const now = new Date();
|
|
16
|
+
const client = getActiveClient();
|
|
17
|
+
|
|
18
|
+
const recentViewedPostDate = this._recentViewed[postId] ?? new Date(-86400000);
|
|
19
|
+
const timeDiff = now.getTime() - recentViewedPostDate.getTime();
|
|
20
|
+
if (timeDiff < this._expireTime) {
|
|
21
|
+
// just recently view this post, ignore the event.
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const currentData: { event: Amity.AnalyticEventModel[] } = { event: [] };
|
|
26
|
+
const cache = pullFromCache<{ event: Amity.AnalyticEventModel[] }>(ANALYTIC_CACHE_KEY);
|
|
27
|
+
|
|
28
|
+
if (cache?.data) {
|
|
29
|
+
currentData.event = cache.data.event;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// If the pool is full (Max 1000 items), remove the oldest data
|
|
33
|
+
if (currentData.event.length >= this._poolLimit) {
|
|
34
|
+
// Remove oldest data
|
|
35
|
+
currentData.event.shift();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
currentData.event.push({
|
|
39
|
+
contentId: postId,
|
|
40
|
+
contentType: 'post',
|
|
41
|
+
activityType: 'view',
|
|
42
|
+
timestamp: now.toISOString(),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
upsertInCache(ANALYTIC_CACHE_KEY, currentData);
|
|
46
|
+
this._recentViewed[postId] = now;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { pullFromCache } from '~/cache/api/pullFromCache';
|
|
2
|
+
import { dropFromCache } from '~/cache/api/dropFromCache';
|
|
3
|
+
import { MINUTE } from '~/utils/constants';
|
|
4
|
+
import { ANALYTIC_CACHE_KEY } from '../../constant';
|
|
5
|
+
import { syncEvent } from '../../api/syncEvent';
|
|
6
|
+
|
|
7
|
+
export class AnalyticsEventSyncer {
|
|
8
|
+
_timer: NodeJS.Timeout | undefined = undefined;
|
|
9
|
+
|
|
10
|
+
start() {
|
|
11
|
+
this.syncCapturedEvent();
|
|
12
|
+
|
|
13
|
+
this._timer = setInterval(() => {
|
|
14
|
+
this.syncCapturedEvent();
|
|
15
|
+
}, 1 * MINUTE);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
stop() {
|
|
19
|
+
if (!this._timer) return;
|
|
20
|
+
clearInterval(this._timer);
|
|
21
|
+
this._timer = undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async syncCapturedEvent() {
|
|
25
|
+
try {
|
|
26
|
+
// Must query only objects that has same userId with current logged-in user.
|
|
27
|
+
// Query captured event with maximum of 1000
|
|
28
|
+
// Order by latest first
|
|
29
|
+
// e.g. If there is 2000 events we will query 1000-2000 first
|
|
30
|
+
const cache = pullFromCache<{ event: Amity.AnalyticEventModel[] }>(ANALYTIC_CACHE_KEY);
|
|
31
|
+
if (!cache?.data) return;
|
|
32
|
+
if (cache.data.event.length === 0) return;
|
|
33
|
+
|
|
34
|
+
const capturedEvents = cache.data.event;
|
|
35
|
+
|
|
36
|
+
await syncEvent(capturedEvents);
|
|
37
|
+
|
|
38
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
// stop and destroy all events
|
|
41
|
+
this.stop();
|
|
42
|
+
dropFromCache(ANALYTIC_CACHE_KEY);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import AnalyticsEngine from './AnalyticsEngine';
|
|
2
|
+
|
|
3
|
+
class AnalyticsService {
|
|
4
|
+
private analyticEngine;
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
this.analyticEngine = AnalyticsEngine.getInstance();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
markPostAsViewed(postId: string): void {
|
|
11
|
+
this.analyticEngine.markPostAsViewed(postId);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let instance: AnalyticsService;
|
|
16
|
+
export default {
|
|
17
|
+
getInstance: () => {
|
|
18
|
+
if (!instance) {
|
|
19
|
+
instance = new AnalyticsService();
|
|
20
|
+
}
|
|
21
|
+
return instance;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { onSessionStateChange } from '~/client/events/onSessionStateChange';
|
|
2
|
+
import AnalyticsEngine from '../service/analytic/AnalyticsEngine';
|
|
3
|
+
|
|
4
|
+
export default () => {
|
|
5
|
+
const analyticsEngine = AnalyticsEngine.getInstance();
|
|
6
|
+
analyticsEngine.established();
|
|
7
|
+
|
|
8
|
+
onSessionStateChange(state => {
|
|
9
|
+
if (state === Amity.SessionStates.ESTABLISHED) {
|
|
10
|
+
analyticsEngine.established();
|
|
11
|
+
} else {
|
|
12
|
+
analyticsEngine.handleTokenExpired();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return () => {
|
|
17
|
+
analyticsEngine.destroy();
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -5,7 +5,7 @@ import { encodeKey } from '../utils';
|
|
|
5
5
|
/**
|
|
6
6
|
* ```js
|
|
7
7
|
* import { pushToCache } from '@amityco/ts-sdk-react-native'
|
|
8
|
-
* pushToCache<Amity.
|
|
8
|
+
* pushToCache<Amity.InternalUser>(["user", "foobar"], user)
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
11
|
* Saves any provided value as {@link Amity.CacheEntry} for the matching {@link Amity.CacheKey}
|
|
@@ -7,7 +7,7 @@ import { mergeInCache } from './mergeInCache';
|
|
|
7
7
|
/**
|
|
8
8
|
* ```js
|
|
9
9
|
* import { upsertInCache } from '@amityco/ts-sdk-react-native'
|
|
10
|
-
* upsertInCache<Amity.
|
|
10
|
+
* upsertInCache<Amity.InternalUser>(["user", "foobar"], user)
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* Insert or update any provided value as {@link Amity.CacheEntry} for
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
2
|
|
|
3
|
-
import { pullFromCache
|
|
3
|
+
import { pullFromCache } from '~/cache/api';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
+
import { categoryLinkedObject } from '~/utils/linkedObject/categoryLinkedObject';
|
|
5
6
|
|
|
6
7
|
/* begin_public_function
|
|
7
8
|
id: community.category.get
|
|
@@ -36,7 +37,7 @@ export const getCategory = async (
|
|
|
36
37
|
const { categories } = data;
|
|
37
38
|
|
|
38
39
|
return {
|
|
39
|
-
data: categories.find(category => category.categoryId === categoryId)
|
|
40
|
+
data: categoryLinkedObject(categories.find(category => category.categoryId === categoryId)!),
|
|
40
41
|
cachedAt,
|
|
41
42
|
};
|
|
42
43
|
};
|
|
@@ -7,6 +7,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
7
7
|
import { getResolver } from '~/core/model';
|
|
8
8
|
|
|
9
9
|
import { inferIsDeleted } from '~/utils/inferIsDeleted';
|
|
10
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* ```js
|
|
@@ -62,7 +63,12 @@ export const queryCategories = async (
|
|
|
62
63
|
const nextPage = toPage(paging.next);
|
|
63
64
|
const prevPage = toPage(paging.previous);
|
|
64
65
|
|
|
65
|
-
return {
|
|
66
|
+
return {
|
|
67
|
+
data: categories.map(category => LinkedObject.category(category)),
|
|
68
|
+
cachedAt,
|
|
69
|
+
prevPage,
|
|
70
|
+
nextPage,
|
|
71
|
+
};
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
/**
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
ENABLE_CACHE_MESSAGE,
|
|
18
18
|
} from '~/utils/constants';
|
|
19
19
|
import { queryCategories } from '../api/queryCategories';
|
|
20
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
20
21
|
|
|
21
22
|
/* begin_public_function
|
|
22
23
|
id: community.category.query
|
|
@@ -62,9 +63,9 @@ export const getCategories = (
|
|
|
62
63
|
const responder = (data: Amity.CategoryLiveCollectionCache) => {
|
|
63
64
|
let categories: Amity.Category[] =
|
|
64
65
|
data.data
|
|
65
|
-
.map(categoryId => pullFromCache<Amity.
|
|
66
|
+
.map(categoryId => pullFromCache<Amity.InternalCategory>(['category', 'get', categoryId])!)
|
|
66
67
|
.filter(Boolean)
|
|
67
|
-
.map(({ data }) => data) ?? [];
|
|
68
|
+
.map(({ data }) => LinkedObject.category(data)) ?? [];
|
|
68
69
|
|
|
69
70
|
if (!params.includeDeleted) {
|
|
70
71
|
categories = filterByPropEquality(categories, 'isDeleted', false);
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { sortByName } from '~/core/query';
|
|
13
13
|
|
|
14
14
|
import { getCategories } from '../getCategories';
|
|
15
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
15
16
|
|
|
16
17
|
const getSnapshot = (params?: Record<string, any>) => {
|
|
17
18
|
return {
|
|
@@ -48,7 +49,7 @@ describe('getCategories', () => {
|
|
|
48
49
|
2,
|
|
49
50
|
expect.objectContaining(
|
|
50
51
|
getSnapshot({
|
|
51
|
-
data: payload.categories,
|
|
52
|
+
data: payload.categories.map(category => LinkedObject.category(category)),
|
|
52
53
|
loading: false,
|
|
53
54
|
}),
|
|
54
55
|
),
|
|
@@ -22,7 +22,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
22
22
|
* @async
|
|
23
23
|
*/
|
|
24
24
|
export const createChannel = async <T extends Amity.ChannelType>(
|
|
25
|
-
bundle: { type: T; userIds?: Amity.
|
|
25
|
+
bundle: { type: T; userIds?: Amity.InternalUser['userId'][] } & Pick<
|
|
26
26
|
Amity.Channel<T>,
|
|
27
27
|
'displayName' | 'avatarFileId' | 'tags' | 'metadata'
|
|
28
28
|
>,
|
|
@@ -14,18 +14,18 @@ import { prepareChannelPayload } from '../../utils';
|
|
|
14
14
|
* const updated = await addMembers(channelId, ['foo', 'bar'])
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Adds a list of {@link Amity.
|
|
17
|
+
* Adds a list of {@link Amity.InternalUser} to a {@link Amity.Channel}
|
|
18
18
|
*
|
|
19
19
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
20
|
-
* @param userIds The list of IDs {@link Amity.
|
|
21
|
-
* @returns A success boolean if the {@link Amity.
|
|
20
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to add
|
|
21
|
+
* @returns A success boolean if the {@link Amity.InternalUser} were added to the {@link Amity.Channel}
|
|
22
22
|
*
|
|
23
23
|
* @category Channel API
|
|
24
24
|
* @async
|
|
25
25
|
*/
|
|
26
26
|
export const addMembers = async (
|
|
27
27
|
channelId: Amity.Channel['channelId'],
|
|
28
|
-
userIds: Amity.
|
|
28
|
+
userIds: Amity.InternalUser['userId'][],
|
|
29
29
|
): Promise<boolean> => {
|
|
30
30
|
const client = getActiveClient();
|
|
31
31
|
client.log('channel/addMembers', channelId, userIds);
|
|
@@ -80,7 +80,7 @@ export const queryChannelMembers = async (
|
|
|
80
80
|
* const channelMembers = await queryChannelMembers(query)
|
|
81
81
|
* ```
|
|
82
82
|
*
|
|
83
|
-
* Queries a paginable list of {@link Amity.
|
|
83
|
+
* Queries a paginable list of {@link Amity.InternalPost} objects from cache
|
|
84
84
|
*
|
|
85
85
|
* @param query The query parameters
|
|
86
86
|
* @returns posts
|
|
@@ -14,18 +14,18 @@ import { prepareChannelPayload } from '../../utils';
|
|
|
14
14
|
* const updated = await removeMembers(channelId, ['foo', 'bar'])
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Removes a list of {@link Amity.
|
|
17
|
+
* Removes a list of {@link Amity.InternalUser} from a {@link Amity.Channel}
|
|
18
18
|
*
|
|
19
19
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
20
|
-
* @param userIds The list of IDs {@link Amity.
|
|
21
|
-
* @returns A success boolean if the list of {@link Amity.
|
|
20
|
+
* @param userIds The list of IDs {@link Amity.InternalUser} to remove
|
|
21
|
+
* @returns A success boolean if the list of {@link Amity.InternalUser} were removed from the {@link Amity.Channel}
|
|
22
22
|
*
|
|
23
23
|
* @category Channel API
|
|
24
24
|
* @async
|
|
25
25
|
*/
|
|
26
26
|
export const removeMembers = async (
|
|
27
27
|
channelId: Amity.Channel['channelId'],
|
|
28
|
-
userIds: Amity.
|
|
28
|
+
userIds: Amity.InternalUser['userId'][],
|
|
29
29
|
): Promise<boolean> => {
|
|
30
30
|
const client = getActiveClient();
|
|
31
31
|
client.log('channel/removeMembers', channelId, userIds);
|
|
@@ -8,14 +8,12 @@ import {
|
|
|
8
8
|
channelUserModel,
|
|
9
9
|
channelUserQueryResponse,
|
|
10
10
|
channelUserQueryResponsePage2,
|
|
11
|
-
channelUserQueryResponsePage3,
|
|
12
11
|
channelUserWithRole,
|
|
13
12
|
client,
|
|
14
13
|
connectClient,
|
|
15
14
|
convertRawChannelPayload,
|
|
16
15
|
disconnectClient,
|
|
17
16
|
emptyChannelUserQueryResponse,
|
|
18
|
-
mutedChannelUser,
|
|
19
17
|
pause,
|
|
20
18
|
rawBannedChannelUser,
|
|
21
19
|
rawChannelUser,
|
|
@@ -94,7 +92,7 @@ describe('searchMembers', () => {
|
|
|
94
92
|
string,
|
|
95
93
|
keyof Amity.Events,
|
|
96
94
|
Amity.RawMembership<'channel'>,
|
|
97
|
-
Amity.
|
|
95
|
+
Amity.InternalUser,
|
|
98
96
|
Amity.Membership<'channel'>[],
|
|
99
97
|
][] = [
|
|
100
98
|
[
|
|
@@ -14,12 +14,12 @@ import { fireEvent } from '~/core/events';
|
|
|
14
14
|
* const updated = await addRole(channelId, 'foo', ['bar'])
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Adds an {@link Amity.Role} to a list of {@link Amity.
|
|
17
|
+
* Adds an {@link Amity.Role} to a list of {@link Amity.InternalUser} on a {@link Amity.Channel}
|
|
18
18
|
*
|
|
19
19
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
20
20
|
* @param roleId The ID of the {@link Amity.Role} to apply
|
|
21
|
-
* @param userId Array of IDs of the {@link Amity.
|
|
22
|
-
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.
|
|
21
|
+
* @param userId Array of IDs of the {@link Amity.InternalUser} to perform
|
|
22
|
+
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.InternalUser} in the {@link Amity.Channel}
|
|
23
23
|
*
|
|
24
24
|
* @category Channel API
|
|
25
25
|
* @async
|
|
@@ -27,7 +27,7 @@ import { fireEvent } from '~/core/events';
|
|
|
27
27
|
export const addRole = async (
|
|
28
28
|
channelId: Amity.Channel['channelId'],
|
|
29
29
|
roleId: Amity.Role['roleId'],
|
|
30
|
-
userIds: Amity.
|
|
30
|
+
userIds: Amity.InternalUser['userId'][],
|
|
31
31
|
): Promise<boolean> => {
|
|
32
32
|
const client = getActiveClient();
|
|
33
33
|
client.log('channel/addRole', channelId, roleId, userIds);
|
|
@@ -15,7 +15,7 @@ import { prepareChannelPayload } from '../../utils';
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @param channelId of {@link Amity.Channel} from which the users should be banned
|
|
18
|
-
* @param userIds of the {@link Amity.
|
|
18
|
+
* @param userIds of the {@link Amity.InternalUser}'s to be banned
|
|
19
19
|
* @returns the updated {@link Amity.Membership}'s object
|
|
20
20
|
*
|
|
21
21
|
* @category Channel API
|
|
@@ -23,7 +23,7 @@ import { prepareChannelPayload } from '../../utils';
|
|
|
23
23
|
* */
|
|
24
24
|
export const banMembers = async (
|
|
25
25
|
channelId: Amity.Channel['channelId'],
|
|
26
|
-
userIds: Amity.
|
|
26
|
+
userIds: Amity.InternalUser['userId'][],
|
|
27
27
|
): Promise<Amity.Cached<Amity.Membership<'channel'>[]>> => {
|
|
28
28
|
const client = getActiveClient();
|
|
29
29
|
client.log('channel/banMembers', { userIds, channelId });
|
|
@@ -14,12 +14,12 @@ import { fireEvent } from '~/core/events';
|
|
|
14
14
|
* const updated = await removeRole(channelId, 'foo', ['bar'])
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
|
-
* Removes an {@link Amity.Role} from a list of {@link Amity.
|
|
17
|
+
* Removes an {@link Amity.Role} from a list of {@link Amity.InternalUser} on a {@link Amity.Channel}
|
|
18
18
|
*
|
|
19
19
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
20
20
|
* @param roleId The ID of the {@link Amity.Role} to apply
|
|
21
|
-
* @param userIds Array of IDs of the {@link Amity.
|
|
22
|
-
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.
|
|
21
|
+
* @param userIds Array of IDs of the {@link Amity.InternalUser} to perform
|
|
22
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.InternalUser} in the {@link Amity.Channel}
|
|
23
23
|
*
|
|
24
24
|
* @category Channel API
|
|
25
25
|
* @async
|
|
@@ -27,7 +27,7 @@ import { fireEvent } from '~/core/events';
|
|
|
27
27
|
export const removeRole = async (
|
|
28
28
|
channelId: Amity.Channel['channelId'],
|
|
29
29
|
roleId: Amity.Role['roleId'],
|
|
30
|
-
userIds: Amity.
|
|
30
|
+
userIds: Amity.InternalUser['userId'][],
|
|
31
31
|
): Promise<boolean> => {
|
|
32
32
|
const client = getActiveClient();
|
|
33
33
|
client.log('channel/removeRole', channelId, roleId, userIds);
|
|
@@ -15,7 +15,7 @@ import { prepareChannelPayload } from '../../utils';
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @param channelId of {@link Amity.Channel} where the users should be unbanned
|
|
18
|
-
* @param userIds of the {@link Amity.
|
|
18
|
+
* @param userIds of the {@link Amity.InternalUser}'s to be unbanned
|
|
19
19
|
* @returns the updated {@link Amity.Membership}'s object
|
|
20
20
|
*
|
|
21
21
|
* @category Channel API
|
|
@@ -23,7 +23,7 @@ import { prepareChannelPayload } from '../../utils';
|
|
|
23
23
|
* */
|
|
24
24
|
export const unbanMembers = async (
|
|
25
25
|
channelId: Amity.Channel['channelId'],
|
|
26
|
-
userIds: Amity.
|
|
26
|
+
userIds: Amity.InternalUser['userId'][],
|
|
27
27
|
): Promise<Amity.Cached<Amity.Membership<'channel'>[]>> => {
|
|
28
28
|
const client = getActiveClient();
|
|
29
29
|
client.log('channel/unbanMembers', { userIds, channelId });
|
|
@@ -12,7 +12,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
12
12
|
* })
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Fired when any {@link Amity.
|
|
15
|
+
* Fired when any {@link Amity.InternalUser} has been added to any {@link Amity.Channel}
|
|
16
16
|
*
|
|
17
17
|
* @param callback The function to call when the event was fired
|
|
18
18
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -13,7 +13,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
13
13
|
* })
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* Fired when any {@link Amity.
|
|
16
|
+
* Fired when any {@link Amity.InternalUser} has been banned from any {@link Amity.Channel}
|
|
17
17
|
*
|
|
18
18
|
* @param callback The function to call when the event was fired
|
|
19
19
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -13,7 +13,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
13
13
|
* })
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* Fired when any {@link Amity.
|
|
16
|
+
* Fired when any {@link Amity.InternalUser} has been removed from any {@link Amity.Channel}
|
|
17
17
|
*
|
|
18
18
|
* @param callback The function to call when the event was fired
|
|
19
19
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -13,7 +13,7 @@ import { prepareChannelPayload } from '../utils';
|
|
|
13
13
|
* })
|
|
14
14
|
* ```
|
|
15
15
|
*
|
|
16
|
-
* Fired when any {@link Amity.
|
|
16
|
+
* Fired when any {@link Amity.InternalUser} has been unbanned from any {@link Amity.Channel}
|
|
17
17
|
*
|
|
18
18
|
* @param callback The function to call when the event was fired
|
|
19
19
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
channelQueryResponse,
|
|
3
|
+
client,
|
|
4
|
+
connectClient,
|
|
5
|
+
convertRawChannelPayload,
|
|
6
|
+
disconnectClient,
|
|
7
|
+
pause,
|
|
8
|
+
} from '~/utils/tests';
|
|
9
|
+
import { getChannel } from '../getChannel';
|
|
10
|
+
|
|
11
|
+
describe('getChannel (observer)', () => {
|
|
12
|
+
beforeAll(connectClient);
|
|
13
|
+
afterAll(disconnectClient);
|
|
14
|
+
|
|
15
|
+
test('When user gets valid channel, it should return valid channel', async () => {
|
|
16
|
+
const callback = jest.fn();
|
|
17
|
+
const { channelId } = channelQueryResponse.data.channels[0];
|
|
18
|
+
|
|
19
|
+
client.http.get = jest.fn().mockResolvedValue(channelQueryResponse);
|
|
20
|
+
|
|
21
|
+
getChannel(channelId, callback);
|
|
22
|
+
|
|
23
|
+
await pause();
|
|
24
|
+
|
|
25
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
26
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
27
|
+
1,
|
|
28
|
+
expect.objectContaining({
|
|
29
|
+
data: undefined,
|
|
30
|
+
loading: true,
|
|
31
|
+
error: undefined,
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
36
|
+
2,
|
|
37
|
+
expect.objectContaining({
|
|
38
|
+
data: convertRawChannelPayload(channelQueryResponse.data).channels[0],
|
|
39
|
+
loading: false,
|
|
40
|
+
error: undefined,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('When user queries invalid channel, it should return error', async () => {
|
|
46
|
+
const callback = jest.fn();
|
|
47
|
+
|
|
48
|
+
client.http.get = jest.fn().mockRejectedValue(new Error('error'));
|
|
49
|
+
|
|
50
|
+
getChannel('xxxxxx', callback);
|
|
51
|
+
|
|
52
|
+
await pause();
|
|
53
|
+
|
|
54
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
55
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
56
|
+
1,
|
|
57
|
+
expect.objectContaining({
|
|
58
|
+
data: undefined,
|
|
59
|
+
loading: true,
|
|
60
|
+
error: undefined,
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
65
|
+
2,
|
|
66
|
+
expect.objectContaining({
|
|
67
|
+
data: undefined,
|
|
68
|
+
loading: false,
|
|
69
|
+
error: new Error('error'),
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
});
|