@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
|
@@ -3,6 +3,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { pullFromCache } from '~/cache/api';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
6
7
|
|
|
7
8
|
/* begin_public_function
|
|
8
9
|
id: user.get_by_ids
|
|
@@ -40,7 +41,7 @@ export const getUserByIds = async (
|
|
|
40
41
|
fireEvent('user.fetched', data);
|
|
41
42
|
|
|
42
43
|
return {
|
|
43
|
-
data: data.users,
|
|
44
|
+
data: data.users.map(user => LinkedObject.user(user)),
|
|
44
45
|
cachedAt,
|
|
45
46
|
};
|
|
46
47
|
};
|
|
@@ -61,17 +62,17 @@ export const getUserByIds = async (
|
|
|
61
62
|
*/
|
|
62
63
|
getUserByIds.locally = (
|
|
63
64
|
userIds: Amity.User['userId'][],
|
|
64
|
-
): Amity.Cached<Amity.
|
|
65
|
+
): Amity.Cached<Amity.InternalUser[]> | undefined => {
|
|
65
66
|
const client = getActiveClient();
|
|
66
67
|
client.log('user/getUsers.locally', userIds);
|
|
67
68
|
|
|
68
69
|
if (!client.cache) return;
|
|
69
70
|
|
|
70
71
|
const cached = userIds
|
|
71
|
-
.map(userId => pullFromCache<Amity.
|
|
72
|
+
.map(userId => pullFromCache<Amity.InternalUser>(['user', 'get', userId])!)
|
|
72
73
|
.filter(Boolean);
|
|
73
74
|
|
|
74
|
-
const users = cached.map(({ data }) => data);
|
|
75
|
+
const users = cached.map(({ data }) => LinkedObject.user(data));
|
|
75
76
|
const oldest = cached.sort((a, b) => (a.cachedAt! < b.cachedAt! ? -1 : 1))?.[0];
|
|
76
77
|
|
|
77
78
|
if (cached?.length < userIds.length) return;
|
|
@@ -16,7 +16,7 @@ import { synchronousWSCall } from '~/core/transports';
|
|
|
16
16
|
* @category Report API
|
|
17
17
|
* @async
|
|
18
18
|
* */
|
|
19
|
-
export const isUserFlaggedByMe = async (userId: Amity.
|
|
19
|
+
export const isUserFlaggedByMe = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
20
20
|
const client = getActiveClient();
|
|
21
21
|
client.log('user/isUserFlaggedByMe', userId);
|
|
22
22
|
|
|
@@ -11,7 +11,7 @@ import { toPageRaw } from '~/core/query';
|
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* @param query The query parameters
|
|
14
|
-
* @returns A page of {@link Amity.
|
|
14
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
15
15
|
*
|
|
16
16
|
* @category Block API
|
|
17
17
|
* @async
|
|
@@ -20,7 +20,7 @@ import { toPageRaw } from '~/core/query';
|
|
|
20
20
|
export const queryBlockedUsers = async (
|
|
21
21
|
query?: Amity.QueryBlockedUser,
|
|
22
22
|
): Promise<
|
|
23
|
-
Amity.Cached<Amity.Paged<Amity.
|
|
23
|
+
Amity.Cached<Amity.Paged<Amity.InternalUser, Amity.PageRaw>> & {
|
|
24
24
|
total: number;
|
|
25
25
|
}
|
|
26
26
|
> => {
|
|
@@ -66,18 +66,18 @@ export const queryBlockedUsers = async (
|
|
|
66
66
|
* const { data: users } = queryBlockedUsers.locally({ page: 'page_token' })
|
|
67
67
|
* ```
|
|
68
68
|
*
|
|
69
|
-
* Queries a paginable list of {@link Amity.
|
|
69
|
+
* Queries a paginable list of {@link Amity.InternalUser} objects from cache
|
|
70
70
|
* Search is performed by displayName such as `.startsWith(search)`
|
|
71
71
|
*
|
|
72
72
|
* @param query The query parameters
|
|
73
|
-
* @returns A page of {@link Amity.
|
|
73
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
74
74
|
*
|
|
75
75
|
* @category Block API
|
|
76
76
|
*/
|
|
77
77
|
queryBlockedUsers.locally = (
|
|
78
78
|
query: Parameters<typeof queryBlockedUsers>[0] = {},
|
|
79
79
|
):
|
|
80
|
-
| (Amity.Cached<Amity.Paged<Amity.
|
|
80
|
+
| (Amity.Cached<Amity.Paged<Amity.InternalUser, Amity.PageRaw>> & {
|
|
81
81
|
total: number;
|
|
82
82
|
})
|
|
83
83
|
| undefined => {
|
|
@@ -98,11 +98,13 @@ queryBlockedUsers.locally = (
|
|
|
98
98
|
const cacheKey = ['blockedUsers', 'query', params as Amity.Serializable];
|
|
99
99
|
|
|
100
100
|
const { data, cachedAt } =
|
|
101
|
-
pullFromCache<{ users: Pick<Amity.
|
|
101
|
+
pullFromCache<{ users: Pick<Amity.InternalUser, 'userId'>[] } & Amity.BlockedUserPaged>(
|
|
102
|
+
cacheKey,
|
|
103
|
+
) ?? {};
|
|
102
104
|
|
|
103
|
-
const users: Amity.
|
|
105
|
+
const users: Amity.InternalUser[] =
|
|
104
106
|
data?.users
|
|
105
|
-
.map(userId => pullFromCache<Amity.
|
|
107
|
+
.map(userId => pullFromCache<Amity.InternalUser>(['user', 'get', userId])!)
|
|
106
108
|
.filter(Boolean)
|
|
107
109
|
.map(({ data }) => data) ?? [];
|
|
108
110
|
|
|
@@ -6,6 +6,7 @@ import { pullFromCache, pushToCache } from '~/cache/api';
|
|
|
6
6
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
7
7
|
import { getResolver } from '~/core/model';
|
|
8
8
|
import { fireEvent } from '~/core/events';
|
|
9
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* ```js
|
|
@@ -13,18 +14,18 @@ import { fireEvent } from '~/core/events';
|
|
|
13
14
|
* const { data: users, prevPage, nextPage } = await queryUsers({ displayName: 'foo' })
|
|
14
15
|
* ```
|
|
15
16
|
*
|
|
16
|
-
* Queries a paginable list of {@link Amity.
|
|
17
|
+
* Queries a paginable list of {@link Amity.InternalUser} objects
|
|
17
18
|
* Search is performed by displayName such as `.startsWith(search)`
|
|
18
19
|
*
|
|
19
20
|
* @param query The query parameters
|
|
20
|
-
* @returns A page of {@link Amity.
|
|
21
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
21
22
|
*
|
|
22
23
|
* @category User API
|
|
23
24
|
* @async
|
|
24
25
|
*/
|
|
25
26
|
export const queryUsers = async (
|
|
26
27
|
query: Amity.QueryUsers = {},
|
|
27
|
-
): Promise<Amity.Cached<Amity.Paged<Amity.
|
|
28
|
+
): Promise<Amity.Cached<Amity.Paged<Amity.InternalUser>>> => {
|
|
28
29
|
const client = getActiveClient();
|
|
29
30
|
client.log('user/queryUsers', query);
|
|
30
31
|
|
|
@@ -70,7 +71,7 @@ export const queryUsers = async (
|
|
|
70
71
|
const prevPage = toPage(paging.previous);
|
|
71
72
|
const nextPage = toPage(paging.next);
|
|
72
73
|
|
|
73
|
-
return { data: users, cachedAt, prevPage, nextPage };
|
|
74
|
+
return { data: users.map(user => LinkedObject.user(user)), cachedAt, prevPage, nextPage };
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
/**
|
|
@@ -79,17 +80,17 @@ export const queryUsers = async (
|
|
|
79
80
|
* const { data: users } = queryUsers.locally({ keyword: 'foo' })
|
|
80
81
|
* ```
|
|
81
82
|
*
|
|
82
|
-
* Queries a paginable list of {@link Amity.
|
|
83
|
+
* Queries a paginable list of {@link Amity.InternalUser} objects from cache
|
|
83
84
|
* Search is performed by displayName such as `.startsWith(search)`
|
|
84
85
|
*
|
|
85
86
|
* @param query The query parameters
|
|
86
|
-
* @returns A page of {@link Amity.
|
|
87
|
+
* @returns A page of {@link Amity.InternalUser} objects
|
|
87
88
|
*
|
|
88
89
|
* @category User API
|
|
89
90
|
*/
|
|
90
91
|
queryUsers.locally = (
|
|
91
92
|
query: Parameters<typeof queryUsers>[0] = {},
|
|
92
|
-
): Amity.Cached<Amity.Paged<Amity.
|
|
93
|
+
): Amity.Cached<Amity.Paged<Amity.InternalUser>> | undefined => {
|
|
93
94
|
const client = getActiveClient();
|
|
94
95
|
client.log('user/queryUsers.locally', query);
|
|
95
96
|
|
|
@@ -107,11 +108,12 @@ queryUsers.locally = (
|
|
|
107
108
|
];
|
|
108
109
|
|
|
109
110
|
const { data, cachedAt } =
|
|
110
|
-
pullFromCache<{ users: Pick<Amity.
|
|
111
|
+
pullFromCache<{ users: Pick<Amity.InternalUser, 'userId'>[] } & Amity.Pagination>(cacheKey) ??
|
|
112
|
+
{};
|
|
111
113
|
|
|
112
|
-
const users: Amity.
|
|
114
|
+
const users: Amity.InternalUser[] =
|
|
113
115
|
data?.users
|
|
114
|
-
.map(userId => pullFromCache<Amity.
|
|
116
|
+
.map(userId => pullFromCache<Amity.InternalUser>(['user', 'get', userId])!)
|
|
115
117
|
.filter(Boolean)
|
|
116
118
|
.map(({ data }) => data) ?? [];
|
|
117
119
|
|
|
@@ -18,7 +18,7 @@ import { fireEvent } from '~/core/events';
|
|
|
18
18
|
* @category User API
|
|
19
19
|
* @async
|
|
20
20
|
* */
|
|
21
|
-
export const unflagUser = async (userId: Amity.
|
|
21
|
+
export const unflagUser = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
|
|
22
22
|
const client = getActiveClient();
|
|
23
23
|
client.log('user/unflag', userId);
|
|
24
24
|
|
|
@@ -12,22 +12,22 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
12
12
|
* const updated = await updateUser(userId, { displayName: 'foobar' })
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Updates an {@link Amity.
|
|
15
|
+
* Updates an {@link Amity.InternalUser}
|
|
16
16
|
*
|
|
17
|
-
* @param userId The ID of the {@link Amity.
|
|
17
|
+
* @param userId The ID of the {@link Amity.InternalUser} to update
|
|
18
18
|
* @param patch The patch data to apply
|
|
19
|
-
* @returns the updated {@link Amity.
|
|
19
|
+
* @returns the updated {@link Amity.InternalUser} object
|
|
20
20
|
*
|
|
21
21
|
* @category User API
|
|
22
22
|
* @async
|
|
23
23
|
*/
|
|
24
24
|
export const updateUser = async (
|
|
25
|
-
userId: Amity.
|
|
25
|
+
userId: Amity.InternalUser['userId'],
|
|
26
26
|
patch: Patch<
|
|
27
|
-
Amity.
|
|
27
|
+
Amity.InternalUser,
|
|
28
28
|
'displayName' | 'description' | 'avatarFileId' | 'avatarCustomUrl' | 'metadata'
|
|
29
29
|
>,
|
|
30
|
-
): Promise<Amity.Cached<Amity.
|
|
30
|
+
): Promise<Amity.Cached<Amity.InternalUser>> => {
|
|
31
31
|
const client = getActiveClient();
|
|
32
32
|
client.log('user/updateUser', userId, patch);
|
|
33
33
|
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalUser} has been deleted
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserDeleted = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserDeleted = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.deleted', callback);
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalUser} has been fetched
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserFetched = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserFetched = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.fetched', callback);
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when flags have been cleared for a {@link Amity.
|
|
11
|
+
* Fired when flags have been cleared for a {@link Amity.InternalUser}
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserFlagCleared = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserFlagCleared = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.flagCleared', callback);
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalUser} has been flagged
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserFlagged = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserFlagged = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.flagged', callback);
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a flag has been removed from a {@link Amity.
|
|
11
|
+
* Fired when a flag has been removed from a {@link Amity.InternalUser}
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserUnflagged = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserUnflagged = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.unflagged', callback);
|
|
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
|
|
|
8
8
|
* })
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
|
-
* Fired when a {@link Amity.
|
|
11
|
+
* Fired when a {@link Amity.InternalUser} has been updated
|
|
12
12
|
*
|
|
13
13
|
* @param callback The function to call when the event was fired
|
|
14
14
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
15
15
|
*
|
|
16
16
|
* @category User Events
|
|
17
17
|
*/
|
|
18
|
-
export const onUserUpdated = (callback: Amity.Listener<Amity.
|
|
18
|
+
export const onUserUpdated = (callback: Amity.Listener<Amity.InternalUser>) =>
|
|
19
19
|
createUserEventSubscriber('user.updated', callback);
|
|
@@ -5,7 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
export const createUserEventSubscriber = (
|
|
7
7
|
event: keyof Amity.MqttUserEvents,
|
|
8
|
-
callback: Amity.Listener<Amity.
|
|
8
|
+
callback: Amity.Listener<Amity.InternalUser>,
|
|
9
9
|
) => {
|
|
10
10
|
const client = getActiveClient();
|
|
11
11
|
|
|
@@ -10,6 +10,7 @@ import { createQuery, queryOptions, runQuery, toToken } from '~/core/query';
|
|
|
10
10
|
import { CACHE_SHORTEN_LIFESPAN } from '~/cache/utils';
|
|
11
11
|
import { getResolver } from '~/core/model';
|
|
12
12
|
import { queryBlockedUsers } from '../api/queryBlockedUsers';
|
|
13
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
13
14
|
|
|
14
15
|
/* begin_public_function
|
|
15
16
|
id: user.get_blocked_users
|
|
@@ -20,10 +21,10 @@ import { queryBlockedUsers } from '../api/queryBlockedUsers';
|
|
|
20
21
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
21
22
|
* ```
|
|
22
23
|
*
|
|
23
|
-
* Blocks a {@link Amity.
|
|
24
|
+
* Blocks a {@link Amity.InternalUser}
|
|
24
25
|
*
|
|
25
|
-
* @param params The params to get blocked {@link Amity.
|
|
26
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
26
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
27
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
27
28
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
28
29
|
*
|
|
29
30
|
* @category Post API
|
|
@@ -31,7 +32,7 @@ import { queryBlockedUsers } from '../api/queryBlockedUsers';
|
|
|
31
32
|
*/
|
|
32
33
|
export const getBlockedUsers = (
|
|
33
34
|
params: Amity.BlockedUsersLiveCollection,
|
|
34
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
35
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
|
|
35
36
|
config?: Amity.LiveCollectionConfig,
|
|
36
37
|
): Amity.Unsubscriber => {
|
|
37
38
|
const { log, cache } = getActiveClient();
|
|
@@ -52,11 +53,11 @@ export const getBlockedUsers = (
|
|
|
52
53
|
const cacheKey = ['blockedUsers', 'collection', {}];
|
|
53
54
|
|
|
54
55
|
const responder = (data: Amity.BlockedUserLiveCollectionCache) => {
|
|
55
|
-
const users: Amity.
|
|
56
|
+
const users: Amity.InternalUser[] =
|
|
56
57
|
data.data
|
|
57
|
-
.map(userId => pullFromCache<Amity.
|
|
58
|
+
.map(userId => pullFromCache<Amity.InternalUser>(['user', 'get', userId])!)
|
|
58
59
|
.filter(Boolean)
|
|
59
|
-
.map(({ data }) => data) ?? [];
|
|
60
|
+
.map(({ data }) => LinkedObject.user(data)) ?? [];
|
|
60
61
|
|
|
61
62
|
callback({
|
|
62
63
|
onNextPage: onFetch,
|
|
@@ -23,7 +23,7 @@ import { getUser as _getUser } from '../api/getUser';
|
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* Observe all mutation on a given {@link Amity.
|
|
26
|
+
* Observe all mutation on a given {@link Amity.InternalUser}
|
|
27
27
|
*
|
|
28
28
|
* @param userId the ID of the user to observe
|
|
29
29
|
* @param callback the function to call when new data are available
|
|
@@ -32,8 +32,8 @@ import { getUser as _getUser } from '../api/getUser';
|
|
|
32
32
|
* @category Message Live Object
|
|
33
33
|
*/
|
|
34
34
|
export const getUser = (
|
|
35
|
-
userId: Amity.
|
|
36
|
-
callback: Amity.LiveObjectCallback<Amity.
|
|
35
|
+
userId: Amity.InternalUser['userId'],
|
|
36
|
+
callback: Amity.LiveObjectCallback<Amity.InternalUser>,
|
|
37
37
|
): Amity.Unsubscriber => {
|
|
38
38
|
return liveObject(userId, callback, 'userId', _getUser, [
|
|
39
39
|
onUserFetched,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
onUserUnflagged,
|
|
29
29
|
onUserUpdated,
|
|
30
30
|
} from '../events';
|
|
31
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
31
32
|
|
|
32
33
|
/*
|
|
33
34
|
* Exported for testing
|
|
@@ -106,7 +107,7 @@ export const getUsers = (
|
|
|
106
107
|
data.data
|
|
107
108
|
.map(userId => pullFromCache<Amity.User>(['user', 'get', userId])!)
|
|
108
109
|
.filter(Boolean)
|
|
109
|
-
.map(({ data }) => data) ?? [];
|
|
110
|
+
.map(({ data }) => LinkedObject.user(data)) ?? [];
|
|
110
111
|
|
|
111
112
|
callback({
|
|
112
113
|
onNextPage: onFetch,
|
|
@@ -125,7 +126,6 @@ export const getUsers = (
|
|
|
125
126
|
if (!collection) return;
|
|
126
127
|
|
|
127
128
|
collection.data = [...new Set([user.userId, ...collection.data])];
|
|
128
|
-
|
|
129
129
|
pushToCache(cacheKey, collection);
|
|
130
130
|
responder(collection, true);
|
|
131
131
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client';
|
|
2
|
+
import { COLLECTION_DEFAULT_CACHING_POLICY, ENABLE_CACHE_MESSAGE } from '~/utils/constants';
|
|
3
|
+
import { dropFromCache, pullFromCache, pushToCache } from '~/cache/api';
|
|
4
|
+
import { createQuery, queryOptions, runQuery } from '~/core/query';
|
|
5
|
+
import { CACHE_SHORTEN_LIFESPAN } from '~/cache/utils';
|
|
6
|
+
import { queryReachUser } from '~/analytic/api/queryReachUser';
|
|
7
|
+
|
|
8
|
+
export const getViewedUsers = (
|
|
9
|
+
params: Amity.PostViewedUsersLiveCollection,
|
|
10
|
+
callback: Amity.LiveCollectionCallback<Amity.User | undefined>,
|
|
11
|
+
): Amity.Unsubscriber => {
|
|
12
|
+
const { log, cache } = getActiveClient();
|
|
13
|
+
const cacheKey = ['postViewedUsers', 'collection', { postId: params.postId }];
|
|
14
|
+
|
|
15
|
+
if (!cache) {
|
|
16
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const timestamp = Date.now();
|
|
20
|
+
log(`getViewedUsers(tmpid: ${timestamp}) > listen`);
|
|
21
|
+
|
|
22
|
+
const { limit: queryLimit, postId } = params;
|
|
23
|
+
|
|
24
|
+
const responder = (snapshot: {
|
|
25
|
+
loading?: boolean;
|
|
26
|
+
params?: { page: { next: Amity.Token; previous?: Amity.Token } };
|
|
27
|
+
data: Amity.User['userId'][];
|
|
28
|
+
}) => {
|
|
29
|
+
let users: (Amity.User | undefined)[] = [];
|
|
30
|
+
|
|
31
|
+
if (snapshot?.data) {
|
|
32
|
+
users =
|
|
33
|
+
snapshot.data
|
|
34
|
+
.map((userId: Amity.User['userId']) => pullFromCache<Amity.User>(['user', 'get', userId]))
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.map(data => data?.data) || [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
callback({
|
|
40
|
+
// eslint-disable-next-line no-use-before-define
|
|
41
|
+
onNextPage: onFetch,
|
|
42
|
+
data: users,
|
|
43
|
+
hasNextPage: !!snapshot.params?.page?.next,
|
|
44
|
+
loading: snapshot.loading || false,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const onFetch = (initial = false) => {
|
|
49
|
+
const collection = pullFromCache<Amity.PostViewedUsersLiveCollectionCache>(cacheKey)?.data;
|
|
50
|
+
|
|
51
|
+
const users = collection?.data ?? [];
|
|
52
|
+
|
|
53
|
+
if (!initial && users.length > 0 && !collection?.params.page) return;
|
|
54
|
+
|
|
55
|
+
const query = createQuery(queryReachUser, {
|
|
56
|
+
postId,
|
|
57
|
+
limit: queryLimit || 10,
|
|
58
|
+
token: !initial ? collection?.params.page?.next : undefined,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
runQuery(
|
|
62
|
+
query,
|
|
63
|
+
result => {
|
|
64
|
+
let userIds =
|
|
65
|
+
pullFromCache<Amity.PostViewedUsersLiveCollectionCache>(cacheKey)?.data?.data ?? [];
|
|
66
|
+
|
|
67
|
+
if (result.data?.users) {
|
|
68
|
+
userIds = [
|
|
69
|
+
...new Set([...userIds, ...result.data.users.map(({ userId }: Amity.User) => userId)]),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const saveToCache = {
|
|
74
|
+
loading: result.loading,
|
|
75
|
+
params: { page: result.data?.paging },
|
|
76
|
+
data: userIds || [],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
pushToCache(cacheKey, saveToCache);
|
|
80
|
+
|
|
81
|
+
responder(saveToCache);
|
|
82
|
+
},
|
|
83
|
+
queryOptions(COLLECTION_DEFAULT_CACHING_POLICY, CACHE_SHORTEN_LIFESPAN),
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
onFetch(true);
|
|
88
|
+
|
|
89
|
+
return () => {
|
|
90
|
+
log(`getViewedUsers(tmpid: ${timestamp}) > dispose`);
|
|
91
|
+
dropFromCache(cacheKey);
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
onUserUnflagged,
|
|
11
11
|
onUserFlagCleared,
|
|
12
12
|
} from '../events';
|
|
13
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* ```js
|
|
@@ -23,14 +24,14 @@ import {
|
|
|
23
24
|
* @param callback the function to call when new data are available
|
|
24
25
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the user
|
|
25
26
|
*
|
|
26
|
-
* Observe all mutation on a given {@link Amity.
|
|
27
|
+
* Observe all mutation on a given {@link Amity.InternalUser}
|
|
27
28
|
* @category User Observer
|
|
28
29
|
*/
|
|
29
30
|
export const observeUser = <
|
|
30
31
|
Events extends ['onFetch', 'onUpdate', 'onDelete', 'onFlagged', 'onUnflagged', 'onFlagCleared'],
|
|
31
32
|
>(
|
|
32
33
|
userId: string,
|
|
33
|
-
callback: Amity.ObjectListener<Amity.Snapshot<Amity.
|
|
34
|
+
callback: Amity.ObjectListener<Amity.Snapshot<Amity.InternalUser>, Events>,
|
|
34
35
|
): Amity.Unsubscriber => {
|
|
35
36
|
const { log } = getActiveClient();
|
|
36
37
|
|
|
@@ -38,15 +39,17 @@ export const observeUser = <
|
|
|
38
39
|
log(`observeUser(tmpid: ${timestamp}) > listen`);
|
|
39
40
|
|
|
40
41
|
// wrapper function to make sure
|
|
41
|
-
const router = (result: Amity.Snapshot<Amity.
|
|
42
|
+
const router = (result: Amity.Snapshot<Amity.InternalUser>, action: Events[number]) => {
|
|
42
43
|
// filter function
|
|
43
44
|
if (result.data?.userId !== userId) return;
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
const newResult = { ...result, data: LinkedObject.user(result.data) };
|
|
46
47
|
|
|
47
|
-
if (
|
|
48
|
+
if (callback instanceof Function) return callback(newResult);
|
|
48
49
|
|
|
49
|
-
callback
|
|
50
|
+
if (action !== 'onFetch') callback.onEvent?.(action, newResult);
|
|
51
|
+
|
|
52
|
+
callback[action]?.(newResult);
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
const disposers: Amity.Unsubscriber[] = [];
|
|
@@ -11,7 +11,7 @@ import { getUsers } from './getUsers';
|
|
|
11
11
|
* const unsub = UserRepository.searchUserByDisplayName({}, response => merge(users, response.data))
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
* Observe all mutations on a list of {@link Amity.
|
|
14
|
+
* Observe all mutations on a list of {@link Amity.InternalUser}s
|
|
15
15
|
*
|
|
16
16
|
* @param params for searching users
|
|
17
17
|
* @param callback the function to call when new data are available
|
|
@@ -22,7 +22,7 @@ import { getUsers } from './getUsers';
|
|
|
22
22
|
*/
|
|
23
23
|
export const searchUserByDisplayName = (
|
|
24
24
|
params: Amity.UserSearchLiveCollection,
|
|
25
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
25
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
|
|
26
26
|
config?: Amity.LiveCollectionConfig,
|
|
27
27
|
) => {
|
|
28
28
|
return getUsers({ ...params, filter: 'all' }, callback, config);
|
|
@@ -18,7 +18,7 @@ const { getUsers, applyFilter } = getUsersModule;
|
|
|
18
18
|
|
|
19
19
|
const getSnapshot = (params?: Record<string, any>) => {
|
|
20
20
|
return {
|
|
21
|
-
data: [] as Amity.
|
|
21
|
+
data: [] as Amity.InternalUser[],
|
|
22
22
|
loading: true,
|
|
23
23
|
error: undefined as any,
|
|
24
24
|
...params,
|
|
@@ -127,7 +127,7 @@ describe('getUsers', () => {
|
|
|
127
127
|
const unflaggedUser = { ...user11, flagCount: 1 };
|
|
128
128
|
const flagClearedUser = { ...user11, flagCount: 0 };
|
|
129
129
|
|
|
130
|
-
const cases: [string, keyof Amity.Events, Amity.UserPayload, Amity.
|
|
130
|
+
const cases: [string, keyof Amity.Events, Amity.UserPayload, Amity.InternalUser[]][] = [
|
|
131
131
|
[
|
|
132
132
|
'it should update user in collection onUpdate',
|
|
133
133
|
'user.updated',
|
|
@@ -198,20 +198,21 @@ describe('getUsers > applyFilter', () => {
|
|
|
198
198
|
userId: 'test',
|
|
199
199
|
displayName: 'a',
|
|
200
200
|
createdAt: new Date().toISOString(),
|
|
201
|
-
} as Amity.
|
|
201
|
+
} as Amity.InternalUser;
|
|
202
202
|
|
|
203
203
|
const u2 = {
|
|
204
204
|
userId: 'searchable',
|
|
205
205
|
displayName: 'b',
|
|
206
206
|
createdAt: getPastDate(),
|
|
207
|
-
} as Amity.
|
|
208
|
-
|
|
209
|
-
const filters: [string, Amity.UserLiveCollection, Amity.
|
|
210
|
-
[
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
207
|
+
} as Amity.InternalUser;
|
|
208
|
+
|
|
209
|
+
const filters: [string, Amity.UserLiveCollection, Amity.InternalUser[], Amity.InternalUser[]][] =
|
|
210
|
+
[
|
|
211
|
+
['it should filter by display name', { displayName: 'a' }, [u1, u2], [u1]],
|
|
212
|
+
['it should sort by dispaly name', {}, [u1, u2], [u1, u2]],
|
|
213
|
+
['it should sort by last created', { sortBy: 'lastCreated' }, [u1, u2], [u1, u2]],
|
|
214
|
+
['it should sort by first created', { sortBy: 'firstCreated' }, [u1, u2], [u2, u1]],
|
|
215
|
+
];
|
|
215
216
|
|
|
216
217
|
test.each(filters)('%s', (test, param, input, expected) => {
|
|
217
218
|
expect(applyFilter(input, param)).toStrictEqual(expected);
|