@amityco/ts-sdk 0.0.1-655cb77.0 → 0.0.1-65645.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/.eslintrc.json +2 -0
- package/README.md +3 -1
- package/dist/@types/core/events.d.ts +22 -22
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +5 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +87 -34
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +3 -3
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +5 -0
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -0
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +7 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +1 -2
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -2
- package/dist/@types/domains/message.d.ts +1 -1
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +8 -0
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/@types/global.d.ts +8 -0
- package/dist/@types/global.d.ts.map +1 -1
- package/dist/cache/api/ingestInCache.d.ts +2 -1
- package/dist/cache/api/ingestInCache.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts.map +1 -1
- package/dist/channel/api/addChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/addChannelMembersRole.d.ts.map +1 -1
- package/dist/channel/api/banChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/createChannel.d.ts.map +1 -1
- package/dist/channel/api/getChannel.d.ts.map +1 -1
- package/dist/channel/api/joinChannel.d.ts.map +1 -1
- package/dist/channel/api/leaveChannel.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/channel/api/removeChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/removeChannelMembersRole.d.ts +1 -1
- package/dist/channel/api/removeChannelMembersRole.d.ts.map +1 -1
- package/dist/channel/api/startReading.d.ts +3 -3
- package/dist/channel/api/startReading.d.ts.map +1 -1
- package/dist/channel/api/stopReading.d.ts +2 -2
- package/dist/channel/api/stopReading.d.ts.map +1 -1
- package/dist/channel/api/unbanChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/updateChannel.d.ts.map +1 -1
- package/dist/channel/events/onChannelJoined.d.ts.map +1 -1
- package/dist/channel/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberAdded.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberBanned.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberRemoved.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberUnbanned.d.ts.map +1 -1
- package/dist/channel/observers/liveChannels.d.ts.map +1 -1
- package/dist/channel/utils/index.d.ts +2 -2
- package/dist/channel/utils/index.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.d.ts.map +1 -1
- package/dist/client/api/renewal.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/deleteComment.d.ts.map +1 -1
- package/dist/comment/api/getComment.d.ts.map +1 -1
- package/dist/comment/api/getComments.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/comment/api/tests/updateComment.test.d.ts +2 -0
- package/dist/comment/api/tests/updateComment.test.d.ts.map +1 -0
- package/dist/comment/api/updateComment.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/api/createCommunity.d.ts.map +1 -1
- package/dist/community/api/deleteCommunity.d.ts.map +1 -1
- package/dist/community/api/getCommunity.d.ts.map +1 -1
- package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -1
- package/dist/community/api/joinCommunity.d.ts.map +1 -1
- package/dist/community/api/leaveCommunity.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/api/queryCommunityMembers.d.ts +1 -7
- package/dist/community/api/queryCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/api/updateCommunity.d.ts.map +1 -1
- package/dist/community/events/index.d.ts +2 -0
- package/dist/community/events/index.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserRoleAdded.d.ts +17 -0
- package/dist/community/events/onCommunityUserRoleAdded.d.ts.map +1 -0
- package/dist/community/events/onCommunityUserRoleRemoved.d.ts +17 -0
- package/dist/community/events/onCommunityUserRoleRemoved.d.ts.map +1 -0
- package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts +2 -0
- package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts.map +1 -0
- package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts +2 -0
- package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts.map +1 -0
- package/dist/community/events/utils.d.ts.map +1 -1
- package/dist/community/observers/index.d.ts +2 -0
- package/dist/community/observers/index.d.ts.map +1 -1
- package/dist/community/observers/liveCommunity.d.ts +21 -0
- package/dist/community/observers/liveCommunity.d.ts.map +1 -0
- package/dist/community/observers/liveCommunityMembers.d.ts +20 -0
- package/dist/community/observers/liveCommunityMembers.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunity.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunity.test.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunityMembers.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunityMembers.test.d.ts.map +1 -0
- package/dist/community/utils/payload.d.ts +3 -5
- package/dist/community/utils/payload.d.ts.map +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts +2 -4
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts +2 -2
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +10 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/core/query/paging.d.ts +2 -2
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/core/query/tests/paging.test.d.ts +2 -0
- package/dist/core/query/tests/paging.test.d.ts.map +1 -0
- package/dist/external/api/tests/createUserToken.test.d.ts +2 -0
- package/dist/external/api/tests/createUserToken.test.d.ts.map +1 -0
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/file/api/createFile.d.ts.map +1 -1
- package/dist/file/api/createImage.d.ts.map +1 -1
- package/dist/file/api/createVideo.d.ts.map +1 -1
- package/dist/file/api/deleteFile.d.ts.map +1 -1
- package/dist/file/api/getFile.d.ts.map +1 -1
- package/dist/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/follow/api/follow.d.ts.map +1 -1
- package/dist/follow/api/getFollowInfo.d.ts.map +1 -1
- package/dist/follow/api/queryFollowers.d.ts.map +1 -1
- package/dist/follow/api/queryFollowings.d.ts.map +1 -1
- package/dist/follow/api/unfollow.d.ts.map +1 -1
- package/dist/group/utils/withUser.d.ts.map +1 -1
- package/dist/index.cjs.js +1076 -331
- package/dist/index.esm.js +1069 -330
- package/dist/index.umd.js +4 -4
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/api/deleteMessage.d.ts.map +1 -1
- package/dist/message/api/getMessage.d.ts.map +1 -1
- package/dist/message/api/queryMessages.d.ts +2 -2
- package/dist/message/api/queryMessages.d.ts.map +1 -1
- package/dist/message/api/updateMessage.d.ts.map +1 -1
- package/dist/message/utils/index.d.ts +3 -3
- package/dist/message/utils/index.d.ts.map +1 -1
- package/dist/poll/api/closePoll.d.ts.map +1 -1
- package/dist/poll/api/createPoll.d.ts.map +1 -1
- package/dist/poll/api/deletePoll.d.ts.map +1 -1
- package/dist/poll/api/getPoll.d.ts.map +1 -1
- package/dist/poll/api/tests/closePoll.test.d.ts +2 -0
- package/dist/poll/api/tests/closePoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/createPoll.test.d.ts +2 -0
- package/dist/poll/api/tests/createPoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/getPoll.test.d.ts +2 -0
- package/dist/poll/api/tests/getPoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/votePoll.test.d.ts +2 -0
- package/dist/poll/api/tests/votePoll.test.d.ts.map +1 -0
- package/dist/poll/api/votePoll.d.ts.map +1 -1
- package/dist/post/api/approvePost.d.ts.map +1 -1
- package/dist/post/api/createPost.d.ts.map +1 -1
- package/dist/post/api/declinePost.d.ts.map +1 -1
- package/dist/post/api/deletePost.d.ts.map +1 -1
- package/dist/post/api/getPost.d.ts.map +1 -1
- package/dist/post/api/getPosts.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/post/api/updatePost.d.ts.map +1 -1
- package/dist/post/events/utils.d.ts.map +1 -1
- package/dist/post/observers/livePosts.d.ts +2 -2
- package/dist/post/observers/livePosts.d.ts.map +1 -1
- package/dist/reaction/api/addReaction.d.ts.map +1 -1
- package/dist/reaction/api/queryReactions.d.ts.map +1 -1
- package/dist/reaction/api/removeReaction.d.ts.map +1 -1
- package/dist/reaction/events/onReactorAdded.d.ts.map +1 -1
- package/dist/reaction/events/onReactorRemoved.d.ts.map +1 -1
- package/dist/reaction/utils/dispatchReactable.d.ts +1 -1
- package/dist/reaction/utils/dispatchReactable.d.ts.map +1 -1
- package/dist/report/api/createReport.d.ts.map +1 -1
- package/dist/report/api/deleteReport.d.ts.map +1 -1
- package/dist/report/api/isReportedByMe.d.ts.map +1 -1
- package/dist/report/api/tests/createReport.test.d.ts +2 -0
- package/dist/report/api/tests/createReport.test.d.ts.map +1 -0
- package/dist/report/api/tests/deleteReport.test.d.ts +2 -0
- package/dist/report/api/tests/deleteReport.test.d.ts.map +1 -0
- package/dist/stream/api/createStream.d.ts.map +1 -1
- package/dist/stream/api/deleteStream.d.ts.map +1 -1
- package/dist/stream/api/getStream.d.ts.map +1 -1
- package/dist/stream/api/queryStreams.d.ts.map +1 -1
- package/dist/stream/api/updateStream.d.ts.map +1 -1
- package/dist/subChannel/api/createSubChannel.d.ts.map +1 -1
- package/dist/subChannel/api/deleteSubChannel.d.ts.map +1 -1
- package/dist/subChannel/api/getSubChannel.d.ts.map +1 -1
- package/dist/subChannel/api/querySubChannels.d.ts.map +1 -1
- package/dist/subChannel/api/updateSubChannel.d.ts.map +1 -1
- package/dist/subChannel/utils/index.d.ts +1 -1
- package/dist/subChannel/utils/index.d.ts.map +1 -1
- package/dist/user/api/getUser.d.ts.map +1 -1
- package/dist/user/api/getUsers.d.ts.map +1 -1
- package/dist/user/api/queryUsers.d.ts +1 -6
- package/dist/user/api/queryUsers.d.ts.map +1 -1
- package/dist/user/api/updateUser.d.ts.map +1 -1
- package/dist/user/observers/index.d.ts +1 -0
- package/dist/user/observers/index.d.ts.map +1 -1
- package/dist/user/observers/liveUsers.d.ts +18 -0
- package/dist/user/observers/liveUsers.d.ts.map +1 -0
- package/dist/user/observers/tests/liveUsers.test.d.ts +2 -0
- package/dist/user/observers/tests/liveUsers.test.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/liveObject.d.ts +1 -1
- package/dist/utils/liveObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +31 -35
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +35 -84
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/dist/utils/tests/dummy/feed.d.ts +5 -0
- package/dist/utils/tests/dummy/feed.d.ts.map +1 -0
- package/dist/utils/tests/dummy/index.d.ts +1 -0
- package/dist/utils/tests/dummy/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/member.d.ts +1 -1
- package/dist/utils/tests/dummy/post.d.ts +30 -20
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/utils/tests/dummy/user.d.ts +63 -0
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +22 -20
- package/src/@types/core/model.ts +7 -2
- package/src/@types/core/payload.ts +102 -38
- package/src/@types/domains/channel.ts +3 -3
- package/src/@types/domains/client.ts +1 -1
- package/src/@types/domains/comment.ts +7 -0
- package/src/@types/domains/community.ts +25 -0
- package/src/@types/domains/content.ts +9 -1
- package/src/@types/domains/feed.ts +1 -3
- package/src/@types/domains/group.ts +2 -2
- package/src/@types/domains/message.ts +4 -1
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/domains/user.ts +14 -0
- package/src/@types/global.ts +10 -0
- package/src/cache/api/ingestInCache.ts +3 -6
- package/src/cache/api/tests/ingestInCache.test.ts +14 -9
- package/src/category/api/queryCategories.ts +3 -0
- package/src/channel/api/addChannelMembers.ts +9 -5
- package/src/channel/api/addChannelMembersRole.ts +4 -0
- package/src/channel/api/banChannelMembers.ts +5 -3
- package/src/channel/api/createChannel.ts +4 -0
- package/src/channel/api/getChannel.ts +5 -1
- package/src/channel/api/joinChannel.ts +4 -0
- package/src/channel/api/leaveChannel.ts +4 -0
- package/src/channel/api/queryChannelMembers.ts +5 -3
- package/src/channel/api/queryChannels.ts +4 -0
- package/src/channel/api/removeChannelMembers.ts +9 -5
- package/src/channel/api/removeChannelMembersRole.ts +5 -1
- package/src/channel/api/startReading.ts +7 -3
- package/src/channel/api/stopReading.ts +6 -2
- package/src/channel/api/tests/addChannelMembers.test.ts +4 -3
- package/src/channel/api/tests/createChannel.test.ts +5 -3
- package/src/channel/api/tests/getChannel.test.ts +2 -1
- package/src/channel/api/tests/joinChannel.test.ts +2 -2
- package/src/channel/api/tests/leaveChannel.test.ts +2 -2
- package/src/channel/api/tests/queryChannelMembers.test.ts +2 -5
- package/src/channel/api/tests/queryChannels.test.ts +4 -3
- package/src/channel/api/tests/removeChannelMembers.test.ts +16 -5
- package/src/channel/api/unbanChannelMembers.ts +5 -3
- package/src/channel/api/updateChannel.ts +4 -0
- package/src/channel/events/onChannelJoined.ts +1 -3
- package/src/channel/events/onChannelLeft.ts +1 -3
- package/src/channel/events/onChannelMemberAdded.ts +1 -3
- package/src/channel/events/onChannelMemberBanned.ts +1 -3
- package/src/channel/events/onChannelMemberRemoved.ts +1 -3
- package/src/channel/events/onChannelMemberUnbanned.ts +1 -3
- package/src/channel/observers/liveChannels.ts +29 -24
- package/src/channel/observers/tests/liveChannelMembers.test.ts +5 -12
- package/src/channel/observers/tests/liveChannels.test.ts +3 -1
- package/src/channel/utils/index.ts +9 -6
- package/src/client/api/connectClient.ts +4 -2
- package/src/client/api/disconnectClient.ts +4 -0
- package/src/client/api/getToken.ts +1 -1
- package/src/client/api/renewal.ts +4 -0
- package/src/client/api/tests/getToken.test.ts +2 -2
- package/src/comment/api/createComment.ts +22 -2
- package/src/comment/api/deleteComment.ts +23 -2
- package/src/comment/api/getComment.ts +4 -0
- package/src/comment/api/getComments.ts +4 -0
- package/src/comment/api/queryComments.ts +4 -0
- package/src/comment/api/tests/createComment.test.ts +169 -9
- package/src/comment/api/tests/updateComment.test.ts +189 -0
- package/src/comment/api/updateComment.ts +4 -0
- package/src/comment/events/tests/onCommentCreated.test.ts +3 -3
- package/src/comment/events/tests/onCommentDeleted.test.ts +3 -3
- package/src/comment/observers/tests/liveComment.test.ts +18 -2
- package/src/community/api/addCommunityMembers.ts +10 -3
- package/src/community/api/addCommunityMembersRoles.ts +9 -2
- package/src/community/api/createCommunity.ts +9 -5
- package/src/community/api/deleteCommunity.ts +13 -1
- package/src/community/api/getCommunities.ts +2 -2
- package/src/community/api/getCommunity.ts +6 -2
- package/src/community/api/getRecommendedCommunities.ts +6 -2
- package/src/community/api/getTopTrendingCommunities.ts +6 -2
- package/src/community/api/joinCommunity.ts +10 -3
- package/src/community/api/leaveCommunity.ts +10 -3
- package/src/community/api/queryCommunities.ts +7 -3
- package/src/community/api/queryCommunityMembers.ts +7 -7
- package/src/community/api/removeCommunityMembers.ts +11 -3
- package/src/community/api/removeCommunityMembersRoles.ts +9 -2
- package/src/community/api/test/queryCommunityMembers.test.ts +2 -1
- package/src/community/api/test/removeCommunityMemberRole.test.ts +4 -1
- package/src/community/api/updateCommunity.ts +9 -5
- package/src/community/events/index.ts +2 -0
- package/src/community/events/onCommunityUserRoleAdded.ts +20 -0
- package/src/community/events/onCommunityUserRoleRemoved.ts +20 -0
- package/src/community/events/test/onCommunityDeleted.test.ts +8 -1
- package/src/community/events/test/onCommunityUserRoleAdded.test.ts +50 -0
- package/src/community/events/test/onCommunityUserRoleRemoved.test.ts +50 -0
- package/src/community/events/utils.ts +4 -8
- package/src/community/observers/index.ts +4 -0
- package/src/community/observers/liveCommunity.ts +45 -0
- package/src/community/observers/liveCommunityMembers.ts +187 -0
- package/src/community/observers/tests/liveCommunities.test.ts +38 -18
- package/src/community/observers/tests/liveCommunity.test.ts +147 -0
- package/src/community/observers/tests/liveCommunityMembers.test.ts +195 -0
- package/src/community/utils/payload.ts +28 -22
- package/src/core/device.ts +2 -4
- package/src/core/model/idResolvers.ts +6 -3
- package/src/core/model/identifyModel.ts +4 -3
- package/src/core/model/index.ts +3 -0
- package/src/core/query/filtering.ts +33 -3
- package/src/core/query/paging.ts +5 -4
- package/src/core/query/query.ts +7 -0
- package/src/core/query/tests/paging.test.ts +66 -0
- package/src/core/tests/query/query/runQuery.test.ts +8 -3
- package/src/core/tests/subscription.test.ts +80 -2
- package/src/external/api/tests/createUserToken.test.ts +29 -0
- package/src/feed/api/queryGlobalFeed.ts +12 -4
- package/src/file/api/createFile.ts +4 -0
- package/src/file/api/createImage.ts +4 -0
- package/src/file/api/createVideo.ts +4 -0
- package/src/file/api/deleteFile.ts +4 -0
- package/src/file/api/getFile.ts +4 -0
- package/src/follow/api/acceptFollower.ts +4 -0
- package/src/follow/api/declineFollower.ts +4 -0
- package/src/follow/api/follow.ts +4 -0
- package/src/follow/api/getFollowInfo.ts +4 -0
- package/src/follow/api/queryFollowers.ts +4 -0
- package/src/follow/api/queryFollowings.ts +4 -0
- package/src/follow/api/unfollow.ts +4 -0
- package/src/group/utils/test/withUsers.test.ts +5 -5
- package/src/group/utils/withUser.ts +20 -14
- package/src/message/api/createMessage.ts +19 -13
- package/src/message/api/deleteMessage.ts +4 -0
- package/src/message/api/getMessage.ts +6 -2
- package/src/message/api/getMessages.ts +1 -1
- package/src/message/api/queryMessages.ts +13 -9
- package/src/message/api/tests/createMessage.test.ts +21 -1
- package/src/message/api/tests/queryMessages.test.ts +6 -6
- package/src/message/api/updateMessage.ts +5 -1
- package/src/message/events/onMessageCreated.ts +1 -1
- package/src/message/events/onMessageDeleted.ts +1 -1
- package/src/message/events/onMessageFetched.ts +1 -1
- package/src/message/events/onMessageFlagCleared.ts +1 -1
- package/src/message/events/onMessageFlagged.ts +1 -1
- package/src/message/events/onMessageReactionAdded.ts +1 -1
- package/src/message/events/onMessageReactionRemoved.ts +1 -1
- package/src/message/events/onMessageUnflagged.ts +1 -1
- package/src/message/events/onMessageUpdated.ts +1 -1
- package/src/message/observers/liveMessages.ts +1 -1
- package/src/message/tests/events.test.ts +10 -2
- package/src/message/tests/observers/liveMessage.test.ts +6 -1
- package/src/message/tests/observers/liveMessages.test.ts +20 -7
- package/src/message/utils/index.ts +5 -3
- package/src/poll/api/closePoll.ts +4 -0
- package/src/poll/api/createPoll.ts +4 -0
- package/src/poll/api/deletePoll.ts +4 -0
- package/src/poll/api/getPoll.ts +4 -0
- package/src/poll/api/tests/closePoll.test.ts +50 -0
- package/src/poll/api/tests/createPoll.test.ts +70 -0
- package/src/poll/api/tests/getPoll.test.ts +31 -0
- package/src/poll/api/tests/votePoll.test.ts +41 -0
- package/src/poll/api/votePoll.ts +4 -0
- package/src/poll/events/onPollDeleted.ts +1 -1
- package/src/poll/events/onPollUpdated.ts +1 -1
- package/src/post/api/approvePost.ts +14 -10
- package/src/post/api/createPost.ts +10 -3
- package/src/post/api/declinePost.ts +15 -11
- package/src/post/api/deletePost.ts +23 -2
- package/src/post/api/getPost.ts +9 -2
- package/src/post/api/getPosts.ts +7 -1
- package/src/post/api/queryPosts.ts +7 -1
- package/src/post/api/tests/queryPosts.test.ts +5 -4
- package/src/post/api/updatePost.ts +8 -1
- package/src/post/events/onPostReactionAdded.ts +1 -1
- package/src/post/events/onPostReactionRemoved.ts +1 -1
- package/src/post/events/utils.ts +12 -2
- package/src/post/observers/livePosts.ts +14 -22
- package/src/post/observers/tests/livePost.test.ts +10 -3
- package/src/post/observers/tests/livePosts.test.ts +76 -11
- package/src/post/tests/api/getPost.test.ts +13 -3
- package/src/post/tests/api/queryPosts.test.ts +5 -4
- package/src/reaction/api/addReaction.ts +7 -3
- package/src/reaction/api/queryReactions.ts +6 -0
- package/src/reaction/api/removeReaction.ts +8 -3
- package/src/reaction/events/onReactionAdded.ts +3 -3
- package/src/reaction/events/onReactionRemoved.ts +3 -3
- package/src/reaction/events/onReactorAdded.ts +8 -2
- package/src/reaction/events/onReactorRemoved.ts +8 -2
- package/src/reaction/utils/dispatchReactable.ts +1 -1
- package/src/reaction/utils/fetchReference.ts +1 -1
- package/src/report/api/createReport.ts +18 -13
- package/src/report/api/deleteReport.ts +19 -13
- package/src/report/api/isReportedByMe.ts +4 -0
- package/src/report/api/tests/createReport.test.ts +93 -0
- package/src/report/api/tests/deleteReport.test.ts +93 -0
- package/src/stream/api/createStream.ts +4 -0
- package/src/stream/api/deleteStream.ts +3 -0
- package/src/stream/api/getStream.ts +4 -0
- package/src/stream/api/queryStreams.ts +4 -0
- package/src/stream/api/updateStream.ts +3 -0
- package/src/subChannel/api/createSubChannel.ts +5 -1
- package/src/subChannel/api/deleteSubChannel.ts +4 -0
- package/src/subChannel/api/getSubChannel.ts +5 -1
- package/src/subChannel/api/getSubChannels.ts +1 -1
- package/src/subChannel/api/querySubChannels.ts +6 -2
- package/src/subChannel/api/updateSubChannel.ts +5 -1
- package/src/subChannel/events/onSubChannelCreated.ts +1 -1
- package/src/subChannel/events/onSubChannelDeleted.ts +1 -1
- package/src/subChannel/events/onSubChannelUpdated.ts +1 -1
- package/src/subChannel/utils/index.ts +2 -2
- package/src/user/api/getUser.ts +4 -0
- package/src/user/api/getUsers.ts +3 -0
- package/src/user/api/queryUsers.ts +5 -6
- package/src/user/api/updateUser.ts +4 -0
- package/src/user/observers/index.ts +1 -0
- package/src/user/observers/liveUsers.ts +162 -0
- package/src/user/observers/tests/liveUsers.test.ts +204 -0
- package/src/user/tests/api/getUser.test.ts +17 -3
- package/src/utils/index.ts +2 -2
- package/src/utils/liveObject.ts +1 -1
- package/src/utils/tests/dummy/channel.ts +19 -11
- package/src/utils/tests/dummy/community.ts +68 -6
- package/src/utils/tests/dummy/feed.ts +13 -0
- package/src/utils/tests/dummy/index.ts +2 -0
- package/src/utils/tests/dummy/member.ts +1 -1
- package/src/utils/tests/dummy/post.ts +98 -10
- package/src/utils/tests/dummy/user.ts +36 -0
- package/src/version.ts +9 -3
package/dist/index.esm.js
CHANGED
|
@@ -79,16 +79,16 @@ const PostContentType = Object.freeze({
|
|
|
79
79
|
POLL: 'poll',
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const VERSION
|
|
82
|
+
function getVersion() {
|
|
83
|
+
try {
|
|
84
|
+
// the string ''v0.0.1-beta.41-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
85
|
+
return 'v0.0.1-beta.41-esm';
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
return '__dev__';
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const VERSION = getVersion();
|
|
92
92
|
|
|
93
93
|
// cache constants
|
|
94
94
|
const CACHE_KEY_GET = 'get';
|
|
@@ -163,14 +163,14 @@ const partialMatch = (predicate, candidate) => {
|
|
|
163
163
|
const checkIfShouldGoesToTombstone = (errorCode) => [400400 /* Amity.ServerError.ITEM_NOT_FOUND */, 400300 /* Amity.ServerError.FORBIDDEN */].includes(errorCode);
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
* Type guard to find if the a given decoded backend token uses "skip
|
|
166
|
+
* Type guard to find if the a given decoded backend token uses "skip" pagination style
|
|
167
167
|
*
|
|
168
168
|
* @param json any json object as extracted from the backend
|
|
169
169
|
* @returns success boolean if the token has either "skip" or "limit" props
|
|
170
170
|
*
|
|
171
171
|
* @hidden
|
|
172
172
|
*/
|
|
173
|
-
const
|
|
173
|
+
const isSkip = (json) => ['skip'].some(prop => prop in json);
|
|
174
174
|
/**
|
|
175
175
|
* Type guard to find if the a given decoded backend token uses "after/before" pagination style
|
|
176
176
|
*
|
|
@@ -270,7 +270,7 @@ const toPage = (token) => {
|
|
|
270
270
|
return undefined;
|
|
271
271
|
// don't try catch, let it throw
|
|
272
272
|
const json = JSON.parse(decode(token));
|
|
273
|
-
if (
|
|
273
|
+
if (isSkip(json)) {
|
|
274
274
|
return {
|
|
275
275
|
after: json.skip,
|
|
276
276
|
limit: json.limit,
|
|
@@ -426,6 +426,8 @@ const queryOptions = (policy, lifeSpan = CACHE_LIFESPAN) => {
|
|
|
426
426
|
* @category Query
|
|
427
427
|
*/
|
|
428
428
|
const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_server')) => {
|
|
429
|
+
console.warn('Deprecation Notice: After 1 April 2023, CreateQuery/RunQuery will no longer be supported. You will be able to use the API without either methods. Check https://docs.amity.co/ for details');
|
|
430
|
+
console.warn('Deprecation Notice: After 1 March 2023, individual module imoprts will no longer be supported. All public APIs will need to be imported from their respective repositories. Ex: CommunityRepository, UserRepository, etc. Check https://docs.amity.co/ for detailed info.');
|
|
429
431
|
let local;
|
|
430
432
|
const { lifeSpan } = queryOptions('cache_then_server', options.lifeSpan);
|
|
431
433
|
// offline first
|
|
@@ -497,6 +499,7 @@ const idResolvers = {
|
|
|
497
499
|
stream: ({ streamId }) => streamId,
|
|
498
500
|
follow: ({ from, to }) => `${from}#${to}`,
|
|
499
501
|
followCount: ({ userId }) => userId,
|
|
502
|
+
feed: ({ targetId, feedId }) => `${targetId}#${feedId}`,
|
|
500
503
|
};
|
|
501
504
|
/**
|
|
502
505
|
* Retrieve the id resolver matching a domain name
|
|
@@ -534,6 +537,7 @@ const CRITERIAS = {
|
|
|
534
537
|
stream: ['streamId'],
|
|
535
538
|
follow: ['from', 'to'],
|
|
536
539
|
followCount: ['userId', 'followerCount'],
|
|
540
|
+
feed: ['feedId', 'feedType'],
|
|
537
541
|
};
|
|
538
542
|
/** @hidden */
|
|
539
543
|
const hasKeys = (object, needles) => {
|
|
@@ -543,7 +547,7 @@ const hasKeys = (object, needles) => {
|
|
|
543
547
|
/**
|
|
544
548
|
* Finds the name of the store for a given unknown model
|
|
545
549
|
*
|
|
546
|
-
* @param model one of the {@link Amity.
|
|
550
|
+
* @param model one of the {@link Amity.Models} to identify
|
|
547
551
|
* @returns the name of the corresponding store
|
|
548
552
|
*/
|
|
549
553
|
const identifyModel = (model) => {
|
|
@@ -594,6 +598,7 @@ const PAYLOAD2MODEL = {
|
|
|
594
598
|
videoStreamings: 'stream',
|
|
595
599
|
follows: 'follow',
|
|
596
600
|
followCounts: 'followCount',
|
|
601
|
+
feeds: 'feed',
|
|
597
602
|
};
|
|
598
603
|
/** hidden */
|
|
599
604
|
const hasUpdates = (prevData, nextData) => {
|
|
@@ -1060,10 +1065,36 @@ const filterByChannelMembership = (collection, membership, userId) => {
|
|
|
1060
1065
|
'get',
|
|
1061
1066
|
channelUserCacheKey,
|
|
1062
1067
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1063
|
-
if (membership === 'member'
|
|
1064
|
-
return
|
|
1068
|
+
if (membership === 'member') {
|
|
1069
|
+
return channelUser && channelUser.membership !== 'none';
|
|
1065
1070
|
}
|
|
1066
|
-
|
|
1071
|
+
// only membership value remainging is 'notMember'
|
|
1072
|
+
return !channelUser || channelUser.membership === 'none';
|
|
1073
|
+
});
|
|
1074
|
+
};
|
|
1075
|
+
/**
|
|
1076
|
+
* Filter a channel collection by membership of the userId
|
|
1077
|
+
*
|
|
1078
|
+
* @param collection the channel collection to filter
|
|
1079
|
+
* @param feedType to be filtered by
|
|
1080
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1081
|
+
*
|
|
1082
|
+
* @hidden
|
|
1083
|
+
*/
|
|
1084
|
+
const filterByFeedType = (collection, feedType) => {
|
|
1085
|
+
/*
|
|
1086
|
+
* It is possible that the targetId & feedId are the same for most of the posts
|
|
1087
|
+
* But since cache is in-memory, i've avoided memoizing, to avoid premature
|
|
1088
|
+
* optimization. Can be revisited if performance issues arise
|
|
1089
|
+
*/
|
|
1090
|
+
return collection.filter(({ targetId, feedId }) => {
|
|
1091
|
+
var _a;
|
|
1092
|
+
const feed = (_a = pullFromCache([
|
|
1093
|
+
'feed',
|
|
1094
|
+
'get',
|
|
1095
|
+
getResolver('feed')({ targetId, feedId }),
|
|
1096
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1097
|
+
return feed && feed.feedType === feedType;
|
|
1067
1098
|
});
|
|
1068
1099
|
};
|
|
1069
1100
|
|
|
@@ -1331,6 +1362,14 @@ function subscribeTopic(topic, callback) {
|
|
|
1331
1362
|
return mqtt.subscribe(topic, callback);
|
|
1332
1363
|
}
|
|
1333
1364
|
|
|
1365
|
+
var _a;
|
|
1366
|
+
/* eslint-disable no-undef */
|
|
1367
|
+
const theGlobal =
|
|
1368
|
+
// eslint-disable-next-line no-nested-ternary
|
|
1369
|
+
typeof globalThis === 'object' ? globalThis : typeof global === 'object' ? global : window;
|
|
1370
|
+
const { process: safeProcess = {} } = theGlobal;
|
|
1371
|
+
const isProduction = ((_a = safeProcess.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV) === 'production';
|
|
1372
|
+
|
|
1334
1373
|
/**
|
|
1335
1374
|
* Creates a pre-configured logger instance
|
|
1336
1375
|
*
|
|
@@ -20325,8 +20364,6 @@ const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
|
|
|
20325
20364
|
|
|
20326
20365
|
// TODO: find a way to uniquely identify the device
|
|
20327
20366
|
/** @hidden */
|
|
20328
|
-
const VERSION = '11.0.0';
|
|
20329
|
-
/** @hidden */
|
|
20330
20367
|
const getDeviceId = () => {
|
|
20331
20368
|
// here maybe put some auto detection of the device id based on if it's react or not?
|
|
20332
20369
|
// anyhow we let consumer branch out if they want, but it doesn't mean we shouldn't try to be nice
|
|
@@ -20348,10 +20385,10 @@ const getDeviceModel = () => {
|
|
|
20348
20385
|
const getDeviceInfo = () => {
|
|
20349
20386
|
const model = getDeviceModel();
|
|
20350
20387
|
return {
|
|
20351
|
-
version: VERSION,
|
|
20352
20388
|
// TODO: replace with: kind: process.versions ? 'node' : 'web', when backend has fixed this
|
|
20353
20389
|
kind: 'web',
|
|
20354
20390
|
model,
|
|
20391
|
+
sdkVersion: VERSION,
|
|
20355
20392
|
};
|
|
20356
20393
|
};
|
|
20357
20394
|
|
|
@@ -20427,7 +20464,7 @@ const getToken = async (params) => {
|
|
|
20427
20464
|
const client = getActiveClient();
|
|
20428
20465
|
client.log('client/api/getToken', params);
|
|
20429
20466
|
const deviceInfo = getDeviceInfo();
|
|
20430
|
-
const { data } = await client.http.post('/api/
|
|
20467
|
+
const { data } = await client.http.post('/api/v4/sessions', Object.assign(Object.assign({}, params), { deviceInfo }), {
|
|
20431
20468
|
// @ts-ignore
|
|
20432
20469
|
headers: { 'X-API-Key': client.apiKey },
|
|
20433
20470
|
});
|
|
@@ -20463,6 +20500,9 @@ const setClientToken = async (params) => {
|
|
|
20463
20500
|
return { accessToken, users, refreshToken };
|
|
20464
20501
|
};
|
|
20465
20502
|
|
|
20503
|
+
/* begin_public_function
|
|
20504
|
+
id: client.logout
|
|
20505
|
+
*/
|
|
20466
20506
|
/**
|
|
20467
20507
|
* ```js
|
|
20468
20508
|
* import { disconnectClient } from '@amityco/ts-sdk'
|
|
@@ -20511,7 +20551,8 @@ const disconnectClient = async () => {
|
|
|
20511
20551
|
client.cache = { data: {} };
|
|
20512
20552
|
}
|
|
20513
20553
|
return !client.ws.connected;
|
|
20514
|
-
};
|
|
20554
|
+
};
|
|
20555
|
+
/* end_public_function */
|
|
20515
20556
|
|
|
20516
20557
|
/**
|
|
20517
20558
|
* Ingest a payload (v3) into the cache
|
|
@@ -20528,9 +20569,10 @@ const ingestInCache = (payload = {}, options) => {
|
|
|
20528
20569
|
if (!type)
|
|
20529
20570
|
return;
|
|
20530
20571
|
const resolver = getResolver(type);
|
|
20572
|
+
if (!resolver)
|
|
20573
|
+
return;
|
|
20531
20574
|
models.forEach(model => {
|
|
20532
|
-
upsertInCache([type, 'get', resolver(model)],
|
|
20533
|
-
model, options);
|
|
20575
|
+
upsertInCache([type, 'get', resolver(model)], model, options);
|
|
20534
20576
|
});
|
|
20535
20577
|
});
|
|
20536
20578
|
};
|
|
@@ -20714,6 +20756,9 @@ const onTokenTerminated = (callback) => {
|
|
|
20714
20756
|
* to be cleared
|
|
20715
20757
|
*/
|
|
20716
20758
|
const subscriptions = [];
|
|
20759
|
+
/* begin_public_function
|
|
20760
|
+
id: client.login
|
|
20761
|
+
*/
|
|
20717
20762
|
/**
|
|
20718
20763
|
* ```js
|
|
20719
20764
|
* import { connectClient } from '@amityco/ts-sdk/client/api'
|
|
@@ -20806,10 +20851,14 @@ const connectClient = async (params, sessionHandler, config) => {
|
|
|
20806
20851
|
setSessionState(state);
|
|
20807
20852
|
disconnectClient();
|
|
20808
20853
|
subscriptions.forEach(fn => fn());
|
|
20809
|
-
})
|
|
20854
|
+
}));
|
|
20810
20855
|
return client.ws.connected;
|
|
20811
|
-
};
|
|
20856
|
+
};
|
|
20857
|
+
/* end_public_function */
|
|
20812
20858
|
|
|
20859
|
+
/* begin_public_function
|
|
20860
|
+
id: client.renew_access_token
|
|
20861
|
+
*/
|
|
20813
20862
|
/*
|
|
20814
20863
|
* Renewal defintion accepted by SessionHandler interface
|
|
20815
20864
|
*
|
|
@@ -20868,7 +20917,8 @@ const renewal = () => {
|
|
|
20868
20917
|
}, ACCESS_TOKEN_WATCHER_INTERVAL);
|
|
20869
20918
|
},
|
|
20870
20919
|
};
|
|
20871
|
-
};
|
|
20920
|
+
};
|
|
20921
|
+
/* end_public_function */
|
|
20872
20922
|
|
|
20873
20923
|
const ABOUT_TO_EXPIRE_THRESHOLD = 80 / 100;
|
|
20874
20924
|
const COMPENSATED_DELAY = 5 * MINUTE;
|
|
@@ -20965,7 +21015,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
|
|
|
20965
21015
|
const sessionState = "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */;
|
|
20966
21016
|
const sessionHandler = undefined;
|
|
20967
21017
|
const client = {
|
|
20968
|
-
version: `${VERSION
|
|
21018
|
+
version: `${VERSION}`,
|
|
20969
21019
|
apiKey,
|
|
20970
21020
|
log,
|
|
20971
21021
|
http,
|
|
@@ -21063,6 +21113,9 @@ const pushToTombstone = (model, modelId) => {
|
|
|
21063
21113
|
pushToCache(cacheKey, data);
|
|
21064
21114
|
};
|
|
21065
21115
|
|
|
21116
|
+
/* begin_public_function
|
|
21117
|
+
id: user.get
|
|
21118
|
+
*/
|
|
21066
21119
|
/**
|
|
21067
21120
|
* ```js
|
|
21068
21121
|
* import { getUser } from '@amityco/ts-sdk'
|
|
@@ -21105,6 +21158,7 @@ const getUser = async (userId, isLive = false) => {
|
|
|
21105
21158
|
cachedAt,
|
|
21106
21159
|
};
|
|
21107
21160
|
};
|
|
21161
|
+
/* end_public_function */
|
|
21108
21162
|
/**
|
|
21109
21163
|
* ```js
|
|
21110
21164
|
* import { getUser } from '@amityco/ts-sdk'
|
|
@@ -21124,6 +21178,9 @@ getUser.locally = (userId) => {
|
|
|
21124
21178
|
return client.cache && pullFromCache(['user', 'get', userId]);
|
|
21125
21179
|
};
|
|
21126
21180
|
|
|
21181
|
+
/* begin_public_function
|
|
21182
|
+
id: user.get_by_ids
|
|
21183
|
+
*/
|
|
21127
21184
|
/**
|
|
21128
21185
|
* ```js
|
|
21129
21186
|
* import { getUsers } from '@amityco/ts-sdk'
|
|
@@ -21214,6 +21271,9 @@ function __rest(s, e) {
|
|
|
21214
21271
|
return t;
|
|
21215
21272
|
}
|
|
21216
21273
|
|
|
21274
|
+
/* begin_public_function
|
|
21275
|
+
id: user.query, user.search
|
|
21276
|
+
*/
|
|
21217
21277
|
/**
|
|
21218
21278
|
* ```js
|
|
21219
21279
|
* import { queryUsers } from '@amityco/ts-sdk'
|
|
@@ -21257,6 +21317,7 @@ const queryUsers = async (query = {}) => {
|
|
|
21257
21317
|
const nextPage = toPage(paging.next);
|
|
21258
21318
|
return { data: users, cachedAt, prevPage, nextPage };
|
|
21259
21319
|
};
|
|
21320
|
+
/* end_public_function */
|
|
21260
21321
|
/**
|
|
21261
21322
|
* ```js
|
|
21262
21323
|
* import { queryUsers } from '@amityco/ts-sdk'
|
|
@@ -21292,6 +21353,9 @@ queryUsers.locally = (query = {}) => {
|
|
|
21292
21353
|
: undefined;
|
|
21293
21354
|
};
|
|
21294
21355
|
|
|
21356
|
+
/* begin_public_function
|
|
21357
|
+
id: client.update_user
|
|
21358
|
+
*/
|
|
21295
21359
|
/**
|
|
21296
21360
|
* ```js
|
|
21297
21361
|
* import { updateUser } from '@amityco/ts-sdk'
|
|
@@ -21326,7 +21390,8 @@ const updateUser = async (userId, patch) => {
|
|
|
21326
21390
|
data: users.find(user => user.userId === userId),
|
|
21327
21391
|
cachedAt,
|
|
21328
21392
|
};
|
|
21329
|
-
};
|
|
21393
|
+
};
|
|
21394
|
+
/* end_public_function */
|
|
21330
21395
|
|
|
21331
21396
|
/**
|
|
21332
21397
|
* ```js
|
|
@@ -21495,6 +21560,101 @@ const liveUser = (userId, callback) => {
|
|
|
21495
21560
|
]);
|
|
21496
21561
|
};
|
|
21497
21562
|
|
|
21563
|
+
/**
|
|
21564
|
+
* ```js
|
|
21565
|
+
* import { liveUsers } from '@amityco/ts-sdk'
|
|
21566
|
+
*
|
|
21567
|
+
* let users = []
|
|
21568
|
+
* const unsub = liveUsers({}, response => merge(users, response.data))
|
|
21569
|
+
* ```
|
|
21570
|
+
*
|
|
21571
|
+
* Observe all mutations on a list of {@link Amity.User}s
|
|
21572
|
+
*
|
|
21573
|
+
* @param params for querying users
|
|
21574
|
+
* @param callback the function to call when new data are available
|
|
21575
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the users
|
|
21576
|
+
*
|
|
21577
|
+
* @category Category Live Collection
|
|
21578
|
+
*/
|
|
21579
|
+
const liveUsers = (params, callback, config) => {
|
|
21580
|
+
const { log, cache } = getActiveClient();
|
|
21581
|
+
if (!cache) {
|
|
21582
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
21583
|
+
}
|
|
21584
|
+
const timestamp = Date.now();
|
|
21585
|
+
log(`liveUsers(tmpid: ${timestamp}) > listen`);
|
|
21586
|
+
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
21587
|
+
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
21588
|
+
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
21589
|
+
const disposers = [];
|
|
21590
|
+
const cacheKey = ['user', 'collection', {}];
|
|
21591
|
+
const responder = (data) => {
|
|
21592
|
+
var _a, _b;
|
|
21593
|
+
let users = (_a = data.data
|
|
21594
|
+
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
21595
|
+
.filter(Boolean)
|
|
21596
|
+
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
21597
|
+
users = filterByPropEquality(users, 'displayName', params.displayName);
|
|
21598
|
+
switch (params.sortBy) {
|
|
21599
|
+
case 'firstCreated':
|
|
21600
|
+
users = users.sort(sortByFirstCreated);
|
|
21601
|
+
break;
|
|
21602
|
+
case 'lastCreated':
|
|
21603
|
+
users = users.sort(sortByLastCreated);
|
|
21604
|
+
break;
|
|
21605
|
+
default:
|
|
21606
|
+
users = users
|
|
21607
|
+
// this needs to be aligned with the backend data type
|
|
21608
|
+
.map(u => (u.displayName ? u : Object.assign(Object.assign({}, u), { displayName: '' })))
|
|
21609
|
+
// @ts-ignore
|
|
21610
|
+
.sort(sortByDisplayName);
|
|
21611
|
+
}
|
|
21612
|
+
callback({
|
|
21613
|
+
onNextPage: onFetch,
|
|
21614
|
+
data: users,
|
|
21615
|
+
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
21616
|
+
loading: data.loading,
|
|
21617
|
+
error: data.error,
|
|
21618
|
+
});
|
|
21619
|
+
};
|
|
21620
|
+
const realtimeRouter = (_) => (user) => {
|
|
21621
|
+
var _a;
|
|
21622
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21623
|
+
if (!collection)
|
|
21624
|
+
return;
|
|
21625
|
+
collection.data = [...new Set([user.userId, ...collection.data])];
|
|
21626
|
+
pushToCache(cacheKey, collection);
|
|
21627
|
+
responder(collection);
|
|
21628
|
+
};
|
|
21629
|
+
const onFetch = () => {
|
|
21630
|
+
var _a, _b, _c;
|
|
21631
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
21632
|
+
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
21633
|
+
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
21634
|
+
return;
|
|
21635
|
+
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
21636
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
21637
|
+
const data = {
|
|
21638
|
+
loading,
|
|
21639
|
+
error,
|
|
21640
|
+
params: { page },
|
|
21641
|
+
data: users,
|
|
21642
|
+
};
|
|
21643
|
+
if (result) {
|
|
21644
|
+
data.data = [...new Set([...users, ...result.map(getResolver('user'))])];
|
|
21645
|
+
}
|
|
21646
|
+
pushToCache(cacheKey, data);
|
|
21647
|
+
responder(data);
|
|
21648
|
+
}, queryOptions(policy));
|
|
21649
|
+
};
|
|
21650
|
+
disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
|
|
21651
|
+
onFetch();
|
|
21652
|
+
return () => {
|
|
21653
|
+
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
21654
|
+
disposers.forEach(fn => fn());
|
|
21655
|
+
};
|
|
21656
|
+
};
|
|
21657
|
+
|
|
21498
21658
|
/**
|
|
21499
21659
|
* ```js
|
|
21500
21660
|
* import { observeUser } from '@amityco/ts-sdk'
|
|
@@ -21536,6 +21696,9 @@ const observeUser = (userId, callback) => {
|
|
|
21536
21696
|
};
|
|
21537
21697
|
};
|
|
21538
21698
|
|
|
21699
|
+
/* begin_public_function
|
|
21700
|
+
id: file.get
|
|
21701
|
+
*/
|
|
21539
21702
|
/**
|
|
21540
21703
|
* ```js
|
|
21541
21704
|
* import { getFile } from '@amityco/ts-sdk'
|
|
@@ -21564,6 +21727,7 @@ const getFile = async (fileId) => {
|
|
|
21564
21727
|
cachedAt,
|
|
21565
21728
|
};
|
|
21566
21729
|
};
|
|
21730
|
+
/* end_public_function */
|
|
21567
21731
|
/**
|
|
21568
21732
|
* ```js
|
|
21569
21733
|
* import { getFile } from '@amityco/ts-sdk'
|
|
@@ -21591,6 +21755,9 @@ getFile.locally = (fileId) => {
|
|
|
21591
21755
|
};
|
|
21592
21756
|
};
|
|
21593
21757
|
|
|
21758
|
+
/* begin_public_function
|
|
21759
|
+
id: file.upload.file
|
|
21760
|
+
*/
|
|
21594
21761
|
/**
|
|
21595
21762
|
* ```js
|
|
21596
21763
|
* import { createFile } from '@amityco/ts-sdk'
|
|
@@ -21630,8 +21797,12 @@ const createFile = async (formData, onProgress) => {
|
|
|
21630
21797
|
cachedAt,
|
|
21631
21798
|
};
|
|
21632
21799
|
};
|
|
21800
|
+
/* end_public_function */
|
|
21633
21801
|
// TODO: consider doing local creation with URL.createObjectURL()
|
|
21634
21802
|
|
|
21803
|
+
/* begin_public_function
|
|
21804
|
+
id: file.delete
|
|
21805
|
+
*/
|
|
21635
21806
|
/**
|
|
21636
21807
|
* ```js
|
|
21637
21808
|
* import { deleteFile } from '@amityco/ts-sdk'
|
|
@@ -21653,7 +21824,8 @@ const deleteFile = async (fileId) => {
|
|
|
21653
21824
|
await client.http.delete(`/api/v3/files/${fileId}`);
|
|
21654
21825
|
dropFromCache(['file', 'get', fileId], true);
|
|
21655
21826
|
return { success: true };
|
|
21656
|
-
};
|
|
21827
|
+
};
|
|
21828
|
+
/* end_public_function */
|
|
21657
21829
|
|
|
21658
21830
|
/**
|
|
21659
21831
|
* Allow to query a file url with a selected size
|
|
@@ -21666,6 +21838,9 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
21666
21838
|
return `${fileUrl}?size=${size}`;
|
|
21667
21839
|
};
|
|
21668
21840
|
|
|
21841
|
+
/* begin_public_function
|
|
21842
|
+
id: file.upload.video
|
|
21843
|
+
*/
|
|
21669
21844
|
/**
|
|
21670
21845
|
* ```js
|
|
21671
21846
|
* import { createVideo } from '@amityco/ts-sdk'
|
|
@@ -21709,8 +21884,12 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
21709
21884
|
cachedAt,
|
|
21710
21885
|
};
|
|
21711
21886
|
};
|
|
21887
|
+
/* end_public_function */
|
|
21712
21888
|
// TODO: consider doing local creation with URL.createObjectURL()
|
|
21713
21889
|
|
|
21890
|
+
/* begin_public_function
|
|
21891
|
+
id: file.upload.image
|
|
21892
|
+
*/
|
|
21714
21893
|
/**
|
|
21715
21894
|
* ```js
|
|
21716
21895
|
* import { createImage } from '@amityco/ts-sdk'
|
|
@@ -21750,6 +21929,7 @@ const createImage = async (formData, onProgress) => {
|
|
|
21750
21929
|
cachedAt,
|
|
21751
21930
|
};
|
|
21752
21931
|
};
|
|
21932
|
+
/* end_public_function */
|
|
21753
21933
|
// TODO: consider doing local creation with URL.createObjectURL()
|
|
21754
21934
|
|
|
21755
21935
|
/**
|
|
@@ -22004,6 +22184,9 @@ function convertQueryParams$1(_a) {
|
|
|
22004
22184
|
return out;
|
|
22005
22185
|
}
|
|
22006
22186
|
|
|
22187
|
+
/* begin_public_function
|
|
22188
|
+
id: message.get
|
|
22189
|
+
*/
|
|
22007
22190
|
/**
|
|
22008
22191
|
* ```js
|
|
22009
22192
|
* import { getMessage } from '@amityco/ts-sdk'
|
|
@@ -22049,6 +22232,7 @@ const getMessage = async (messageId, isLive = false) => {
|
|
|
22049
22232
|
cachedAt,
|
|
22050
22233
|
};
|
|
22051
22234
|
};
|
|
22235
|
+
/* end_public_function */
|
|
22052
22236
|
/**
|
|
22053
22237
|
* ```js
|
|
22054
22238
|
* import { getMessage } from '@amityco/ts-sdk'
|
|
@@ -22140,6 +22324,9 @@ getMessages.locally = (messageIds) => {
|
|
|
22140
22324
|
};
|
|
22141
22325
|
};
|
|
22142
22326
|
|
|
22327
|
+
/* begin_public_function
|
|
22328
|
+
id: message.query
|
|
22329
|
+
*/
|
|
22143
22330
|
/**
|
|
22144
22331
|
* ```js
|
|
22145
22332
|
* import { queryMessages } from '@amityco/ts-sdk'
|
|
@@ -22176,10 +22363,11 @@ const queryMessages = async (query) => {
|
|
|
22176
22363
|
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
22177
22364
|
}
|
|
22178
22365
|
fireEvent('local.message.fetched', { messages });
|
|
22179
|
-
const nextPage =
|
|
22180
|
-
const prevPage =
|
|
22366
|
+
const nextPage = toPageRaw(paging.next);
|
|
22367
|
+
const prevPage = toPageRaw(paging.previous);
|
|
22181
22368
|
return { data: messages, cachedAt, prevPage, nextPage };
|
|
22182
22369
|
};
|
|
22370
|
+
/* end_public_function */
|
|
22183
22371
|
/**
|
|
22184
22372
|
* ```js
|
|
22185
22373
|
* import { queryMessages } from '@amityco/ts-sdk'
|
|
@@ -22208,8 +22396,8 @@ queryMessages.locally = (query) => {
|
|
|
22208
22396
|
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
22209
22397
|
.filter(Boolean)
|
|
22210
22398
|
.map(({ data }) => data);
|
|
22211
|
-
const prevPage =
|
|
22212
|
-
const nextPage =
|
|
22399
|
+
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
22400
|
+
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
22213
22401
|
return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
|
|
22214
22402
|
? { data: messages, cachedAt, prevPage, nextPage }
|
|
22215
22403
|
: undefined;
|
|
@@ -22217,8 +22405,12 @@ queryMessages.locally = (query) => {
|
|
|
22217
22405
|
|
|
22218
22406
|
const uuid = () => nativeIdGenerator.v4().toString();
|
|
22219
22407
|
|
|
22408
|
+
const getLocalId = () => `LOCAL_${uuid()}`;
|
|
22220
22409
|
// FIXME: temp solution
|
|
22221
22410
|
let uniqueId;
|
|
22411
|
+
/* begin_public_function
|
|
22412
|
+
id: message.create.text_message, message.create.image_message, message.create.file_message, message.create.video_message, message.create.audio_message, message.create.custom_message
|
|
22413
|
+
*/
|
|
22222
22414
|
/**
|
|
22223
22415
|
* ```js
|
|
22224
22416
|
* import { createMessage, createQuery, runQuery } from '@amityco/ts-sdk'
|
|
@@ -22244,17 +22436,16 @@ let uniqueId;
|
|
|
22244
22436
|
const createMessage = async (bundle) => {
|
|
22245
22437
|
const client = getActiveClient();
|
|
22246
22438
|
client.log('message/createMessage', bundle);
|
|
22247
|
-
const referenceId = uniqueId;
|
|
22439
|
+
const referenceId = uniqueId || getLocalId();
|
|
22248
22440
|
uniqueId = undefined;
|
|
22249
|
-
const { data } = await client.http
|
|
22250
|
-
|
|
22251
|
-
|
|
22441
|
+
const { data: payload } = await client.http.post('/api/v5/messages', Object.assign(Object.assign({}, convertParams(bundle)), { referenceId }));
|
|
22442
|
+
const data = prepareMessagePayload(payload);
|
|
22443
|
+
const { messages } = data;
|
|
22252
22444
|
const cachedAt = client.cache && Date.now();
|
|
22253
22445
|
if (client.cache) {
|
|
22254
22446
|
dropFromCache(['message', 'get', referenceId]);
|
|
22255
22447
|
ingestInCache(data, { cachedAt });
|
|
22256
22448
|
}
|
|
22257
|
-
const { messages } = data;
|
|
22258
22449
|
fireEvent('local.message.created', { messages });
|
|
22259
22450
|
return {
|
|
22260
22451
|
data: messages[0],
|
|
@@ -22290,9 +22481,8 @@ createMessage.optimistically = (bundle) => {
|
|
|
22290
22481
|
* Updated to handle client requirement to add messageId while uploading
|
|
22291
22482
|
* message with image. Temporary!
|
|
22292
22483
|
*/
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
const bundleWithMessageId = Object.assign({ messageId: localId, uniqueId: localId }, bundle);
|
|
22484
|
+
uniqueId = getLocalId();
|
|
22485
|
+
const bundleWithMessageId = Object.assign({ messageId: uniqueId, uniqueId }, bundle);
|
|
22296
22486
|
client.log('message/createMessage.optimistically', bundleWithMessageId);
|
|
22297
22487
|
const subChannel = pullFromCache(['subChannel', 'get', bundle.subChannelId]);
|
|
22298
22488
|
if (subChannel) {
|
|
@@ -22314,8 +22504,12 @@ createMessage.optimistically = (bundle) => {
|
|
|
22314
22504
|
cachedAt,
|
|
22315
22505
|
data: message,
|
|
22316
22506
|
};
|
|
22317
|
-
};
|
|
22507
|
+
};
|
|
22508
|
+
/* end_public_function */
|
|
22318
22509
|
|
|
22510
|
+
/* begin_public_function
|
|
22511
|
+
id: message.edit
|
|
22512
|
+
*/
|
|
22319
22513
|
/**
|
|
22320
22514
|
* ```js
|
|
22321
22515
|
* import { updateMessage } from '@amityco/ts-sdk'
|
|
@@ -22381,8 +22575,12 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
22381
22575
|
data: updated,
|
|
22382
22576
|
cachedAt,
|
|
22383
22577
|
};
|
|
22384
|
-
};
|
|
22578
|
+
};
|
|
22579
|
+
/* end_public_function */
|
|
22385
22580
|
|
|
22581
|
+
/* begin_public_function
|
|
22582
|
+
id: message.soft_delete
|
|
22583
|
+
*/
|
|
22386
22584
|
/**
|
|
22387
22585
|
* ```js
|
|
22388
22586
|
* import { deleteMessage } from '@amityco/ts-sdk'
|
|
@@ -22433,8 +22631,72 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
22433
22631
|
data: deleted,
|
|
22434
22632
|
cachedAt,
|
|
22435
22633
|
};
|
|
22634
|
+
};
|
|
22635
|
+
/* end_public_function */
|
|
22636
|
+
|
|
22637
|
+
/**
|
|
22638
|
+
* Attach user object to membership model
|
|
22639
|
+
* - If cache is not enabled, set user to undefined ({..., user: undefined})
|
|
22640
|
+
* - If user object is not found in cache, set user to undefined
|
|
22641
|
+
* ({..., user: undefined})
|
|
22642
|
+
* - If a user is found in the cache, it attaches the user from the cache
|
|
22643
|
+
* ({..., user: { userId, displayName,... }})
|
|
22644
|
+
*
|
|
22645
|
+
* @param member The membership model object
|
|
22646
|
+
* @param userIdProp The user ID prop name of membership object
|
|
22647
|
+
* @param userProp The user prop name of destination object
|
|
22648
|
+
* @returns The membership model object that is already mapped to user
|
|
22649
|
+
* @hidden
|
|
22650
|
+
*/
|
|
22651
|
+
const withUser = (member, userIdProp = 'userId', userProp = 'user') => {
|
|
22652
|
+
// If the user prop already exists, do not overwrite.
|
|
22653
|
+
if (member[userProp])
|
|
22654
|
+
return member;
|
|
22655
|
+
return Object.assign({ get [userProp]() {
|
|
22656
|
+
var _a;
|
|
22657
|
+
const client = getActiveClient();
|
|
22658
|
+
if (!client.cache)
|
|
22659
|
+
return undefined;
|
|
22660
|
+
const userCache = (_a = pullFromCache(['user', 'get', member[userIdProp]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
22661
|
+
if (!userCache) {
|
|
22662
|
+
return undefined;
|
|
22663
|
+
}
|
|
22664
|
+
return userCache;
|
|
22665
|
+
} }, member);
|
|
22666
|
+
};
|
|
22667
|
+
/**
|
|
22668
|
+
* Mapping membership model with user object
|
|
22669
|
+
*
|
|
22670
|
+
* @param members The membership model objects
|
|
22671
|
+
* @param userIdProp The user ID prop name of membership object
|
|
22672
|
+
* @param userProp The user prop name of destination object
|
|
22673
|
+
* @returns The membership model objects that is already
|
|
22674
|
+
* mapped to users
|
|
22675
|
+
* @hidden
|
|
22676
|
+
*/
|
|
22677
|
+
const withUsers = (members, userIdProp = 'userId', userProp = 'user') => {
|
|
22678
|
+
var _a;
|
|
22679
|
+
return (_a = members === null || members === void 0 ? void 0 : members.map(member => withUser(member, userIdProp, userProp))) !== null && _a !== void 0 ? _a : members;
|
|
22680
|
+
};
|
|
22681
|
+
/**
|
|
22682
|
+
* Transform members prop in any payload with attached users members
|
|
22683
|
+
*
|
|
22684
|
+
* @param payload The payload contain members prop
|
|
22685
|
+
* @param memberProp A name of members prop
|
|
22686
|
+
* @param userIdProp The user ID prop name of membership object
|
|
22687
|
+
* @param userProp The user prop name of destination object
|
|
22688
|
+
* @returns The transforming payload
|
|
22689
|
+
* @hidden
|
|
22690
|
+
*/
|
|
22691
|
+
const prepareMembershipPayload = (payload, memberProp, userIdProp = 'userId', userProp = 'user') => {
|
|
22692
|
+
const _a = payload, _b = memberProp, memberPayload = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
22693
|
+
const members = withUsers(memberPayload, userIdProp, userProp);
|
|
22694
|
+
return Object.assign(Object.assign({}, rest), { [memberProp]: members });
|
|
22436
22695
|
};
|
|
22437
22696
|
|
|
22697
|
+
/* begin_public_function
|
|
22698
|
+
id: post.query, feed.query.community_feed, feed.query.user_feed
|
|
22699
|
+
*/
|
|
22438
22700
|
/**
|
|
22439
22701
|
* ```js
|
|
22440
22702
|
* import { queryPosts } from '@amityco/ts-sdk'
|
|
@@ -22474,10 +22736,11 @@ const queryPosts = async (query) => {
|
|
|
22474
22736
|
// const { paging, posts } = unwrapPayload(data)
|
|
22475
22737
|
// unpacking
|
|
22476
22738
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
22739
|
+
const paperedPayload = prepareMembershipPayload(payload, 'communityUsers');
|
|
22477
22740
|
const { posts } = payload;
|
|
22478
22741
|
const cachedAt = client.cache && Date.now();
|
|
22479
22742
|
if (client.cache) {
|
|
22480
|
-
ingestInCache(
|
|
22743
|
+
ingestInCache(paperedPayload, { cachedAt });
|
|
22481
22744
|
const cacheKey = ['post', 'query', Object.assign(Object.assign({}, params), { options: Object.assign({}, page) })];
|
|
22482
22745
|
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
22483
22746
|
}
|
|
@@ -22485,6 +22748,7 @@ const queryPosts = async (query) => {
|
|
|
22485
22748
|
const prevPage = toPageRaw(paging.previous);
|
|
22486
22749
|
return { data: posts, cachedAt, prevPage, nextPage };
|
|
22487
22750
|
};
|
|
22751
|
+
/* end_public_function */
|
|
22488
22752
|
/**
|
|
22489
22753
|
* ```js
|
|
22490
22754
|
* import { queryPosts } from '@amityco/ts-sdk'
|
|
@@ -22520,6 +22784,9 @@ queryPosts.locally = (query) => {
|
|
|
22520
22784
|
: undefined;
|
|
22521
22785
|
};
|
|
22522
22786
|
|
|
22787
|
+
/* begin_public_function
|
|
22788
|
+
id: post.get_by_ids
|
|
22789
|
+
*/
|
|
22523
22790
|
/**
|
|
22524
22791
|
* ```js
|
|
22525
22792
|
* import { getPosts } from '@amityco/ts-sdk'
|
|
@@ -22539,9 +22806,10 @@ const getPosts = async (postIds) => {
|
|
|
22539
22806
|
client.log('post/getPosts', postIds);
|
|
22540
22807
|
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
22541
22808
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22542
|
-
const { data } = await client.http.get(`/api/v3/posts/list`, {
|
|
22809
|
+
const { data: payload } = await client.http.get(`/api/v3/posts/list`, {
|
|
22543
22810
|
params: { postIds: encodedPostIds },
|
|
22544
22811
|
});
|
|
22812
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
22545
22813
|
const cachedAt = client.cache && Date.now();
|
|
22546
22814
|
if (client.cache)
|
|
22547
22815
|
ingestInCache(data, { cachedAt });
|
|
@@ -22582,6 +22850,9 @@ getPosts.locally = (postIds) => {
|
|
|
22582
22850
|
};
|
|
22583
22851
|
};
|
|
22584
22852
|
|
|
22853
|
+
/* begin_public_function
|
|
22854
|
+
id: post.get
|
|
22855
|
+
*/
|
|
22585
22856
|
/**
|
|
22586
22857
|
* ```js
|
|
22587
22858
|
* import { getPost } from '@amityco/ts-sdk'
|
|
@@ -22600,11 +22871,11 @@ const getPost = async (postId) => {
|
|
|
22600
22871
|
const client = getActiveClient();
|
|
22601
22872
|
client.log('post/getPost', postId);
|
|
22602
22873
|
isInTombstone('post', postId);
|
|
22603
|
-
let
|
|
22874
|
+
let payload;
|
|
22604
22875
|
try {
|
|
22605
22876
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22606
22877
|
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
22607
|
-
|
|
22878
|
+
payload = response.data;
|
|
22608
22879
|
}
|
|
22609
22880
|
catch (error) {
|
|
22610
22881
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
@@ -22612,6 +22883,7 @@ const getPost = async (postId) => {
|
|
|
22612
22883
|
}
|
|
22613
22884
|
throw error;
|
|
22614
22885
|
}
|
|
22886
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
22615
22887
|
const cachedAt = client.cache && Date.now();
|
|
22616
22888
|
if (client.cache)
|
|
22617
22889
|
ingestInCache(data, { cachedAt });
|
|
@@ -22621,6 +22893,7 @@ const getPost = async (postId) => {
|
|
|
22621
22893
|
cachedAt,
|
|
22622
22894
|
};
|
|
22623
22895
|
};
|
|
22896
|
+
/* end_public_function */
|
|
22624
22897
|
/**
|
|
22625
22898
|
* ```js
|
|
22626
22899
|
* import { getPost } from '@amityco/ts-sdk'
|
|
@@ -22648,6 +22921,9 @@ getPost.locally = (postId) => {
|
|
|
22648
22921
|
};
|
|
22649
22922
|
};
|
|
22650
22923
|
|
|
22924
|
+
/* begin_public_function
|
|
22925
|
+
id: post.create.text_post, post.create.image_post, post.create.file_post, post.create.video_post, post.create.poll_post, post.create.livestream_post, post.create.custom_post
|
|
22926
|
+
*/
|
|
22651
22927
|
/**
|
|
22652
22928
|
* ```js
|
|
22653
22929
|
* import { createPost } from '@amityco/ts-sdk'
|
|
@@ -22674,18 +22950,23 @@ const createPost = async (bundle) => {
|
|
|
22674
22950
|
// eslint-disable-next-line no-param-reassign
|
|
22675
22951
|
delete bundle.dataType;
|
|
22676
22952
|
}
|
|
22677
|
-
const { data } = await client.http.post('/api/v4/posts', bundle);
|
|
22953
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
22954
|
+
fireEvent('post.created', payload);
|
|
22955
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
22678
22956
|
const cachedAt = client.cache && Date.now();
|
|
22679
22957
|
if (client.cache)
|
|
22680
22958
|
ingestInCache(data, { cachedAt });
|
|
22681
|
-
fireEvent('post.created', data);
|
|
22682
22959
|
const { posts } = data;
|
|
22683
22960
|
return {
|
|
22684
22961
|
data: posts[0],
|
|
22685
22962
|
cachedAt,
|
|
22686
22963
|
};
|
|
22687
|
-
};
|
|
22964
|
+
};
|
|
22965
|
+
/* end_public_function */
|
|
22688
22966
|
|
|
22967
|
+
/* begin_public_function
|
|
22968
|
+
id: post.edit
|
|
22969
|
+
*/
|
|
22689
22970
|
/**
|
|
22690
22971
|
* ```js
|
|
22691
22972
|
* import { updatePost } from '@amityco/ts-sdk'
|
|
@@ -22706,7 +22987,8 @@ const createPost = async (bundle) => {
|
|
|
22706
22987
|
const updatePost = async (postId, patch) => {
|
|
22707
22988
|
const client = getActiveClient();
|
|
22708
22989
|
client.log('user/updatePost', patch);
|
|
22709
|
-
const { data } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
22990
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
22991
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
22710
22992
|
const cachedAt = client.cache && Date.now();
|
|
22711
22993
|
if (client.cache)
|
|
22712
22994
|
ingestInCache(data, { cachedAt });
|
|
@@ -22716,7 +22998,8 @@ const updatePost = async (postId, patch) => {
|
|
|
22716
22998
|
data: posts.find(post => post.postId === postId),
|
|
22717
22999
|
cachedAt,
|
|
22718
23000
|
};
|
|
22719
|
-
};
|
|
23001
|
+
};
|
|
23002
|
+
/* end_public_function */
|
|
22720
23003
|
|
|
22721
23004
|
const getMatchPostSetting = (value) => {
|
|
22722
23005
|
var _a;
|
|
@@ -22724,27 +23007,27 @@ const getMatchPostSetting = (value) => {
|
|
|
22724
23007
|
CommunityPostSettingMaps[key].needApprovalOnPostCreation &&
|
|
22725
23008
|
value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost)) !== null && _a !== void 0 ? _a : DefaultCommunityPostSetting;
|
|
22726
23009
|
};
|
|
22727
|
-
|
|
22728
|
-
|
|
22729
|
-
|
|
22730
|
-
|
|
22731
|
-
|
|
22732
|
-
|
|
22733
|
-
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
23010
|
+
const prepareCommunityPayload = (rawPayload) => {
|
|
23011
|
+
// Unpack community payload by mapping payload field to postSetting value.
|
|
23012
|
+
const communities = rawPayload.communities.map((_a) => {
|
|
23013
|
+
var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
|
|
23014
|
+
return (Object.assign({ postSetting: getMatchPostSetting({
|
|
23015
|
+
needApprovalOnPostCreation,
|
|
23016
|
+
onlyAdminCanPost,
|
|
23017
|
+
}) }, restCommunityPayload));
|
|
23018
|
+
});
|
|
23019
|
+
const communityUsers = withUsers(rawPayload.communityUsers);
|
|
23020
|
+
return Object.assign(Object.assign({}, rawPayload), { communities,
|
|
23021
|
+
communityUsers });
|
|
22739
23022
|
};
|
|
22740
|
-
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
const packCommunityPayload = (_a) => {
|
|
22744
|
-
var { postSetting = undefined } = _a, restParam = __rest(_a, ["postSetting"]);
|
|
22745
|
-
return (Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)));
|
|
23023
|
+
const prepareCommunityRequest = (params) => {
|
|
23024
|
+
const { postSetting = undefined } = params, restParam = __rest(params, ["postSetting"]);
|
|
23025
|
+
return Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined));
|
|
22746
23026
|
};
|
|
22747
23027
|
|
|
23028
|
+
/* begin_public_function
|
|
23029
|
+
id: community.query
|
|
23030
|
+
*/
|
|
22748
23031
|
/**
|
|
22749
23032
|
* ```js
|
|
22750
23033
|
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
@@ -22775,7 +23058,7 @@ const queryCommunities = async (query) => {
|
|
|
22775
23058
|
} }),
|
|
22776
23059
|
});
|
|
22777
23060
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
22778
|
-
const unpackedPayload =
|
|
23061
|
+
const unpackedPayload = prepareCommunityPayload(payload);
|
|
22779
23062
|
const { communities } = unpackedPayload;
|
|
22780
23063
|
const cachedAt = client.cache && Date.now();
|
|
22781
23064
|
if (client.cache) {
|
|
@@ -22791,6 +23074,7 @@ const queryCommunities = async (query) => {
|
|
|
22791
23074
|
const prevPage = toPage(paging.previous);
|
|
22792
23075
|
return { data: communities, cachedAt, prevPage, nextPage };
|
|
22793
23076
|
};
|
|
23077
|
+
/* end_public_function */
|
|
22794
23078
|
/**
|
|
22795
23079
|
* ```js
|
|
22796
23080
|
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
@@ -22831,7 +23115,7 @@ const getCommunities = async (communityIds) => {
|
|
|
22831
23115
|
const { data: payload } = await client.http.get(`/api/v3/communities/list`, {
|
|
22832
23116
|
params: { communityIds },
|
|
22833
23117
|
});
|
|
22834
|
-
const data =
|
|
23118
|
+
const data = prepareCommunityPayload(payload);
|
|
22835
23119
|
const cachedAt = client.cache && Date.now();
|
|
22836
23120
|
if (client.cache)
|
|
22837
23121
|
ingestInCache(data, { cachedAt });
|
|
@@ -22872,6 +23156,9 @@ getCommunities.locally = (communityIds) => {
|
|
|
22872
23156
|
};
|
|
22873
23157
|
};
|
|
22874
23158
|
|
|
23159
|
+
/* begin_public_function
|
|
23160
|
+
id: community.get
|
|
23161
|
+
*/
|
|
22875
23162
|
/**
|
|
22876
23163
|
* ```js
|
|
22877
23164
|
* import { getCommunity } from '@amityco/ts-sdk'
|
|
@@ -22891,7 +23178,7 @@ const getCommunity = async (communityId) => {
|
|
|
22891
23178
|
client.log('community/getCommunity', communityId);
|
|
22892
23179
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22893
23180
|
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
22894
|
-
const data =
|
|
23181
|
+
const data = prepareCommunityPayload(payload);
|
|
22895
23182
|
const cachedAt = client.cache && Date.now();
|
|
22896
23183
|
if (client.cache)
|
|
22897
23184
|
ingestInCache(data, { cachedAt });
|
|
@@ -22901,6 +23188,7 @@ const getCommunity = async (communityId) => {
|
|
|
22901
23188
|
cachedAt,
|
|
22902
23189
|
};
|
|
22903
23190
|
};
|
|
23191
|
+
/* end_public_function */
|
|
22904
23192
|
/**
|
|
22905
23193
|
* ```js
|
|
22906
23194
|
* import { getCommunity } from '@amityco/ts-sdk'
|
|
@@ -22928,6 +23216,9 @@ getCommunity.locally = (communityId) => {
|
|
|
22928
23216
|
};
|
|
22929
23217
|
};
|
|
22930
23218
|
|
|
23219
|
+
/* begin_public_function
|
|
23220
|
+
id: community.create
|
|
23221
|
+
*/
|
|
22931
23222
|
/**
|
|
22932
23223
|
* ```js
|
|
22933
23224
|
* import { createCommunity } from '@amityco/ts-sdk'
|
|
@@ -22945,19 +23236,23 @@ getCommunity.locally = (communityId) => {
|
|
|
22945
23236
|
const createCommunity = async (bundle) => {
|
|
22946
23237
|
const client = getActiveClient();
|
|
22947
23238
|
client.log('user/createCommunity', bundle);
|
|
22948
|
-
const { data: payload } = await client.http.post('/api/v3/communities/',
|
|
22949
|
-
|
|
23239
|
+
const { data: payload } = await client.http.post('/api/v3/communities/', prepareCommunityRequest(bundle));
|
|
23240
|
+
fireEvent('community.created', payload);
|
|
23241
|
+
const data = prepareCommunityPayload(payload);
|
|
22950
23242
|
const cachedAt = client.cache && Date.now();
|
|
22951
23243
|
if (client.cache)
|
|
22952
23244
|
ingestInCache(data, { cachedAt });
|
|
22953
|
-
fireEvent('community.created', data);
|
|
22954
23245
|
const { communities } = data;
|
|
22955
23246
|
return {
|
|
22956
23247
|
data: communities[0],
|
|
22957
23248
|
cachedAt,
|
|
22958
23249
|
};
|
|
22959
|
-
};
|
|
23250
|
+
};
|
|
23251
|
+
/* end_public_function */
|
|
22960
23252
|
|
|
23253
|
+
/* begin_public_function
|
|
23254
|
+
id: community.update
|
|
23255
|
+
*/
|
|
22961
23256
|
/**
|
|
22962
23257
|
* ```js
|
|
22963
23258
|
* import { updateCommunity } from '@amityco/ts-sdk'
|
|
@@ -22976,19 +23271,23 @@ const createCommunity = async (bundle) => {
|
|
|
22976
23271
|
const updateCommunity = async (communityId, patch) => {
|
|
22977
23272
|
const client = getActiveClient();
|
|
22978
23273
|
client.log('community/updateCommunity', communityId, patch);
|
|
22979
|
-
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}`,
|
|
22980
|
-
|
|
23274
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}`, prepareCommunityRequest(patch));
|
|
23275
|
+
fireEvent('community.updated', payload);
|
|
23276
|
+
const data = prepareCommunityPayload(payload);
|
|
22981
23277
|
const cachedAt = client.cache && Date.now();
|
|
22982
23278
|
if (client.cache)
|
|
22983
23279
|
ingestInCache(data, { cachedAt });
|
|
22984
|
-
fireEvent('community.updated', data);
|
|
22985
23280
|
const { communities } = data;
|
|
22986
23281
|
return {
|
|
22987
23282
|
data: communities.find(community => community.communityId === communityId),
|
|
22988
23283
|
cachedAt,
|
|
22989
23284
|
};
|
|
22990
|
-
};
|
|
23285
|
+
};
|
|
23286
|
+
/* end_public_function */
|
|
22991
23287
|
|
|
23288
|
+
/* begin_public_function
|
|
23289
|
+
id: community.delete
|
|
23290
|
+
*/
|
|
22992
23291
|
/**
|
|
22993
23292
|
* ```js
|
|
22994
23293
|
* import { deleteCommunity } from '@amityco/ts-sdk'
|
|
@@ -23009,10 +23308,21 @@ const deleteCommunity = async (communityId) => {
|
|
|
23009
23308
|
// API-FIX: This endpoint has not been implemented yet.
|
|
23010
23309
|
await client.http.delete(`/api/v3/communities/${communityId}`);
|
|
23011
23310
|
const deleted = await getCommunity(communityId);
|
|
23012
|
-
fireEvent('community.deleted', {
|
|
23311
|
+
fireEvent('community.deleted', {
|
|
23312
|
+
communities: [deleted.data],
|
|
23313
|
+
categories: [],
|
|
23314
|
+
communityUsers: [],
|
|
23315
|
+
feeds: [],
|
|
23316
|
+
files: [],
|
|
23317
|
+
users: [],
|
|
23318
|
+
});
|
|
23013
23319
|
return deleted.data;
|
|
23014
|
-
};
|
|
23320
|
+
};
|
|
23321
|
+
/* end_public_function */
|
|
23015
23322
|
|
|
23323
|
+
/* begin_public_function
|
|
23324
|
+
id: community.join
|
|
23325
|
+
*/
|
|
23016
23326
|
/**
|
|
23017
23327
|
* ```js
|
|
23018
23328
|
* import { joinCommunity } from '@amityco/ts-sdk'
|
|
@@ -23030,15 +23340,20 @@ const deleteCommunity = async (communityId) => {
|
|
|
23030
23340
|
const joinCommunity = async (communityId) => {
|
|
23031
23341
|
const client = getActiveClient();
|
|
23032
23342
|
client.log('community/joinCommunity', communityId);
|
|
23033
|
-
const { data } = await client.http.post(`/api/v3/communities/${communityId}/join`);
|
|
23343
|
+
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/join`);
|
|
23344
|
+
fireEvent('community.joined', payload);
|
|
23345
|
+
const data = prepareCommunityPayload(payload);
|
|
23034
23346
|
const cachedAt = client.cache && Date.now();
|
|
23035
23347
|
if (client.cache)
|
|
23036
23348
|
ingestInCache(data, { cachedAt });
|
|
23037
|
-
fireEvent('community.joined', data);
|
|
23038
23349
|
const { communityUsers } = data;
|
|
23039
23350
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
23040
|
-
};
|
|
23351
|
+
};
|
|
23352
|
+
/* end_public_function */
|
|
23041
23353
|
|
|
23354
|
+
/* begin_public_function
|
|
23355
|
+
id: community.leave
|
|
23356
|
+
*/
|
|
23042
23357
|
/**
|
|
23043
23358
|
* ```js
|
|
23044
23359
|
* import { leaveCommunity } from '@amityco/ts-sdk'
|
|
@@ -23056,67 +23371,20 @@ const joinCommunity = async (communityId) => {
|
|
|
23056
23371
|
const leaveCommunity = async (communityId) => {
|
|
23057
23372
|
const client = getActiveClient();
|
|
23058
23373
|
client.log('community/leaveCommunity', communityId);
|
|
23059
|
-
const { data } = await client.http.delete(`/api/v3/communities/${communityId}/leave`);
|
|
23374
|
+
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/leave`);
|
|
23375
|
+
fireEvent('community.left', payload);
|
|
23376
|
+
const data = prepareCommunityPayload(payload);
|
|
23060
23377
|
const cachedAt = client.cache && Date.now();
|
|
23061
23378
|
if (client.cache)
|
|
23062
23379
|
ingestInCache(data, { cachedAt });
|
|
23063
|
-
fireEvent('community.left', data);
|
|
23064
23380
|
const { communityUsers } = data;
|
|
23065
23381
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
23066
|
-
};
|
|
23067
|
-
|
|
23068
|
-
/**
|
|
23069
|
-
* Attach user object to membership model
|
|
23070
|
-
* - If cache is not enabled, set user to undefined ({..., user: undefined})
|
|
23071
|
-
* - If user object is not found in cache, set user to undefined
|
|
23072
|
-
* ({..., user: undefined})
|
|
23073
|
-
* - If a user is found in the cache, it attaches the user from the cache
|
|
23074
|
-
* ({..., user: { userId, displayName,... }})
|
|
23075
|
-
*
|
|
23076
|
-
* @param member The membership model object
|
|
23077
|
-
* @param userIdProp The user ID prop name of membership object
|
|
23078
|
-
* @param userProp The user prop name of destination object
|
|
23079
|
-
* @returns The membership model object that is already mapped to user
|
|
23080
|
-
* @hidden
|
|
23081
|
-
*/
|
|
23082
|
-
const withUser = (member, userIdProp = 'userId', userProp = 'user') => (Object.assign({ get [userProp]() {
|
|
23083
|
-
var _a;
|
|
23084
|
-
const client = getActiveClient();
|
|
23085
|
-
if (!client.cache)
|
|
23086
|
-
return undefined;
|
|
23087
|
-
const userCache = (_a = pullFromCache(['user', 'get', member[userIdProp]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
23088
|
-
if (!userCache) {
|
|
23089
|
-
return undefined;
|
|
23090
|
-
}
|
|
23091
|
-
return userCache;
|
|
23092
|
-
} }, member));
|
|
23093
|
-
/**
|
|
23094
|
-
* Mapping membership model with user object
|
|
23095
|
-
*
|
|
23096
|
-
* @param members The membership model objects
|
|
23097
|
-
* @param userIdProp The user ID prop name of membership object
|
|
23098
|
-
* @param userProp The user prop name of destination object
|
|
23099
|
-
* @returns The membership model objects that is already
|
|
23100
|
-
* mapped to users
|
|
23101
|
-
* @hidden
|
|
23102
|
-
*/
|
|
23103
|
-
const withUsers = (members, userIdProp = 'userId', userProp = 'user') => members.map(member => withUser(member, userIdProp, userProp));
|
|
23104
|
-
/**
|
|
23105
|
-
* Transform members prop in any payload with attached users members
|
|
23106
|
-
*
|
|
23107
|
-
* @param payload The payload contain members prop
|
|
23108
|
-
* @param memberProp A name of members prop
|
|
23109
|
-
* @param userIdProp The user ID prop name of membership object
|
|
23110
|
-
* @param userProp The user prop name of destination object
|
|
23111
|
-
* @returns The transforming payload
|
|
23112
|
-
* @hidden
|
|
23113
|
-
*/
|
|
23114
|
-
const prepareMembershipPayload = (payload, memberProp, userIdProp = 'userId', userProp = 'user') => {
|
|
23115
|
-
const _a = payload, _b = memberProp, memberPayload = _a[_b], rest = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
23116
|
-
const members = withUsers(memberPayload, userIdProp, userProp);
|
|
23117
|
-
return Object.assign(Object.assign({}, rest), { [memberProp]: members });
|
|
23118
|
-
};
|
|
23382
|
+
};
|
|
23383
|
+
/* end_public_function */
|
|
23119
23384
|
|
|
23385
|
+
/* begin_public_function
|
|
23386
|
+
id: community.membership.query
|
|
23387
|
+
*/
|
|
23120
23388
|
/**
|
|
23121
23389
|
* ```js
|
|
23122
23390
|
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -23160,6 +23428,7 @@ const queryCommunityMembers = async (query) => {
|
|
|
23160
23428
|
const prevPage = toPage(paging.previous);
|
|
23161
23429
|
return { data: communityUsers, cachedAt, nextPage, prevPage };
|
|
23162
23430
|
};
|
|
23431
|
+
/* end_public_function */
|
|
23163
23432
|
/**
|
|
23164
23433
|
* ```js
|
|
23165
23434
|
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -23199,6 +23468,9 @@ queryCommunityMembers.locally = (query) => {
|
|
|
23199
23468
|
: undefined;
|
|
23200
23469
|
};
|
|
23201
23470
|
|
|
23471
|
+
/* begin_public_function
|
|
23472
|
+
id: community.membership.add_members
|
|
23473
|
+
*/
|
|
23202
23474
|
/**
|
|
23203
23475
|
* ```js
|
|
23204
23476
|
* import { addCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -23217,14 +23489,19 @@ queryCommunityMembers.locally = (query) => {
|
|
|
23217
23489
|
const addCommunityMembers = async (communityId, userIds) => {
|
|
23218
23490
|
const client = getActiveClient();
|
|
23219
23491
|
client.log('community/addCommunityMembers', communityId, userIds);
|
|
23220
|
-
const { data } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
23492
|
+
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
23493
|
+
fireEvent('community.userAdded', payload);
|
|
23494
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23221
23495
|
if (client.cache)
|
|
23222
23496
|
ingestInCache(data);
|
|
23223
|
-
fireEvent('community.userAdded', data);
|
|
23224
23497
|
const { communityUsers } = data;
|
|
23225
23498
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
23226
|
-
};
|
|
23499
|
+
};
|
|
23500
|
+
/* end_public_function */
|
|
23227
23501
|
|
|
23502
|
+
/* begin_public_function
|
|
23503
|
+
id: community.membership.remove_member
|
|
23504
|
+
*/
|
|
23228
23505
|
/**
|
|
23229
23506
|
* ```js
|
|
23230
23507
|
* import { removeCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -23243,14 +23520,19 @@ const addCommunityMembers = async (communityId, userIds) => {
|
|
|
23243
23520
|
const removeCommunityMembers = async (communityId, userIds) => {
|
|
23244
23521
|
const client = getActiveClient();
|
|
23245
23522
|
client.log('community/removeCommunityMembers', communityId, userIds);
|
|
23246
|
-
const { data } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
23523
|
+
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
23524
|
+
fireEvent('community.userRemoved', payload);
|
|
23525
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23247
23526
|
if (client.cache)
|
|
23248
23527
|
ingestInCache(data);
|
|
23249
|
-
fireEvent('community.userRemoved', data);
|
|
23250
23528
|
const { communityUsers } = data;
|
|
23251
23529
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
23252
|
-
};
|
|
23530
|
+
};
|
|
23531
|
+
/* end_public_function */
|
|
23253
23532
|
|
|
23533
|
+
/* begin_public_function
|
|
23534
|
+
id: community.moderation.add_roles
|
|
23535
|
+
*/
|
|
23254
23536
|
/**
|
|
23255
23537
|
* ```js
|
|
23256
23538
|
* import { addCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
@@ -23261,7 +23543,7 @@ const removeCommunityMembers = async (communityId, userIds) => {
|
|
|
23261
23543
|
*
|
|
23262
23544
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
23263
23545
|
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
23264
|
-
* @param
|
|
23546
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
23265
23547
|
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
23266
23548
|
*
|
|
23267
23549
|
* @category Community API
|
|
@@ -23270,14 +23552,19 @@ const removeCommunityMembers = async (communityId, userIds) => {
|
|
|
23270
23552
|
const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
23271
23553
|
const client = getActiveClient();
|
|
23272
23554
|
client.log('community/addCommunityMembersRoles', communityId, roleIds, userIds);
|
|
23273
|
-
const { data } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
23555
|
+
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
23556
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23274
23557
|
if (client.cache)
|
|
23275
23558
|
ingestInCache(data);
|
|
23276
23559
|
const { communityUsers } = data;
|
|
23277
23560
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
23278
23561
|
roleIds.some(role => communityUser.roles.includes(role)));
|
|
23279
|
-
};
|
|
23562
|
+
};
|
|
23563
|
+
/* end_public_function */
|
|
23280
23564
|
|
|
23565
|
+
/* begin_public_function
|
|
23566
|
+
id: community.moderation.remove_roles
|
|
23567
|
+
*/
|
|
23281
23568
|
/**
|
|
23282
23569
|
* ```js
|
|
23283
23570
|
* import { removeCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
@@ -23288,7 +23575,7 @@ const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
|
23288
23575
|
*
|
|
23289
23576
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
23290
23577
|
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
23291
|
-
* @param
|
|
23578
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
23292
23579
|
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
23293
23580
|
*
|
|
23294
23581
|
* @category Community API
|
|
@@ -23297,14 +23584,19 @@ const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
|
23297
23584
|
const removeCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
23298
23585
|
const client = getActiveClient();
|
|
23299
23586
|
client.log('community/removeCommunityMembersRoles', communityId, roleIds, userIds);
|
|
23300
|
-
const { data } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
23587
|
+
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
23588
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23301
23589
|
if (client.cache)
|
|
23302
23590
|
ingestInCache(data);
|
|
23303
23591
|
const { communityUsers } = data;
|
|
23304
23592
|
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
23305
23593
|
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
23306
|
-
};
|
|
23594
|
+
};
|
|
23595
|
+
/* end_public_function */
|
|
23307
23596
|
|
|
23597
|
+
/* begin_public_function
|
|
23598
|
+
id: community.query.trending_communities
|
|
23599
|
+
*/
|
|
23308
23600
|
/**
|
|
23309
23601
|
* ```js
|
|
23310
23602
|
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
@@ -23326,7 +23618,7 @@ const getTopTrendingCommunities = async (query) => {
|
|
|
23326
23618
|
// API-FIX: backend doesnt answer Amity.Response
|
|
23327
23619
|
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
23328
23620
|
const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
23329
|
-
const data =
|
|
23621
|
+
const data = prepareCommunityPayload(payload);
|
|
23330
23622
|
const { communities } = data;
|
|
23331
23623
|
const cachedAt = client.cache && Date.now();
|
|
23332
23624
|
if (client.cache) {
|
|
@@ -23336,6 +23628,7 @@ const getTopTrendingCommunities = async (query) => {
|
|
|
23336
23628
|
}
|
|
23337
23629
|
return { data: communities, cachedAt };
|
|
23338
23630
|
};
|
|
23631
|
+
/* end_public_function */
|
|
23339
23632
|
/**
|
|
23340
23633
|
* ```js
|
|
23341
23634
|
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
@@ -23369,6 +23662,9 @@ getTopTrendingCommunities.locally = (query) => {
|
|
|
23369
23662
|
: undefined;
|
|
23370
23663
|
};
|
|
23371
23664
|
|
|
23665
|
+
/* begin_public_function
|
|
23666
|
+
id: community.query.recommended_communities
|
|
23667
|
+
*/
|
|
23372
23668
|
/**
|
|
23373
23669
|
* ```js
|
|
23374
23670
|
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
@@ -23390,7 +23686,7 @@ const getRecommendedCommunities = async (query) => {
|
|
|
23390
23686
|
// API-FIX: backend doesnt answer Amity.Response
|
|
23391
23687
|
// const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
23392
23688
|
const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
23393
|
-
const data =
|
|
23689
|
+
const data = prepareCommunityPayload(payload);
|
|
23394
23690
|
const { communities } = data;
|
|
23395
23691
|
const cachedAt = client.cache && Date.now();
|
|
23396
23692
|
if (client.cache) {
|
|
@@ -23400,6 +23696,7 @@ const getRecommendedCommunities = async (query) => {
|
|
|
23400
23696
|
}
|
|
23401
23697
|
return { data: communities, cachedAt };
|
|
23402
23698
|
};
|
|
23699
|
+
/* end_public_function */
|
|
23403
23700
|
/**
|
|
23404
23701
|
* ```js
|
|
23405
23702
|
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
@@ -23433,6 +23730,9 @@ getRecommendedCommunities.locally = (query) => {
|
|
|
23433
23730
|
: undefined;
|
|
23434
23731
|
};
|
|
23435
23732
|
|
|
23733
|
+
/* begin_public_function
|
|
23734
|
+
id: post.soft_delete, post.hard_delete
|
|
23735
|
+
*/
|
|
23436
23736
|
/**
|
|
23437
23737
|
* ```js
|
|
23438
23738
|
* import { deletePost } from '@amityco/ts-sdk'
|
|
@@ -23464,11 +23764,28 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
23464
23764
|
// later when realtime events covers that for us.
|
|
23465
23765
|
if (post.data.targetType === 'community') {
|
|
23466
23766
|
const community = await getCommunity(post.data.targetId);
|
|
23467
|
-
fireEvent('community.updated', {
|
|
23767
|
+
fireEvent('community.updated', {
|
|
23768
|
+
communities: [community.data],
|
|
23769
|
+
categories: [],
|
|
23770
|
+
communityUsers: [],
|
|
23771
|
+
feeds: [],
|
|
23772
|
+
files: [],
|
|
23773
|
+
users: [],
|
|
23774
|
+
});
|
|
23468
23775
|
}
|
|
23469
23776
|
// to support hard deletion
|
|
23470
23777
|
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
23471
|
-
fireEvent('post.deleted', {
|
|
23778
|
+
fireEvent('post.deleted', {
|
|
23779
|
+
posts: [deleted],
|
|
23780
|
+
categories: [],
|
|
23781
|
+
comments: [],
|
|
23782
|
+
communities: [],
|
|
23783
|
+
communityUsers: [],
|
|
23784
|
+
feeds: [],
|
|
23785
|
+
files: [],
|
|
23786
|
+
postChildren: [],
|
|
23787
|
+
users: [],
|
|
23788
|
+
});
|
|
23472
23789
|
if (permanent) {
|
|
23473
23790
|
setTimeout(() => {
|
|
23474
23791
|
pushToTombstone('post', postId);
|
|
@@ -23478,8 +23795,12 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
23478
23795
|
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
23479
23796
|
}
|
|
23480
23797
|
return deleted;
|
|
23481
|
-
};
|
|
23798
|
+
};
|
|
23799
|
+
/* end_public_function */
|
|
23482
23800
|
|
|
23801
|
+
/* begin_public_function
|
|
23802
|
+
id: post.approve
|
|
23803
|
+
*/
|
|
23483
23804
|
/**
|
|
23484
23805
|
* ```js
|
|
23485
23806
|
* import { approvePost } from '@amityco/ts-sdk'
|
|
@@ -23496,26 +23817,28 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
23496
23817
|
* @async
|
|
23497
23818
|
*/
|
|
23498
23819
|
const approvePost = async (postId) => {
|
|
23499
|
-
var _a;
|
|
23500
23820
|
const client = getActiveClient();
|
|
23501
23821
|
client.log('post/approvePost', postId);
|
|
23502
|
-
const { data:
|
|
23503
|
-
|
|
23504
|
-
if (client.cache)
|
|
23505
|
-
ingestInCache(approved, { cachedAt });
|
|
23822
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
23823
|
+
fireEvent('post.approved', payload);
|
|
23506
23824
|
// fire virtual event for community update
|
|
23507
|
-
if (
|
|
23508
|
-
|
|
23509
|
-
// @ts-ignore as communities is optional currently in PostPayload
|
|
23510
|
-
fireEvent('community.updated', { communities: [community] });
|
|
23825
|
+
if (payload.posts[0].targetType === 'community') {
|
|
23826
|
+
fireEvent('community.updated', payload);
|
|
23511
23827
|
}
|
|
23512
|
-
|
|
23828
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23829
|
+
const cachedAt = client.cache && Date.now();
|
|
23830
|
+
if (client.cache)
|
|
23831
|
+
ingestInCache(data, { cachedAt });
|
|
23513
23832
|
return {
|
|
23514
|
-
data:
|
|
23833
|
+
data: data.posts.find(post => post.postId === postId),
|
|
23515
23834
|
cachedAt,
|
|
23516
23835
|
};
|
|
23517
|
-
};
|
|
23836
|
+
};
|
|
23837
|
+
/* end_public_function */
|
|
23518
23838
|
|
|
23839
|
+
/* begin_public_function
|
|
23840
|
+
id: post.decline
|
|
23841
|
+
*/
|
|
23519
23842
|
/**
|
|
23520
23843
|
* ```js
|
|
23521
23844
|
* import { declinePost } from '@amityco/ts-sdk'
|
|
@@ -23532,26 +23855,28 @@ const approvePost = async (postId) => {
|
|
|
23532
23855
|
* @async
|
|
23533
23856
|
*/
|
|
23534
23857
|
const declinePost = async (postId) => {
|
|
23535
|
-
var _a;
|
|
23536
23858
|
const client = getActiveClient();
|
|
23537
23859
|
client.log('post/declinePost', postId);
|
|
23538
|
-
const { data:
|
|
23539
|
-
const cachedAt = client.cache && Date.now();
|
|
23540
|
-
if (client.cache)
|
|
23541
|
-
ingestInCache(declined, { cachedAt });
|
|
23860
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
23542
23861
|
// fire virtual event
|
|
23543
|
-
if (
|
|
23544
|
-
|
|
23545
|
-
// @ts-ignore as communities is optional currently in PostPayload
|
|
23546
|
-
fireEvent('community.updated', { communities: [community] });
|
|
23862
|
+
if (payload.posts[0].targetType === 'community') {
|
|
23863
|
+
fireEvent('community.updated', payload);
|
|
23547
23864
|
}
|
|
23548
|
-
fireEvent('post.declined',
|
|
23865
|
+
fireEvent('post.declined', payload);
|
|
23866
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23867
|
+
const cachedAt = client.cache && Date.now();
|
|
23868
|
+
if (client.cache)
|
|
23869
|
+
ingestInCache(data, { cachedAt });
|
|
23549
23870
|
return {
|
|
23550
|
-
data:
|
|
23871
|
+
data: payload.posts.find(post => post.postId === postId),
|
|
23551
23872
|
cachedAt,
|
|
23552
23873
|
};
|
|
23553
|
-
};
|
|
23874
|
+
};
|
|
23875
|
+
/* end_public_function */
|
|
23554
23876
|
|
|
23877
|
+
/* begin_public_function
|
|
23878
|
+
id: comment.query
|
|
23879
|
+
*/
|
|
23555
23880
|
/**
|
|
23556
23881
|
* ```js
|
|
23557
23882
|
* import { queryComments } from '@amityco/ts-sdk'
|
|
@@ -23601,6 +23926,7 @@ const queryComments = async (query) => {
|
|
|
23601
23926
|
const prevPage = toPage(paging.previous);
|
|
23602
23927
|
return { data: comments, cachedAt, prevPage, nextPage };
|
|
23603
23928
|
};
|
|
23929
|
+
/* end_public_function */
|
|
23604
23930
|
/**
|
|
23605
23931
|
* ```js
|
|
23606
23932
|
* import { queryComments } from '@amityco/ts-sdk'
|
|
@@ -23636,6 +23962,9 @@ queryComments.locally = (query) => {
|
|
|
23636
23962
|
: undefined;
|
|
23637
23963
|
};
|
|
23638
23964
|
|
|
23965
|
+
/* begin_public_function
|
|
23966
|
+
id: comment.get_by_ids
|
|
23967
|
+
*/
|
|
23639
23968
|
/**
|
|
23640
23969
|
* ```js
|
|
23641
23970
|
* import { getComments } from '@amityco/ts-sdk'
|
|
@@ -23666,6 +23995,7 @@ const getComments = async (commentIds) => {
|
|
|
23666
23995
|
cachedAt,
|
|
23667
23996
|
};
|
|
23668
23997
|
};
|
|
23998
|
+
/* end_public_function */
|
|
23669
23999
|
/**
|
|
23670
24000
|
* ```js
|
|
23671
24001
|
* import { getComments } from '@amityco/ts-sdk'
|
|
@@ -23698,6 +24028,9 @@ getComments.locally = (commentIds) => {
|
|
|
23698
24028
|
};
|
|
23699
24029
|
};
|
|
23700
24030
|
|
|
24031
|
+
/* begin_public_function
|
|
24032
|
+
id: comment.get
|
|
24033
|
+
*/
|
|
23701
24034
|
/**
|
|
23702
24035
|
* ```js
|
|
23703
24036
|
* import { getComment } from '@amityco/ts-sdk'
|
|
@@ -23737,6 +24070,7 @@ const getComment = async (commentId) => {
|
|
|
23737
24070
|
cachedAt,
|
|
23738
24071
|
};
|
|
23739
24072
|
};
|
|
24073
|
+
/* end_public_function */
|
|
23740
24074
|
/**
|
|
23741
24075
|
* ```js
|
|
23742
24076
|
* import { getComment } from '@amityco/ts-sdk'
|
|
@@ -23764,6 +24098,9 @@ getComment.locally = (commentId) => {
|
|
|
23764
24098
|
};
|
|
23765
24099
|
};
|
|
23766
24100
|
|
|
24101
|
+
/* begin_public_function
|
|
24102
|
+
id: comment.create
|
|
24103
|
+
*/
|
|
23767
24104
|
/**
|
|
23768
24105
|
* ```js
|
|
23769
24106
|
* import { createComment } from '@amityco/ts-sdk'
|
|
@@ -23786,15 +24123,29 @@ const createComment = async (bundle) => {
|
|
|
23786
24123
|
if (client.cache)
|
|
23787
24124
|
ingestInCache(data, { cachedAt });
|
|
23788
24125
|
const post = await getPost(bundle.referenceId);
|
|
23789
|
-
fireEvent('post.updated', {
|
|
24126
|
+
fireEvent('post.updated', {
|
|
24127
|
+
posts: [post.data],
|
|
24128
|
+
categories: [],
|
|
24129
|
+
comments: [],
|
|
24130
|
+
communities: [],
|
|
24131
|
+
communityUsers: [],
|
|
24132
|
+
feeds: [],
|
|
24133
|
+
files: [],
|
|
24134
|
+
postChildren: [],
|
|
24135
|
+
users: [],
|
|
24136
|
+
});
|
|
23790
24137
|
fireEvent('comment.created', data);
|
|
23791
24138
|
const { comments } = data;
|
|
23792
24139
|
return {
|
|
23793
24140
|
data: comments[0],
|
|
23794
24141
|
cachedAt,
|
|
23795
24142
|
};
|
|
23796
|
-
};
|
|
24143
|
+
};
|
|
24144
|
+
/* end_public_function */
|
|
23797
24145
|
|
|
24146
|
+
/* begin_public_function
|
|
24147
|
+
id: comment.update_comment
|
|
24148
|
+
*/
|
|
23798
24149
|
/**
|
|
23799
24150
|
* ```js
|
|
23800
24151
|
* import { updateComment } from '@amityco/ts-sdk'
|
|
@@ -23825,8 +24176,12 @@ const updateComment = async (commentId, patch) => {
|
|
|
23825
24176
|
data: comments.find(comment => comment.commentId === commentId),
|
|
23826
24177
|
cachedAt,
|
|
23827
24178
|
};
|
|
23828
|
-
};
|
|
24179
|
+
};
|
|
24180
|
+
/* end_public_function */
|
|
23829
24181
|
|
|
24182
|
+
/* begin_public_function
|
|
24183
|
+
id: comment.soft_delete, comment.hard_delete
|
|
24184
|
+
*/
|
|
23830
24185
|
/**
|
|
23831
24186
|
* ```js
|
|
23832
24187
|
* import { deleteComment } from '@amityco/ts-sdk'
|
|
@@ -23855,8 +24210,23 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
23855
24210
|
// to support hard deletion
|
|
23856
24211
|
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
23857
24212
|
const post = await getPost(comment.data.referenceId);
|
|
23858
|
-
fireEvent('post.updated', {
|
|
23859
|
-
|
|
24213
|
+
fireEvent('post.updated', {
|
|
24214
|
+
posts: [post.data],
|
|
24215
|
+
categories: [],
|
|
24216
|
+
comments: [],
|
|
24217
|
+
communities: [],
|
|
24218
|
+
communityUsers: [],
|
|
24219
|
+
feeds: [],
|
|
24220
|
+
files: [],
|
|
24221
|
+
postChildren: [],
|
|
24222
|
+
users: [],
|
|
24223
|
+
});
|
|
24224
|
+
fireEvent('comment.deleted', {
|
|
24225
|
+
comments: [deleted],
|
|
24226
|
+
commentChildren: [],
|
|
24227
|
+
files: [],
|
|
24228
|
+
users: [],
|
|
24229
|
+
});
|
|
23860
24230
|
if (permanent) {
|
|
23861
24231
|
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
23862
24232
|
}
|
|
@@ -23864,7 +24234,8 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
23864
24234
|
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
23865
24235
|
}
|
|
23866
24236
|
return deleted;
|
|
23867
|
-
};
|
|
24237
|
+
};
|
|
24238
|
+
/* end_public_function */
|
|
23868
24239
|
|
|
23869
24240
|
/** @hidden */
|
|
23870
24241
|
const preparePayloadForCache = (event, payload) => {
|
|
@@ -23904,6 +24275,9 @@ const preparePayloadForCache = (event, payload) => {
|
|
|
23904
24275
|
}
|
|
23905
24276
|
};
|
|
23906
24277
|
|
|
24278
|
+
/* begin_public_function
|
|
24279
|
+
id: reaction.add
|
|
24280
|
+
*/
|
|
23907
24281
|
/**
|
|
23908
24282
|
* ```js
|
|
23909
24283
|
* import { addReaction } from '@amityco/ts-sdk'
|
|
@@ -23944,6 +24318,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
23944
24318
|
}
|
|
23945
24319
|
return true;
|
|
23946
24320
|
};
|
|
24321
|
+
/* end_public_function */
|
|
23947
24322
|
/**
|
|
23948
24323
|
* ```js
|
|
23949
24324
|
* import { addReaction } from '@amityco/ts-sdk'
|
|
@@ -23984,6 +24359,9 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
23984
24359
|
return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
|
|
23985
24360
|
};
|
|
23986
24361
|
|
|
24362
|
+
/* begin_public_function
|
|
24363
|
+
id: reaction.remove
|
|
24364
|
+
*/
|
|
23987
24365
|
/**
|
|
23988
24366
|
* ```js
|
|
23989
24367
|
* import { deleteReaction } from '@amityco/ts-sdk'
|
|
@@ -24026,6 +24404,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
24026
24404
|
}
|
|
24027
24405
|
return true;
|
|
24028
24406
|
};
|
|
24407
|
+
/* end_public_function */
|
|
24029
24408
|
/**
|
|
24030
24409
|
* ```js
|
|
24031
24410
|
* import { removeReaction } from '@amityco/ts-sdk'
|
|
@@ -24066,6 +24445,9 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
24066
24445
|
return (_e = !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName))) !== null && _e !== void 0 ? _e : false;
|
|
24067
24446
|
};
|
|
24068
24447
|
|
|
24448
|
+
/* begin_public_function
|
|
24449
|
+
id: reaction.query
|
|
24450
|
+
*/
|
|
24069
24451
|
/**
|
|
24070
24452
|
* ```js
|
|
24071
24453
|
* import { queryReactions } from '@amityco/ts-sdk'
|
|
@@ -24094,11 +24476,14 @@ const queryReactions = async (query) => {
|
|
|
24094
24476
|
});
|
|
24095
24477
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
24096
24478
|
const { reactions } = payload;
|
|
24479
|
+
// FIXME: correct reactions type in model
|
|
24480
|
+
// @ts-ignore
|
|
24097
24481
|
ingestInCache(Object.assign(Object.assign({}, payload), { reactions: reactions[0].reactors }));
|
|
24098
24482
|
const nextPage = toPageRaw(paging.next);
|
|
24099
24483
|
const prevPage = toPageRaw(paging.previous);
|
|
24100
24484
|
return { data: reactions, prevPage, nextPage };
|
|
24101
|
-
};
|
|
24485
|
+
};
|
|
24486
|
+
/* end_public_function */
|
|
24102
24487
|
|
|
24103
24488
|
const createPostEventSubscriber = (event, callback) => {
|
|
24104
24489
|
const client = getActiveClient();
|
|
@@ -24109,9 +24494,17 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
24109
24494
|
}
|
|
24110
24495
|
else {
|
|
24111
24496
|
const { communities } = payload, others = __rest(payload, ["communities"]);
|
|
24112
|
-
|
|
24497
|
+
const data = prepareMembershipPayload(others, 'communityUsers');
|
|
24498
|
+
ingestInCache(data);
|
|
24113
24499
|
if ((communities === null || communities === void 0 ? void 0 : communities[0]) && !['post.updated'].includes(event)) {
|
|
24114
|
-
fireEvent('community.updated', {
|
|
24500
|
+
fireEvent('community.updated', {
|
|
24501
|
+
communities,
|
|
24502
|
+
categories: [],
|
|
24503
|
+
communityUsers: [],
|
|
24504
|
+
feeds: [],
|
|
24505
|
+
files: [],
|
|
24506
|
+
users: [],
|
|
24507
|
+
});
|
|
24115
24508
|
}
|
|
24116
24509
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
24117
24510
|
if (['post.created', 'post.approved', 'post.declined'].includes(event)) {
|
|
@@ -24628,6 +25021,8 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
24628
25021
|
if (eventName !== 'add')
|
|
24629
25022
|
return;
|
|
24630
25023
|
ingestInCache(payload);
|
|
25024
|
+
// FIXME: correct reactions type in model
|
|
25025
|
+
// @ts-ignore
|
|
24631
25026
|
ingestInCache({ reactions: [reactor] });
|
|
24632
25027
|
callbackWrapper('message', payload.messages[0].messageId, reactor);
|
|
24633
25028
|
};
|
|
@@ -24637,6 +25032,8 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
24637
25032
|
const filter = (payload) => {
|
|
24638
25033
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
24639
25034
|
ingestInCache(rest);
|
|
25035
|
+
// FIXME: correct reactions type in model
|
|
25036
|
+
// @ts-ignore
|
|
24640
25037
|
ingestInCache({ reactions: [reactor] });
|
|
24641
25038
|
callbackWrapper('post', payload.posts[0].postId, reactor);
|
|
24642
25039
|
};
|
|
@@ -24645,6 +25042,8 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
24645
25042
|
const filter = (payload) => {
|
|
24646
25043
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
24647
25044
|
ingestInCache(rest);
|
|
25045
|
+
// FIXME: correct reactions type in model
|
|
25046
|
+
// @ts-ignore
|
|
24648
25047
|
ingestInCache({ reactions: [reactor] });
|
|
24649
25048
|
callbackWrapper('comment', payload.comments[0].commentId, reactor);
|
|
24650
25049
|
};
|
|
@@ -24684,6 +25083,8 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
24684
25083
|
if (eventName !== 'remove')
|
|
24685
25084
|
return;
|
|
24686
25085
|
ingestInCache(payload);
|
|
25086
|
+
// FIXME: correct reactions type in model
|
|
25087
|
+
// @ts-ignore
|
|
24687
25088
|
ingestInCache({ reactions: [reactor] });
|
|
24688
25089
|
callbackWrapper('message', payload.messages[0].messageId, reactor);
|
|
24689
25090
|
};
|
|
@@ -24693,6 +25094,8 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
24693
25094
|
const filter = (payload) => {
|
|
24694
25095
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
24695
25096
|
ingestInCache(rest);
|
|
25097
|
+
// FIXME: correct reactions type in model
|
|
25098
|
+
// @ts-ignore
|
|
24696
25099
|
ingestInCache({ reactions: [reactor] });
|
|
24697
25100
|
callbackWrapper('post', payload.posts[0].postId, reactor);
|
|
24698
25101
|
};
|
|
@@ -24701,6 +25104,8 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
24701
25104
|
const filter = (payload) => {
|
|
24702
25105
|
const { reactor } = payload, rest = __rest(payload, ["reactor"]);
|
|
24703
25106
|
ingestInCache(rest);
|
|
25107
|
+
// FIXME: correct reactions type in model
|
|
25108
|
+
// @ts-ignore
|
|
24704
25109
|
ingestInCache({ reactions: [reactor] });
|
|
24705
25110
|
callbackWrapper('comment', payload.comments[0].commentId, reactor);
|
|
24706
25111
|
};
|
|
@@ -24825,6 +25230,9 @@ var REFERENCE_TYPES = {
|
|
|
24825
25230
|
},
|
|
24826
25231
|
};
|
|
24827
25232
|
|
|
25233
|
+
/* begin_public_function
|
|
25234
|
+
id: user.flag, message.flag, post.flag, comment.flag
|
|
25235
|
+
*/
|
|
24828
25236
|
/**
|
|
24829
25237
|
* ```js
|
|
24830
25238
|
* import { createReport } from '@amityco/ts-sdk'
|
|
@@ -24851,19 +25259,26 @@ const createReport = async (referenceType, referenceId) => {
|
|
|
24851
25259
|
const { domainName } = REFERENCE_TYPES[referenceType];
|
|
24852
25260
|
return `/api/v3/${domainName}/${encodeURIComponent(referenceId)}/flag`;
|
|
24853
25261
|
};
|
|
24854
|
-
const { data } = await client.http.post(getAPIUrl());
|
|
24855
|
-
if (client.cache)
|
|
24856
|
-
|
|
24857
|
-
|
|
24858
|
-
|
|
24859
|
-
|
|
24860
|
-
|
|
24861
|
-
|
|
24862
|
-
|
|
25262
|
+
const { data: payload } = await client.http.post(getAPIUrl());
|
|
25263
|
+
if (client.cache) {
|
|
25264
|
+
if (referenceType === 'message') {
|
|
25265
|
+
ingestInCache(prepareMessagePayload(payload));
|
|
25266
|
+
}
|
|
25267
|
+
else if (referenceType === 'post') {
|
|
25268
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
25269
|
+
}
|
|
25270
|
+
else {
|
|
25271
|
+
ingestInCache(payload);
|
|
25272
|
+
}
|
|
24863
25273
|
}
|
|
24864
|
-
|
|
24865
|
-
|
|
25274
|
+
fireEvent(`${referenceType}.flagged`, payload);
|
|
25275
|
+
return !!payload;
|
|
25276
|
+
};
|
|
25277
|
+
/* end_public_function */
|
|
24866
25278
|
|
|
25279
|
+
/* begin_public_function
|
|
25280
|
+
id: user.unflag, message.unflag, post.unflag, comment.unflag
|
|
25281
|
+
*/
|
|
24867
25282
|
/**
|
|
24868
25283
|
* ```js
|
|
24869
25284
|
* import { deleteReport } from '@amityco/ts-sdk'
|
|
@@ -24890,19 +25305,27 @@ const deleteReport = async (referenceType, referenceId) => {
|
|
|
24890
25305
|
const { domainName } = REFERENCE_TYPES[referenceType];
|
|
24891
25306
|
return `/api/v3/${domainName}/${encodeURIComponent(referenceId)}/unflag`;
|
|
24892
25307
|
};
|
|
24893
|
-
const { data } = await client.http.delete(getAPIUrl());
|
|
24894
|
-
if (client.cache)
|
|
24895
|
-
|
|
24896
|
-
|
|
24897
|
-
|
|
24898
|
-
|
|
24899
|
-
|
|
24900
|
-
|
|
24901
|
-
|
|
25308
|
+
const { data: payload } = await client.http.delete(getAPIUrl());
|
|
25309
|
+
if (client.cache) {
|
|
25310
|
+
if (referenceType === 'message') {
|
|
25311
|
+
ingestInCache(prepareMessagePayload(payload));
|
|
25312
|
+
}
|
|
25313
|
+
else if (referenceType === 'post') {
|
|
25314
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
25315
|
+
}
|
|
25316
|
+
else {
|
|
25317
|
+
ingestInCache(payload);
|
|
25318
|
+
}
|
|
24902
25319
|
}
|
|
24903
|
-
|
|
24904
|
-
};
|
|
25320
|
+
// @ts-ignore
|
|
25321
|
+
fireEvent(`${referenceType}.unflagged`, payload);
|
|
25322
|
+
return !!payload;
|
|
25323
|
+
};
|
|
25324
|
+
/* end_public_function */
|
|
24905
25325
|
|
|
25326
|
+
/* begin_public_function
|
|
25327
|
+
id: user.check_flag_by_me, message.check_flag_by_me, post.check_flag_by_me, comment.check_flag_by_me
|
|
25328
|
+
*/
|
|
24906
25329
|
/**
|
|
24907
25330
|
* ```js
|
|
24908
25331
|
* import { isReportedByMe } from '@amityco/ts-sdk'
|
|
@@ -24929,7 +25352,8 @@ const isReportedByMe = async (referenceType, referenceId) => {
|
|
|
24929
25352
|
[primaryKey]: referenceId,
|
|
24930
25353
|
}))) !== null && _a !== void 0 ? _a : {};
|
|
24931
25354
|
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
24932
|
-
};
|
|
25355
|
+
};
|
|
25356
|
+
/* end_public_function */
|
|
24933
25357
|
|
|
24934
25358
|
function convertFromRaw$1(_a, params) {
|
|
24935
25359
|
var { _id } = _a, rest = __rest(_a, ["_id"]);
|
|
@@ -24958,11 +25382,15 @@ function getSegmentParams(rawChannel) {
|
|
|
24958
25382
|
localLastMentionSegment: 0,
|
|
24959
25383
|
};
|
|
24960
25384
|
}
|
|
24961
|
-
const prepareChannelPayload = (
|
|
24962
|
-
const channels =
|
|
24963
|
-
|
|
25385
|
+
const prepareChannelPayload = (rawPayload) => {
|
|
25386
|
+
const channels = rawPayload.channels.map(channel => convertFromRaw$1(channel, getSegmentParams(channel)));
|
|
25387
|
+
const channelUsers = withUsers(rawPayload.channelUsers);
|
|
25388
|
+
return Object.assign(Object.assign({}, rawPayload), { channels, channelUsers });
|
|
24964
25389
|
};
|
|
24965
25390
|
|
|
25391
|
+
/* begin_public_function
|
|
25392
|
+
id: channel.query
|
|
25393
|
+
*/
|
|
24966
25394
|
/**
|
|
24967
25395
|
* ```js
|
|
24968
25396
|
* import { queryChannels } from '@amityco/ts-sdk'
|
|
@@ -25008,6 +25436,7 @@ const queryChannels = async (query) => {
|
|
|
25008
25436
|
const prevPage = toPage(paging.previous);
|
|
25009
25437
|
return { data: channels, cachedAt, prevPage, nextPage };
|
|
25010
25438
|
};
|
|
25439
|
+
/* end_public_function */
|
|
25011
25440
|
/**
|
|
25012
25441
|
* ```js
|
|
25013
25442
|
* import { queryChannels } from '@amityco/ts-sdk'
|
|
@@ -25105,6 +25534,9 @@ getChannels.locally = (channelIds) => {
|
|
|
25105
25534
|
};
|
|
25106
25535
|
};
|
|
25107
25536
|
|
|
25537
|
+
/* begin_public_function
|
|
25538
|
+
id: channel.get
|
|
25539
|
+
*/
|
|
25108
25540
|
/**
|
|
25109
25541
|
* ```js
|
|
25110
25542
|
* import { getChannel } from '@amityco/ts-sdk'
|
|
@@ -25143,6 +25575,7 @@ const getChannel = async (channelId) => {
|
|
|
25143
25575
|
cachedAt,
|
|
25144
25576
|
};
|
|
25145
25577
|
};
|
|
25578
|
+
/* end_public_function */
|
|
25146
25579
|
/**
|
|
25147
25580
|
* ```js
|
|
25148
25581
|
* import { getChannel } from '@amityco/ts-sdk'
|
|
@@ -25170,6 +25603,9 @@ getChannel.locally = (channelId) => {
|
|
|
25170
25603
|
};
|
|
25171
25604
|
};
|
|
25172
25605
|
|
|
25606
|
+
/* begin_public_function
|
|
25607
|
+
id: channel.create
|
|
25608
|
+
*/
|
|
25173
25609
|
/**
|
|
25174
25610
|
* ```js
|
|
25175
25611
|
* import { createChannel } from '@amityco/ts-sdk'
|
|
@@ -25203,8 +25639,12 @@ const createChannel = async (bundle) => {
|
|
|
25203
25639
|
data: channels[0],
|
|
25204
25640
|
cachedAt,
|
|
25205
25641
|
};
|
|
25206
|
-
};
|
|
25642
|
+
};
|
|
25643
|
+
/* end_public_function */
|
|
25207
25644
|
|
|
25645
|
+
/* begin_public_function
|
|
25646
|
+
id: channel.update
|
|
25647
|
+
*/
|
|
25208
25648
|
/**
|
|
25209
25649
|
* ```js
|
|
25210
25650
|
* import { updateChannel } from '@amityco/ts-sdk'
|
|
@@ -25233,7 +25673,8 @@ const updateChannel = async (channelId, patch) => {
|
|
|
25233
25673
|
data: channels.find(channel => channel.channelId === channelId),
|
|
25234
25674
|
cachedAt,
|
|
25235
25675
|
};
|
|
25236
|
-
};
|
|
25676
|
+
};
|
|
25677
|
+
/* end_public_function */
|
|
25237
25678
|
|
|
25238
25679
|
/**
|
|
25239
25680
|
* ```js
|
|
@@ -25258,6 +25699,9 @@ const deleteChannel = async (channelId) => {
|
|
|
25258
25699
|
return deleted.data;
|
|
25259
25700
|
};
|
|
25260
25701
|
|
|
25702
|
+
/* begin_public_function
|
|
25703
|
+
id: channel.join
|
|
25704
|
+
*/
|
|
25261
25705
|
/**
|
|
25262
25706
|
* ```js
|
|
25263
25707
|
* import { joinChannel } from '@amityco/ts-sdk'
|
|
@@ -25281,8 +25725,12 @@ const joinChannel = async (channelId) => {
|
|
|
25281
25725
|
ingestInCache(data);
|
|
25282
25726
|
const { channelUsers } = data;
|
|
25283
25727
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
|
|
25284
|
-
};
|
|
25728
|
+
};
|
|
25729
|
+
/* end_public_function */
|
|
25285
25730
|
|
|
25731
|
+
/* begin_public_function
|
|
25732
|
+
id: channel.leave
|
|
25733
|
+
*/
|
|
25286
25734
|
/**
|
|
25287
25735
|
* ```js
|
|
25288
25736
|
* import { leaveChannel } from '@amityco/ts-sdk'
|
|
@@ -25306,8 +25754,12 @@ const leaveChannel = async (channelId) => {
|
|
|
25306
25754
|
ingestInCache(data);
|
|
25307
25755
|
const { channelUsers } = data;
|
|
25308
25756
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership !== 'member');
|
|
25309
|
-
};
|
|
25757
|
+
};
|
|
25758
|
+
/* end_public_function */
|
|
25310
25759
|
|
|
25760
|
+
/* begin_public_function
|
|
25761
|
+
id: channel.member.query, channel.member.search
|
|
25762
|
+
*/
|
|
25311
25763
|
/**
|
|
25312
25764
|
* ```js
|
|
25313
25765
|
* import { queryChannelMembers } from '@amityco/ts-sdk'
|
|
@@ -25332,8 +25784,7 @@ const queryChannelMembers = async (query) => {
|
|
|
25332
25784
|
} }),
|
|
25333
25785
|
});
|
|
25334
25786
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
25335
|
-
const
|
|
25336
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
25787
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25337
25788
|
const { channelUsers } = preparedPayload;
|
|
25338
25789
|
const cachedAt = client.cache && Date.now();
|
|
25339
25790
|
if (client.cache) {
|
|
@@ -25357,6 +25808,7 @@ const queryChannelMembers = async (query) => {
|
|
|
25357
25808
|
prevPage,
|
|
25358
25809
|
};
|
|
25359
25810
|
};
|
|
25811
|
+
/* end_public_function */
|
|
25360
25812
|
/**
|
|
25361
25813
|
* ```js
|
|
25362
25814
|
* import { queryChannelMembers } from '@amityco/ts-sdk'
|
|
@@ -25397,6 +25849,9 @@ queryChannelMembers.locally = (query) => {
|
|
|
25397
25849
|
: undefined;
|
|
25398
25850
|
};
|
|
25399
25851
|
|
|
25852
|
+
/* begin_public_function
|
|
25853
|
+
id: channel.member.add
|
|
25854
|
+
*/
|
|
25400
25855
|
/**
|
|
25401
25856
|
* ```js
|
|
25402
25857
|
* import { addChannelMembers } from '@amityco/ts-sdk'
|
|
@@ -25416,17 +25871,21 @@ const addChannelMembers = async (channelId, userIds) => {
|
|
|
25416
25871
|
const client = getActiveClient();
|
|
25417
25872
|
client.log('channel/addChannelMembers', channelId, userIds);
|
|
25418
25873
|
const { data: payload } = await client.http.post(`/api/v3/channels/${encodeURIComponent(channelId)}/users`, { channelId, userIds });
|
|
25419
|
-
const data = prepareChannelPayload(payload);
|
|
25420
|
-
if (client.cache)
|
|
25421
|
-
ingestInCache(data);
|
|
25422
25874
|
/*
|
|
25423
25875
|
* should fire event for each user that was added
|
|
25424
25876
|
*/
|
|
25425
|
-
userIds.forEach(id => fireEvent('channel.membersAdded', Object.assign(Object.assign({}, payload), { channelUsers:
|
|
25877
|
+
userIds.forEach(id => fireEvent('channel.membersAdded', Object.assign(Object.assign({}, payload), { channelUsers: payload.channelUsers.filter(u => u.userId === id) })));
|
|
25878
|
+
const data = prepareChannelPayload(payload);
|
|
25879
|
+
if (client.cache)
|
|
25880
|
+
ingestInCache(data);
|
|
25426
25881
|
const { channelUsers } = data;
|
|
25427
25882
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
|
|
25428
|
-
};
|
|
25883
|
+
};
|
|
25884
|
+
/* end_public_function */
|
|
25429
25885
|
|
|
25886
|
+
/* begin_public_function
|
|
25887
|
+
id: channel.member.remove
|
|
25888
|
+
*/
|
|
25430
25889
|
/**
|
|
25431
25890
|
* ```js
|
|
25432
25891
|
* import { removeChannelMembers } from '@amityco/ts-sdk'
|
|
@@ -25446,17 +25905,21 @@ const removeChannelMembers = async (channelId, userIds) => {
|
|
|
25446
25905
|
const client = getActiveClient();
|
|
25447
25906
|
client.log('channel/removeChannelMembers', channelId, userIds);
|
|
25448
25907
|
const { data: payload } = await client.http.delete(`/api/v3/channels/${encodeURIComponent(channelId)}/users`, { data: { channelId, userIds } });
|
|
25449
|
-
const data = prepareChannelPayload(payload);
|
|
25450
|
-
if (client.cache)
|
|
25451
|
-
ingestInCache(data);
|
|
25452
25908
|
/*
|
|
25453
25909
|
* should fire event for each user that was removed
|
|
25454
25910
|
*/
|
|
25455
|
-
userIds.forEach(id => fireEvent('channel.membersRemoved', Object.assign(Object.assign({}, payload), { channelUsers:
|
|
25911
|
+
userIds.forEach(id => fireEvent('channel.membersRemoved', Object.assign(Object.assign({}, payload), { channelUsers: payload.channelUsers.filter(u => u.userId === id) })));
|
|
25912
|
+
const data = prepareChannelPayload(payload);
|
|
25913
|
+
if (client.cache)
|
|
25914
|
+
ingestInCache(data);
|
|
25456
25915
|
const { channelUsers } = data;
|
|
25457
25916
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership !== 'member');
|
|
25458
|
-
};
|
|
25917
|
+
};
|
|
25918
|
+
/* end_public_function */
|
|
25459
25919
|
|
|
25920
|
+
/* begin_public_function
|
|
25921
|
+
id: channel.moderation.add_roles
|
|
25922
|
+
*/
|
|
25460
25923
|
/**
|
|
25461
25924
|
* ```js
|
|
25462
25925
|
* import { addChannelMembersRole } from '@amityco/ts-sdk'
|
|
@@ -25482,8 +25945,12 @@ const addChannelMembersRole = async (channelId, roleId, userIds) => {
|
|
|
25482
25945
|
ingestInCache(data);
|
|
25483
25946
|
const { channelUsers } = data;
|
|
25484
25947
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.roles.includes(roleId));
|
|
25485
|
-
};
|
|
25948
|
+
};
|
|
25949
|
+
/* end_public_function */
|
|
25486
25950
|
|
|
25951
|
+
/* begin_public_function
|
|
25952
|
+
id: channel.moderation.remove_roles
|
|
25953
|
+
*/
|
|
25487
25954
|
/**
|
|
25488
25955
|
* ```js
|
|
25489
25956
|
* import { removeChannelMembersRole } from '@amityco/ts-sdk'
|
|
@@ -25494,7 +25961,7 @@ const addChannelMembersRole = async (channelId, roleId, userIds) => {
|
|
|
25494
25961
|
*
|
|
25495
25962
|
* @param channelId The ID of the {@link Amity.Channel} to perform
|
|
25496
25963
|
* @param roleId The ID of the {@link Amity.Role} to apply
|
|
25497
|
-
* @param
|
|
25964
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
25498
25965
|
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Channel}
|
|
25499
25966
|
*
|
|
25500
25967
|
* @category Channel API
|
|
@@ -25509,8 +25976,12 @@ const removeChannelMembersRole = async (channelId, roleId, userIds) => {
|
|
|
25509
25976
|
ingestInCache(data);
|
|
25510
25977
|
const { channelUsers } = data;
|
|
25511
25978
|
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && !channelUser.roles.includes(roleId));
|
|
25512
|
-
};
|
|
25979
|
+
};
|
|
25980
|
+
/* end_public_function */
|
|
25513
25981
|
|
|
25982
|
+
/* begin_public_function
|
|
25983
|
+
id: channel.moderation.ban_members
|
|
25984
|
+
*/
|
|
25514
25985
|
/**
|
|
25515
25986
|
* ```js
|
|
25516
25987
|
* import { banChannelMembers } from '@amityco/ts-sdk'
|
|
@@ -25531,8 +26002,7 @@ const banChannelMembers = async (channelId, userIds) => {
|
|
|
25531
26002
|
const { data: payload } = await client.http.put(`/api/v3/channels/${channelId}/users/ban`, {
|
|
25532
26003
|
userIds,
|
|
25533
26004
|
});
|
|
25534
|
-
const
|
|
25535
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26005
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25536
26006
|
const { channelUsers } = preparedPayload;
|
|
25537
26007
|
const cachedAt = client.cache && Date.now();
|
|
25538
26008
|
if (client.cache)
|
|
@@ -25541,8 +26011,12 @@ const banChannelMembers = async (channelId, userIds) => {
|
|
|
25541
26011
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'banned'),
|
|
25542
26012
|
cachedAt,
|
|
25543
26013
|
};
|
|
25544
|
-
};
|
|
26014
|
+
};
|
|
26015
|
+
/* end_public_function */
|
|
25545
26016
|
|
|
26017
|
+
/* begin_public_function
|
|
26018
|
+
id: channel.moderation.unban_members
|
|
26019
|
+
*/
|
|
25546
26020
|
/**
|
|
25547
26021
|
* ```js
|
|
25548
26022
|
* import { unbanChannelMembers } from '@amityco/ts-sdk'
|
|
@@ -25563,8 +26037,7 @@ const unbanChannelMembers = async (channelId, userIds) => {
|
|
|
25563
26037
|
const { data: payload } = await client.http.put(`/api/v3/channels/${encodeURIComponent(channelId)}/users/unban`, {
|
|
25564
26038
|
userIds,
|
|
25565
26039
|
});
|
|
25566
|
-
const
|
|
25567
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26040
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25568
26041
|
const cachedAt = client.cache && Date.now();
|
|
25569
26042
|
if (client.cache)
|
|
25570
26043
|
ingestInCache(preparedPayload, { cachedAt });
|
|
@@ -25573,8 +26046,12 @@ const unbanChannelMembers = async (channelId, userIds) => {
|
|
|
25573
26046
|
data: channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(user => user.membership === 'member'),
|
|
25574
26047
|
cachedAt,
|
|
25575
26048
|
};
|
|
25576
|
-
};
|
|
26049
|
+
};
|
|
26050
|
+
/* end_public_function */
|
|
25577
26051
|
|
|
26052
|
+
/* begin_public_function
|
|
26053
|
+
id: channel.start_reading
|
|
26054
|
+
*/
|
|
25578
26055
|
/**
|
|
25579
26056
|
* ```js
|
|
25580
26057
|
* import { startReading } from '@amityco/ts-sdk'
|
|
@@ -25583,9 +26060,9 @@ const unbanChannelMembers = async (channelId, userIds) => {
|
|
|
25583
26060
|
*
|
|
25584
26061
|
* Mark all messages as read and start reading message inside channel
|
|
25585
26062
|
*
|
|
25586
|
-
* @param
|
|
25587
|
-
* @param
|
|
25588
|
-
* @return
|
|
26063
|
+
* @param subChannelId - The channel ID to start reading.
|
|
26064
|
+
* @param userId - The user ID of channel member.
|
|
26065
|
+
* @return A success boolean if the channel reading of the sub channel had begun.
|
|
25589
26066
|
*
|
|
25590
26067
|
* @category Message API
|
|
25591
26068
|
* @async
|
|
@@ -25611,8 +26088,12 @@ const startReading = async (subChannelId, userId = getActiveClient().userId) =>
|
|
|
25611
26088
|
channelId,
|
|
25612
26089
|
});
|
|
25613
26090
|
return !!result;
|
|
25614
|
-
};
|
|
26091
|
+
};
|
|
26092
|
+
/* end_public_function */
|
|
25615
26093
|
|
|
26094
|
+
/* begin_public_function
|
|
26095
|
+
id: channel.stop_reading
|
|
26096
|
+
*/
|
|
25616
26097
|
/**
|
|
25617
26098
|
* ```js
|
|
25618
26099
|
* import { stopReading } from '@amityco/ts-sdk'
|
|
@@ -25621,8 +26102,8 @@ const startReading = async (subChannelId, userId = getActiveClient().userId) =>
|
|
|
25621
26102
|
*
|
|
25622
26103
|
* Stop reading message inside channel
|
|
25623
26104
|
*
|
|
25624
|
-
* @param
|
|
25625
|
-
* @return
|
|
26105
|
+
* @param subChannelId - The channel ID to stop reading.
|
|
26106
|
+
* @return A success boolean if the sub channel reading was halted.
|
|
25626
26107
|
*
|
|
25627
26108
|
* @category Message API
|
|
25628
26109
|
* @async
|
|
@@ -25647,7 +26128,8 @@ const stopReading = async (subChannelId) => {
|
|
|
25647
26128
|
channelId,
|
|
25648
26129
|
});
|
|
25649
26130
|
return !!result;
|
|
25650
|
-
};
|
|
26131
|
+
};
|
|
26132
|
+
/* end_public_function */
|
|
25651
26133
|
|
|
25652
26134
|
/**
|
|
25653
26135
|
* ```js
|
|
@@ -25748,8 +26230,7 @@ const onChannelDeleted = (callback) => {
|
|
|
25748
26230
|
const onChannelJoined = (callback) => {
|
|
25749
26231
|
const client = getActiveClient();
|
|
25750
26232
|
const filter = (payload) => {
|
|
25751
|
-
const
|
|
25752
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26233
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25753
26234
|
const { channels, channelUsers } = preparedPayload;
|
|
25754
26235
|
ingestInCache(preparedPayload);
|
|
25755
26236
|
callback(channels[0], channelUsers[0]);
|
|
@@ -25775,8 +26256,7 @@ const onChannelJoined = (callback) => {
|
|
|
25775
26256
|
const onChannelLeft = (callback) => {
|
|
25776
26257
|
const client = getActiveClient();
|
|
25777
26258
|
const filter = (payload) => {
|
|
25778
|
-
const
|
|
25779
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26259
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25780
26260
|
const { channels, channelUsers } = preparedPayload;
|
|
25781
26261
|
ingestInCache(preparedPayload);
|
|
25782
26262
|
callback(channels[0], channelUsers[0]);
|
|
@@ -25827,8 +26307,7 @@ const onChannelMuted = (callback) => {
|
|
|
25827
26307
|
const onChannelMemberAdded = (callback) => {
|
|
25828
26308
|
const client = getActiveClient();
|
|
25829
26309
|
const filter = (payload) => {
|
|
25830
|
-
const
|
|
25831
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26310
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25832
26311
|
const { channels, channelUsers } = preparedPayload;
|
|
25833
26312
|
ingestInCache(preparedPayload);
|
|
25834
26313
|
callback(channels[0], channelUsers.find(cu => cu.membership === 'member'));
|
|
@@ -25854,8 +26333,7 @@ const onChannelMemberAdded = (callback) => {
|
|
|
25854
26333
|
const onChannelMemberRemoved = (callback) => {
|
|
25855
26334
|
const client = getActiveClient();
|
|
25856
26335
|
const filter = (payload) => {
|
|
25857
|
-
const
|
|
25858
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26336
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25859
26337
|
const { channels, channelUsers } = preparedPayload;
|
|
25860
26338
|
ingestInCache(preparedPayload);
|
|
25861
26339
|
callback(channels[0], channelUsers[0]);
|
|
@@ -25881,8 +26359,7 @@ const onChannelMemberRemoved = (callback) => {
|
|
|
25881
26359
|
const onChannelMemberBanned = (callback) => {
|
|
25882
26360
|
const client = getActiveClient();
|
|
25883
26361
|
const filter = (payload) => {
|
|
25884
|
-
const
|
|
25885
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26362
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25886
26363
|
const { channels, channelUsers } = preparedPayload;
|
|
25887
26364
|
ingestInCache(preparedPayload);
|
|
25888
26365
|
callback(channels[0], channelUsers.find(cu => cu.membership === 'banned'));
|
|
@@ -25908,8 +26385,7 @@ const onChannelMemberBanned = (callback) => {
|
|
|
25908
26385
|
const onChannelMemberUnbanned = (callback) => {
|
|
25909
26386
|
const client = getActiveClient();
|
|
25910
26387
|
const filter = (payload) => {
|
|
25911
|
-
const
|
|
25912
|
-
const preparedPayload = prepareMembershipPayload(channelPayload, 'channelUsers');
|
|
26388
|
+
const preparedPayload = prepareChannelPayload(payload);
|
|
25913
26389
|
const { channels, channelUsers } = preparedPayload;
|
|
25914
26390
|
ingestInCache(preparedPayload);
|
|
25915
26391
|
callback(channels[0], channelUsers.find(cu => cu.membership === 'none'));
|
|
@@ -26341,22 +26817,29 @@ const liveChannels = (params, callback, config) => {
|
|
|
26341
26817
|
if (params.membership && userId) {
|
|
26342
26818
|
channels = filterByChannelMembership(channels, params.membership, userId);
|
|
26343
26819
|
}
|
|
26344
|
-
|
|
26345
|
-
|
|
26346
|
-
|
|
26347
|
-
|
|
26348
|
-
|
|
26349
|
-
|
|
26350
|
-
|
|
26351
|
-
|
|
26352
|
-
|
|
26353
|
-
|
|
26354
|
-
|
|
26355
|
-
|
|
26356
|
-
|
|
26357
|
-
|
|
26358
|
-
|
|
26359
|
-
|
|
26820
|
+
switch (params.sortBy) {
|
|
26821
|
+
case 'firstCreated':
|
|
26822
|
+
channels = channels.sort(sortByFirstCreated);
|
|
26823
|
+
break;
|
|
26824
|
+
case 'lastCreated':
|
|
26825
|
+
channels = channels.sort(sortByLastCreated);
|
|
26826
|
+
break;
|
|
26827
|
+
case 'displayName':
|
|
26828
|
+
/*
|
|
26829
|
+
* The server returns channels with empty | null displayName's first before
|
|
26830
|
+
* returning sorted list of channels with displayNames
|
|
26831
|
+
*
|
|
26832
|
+
* This section needs to be updated as displayNames can be null as well
|
|
26833
|
+
*/
|
|
26834
|
+
channels = channels
|
|
26835
|
+
// this needs to be aligned with the backend data type
|
|
26836
|
+
.map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
|
|
26837
|
+
// @ts-ignore
|
|
26838
|
+
.sort(sortByDisplayName);
|
|
26839
|
+
break;
|
|
26840
|
+
default:
|
|
26841
|
+
channels = channels.sort(sortByLastActivity);
|
|
26842
|
+
break;
|
|
26360
26843
|
}
|
|
26361
26844
|
callback({
|
|
26362
26845
|
onNextPage: onFetch,
|
|
@@ -26366,17 +26849,12 @@ const liveChannels = (params, callback, config) => {
|
|
|
26366
26849
|
error: data.error,
|
|
26367
26850
|
});
|
|
26368
26851
|
};
|
|
26369
|
-
const realtimeRouter = (
|
|
26852
|
+
const realtimeRouter = (_) => (channel) => {
|
|
26370
26853
|
var _a;
|
|
26371
26854
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26372
26855
|
if (!collection)
|
|
26373
26856
|
return;
|
|
26374
|
-
|
|
26375
|
-
collection.data = collection.data.filter(c => c !== channel.channelId);
|
|
26376
|
-
}
|
|
26377
|
-
else {
|
|
26378
|
-
collection.data = [...new Set([channel.channelId, ...collection.data])];
|
|
26379
|
-
}
|
|
26857
|
+
collection.data = [...new Set([channel.channelId, ...collection.data])];
|
|
26380
26858
|
pushToCache(cacheKey, collection);
|
|
26381
26859
|
responder(collection);
|
|
26382
26860
|
};
|
|
@@ -26401,7 +26879,7 @@ const liveChannels = (params, callback, config) => {
|
|
|
26401
26879
|
responder(data);
|
|
26402
26880
|
}, queryOptions(policy));
|
|
26403
26881
|
};
|
|
26404
|
-
disposers.push(onChannelCreated(realtimeRouter(
|
|
26882
|
+
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
|
|
26405
26883
|
onFetch();
|
|
26406
26884
|
return () => {
|
|
26407
26885
|
log(`liveChannels(tmpid: ${timestamp}) > dispose`);
|
|
@@ -26543,6 +27021,9 @@ function convertQueryParams(_a) {
|
|
|
26543
27021
|
return out;
|
|
26544
27022
|
}
|
|
26545
27023
|
|
|
27024
|
+
/* begin_public_function
|
|
27025
|
+
id: subchannel.query
|
|
27026
|
+
*/
|
|
26546
27027
|
/**
|
|
26547
27028
|
* ```js
|
|
26548
27029
|
* import { querySubChannels } from '@amityco/ts-sdk'
|
|
@@ -26584,6 +27065,7 @@ const querySubChannels = async (query) => {
|
|
|
26584
27065
|
const prevPage = toPage(paging.previous);
|
|
26585
27066
|
return { data: subChannels, cachedAt, prevPage, nextPage };
|
|
26586
27067
|
};
|
|
27068
|
+
/* end_public_function */
|
|
26587
27069
|
/**
|
|
26588
27070
|
* ```js
|
|
26589
27071
|
* import { querySubChannels } from '@amityco/ts-sdk'
|
|
@@ -26684,6 +27166,9 @@ getSubChannels.locally = (subChannelIds) => {
|
|
|
26684
27166
|
};
|
|
26685
27167
|
};
|
|
26686
27168
|
|
|
27169
|
+
/* begin_public_function
|
|
27170
|
+
id: subchannel.get
|
|
27171
|
+
*/
|
|
26687
27172
|
/**
|
|
26688
27173
|
* ```js
|
|
26689
27174
|
* import { getSubChannel } from '@amityco/ts-sdk'
|
|
@@ -26721,6 +27206,7 @@ const getSubChannel = async (subChannelId) => {
|
|
|
26721
27206
|
throw error;
|
|
26722
27207
|
}
|
|
26723
27208
|
};
|
|
27209
|
+
/* end_public_function */
|
|
26724
27210
|
/**
|
|
26725
27211
|
* ```js
|
|
26726
27212
|
* import { getSubChannel } from '@amityco/ts-sdk'
|
|
@@ -26748,6 +27234,9 @@ getSubChannel.locally = (subChannelId) => {
|
|
|
26748
27234
|
};
|
|
26749
27235
|
};
|
|
26750
27236
|
|
|
27237
|
+
/* begin_public_function
|
|
27238
|
+
id: subchannel.create
|
|
27239
|
+
*/
|
|
26751
27240
|
/**
|
|
26752
27241
|
* ```js
|
|
26753
27242
|
* import { createSubChannel } from '@amityco/ts-sdk'
|
|
@@ -26778,8 +27267,12 @@ const createSubChannel = async (bundle) => {
|
|
|
26778
27267
|
data: data.messageFeeds[0],
|
|
26779
27268
|
cachedAt,
|
|
26780
27269
|
};
|
|
26781
|
-
};
|
|
27270
|
+
};
|
|
27271
|
+
/* end_public_function */
|
|
26782
27272
|
|
|
27273
|
+
/* begin_public_function
|
|
27274
|
+
id: subchannel.update
|
|
27275
|
+
*/
|
|
26783
27276
|
/**
|
|
26784
27277
|
* ```js
|
|
26785
27278
|
* import { updateSubChannel } from '@amityco/ts-sdk'
|
|
@@ -26808,8 +27301,12 @@ const updateSubChannel = async (subChannelId, patch) => {
|
|
|
26808
27301
|
data: data.messageFeeds[0],
|
|
26809
27302
|
cachedAt,
|
|
26810
27303
|
};
|
|
26811
|
-
};
|
|
27304
|
+
};
|
|
27305
|
+
/* end_public_function */
|
|
26812
27306
|
|
|
27307
|
+
/* begin_public_function
|
|
27308
|
+
id: subchannel.soft_delete, subchannel.hard_delete
|
|
27309
|
+
*/
|
|
26813
27310
|
/**
|
|
26814
27311
|
* ```js
|
|
26815
27312
|
* import { deleteSubChannel } from '@amityco/ts-sdk'
|
|
@@ -26840,7 +27337,8 @@ const deleteSubChannel = async (subChannelId, permanent = false) => {
|
|
|
26840
27337
|
}
|
|
26841
27338
|
fireEvent('local.message-feed.deleted', { messageFeeds: [deleted] });
|
|
26842
27339
|
return deleted;
|
|
26843
|
-
};
|
|
27340
|
+
};
|
|
27341
|
+
/* end_public_function */
|
|
26844
27342
|
|
|
26845
27343
|
/**
|
|
26846
27344
|
* ```js
|
|
@@ -27166,7 +27664,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
27166
27664
|
if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
27167
27665
|
return;
|
|
27168
27666
|
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (_e = (_d = collection === null || collection === void 0 ? void 0 : collection.params) === null || _d === void 0 ? void 0 : _d.page) !== null && _e !== void 0 ? _e : { limit } }));
|
|
27169
|
-
runQuery(query, ({ data: result, error, loading,
|
|
27667
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27170
27668
|
const data = {
|
|
27171
27669
|
loading,
|
|
27172
27670
|
error,
|
|
@@ -27276,7 +27774,7 @@ const observeMessages = (subChannelId, callback) => {
|
|
|
27276
27774
|
const createCommunityEventSubscriber = (event, callback) => {
|
|
27277
27775
|
const client = getActiveClient();
|
|
27278
27776
|
const filter = (payload) => {
|
|
27279
|
-
const unpackedPayload =
|
|
27777
|
+
const unpackedPayload = prepareCommunityPayload(payload);
|
|
27280
27778
|
if (!client.cache) {
|
|
27281
27779
|
// TODO: here we are missing specific properties here!
|
|
27282
27780
|
callback(unpackedPayload.communities[0]);
|
|
@@ -27346,10 +27844,8 @@ function getEventRelatedMember(event, payload) {
|
|
|
27346
27844
|
const createCommunityMemberEventSubscriber = (event, callback) => {
|
|
27347
27845
|
const client = getActiveClient();
|
|
27348
27846
|
const filter = (payload) => {
|
|
27349
|
-
const
|
|
27350
|
-
const { communities } =
|
|
27351
|
-
const preparedPayload = prepareMembershipPayload(communityPayload, 'communityUsers');
|
|
27352
|
-
const { communityUsers } = preparedPayload;
|
|
27847
|
+
const preparedPayload = prepareCommunityPayload(payload);
|
|
27848
|
+
const { communities, communityUsers } = preparedPayload;
|
|
27353
27849
|
/*
|
|
27354
27850
|
* community.isJoined is not part of the communityMembership payload, and needs
|
|
27355
27851
|
* to be calculated based on the communityMembership value
|
|
@@ -27548,6 +28044,40 @@ const onCommunityUserBanned = (callback) => createCommunityMemberEventSubscriber
|
|
|
27548
28044
|
*/
|
|
27549
28045
|
const onCommunityUserUnbanned = (callback) => createCommunityMemberEventSubscriber('community.userUnbanned', callback);
|
|
27550
28046
|
|
|
28047
|
+
/**
|
|
28048
|
+
* ```js
|
|
28049
|
+
* import { onCommunityUserRoleAdded } from '@amityco/ts-sdk'
|
|
28050
|
+
* const dispose = onCommunityUserRoleAdded((community, member) => {
|
|
28051
|
+
* // ...
|
|
28052
|
+
* })
|
|
28053
|
+
* ```
|
|
28054
|
+
*
|
|
28055
|
+
* Fired when a role has been added to {@link Amity.CommunityUser}
|
|
28056
|
+
*
|
|
28057
|
+
* @param callback The function to call when the event was fired
|
|
28058
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28059
|
+
*
|
|
28060
|
+
* @category Community Events
|
|
28061
|
+
*/
|
|
28062
|
+
const onCommunityUserRoleAdded = (callback) => createCommunityMemberEventSubscriber('community.roleAdded', callback);
|
|
28063
|
+
|
|
28064
|
+
/**
|
|
28065
|
+
* ```js
|
|
28066
|
+
* import { onCommunityUserRoleRemoved } from '@amityco/ts-sdk'
|
|
28067
|
+
* const dispose = onCommunityUserRoleRemoved((community, member) => {
|
|
28068
|
+
* // ...
|
|
28069
|
+
* })
|
|
28070
|
+
* ```
|
|
28071
|
+
*
|
|
28072
|
+
* Fired when a role has been removed from {@link Amity.CommunityUser}
|
|
28073
|
+
*
|
|
28074
|
+
* @param callback The function to call when the event was fired
|
|
28075
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28076
|
+
*
|
|
28077
|
+
* @category Community Events
|
|
28078
|
+
*/
|
|
28079
|
+
const onCommunityUserRoleRemoved = (callback) => createCommunityMemberEventSubscriber('community.roleRemoved', callback);
|
|
28080
|
+
|
|
27551
28081
|
/**
|
|
27552
28082
|
* ```js
|
|
27553
28083
|
* import { observeCommunity } from '@amityco/ts-sdk'
|
|
@@ -27708,6 +28238,152 @@ const liveCommunities = (params, callback, config) => {
|
|
|
27708
28238
|
};
|
|
27709
28239
|
};
|
|
27710
28240
|
|
|
28241
|
+
/**
|
|
28242
|
+
* ```js
|
|
28243
|
+
* import { liveCommunity } from '@amityco/ts-sdk';
|
|
28244
|
+
*
|
|
28245
|
+
* let community;
|
|
28246
|
+
*
|
|
28247
|
+
* const unsubscribe = liveCommunity(communityId, response => {
|
|
28248
|
+
* community = response.data;
|
|
28249
|
+
* });
|
|
28250
|
+
* ```
|
|
28251
|
+
*
|
|
28252
|
+
* Observe all mutation on a given {@link Amity.Community}
|
|
28253
|
+
*
|
|
28254
|
+
* @param communityId the ID of the message to observe
|
|
28255
|
+
* @param callback the function to call when new data are available
|
|
28256
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the community
|
|
28257
|
+
*
|
|
28258
|
+
* @category Community Live Object
|
|
28259
|
+
*/
|
|
28260
|
+
const liveCommunity = (communityId, callback) => {
|
|
28261
|
+
return liveObject(communityId, callback, 'communityId', getCommunity, [
|
|
28262
|
+
onCommunityUpdated,
|
|
28263
|
+
onCommunityDeleted,
|
|
28264
|
+
onCommunityJoined,
|
|
28265
|
+
onCommunityLeft,
|
|
28266
|
+
onCommunityUserBanned,
|
|
28267
|
+
onCommunityUserUnbanned,
|
|
28268
|
+
onCommunityUserChanged,
|
|
28269
|
+
]);
|
|
28270
|
+
};
|
|
28271
|
+
|
|
28272
|
+
/**
|
|
28273
|
+
* ```js
|
|
28274
|
+
* import { liveCommunityMembers } from '@amityco/ts-sdk'
|
|
28275
|
+
*
|
|
28276
|
+
* let communityMembers = []
|
|
28277
|
+
* const unsub = liveCommunityMembers({
|
|
28278
|
+
* communityId: Amity.Community['communityId'],
|
|
28279
|
+
* }, response => merge(communityMembers, response.data))
|
|
28280
|
+
* ```
|
|
28281
|
+
*
|
|
28282
|
+
* Observe all mutations on a list of {@link Amity.CommunityUser}s
|
|
28283
|
+
*
|
|
28284
|
+
* @param params for querying community users
|
|
28285
|
+
* @param callback the function to call when new data are available
|
|
28286
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the community users
|
|
28287
|
+
*
|
|
28288
|
+
* @category Community Live Collection
|
|
28289
|
+
*/
|
|
28290
|
+
const liveCommunityMembers = (params, callback, config) => {
|
|
28291
|
+
const { log, cache } = getActiveClient();
|
|
28292
|
+
if (!cache) {
|
|
28293
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
28294
|
+
}
|
|
28295
|
+
const timestamp = Date.now();
|
|
28296
|
+
log(`liveCommunityMembers(tmpid: ${timestamp}) > listen`);
|
|
28297
|
+
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
28298
|
+
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
28299
|
+
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
28300
|
+
const disposers = [];
|
|
28301
|
+
const cacheKey = ['communityUsers', 'collection', { communityId: params.communityId }];
|
|
28302
|
+
const responder = (data) => {
|
|
28303
|
+
var _a, _b;
|
|
28304
|
+
let communityMembers = (_a = data.data
|
|
28305
|
+
.map(id => pullFromCache(['communityUsers', 'get', id]))
|
|
28306
|
+
.filter(Boolean)
|
|
28307
|
+
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
28308
|
+
if (params.roles)
|
|
28309
|
+
communityMembers = communityMembers.filter(c => { var _a; return (_a = c.roles) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.roles) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
28310
|
+
if (params.membership) {
|
|
28311
|
+
communityMembers = communityMembers.filter(({ communityMembership }) =>
|
|
28312
|
+
// @ts-ignore
|
|
28313
|
+
params.membership.includes(communityMembership));
|
|
28314
|
+
}
|
|
28315
|
+
if (params.search) {
|
|
28316
|
+
/*
|
|
28317
|
+
* Search by userId | displayName
|
|
28318
|
+
*/
|
|
28319
|
+
const containsMatcher = new RegExp(params.search);
|
|
28320
|
+
communityMembers = communityMembers.filter(m => {
|
|
28321
|
+
var _a;
|
|
28322
|
+
if (m.userId.match(containsMatcher))
|
|
28323
|
+
return true;
|
|
28324
|
+
return m.user && ((_a = m.user.displayName) === null || _a === void 0 ? void 0 : _a.match(containsMatcher));
|
|
28325
|
+
});
|
|
28326
|
+
}
|
|
28327
|
+
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
28328
|
+
communityMembers = communityMembers.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
28329
|
+
callback({
|
|
28330
|
+
onNextPage: onFetch,
|
|
28331
|
+
data: communityMembers,
|
|
28332
|
+
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
28333
|
+
loading: data.loading,
|
|
28334
|
+
error: data.error,
|
|
28335
|
+
});
|
|
28336
|
+
};
|
|
28337
|
+
const realtimeRouter = (_) => (_, communityMember) => {
|
|
28338
|
+
var _a;
|
|
28339
|
+
if (params.communityId !== communityMember.communityId) {
|
|
28340
|
+
return;
|
|
28341
|
+
}
|
|
28342
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28343
|
+
if (!collection)
|
|
28344
|
+
return;
|
|
28345
|
+
const communityMemberCacheId = getResolver('communityUsers')({
|
|
28346
|
+
communityId: params.communityId,
|
|
28347
|
+
userId: communityMember.userId,
|
|
28348
|
+
});
|
|
28349
|
+
collection.data = [...new Set([communityMemberCacheId, ...collection.data])];
|
|
28350
|
+
pushToCache(cacheKey, collection);
|
|
28351
|
+
responder(collection);
|
|
28352
|
+
};
|
|
28353
|
+
const onFetch = () => {
|
|
28354
|
+
var _a, _b, _c;
|
|
28355
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28356
|
+
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28357
|
+
if (communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
28358
|
+
return;
|
|
28359
|
+
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
28360
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
28361
|
+
const data = {
|
|
28362
|
+
loading,
|
|
28363
|
+
error,
|
|
28364
|
+
params: { page },
|
|
28365
|
+
data: communityMembers,
|
|
28366
|
+
};
|
|
28367
|
+
if (result) {
|
|
28368
|
+
data.data = [
|
|
28369
|
+
...new Set([...communityMembers, ...result.map(getResolver('communityUsers'))]),
|
|
28370
|
+
];
|
|
28371
|
+
}
|
|
28372
|
+
pushToCache(cacheKey, data);
|
|
28373
|
+
responder(data);
|
|
28374
|
+
}, queryOptions(policy));
|
|
28375
|
+
};
|
|
28376
|
+
disposers.push(onCommunityLeft(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityUserBanned(realtimeRouter()), onCommunityUserUnbanned(realtimeRouter()), onCommunityUserChanged(realtimeRouter()), onCommunityUserRoleAdded(realtimeRouter()), onCommunityUserRoleRemoved(realtimeRouter()));
|
|
28377
|
+
onFetch();
|
|
28378
|
+
return () => {
|
|
28379
|
+
log(`liveCommunityMembers(tmpid: ${timestamp}) > dispose`);
|
|
28380
|
+
disposers.forEach(fn => fn());
|
|
28381
|
+
};
|
|
28382
|
+
};
|
|
28383
|
+
|
|
28384
|
+
/* begin_public_function
|
|
28385
|
+
id: community.category.query
|
|
28386
|
+
*/
|
|
27711
28387
|
/**
|
|
27712
28388
|
* ```js
|
|
27713
28389
|
* import { queryCategories } from '@amityco/ts-sdk'
|
|
@@ -27926,6 +28602,9 @@ const liveCategories = (params, callback, config) => {
|
|
|
27926
28602
|
};
|
|
27927
28603
|
};
|
|
27928
28604
|
|
|
28605
|
+
/* begin_public_function
|
|
28606
|
+
id: feed.query.global_feed
|
|
28607
|
+
*/
|
|
27929
28608
|
/**
|
|
27930
28609
|
* ```js
|
|
27931
28610
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
@@ -27944,16 +28623,17 @@ const queryGlobalFeed = async (query) => {
|
|
|
27944
28623
|
const client = getActiveClient();
|
|
27945
28624
|
client.log('feed/queryGlobalFeed', query);
|
|
27946
28625
|
const _a = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _a, params = __rest(_a, ["useCustomRanking", "page"]);
|
|
27947
|
-
const { data } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
|
|
28626
|
+
const { data: queryPayload } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
|
|
27948
28627
|
params: Object.assign(Object.assign({}, params), { options: {
|
|
27949
28628
|
token: toToken(page, 'skiplimit'),
|
|
27950
28629
|
} }),
|
|
27951
28630
|
});
|
|
27952
|
-
const { paging } =
|
|
27953
|
-
const
|
|
28631
|
+
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
28632
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
28633
|
+
const { posts } = data;
|
|
27954
28634
|
const cachedAt = client.cache && Date.now();
|
|
27955
28635
|
if (client.cache) {
|
|
27956
|
-
ingestInCache(
|
|
28636
|
+
ingestInCache(data);
|
|
27957
28637
|
const cacheKey = [
|
|
27958
28638
|
'globalFeed',
|
|
27959
28639
|
'query',
|
|
@@ -27965,6 +28645,7 @@ const queryGlobalFeed = async (query) => {
|
|
|
27965
28645
|
const prevPage = toPage(paging.previous);
|
|
27966
28646
|
return { data: posts, cachedAt, prevPage, nextPage };
|
|
27967
28647
|
};
|
|
28648
|
+
/* end_public_function */
|
|
27968
28649
|
/**
|
|
27969
28650
|
* ```js
|
|
27970
28651
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
@@ -28055,6 +28736,9 @@ queryFollows.locally = (key, query) => {
|
|
|
28055
28736
|
: undefined;
|
|
28056
28737
|
};
|
|
28057
28738
|
|
|
28739
|
+
/* begin_public_function
|
|
28740
|
+
id: user.relationship.query_my_followers, user.relationship.query_followers
|
|
28741
|
+
*/
|
|
28058
28742
|
/**
|
|
28059
28743
|
* ```js
|
|
28060
28744
|
* import { queryFollowers } from '@amityco/ts-sdk'
|
|
@@ -28070,6 +28754,7 @@ queryFollows.locally = (key, query) => {
|
|
|
28070
28754
|
* @async
|
|
28071
28755
|
*/
|
|
28072
28756
|
const queryFollowers = async (query) => queryFollows('followers', query);
|
|
28757
|
+
/* end_public_function */
|
|
28073
28758
|
/**
|
|
28074
28759
|
* ```js
|
|
28075
28760
|
* import { queryFollowers } from '@amityco/ts-sdk'
|
|
@@ -28085,6 +28770,9 @@ const queryFollowers = async (query) => queryFollows('followers', query);
|
|
|
28085
28770
|
*/
|
|
28086
28771
|
queryFollowers.locally = (query) => queryFollows.locally('followers', query);
|
|
28087
28772
|
|
|
28773
|
+
/* begin_public_function
|
|
28774
|
+
id: user.relationship.query_my_followings, user.relationship.query_followings
|
|
28775
|
+
*/
|
|
28088
28776
|
/**
|
|
28089
28777
|
* ```js
|
|
28090
28778
|
* import { queryFollowings } from '@amityco/ts-sdk'
|
|
@@ -28100,6 +28788,7 @@ queryFollowers.locally = (query) => queryFollows.locally('followers', query);
|
|
|
28100
28788
|
* @async
|
|
28101
28789
|
*/
|
|
28102
28790
|
const queryFollowings = async (query) => queryFollows('following', query);
|
|
28791
|
+
/* end_public_function */
|
|
28103
28792
|
/**
|
|
28104
28793
|
* ```js
|
|
28105
28794
|
* import { queryFollowings } from '@amityco/ts-sdk'
|
|
@@ -28120,6 +28809,9 @@ const getCacheKey = (userId) => [
|
|
|
28120
28809
|
'get',
|
|
28121
28810
|
`${getActiveClient().userId}#${userId}`,
|
|
28122
28811
|
];
|
|
28812
|
+
/* begin_public_function
|
|
28813
|
+
id: user.relationship.get_follow_info, user.relationship.get_my_follow_info
|
|
28814
|
+
*/
|
|
28123
28815
|
/**
|
|
28124
28816
|
* ```js
|
|
28125
28817
|
* import { getFollowInfo } from '@amityco/ts-sdk'
|
|
@@ -28150,6 +28842,7 @@ const getFollowInfo = async (userId) => {
|
|
|
28150
28842
|
cachedAt,
|
|
28151
28843
|
};
|
|
28152
28844
|
};
|
|
28845
|
+
/* end_public_function */
|
|
28153
28846
|
/**
|
|
28154
28847
|
* ```js
|
|
28155
28848
|
* import { getFollowInfo } from '@amityco/ts-sdk'
|
|
@@ -28179,6 +28872,9 @@ getFollowInfo.locally = (userId) => {
|
|
|
28179
28872
|
};
|
|
28180
28873
|
};
|
|
28181
28874
|
|
|
28875
|
+
/* begin_public_function
|
|
28876
|
+
id: user.relationship.follow
|
|
28877
|
+
*/
|
|
28182
28878
|
/**
|
|
28183
28879
|
* ```js
|
|
28184
28880
|
* import { follow } from '@amityco/ts-sdk'
|
|
@@ -28206,8 +28902,12 @@ const follow = async (userId) => {
|
|
|
28206
28902
|
data: data.follows[0],
|
|
28207
28903
|
cachedAt,
|
|
28208
28904
|
};
|
|
28209
|
-
};
|
|
28905
|
+
};
|
|
28906
|
+
/* end_public_function */
|
|
28210
28907
|
|
|
28908
|
+
/* begin_public_function
|
|
28909
|
+
id: user.relationship.unfollow
|
|
28910
|
+
*/
|
|
28211
28911
|
/**
|
|
28212
28912
|
* ```js
|
|
28213
28913
|
* import { unfollow } from '@amityco/ts-sdk'
|
|
@@ -28231,8 +28931,12 @@ const unfollow = async (userId) => {
|
|
|
28231
28931
|
}
|
|
28232
28932
|
fireEvent('follow.unfollowed', data);
|
|
28233
28933
|
return true;
|
|
28234
|
-
};
|
|
28934
|
+
};
|
|
28935
|
+
/* end_public_function */
|
|
28235
28936
|
|
|
28937
|
+
/* begin_public_function
|
|
28938
|
+
id: user.relationship.accept_follow
|
|
28939
|
+
*/
|
|
28236
28940
|
/**
|
|
28237
28941
|
* ```js
|
|
28238
28942
|
* import { acceptFollower } from '@amityco/ts-sdk'
|
|
@@ -28256,8 +28960,12 @@ const acceptFollower = async (userId) => {
|
|
|
28256
28960
|
}
|
|
28257
28961
|
fireEvent('follow.accepted', data);
|
|
28258
28962
|
return true;
|
|
28259
|
-
};
|
|
28963
|
+
};
|
|
28964
|
+
/* end_public_function */
|
|
28260
28965
|
|
|
28966
|
+
/* begin_public_function
|
|
28967
|
+
id: user.relationship.decline_follow
|
|
28968
|
+
*/
|
|
28261
28969
|
/**
|
|
28262
28970
|
* ```js
|
|
28263
28971
|
* import { declineFollower } from '@amityco/ts-sdk'
|
|
@@ -28281,7 +28989,8 @@ const declineFollower = async (userId) => {
|
|
|
28281
28989
|
}
|
|
28282
28990
|
fireEvent('follow.requestDeclined', data);
|
|
28283
28991
|
return true;
|
|
28284
|
-
};
|
|
28992
|
+
};
|
|
28993
|
+
/* end_public_function */
|
|
28285
28994
|
|
|
28286
28995
|
const createFollowEventSubscriber = (event, callback) => {
|
|
28287
28996
|
const client = getActiveClient();
|
|
@@ -28895,8 +29604,8 @@ const livePost = (postId, callback) => {
|
|
|
28895
29604
|
*
|
|
28896
29605
|
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
28897
29606
|
*
|
|
28898
|
-
* @param targetType the type of the target
|
|
28899
|
-
* @param targetId the ID of the target
|
|
29607
|
+
* @param param.targetType the type of the target
|
|
29608
|
+
* @param param.targetId the ID of the target
|
|
28900
29609
|
* @param callback the function to call when new data are available
|
|
28901
29610
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
28902
29611
|
*
|
|
@@ -28930,6 +29639,9 @@ const livePosts = (params, callback, config) => {
|
|
|
28930
29639
|
if (params.tags) {
|
|
28931
29640
|
posts = posts.filter(p => { var _a; return (_a = p.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
28932
29641
|
}
|
|
29642
|
+
if (params.targetType === 'community' && params.feedType) {
|
|
29643
|
+
posts = filterByFeedType(posts, params.feedType);
|
|
29644
|
+
}
|
|
28933
29645
|
callback({
|
|
28934
29646
|
onNextPage: onFetch,
|
|
28935
29647
|
data: posts,
|
|
@@ -28943,27 +29655,16 @@ const livePosts = (params, callback, config) => {
|
|
|
28943
29655
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28944
29656
|
if (params.targetId !== post.targetId || params.targetType !== post.targetType || !collection)
|
|
28945
29657
|
return;
|
|
28946
|
-
if (['onCreate', 'onApproved'].includes(action)) {
|
|
28947
|
-
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
28948
|
-
}
|
|
28949
|
-
else if (['onDelete', 'onDeclined'].includes(action)) {
|
|
28950
|
-
collection.data = collection.data.filter(p => p !== post.postId);
|
|
28951
|
-
/*
|
|
28952
|
-
* if isDeleted is true, collection should add deleted items to the
|
|
28953
|
-
* begining of the collection
|
|
28954
|
-
*/
|
|
28955
|
-
if (params.isDeleted)
|
|
28956
|
-
collection.data.unshift(post.postId);
|
|
28957
|
-
}
|
|
28958
29658
|
/*
|
|
28959
|
-
*
|
|
28960
|
-
*
|
|
28961
|
-
* The responder should pull the feed from cache once available and should
|
|
28962
|
-
* match the collection to feedType param
|
|
28963
|
-
* https://ekoapp.atlassian.net/browse/ASC-9382
|
|
29659
|
+
* This is not ideal, but currently this is the only way to update the
|
|
29660
|
+
* collection on post declined
|
|
28964
29661
|
*/
|
|
28965
|
-
if (
|
|
28966
|
-
collection.data = collection.data.filter(
|
|
29662
|
+
if (action === 'onDeclined') {
|
|
29663
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
29664
|
+
}
|
|
29665
|
+
else {
|
|
29666
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
29667
|
+
}
|
|
28967
29668
|
pushToCache(cacheKey, collection);
|
|
28968
29669
|
responder(collection);
|
|
28969
29670
|
};
|
|
@@ -29207,6 +29908,9 @@ const liveComments = (params, callback, config) => {
|
|
|
29207
29908
|
};
|
|
29208
29909
|
};
|
|
29209
29910
|
|
|
29911
|
+
/* begin_public_function
|
|
29912
|
+
id: poll.get
|
|
29913
|
+
*/
|
|
29210
29914
|
/**
|
|
29211
29915
|
* ```js
|
|
29212
29916
|
* import { getPoll } from '@amityco/ts-sdk'
|
|
@@ -29234,6 +29938,7 @@ const getPoll = async (pollId) => {
|
|
|
29234
29938
|
cachedAt,
|
|
29235
29939
|
};
|
|
29236
29940
|
};
|
|
29941
|
+
/* end_public_function */
|
|
29237
29942
|
/**
|
|
29238
29943
|
* ```js
|
|
29239
29944
|
* import { getPoll } from '@amityco/ts-sdk'
|
|
@@ -29261,6 +29966,9 @@ getPoll.locally = (pollId) => {
|
|
|
29261
29966
|
};
|
|
29262
29967
|
};
|
|
29263
29968
|
|
|
29969
|
+
/* begin_public_function
|
|
29970
|
+
id: poll.create
|
|
29971
|
+
*/
|
|
29264
29972
|
/**
|
|
29265
29973
|
* ```js
|
|
29266
29974
|
* import { createPoll } from '@amityco/ts-sdk'
|
|
@@ -29294,8 +30002,12 @@ const createPoll = async (bundle) => {
|
|
|
29294
30002
|
data: polls[0],
|
|
29295
30003
|
cachedAt,
|
|
29296
30004
|
};
|
|
29297
|
-
};
|
|
30005
|
+
};
|
|
30006
|
+
/* end_public_function */
|
|
29298
30007
|
|
|
30008
|
+
/* begin_public_function
|
|
30009
|
+
id: poll.close
|
|
30010
|
+
*/
|
|
29299
30011
|
/**
|
|
29300
30012
|
* ```js
|
|
29301
30013
|
* import { closePoll } from '@amityco/ts-sdk'
|
|
@@ -29323,8 +30035,12 @@ const closePoll = async (pollId) => {
|
|
|
29323
30035
|
data: polls.find(poll => poll.pollId === pollId),
|
|
29324
30036
|
cachedAt,
|
|
29325
30037
|
};
|
|
29326
|
-
};
|
|
30038
|
+
};
|
|
30039
|
+
/* end_public_function */
|
|
29327
30040
|
|
|
30041
|
+
/* begin_public_function
|
|
30042
|
+
id: poll.delete
|
|
30043
|
+
*/
|
|
29328
30044
|
/**
|
|
29329
30045
|
* ```js
|
|
29330
30046
|
* import { deletePoll } from '@amityco/ts-sdk'
|
|
@@ -29350,8 +30066,12 @@ const deletePoll = async (pollId) => {
|
|
|
29350
30066
|
upsertInCache(['poll', 'get', pollId], deleted);
|
|
29351
30067
|
fireEvent('poll.deleted', { polls: [deleted], users: [] });
|
|
29352
30068
|
return success;
|
|
29353
|
-
};
|
|
30069
|
+
};
|
|
30070
|
+
/* end_public_function */
|
|
29354
30071
|
|
|
30072
|
+
/* begin_public_function
|
|
30073
|
+
id: poll.vote
|
|
30074
|
+
*/
|
|
29355
30075
|
/**
|
|
29356
30076
|
* ```js
|
|
29357
30077
|
* import { votePoll } from '@amityco/ts-sdk'
|
|
@@ -29380,7 +30100,8 @@ const votePoll = async (pollId, answerIds) => {
|
|
|
29380
30100
|
data: polls.find(poll => poll.pollId === pollId),
|
|
29381
30101
|
cachedAt,
|
|
29382
30102
|
};
|
|
29383
|
-
};
|
|
30103
|
+
};
|
|
30104
|
+
/* end_public_function */
|
|
29384
30105
|
|
|
29385
30106
|
/**
|
|
29386
30107
|
* ```js
|
|
@@ -29476,6 +30197,9 @@ const observePoll = (pollId, callback, policy = 'cache_then_server') => {
|
|
|
29476
30197
|
};
|
|
29477
30198
|
};
|
|
29478
30199
|
|
|
30200
|
+
/* begin_public_function
|
|
30201
|
+
id: stream.get
|
|
30202
|
+
*/
|
|
29479
30203
|
/**
|
|
29480
30204
|
* ```js
|
|
29481
30205
|
* import { getStream } from '@amityco/ts-sdk'
|
|
@@ -29503,6 +30227,7 @@ const getStream = async (streamId) => {
|
|
|
29503
30227
|
cachedAt,
|
|
29504
30228
|
};
|
|
29505
30229
|
};
|
|
30230
|
+
/* end_public_function */
|
|
29506
30231
|
/**
|
|
29507
30232
|
* ```js
|
|
29508
30233
|
* import { getStream } from '@amityco/ts-sdk'
|
|
@@ -29530,6 +30255,9 @@ getStream.locally = (streamId) => {
|
|
|
29530
30255
|
};
|
|
29531
30256
|
};
|
|
29532
30257
|
|
|
30258
|
+
/* begin_public_function
|
|
30259
|
+
id: stream.query
|
|
30260
|
+
*/
|
|
29533
30261
|
/**
|
|
29534
30262
|
* ```js
|
|
29535
30263
|
* import { queryStreams } from '@amityco/ts-sdk'
|
|
@@ -29564,6 +30292,7 @@ const queryStreams = async (query) => {
|
|
|
29564
30292
|
const prevPage = toPage(paging.previous);
|
|
29565
30293
|
return { data: videoStreamings, cachedAt, prevPage, nextPage };
|
|
29566
30294
|
};
|
|
30295
|
+
/* end_public_function */
|
|
29567
30296
|
/**
|
|
29568
30297
|
* ```js
|
|
29569
30298
|
* import { queryStreams } from '@amityco/ts-sdk'
|
|
@@ -29583,6 +30312,9 @@ queryStreams.locally = (query) => {
|
|
|
29583
30312
|
// TODO
|
|
29584
30313
|
};
|
|
29585
30314
|
|
|
30315
|
+
/* begin_public_function
|
|
30316
|
+
id: stream.create
|
|
30317
|
+
*/
|
|
29586
30318
|
/**
|
|
29587
30319
|
* ```js
|
|
29588
30320
|
* import { createStream } from '@amityco/ts-sdk'
|
|
@@ -29609,8 +30341,12 @@ const createStream = async (bundle) => {
|
|
|
29609
30341
|
data: videoStreamings[0],
|
|
29610
30342
|
cachedAt,
|
|
29611
30343
|
};
|
|
29612
|
-
};
|
|
30344
|
+
};
|
|
30345
|
+
/* end_public_function */
|
|
29613
30346
|
|
|
30347
|
+
/* begin_public_function
|
|
30348
|
+
id: stream.update
|
|
30349
|
+
*/
|
|
29614
30350
|
/**
|
|
29615
30351
|
* ```js
|
|
29616
30352
|
* import { updateStream } from '@amityco/ts-sdk'
|
|
@@ -29641,6 +30377,9 @@ const updateStream = async (streamId, patch) => {
|
|
|
29641
30377
|
};
|
|
29642
30378
|
|
|
29643
30379
|
// import { unwrapPayload } from '~/core/transports'
|
|
30380
|
+
/* begin_public_function
|
|
30381
|
+
id: stream.delete
|
|
30382
|
+
*/
|
|
29644
30383
|
/**
|
|
29645
30384
|
* ```js
|
|
29646
30385
|
* import { deleteStream } from '@amityco/ts-sdk'
|
|
@@ -29791,4 +30530,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
29791
30530
|
return { accessToken: data.accessToken };
|
|
29792
30531
|
};
|
|
29793
30532
|
|
|
29794
|
-
export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, MessageContentType, PostContentType, SubscriptionLevels, VERSION
|
|
30533
|
+
export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, MessageContentType, PostContentType, SubscriptionLevels, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createSubChannel, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, deleteSubChannel, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByChannelMembership, filterByFeedType, filterByPropEquality, filterByPropInclusion, follow, getActiveClient, getCategory, getChannel, getChannelTopic, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMessage, getMessageTopic, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStream, getSubChannel, getSubChannelTopic, getSubChannels, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveCategories, liveChannel, liveChannelMembers, liveChannels, liveComment, liveComments, liveCommunities, liveCommunity, liveCommunityMembers, liveFollowers, liveFollowings, liveMessage, liveMessages, livePost, livePosts, liveReactions, liveSubChannel, liveSubChannels, liveUser, liveUsers, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMemberAdded, onChannelMemberBanned, onChannelMemberRemoved, onChannelMemberUnbanned, onChannelMuted, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserChanged, onCommunityUserRemoved, onCommunityUserRoleAdded, onCommunityUserRoleRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageFlagCleared, onMessageFlagged, onMessageReactionAdded, onMessageReactionRemoved, onMessageUnflagged, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onSessionStateChange, onStreamRecorded, onStreamStarted, onStreamStopped, onSubChannelCreated, onSubChannelDeleted, onSubChannelUpdated, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, querySubChannels, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, renewal, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortByName, sortBySegmentNumber, startReading, stopReading, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateSubChannel, updateUser, upsertInCache, votePoll, wipeCache };
|