@amityco/ts-sdk 7.8.1-fffd2ec.0 → 7.8.1
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/.env +26 -26
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts +4 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/community.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/community.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/community.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts +36 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js +22 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts +11 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.d.ts +1 -4
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/pinnedPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/poll.d.ts +3 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/poll.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/poll.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts +14 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js +21 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.d.ts +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.js +2 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js +6 -6
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.js +3 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.js +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js +3 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js +2 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js +60 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js +66 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js +60 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js +66 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js +108 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/LiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/PaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js +78 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed/QueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js +46 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getUserFeed.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +4 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +4 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts +6 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js +60 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/liveReactionRepository/api/createReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.d.ts +3 -3
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.js +2 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/pollRepository/api/createPoll.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.d.ts +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js +2 -2
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js +26 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js +5 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js +17 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js +2 -50
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js +126 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js +27 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js +65 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js +45 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts +13 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js +61 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js.map +1 -0
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js +9 -4
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js.map +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
- package/dist/@types/domains/client.d.ts +4 -0
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +2 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +1 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +36 -0
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/hashtag.d.ts +11 -0
- package/dist/@types/domains/hashtag.d.ts.map +1 -0
- package/dist/@types/domains/notification.d.ts +2 -1
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/@types/domains/pinnedPost.d.ts +1 -4
- package/dist/@types/domains/pinnedPost.d.ts.map +1 -1
- package/dist/@types/domains/poll.d.ts +3 -1
- package/dist/@types/domains/poll.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +14 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
- package/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +2 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/feedRepository/api/index.d.ts +0 -1
- package/dist/feedRepository/api/index.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
- package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/index.d.ts +2 -1
- package/dist/feedRepository/index.d.ts.map +1 -1
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
- package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
- package/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +13 -0
- package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts +5 -0
- package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +15 -0
- package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts +23 -0
- package/dist/feedRepository/observers/getUserFeed.d.ts.map +1 -0
- package/dist/feedRepository/observers/index.d.ts +4 -0
- package/dist/feedRepository/observers/index.d.ts.map +1 -0
- package/dist/feedRepository/observers/utils.d.ts +6 -0
- package/dist/feedRepository/observers/utils.d.ts.map +1 -0
- package/dist/index.cjs.js +2135 -1282
- package/dist/index.esm.js +2038 -1185
- package/dist/index.umd.js +4 -4
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/dist/pollRepository/api/createPoll.d.ts +3 -3
- package/dist/pollRepository/api/createPoll.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts +1 -1
- package/dist/postRepository/api/editPost.d.ts +1 -1
- package/dist/postRepository/events/utils.d.ts.map +1 -1
- package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
- package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
- package/dist/postRepository/observers/index.d.ts +1 -0
- package/dist/postRepository/observers/index.d.ts.map +1 -1
- package/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
- package/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
- package/dist/postRepository/observers/utils.d.ts +13 -0
- package/dist/postRepository/observers/utils.d.ts.map +1 -0
- package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/client.ts +5 -0
- package/src/@types/domains/community.ts +1 -0
- package/src/@types/domains/content.ts +1 -0
- package/src/@types/domains/feed.ts +60 -0
- package/src/@types/domains/hashtag.ts +11 -0
- package/src/@types/domains/notification.ts +1 -0
- package/src/@types/domains/pinnedPost.ts +1 -4
- package/src/@types/domains/poll.ts +3 -1
- package/src/@types/domains/post.ts +18 -1
- package/src/@types/index.ts +2 -0
- package/src/client/api/getShareableLinkConfiguration.ts +26 -0
- package/src/client/api/index.ts +4 -0
- package/src/commentRepository/api/deleteComment.ts +6 -6
- package/src/communityRepository/observers/getCommunities/CommunitiesLiveCollectionController.ts +3 -3
- package/src/core/model/index.ts +2 -1
- package/src/feedRepository/api/index.ts +0 -1
- package/src/feedRepository/api/queryGlobalFeed.ts +3 -0
- package/src/feedRepository/index.ts +2 -1
- package/src/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.ts +95 -0
- package/src/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.ts +25 -0
- package/src/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.ts +101 -0
- package/src/feedRepository/observers/getCustomRankingGlobalFeed.ts +56 -0
- package/src/feedRepository/observers/getGlobalFeed/LiveCollectionController.ts +91 -0
- package/src/feedRepository/observers/getGlobalFeed/PaginationController.ts +23 -0
- package/src/feedRepository/observers/getGlobalFeed/QueryStreamController.ts +99 -0
- package/src/feedRepository/observers/getGlobalFeed.ts +56 -0
- package/src/feedRepository/observers/getUserFeed/LiveCollectionController.ts +162 -0
- package/src/feedRepository/observers/getUserFeed/PaginationController.ts +37 -0
- package/src/feedRepository/observers/getUserFeed/QueryStreamController.ts +119 -0
- package/src/feedRepository/observers/getUserFeed.ts +56 -0
- package/src/feedRepository/observers/index.ts +3 -0
- package/src/feedRepository/observers/utils.ts +85 -0
- package/src/liveReactionRepository/api/createReaction.ts +0 -1
- package/src/pollRepository/api/createPoll.ts +3 -3
- package/src/postRepository/api/createPost.ts +1 -1
- package/src/postRepository/api/editPost.ts +1 -1
- package/src/postRepository/api/queryPosts.ts +2 -2
- package/src/postRepository/events/utils.ts +35 -1
- package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.ts +5 -0
- package/src/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.ts +7 -1
- package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +27 -0
- package/src/postRepository/observers/getPosts/PostLiveCollectionController.ts +2 -74
- package/src/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.ts +183 -0
- package/src/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.ts +49 -0
- package/src/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.ts +99 -0
- package/src/postRepository/observers/index.ts +1 -0
- package/src/postRepository/observers/searchPostsByHashtag.ts +56 -0
- package/src/postRepository/observers/utils.ts +97 -0
- package/src/reactionRepository/api/addReaction.ts +1 -0
- package/src/reactionRepository/api/removeReaction.ts +1 -0
- package/src/utils/linkedObject/postLinkedObject.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js +0 -83
- package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js.map +0 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +0 -115
package/dist/index.esm.js
CHANGED
|
@@ -137,10 +137,33 @@ var JoinResultStatusEnum;
|
|
|
137
137
|
JoinResultStatusEnum["Pending"] = "pending";
|
|
138
138
|
})(JoinResultStatusEnum || (JoinResultStatusEnum = {}));
|
|
139
139
|
|
|
140
|
+
var FeedDataTypeEnum;
|
|
141
|
+
(function (FeedDataTypeEnum) {
|
|
142
|
+
FeedDataTypeEnum["Text"] = "text";
|
|
143
|
+
FeedDataTypeEnum["Video"] = "video";
|
|
144
|
+
FeedDataTypeEnum["Image"] = "image";
|
|
145
|
+
FeedDataTypeEnum["File"] = "file";
|
|
146
|
+
FeedDataTypeEnum["LiveStream"] = "liveStream";
|
|
147
|
+
FeedDataTypeEnum["Clip"] = "clip";
|
|
148
|
+
FeedDataTypeEnum["Poll"] = "poll";
|
|
149
|
+
})(FeedDataTypeEnum || (FeedDataTypeEnum = {}));
|
|
150
|
+
var FeedSortByEnum;
|
|
151
|
+
(function (FeedSortByEnum) {
|
|
152
|
+
FeedSortByEnum["LastCreated"] = "lastCreated";
|
|
153
|
+
FeedSortByEnum["FirstCreated"] = "firstCreated";
|
|
154
|
+
FeedSortByEnum["LastUpdated"] = "lastUpdated";
|
|
155
|
+
FeedSortByEnum["FirstUpdated"] = "firstUpdated";
|
|
156
|
+
})(FeedSortByEnum || (FeedSortByEnum = {}));
|
|
157
|
+
var FeedSourceEnum;
|
|
158
|
+
(function (FeedSourceEnum) {
|
|
159
|
+
FeedSourceEnum["Community"] = "community";
|
|
160
|
+
FeedSourceEnum["User"] = "user";
|
|
161
|
+
})(FeedSourceEnum || (FeedSourceEnum = {}));
|
|
162
|
+
|
|
140
163
|
function getVersion() {
|
|
141
164
|
try {
|
|
142
|
-
// the string ''v7.8.
|
|
143
|
-
return 'v7.8.
|
|
165
|
+
// the string ''v7.8.1-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
166
|
+
return 'v7.8.1-esm';
|
|
144
167
|
}
|
|
145
168
|
catch (error) {
|
|
146
169
|
return '__dev__';
|
|
@@ -642,7 +665,8 @@ const PAYLOAD2MODEL = {
|
|
|
642
665
|
};
|
|
643
666
|
/** hidden */
|
|
644
667
|
const isOutdated = (prevData, nextData) => {
|
|
645
|
-
|
|
668
|
+
// Check if the new value is outdated.
|
|
669
|
+
if ('updatedAt' in nextData && 'updatedAt' in prevData) {
|
|
646
670
|
return new Date(nextData.updatedAt) < new Date(prevData.updatedAt);
|
|
647
671
|
}
|
|
648
672
|
return false;
|
|
@@ -25872,6 +25896,26 @@ const fetchLinkPreview = async (url) => {
|
|
|
25872
25896
|
return data;
|
|
25873
25897
|
};
|
|
25874
25898
|
|
|
25899
|
+
/**
|
|
25900
|
+
* ```js
|
|
25901
|
+
* import Client from '@amityco/ts-sdk'
|
|
25902
|
+
* const shareableLinkConfiguration = await Client.getShareableLinkConfiguration()
|
|
25903
|
+
* const postLinkPattern = shareableLinkConfiguration.post
|
|
25904
|
+
* ```
|
|
25905
|
+
*
|
|
25906
|
+
* Fetches a {@link Amity.ShareableLinkConfiguration} object
|
|
25907
|
+
*
|
|
25908
|
+
* @returns A Promise of {@link Amity.ShareableLinkConfiguration} object
|
|
25909
|
+
*
|
|
25910
|
+
* @category Client API
|
|
25911
|
+
* @async
|
|
25912
|
+
*/
|
|
25913
|
+
const getShareableLinkConfiguration = async () => {
|
|
25914
|
+
const client = getActiveClient();
|
|
25915
|
+
const { data } = await client.http.get(`/api/v3/network-settings/shareable-deep-links`);
|
|
25916
|
+
return data;
|
|
25917
|
+
};
|
|
25918
|
+
|
|
25875
25919
|
/**
|
|
25876
25920
|
* ```js
|
|
25877
25921
|
* import { onChannelMarkerFetched } from '@amityco/ts-sdk'
|
|
@@ -26241,6 +26285,8 @@ var index$o = /*#__PURE__*/Object.freeze({
|
|
|
26241
26285
|
enableUnreadCount: enableUnreadCount,
|
|
26242
26286
|
setUploadedFileAccessType: setUploadedFileAccessType,
|
|
26243
26287
|
fetchLinkPreview: fetchLinkPreview,
|
|
26288
|
+
getSocialSettings: getSocialSettings,
|
|
26289
|
+
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26244
26290
|
onConnectionError: onConnectionError,
|
|
26245
26291
|
onClientDisconnected: onClientDisconnected,
|
|
26246
26292
|
onClientBanned: onClientBanned,
|
|
@@ -27944,15 +27990,18 @@ function isAmityClipPost(post) {
|
|
|
27944
27990
|
}
|
|
27945
27991
|
|
|
27946
27992
|
const postLinkedObject = (post) => {
|
|
27947
|
-
return
|
|
27993
|
+
return shallowClone(post, {
|
|
27994
|
+
childrenPosts: post.children
|
|
27948
27995
|
.map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
|
|
27949
27996
|
.filter(isNonNullable)
|
|
27950
|
-
.map(postLinkedObject),
|
|
27997
|
+
.map(postLinkedObject),
|
|
27998
|
+
analytics: {
|
|
27951
27999
|
markAsViewed: () => {
|
|
27952
28000
|
const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
|
|
27953
28001
|
analyticsEngineInstance.markPostAsViewed(post.postId);
|
|
27954
28002
|
},
|
|
27955
|
-
},
|
|
28003
|
+
},
|
|
28004
|
+
get latestComments() {
|
|
27956
28005
|
if (!post.comments)
|
|
27957
28006
|
return [];
|
|
27958
28007
|
return (post.comments
|
|
@@ -28026,7 +28075,8 @@ const postLinkedObject = (post) => {
|
|
|
28026
28075
|
return isAmityClipPost(post)
|
|
28027
28076
|
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
28028
28077
|
: undefined;
|
|
28029
|
-
}
|
|
28078
|
+
},
|
|
28079
|
+
});
|
|
28030
28080
|
};
|
|
28031
28081
|
|
|
28032
28082
|
const getCachedMarker = (message) => {
|
|
@@ -31021,7 +31071,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
31021
31071
|
]);
|
|
31022
31072
|
if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
31023
31073
|
return true;
|
|
31024
|
-
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
|
|
31074
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }), updatedAt: new Date().toISOString() });
|
|
31025
31075
|
if (referenceType === 'comment') {
|
|
31026
31076
|
fireEvent('local.comment.addReaction', {
|
|
31027
31077
|
comment: updatedModel,
|
|
@@ -31144,7 +31194,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
31144
31194
|
]);
|
|
31145
31195
|
if (!model)
|
|
31146
31196
|
return true;
|
|
31147
|
-
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }) });
|
|
31197
|
+
const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) - 1) }), updatedAt: new Date().toISOString() });
|
|
31148
31198
|
if (referenceType === 'comment') {
|
|
31149
31199
|
fireEvent('local.comment.removeReaction', {
|
|
31150
31200
|
comment: updatedModel,
|
|
@@ -31258,6 +31308,26 @@ const prepareSemanticSearchPostPayload = (_a) => {
|
|
|
31258
31308
|
return Object.assign(Object.assign({}, processedPostPayload), { polls });
|
|
31259
31309
|
};
|
|
31260
31310
|
|
|
31311
|
+
const processDeleteChildPost = (payload) => {
|
|
31312
|
+
var _a;
|
|
31313
|
+
const post = payload.posts[0];
|
|
31314
|
+
if (!post.parentId)
|
|
31315
|
+
return;
|
|
31316
|
+
const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
31317
|
+
if (!parentPost)
|
|
31318
|
+
return;
|
|
31319
|
+
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
|
|
31320
|
+
};
|
|
31321
|
+
const processCreateChildPost = (payload) => {
|
|
31322
|
+
var _a;
|
|
31323
|
+
const post = payload.posts[0];
|
|
31324
|
+
if (!post.parentId)
|
|
31325
|
+
return;
|
|
31326
|
+
const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
31327
|
+
if (!parentPost)
|
|
31328
|
+
return;
|
|
31329
|
+
pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));
|
|
31330
|
+
};
|
|
31261
31331
|
const createPostEventSubscriber = (event, callback) => {
|
|
31262
31332
|
const client = getActiveClient();
|
|
31263
31333
|
const filter = (payload) => {
|
|
@@ -31282,6 +31352,7 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
31282
31352
|
}
|
|
31283
31353
|
if (event === 'post.deleted') {
|
|
31284
31354
|
const { postId, postedUserId } = payload.posts[0];
|
|
31355
|
+
processDeleteChildPost(payload);
|
|
31285
31356
|
try {
|
|
31286
31357
|
isInTombstone('post', postId);
|
|
31287
31358
|
}
|
|
@@ -31308,6 +31379,8 @@ const createPostEventSubscriber = (event, callback) => {
|
|
|
31308
31379
|
}
|
|
31309
31380
|
queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
31310
31381
|
}
|
|
31382
|
+
if (event === 'post.created')
|
|
31383
|
+
processCreateChildPost(payload);
|
|
31311
31384
|
callback(post.data);
|
|
31312
31385
|
}
|
|
31313
31386
|
};
|
|
@@ -31334,6 +31407,8 @@ const createLocalPostEventSubscriber = (event, callback) => {
|
|
|
31334
31407
|
});
|
|
31335
31408
|
}
|
|
31336
31409
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
31410
|
+
if (event === 'local.post.deleted')
|
|
31411
|
+
processDeleteChildPost(payload);
|
|
31337
31412
|
callback(post.data);
|
|
31338
31413
|
}
|
|
31339
31414
|
};
|
|
@@ -37865,10 +37940,10 @@ class CommunityLiveCollectionController extends LiveCollectionController {
|
|
|
37865
37940
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
37866
37941
|
if (!collection)
|
|
37867
37942
|
return;
|
|
37868
|
-
const data =
|
|
37943
|
+
const data = (_b = collection.data
|
|
37869
37944
|
.map(id => pullFromCache(['community', 'get', id]))
|
|
37870
37945
|
.filter(isNonNullable)
|
|
37871
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []
|
|
37946
|
+
.map(({ data }) => communityLinkedObject(data))) !== null && _b !== void 0 ? _b : [];
|
|
37872
37947
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
37873
37948
|
return;
|
|
37874
37949
|
this.callback({
|
|
@@ -39109,6 +39184,9 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
39109
39184
|
id: feed.query.global_feed
|
|
39110
39185
|
*/
|
|
39111
39186
|
/**
|
|
39187
|
+
*
|
|
39188
|
+
* @deprecated This function will to be deprecated. Please use getGlobalFeed instead.
|
|
39189
|
+
*
|
|
39112
39190
|
* ```js
|
|
39113
39191
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
39114
39192
|
* const posts = await queryGlobalFeed()
|
|
@@ -39191,1086 +39269,1023 @@ queryGlobalFeed.locally = (query) => {
|
|
|
39191
39269
|
: undefined;
|
|
39192
39270
|
};
|
|
39193
39271
|
|
|
39194
|
-
|
|
39195
|
-
|
|
39196
|
-
|
|
39197
|
-
|
|
39198
|
-
|
|
39199
|
-
|
|
39200
|
-
|
|
39201
|
-
|
|
39202
|
-
*
|
|
39203
|
-
* Queries a paginable list of {@link Amity.Post} objects
|
|
39204
|
-
*
|
|
39205
|
-
* @param query The query parameters
|
|
39206
|
-
* @returns A page of {@link Amity.Post} objects
|
|
39207
|
-
*
|
|
39208
|
-
* @category Feed API
|
|
39209
|
-
* @async
|
|
39210
|
-
* */
|
|
39211
|
-
const getCustomRankingGlobalFeed = async (query) => {
|
|
39212
|
-
const client = getActiveClient();
|
|
39213
|
-
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
39214
|
-
const _a = query !== null && query !== void 0 ? query : {}, { queryToken, limit } = _a, params = __rest(_a, ["queryToken", "limit"]);
|
|
39215
|
-
const options = (() => {
|
|
39216
|
-
if (queryToken)
|
|
39217
|
-
return { token: queryToken };
|
|
39218
|
-
return undefined;
|
|
39219
|
-
})();
|
|
39220
|
-
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
39221
|
-
params: Object.assign(Object.assign({}, params), { limit: !queryToken ? limit : undefined, options }),
|
|
39222
|
-
});
|
|
39223
|
-
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
39224
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39225
|
-
const { posts } = data;
|
|
39226
|
-
const cachedAt = client.cache && Date.now();
|
|
39227
|
-
if (client.cache) {
|
|
39228
|
-
ingestInCache(data);
|
|
39229
|
-
const cacheKey = ['customGlobalFeed', 'query', Object.assign(Object.assign({}, params), { options })];
|
|
39230
|
-
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
39272
|
+
class CustomRankingGlobalFeedPaginationController extends PaginationController {
|
|
39273
|
+
async getRequest(queryParams, token) {
|
|
39274
|
+
const { limit } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
39275
|
+
const options = token ? { token } : { limit };
|
|
39276
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/me/global-feeds`, {
|
|
39277
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
39278
|
+
});
|
|
39279
|
+
return queryResponse;
|
|
39231
39280
|
}
|
|
39232
|
-
|
|
39233
|
-
};
|
|
39234
|
-
/* end_public_function */
|
|
39235
|
-
/**
|
|
39236
|
-
* ```js
|
|
39237
|
-
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
39238
|
-
* const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
|
|
39239
|
-
* ```
|
|
39240
|
-
*
|
|
39241
|
-
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
39242
|
-
*
|
|
39243
|
-
* @param query The query parameters
|
|
39244
|
-
* @returns A page of {@link Amity.Post} objects
|
|
39245
|
-
*
|
|
39246
|
-
* @category Feed API
|
|
39247
|
-
* @async
|
|
39248
|
-
* */
|
|
39249
|
-
getCustomRankingGlobalFeed.locally = (query) => {
|
|
39250
|
-
var _a, _b;
|
|
39251
|
-
const client = getActiveClient();
|
|
39252
|
-
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
39253
|
-
if (!client.cache)
|
|
39254
|
-
return;
|
|
39255
|
-
const params = __rest(query !== null && query !== void 0 ? query : {}, []);
|
|
39256
|
-
const queryKey = ['customGlobalFeed', 'query', Object.assign({}, params)];
|
|
39257
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
39258
|
-
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
39259
|
-
return;
|
|
39260
|
-
const posts = data.posts
|
|
39261
|
-
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
39262
|
-
.filter(Boolean)
|
|
39263
|
-
.map(({ data }) => data);
|
|
39264
|
-
const { paging } = data;
|
|
39265
|
-
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
39266
|
-
? { data: posts.map(LinkedObject.post), cachedAt, paging }
|
|
39267
|
-
: undefined;
|
|
39268
|
-
};
|
|
39281
|
+
}
|
|
39269
39282
|
|
|
39270
|
-
var
|
|
39271
|
-
|
|
39272
|
-
|
|
39273
|
-
|
|
39274
|
-
|
|
39283
|
+
var EnumPostActions;
|
|
39284
|
+
(function (EnumPostActions) {
|
|
39285
|
+
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
39286
|
+
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
39287
|
+
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
39288
|
+
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
39289
|
+
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
39290
|
+
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
39291
|
+
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
39292
|
+
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
39293
|
+
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
39294
|
+
})(EnumPostActions || (EnumPostActions = {}));
|
|
39295
|
+
|
|
39296
|
+
class CustomRankingGlobalFeedQueryStreamController extends QueryStreamController {
|
|
39297
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
39298
|
+
super(query, cacheKey);
|
|
39299
|
+
this.notifyChange = notifyChange;
|
|
39300
|
+
this.preparePayload = preparePayload;
|
|
39301
|
+
}
|
|
39302
|
+
async saveToMainDB(response) {
|
|
39303
|
+
const processedPayload = await this.preparePayload(response);
|
|
39304
|
+
const client = getActiveClient();
|
|
39305
|
+
const cachedAt = client.cache && Date.now();
|
|
39306
|
+
if (client.cache) {
|
|
39307
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
39308
|
+
}
|
|
39309
|
+
}
|
|
39310
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
39311
|
+
var _a, _b;
|
|
39312
|
+
if (refresh) {
|
|
39313
|
+
pushToCache(this.cacheKey, {
|
|
39314
|
+
data: response.posts.map(getResolver('post')),
|
|
39315
|
+
});
|
|
39316
|
+
}
|
|
39317
|
+
else {
|
|
39318
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39319
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
39320
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
39321
|
+
}
|
|
39322
|
+
}
|
|
39323
|
+
reactor(action) {
|
|
39324
|
+
return (post) => {
|
|
39325
|
+
var _a;
|
|
39326
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
39327
|
+
if (!collection)
|
|
39328
|
+
return;
|
|
39329
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
39330
|
+
return;
|
|
39331
|
+
// Delete Action
|
|
39332
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
39333
|
+
// Parent Post - Remove from collection
|
|
39334
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
39335
|
+
}
|
|
39336
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
39337
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
39338
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
39339
|
+
if (!this.query.dataTypes.includes(post.dataType))
|
|
39340
|
+
return;
|
|
39341
|
+
}
|
|
39342
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
39343
|
+
}
|
|
39344
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
39345
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
39346
|
+
}
|
|
39347
|
+
pushToCache(this.cacheKey, collection);
|
|
39348
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
39349
|
+
};
|
|
39350
|
+
}
|
|
39351
|
+
subscribeRTE(createSubscriber) {
|
|
39352
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
39353
|
+
}
|
|
39354
|
+
}
|
|
39275
39355
|
|
|
39276
39356
|
/* begin_public_function
|
|
39277
|
-
id:
|
|
39357
|
+
id: comment.get_by_ids
|
|
39278
39358
|
*/
|
|
39279
39359
|
/**
|
|
39280
39360
|
* ```js
|
|
39281
|
-
* import {
|
|
39282
|
-
* const
|
|
39361
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39362
|
+
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
39283
39363
|
* ```
|
|
39284
39364
|
*
|
|
39285
|
-
* Fetches a collection of {@link Amity.
|
|
39365
|
+
* Fetches a collection of {@link Amity.Comment} objects
|
|
39286
39366
|
*
|
|
39287
|
-
* @param
|
|
39288
|
-
* @returns the associated collection of {@link Amity.
|
|
39367
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39368
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39289
39369
|
*
|
|
39290
|
-
* @category
|
|
39370
|
+
* @category Comment API
|
|
39291
39371
|
* @async
|
|
39292
39372
|
*/
|
|
39293
|
-
const
|
|
39373
|
+
const getCommentByIds = async (commentIds) => {
|
|
39294
39374
|
const client = getActiveClient();
|
|
39295
|
-
client.log('
|
|
39296
|
-
const
|
|
39297
|
-
let
|
|
39375
|
+
client.log('comment/getCommentByIds', commentIds);
|
|
39376
|
+
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
39377
|
+
let data;
|
|
39298
39378
|
try {
|
|
39299
39379
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
39300
|
-
const response = await client.http.get(`/api/v3/
|
|
39301
|
-
params: {
|
|
39380
|
+
const response = await client.http.get(`/api/v3/comments/list`, {
|
|
39381
|
+
params: { commentIds: encodedCommentIds },
|
|
39302
39382
|
});
|
|
39303
|
-
|
|
39383
|
+
data = response.data;
|
|
39304
39384
|
}
|
|
39305
39385
|
catch (error) {
|
|
39306
|
-
|
|
39386
|
+
commentIds.forEach(commentId => {
|
|
39307
39387
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39308
|
-
pushToTombstone('
|
|
39388
|
+
pushToTombstone('comment', commentId);
|
|
39309
39389
|
}
|
|
39310
39390
|
});
|
|
39311
39391
|
throw error;
|
|
39312
39392
|
}
|
|
39313
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39314
39393
|
const cachedAt = client.cache && Date.now();
|
|
39315
39394
|
if (client.cache)
|
|
39316
39395
|
ingestInCache(data, { cachedAt });
|
|
39317
39396
|
return {
|
|
39318
|
-
data: data.
|
|
39397
|
+
data: data.comments.map(comment => LinkedObject.comment(comment)),
|
|
39319
39398
|
cachedAt,
|
|
39320
39399
|
};
|
|
39321
39400
|
};
|
|
39322
39401
|
/* end_public_function */
|
|
39323
39402
|
/**
|
|
39324
39403
|
* ```js
|
|
39325
|
-
* import {
|
|
39326
|
-
* const
|
|
39404
|
+
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
39405
|
+
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
39327
39406
|
* ```
|
|
39328
39407
|
*
|
|
39329
|
-
* Fetches a collection of {@link Amity.
|
|
39408
|
+
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
39330
39409
|
*
|
|
39331
|
-
* @param
|
|
39332
|
-
* @returns the associated collection of {@link Amity.
|
|
39410
|
+
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39411
|
+
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39333
39412
|
*
|
|
39334
|
-
* @category
|
|
39413
|
+
* @category Comment API
|
|
39335
39414
|
*/
|
|
39336
|
-
|
|
39415
|
+
getCommentByIds.locally = (commentIds) => {
|
|
39337
39416
|
var _a;
|
|
39338
39417
|
const client = getActiveClient();
|
|
39339
|
-
client.log('
|
|
39418
|
+
client.log('comment/getCommentByIds.locally', commentIds);
|
|
39340
39419
|
if (!client.cache)
|
|
39341
39420
|
return;
|
|
39342
|
-
const cached =
|
|
39343
|
-
.map(
|
|
39421
|
+
const cached = commentIds
|
|
39422
|
+
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
39344
39423
|
.filter(Boolean);
|
|
39345
|
-
const
|
|
39424
|
+
const comments = cached.map(({ data }) => data);
|
|
39346
39425
|
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
39347
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) <
|
|
39426
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
39348
39427
|
return;
|
|
39349
39428
|
return {
|
|
39350
|
-
data:
|
|
39429
|
+
data: comments.map(comment => LinkedObject.comment(comment)),
|
|
39351
39430
|
cachedAt: oldest.cachedAt,
|
|
39352
39431
|
};
|
|
39353
39432
|
};
|
|
39354
39433
|
|
|
39355
39434
|
/* begin_public_function
|
|
39356
|
-
id:
|
|
39435
|
+
id: comment.create
|
|
39357
39436
|
*/
|
|
39358
39437
|
/**
|
|
39359
39438
|
* ```js
|
|
39360
|
-
* import {
|
|
39361
|
-
* const
|
|
39362
|
-
* targetType: 'user',
|
|
39363
|
-
* targetId: 'foobar',
|
|
39364
|
-
* data: { text: 'hello world' }
|
|
39365
|
-
* }))
|
|
39439
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39440
|
+
* const newComment = await CommentRepository.createComment(bundle)
|
|
39366
39441
|
* ```
|
|
39367
39442
|
*
|
|
39368
|
-
* Creates an {@link Amity.
|
|
39443
|
+
* Creates an {@link Amity.Comment}
|
|
39369
39444
|
*
|
|
39370
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
39371
|
-
* @returns The newly created {@link Amity.
|
|
39445
|
+
* @param bundle The data necessary to create a new {@link Amity.Comment}
|
|
39446
|
+
* @returns The newly created {@link Amity.Comment}
|
|
39372
39447
|
*
|
|
39373
|
-
* @category
|
|
39448
|
+
* @category Comment API
|
|
39374
39449
|
* @async
|
|
39375
39450
|
*/
|
|
39376
|
-
const
|
|
39451
|
+
const createComment = async (bundle) => {
|
|
39452
|
+
var _a;
|
|
39377
39453
|
const client = getActiveClient();
|
|
39378
|
-
client.log('
|
|
39379
|
-
|
|
39380
|
-
|
|
39381
|
-
|
|
39382
|
-
|
|
39383
|
-
|
|
39384
|
-
fireEvent('post.created', payload);
|
|
39385
|
-
const data = preparePostPayload(payload);
|
|
39454
|
+
client.log('comment/createComment', bundle);
|
|
39455
|
+
const { data } = await client.http.post('/api/v3/comments', bundle);
|
|
39456
|
+
const { comments } = data;
|
|
39457
|
+
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
39458
|
+
if (comments.length === 0)
|
|
39459
|
+
throw new Error('Comment not created');
|
|
39386
39460
|
const cachedAt = client.cache && Date.now();
|
|
39387
39461
|
if (client.cache)
|
|
39388
39462
|
ingestInCache(data, { cachedAt });
|
|
39389
|
-
|
|
39463
|
+
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
39464
|
+
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39465
|
+
if (post) {
|
|
39466
|
+
post.commentsCount += 1;
|
|
39467
|
+
fireEvent('local.post.updated', {
|
|
39468
|
+
posts: [post],
|
|
39469
|
+
categories: [],
|
|
39470
|
+
comments: [],
|
|
39471
|
+
communities: [],
|
|
39472
|
+
communityUsers: data.communityUsers,
|
|
39473
|
+
feeds: [],
|
|
39474
|
+
files: data.files,
|
|
39475
|
+
postChildren: [],
|
|
39476
|
+
users: data.users,
|
|
39477
|
+
videoStreamings: [],
|
|
39478
|
+
});
|
|
39479
|
+
}
|
|
39480
|
+
}
|
|
39481
|
+
else if (bundle.referenceType === 'story') {
|
|
39482
|
+
const storyIndex = pullFromCache([
|
|
39483
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39484
|
+
bundle.referenceId,
|
|
39485
|
+
]);
|
|
39486
|
+
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
39487
|
+
const cacheStory = pullFromCache([
|
|
39488
|
+
"story" /* STORY_KEY_CACHE.STORY */,
|
|
39489
|
+
'get',
|
|
39490
|
+
storyIndex.data,
|
|
39491
|
+
]);
|
|
39492
|
+
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
39493
|
+
fireEvent('story.updated', {
|
|
39494
|
+
stories: [
|
|
39495
|
+
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
39496
|
+
],
|
|
39497
|
+
categories: [],
|
|
39498
|
+
comments,
|
|
39499
|
+
communities: [],
|
|
39500
|
+
communityUsers: data.communityUsers,
|
|
39501
|
+
files: data.files,
|
|
39502
|
+
users: data.users,
|
|
39503
|
+
});
|
|
39504
|
+
}
|
|
39505
|
+
}
|
|
39506
|
+
}
|
|
39507
|
+
fireEvent('local.comment.created', data);
|
|
39390
39508
|
return {
|
|
39391
|
-
data: LinkedObject.
|
|
39509
|
+
data: LinkedObject.comment(comments[0]),
|
|
39392
39510
|
cachedAt,
|
|
39393
39511
|
};
|
|
39394
39512
|
};
|
|
39395
39513
|
/* end_public_function */
|
|
39396
39514
|
|
|
39397
39515
|
/* begin_public_function
|
|
39398
|
-
id:
|
|
39516
|
+
id: comment.update_comment
|
|
39399
39517
|
*/
|
|
39400
39518
|
/**
|
|
39401
39519
|
* ```js
|
|
39402
|
-
* import {
|
|
39403
|
-
* const updated = await
|
|
39520
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39521
|
+
* const updated = await CommentRepository.updateComment(commentId, {
|
|
39404
39522
|
* data: { text: 'hello world' }
|
|
39405
39523
|
* })
|
|
39406
39524
|
* ```
|
|
39407
39525
|
*
|
|
39408
|
-
* Updates an {@link Amity.
|
|
39526
|
+
* Updates an {@link Amity.Comment}
|
|
39409
39527
|
*
|
|
39410
|
-
* @param
|
|
39528
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
39411
39529
|
* @param patch The patch data to apply
|
|
39412
|
-
* @returns the updated {@link Amity.
|
|
39530
|
+
* @returns the updated {@link Amity.Comment} object
|
|
39413
39531
|
*
|
|
39414
|
-
* @category
|
|
39532
|
+
* @category Comment API
|
|
39415
39533
|
* @async
|
|
39416
39534
|
*/
|
|
39417
|
-
const
|
|
39535
|
+
const updateComment = async (commentId, patch) => {
|
|
39418
39536
|
const client = getActiveClient();
|
|
39419
|
-
client.log('user/
|
|
39420
|
-
const { data
|
|
39421
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39537
|
+
client.log('user/updateComment', patch);
|
|
39538
|
+
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
39422
39539
|
const cachedAt = client.cache && Date.now();
|
|
39423
39540
|
if (client.cache)
|
|
39424
39541
|
ingestInCache(data, { cachedAt });
|
|
39425
|
-
fireEvent('
|
|
39426
|
-
const {
|
|
39542
|
+
fireEvent('comment.updated', data);
|
|
39543
|
+
const { comments } = data;
|
|
39427
39544
|
return {
|
|
39428
|
-
data: LinkedObject.
|
|
39545
|
+
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
39429
39546
|
cachedAt,
|
|
39430
39547
|
};
|
|
39431
39548
|
};
|
|
39432
39549
|
/* end_public_function */
|
|
39433
39550
|
|
|
39551
|
+
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
39552
|
+
const applyMissingField = (rawData, isCreated = false) => {
|
|
39553
|
+
const { storyId, referenceId } = rawData;
|
|
39554
|
+
if (!isCreated) {
|
|
39555
|
+
if (referenceId)
|
|
39556
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
39557
|
+
}
|
|
39558
|
+
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
39559
|
+
};
|
|
39560
|
+
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
39561
|
+
const { stories } = data;
|
|
39562
|
+
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
39563
|
+
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
39564
|
+
};
|
|
39565
|
+
|
|
39566
|
+
const getStoryByStoryId$1 = async (storyId) => {
|
|
39567
|
+
const client = getActiveClient();
|
|
39568
|
+
client.log('story/getStoryByStoryId', storyId);
|
|
39569
|
+
// Get story referenceId from cache
|
|
39570
|
+
const cacheReferenceId = pullFromCache([
|
|
39571
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39572
|
+
storyId,
|
|
39573
|
+
]);
|
|
39574
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
39575
|
+
const { data: referenceId } = cacheReferenceId;
|
|
39576
|
+
isInTombstone('story', referenceId);
|
|
39577
|
+
}
|
|
39578
|
+
let data;
|
|
39579
|
+
try {
|
|
39580
|
+
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
39581
|
+
data = convertRawStoryToInternal(response.data);
|
|
39582
|
+
}
|
|
39583
|
+
catch (error) {
|
|
39584
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39585
|
+
pushToTombstone('story', storyId);
|
|
39586
|
+
}
|
|
39587
|
+
throw error;
|
|
39588
|
+
}
|
|
39589
|
+
const cachedAt = client.cache && Date.now();
|
|
39590
|
+
if (client.cache) {
|
|
39591
|
+
ingestInCache(data, { cachedAt });
|
|
39592
|
+
}
|
|
39593
|
+
return {
|
|
39594
|
+
data: data.stories[0],
|
|
39595
|
+
cachedAt,
|
|
39596
|
+
};
|
|
39597
|
+
};
|
|
39598
|
+
getStoryByStoryId$1.locally = (storyId) => {
|
|
39599
|
+
const client = getActiveClient();
|
|
39600
|
+
client.log('story/getStorybyStoryId', storyId);
|
|
39601
|
+
// Get story referenceId from cache
|
|
39602
|
+
const cacheReferenceId = pullFromCache([
|
|
39603
|
+
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39604
|
+
storyId,
|
|
39605
|
+
]);
|
|
39606
|
+
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
39607
|
+
const { data: referenceId } = cacheReferenceId;
|
|
39608
|
+
isInTombstone('story', referenceId);
|
|
39609
|
+
}
|
|
39610
|
+
const cachedAt = client.cache && Date.now();
|
|
39611
|
+
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
39612
|
+
if (!storyCache)
|
|
39613
|
+
return;
|
|
39614
|
+
return {
|
|
39615
|
+
data: storyCache.data,
|
|
39616
|
+
cachedAt,
|
|
39617
|
+
};
|
|
39618
|
+
};
|
|
39619
|
+
|
|
39620
|
+
/* begin_public_function
|
|
39621
|
+
id: comment.soft_delete, comment.hard_delete
|
|
39622
|
+
*/
|
|
39434
39623
|
/**
|
|
39435
39624
|
* ```js
|
|
39436
|
-
* import {
|
|
39437
|
-
* const success = await
|
|
39625
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39626
|
+
* const success = await CommentRepository.deleteComment('foobar')
|
|
39438
39627
|
* ```
|
|
39439
39628
|
*
|
|
39440
|
-
* Deletes a {@link Amity.
|
|
39629
|
+
* Deletes a {@link Amity.Comment}
|
|
39441
39630
|
*
|
|
39442
|
-
* @param
|
|
39443
|
-
* @return A success boolean if the {@link Amity.
|
|
39631
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39632
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39444
39633
|
*
|
|
39445
|
-
* @
|
|
39634
|
+
* @category Comment API
|
|
39446
39635
|
* @async
|
|
39447
39636
|
*/
|
|
39448
|
-
const
|
|
39637
|
+
const deleteComment = async (commentId, permanent = false) => {
|
|
39449
39638
|
var _a;
|
|
39450
39639
|
const client = getActiveClient();
|
|
39451
|
-
const
|
|
39452
|
-
|
|
39640
|
+
const comment = await getComment$2(commentId);
|
|
39641
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
39642
|
+
await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
|
|
39453
39643
|
params: {
|
|
39454
|
-
|
|
39644
|
+
commentId,
|
|
39455
39645
|
permanent,
|
|
39456
39646
|
},
|
|
39457
39647
|
});
|
|
39458
|
-
//
|
|
39459
|
-
|
|
39460
|
-
|
|
39461
|
-
|
|
39462
|
-
|
|
39463
|
-
|
|
39464
|
-
|
|
39465
|
-
|
|
39466
|
-
|
|
39467
|
-
|
|
39468
|
-
|
|
39469
|
-
|
|
39470
|
-
if (key[1] !== 'get')
|
|
39471
|
-
return false;
|
|
39472
|
-
if (typeof key[2] === 'string')
|
|
39473
|
-
return key[2].includes(community.data.communityId);
|
|
39474
|
-
return false;
|
|
39475
|
-
})
|
|
39476
|
-
.map(({ data }) => data);
|
|
39477
|
-
fireEvent('community.updated', {
|
|
39478
|
-
communities: [community.data],
|
|
39648
|
+
// to support hard deletion
|
|
39649
|
+
const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
|
|
39650
|
+
if (permanent) {
|
|
39651
|
+
scheduleTask(() => pushToTombstone('comment', commentId));
|
|
39652
|
+
}
|
|
39653
|
+
else {
|
|
39654
|
+
upsertInCache(['comment', 'get', commentId], { isDeleted: true });
|
|
39655
|
+
}
|
|
39656
|
+
if (comment.data.referenceType === 'story') {
|
|
39657
|
+
const story = await getStoryByStoryId$1(comment.data.referenceId);
|
|
39658
|
+
fireEvent('local.story.updated', {
|
|
39659
|
+
stories: [story.data],
|
|
39479
39660
|
categories: [],
|
|
39480
|
-
|
|
39481
|
-
|
|
39661
|
+
comments: [],
|
|
39662
|
+
communities: [],
|
|
39663
|
+
communityUsers: [],
|
|
39482
39664
|
files: [],
|
|
39483
39665
|
users: [],
|
|
39484
39666
|
});
|
|
39485
39667
|
}
|
|
39486
|
-
// to support hard deletion
|
|
39487
|
-
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
39488
|
-
if (permanent) {
|
|
39489
|
-
setTimeout(() => {
|
|
39490
|
-
pushToTombstone('post', postId);
|
|
39491
|
-
}, 0);
|
|
39492
|
-
}
|
|
39493
39668
|
else {
|
|
39494
|
-
|
|
39669
|
+
const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39670
|
+
if (post) {
|
|
39671
|
+
let removeCount;
|
|
39672
|
+
if (!deleted.parentId) {
|
|
39673
|
+
// NOTE: delete the parent comment will remove all children comments
|
|
39674
|
+
removeCount = deleted.childrenNumber + 1;
|
|
39675
|
+
}
|
|
39676
|
+
else
|
|
39677
|
+
removeCount = 1;
|
|
39678
|
+
post.commentsCount -= removeCount;
|
|
39679
|
+
fireEvent('local.post.updated', {
|
|
39680
|
+
posts: [post],
|
|
39681
|
+
categories: [],
|
|
39682
|
+
comments: [],
|
|
39683
|
+
communities: [],
|
|
39684
|
+
communityUsers: [],
|
|
39685
|
+
feeds: [],
|
|
39686
|
+
files: [],
|
|
39687
|
+
postChildren: [],
|
|
39688
|
+
users: [],
|
|
39689
|
+
videoStreamings: [],
|
|
39690
|
+
});
|
|
39691
|
+
}
|
|
39495
39692
|
}
|
|
39496
|
-
fireEvent('local.
|
|
39497
|
-
|
|
39498
|
-
|
|
39499
|
-
comments: [],
|
|
39500
|
-
communities: [],
|
|
39501
|
-
communityUsers: [],
|
|
39502
|
-
feeds: [],
|
|
39693
|
+
fireEvent('local.comment.deleted', {
|
|
39694
|
+
comments: [deleted],
|
|
39695
|
+
commentChildren: [],
|
|
39503
39696
|
files: [],
|
|
39504
|
-
postChildren: [],
|
|
39505
39697
|
users: [],
|
|
39506
|
-
|
|
39698
|
+
communityUsers: [],
|
|
39507
39699
|
});
|
|
39508
|
-
return
|
|
39509
|
-
};
|
|
39510
|
-
|
|
39511
|
-
/* begin_public_function
|
|
39512
|
-
id: post.soft_delete
|
|
39513
|
-
*/
|
|
39514
|
-
/**
|
|
39515
|
-
* ```js
|
|
39516
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
39517
|
-
* const success = await PostRepository.softDeletePost('foobar')
|
|
39518
|
-
* ```
|
|
39519
|
-
*
|
|
39520
|
-
* Soft deletes a {@link Amity.Post}
|
|
39521
|
-
*
|
|
39522
|
-
* @param postId The {@link Amity.Post} ID to soft delete
|
|
39523
|
-
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
39524
|
-
*
|
|
39525
|
-
* @category Post API
|
|
39526
|
-
* @async
|
|
39527
|
-
*/
|
|
39528
|
-
const softDeletePost = async (postId) => {
|
|
39529
|
-
const client = getActiveClient();
|
|
39530
|
-
client.log('post/softDeletePost', postId);
|
|
39531
|
-
const softDeleted = await deletePost(postId, false);
|
|
39532
|
-
return LinkedObject.post(softDeleted);
|
|
39533
|
-
};
|
|
39534
|
-
/* end_public_function */
|
|
39535
|
-
|
|
39536
|
-
/* begin_public_function
|
|
39537
|
-
id: post.hard_delete
|
|
39538
|
-
*/
|
|
39539
|
-
/**
|
|
39540
|
-
* ```js
|
|
39541
|
-
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
39542
|
-
* const success = await hardDeletePost('foobar')
|
|
39543
|
-
* ```
|
|
39544
|
-
*
|
|
39545
|
-
* Hard deletes a {@link Amity.Post}
|
|
39546
|
-
*
|
|
39547
|
-
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
39548
|
-
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
39549
|
-
*
|
|
39550
|
-
* @category Post API
|
|
39551
|
-
* @async
|
|
39552
|
-
*/
|
|
39553
|
-
const hardDeletePost = async (postId) => {
|
|
39554
|
-
const client = getActiveClient();
|
|
39555
|
-
client.log('post/hardDeletePost', postId);
|
|
39556
|
-
const hardDeleted = await deletePost(postId, true);
|
|
39557
|
-
return LinkedObject.post(hardDeleted);
|
|
39700
|
+
return deleted;
|
|
39558
39701
|
};
|
|
39559
39702
|
/* end_public_function */
|
|
39560
39703
|
|
|
39561
39704
|
/* begin_public_function
|
|
39562
|
-
id:
|
|
39705
|
+
id: comment.soft_delete
|
|
39563
39706
|
*/
|
|
39564
39707
|
/**
|
|
39565
39708
|
* ```js
|
|
39566
|
-
* import {
|
|
39567
|
-
*
|
|
39568
|
-
* const { data: post } = await approvePost('postId')
|
|
39709
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39710
|
+
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
39569
39711
|
* ```
|
|
39570
39712
|
*
|
|
39571
|
-
*
|
|
39713
|
+
* Deletes a {@link Amity.Comment}
|
|
39572
39714
|
*
|
|
39573
|
-
* @param
|
|
39574
|
-
* @return A {@link Amity.
|
|
39715
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39716
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39575
39717
|
*
|
|
39576
|
-
* @category
|
|
39718
|
+
* @category Comment API
|
|
39577
39719
|
* @async
|
|
39578
39720
|
*/
|
|
39579
|
-
const
|
|
39721
|
+
const softDeleteComment = async (commentId) => {
|
|
39580
39722
|
const client = getActiveClient();
|
|
39581
|
-
client.log('
|
|
39582
|
-
const
|
|
39583
|
-
|
|
39584
|
-
// fire virtual event for community update
|
|
39585
|
-
if (payload.posts[0].targetType === 'community') {
|
|
39586
|
-
fireEvent('community.updated', payload);
|
|
39587
|
-
}
|
|
39588
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39589
|
-
const cachedAt = client.cache && Date.now();
|
|
39590
|
-
if (client.cache)
|
|
39591
|
-
ingestInCache(data, { cachedAt });
|
|
39592
|
-
return {
|
|
39593
|
-
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
39594
|
-
cachedAt,
|
|
39595
|
-
};
|
|
39723
|
+
client.log('comment/softDeleteComment', commentId);
|
|
39724
|
+
const softDeleted = deleteComment(commentId);
|
|
39725
|
+
return softDeleted;
|
|
39596
39726
|
};
|
|
39597
39727
|
/* end_public_function */
|
|
39598
39728
|
|
|
39599
39729
|
/* begin_public_function
|
|
39600
|
-
id:
|
|
39730
|
+
id: comment.hard_delete
|
|
39601
39731
|
*/
|
|
39602
39732
|
/**
|
|
39603
39733
|
* ```js
|
|
39604
|
-
* import {
|
|
39605
|
-
*
|
|
39606
|
-
* const {data: post} = await declinePost('postId')
|
|
39734
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39735
|
+
* const success = await CommentRepository.hardDeleteComment('foobar')
|
|
39607
39736
|
* ```
|
|
39608
39737
|
*
|
|
39609
|
-
*
|
|
39738
|
+
* Deletes a {@link Amity.Comment}
|
|
39610
39739
|
*
|
|
39611
|
-
* @param
|
|
39612
|
-
* @return A {@link Amity.
|
|
39740
|
+
* @param commentId The {@link Amity.Comment} ID to delete
|
|
39741
|
+
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
39613
39742
|
*
|
|
39614
|
-
* @category
|
|
39743
|
+
* @category Comment API
|
|
39615
39744
|
* @async
|
|
39616
39745
|
*/
|
|
39617
|
-
const
|
|
39746
|
+
const hardDeleteComment = async (commentId) => {
|
|
39618
39747
|
const client = getActiveClient();
|
|
39619
|
-
client.log('
|
|
39620
|
-
const
|
|
39621
|
-
|
|
39622
|
-
if (payload.posts[0].targetType === 'community') {
|
|
39623
|
-
fireEvent('community.updated', payload);
|
|
39624
|
-
}
|
|
39625
|
-
fireEvent('post.declined', payload);
|
|
39626
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39627
|
-
const cachedAt = client.cache && Date.now();
|
|
39628
|
-
if (client.cache)
|
|
39629
|
-
ingestInCache(data, { cachedAt });
|
|
39630
|
-
return {
|
|
39631
|
-
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
39632
|
-
cachedAt,
|
|
39633
|
-
};
|
|
39748
|
+
client.log('comment/hardDeleteComment', commentId);
|
|
39749
|
+
const hardDeleted = deleteComment(commentId, true);
|
|
39750
|
+
return hardDeleted;
|
|
39634
39751
|
};
|
|
39635
39752
|
/* end_public_function */
|
|
39636
39753
|
|
|
39637
39754
|
/* begin_public_function
|
|
39638
|
-
id:
|
|
39755
|
+
id: comment.flag
|
|
39639
39756
|
*/
|
|
39640
39757
|
/**
|
|
39641
39758
|
* ```js
|
|
39642
|
-
* import {
|
|
39643
|
-
* const flagged = await
|
|
39759
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39760
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
39644
39761
|
* ```
|
|
39645
39762
|
*
|
|
39646
|
-
* @param
|
|
39647
|
-
* @param reason the reason to flag the
|
|
39648
|
-
* @returns
|
|
39763
|
+
* @param commentId The ID of the comment to flag
|
|
39764
|
+
* @param reason the reason to flag the comment
|
|
39765
|
+
* @returns the created report result
|
|
39649
39766
|
*
|
|
39650
|
-
* @category
|
|
39767
|
+
* @category Comment API
|
|
39651
39768
|
* @async
|
|
39652
39769
|
* */
|
|
39653
|
-
const
|
|
39770
|
+
const flagComment = async (commentId, reason) => {
|
|
39654
39771
|
const client = getActiveClient();
|
|
39655
|
-
client.log('
|
|
39772
|
+
client.log('comment/flagComment', commentId);
|
|
39656
39773
|
const isPredefinedReason = reason &&
|
|
39657
39774
|
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
39658
39775
|
const body = {
|
|
39659
39776
|
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
39660
39777
|
detail: reason && !isPredefinedReason ? reason : '',
|
|
39661
39778
|
};
|
|
39662
|
-
const { data: payload } = await client.http.post(`/api/v3/
|
|
39779
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
39663
39780
|
if (client.cache) {
|
|
39664
|
-
ingestInCache(
|
|
39781
|
+
ingestInCache(payload);
|
|
39665
39782
|
}
|
|
39666
|
-
fireEvent('
|
|
39783
|
+
fireEvent('comment.flagged', payload);
|
|
39667
39784
|
return !!payload;
|
|
39668
39785
|
};
|
|
39669
39786
|
/* end_public_function */
|
|
39670
39787
|
|
|
39671
39788
|
/* begin_public_function
|
|
39672
|
-
id:
|
|
39789
|
+
id: comment.unflag
|
|
39673
39790
|
*/
|
|
39674
39791
|
/**
|
|
39675
39792
|
* ```js
|
|
39676
|
-
* import {
|
|
39677
|
-
* const unflagged = await
|
|
39793
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39794
|
+
* const unflagged = await CommentRepository.unflagComment('commentId')
|
|
39678
39795
|
* ```
|
|
39679
39796
|
*
|
|
39680
|
-
* @param
|
|
39681
|
-
* @returns the
|
|
39797
|
+
* @param commentId The ID of comment to unflag
|
|
39798
|
+
* @returns the unflagged result
|
|
39682
39799
|
*
|
|
39683
|
-
* @category
|
|
39800
|
+
* @category Comment API
|
|
39684
39801
|
* @async
|
|
39685
39802
|
* */
|
|
39686
|
-
const
|
|
39803
|
+
const unflagComment = async (commentId) => {
|
|
39687
39804
|
const client = getActiveClient();
|
|
39688
|
-
client.log('
|
|
39689
|
-
const { data: payload } = await client.http.delete(`/api/v3/
|
|
39805
|
+
client.log('comment/unflagComment', commentId);
|
|
39806
|
+
const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
|
|
39690
39807
|
if (client.cache) {
|
|
39691
|
-
ingestInCache(
|
|
39808
|
+
ingestInCache(payload);
|
|
39692
39809
|
}
|
|
39693
|
-
fireEvent('
|
|
39810
|
+
fireEvent('comment.unflagged', payload);
|
|
39694
39811
|
return !!payload;
|
|
39695
39812
|
};
|
|
39696
39813
|
/* end_public_function */
|
|
39697
39814
|
|
|
39698
39815
|
/* begin_public_function
|
|
39699
|
-
id:
|
|
39816
|
+
id: comment.check_flag_by_me
|
|
39700
39817
|
*/
|
|
39701
39818
|
/**
|
|
39702
39819
|
* ```js
|
|
39703
|
-
* import {
|
|
39704
|
-
* const isReported = await
|
|
39820
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39821
|
+
* const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
|
|
39705
39822
|
* ```
|
|
39706
39823
|
*
|
|
39707
|
-
* @param
|
|
39708
|
-
* @returns `true` if the
|
|
39824
|
+
* @param commentId The ID of the comment to check if flagged by current user
|
|
39825
|
+
* @returns `true` if the comment is flagged by me, `false` if doesn't.
|
|
39709
39826
|
*
|
|
39710
|
-
* @category
|
|
39827
|
+
* @category Comment API
|
|
39711
39828
|
* @async
|
|
39712
39829
|
* */
|
|
39713
|
-
const
|
|
39830
|
+
const isCommentFlaggedByMe = async (commentId) => {
|
|
39714
39831
|
const client = getActiveClient();
|
|
39715
|
-
client.log('
|
|
39716
|
-
const { data: { result }, } = await client.http.get(`/api/v3/
|
|
39832
|
+
client.log('comment/isCommentFlaggedByMe', commentId);
|
|
39833
|
+
const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
|
|
39717
39834
|
return result;
|
|
39718
39835
|
};
|
|
39719
39836
|
/* end_public_function */
|
|
39720
39837
|
|
|
39721
|
-
|
|
39722
|
-
id: post.create.clip_post
|
|
39723
|
-
*/
|
|
39724
|
-
/**
|
|
39725
|
-
* ```js
|
|
39726
|
-
* import { PostRepository } from '@amityco/ts-sdk'
|
|
39727
|
-
* const created = await PostRepository.createClipPost({
|
|
39728
|
-
* targetType: 'user',
|
|
39729
|
-
* targetId: 'foobar',
|
|
39730
|
-
* dataType: 'clip',
|
|
39731
|
-
* data: { text: 'hello world' },
|
|
39732
|
-
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
39733
|
-
* }))
|
|
39734
|
-
* ```
|
|
39735
|
-
*
|
|
39736
|
-
* Creates an {@link Amity.Post}
|
|
39737
|
-
*
|
|
39738
|
-
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
39739
|
-
* @returns The newly created {@link Amity.Post}
|
|
39740
|
-
*
|
|
39741
|
-
* @category Post API
|
|
39742
|
-
* @async
|
|
39743
|
-
*/
|
|
39744
|
-
const createClipPost = async (bundle) => {
|
|
39745
|
-
const client = getActiveClient();
|
|
39746
|
-
client.log('post/createPost', bundle);
|
|
39747
|
-
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
39748
|
-
fireEvent('post.created', payload);
|
|
39749
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39750
|
-
const cachedAt = client.cache && Date.now();
|
|
39751
|
-
if (client.cache)
|
|
39752
|
-
ingestInCache(data, { cachedAt });
|
|
39753
|
-
const { posts } = data;
|
|
39754
|
-
return {
|
|
39755
|
-
data: LinkedObject.post(posts[0]),
|
|
39756
|
-
cachedAt,
|
|
39757
|
-
};
|
|
39758
|
-
};
|
|
39759
|
-
/* end_public_function */
|
|
39760
|
-
|
|
39761
|
-
/* begin_public_function
|
|
39762
|
-
id: comment.get_by_ids
|
|
39763
|
-
*/
|
|
39764
|
-
/**
|
|
39765
|
-
* ```js
|
|
39766
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
39767
|
-
* const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
|
|
39768
|
-
* ```
|
|
39769
|
-
*
|
|
39770
|
-
* Fetches a collection of {@link Amity.Comment} objects
|
|
39771
|
-
*
|
|
39772
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39773
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39774
|
-
*
|
|
39775
|
-
* @category Comment API
|
|
39776
|
-
* @async
|
|
39777
|
-
*/
|
|
39778
|
-
const getCommentByIds = async (commentIds) => {
|
|
39838
|
+
const getComment$1 = async (commentId) => {
|
|
39779
39839
|
const client = getActiveClient();
|
|
39780
|
-
client.log('comment/
|
|
39781
|
-
|
|
39840
|
+
client.log('comment/getComment', commentId);
|
|
39841
|
+
isInTombstone('comment', commentId);
|
|
39782
39842
|
let data;
|
|
39783
39843
|
try {
|
|
39784
39844
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
39785
|
-
const response = await client.http.get(`/api/v3/comments
|
|
39786
|
-
params: { commentIds: encodedCommentIds },
|
|
39787
|
-
});
|
|
39845
|
+
const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
|
|
39788
39846
|
data = response.data;
|
|
39789
39847
|
}
|
|
39790
39848
|
catch (error) {
|
|
39791
|
-
|
|
39792
|
-
|
|
39793
|
-
|
|
39794
|
-
}
|
|
39795
|
-
});
|
|
39849
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39850
|
+
pushToTombstone('comment', commentId);
|
|
39851
|
+
}
|
|
39796
39852
|
throw error;
|
|
39797
39853
|
}
|
|
39798
39854
|
const cachedAt = client.cache && Date.now();
|
|
39799
39855
|
if (client.cache)
|
|
39800
39856
|
ingestInCache(data, { cachedAt });
|
|
39857
|
+
const { comments } = data;
|
|
39801
39858
|
return {
|
|
39802
|
-
data:
|
|
39859
|
+
data: comments.find(comment => comment.commentId === commentId),
|
|
39803
39860
|
cachedAt,
|
|
39804
39861
|
};
|
|
39805
39862
|
};
|
|
39806
|
-
|
|
39807
|
-
/**
|
|
39808
|
-
* ```js
|
|
39809
|
-
* import { getCommentByIds } from '@amityco/ts-sdk'
|
|
39810
|
-
* const comments = getCommentByIds.locally(['foo', 'bar'])
|
|
39811
|
-
* ```
|
|
39812
|
-
*
|
|
39813
|
-
* Fetches a collection of {@link Amity.Comment} objects from cache
|
|
39814
|
-
*
|
|
39815
|
-
* @param commentIds the IDs of the {@link Amity.Comment} to fetch
|
|
39816
|
-
* @returns the associated collection of {@link Amity.Comment} objects
|
|
39817
|
-
*
|
|
39818
|
-
* @category Comment API
|
|
39819
|
-
*/
|
|
39820
|
-
getCommentByIds.locally = (commentIds) => {
|
|
39821
|
-
var _a;
|
|
39863
|
+
getComment$1.locally = (commentId) => {
|
|
39822
39864
|
const client = getActiveClient();
|
|
39823
|
-
client.log('comment/
|
|
39865
|
+
client.log('comment/getComment.locally', commentId);
|
|
39824
39866
|
if (!client.cache)
|
|
39825
39867
|
return;
|
|
39826
|
-
const cached =
|
|
39827
|
-
|
|
39828
|
-
.filter(Boolean);
|
|
39829
|
-
const comments = cached.map(({ data }) => data);
|
|
39830
|
-
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
39831
|
-
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
39868
|
+
const cached = pullFromCache(['comment', 'get', commentId]);
|
|
39869
|
+
if (!cached)
|
|
39832
39870
|
return;
|
|
39833
39871
|
return {
|
|
39834
|
-
data:
|
|
39835
|
-
cachedAt:
|
|
39872
|
+
data: cached.data,
|
|
39873
|
+
cachedAt: cached.cachedAt,
|
|
39836
39874
|
};
|
|
39837
39875
|
};
|
|
39838
39876
|
|
|
39839
|
-
/* begin_public_function
|
|
39840
|
-
id: comment.create
|
|
39841
|
-
*/
|
|
39842
39877
|
/**
|
|
39843
39878
|
* ```js
|
|
39844
|
-
* import {
|
|
39845
|
-
* const
|
|
39879
|
+
* import { onCommentDeleteLocal } from '@amityco/ts-sdk'
|
|
39880
|
+
* const dispose = onCommentDeleteLocal(comment => {
|
|
39881
|
+
* // ...
|
|
39882
|
+
* })
|
|
39846
39883
|
* ```
|
|
39847
39884
|
*
|
|
39848
|
-
*
|
|
39885
|
+
* Fired when a {@link Amity.InternalComment} has been deleted
|
|
39849
39886
|
*
|
|
39850
|
-
* @param
|
|
39851
|
-
* @returns
|
|
39887
|
+
* @param callback The function to call when the event was fired
|
|
39888
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
39852
39889
|
*
|
|
39853
|
-
* @category Comment
|
|
39854
|
-
* @async
|
|
39890
|
+
* @category Comment Events
|
|
39855
39891
|
*/
|
|
39856
|
-
const
|
|
39857
|
-
|
|
39892
|
+
const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
|
|
39893
|
+
|
|
39894
|
+
/**
|
|
39895
|
+
* ```js
|
|
39896
|
+
* import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
|
|
39897
|
+
* const dispose = onLocalCommentReactionAdded(comment => {
|
|
39898
|
+
* // ...
|
|
39899
|
+
* })
|
|
39900
|
+
* ```
|
|
39901
|
+
*
|
|
39902
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
39903
|
+
*
|
|
39904
|
+
* @param callback The function to call when the event was fired
|
|
39905
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
39906
|
+
*
|
|
39907
|
+
* @category Comment Events
|
|
39908
|
+
*/
|
|
39909
|
+
const onLocalCommentReactionAdded = (callback) => {
|
|
39858
39910
|
const client = getActiveClient();
|
|
39859
|
-
|
|
39860
|
-
|
|
39861
|
-
|
|
39862
|
-
// BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
|
|
39863
|
-
if (comments.length === 0)
|
|
39864
|
-
throw new Error('Comment not created');
|
|
39865
|
-
const cachedAt = client.cache && Date.now();
|
|
39866
|
-
if (client.cache)
|
|
39867
|
-
ingestInCache(data, { cachedAt });
|
|
39868
|
-
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
39869
|
-
const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
39870
|
-
if (post) {
|
|
39871
|
-
post.commentsCount += 1;
|
|
39872
|
-
fireEvent('local.post.updated', {
|
|
39873
|
-
posts: [post],
|
|
39874
|
-
categories: [],
|
|
39875
|
-
comments: [],
|
|
39876
|
-
communities: [],
|
|
39877
|
-
communityUsers: data.communityUsers,
|
|
39878
|
-
feeds: [],
|
|
39879
|
-
files: data.files,
|
|
39880
|
-
postChildren: [],
|
|
39881
|
-
users: data.users,
|
|
39882
|
-
videoStreamings: [],
|
|
39883
|
-
});
|
|
39911
|
+
const filter = ({ comment }) => {
|
|
39912
|
+
if (!client.cache) {
|
|
39913
|
+
callback(comment);
|
|
39884
39914
|
}
|
|
39885
|
-
|
|
39886
|
-
|
|
39887
|
-
|
|
39888
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
39889
|
-
bundle.referenceId,
|
|
39890
|
-
]);
|
|
39891
|
-
if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
|
|
39892
|
-
const cacheStory = pullFromCache([
|
|
39893
|
-
"story" /* STORY_KEY_CACHE.STORY */,
|
|
39894
|
-
'get',
|
|
39895
|
-
storyIndex.data,
|
|
39896
|
-
]);
|
|
39897
|
-
if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
|
|
39898
|
-
fireEvent('story.updated', {
|
|
39899
|
-
stories: [
|
|
39900
|
-
Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
|
|
39901
|
-
],
|
|
39902
|
-
categories: [],
|
|
39903
|
-
comments,
|
|
39904
|
-
communities: [],
|
|
39905
|
-
communityUsers: data.communityUsers,
|
|
39906
|
-
files: data.files,
|
|
39907
|
-
users: data.users,
|
|
39908
|
-
});
|
|
39909
|
-
}
|
|
39915
|
+
else {
|
|
39916
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
39917
|
+
callback(commentLinkedObject(comment));
|
|
39910
39918
|
}
|
|
39911
|
-
}
|
|
39912
|
-
fireEvent('local.comment.created', data);
|
|
39913
|
-
return {
|
|
39914
|
-
data: LinkedObject.comment(comments[0]),
|
|
39915
|
-
cachedAt,
|
|
39916
39919
|
};
|
|
39920
|
+
return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
|
|
39917
39921
|
};
|
|
39918
|
-
/* end_public_function */
|
|
39919
39922
|
|
|
39920
|
-
/* begin_public_function
|
|
39921
|
-
id: comment.update_comment
|
|
39922
|
-
*/
|
|
39923
39923
|
/**
|
|
39924
39924
|
* ```js
|
|
39925
|
-
* import {
|
|
39926
|
-
* const
|
|
39927
|
-
*
|
|
39925
|
+
* import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
|
|
39926
|
+
* const dispose = onLocalCommentReactionRemoved(comment => {
|
|
39927
|
+
* // ...
|
|
39928
39928
|
* })
|
|
39929
39929
|
* ```
|
|
39930
39930
|
*
|
|
39931
|
-
*
|
|
39931
|
+
* Fired when a {@link Amity.InternalComment} has been reacted
|
|
39932
39932
|
*
|
|
39933
|
-
* @param
|
|
39934
|
-
* @
|
|
39935
|
-
* @returns the updated {@link Amity.Comment} object
|
|
39933
|
+
* @param callback The function to call when the event was fired
|
|
39934
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
39936
39935
|
*
|
|
39937
|
-
* @category Comment
|
|
39938
|
-
* @async
|
|
39936
|
+
* @category Comment Events
|
|
39939
39937
|
*/
|
|
39940
|
-
const
|
|
39941
|
-
const client = getActiveClient();
|
|
39942
|
-
client.log('user/updateComment', patch);
|
|
39943
|
-
const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
|
|
39944
|
-
const cachedAt = client.cache && Date.now();
|
|
39945
|
-
if (client.cache)
|
|
39946
|
-
ingestInCache(data, { cachedAt });
|
|
39947
|
-
fireEvent('comment.updated', data);
|
|
39948
|
-
const { comments } = data;
|
|
39949
|
-
return {
|
|
39950
|
-
data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
|
|
39951
|
-
cachedAt,
|
|
39952
|
-
};
|
|
39953
|
-
};
|
|
39954
|
-
/* end_public_function */
|
|
39955
|
-
|
|
39956
|
-
// Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
|
|
39957
|
-
const applyMissingField = (rawData, isCreated = false) => {
|
|
39958
|
-
const { storyId, referenceId } = rawData;
|
|
39959
|
-
if (!isCreated) {
|
|
39960
|
-
if (referenceId)
|
|
39961
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
|
|
39962
|
-
}
|
|
39963
|
-
return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
|
|
39964
|
-
};
|
|
39965
|
-
const convertRawStoryToInternal = (data, isCreated = false) => {
|
|
39966
|
-
const { stories } = data;
|
|
39967
|
-
const storiesData = stories.map(story => applyMissingField(story, isCreated));
|
|
39968
|
-
return Object.assign(Object.assign({}, data), { stories: storiesData });
|
|
39969
|
-
};
|
|
39970
|
-
|
|
39971
|
-
const getStoryByStoryId$1 = async (storyId) => {
|
|
39938
|
+
const onLocalCommentReactionRemoved = (callback) => {
|
|
39972
39939
|
const client = getActiveClient();
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39977
|
-
|
|
39978
|
-
|
|
39979
|
-
|
|
39980
|
-
const { data: referenceId } = cacheReferenceId;
|
|
39981
|
-
isInTombstone('story', referenceId);
|
|
39982
|
-
}
|
|
39983
|
-
let data;
|
|
39984
|
-
try {
|
|
39985
|
-
const response = await client.http.get(`/api/v4/stories/${storyId}`);
|
|
39986
|
-
data = convertRawStoryToInternal(response.data);
|
|
39987
|
-
}
|
|
39988
|
-
catch (error) {
|
|
39989
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
39990
|
-
pushToTombstone('story', storyId);
|
|
39940
|
+
const filter = ({ comment }) => {
|
|
39941
|
+
if (!client.cache) {
|
|
39942
|
+
callback(comment);
|
|
39943
|
+
}
|
|
39944
|
+
else {
|
|
39945
|
+
upsertInCache(['comment', 'get', comment.commentId], comment);
|
|
39946
|
+
callback(commentLinkedObject(comment));
|
|
39991
39947
|
}
|
|
39992
|
-
throw error;
|
|
39993
|
-
}
|
|
39994
|
-
const cachedAt = client.cache && Date.now();
|
|
39995
|
-
if (client.cache) {
|
|
39996
|
-
ingestInCache(data, { cachedAt });
|
|
39997
|
-
}
|
|
39998
|
-
return {
|
|
39999
|
-
data: data.stories[0],
|
|
40000
|
-
cachedAt,
|
|
40001
|
-
};
|
|
40002
|
-
};
|
|
40003
|
-
getStoryByStoryId$1.locally = (storyId) => {
|
|
40004
|
-
const client = getActiveClient();
|
|
40005
|
-
client.log('story/getStorybyStoryId', storyId);
|
|
40006
|
-
// Get story referenceId from cache
|
|
40007
|
-
const cacheReferenceId = pullFromCache([
|
|
40008
|
-
"story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
|
|
40009
|
-
storyId,
|
|
40010
|
-
]);
|
|
40011
|
-
if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
|
|
40012
|
-
const { data: referenceId } = cacheReferenceId;
|
|
40013
|
-
isInTombstone('story', referenceId);
|
|
40014
|
-
}
|
|
40015
|
-
const cachedAt = client.cache && Date.now();
|
|
40016
|
-
const storyCache = pullFromCache(['story', 'get', storyId]);
|
|
40017
|
-
if (!storyCache)
|
|
40018
|
-
return;
|
|
40019
|
-
return {
|
|
40020
|
-
data: storyCache.data,
|
|
40021
|
-
cachedAt,
|
|
40022
39948
|
};
|
|
39949
|
+
return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
|
|
40023
39950
|
};
|
|
40024
39951
|
|
|
40025
39952
|
/* begin_public_function
|
|
40026
|
-
id: comment.
|
|
39953
|
+
id: comment.get
|
|
40027
39954
|
*/
|
|
40028
39955
|
/**
|
|
40029
39956
|
* ```js
|
|
40030
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
40031
|
-
* const success = await CommentRepository.deleteComment('foobar')
|
|
40032
|
-
* ```
|
|
39957
|
+
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
40033
39958
|
*
|
|
40034
|
-
*
|
|
39959
|
+
* let comment;
|
|
40035
39960
|
*
|
|
40036
|
-
*
|
|
40037
|
-
*
|
|
39961
|
+
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
39962
|
+
* comment = response.data;
|
|
39963
|
+
* });
|
|
39964
|
+
* ```
|
|
40038
39965
|
*
|
|
40039
|
-
* @
|
|
40040
|
-
*
|
|
39966
|
+
* Observe all mutation on a given {@link Amity.Comment}
|
|
39967
|
+
*
|
|
39968
|
+
* @param commentId the ID of the comment to observe
|
|
39969
|
+
* @param callback the function to call when new data are available
|
|
39970
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
39971
|
+
*
|
|
39972
|
+
* @category Comment Live Object
|
|
40041
39973
|
*/
|
|
40042
|
-
const
|
|
40043
|
-
|
|
40044
|
-
|
|
40045
|
-
|
|
40046
|
-
|
|
40047
|
-
|
|
40048
|
-
|
|
40049
|
-
|
|
40050
|
-
|
|
40051
|
-
|
|
40052
|
-
|
|
40053
|
-
|
|
40054
|
-
|
|
40055
|
-
|
|
40056
|
-
|
|
40057
|
-
|
|
40058
|
-
|
|
40059
|
-
|
|
40060
|
-
|
|
40061
|
-
|
|
40062
|
-
|
|
40063
|
-
|
|
40064
|
-
|
|
39974
|
+
const getComment = (commentId, callback) => {
|
|
39975
|
+
return liveObject(commentId, callback, 'commentId', getComment$1, [
|
|
39976
|
+
onCommentDeleteLocal,
|
|
39977
|
+
onCommentDeleted,
|
|
39978
|
+
onCommentFlagged,
|
|
39979
|
+
onCommentReactionAdded,
|
|
39980
|
+
onCommentReactionRemoved,
|
|
39981
|
+
onCommentUnflagged,
|
|
39982
|
+
onCommentUpdated,
|
|
39983
|
+
onLocalCommentReactionAdded,
|
|
39984
|
+
onLocalCommentReactionRemoved,
|
|
39985
|
+
]);
|
|
39986
|
+
};
|
|
39987
|
+
/* end_public_function */
|
|
39988
|
+
|
|
39989
|
+
class CommentPaginationController extends PaginationController {
|
|
39990
|
+
async getRequest(queryParams, token) {
|
|
39991
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
|
|
39992
|
+
const baseOptions = {
|
|
39993
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
39994
|
+
};
|
|
39995
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
39996
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
39997
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
40065
39998
|
});
|
|
39999
|
+
return queryResponse;
|
|
40066
40000
|
}
|
|
40067
|
-
|
|
40068
|
-
|
|
40069
|
-
|
|
40070
|
-
|
|
40071
|
-
|
|
40072
|
-
|
|
40073
|
-
|
|
40074
|
-
|
|
40075
|
-
|
|
40076
|
-
|
|
40077
|
-
|
|
40078
|
-
|
|
40079
|
-
|
|
40080
|
-
|
|
40081
|
-
|
|
40082
|
-
|
|
40083
|
-
|
|
40084
|
-
|
|
40085
|
-
|
|
40086
|
-
|
|
40087
|
-
|
|
40088
|
-
|
|
40001
|
+
}
|
|
40002
|
+
|
|
40003
|
+
var EnumCommentActions;
|
|
40004
|
+
(function (EnumCommentActions) {
|
|
40005
|
+
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
40006
|
+
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
40007
|
+
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
40008
|
+
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
40009
|
+
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
40010
|
+
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
40011
|
+
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
40012
|
+
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
40013
|
+
|
|
40014
|
+
class CommentQueryStreamController extends QueryStreamController {
|
|
40015
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40016
|
+
super(query, cacheKey);
|
|
40017
|
+
this.notifyChange = notifyChange;
|
|
40018
|
+
this.preparePayload = preparePayload;
|
|
40019
|
+
}
|
|
40020
|
+
async saveToMainDB(response) {
|
|
40021
|
+
const processedPayload = await this.preparePayload(response);
|
|
40022
|
+
const client = getActiveClient();
|
|
40023
|
+
const cachedAt = client.cache && Date.now();
|
|
40024
|
+
if (client.cache) {
|
|
40025
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
40026
|
+
}
|
|
40027
|
+
}
|
|
40028
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
40029
|
+
var _a, _b;
|
|
40030
|
+
if (refresh) {
|
|
40031
|
+
pushToCache(this.cacheKey, {
|
|
40032
|
+
data: response.comments.map(getResolver('comment')),
|
|
40089
40033
|
});
|
|
40090
40034
|
}
|
|
40035
|
+
else {
|
|
40036
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40037
|
+
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40038
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
|
|
40039
|
+
}
|
|
40091
40040
|
}
|
|
40092
|
-
|
|
40093
|
-
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
|
|
40098
|
-
|
|
40099
|
-
|
|
40100
|
-
|
|
40041
|
+
reactor(action) {
|
|
40042
|
+
return (comment) => {
|
|
40043
|
+
var _a;
|
|
40044
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40045
|
+
if (this.query.referenceId !== comment.referenceId ||
|
|
40046
|
+
this.query.referenceType !== comment.referenceType ||
|
|
40047
|
+
!collection) {
|
|
40048
|
+
return;
|
|
40049
|
+
}
|
|
40050
|
+
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
40051
|
+
return;
|
|
40052
|
+
}
|
|
40053
|
+
if (!this.query.parentId && comment.parentId) {
|
|
40054
|
+
return;
|
|
40055
|
+
}
|
|
40056
|
+
if (action === EnumCommentActions.OnCommentCreated) {
|
|
40057
|
+
collection.data = [...new Set([comment.commentId, ...collection.data])];
|
|
40058
|
+
}
|
|
40059
|
+
pushToCache(this.cacheKey, collection);
|
|
40060
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40061
|
+
};
|
|
40101
40062
|
}
|
|
40102
|
-
|
|
40103
|
-
|
|
40063
|
+
subscribeRTE(createSubscriber) {
|
|
40064
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40104
40065
|
}
|
|
40105
|
-
|
|
40106
|
-
};
|
|
40107
|
-
/* end_public_function */
|
|
40108
|
-
|
|
40109
|
-
/* begin_public_function
|
|
40110
|
-
id: comment.soft_delete
|
|
40111
|
-
*/
|
|
40112
|
-
/**
|
|
40113
|
-
* ```js
|
|
40114
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
40115
|
-
* const success = await CommentRepository.softDeleteComment('foobar')
|
|
40116
|
-
* ```
|
|
40117
|
-
*
|
|
40118
|
-
* Deletes a {@link Amity.Comment}
|
|
40119
|
-
*
|
|
40120
|
-
* @param commentId The {@link Amity.Comment} ID to delete
|
|
40121
|
-
* @return A success boolean if the {@link Amity.Comment} was deleted
|
|
40122
|
-
*
|
|
40123
|
-
* @category Comment API
|
|
40124
|
-
* @async
|
|
40125
|
-
*/
|
|
40126
|
-
const softDeleteComment = async (commentId) => {
|
|
40127
|
-
const client = getActiveClient();
|
|
40128
|
-
client.log('comment/softDeleteComment', commentId);
|
|
40129
|
-
const softDeleted = deleteComment(commentId);
|
|
40130
|
-
return softDeleted;
|
|
40131
|
-
};
|
|
40132
|
-
/* end_public_function */
|
|
40066
|
+
}
|
|
40133
40067
|
|
|
40134
|
-
/* begin_public_function
|
|
40135
|
-
id: comment.hard_delete
|
|
40136
|
-
*/
|
|
40137
40068
|
/**
|
|
40138
40069
|
* ```js
|
|
40139
|
-
* import {
|
|
40140
|
-
* const
|
|
40070
|
+
* import { onCommentCreated } from '@amityco/ts-sdk'
|
|
40071
|
+
* const dispose = onCommentCreated(comment => {
|
|
40072
|
+
* // ...
|
|
40073
|
+
* })
|
|
40141
40074
|
* ```
|
|
40142
40075
|
*
|
|
40143
|
-
*
|
|
40076
|
+
* Fired when a {@link Amity.InternalComment} has been created
|
|
40144
40077
|
*
|
|
40145
|
-
* @param
|
|
40146
|
-
* @
|
|
40078
|
+
* @param callback The function to call when the event was fired
|
|
40079
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40147
40080
|
*
|
|
40148
|
-
* @category Comment
|
|
40149
|
-
* @async
|
|
40081
|
+
* @category Comment Events
|
|
40150
40082
|
*/
|
|
40151
|
-
const
|
|
40152
|
-
|
|
40153
|
-
client.log('comment/hardDeleteComment', commentId);
|
|
40154
|
-
const hardDeleted = deleteComment(commentId, true);
|
|
40155
|
-
return hardDeleted;
|
|
40083
|
+
const onCommentCreatedLocal = (callback) => {
|
|
40084
|
+
return createLocalCommentEventSubscriber('local.comment.created', callback);
|
|
40156
40085
|
};
|
|
40157
|
-
/* end_public_function */
|
|
40158
40086
|
|
|
40159
|
-
|
|
40160
|
-
|
|
40161
|
-
|
|
40162
|
-
|
|
40163
|
-
|
|
40164
|
-
|
|
40165
|
-
|
|
40166
|
-
|
|
40167
|
-
|
|
40168
|
-
|
|
40169
|
-
* @param reason the reason to flag the comment
|
|
40170
|
-
* @returns the created report result
|
|
40171
|
-
*
|
|
40172
|
-
* @category Comment API
|
|
40173
|
-
* @async
|
|
40174
|
-
* */
|
|
40175
|
-
const flagComment = async (commentId, reason) => {
|
|
40176
|
-
const client = getActiveClient();
|
|
40177
|
-
client.log('comment/flagComment', commentId);
|
|
40178
|
-
const isPredefinedReason = reason &&
|
|
40179
|
-
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
40180
|
-
const body = {
|
|
40181
|
-
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
40182
|
-
detail: reason && !isPredefinedReason ? reason : '',
|
|
40183
|
-
};
|
|
40184
|
-
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
40185
|
-
if (client.cache) {
|
|
40186
|
-
ingestInCache(payload);
|
|
40087
|
+
class CommentLiveCollectionController extends LiveCollectionController {
|
|
40088
|
+
constructor(query, callback) {
|
|
40089
|
+
const queryStreamId = hash(query);
|
|
40090
|
+
const cacheKey = ['comments', 'collection', queryStreamId];
|
|
40091
|
+
const paginationController = new CommentPaginationController(query);
|
|
40092
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40093
|
+
this.query = query;
|
|
40094
|
+
this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
|
|
40095
|
+
this.callback = callback.bind(this);
|
|
40096
|
+
this.loadPage({ initial: true });
|
|
40187
40097
|
}
|
|
40188
|
-
|
|
40189
|
-
|
|
40190
|
-
|
|
40191
|
-
|
|
40098
|
+
setup() {
|
|
40099
|
+
var _a;
|
|
40100
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40101
|
+
if (!collection) {
|
|
40102
|
+
pushToCache(this.cacheKey, {
|
|
40103
|
+
data: [],
|
|
40104
|
+
params: {},
|
|
40105
|
+
});
|
|
40106
|
+
}
|
|
40107
|
+
}
|
|
40108
|
+
async persistModel(queryPayload) {
|
|
40109
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40110
|
+
}
|
|
40111
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40112
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40113
|
+
}
|
|
40114
|
+
startSubscription() {
|
|
40115
|
+
return this.queryStreamController.subscribeRTE([
|
|
40116
|
+
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
40117
|
+
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
40118
|
+
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
40119
|
+
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
40120
|
+
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
40121
|
+
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
40122
|
+
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
40123
|
+
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40124
|
+
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40125
|
+
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40126
|
+
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40127
|
+
]);
|
|
40128
|
+
}
|
|
40129
|
+
notifyChange({ origin, loading, error }) {
|
|
40130
|
+
var _a, _b;
|
|
40131
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40132
|
+
if (!collection)
|
|
40133
|
+
return;
|
|
40134
|
+
const data = this.applyFilter((_b = collection.data
|
|
40135
|
+
.map(id => pullFromCache(['comment', 'get', id]))
|
|
40136
|
+
.filter(isNonNullable)
|
|
40137
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
40138
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40139
|
+
return;
|
|
40140
|
+
this.callback({
|
|
40141
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40142
|
+
data,
|
|
40143
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40144
|
+
loading,
|
|
40145
|
+
error,
|
|
40146
|
+
});
|
|
40147
|
+
}
|
|
40148
|
+
applyFilter(data) {
|
|
40149
|
+
let comments = data;
|
|
40150
|
+
if (!this.query.includeDeleted) {
|
|
40151
|
+
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
40152
|
+
}
|
|
40153
|
+
if (this.query.parentId) {
|
|
40154
|
+
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
40155
|
+
}
|
|
40156
|
+
if (typeof this.query.hasFlag === 'boolean') {
|
|
40157
|
+
if (this.query.hasFlag) {
|
|
40158
|
+
comments = comments.filter(comment => comment.hashFlag != null);
|
|
40159
|
+
}
|
|
40160
|
+
else {
|
|
40161
|
+
comments = comments.filter(comment => comment.hashFlag == null);
|
|
40162
|
+
}
|
|
40163
|
+
}
|
|
40164
|
+
if (this.query.dataTypes) {
|
|
40165
|
+
if (this.query.dataTypes.matchType === 'exact') {
|
|
40166
|
+
comments = comments.filter(comment => {
|
|
40167
|
+
var _a, _b;
|
|
40168
|
+
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
40169
|
+
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
40170
|
+
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
40171
|
+
return false;
|
|
40172
|
+
}
|
|
40173
|
+
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
40174
|
+
});
|
|
40175
|
+
}
|
|
40176
|
+
if (this.query.dataTypes.matchType === 'any') {
|
|
40177
|
+
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
40178
|
+
}
|
|
40179
|
+
}
|
|
40180
|
+
switch (this.query.sortBy) {
|
|
40181
|
+
case 'firstCreated':
|
|
40182
|
+
comments = comments.sort(sortByFirstCreated);
|
|
40183
|
+
break;
|
|
40184
|
+
case 'lastCreated':
|
|
40185
|
+
default:
|
|
40186
|
+
comments = comments.sort(sortByLastCreated);
|
|
40187
|
+
break;
|
|
40188
|
+
}
|
|
40189
|
+
return comments;
|
|
40190
|
+
}
|
|
40191
|
+
}
|
|
40192
40192
|
|
|
40193
40193
|
/* begin_public_function
|
|
40194
|
-
id: comment.
|
|
40194
|
+
id: comment.query
|
|
40195
40195
|
*/
|
|
40196
40196
|
/**
|
|
40197
40197
|
* ```js
|
|
40198
|
-
* import {
|
|
40199
|
-
*
|
|
40198
|
+
* import { getComments } from '@amityco/ts-sdk'
|
|
40199
|
+
*
|
|
40200
|
+
* let comments = []
|
|
40201
|
+
* const unsub = getComments({
|
|
40202
|
+
* referenceType: Amity.InternalComment['referenceType'];
|
|
40203
|
+
* referenceId: Amity.InternalComment['referenceId'];
|
|
40204
|
+
* }, response => merge(comments, response.data))
|
|
40200
40205
|
* ```
|
|
40201
40206
|
*
|
|
40202
|
-
*
|
|
40203
|
-
* @returns the unflagged result
|
|
40207
|
+
* Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
|
|
40204
40208
|
*
|
|
40205
|
-
* @
|
|
40206
|
-
* @
|
|
40207
|
-
*
|
|
40208
|
-
|
|
40209
|
-
|
|
40210
|
-
|
|
40211
|
-
|
|
40212
|
-
|
|
40213
|
-
|
|
40209
|
+
* @param referenceType the type of the target
|
|
40210
|
+
* @param referenceId the ID of the target
|
|
40211
|
+
* @param callback the function to call when new data are available
|
|
40212
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40213
|
+
*
|
|
40214
|
+
* @category Comments Live Collection
|
|
40215
|
+
*/
|
|
40216
|
+
const getComments = (params, callback, config) => {
|
|
40217
|
+
const { log, cache } = getActiveClient();
|
|
40218
|
+
if (!cache) {
|
|
40219
|
+
console.log('For using Live Collection feature you need to enable Cache!');
|
|
40214
40220
|
}
|
|
40215
|
-
|
|
40216
|
-
|
|
40221
|
+
const timestamp = Date.now();
|
|
40222
|
+
log(`getComments(tmpid: ${timestamp}) > listen`);
|
|
40223
|
+
const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
|
|
40224
|
+
const disposers = commentsLiveCollection.startSubscription();
|
|
40225
|
+
const cacheKey = commentsLiveCollection.getCacheKey();
|
|
40226
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40227
|
+
return () => {
|
|
40228
|
+
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
40229
|
+
disposers.forEach(fn => fn());
|
|
40230
|
+
};
|
|
40217
40231
|
};
|
|
40218
40232
|
/* end_public_function */
|
|
40219
40233
|
|
|
40220
|
-
|
|
40221
|
-
|
|
40222
|
-
|
|
40223
|
-
|
|
40224
|
-
|
|
40225
|
-
|
|
40226
|
-
|
|
40227
|
-
|
|
40228
|
-
|
|
40229
|
-
|
|
40230
|
-
|
|
40231
|
-
|
|
40232
|
-
|
|
40233
|
-
|
|
40234
|
-
|
|
40235
|
-
|
|
40236
|
-
|
|
40237
|
-
|
|
40238
|
-
|
|
40239
|
-
|
|
40240
|
-
};
|
|
40241
|
-
/* end_public_function */
|
|
40234
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
40235
|
+
__proto__: null,
|
|
40236
|
+
getCommentByIds: getCommentByIds,
|
|
40237
|
+
createComment: createComment,
|
|
40238
|
+
updateComment: updateComment,
|
|
40239
|
+
deleteComment: deleteComment,
|
|
40240
|
+
softDeleteComment: softDeleteComment,
|
|
40241
|
+
hardDeleteComment: hardDeleteComment,
|
|
40242
|
+
flagComment: flagComment,
|
|
40243
|
+
unflagComment: unflagComment,
|
|
40244
|
+
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
40245
|
+
onCommentCreated: onCommentCreated,
|
|
40246
|
+
onCommentUpdated: onCommentUpdated,
|
|
40247
|
+
onCommentDeleted: onCommentDeleted,
|
|
40248
|
+
onCommentFlagged: onCommentFlagged,
|
|
40249
|
+
onCommentUnflagged: onCommentUnflagged,
|
|
40250
|
+
onCommentReactionAdded: onCommentReactionAdded,
|
|
40251
|
+
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
40252
|
+
getComment: getComment,
|
|
40253
|
+
getComments: getComments
|
|
40254
|
+
});
|
|
40242
40255
|
|
|
40243
|
-
const
|
|
40256
|
+
const getPost$1 = async (postId) => {
|
|
40244
40257
|
const client = getActiveClient();
|
|
40245
|
-
client.log('
|
|
40246
|
-
isInTombstone('
|
|
40247
|
-
let
|
|
40258
|
+
client.log('post/getPost', postId);
|
|
40259
|
+
isInTombstone('post', postId);
|
|
40260
|
+
let payload;
|
|
40248
40261
|
try {
|
|
40249
40262
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
40250
|
-
const response = await client.http.get(`/api/v3/
|
|
40251
|
-
|
|
40263
|
+
const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
|
|
40264
|
+
payload = response.data;
|
|
40252
40265
|
}
|
|
40253
40266
|
catch (error) {
|
|
40254
40267
|
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40255
|
-
pushToTombstone('
|
|
40268
|
+
pushToTombstone('post', postId);
|
|
40256
40269
|
}
|
|
40257
40270
|
throw error;
|
|
40258
40271
|
}
|
|
40272
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40259
40273
|
const cachedAt = client.cache && Date.now();
|
|
40260
40274
|
if (client.cache)
|
|
40261
40275
|
ingestInCache(data, { cachedAt });
|
|
40262
|
-
const {
|
|
40276
|
+
const { posts } = data;
|
|
40277
|
+
const result = posts.find(post => post.postId === postId);
|
|
40263
40278
|
return {
|
|
40264
|
-
data:
|
|
40279
|
+
data: result,
|
|
40265
40280
|
cachedAt,
|
|
40266
40281
|
};
|
|
40267
40282
|
};
|
|
40268
|
-
|
|
40283
|
+
getPost$1.locally = (postId) => {
|
|
40269
40284
|
const client = getActiveClient();
|
|
40270
|
-
client.log('
|
|
40285
|
+
client.log('post/getPost.locally', postId);
|
|
40271
40286
|
if (!client.cache)
|
|
40272
40287
|
return;
|
|
40273
|
-
const cached = pullFromCache(['
|
|
40288
|
+
const cached = pullFromCache(['post', 'get', postId]);
|
|
40274
40289
|
if (!cached)
|
|
40275
40290
|
return;
|
|
40276
40291
|
return {
|
|
@@ -40281,142 +40296,245 @@ getComment$1.locally = (commentId) => {
|
|
|
40281
40296
|
|
|
40282
40297
|
/**
|
|
40283
40298
|
* ```js
|
|
40284
|
-
* import {
|
|
40285
|
-
* const dispose =
|
|
40299
|
+
* import { onLocalPostDeleted } from '@amityco/ts-sdk'
|
|
40300
|
+
* const dispose = onLocalPostDeleted(post => {
|
|
40286
40301
|
* // ...
|
|
40287
40302
|
* })
|
|
40288
40303
|
* ```
|
|
40289
40304
|
*
|
|
40290
|
-
* Fired when a {@link Amity.
|
|
40305
|
+
* Fired when a {@link Amity.InternalPost} has been deleted
|
|
40291
40306
|
*
|
|
40292
40307
|
* @param callback The function to call when the event was fired
|
|
40293
40308
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40294
40309
|
*
|
|
40295
|
-
* @category
|
|
40310
|
+
* @category Post Events
|
|
40296
40311
|
*/
|
|
40297
|
-
const
|
|
40312
|
+
const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
|
|
40298
40313
|
|
|
40299
40314
|
/**
|
|
40300
40315
|
* ```js
|
|
40301
|
-
* import {
|
|
40302
|
-
* const dispose =
|
|
40316
|
+
* import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
|
|
40317
|
+
* const dispose = onPostReactionAdded(post => {
|
|
40303
40318
|
* // ...
|
|
40304
40319
|
* })
|
|
40305
40320
|
* ```
|
|
40306
40321
|
*
|
|
40307
|
-
* Fired when a {@link Amity.
|
|
40322
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
40308
40323
|
*
|
|
40309
40324
|
* @param callback The function to call when the event was fired
|
|
40310
40325
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40311
40326
|
*
|
|
40312
|
-
* @category
|
|
40327
|
+
* @category Post Events
|
|
40313
40328
|
*/
|
|
40314
|
-
const
|
|
40329
|
+
const onLocalPostReactionAdded = (callback) => {
|
|
40315
40330
|
const client = getActiveClient();
|
|
40316
|
-
const filter = ({
|
|
40331
|
+
const filter = ({ post }) => {
|
|
40317
40332
|
if (!client.cache) {
|
|
40318
|
-
callback(
|
|
40333
|
+
callback(post);
|
|
40319
40334
|
}
|
|
40320
40335
|
else {
|
|
40321
|
-
upsertInCache(['
|
|
40322
|
-
callback(
|
|
40336
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
40337
|
+
callback(post);
|
|
40323
40338
|
}
|
|
40324
40339
|
};
|
|
40325
|
-
return createEventSubscriber(client, 'local.
|
|
40340
|
+
return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
|
|
40326
40341
|
};
|
|
40327
40342
|
|
|
40328
40343
|
/**
|
|
40329
40344
|
* ```js
|
|
40330
|
-
* import {
|
|
40331
|
-
* const dispose =
|
|
40345
|
+
* import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
|
|
40346
|
+
* const dispose = onPostReactionRemoved(post => {
|
|
40332
40347
|
* // ...
|
|
40333
40348
|
* })
|
|
40334
40349
|
* ```
|
|
40335
40350
|
*
|
|
40336
|
-
* Fired when a {@link Amity.
|
|
40351
|
+
* Fired when a {@link Amity.InternalPost} has been reacted
|
|
40337
40352
|
*
|
|
40338
40353
|
* @param callback The function to call when the event was fired
|
|
40339
40354
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40340
40355
|
*
|
|
40341
|
-
* @category
|
|
40356
|
+
* @category Post Events
|
|
40342
40357
|
*/
|
|
40343
|
-
const
|
|
40358
|
+
const onLocalPostReactionRemoved = (callback) => {
|
|
40344
40359
|
const client = getActiveClient();
|
|
40345
|
-
const filter = ({
|
|
40360
|
+
const filter = ({ post }) => {
|
|
40346
40361
|
if (!client.cache) {
|
|
40347
|
-
callback(
|
|
40362
|
+
callback(post);
|
|
40348
40363
|
}
|
|
40349
40364
|
else {
|
|
40350
|
-
upsertInCache(['
|
|
40351
|
-
callback(
|
|
40365
|
+
upsertInCache(['post', 'get', post.postId], post);
|
|
40366
|
+
callback(post);
|
|
40352
40367
|
}
|
|
40353
40368
|
};
|
|
40354
|
-
return createEventSubscriber(client, 'local.
|
|
40369
|
+
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
40355
40370
|
};
|
|
40356
40371
|
|
|
40357
|
-
/* begin_public_function
|
|
40358
|
-
id: comment.get
|
|
40359
|
-
*/
|
|
40360
40372
|
/**
|
|
40361
40373
|
* ```js
|
|
40362
|
-
* import {
|
|
40363
|
-
*
|
|
40364
|
-
*
|
|
40365
|
-
*
|
|
40366
|
-
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
40367
|
-
* comment = response.data;
|
|
40368
|
-
* });
|
|
40374
|
+
* import { onPostUpdatedLocal } from '@amityco/ts-sdk'
|
|
40375
|
+
* const dispose = onPostUpdatedLocal(post => {
|
|
40376
|
+
* // ...
|
|
40377
|
+
* })
|
|
40369
40378
|
* ```
|
|
40370
40379
|
*
|
|
40371
|
-
*
|
|
40380
|
+
* Fired when a {@link Amity.InternalPost} has been updated
|
|
40372
40381
|
*
|
|
40373
|
-
* @param
|
|
40374
|
-
* @
|
|
40375
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
40382
|
+
* @param callback The function to call when the event was fired
|
|
40383
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
40376
40384
|
*
|
|
40377
|
-
* @category
|
|
40385
|
+
* @category Post Events
|
|
40378
40386
|
*/
|
|
40379
|
-
const
|
|
40380
|
-
|
|
40381
|
-
|
|
40387
|
+
const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
|
|
40388
|
+
|
|
40389
|
+
const commentEventHandler$1 = (callback, eventHandler, cacheKey) => {
|
|
40390
|
+
return eventHandler(async (comment) => {
|
|
40391
|
+
var _a;
|
|
40392
|
+
const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40393
|
+
if (!currentCollection || !currentCollection.data.includes(comment.referenceId))
|
|
40394
|
+
return;
|
|
40395
|
+
await getPost$1(comment.referenceId);
|
|
40396
|
+
callback(comment);
|
|
40397
|
+
});
|
|
40398
|
+
};
|
|
40399
|
+
const generateCommentSubscriptions$1 = (cacheKey) => {
|
|
40400
|
+
const eventHandlers = [
|
|
40401
|
+
onCommentCreated,
|
|
40382
40402
|
onCommentDeleted,
|
|
40383
|
-
onCommentFlagged,
|
|
40384
40403
|
onCommentReactionAdded,
|
|
40385
40404
|
onCommentReactionRemoved,
|
|
40386
|
-
|
|
40387
|
-
|
|
40405
|
+
onCommentCreatedLocal,
|
|
40406
|
+
onCommentDeleteLocal,
|
|
40388
40407
|
onLocalCommentReactionAdded,
|
|
40389
40408
|
onLocalCommentReactionRemoved,
|
|
40390
|
-
]
|
|
40409
|
+
];
|
|
40410
|
+
return eventHandlers.map(handler => ({
|
|
40411
|
+
fn: convertEventPayload((callback) => commentEventHandler$1(callback, handler, cacheKey), 'referenceId', 'post'),
|
|
40412
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40413
|
+
}));
|
|
40414
|
+
};
|
|
40415
|
+
const getGlobalFeedSubscriptions = (cacheKey) => {
|
|
40416
|
+
return [
|
|
40417
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
40418
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
40419
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
40420
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40421
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
40422
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
40423
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
40424
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
40425
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40426
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40427
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40428
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40429
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40430
|
+
...generateCommentSubscriptions$1(cacheKey),
|
|
40431
|
+
];
|
|
40432
|
+
};
|
|
40433
|
+
|
|
40434
|
+
class CustomRankingGlobalFeedLiveCollectionController extends LiveCollectionController {
|
|
40435
|
+
constructor(query, callback) {
|
|
40436
|
+
const queryStreamId = hash(query);
|
|
40437
|
+
const cacheKey = ['customRankingGlobalFeed', 'collection', queryStreamId];
|
|
40438
|
+
const paginationController = new CustomRankingGlobalFeedPaginationController(query);
|
|
40439
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40440
|
+
this.query = query;
|
|
40441
|
+
this.queryStreamController = new CustomRankingGlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40442
|
+
this.callback = callback.bind(this);
|
|
40443
|
+
this.loadPage({ initial: true });
|
|
40444
|
+
}
|
|
40445
|
+
setup() {
|
|
40446
|
+
var _a;
|
|
40447
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40448
|
+
if (!collection) {
|
|
40449
|
+
pushToCache(this.cacheKey, {
|
|
40450
|
+
data: [],
|
|
40451
|
+
params: {},
|
|
40452
|
+
});
|
|
40453
|
+
}
|
|
40454
|
+
}
|
|
40455
|
+
async persistModel(queryPayload) {
|
|
40456
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40457
|
+
}
|
|
40458
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40459
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40460
|
+
}
|
|
40461
|
+
startSubscription() {
|
|
40462
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
40463
|
+
}
|
|
40464
|
+
notifyChange({ origin, loading, error }) {
|
|
40465
|
+
var _a, _b;
|
|
40466
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40467
|
+
if (!collection)
|
|
40468
|
+
return;
|
|
40469
|
+
const data = ((_b = collection.data
|
|
40470
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40471
|
+
.filter(isNonNullable)
|
|
40472
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40473
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40474
|
+
return;
|
|
40475
|
+
this.callback({
|
|
40476
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40477
|
+
data,
|
|
40478
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40479
|
+
loading,
|
|
40480
|
+
error,
|
|
40481
|
+
});
|
|
40482
|
+
}
|
|
40483
|
+
}
|
|
40484
|
+
|
|
40485
|
+
/* begin_public_function
|
|
40486
|
+
id: feed.query.custom_ranking_feed
|
|
40487
|
+
*/
|
|
40488
|
+
/**
|
|
40489
|
+
* ```js
|
|
40490
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
40491
|
+
*
|
|
40492
|
+
* let posts = []
|
|
40493
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
40494
|
+
* dataTypes: ['video','image'],
|
|
40495
|
+
* resolveParent: true,
|
|
40496
|
+
* }, response => processResponse(response))
|
|
40497
|
+
* ```
|
|
40498
|
+
*
|
|
40499
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
40500
|
+
*
|
|
40501
|
+
* @param params.dataTypes array of data types for the posts
|
|
40502
|
+
* @param callback the function to call when new data are available
|
|
40503
|
+
* @param config
|
|
40504
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40505
|
+
*
|
|
40506
|
+
* @category Posts Live Collection
|
|
40507
|
+
*/
|
|
40508
|
+
const getCustomRankingGlobalFeed = (params, callback, config) => {
|
|
40509
|
+
const { log, cache } = getActiveClient();
|
|
40510
|
+
if (!cache) {
|
|
40511
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
40512
|
+
}
|
|
40513
|
+
const timestamp = Date.now();
|
|
40514
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
40515
|
+
const liveCollection = new CustomRankingGlobalFeedLiveCollectionController(params, callback);
|
|
40516
|
+
const disposers = liveCollection.startSubscription();
|
|
40517
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
40518
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40519
|
+
return () => {
|
|
40520
|
+
log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
40521
|
+
disposers.forEach(fn => fn());
|
|
40522
|
+
};
|
|
40391
40523
|
};
|
|
40392
40524
|
/* end_public_function */
|
|
40393
40525
|
|
|
40394
|
-
class
|
|
40526
|
+
class GlobalFeedPaginationController extends PaginationController {
|
|
40395
40527
|
async getRequest(queryParams, token) {
|
|
40396
|
-
const { limit
|
|
40397
|
-
const
|
|
40398
|
-
|
|
40399
|
-
|
|
40400
|
-
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
40401
|
-
const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
|
|
40402
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
|
|
40528
|
+
const { limit, resolveParent } = queryParams, params = __rest(queryParams, ["limit", "resolveParent"]);
|
|
40529
|
+
const options = token ? { token } : { limit };
|
|
40530
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/me/global-feeds`, {
|
|
40531
|
+
params: Object.assign(Object.assign({}, params), { resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
|
|
40403
40532
|
});
|
|
40404
40533
|
return queryResponse;
|
|
40405
40534
|
}
|
|
40406
40535
|
}
|
|
40407
40536
|
|
|
40408
|
-
|
|
40409
|
-
(function (EnumCommentActions) {
|
|
40410
|
-
EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
|
|
40411
|
-
EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
|
|
40412
|
-
EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
|
|
40413
|
-
EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
|
|
40414
|
-
EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
|
|
40415
|
-
EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
|
|
40416
|
-
EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
|
|
40417
|
-
})(EnumCommentActions || (EnumCommentActions = {}));
|
|
40418
|
-
|
|
40419
|
-
class CommentQueryStreamController extends QueryStreamController {
|
|
40537
|
+
class GlobalFeedQueryStreamController extends QueryStreamController {
|
|
40420
40538
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40421
40539
|
super(query, cacheKey);
|
|
40422
40540
|
this.notifyChange = notifyChange;
|
|
@@ -40434,321 +40552,848 @@ class CommentQueryStreamController extends QueryStreamController {
|
|
|
40434
40552
|
var _a, _b;
|
|
40435
40553
|
if (refresh) {
|
|
40436
40554
|
pushToCache(this.cacheKey, {
|
|
40437
|
-
data: response.
|
|
40555
|
+
data: response.posts.map(getResolver('post')),
|
|
40438
40556
|
});
|
|
40439
40557
|
}
|
|
40440
40558
|
else {
|
|
40441
40559
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40442
|
-
const
|
|
40443
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...
|
|
40560
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40561
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
40444
40562
|
}
|
|
40445
40563
|
}
|
|
40446
40564
|
reactor(action) {
|
|
40447
|
-
return (
|
|
40565
|
+
return (post) => {
|
|
40448
40566
|
var _a;
|
|
40449
40567
|
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40450
|
-
if (
|
|
40451
|
-
this.query.referenceType !== comment.referenceType ||
|
|
40452
|
-
!collection) {
|
|
40568
|
+
if (!collection)
|
|
40453
40569
|
return;
|
|
40454
|
-
|
|
40455
|
-
if (this.query.parentId && this.query.parentId !== comment.parentId) {
|
|
40570
|
+
if (post.parentPostId && !collection.data.includes(post.parentPostId))
|
|
40456
40571
|
return;
|
|
40572
|
+
// Delete Action
|
|
40573
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
40574
|
+
// Parent Post - Remove from collection
|
|
40575
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40457
40576
|
}
|
|
40458
|
-
if (
|
|
40577
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
40578
|
+
// If the query has dataTypes array with value, check if post.dataType is include in the array
|
|
40579
|
+
if (this.query.dataTypes && this.query.dataTypes.length > 0) {
|
|
40580
|
+
if (!this.query.dataTypes.includes(post.dataType))
|
|
40581
|
+
return;
|
|
40582
|
+
}
|
|
40583
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
40584
|
+
}
|
|
40585
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
40586
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40587
|
+
}
|
|
40588
|
+
pushToCache(this.cacheKey, collection);
|
|
40589
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40590
|
+
};
|
|
40591
|
+
}
|
|
40592
|
+
subscribeRTE(createSubscriber) {
|
|
40593
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40594
|
+
}
|
|
40595
|
+
}
|
|
40596
|
+
|
|
40597
|
+
class GlobalFeedLiveCollectionController extends LiveCollectionController {
|
|
40598
|
+
constructor(query, callback) {
|
|
40599
|
+
const queryStreamId = hash(query);
|
|
40600
|
+
const cacheKey = ['globalFeed', 'collection', queryStreamId];
|
|
40601
|
+
const paginationController = new GlobalFeedPaginationController(query);
|
|
40602
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40603
|
+
this.query = query;
|
|
40604
|
+
this.queryStreamController = new GlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40605
|
+
this.callback = callback.bind(this);
|
|
40606
|
+
this.loadPage({ initial: true });
|
|
40607
|
+
}
|
|
40608
|
+
setup() {
|
|
40609
|
+
var _a;
|
|
40610
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40611
|
+
if (!collection) {
|
|
40612
|
+
pushToCache(this.cacheKey, {
|
|
40613
|
+
data: [],
|
|
40614
|
+
params: {},
|
|
40615
|
+
});
|
|
40616
|
+
}
|
|
40617
|
+
}
|
|
40618
|
+
async persistModel(queryPayload) {
|
|
40619
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40620
|
+
}
|
|
40621
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40622
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40623
|
+
}
|
|
40624
|
+
startSubscription() {
|
|
40625
|
+
return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
|
|
40626
|
+
}
|
|
40627
|
+
notifyChange({ origin, loading, error }) {
|
|
40628
|
+
var _a, _b;
|
|
40629
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40630
|
+
if (!collection)
|
|
40631
|
+
return;
|
|
40632
|
+
const data = ((_b = collection.data
|
|
40633
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40634
|
+
.filter(isNonNullable)
|
|
40635
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40636
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40637
|
+
return;
|
|
40638
|
+
this.callback({
|
|
40639
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40640
|
+
data,
|
|
40641
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40642
|
+
loading,
|
|
40643
|
+
error,
|
|
40644
|
+
});
|
|
40645
|
+
}
|
|
40646
|
+
}
|
|
40647
|
+
|
|
40648
|
+
/* begin_public_function
|
|
40649
|
+
id: feed.query.global_feed
|
|
40650
|
+
*/
|
|
40651
|
+
/**
|
|
40652
|
+
* ```js
|
|
40653
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
40654
|
+
*
|
|
40655
|
+
* let posts = []
|
|
40656
|
+
* const unsub = FeedRepository.getGlobalFeed({
|
|
40657
|
+
* dataTypes: ['video','image'],
|
|
40658
|
+
* resolveParent: true,
|
|
40659
|
+
* }, response => processResponse(response))
|
|
40660
|
+
* ```
|
|
40661
|
+
*
|
|
40662
|
+
* Observe all mutations on a list of {@link Amity.Post} for global feed
|
|
40663
|
+
* @param params.dataTypes array of data types for the posts
|
|
40664
|
+
* @param params.resolveParent
|
|
40665
|
+
* @param callback the function to call when new data are available
|
|
40666
|
+
* @param config
|
|
40667
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40668
|
+
*
|
|
40669
|
+
* @category Posts Live Collection
|
|
40670
|
+
*/
|
|
40671
|
+
const getGlobalFeed = (params, callback, config) => {
|
|
40672
|
+
const { log, cache } = getActiveClient();
|
|
40673
|
+
if (!cache) {
|
|
40674
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
40675
|
+
}
|
|
40676
|
+
const timestamp = Date.now();
|
|
40677
|
+
log(`getGlobalFeed(tmpid: ${timestamp}) > listen`);
|
|
40678
|
+
const liveCollection = new GlobalFeedLiveCollectionController(params, callback);
|
|
40679
|
+
const disposers = liveCollection.startSubscription();
|
|
40680
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
40681
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40682
|
+
return () => {
|
|
40683
|
+
log(`getGlobalFeed(tmpid: ${timestamp}) > dispose`);
|
|
40684
|
+
disposers.forEach(fn => fn());
|
|
40685
|
+
};
|
|
40686
|
+
};
|
|
40687
|
+
/* end_public_function */
|
|
40688
|
+
|
|
40689
|
+
class UserFeedPaginationController extends PaginationController {
|
|
40690
|
+
async getRequest(queryParams, token) {
|
|
40691
|
+
const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit"]);
|
|
40692
|
+
const options = token ? { token } : { limit };
|
|
40693
|
+
const { data: queryResponse } = await this.http.get(`/api/v4/user-feeds/${userId}`, {
|
|
40694
|
+
params: Object.assign(Object.assign({}, params), { options, dataTypes: (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) ? dataTypes : undefined, includePostedFeed: feedSources, isDeleted: inferIsDeleted(includeDeleted), matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) }),
|
|
40695
|
+
});
|
|
40696
|
+
return queryResponse;
|
|
40697
|
+
}
|
|
40698
|
+
}
|
|
40699
|
+
|
|
40700
|
+
class UserFeedQueryStreamController extends QueryStreamController {
|
|
40701
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40702
|
+
super(query, cacheKey);
|
|
40703
|
+
this.notifyChange = notifyChange;
|
|
40704
|
+
this.preparePayload = preparePayload;
|
|
40705
|
+
}
|
|
40706
|
+
async saveToMainDB(response) {
|
|
40707
|
+
const processedPayload = await this.preparePayload(response);
|
|
40708
|
+
const client = getActiveClient();
|
|
40709
|
+
const cachedAt = client.cache && Date.now();
|
|
40710
|
+
if (client.cache) {
|
|
40711
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
40712
|
+
}
|
|
40713
|
+
}
|
|
40714
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
40715
|
+
var _a, _b;
|
|
40716
|
+
if (refresh) {
|
|
40717
|
+
pushToCache(this.cacheKey, {
|
|
40718
|
+
data: response.posts.map(getResolver('post')),
|
|
40719
|
+
});
|
|
40720
|
+
}
|
|
40721
|
+
else {
|
|
40722
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40723
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
40724
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
40725
|
+
}
|
|
40726
|
+
}
|
|
40727
|
+
reactor(action) {
|
|
40728
|
+
return (post) => {
|
|
40729
|
+
var _a, _b;
|
|
40730
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40731
|
+
if (!collection)
|
|
40459
40732
|
return;
|
|
40733
|
+
// if the collection is parent post collection and
|
|
40734
|
+
// post is not included in the collection or post is child post
|
|
40735
|
+
if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
|
|
40736
|
+
!collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
|
|
40737
|
+
return;
|
|
40738
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
40739
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40460
40740
|
}
|
|
40461
|
-
if (
|
|
40462
|
-
|
|
40741
|
+
if (post.parentPostId && post.isDeleted) {
|
|
40742
|
+
const parentPost = (_b = pullFromCache([
|
|
40743
|
+
'post',
|
|
40744
|
+
'get',
|
|
40745
|
+
post.parentPostId,
|
|
40746
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
40747
|
+
if (!parentPost)
|
|
40748
|
+
return;
|
|
40749
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
40750
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
40751
|
+
}
|
|
40752
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
40753
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
40754
|
+
}
|
|
40755
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
40756
|
+
if (this.query.dataTypes &&
|
|
40757
|
+
this.query.dataTypes.length > 0 &&
|
|
40758
|
+
!this.query.dataTypes.includes(post.dataType)) {
|
|
40759
|
+
return;
|
|
40760
|
+
}
|
|
40761
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
40463
40762
|
}
|
|
40464
40763
|
pushToCache(this.cacheKey, collection);
|
|
40465
40764
|
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
40466
40765
|
};
|
|
40467
40766
|
}
|
|
40468
|
-
subscribeRTE(createSubscriber) {
|
|
40469
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40767
|
+
subscribeRTE(createSubscriber) {
|
|
40768
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
40769
|
+
}
|
|
40770
|
+
}
|
|
40771
|
+
|
|
40772
|
+
class UserFeedLiveCollectionController extends LiveCollectionController {
|
|
40773
|
+
constructor(query, callback) {
|
|
40774
|
+
const queryStreamId = hash(query);
|
|
40775
|
+
const cacheKey = ['userFeed', 'collection', queryStreamId];
|
|
40776
|
+
const paginationController = new UserFeedPaginationController(query);
|
|
40777
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
40778
|
+
this.query = query;
|
|
40779
|
+
this.queryStreamController = new UserFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
40780
|
+
this.callback = callback.bind(this);
|
|
40781
|
+
this.loadPage({ initial: true });
|
|
40782
|
+
}
|
|
40783
|
+
setup() {
|
|
40784
|
+
var _a;
|
|
40785
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40786
|
+
if (!collection) {
|
|
40787
|
+
pushToCache(this.cacheKey, {
|
|
40788
|
+
data: [],
|
|
40789
|
+
params: {},
|
|
40790
|
+
});
|
|
40791
|
+
}
|
|
40792
|
+
}
|
|
40793
|
+
async persistModel(queryPayload) {
|
|
40794
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
40795
|
+
}
|
|
40796
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
40797
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40798
|
+
}
|
|
40799
|
+
startSubscription() {
|
|
40800
|
+
return this.queryStreamController.subscribeRTE([
|
|
40801
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
40802
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
40803
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
40804
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40805
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
40806
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
40807
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
40808
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
40809
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40810
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40811
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
40812
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
40813
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
40814
|
+
{
|
|
40815
|
+
fn: convertEventPayload((callback) => {
|
|
40816
|
+
return onCommentCreated(async (comment) => {
|
|
40817
|
+
var _a;
|
|
40818
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40819
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
40820
|
+
return;
|
|
40821
|
+
await getPost$1(comment.referenceId);
|
|
40822
|
+
callback(comment);
|
|
40823
|
+
});
|
|
40824
|
+
}, 'referenceId', 'post'),
|
|
40825
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40826
|
+
},
|
|
40827
|
+
{
|
|
40828
|
+
fn: convertEventPayload((callback) => {
|
|
40829
|
+
return onCommentDeleted(async (comment) => {
|
|
40830
|
+
var _a;
|
|
40831
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40832
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
40833
|
+
return;
|
|
40834
|
+
await getPost$1(comment.referenceId);
|
|
40835
|
+
callback(comment);
|
|
40836
|
+
});
|
|
40837
|
+
}, 'referenceId', 'post'),
|
|
40838
|
+
action: EnumPostActions.OnPostUpdated,
|
|
40839
|
+
},
|
|
40840
|
+
]);
|
|
40841
|
+
}
|
|
40842
|
+
notifyChange({ origin, loading, error }) {
|
|
40843
|
+
var _a, _b;
|
|
40844
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40845
|
+
if (!collection)
|
|
40846
|
+
return;
|
|
40847
|
+
const data = ((_b = collection.data
|
|
40848
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
40849
|
+
.filter(isNonNullable)
|
|
40850
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
40851
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
40852
|
+
return;
|
|
40853
|
+
this.callback({
|
|
40854
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40855
|
+
data,
|
|
40856
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40857
|
+
loading,
|
|
40858
|
+
error,
|
|
40859
|
+
});
|
|
40860
|
+
}
|
|
40861
|
+
}
|
|
40862
|
+
|
|
40863
|
+
/* begin_public_function
|
|
40864
|
+
id: feed.query.user_feed
|
|
40865
|
+
*/
|
|
40866
|
+
/**
|
|
40867
|
+
* ```js
|
|
40868
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
40869
|
+
*
|
|
40870
|
+
* let posts = []
|
|
40871
|
+
* const unsubscribe = FeedRepository.getUserFeed({
|
|
40872
|
+
* userId: string,
|
|
40873
|
+
* feedSources: ['user', 'community'],
|
|
40874
|
+
* }, response => response => processResponse(response))
|
|
40875
|
+
* ```
|
|
40876
|
+
*
|
|
40877
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given user and feedSources
|
|
40878
|
+
*
|
|
40879
|
+
* @param params.userId the ID of the user
|
|
40880
|
+
* @param params.feedSources the sources of the feed
|
|
40881
|
+
* @param callback the function to call when new data are available
|
|
40882
|
+
* @param config
|
|
40883
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
40884
|
+
*
|
|
40885
|
+
* @category Posts Live Collection
|
|
40886
|
+
*/
|
|
40887
|
+
const getUserFeed = (params, callback, config) => {
|
|
40888
|
+
const { log, cache } = getActiveClient();
|
|
40889
|
+
if (!cache) {
|
|
40890
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
40891
|
+
}
|
|
40892
|
+
const timestamp = Date.now();
|
|
40893
|
+
log(`getUserFeed(tmpid: ${timestamp}) > listen`);
|
|
40894
|
+
const userFeedLiveCollection = new UserFeedLiveCollectionController(params, callback);
|
|
40895
|
+
const disposers = userFeedLiveCollection.startSubscription();
|
|
40896
|
+
const cacheKey = userFeedLiveCollection.getCacheKey();
|
|
40897
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
40898
|
+
return () => {
|
|
40899
|
+
log(`getUserFeed(tmpid: ${timestamp}) > dispose`);
|
|
40900
|
+
disposers.forEach(fn => fn());
|
|
40901
|
+
};
|
|
40902
|
+
};
|
|
40903
|
+
/* end_public_function */
|
|
40904
|
+
|
|
40905
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
40906
|
+
__proto__: null,
|
|
40907
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
40908
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
40909
|
+
getGlobalFeed: getGlobalFeed,
|
|
40910
|
+
getUserFeed: getUserFeed
|
|
40911
|
+
});
|
|
40912
|
+
|
|
40913
|
+
/* begin_public_function
|
|
40914
|
+
id: post.get_by_ids
|
|
40915
|
+
*/
|
|
40916
|
+
/**
|
|
40917
|
+
* ```js
|
|
40918
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
40919
|
+
* const { data: posts } = await getPostByIds(['foo', 'bar'])
|
|
40920
|
+
* ```
|
|
40921
|
+
*
|
|
40922
|
+
* Fetches a collection of {@link Amity.Post} objects
|
|
40923
|
+
*
|
|
40924
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
40925
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
40926
|
+
*
|
|
40927
|
+
* @category Post API
|
|
40928
|
+
* @async
|
|
40929
|
+
*/
|
|
40930
|
+
const getPostByIds = async (postIds) => {
|
|
40931
|
+
const client = getActiveClient();
|
|
40932
|
+
client.log('post/getPostByIds', postIds);
|
|
40933
|
+
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
40934
|
+
let payload;
|
|
40935
|
+
try {
|
|
40936
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
40937
|
+
const response = await client.http.get(`/api/v3/posts/list`, {
|
|
40938
|
+
params: { postIds: encodedPostIds },
|
|
40939
|
+
});
|
|
40940
|
+
payload = response.data;
|
|
40941
|
+
}
|
|
40942
|
+
catch (error) {
|
|
40943
|
+
postIds.forEach(postId => {
|
|
40944
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40945
|
+
pushToTombstone('post', postId);
|
|
40946
|
+
}
|
|
40947
|
+
});
|
|
40948
|
+
throw error;
|
|
40949
|
+
}
|
|
40950
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40951
|
+
const cachedAt = client.cache && Date.now();
|
|
40952
|
+
if (client.cache)
|
|
40953
|
+
ingestInCache(data, { cachedAt });
|
|
40954
|
+
return {
|
|
40955
|
+
data: data.posts.map(LinkedObject.post),
|
|
40956
|
+
cachedAt,
|
|
40957
|
+
};
|
|
40958
|
+
};
|
|
40959
|
+
/* end_public_function */
|
|
40960
|
+
/**
|
|
40961
|
+
* ```js
|
|
40962
|
+
* import { getPostByIds } from '@amityco/ts-sdk'
|
|
40963
|
+
* const { data: posts } = getPostByIds.locally(['foo', 'bar'])
|
|
40964
|
+
* ```
|
|
40965
|
+
*
|
|
40966
|
+
* Fetches a collection of {@link Amity.Post} objects from cache
|
|
40967
|
+
*
|
|
40968
|
+
* @param postIds the IDs of the {@link Amity.Post} to fetch
|
|
40969
|
+
* @returns the associated collection of {@link Amity.Post} objects
|
|
40970
|
+
*
|
|
40971
|
+
* @category Post API
|
|
40972
|
+
*/
|
|
40973
|
+
getPostByIds.locally = (postIds) => {
|
|
40974
|
+
var _a;
|
|
40975
|
+
const client = getActiveClient();
|
|
40976
|
+
client.log('post/getPostByIds.locally', postIds);
|
|
40977
|
+
if (!client.cache)
|
|
40978
|
+
return;
|
|
40979
|
+
const cached = postIds
|
|
40980
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
40981
|
+
.filter(Boolean);
|
|
40982
|
+
const posts = cached.map(({ data }) => data);
|
|
40983
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
40984
|
+
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
40985
|
+
return;
|
|
40986
|
+
return {
|
|
40987
|
+
data: posts.map(LinkedObject.post),
|
|
40988
|
+
cachedAt: oldest.cachedAt,
|
|
40989
|
+
};
|
|
40990
|
+
};
|
|
40991
|
+
|
|
40992
|
+
/* begin_public_function
|
|
40993
|
+
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
|
|
40994
|
+
*/
|
|
40995
|
+
/**
|
|
40996
|
+
* ```js
|
|
40997
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
40998
|
+
* const created = await PostRepository.createPost({
|
|
40999
|
+
* targetType: 'user',
|
|
41000
|
+
* targetId: 'foobar',
|
|
41001
|
+
* data: { text: 'hello world' }
|
|
41002
|
+
* }))
|
|
41003
|
+
* ```
|
|
41004
|
+
*
|
|
41005
|
+
* Creates an {@link Amity.Post}
|
|
41006
|
+
*
|
|
41007
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
41008
|
+
* @returns The newly created {@link Amity.Post}
|
|
41009
|
+
*
|
|
41010
|
+
* @category Post API
|
|
41011
|
+
* @async
|
|
41012
|
+
*/
|
|
41013
|
+
const createPost = async (bundle) => {
|
|
41014
|
+
const client = getActiveClient();
|
|
41015
|
+
client.log('post/createPost', bundle);
|
|
41016
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
41017
|
+
// eslint-disable-next-line no-param-reassign
|
|
41018
|
+
delete bundle.dataType;
|
|
41019
|
+
}
|
|
41020
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
41021
|
+
fireEvent('post.created', payload);
|
|
41022
|
+
const data = preparePostPayload(payload);
|
|
41023
|
+
const cachedAt = client.cache && Date.now();
|
|
41024
|
+
if (client.cache)
|
|
41025
|
+
ingestInCache(data, { cachedAt });
|
|
41026
|
+
const { posts } = data;
|
|
41027
|
+
return {
|
|
41028
|
+
data: LinkedObject.post(posts[0]),
|
|
41029
|
+
cachedAt,
|
|
41030
|
+
};
|
|
41031
|
+
};
|
|
41032
|
+
/* end_public_function */
|
|
41033
|
+
|
|
41034
|
+
/* begin_public_function
|
|
41035
|
+
id: post.edit, post.edit.custom_post
|
|
41036
|
+
*/
|
|
41037
|
+
/**
|
|
41038
|
+
* ```js
|
|
41039
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41040
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
41041
|
+
* data: { text: 'hello world' }
|
|
41042
|
+
* })
|
|
41043
|
+
* ```
|
|
41044
|
+
*
|
|
41045
|
+
* Updates an {@link Amity.Post}
|
|
41046
|
+
*
|
|
41047
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
41048
|
+
* @param patch The patch data to apply
|
|
41049
|
+
* @returns the updated {@link Amity.Post} object
|
|
41050
|
+
*
|
|
41051
|
+
* @category Post API
|
|
41052
|
+
* @async
|
|
41053
|
+
*/
|
|
41054
|
+
const editPost = async (postId, patch) => {
|
|
41055
|
+
const client = getActiveClient();
|
|
41056
|
+
client.log('user/editPost', patch);
|
|
41057
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
41058
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41059
|
+
const cachedAt = client.cache && Date.now();
|
|
41060
|
+
if (client.cache)
|
|
41061
|
+
ingestInCache(data, { cachedAt });
|
|
41062
|
+
fireEvent('local.post.updated', data);
|
|
41063
|
+
const { posts } = data;
|
|
41064
|
+
return {
|
|
41065
|
+
data: LinkedObject.post(posts.find(post => post.postId === postId)),
|
|
41066
|
+
cachedAt,
|
|
41067
|
+
};
|
|
41068
|
+
};
|
|
41069
|
+
/* end_public_function */
|
|
41070
|
+
|
|
41071
|
+
/**
|
|
41072
|
+
* ```js
|
|
41073
|
+
* import { deletePost } from '@amityco/ts-sdk'
|
|
41074
|
+
* const success = await deletePost('foobar')
|
|
41075
|
+
* ```
|
|
41076
|
+
*
|
|
41077
|
+
* Deletes a {@link Amity.Post}
|
|
41078
|
+
*
|
|
41079
|
+
* @param postId The {@link Amity.Post} ID to delete
|
|
41080
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
41081
|
+
*
|
|
41082
|
+
* @private
|
|
41083
|
+
* @async
|
|
41084
|
+
*/
|
|
41085
|
+
const deletePost = async (postId, permanent = false) => {
|
|
41086
|
+
var _a;
|
|
41087
|
+
const client = getActiveClient();
|
|
41088
|
+
const post = await getPost$2(postId);
|
|
41089
|
+
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
41090
|
+
params: {
|
|
41091
|
+
postId,
|
|
41092
|
+
permanent,
|
|
41093
|
+
},
|
|
41094
|
+
});
|
|
41095
|
+
// there is currently a limitation which doesn't allow us to fire event to tell that community
|
|
41096
|
+
// has been updated. reason is that, when the object is deleted, we don't have its `communityId`
|
|
41097
|
+
// and so we cannot refetch the community or advertise on events. hopefully this should be solved
|
|
41098
|
+
// later when realtime events covers that for us.
|
|
41099
|
+
if (post.data.targetType === 'community') {
|
|
41100
|
+
const community = await getCommunity$1(post.data.targetId);
|
|
41101
|
+
const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
|
|
41102
|
+
const communityUsers = communityUsersCache
|
|
41103
|
+
.filter(({ key }) => {
|
|
41104
|
+
// cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
|
|
41105
|
+
if (key[0] !== 'communityUsers')
|
|
41106
|
+
return false;
|
|
41107
|
+
if (key[1] !== 'get')
|
|
41108
|
+
return false;
|
|
41109
|
+
if (typeof key[2] === 'string')
|
|
41110
|
+
return key[2].includes(community.data.communityId);
|
|
41111
|
+
return false;
|
|
41112
|
+
})
|
|
41113
|
+
.map(({ data }) => data);
|
|
41114
|
+
fireEvent('community.updated', {
|
|
41115
|
+
communities: [community.data],
|
|
41116
|
+
categories: [],
|
|
41117
|
+
communityUsers,
|
|
41118
|
+
feeds: [],
|
|
41119
|
+
files: [],
|
|
41120
|
+
users: [],
|
|
41121
|
+
});
|
|
41122
|
+
}
|
|
41123
|
+
// to support hard deletion
|
|
41124
|
+
const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
|
|
41125
|
+
if (permanent) {
|
|
41126
|
+
setTimeout(() => {
|
|
41127
|
+
pushToTombstone('post', postId);
|
|
41128
|
+
}, 0);
|
|
40470
41129
|
}
|
|
40471
|
-
|
|
41130
|
+
else {
|
|
41131
|
+
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
41132
|
+
}
|
|
41133
|
+
fireEvent('local.post.deleted', {
|
|
41134
|
+
posts: [deleted],
|
|
41135
|
+
categories: [],
|
|
41136
|
+
comments: [],
|
|
41137
|
+
communities: [],
|
|
41138
|
+
communityUsers: [],
|
|
41139
|
+
feeds: [],
|
|
41140
|
+
files: [],
|
|
41141
|
+
postChildren: [],
|
|
41142
|
+
users: [],
|
|
41143
|
+
videoStreamings: [],
|
|
41144
|
+
});
|
|
41145
|
+
return LinkedObject.post(deleted);
|
|
41146
|
+
};
|
|
40472
41147
|
|
|
41148
|
+
/* begin_public_function
|
|
41149
|
+
id: post.soft_delete
|
|
41150
|
+
*/
|
|
40473
41151
|
/**
|
|
40474
41152
|
* ```js
|
|
40475
|
-
* import {
|
|
40476
|
-
* const
|
|
40477
|
-
* // ...
|
|
40478
|
-
* })
|
|
41153
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41154
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
40479
41155
|
* ```
|
|
40480
41156
|
*
|
|
40481
|
-
*
|
|
41157
|
+
* Soft deletes a {@link Amity.Post}
|
|
40482
41158
|
*
|
|
40483
|
-
* @param
|
|
40484
|
-
* @
|
|
41159
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
41160
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
40485
41161
|
*
|
|
40486
|
-
* @category
|
|
41162
|
+
* @category Post API
|
|
41163
|
+
* @async
|
|
40487
41164
|
*/
|
|
40488
|
-
const
|
|
40489
|
-
|
|
41165
|
+
const softDeletePost = async (postId) => {
|
|
41166
|
+
const client = getActiveClient();
|
|
41167
|
+
client.log('post/softDeletePost', postId);
|
|
41168
|
+
const softDeleted = await deletePost(postId, false);
|
|
41169
|
+
return LinkedObject.post(softDeleted);
|
|
40490
41170
|
};
|
|
41171
|
+
/* end_public_function */
|
|
40491
41172
|
|
|
40492
|
-
|
|
40493
|
-
|
|
40494
|
-
|
|
40495
|
-
|
|
40496
|
-
|
|
40497
|
-
|
|
40498
|
-
|
|
40499
|
-
|
|
40500
|
-
|
|
40501
|
-
|
|
40502
|
-
|
|
40503
|
-
|
|
40504
|
-
|
|
40505
|
-
|
|
40506
|
-
|
|
40507
|
-
|
|
40508
|
-
|
|
40509
|
-
|
|
40510
|
-
|
|
40511
|
-
|
|
40512
|
-
|
|
40513
|
-
|
|
40514
|
-
|
|
40515
|
-
|
|
40516
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
40517
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
40518
|
-
}
|
|
40519
|
-
startSubscription() {
|
|
40520
|
-
return this.queryStreamController.subscribeRTE([
|
|
40521
|
-
{ fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
|
|
40522
|
-
{ fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
|
|
40523
|
-
{ fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
|
|
40524
|
-
{ fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
|
|
40525
|
-
{ fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
|
|
40526
|
-
{ fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
|
|
40527
|
-
{ fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
|
|
40528
|
-
{ fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40529
|
-
{ fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40530
|
-
{ fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
|
|
40531
|
-
{ fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
|
|
40532
|
-
]);
|
|
40533
|
-
}
|
|
40534
|
-
notifyChange({ origin, loading, error }) {
|
|
40535
|
-
var _a, _b;
|
|
40536
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
40537
|
-
if (!collection)
|
|
40538
|
-
return;
|
|
40539
|
-
const data = this.applyFilter((_b = collection.data
|
|
40540
|
-
.map(id => pullFromCache(['comment', 'get', id]))
|
|
40541
|
-
.filter(isNonNullable)
|
|
40542
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
|
|
40543
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
40544
|
-
return;
|
|
40545
|
-
this.callback({
|
|
40546
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
40547
|
-
data,
|
|
40548
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
40549
|
-
loading,
|
|
40550
|
-
error,
|
|
40551
|
-
});
|
|
40552
|
-
}
|
|
40553
|
-
applyFilter(data) {
|
|
40554
|
-
let comments = data;
|
|
40555
|
-
if (!this.query.includeDeleted) {
|
|
40556
|
-
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
40557
|
-
}
|
|
40558
|
-
if (this.query.parentId) {
|
|
40559
|
-
comments = comments.filter(comment => comment.parentId === this.query.parentId);
|
|
40560
|
-
}
|
|
40561
|
-
if (typeof this.query.hasFlag === 'boolean') {
|
|
40562
|
-
if (this.query.hasFlag) {
|
|
40563
|
-
comments = comments.filter(comment => comment.hashFlag != null);
|
|
40564
|
-
}
|
|
40565
|
-
else {
|
|
40566
|
-
comments = comments.filter(comment => comment.hashFlag == null);
|
|
40567
|
-
}
|
|
40568
|
-
}
|
|
40569
|
-
if (this.query.dataTypes) {
|
|
40570
|
-
if (this.query.dataTypes.matchType === 'exact') {
|
|
40571
|
-
comments = comments.filter(comment => {
|
|
40572
|
-
var _a, _b;
|
|
40573
|
-
const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
|
|
40574
|
-
const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
|
|
40575
|
-
if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
|
|
40576
|
-
return false;
|
|
40577
|
-
}
|
|
40578
|
-
return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
|
|
40579
|
-
});
|
|
40580
|
-
}
|
|
40581
|
-
if (this.query.dataTypes.matchType === 'any') {
|
|
40582
|
-
comments = comments.filter(comment => { var _a; return (_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.some(value => { var _a; return (_a = comment.dataTypes) === null || _a === void 0 ? void 0 : _a.includes(value); }); });
|
|
40583
|
-
}
|
|
40584
|
-
}
|
|
40585
|
-
switch (this.query.sortBy) {
|
|
40586
|
-
case 'firstCreated':
|
|
40587
|
-
comments = comments.sort(sortByFirstCreated);
|
|
40588
|
-
break;
|
|
40589
|
-
case 'lastCreated':
|
|
40590
|
-
default:
|
|
40591
|
-
comments = comments.sort(sortByLastCreated);
|
|
40592
|
-
break;
|
|
40593
|
-
}
|
|
40594
|
-
return comments;
|
|
40595
|
-
}
|
|
40596
|
-
}
|
|
41173
|
+
/* begin_public_function
|
|
41174
|
+
id: post.hard_delete
|
|
41175
|
+
*/
|
|
41176
|
+
/**
|
|
41177
|
+
* ```js
|
|
41178
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
41179
|
+
* const success = await hardDeletePost('foobar')
|
|
41180
|
+
* ```
|
|
41181
|
+
*
|
|
41182
|
+
* Hard deletes a {@link Amity.Post}
|
|
41183
|
+
*
|
|
41184
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
41185
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
41186
|
+
*
|
|
41187
|
+
* @category Post API
|
|
41188
|
+
* @async
|
|
41189
|
+
*/
|
|
41190
|
+
const hardDeletePost = async (postId) => {
|
|
41191
|
+
const client = getActiveClient();
|
|
41192
|
+
client.log('post/hardDeletePost', postId);
|
|
41193
|
+
const hardDeleted = await deletePost(postId, true);
|
|
41194
|
+
return LinkedObject.post(hardDeleted);
|
|
41195
|
+
};
|
|
41196
|
+
/* end_public_function */
|
|
40597
41197
|
|
|
40598
41198
|
/* begin_public_function
|
|
40599
|
-
id:
|
|
41199
|
+
id: post.approve
|
|
40600
41200
|
*/
|
|
40601
41201
|
/**
|
|
40602
41202
|
* ```js
|
|
40603
|
-
* import {
|
|
41203
|
+
* import { approvePost } from '@amityco/ts-sdk'
|
|
40604
41204
|
*
|
|
40605
|
-
*
|
|
40606
|
-
* const unsub = getComments({
|
|
40607
|
-
* referenceType: Amity.InternalComment['referenceType'];
|
|
40608
|
-
* referenceId: Amity.InternalComment['referenceId'];
|
|
40609
|
-
* }, response => merge(comments, response.data))
|
|
41205
|
+
* const { data: post } = await approvePost('postId')
|
|
40610
41206
|
* ```
|
|
40611
41207
|
*
|
|
40612
|
-
*
|
|
41208
|
+
* Approves a {@link Amity.Post}
|
|
40613
41209
|
*
|
|
40614
|
-
* @param
|
|
40615
|
-
* @
|
|
40616
|
-
* @param callback the function to call when new data are available
|
|
40617
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
41210
|
+
* @param postId The {@link Amity.Post} ID to be approved
|
|
41211
|
+
* @return A {@link Amity.Post} that was approved
|
|
40618
41212
|
*
|
|
40619
|
-
* @category
|
|
41213
|
+
* @category Post API
|
|
41214
|
+
* @async
|
|
40620
41215
|
*/
|
|
40621
|
-
const
|
|
40622
|
-
const
|
|
40623
|
-
|
|
40624
|
-
|
|
41216
|
+
const approvePost = async (postId) => {
|
|
41217
|
+
const client = getActiveClient();
|
|
41218
|
+
client.log('post/approvePost', postId);
|
|
41219
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
|
|
41220
|
+
fireEvent('post.approved', payload);
|
|
41221
|
+
// fire virtual event for community update
|
|
41222
|
+
if (payload.posts[0].targetType === 'community') {
|
|
41223
|
+
fireEvent('community.updated', payload);
|
|
40625
41224
|
}
|
|
40626
|
-
const
|
|
40627
|
-
|
|
40628
|
-
|
|
40629
|
-
|
|
40630
|
-
|
|
40631
|
-
|
|
40632
|
-
|
|
40633
|
-
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
40634
|
-
disposers.forEach(fn => fn());
|
|
41225
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41226
|
+
const cachedAt = client.cache && Date.now();
|
|
41227
|
+
if (client.cache)
|
|
41228
|
+
ingestInCache(data, { cachedAt });
|
|
41229
|
+
return {
|
|
41230
|
+
data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
|
|
41231
|
+
cachedAt,
|
|
40635
41232
|
};
|
|
40636
41233
|
};
|
|
40637
41234
|
/* end_public_function */
|
|
40638
41235
|
|
|
40639
|
-
|
|
40640
|
-
|
|
40641
|
-
|
|
40642
|
-
createComment: createComment,
|
|
40643
|
-
updateComment: updateComment,
|
|
40644
|
-
deleteComment: deleteComment,
|
|
40645
|
-
softDeleteComment: softDeleteComment,
|
|
40646
|
-
hardDeleteComment: hardDeleteComment,
|
|
40647
|
-
flagComment: flagComment,
|
|
40648
|
-
unflagComment: unflagComment,
|
|
40649
|
-
isCommentFlaggedByMe: isCommentFlaggedByMe,
|
|
40650
|
-
onCommentCreated: onCommentCreated,
|
|
40651
|
-
onCommentUpdated: onCommentUpdated,
|
|
40652
|
-
onCommentDeleted: onCommentDeleted,
|
|
40653
|
-
onCommentFlagged: onCommentFlagged,
|
|
40654
|
-
onCommentUnflagged: onCommentUnflagged,
|
|
40655
|
-
onCommentReactionAdded: onCommentReactionAdded,
|
|
40656
|
-
onCommentReactionRemoved: onCommentReactionRemoved,
|
|
40657
|
-
getComment: getComment,
|
|
40658
|
-
getComments: getComments
|
|
40659
|
-
});
|
|
40660
|
-
|
|
41236
|
+
/* begin_public_function
|
|
41237
|
+
id: post.decline
|
|
41238
|
+
*/
|
|
40661
41239
|
/**
|
|
40662
41240
|
* ```js
|
|
40663
|
-
* import {
|
|
40664
|
-
*
|
|
40665
|
-
*
|
|
40666
|
-
* })
|
|
41241
|
+
* import { declinePost } from '@amityco/ts-sdk'
|
|
41242
|
+
*
|
|
41243
|
+
* const {data: post} = await declinePost('postId')
|
|
40667
41244
|
* ```
|
|
40668
41245
|
*
|
|
40669
|
-
*
|
|
41246
|
+
* Declines a {@link Amity.Post}
|
|
40670
41247
|
*
|
|
40671
|
-
* @param
|
|
40672
|
-
* @
|
|
41248
|
+
* @param postId The {@link Amity.Post} ID to be declined
|
|
41249
|
+
* @return A {@link Amity.Post} that was declined
|
|
40673
41250
|
*
|
|
40674
|
-
* @category Post
|
|
41251
|
+
* @category Post API
|
|
41252
|
+
* @async
|
|
40675
41253
|
*/
|
|
40676
|
-
const
|
|
41254
|
+
const declinePost = async (postId) => {
|
|
41255
|
+
const client = getActiveClient();
|
|
41256
|
+
client.log('post/declinePost', postId);
|
|
41257
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
|
|
41258
|
+
// fire virtual event
|
|
41259
|
+
if (payload.posts[0].targetType === 'community') {
|
|
41260
|
+
fireEvent('community.updated', payload);
|
|
41261
|
+
}
|
|
41262
|
+
fireEvent('post.declined', payload);
|
|
41263
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41264
|
+
const cachedAt = client.cache && Date.now();
|
|
41265
|
+
if (client.cache)
|
|
41266
|
+
ingestInCache(data, { cachedAt });
|
|
41267
|
+
return {
|
|
41268
|
+
data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
|
|
41269
|
+
cachedAt,
|
|
41270
|
+
};
|
|
41271
|
+
};
|
|
41272
|
+
/* end_public_function */
|
|
40677
41273
|
|
|
41274
|
+
/* begin_public_function
|
|
41275
|
+
id: post.flag
|
|
41276
|
+
*/
|
|
40678
41277
|
/**
|
|
40679
41278
|
* ```js
|
|
40680
|
-
* import {
|
|
40681
|
-
* const
|
|
40682
|
-
* // ...
|
|
40683
|
-
* })
|
|
41279
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41280
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
40684
41281
|
* ```
|
|
40685
41282
|
*
|
|
40686
|
-
*
|
|
40687
|
-
*
|
|
40688
|
-
* @
|
|
40689
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
41283
|
+
* @param postId of the post to flag
|
|
41284
|
+
* @param reason the reason to flag the post
|
|
41285
|
+
* @returns a boolean
|
|
40690
41286
|
*
|
|
40691
|
-
* @category Post
|
|
40692
|
-
|
|
40693
|
-
|
|
41287
|
+
* @category Post API
|
|
41288
|
+
* @async
|
|
41289
|
+
* */
|
|
41290
|
+
const flagPost = async (postId, reason) => {
|
|
40694
41291
|
const client = getActiveClient();
|
|
40695
|
-
|
|
40696
|
-
|
|
40697
|
-
|
|
40698
|
-
|
|
40699
|
-
|
|
40700
|
-
|
|
40701
|
-
callback(post);
|
|
40702
|
-
}
|
|
41292
|
+
client.log('post/flagPost', postId);
|
|
41293
|
+
const isPredefinedReason = reason &&
|
|
41294
|
+
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
41295
|
+
const body = {
|
|
41296
|
+
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
41297
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
40703
41298
|
};
|
|
40704
|
-
|
|
41299
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
41300
|
+
if (client.cache) {
|
|
41301
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
41302
|
+
}
|
|
41303
|
+
fireEvent('post.flagged', payload);
|
|
41304
|
+
return !!payload;
|
|
40705
41305
|
};
|
|
41306
|
+
/* end_public_function */
|
|
40706
41307
|
|
|
41308
|
+
/* begin_public_function
|
|
41309
|
+
id: post.unflag
|
|
41310
|
+
*/
|
|
40707
41311
|
/**
|
|
40708
41312
|
* ```js
|
|
40709
|
-
* import {
|
|
40710
|
-
* const
|
|
40711
|
-
* // ...
|
|
40712
|
-
* })
|
|
41313
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41314
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
40713
41315
|
* ```
|
|
40714
41316
|
*
|
|
40715
|
-
*
|
|
41317
|
+
* @param postId of the post to unflag
|
|
41318
|
+
* @returns the unflag post result
|
|
40716
41319
|
*
|
|
40717
|
-
* @
|
|
40718
|
-
* @
|
|
41320
|
+
* @category Post API
|
|
41321
|
+
* @async
|
|
41322
|
+
* */
|
|
41323
|
+
const unflagPost = async (postId) => {
|
|
41324
|
+
const client = getActiveClient();
|
|
41325
|
+
client.log('post/unflagPost', postId);
|
|
41326
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
41327
|
+
if (client.cache) {
|
|
41328
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
41329
|
+
}
|
|
41330
|
+
fireEvent('post.unflagged', payload);
|
|
41331
|
+
return !!payload;
|
|
41332
|
+
};
|
|
41333
|
+
/* end_public_function */
|
|
41334
|
+
|
|
41335
|
+
/* begin_public_function
|
|
41336
|
+
id: post.check_flag_by_me
|
|
41337
|
+
*/
|
|
41338
|
+
/**
|
|
41339
|
+
* ```js
|
|
41340
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41341
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
41342
|
+
* ```
|
|
40719
41343
|
*
|
|
40720
|
-
* @
|
|
40721
|
-
|
|
40722
|
-
|
|
41344
|
+
* @param postId of the post to check if flagged by current user
|
|
41345
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
41346
|
+
*
|
|
41347
|
+
* @category Post API
|
|
41348
|
+
* @async
|
|
41349
|
+
* */
|
|
41350
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
40723
41351
|
const client = getActiveClient();
|
|
40724
|
-
|
|
40725
|
-
|
|
40726
|
-
|
|
40727
|
-
}
|
|
40728
|
-
else {
|
|
40729
|
-
upsertInCache(['post', 'get', post.postId], post);
|
|
40730
|
-
callback(post);
|
|
40731
|
-
}
|
|
40732
|
-
};
|
|
40733
|
-
return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
|
|
41352
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
41353
|
+
const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
|
|
41354
|
+
return result;
|
|
40734
41355
|
};
|
|
41356
|
+
/* end_public_function */
|
|
40735
41357
|
|
|
41358
|
+
/* begin_public_function
|
|
41359
|
+
id: post.create.clip_post
|
|
41360
|
+
*/
|
|
40736
41361
|
/**
|
|
40737
41362
|
* ```js
|
|
40738
|
-
* import {
|
|
40739
|
-
* const
|
|
40740
|
-
*
|
|
40741
|
-
*
|
|
41363
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
41364
|
+
* const created = await PostRepository.createClipPost({
|
|
41365
|
+
* targetType: 'user',
|
|
41366
|
+
* targetId: 'foobar',
|
|
41367
|
+
* dataType: 'clip',
|
|
41368
|
+
* data: { text: 'hello world' },
|
|
41369
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
41370
|
+
* }))
|
|
40742
41371
|
* ```
|
|
40743
41372
|
*
|
|
40744
|
-
*
|
|
41373
|
+
* Creates an {@link Amity.Post}
|
|
40745
41374
|
*
|
|
40746
|
-
* @param
|
|
40747
|
-
* @returns
|
|
41375
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
41376
|
+
* @returns The newly created {@link Amity.Post}
|
|
40748
41377
|
*
|
|
40749
|
-
* @category Post
|
|
41378
|
+
* @category Post API
|
|
41379
|
+
* @async
|
|
40750
41380
|
*/
|
|
40751
|
-
const
|
|
41381
|
+
const createClipPost = async (bundle) => {
|
|
41382
|
+
const client = getActiveClient();
|
|
41383
|
+
client.log('post/createPost', bundle);
|
|
41384
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
41385
|
+
fireEvent('post.created', payload);
|
|
41386
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
41387
|
+
const cachedAt = client.cache && Date.now();
|
|
41388
|
+
if (client.cache)
|
|
41389
|
+
ingestInCache(data, { cachedAt });
|
|
41390
|
+
const { posts } = data;
|
|
41391
|
+
return {
|
|
41392
|
+
data: LinkedObject.post(posts[0]),
|
|
41393
|
+
cachedAt,
|
|
41394
|
+
};
|
|
41395
|
+
};
|
|
41396
|
+
/* end_public_function */
|
|
40752
41397
|
|
|
40753
41398
|
/* begin_public_function
|
|
40754
41399
|
id: post.get
|
|
@@ -40772,7 +41417,7 @@ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.p
|
|
|
40772
41417
|
*
|
|
40773
41418
|
* @category Post Live Object
|
|
40774
41419
|
*/
|
|
40775
|
-
const getPost
|
|
41420
|
+
const getPost = (postId, callback) => {
|
|
40776
41421
|
const responder = (snapshot) => {
|
|
40777
41422
|
const { data } = snapshot;
|
|
40778
41423
|
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
|
|
@@ -40861,19 +41506,6 @@ class PostPaginationController extends PaginationController {
|
|
|
40861
41506
|
}
|
|
40862
41507
|
}
|
|
40863
41508
|
|
|
40864
|
-
var EnumPostActions;
|
|
40865
|
-
(function (EnumPostActions) {
|
|
40866
|
-
EnumPostActions["OnPostCreated"] = "onPostCreated";
|
|
40867
|
-
EnumPostActions["OnPostUpdated"] = "onPostUpdated";
|
|
40868
|
-
EnumPostActions["OnPostDeleted"] = "onPostDeleted";
|
|
40869
|
-
EnumPostActions["OnPostFlagged"] = "onPostFlagged";
|
|
40870
|
-
EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
|
|
40871
|
-
EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
|
|
40872
|
-
EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
|
|
40873
|
-
EnumPostActions["OnPostApproved"] = "onPostApproved";
|
|
40874
|
-
EnumPostActions["OnPostDeclined"] = "onPostDeclined";
|
|
40875
|
-
})(EnumPostActions || (EnumPostActions = {}));
|
|
40876
|
-
|
|
40877
41509
|
class PostQueryStreamController extends QueryStreamController {
|
|
40878
41510
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
40879
41511
|
super(query, cacheKey);
|
|
@@ -40939,45 +41571,50 @@ class PostQueryStreamController extends QueryStreamController {
|
|
|
40939
41571
|
}
|
|
40940
41572
|
}
|
|
40941
41573
|
|
|
40942
|
-
const
|
|
40943
|
-
|
|
40944
|
-
|
|
40945
|
-
|
|
40946
|
-
|
|
40947
|
-
|
|
40948
|
-
|
|
40949
|
-
|
|
40950
|
-
|
|
40951
|
-
}
|
|
40952
|
-
catch (error) {
|
|
40953
|
-
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
40954
|
-
pushToTombstone('post', postId);
|
|
40955
|
-
}
|
|
40956
|
-
throw error;
|
|
40957
|
-
}
|
|
40958
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
40959
|
-
const cachedAt = client.cache && Date.now();
|
|
40960
|
-
if (client.cache)
|
|
40961
|
-
ingestInCache(data, { cachedAt });
|
|
40962
|
-
const { posts } = data;
|
|
40963
|
-
const result = posts.find(post => post.postId === postId);
|
|
40964
|
-
return {
|
|
40965
|
-
data: result,
|
|
40966
|
-
cachedAt,
|
|
40967
|
-
};
|
|
41574
|
+
const commentEventHandler = (callback, eventHandler, cacheKey, resolveId) => {
|
|
41575
|
+
return eventHandler(async (comment) => {
|
|
41576
|
+
var _a;
|
|
41577
|
+
const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41578
|
+
if (!currentCollection ||
|
|
41579
|
+
!currentCollection.data.includes(resolveId ? resolveId(comment.referenceId) : comment.referenceId))
|
|
41580
|
+
return;
|
|
41581
|
+
await getPost$1(comment.referenceId);
|
|
41582
|
+
callback(comment);
|
|
41583
|
+
});
|
|
40968
41584
|
};
|
|
40969
|
-
|
|
40970
|
-
const
|
|
40971
|
-
|
|
40972
|
-
|
|
40973
|
-
|
|
40974
|
-
|
|
40975
|
-
|
|
40976
|
-
|
|
40977
|
-
|
|
40978
|
-
|
|
40979
|
-
|
|
40980
|
-
|
|
41585
|
+
const generateCommentSubscriptions = ({ cacheKey, resolveId, }) => {
|
|
41586
|
+
const eventHandlers = [
|
|
41587
|
+
onCommentCreated,
|
|
41588
|
+
onCommentDeleted,
|
|
41589
|
+
onCommentReactionAdded,
|
|
41590
|
+
onCommentReactionRemoved,
|
|
41591
|
+
onCommentCreatedLocal,
|
|
41592
|
+
onCommentDeleteLocal,
|
|
41593
|
+
onLocalCommentReactionAdded,
|
|
41594
|
+
onLocalCommentReactionRemoved,
|
|
41595
|
+
];
|
|
41596
|
+
return eventHandlers.map(handler => ({
|
|
41597
|
+
fn: convertEventPayload((callback) => commentEventHandler(callback, handler, cacheKey, resolveId), 'referenceId', 'post'),
|
|
41598
|
+
action: EnumPostActions.OnPostUpdated,
|
|
41599
|
+
}));
|
|
41600
|
+
};
|
|
41601
|
+
const getPostSubscription = (cacheKey) => {
|
|
41602
|
+
return [
|
|
41603
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
41604
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
41605
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
41606
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41607
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
41608
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
41609
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
41610
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
41611
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41612
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41613
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41614
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41615
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41616
|
+
...generateCommentSubscriptions({ cacheKey }),
|
|
41617
|
+
];
|
|
40981
41618
|
};
|
|
40982
41619
|
|
|
40983
41620
|
class PostLiveCollectionController extends LiveCollectionController {
|
|
@@ -41008,47 +41645,7 @@ class PostLiveCollectionController extends LiveCollectionController {
|
|
|
41008
41645
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
41009
41646
|
}
|
|
41010
41647
|
startSubscription() {
|
|
41011
|
-
return this.queryStreamController.subscribeRTE(
|
|
41012
|
-
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
41013
|
-
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
41014
|
-
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
41015
|
-
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41016
|
-
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
41017
|
-
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
41018
|
-
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
41019
|
-
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
41020
|
-
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41021
|
-
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41022
|
-
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
41023
|
-
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
41024
|
-
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
41025
|
-
{
|
|
41026
|
-
fn: convertEventPayload((callback) => {
|
|
41027
|
-
return onCommentCreated(async (comment) => {
|
|
41028
|
-
var _a;
|
|
41029
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41030
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
41031
|
-
return;
|
|
41032
|
-
await getPost(comment.referenceId);
|
|
41033
|
-
callback(comment);
|
|
41034
|
-
});
|
|
41035
|
-
}, 'referenceId', 'post'),
|
|
41036
|
-
action: EnumPostActions.OnPostUpdated,
|
|
41037
|
-
},
|
|
41038
|
-
{
|
|
41039
|
-
fn: convertEventPayload((callback) => {
|
|
41040
|
-
return onCommentDeleted(async (comment) => {
|
|
41041
|
-
var _a;
|
|
41042
|
-
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41043
|
-
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
41044
|
-
return;
|
|
41045
|
-
await getPost(comment.referenceId);
|
|
41046
|
-
callback(comment);
|
|
41047
|
-
});
|
|
41048
|
-
}, 'referenceId', 'post'),
|
|
41049
|
-
action: EnumPostActions.OnPostUpdated,
|
|
41050
|
-
},
|
|
41051
|
-
]);
|
|
41648
|
+
return this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
|
|
41052
41649
|
}
|
|
41053
41650
|
notifyChange({ origin, loading, error }) {
|
|
41054
41651
|
var _a, _b;
|
|
@@ -41183,6 +41780,22 @@ class PinnedPostQueryStreamController extends QueryStreamController {
|
|
|
41183
41780
|
});
|
|
41184
41781
|
}
|
|
41185
41782
|
}
|
|
41783
|
+
reactor(action) {
|
|
41784
|
+
return (post) => {
|
|
41785
|
+
var _a;
|
|
41786
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
41787
|
+
if (!collection)
|
|
41788
|
+
return;
|
|
41789
|
+
if (action === EnumPostActions.OnPostDeleted) {
|
|
41790
|
+
collection.data = collection.data.filter(referenceId => referenceId !== `global#${post.postId}`);
|
|
41791
|
+
}
|
|
41792
|
+
pushToCache(this.cacheKey, collection);
|
|
41793
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
41794
|
+
};
|
|
41795
|
+
}
|
|
41796
|
+
subscribeRTE(createSubscriber) {
|
|
41797
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
41798
|
+
}
|
|
41186
41799
|
}
|
|
41187
41800
|
|
|
41188
41801
|
class PinnedPostLiveCollectionController extends LiveCollectionController {
|
|
@@ -41214,7 +41827,10 @@ class PinnedPostLiveCollectionController extends LiveCollectionController {
|
|
|
41214
41827
|
}
|
|
41215
41828
|
// eslint-disable-next-line class-methods-use-this
|
|
41216
41829
|
startSubscription() {
|
|
41217
|
-
return
|
|
41830
|
+
return this.queryStreamController.subscribeRTE(generateCommentSubscriptions({
|
|
41831
|
+
cacheKey: this.cacheKey,
|
|
41832
|
+
resolveId: id => `${this.query.placement}#${id}`,
|
|
41833
|
+
}));
|
|
41218
41834
|
}
|
|
41219
41835
|
notifyChange({ origin, loading, error }) {
|
|
41220
41836
|
var _a, _b;
|
|
@@ -41366,6 +41982,10 @@ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController
|
|
|
41366
41982
|
fn: onPostDeleted,
|
|
41367
41983
|
action: EnumPostActions.OnPostDeleted,
|
|
41368
41984
|
},
|
|
41985
|
+
...generateCommentSubscriptions({
|
|
41986
|
+
cacheKey: this.cacheKey,
|
|
41987
|
+
resolveId: id => `global#${id}`,
|
|
41988
|
+
}),
|
|
41369
41989
|
]);
|
|
41370
41990
|
}
|
|
41371
41991
|
notifyChange({ origin, loading, error }) {
|
|
@@ -41645,6 +42265,238 @@ const semanticSearchPosts = (params, callback, config) => {
|
|
|
41645
42265
|
};
|
|
41646
42266
|
};
|
|
41647
42267
|
|
|
42268
|
+
class SearchPostPaginationController extends PaginationController {
|
|
42269
|
+
async getRequest(queryParams, token) {
|
|
42270
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, matchingOnlyParentPost, hashtags, dataTypes, targetType = 'all' } = queryParams, params = __rest(queryParams, ["limit", "matchingOnlyParentPost", "hashtags", "dataTypes", "targetType"]);
|
|
42271
|
+
const baseOptions = {
|
|
42272
|
+
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
42273
|
+
};
|
|
42274
|
+
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
42275
|
+
const { data: queryResponse } = await this.http.get(`/api/v1/search/posts`, {
|
|
42276
|
+
params: Object.assign(Object.assign({}, params), { hashtags,
|
|
42277
|
+
dataTypes,
|
|
42278
|
+
targetType,
|
|
42279
|
+
/*
|
|
42280
|
+
* when creating post like image, file, video BE will create 2 posts
|
|
42281
|
+
* 1. parent post to store text with dataType=text
|
|
42282
|
+
* 2. child post to store dataTypes post data
|
|
42283
|
+
*
|
|
42284
|
+
* By default, BE queries only parent post
|
|
42285
|
+
*/
|
|
42286
|
+
matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options }),
|
|
42287
|
+
});
|
|
42288
|
+
return queryResponse;
|
|
42289
|
+
}
|
|
42290
|
+
}
|
|
42291
|
+
|
|
42292
|
+
class SearchPostQueryStreamController extends QueryStreamController {
|
|
42293
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
42294
|
+
super(query, cacheKey);
|
|
42295
|
+
this.notifyChange = notifyChange;
|
|
42296
|
+
this.preparePayload = preparePayload;
|
|
42297
|
+
}
|
|
42298
|
+
async saveToMainDB(response) {
|
|
42299
|
+
const processedPayload = await this.preparePayload(response);
|
|
42300
|
+
const client = getActiveClient();
|
|
42301
|
+
const cachedAt = client.cache && Date.now();
|
|
42302
|
+
if (client.cache) {
|
|
42303
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
42304
|
+
}
|
|
42305
|
+
}
|
|
42306
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
42307
|
+
var _a, _b;
|
|
42308
|
+
if (refresh) {
|
|
42309
|
+
pushToCache(this.cacheKey, {
|
|
42310
|
+
data: response.posts.map(getResolver('post')),
|
|
42311
|
+
});
|
|
42312
|
+
}
|
|
42313
|
+
else {
|
|
42314
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42315
|
+
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
42316
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
|
|
42317
|
+
}
|
|
42318
|
+
}
|
|
42319
|
+
reactor(action) {
|
|
42320
|
+
return (post) => {
|
|
42321
|
+
var _a, _b;
|
|
42322
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42323
|
+
if (!collection)
|
|
42324
|
+
return;
|
|
42325
|
+
if (post.parentPostId && post.isDeleted) {
|
|
42326
|
+
const parentPost = (_b = pullFromCache([
|
|
42327
|
+
'post',
|
|
42328
|
+
'get',
|
|
42329
|
+
post.parentPostId,
|
|
42330
|
+
])) === null || _b === void 0 ? void 0 : _b.data;
|
|
42331
|
+
if (!parentPost)
|
|
42332
|
+
return;
|
|
42333
|
+
parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
|
|
42334
|
+
pushToCache(['post', 'get', parentPost.postId], parentPost);
|
|
42335
|
+
}
|
|
42336
|
+
if (action === EnumPostActions.OnPostDeclined) {
|
|
42337
|
+
collection.data = collection.data.filter(postId => postId !== post.postId);
|
|
42338
|
+
}
|
|
42339
|
+
if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
|
|
42340
|
+
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
42341
|
+
}
|
|
42342
|
+
pushToCache(this.cacheKey, collection);
|
|
42343
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
42344
|
+
};
|
|
42345
|
+
}
|
|
42346
|
+
subscribeRTE(createSubscriber) {
|
|
42347
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
42348
|
+
}
|
|
42349
|
+
}
|
|
42350
|
+
|
|
42351
|
+
class SearchPostLiveCollectionController extends LiveCollectionController {
|
|
42352
|
+
constructor(query, callback) {
|
|
42353
|
+
const queryStreamId = hash(query);
|
|
42354
|
+
const cacheKey = ['posts', 'collection', queryStreamId];
|
|
42355
|
+
const paginationController = new SearchPostPaginationController(query);
|
|
42356
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
42357
|
+
this.query = query;
|
|
42358
|
+
this.queryStreamController = new SearchPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
|
|
42359
|
+
this.callback = callback.bind(this);
|
|
42360
|
+
this.loadPage({ initial: true });
|
|
42361
|
+
}
|
|
42362
|
+
setup() {
|
|
42363
|
+
var _a;
|
|
42364
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42365
|
+
if (!collection) {
|
|
42366
|
+
pushToCache(this.cacheKey, {
|
|
42367
|
+
data: [],
|
|
42368
|
+
params: {},
|
|
42369
|
+
});
|
|
42370
|
+
}
|
|
42371
|
+
}
|
|
42372
|
+
async persistModel(queryPayload) {
|
|
42373
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
42374
|
+
}
|
|
42375
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
42376
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
42377
|
+
}
|
|
42378
|
+
startSubscription() {
|
|
42379
|
+
return this.queryStreamController.subscribeRTE([
|
|
42380
|
+
{ fn: onPostCreated, action: EnumPostActions.OnPostCreated },
|
|
42381
|
+
{ fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
|
|
42382
|
+
{ fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
|
|
42383
|
+
{ fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
42384
|
+
{ fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
|
|
42385
|
+
{ fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
|
|
42386
|
+
{ fn: onPostApproved, action: EnumPostActions.OnPostApproved },
|
|
42387
|
+
{ fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
|
|
42388
|
+
{ fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
42389
|
+
{ fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
42390
|
+
{ fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
|
|
42391
|
+
{ fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
|
|
42392
|
+
{ fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
|
|
42393
|
+
{
|
|
42394
|
+
fn: convertEventPayload((callback) => {
|
|
42395
|
+
return onCommentCreated(async (comment) => {
|
|
42396
|
+
var _a;
|
|
42397
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42398
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
42399
|
+
return;
|
|
42400
|
+
await getPost$1(comment.referenceId);
|
|
42401
|
+
callback(comment);
|
|
42402
|
+
});
|
|
42403
|
+
}, 'referenceId', 'post'),
|
|
42404
|
+
action: EnumPostActions.OnPostUpdated,
|
|
42405
|
+
},
|
|
42406
|
+
{
|
|
42407
|
+
fn: convertEventPayload((callback) => {
|
|
42408
|
+
return onCommentDeleted(async (comment) => {
|
|
42409
|
+
var _a;
|
|
42410
|
+
const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42411
|
+
if (!currentCollection || currentCollection.data.includes(comment.referenceId))
|
|
42412
|
+
return;
|
|
42413
|
+
await getPost$1(comment.referenceId);
|
|
42414
|
+
callback(comment);
|
|
42415
|
+
});
|
|
42416
|
+
}, 'referenceId', 'post'),
|
|
42417
|
+
action: EnumPostActions.OnPostUpdated,
|
|
42418
|
+
},
|
|
42419
|
+
]);
|
|
42420
|
+
}
|
|
42421
|
+
notifyChange({ origin, loading, error }) {
|
|
42422
|
+
var _a, _b;
|
|
42423
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
42424
|
+
if (!collection)
|
|
42425
|
+
return;
|
|
42426
|
+
const data = this.applyFilter((_b = collection.data
|
|
42427
|
+
.map(id => pullFromCache(['post', 'get', id]))
|
|
42428
|
+
.filter(isNonNullable)
|
|
42429
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
|
|
42430
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
42431
|
+
return;
|
|
42432
|
+
this.callback({
|
|
42433
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
42434
|
+
data,
|
|
42435
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
42436
|
+
loading,
|
|
42437
|
+
error,
|
|
42438
|
+
});
|
|
42439
|
+
}
|
|
42440
|
+
applyFilter(data) {
|
|
42441
|
+
var _a;
|
|
42442
|
+
let posts = data;
|
|
42443
|
+
if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
|
|
42444
|
+
posts = filterByPostDataTypes(posts, this.query.dataTypes);
|
|
42445
|
+
}
|
|
42446
|
+
switch (this.query.sortBy) {
|
|
42447
|
+
case 'firstCreated':
|
|
42448
|
+
posts = posts.sort(sortByFirstCreated);
|
|
42449
|
+
break;
|
|
42450
|
+
case 'lastCreated':
|
|
42451
|
+
default:
|
|
42452
|
+
posts = posts.sort(sortByLastCreated);
|
|
42453
|
+
break;
|
|
42454
|
+
}
|
|
42455
|
+
return posts;
|
|
42456
|
+
}
|
|
42457
|
+
}
|
|
42458
|
+
|
|
42459
|
+
/* begin_public_function
|
|
42460
|
+
id: post.query
|
|
42461
|
+
*/
|
|
42462
|
+
/**
|
|
42463
|
+
* ```js
|
|
42464
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
42465
|
+
*
|
|
42466
|
+
* let posts = []
|
|
42467
|
+
* const unsub = PostRepository.searchPostsByHashtag({
|
|
42468
|
+
* hashtags: ['amity'],
|
|
42469
|
+
* limit: 10,
|
|
42470
|
+
* }, response => merge(posts, response.data))
|
|
42471
|
+
* ```
|
|
42472
|
+
*
|
|
42473
|
+
* Observe all mutations on a list of {@link Amity.Post} for a given target object
|
|
42474
|
+
*
|
|
42475
|
+
* @param params.hashtags the hashtags to search for
|
|
42476
|
+
* @param callback the function to call when new data are available
|
|
42477
|
+
* @param config
|
|
42478
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
42479
|
+
*
|
|
42480
|
+
* @category Posts Live Collection
|
|
42481
|
+
*/
|
|
42482
|
+
const searchPostsByHashtag = (params, callback, config) => {
|
|
42483
|
+
const { log, cache } = getActiveClient();
|
|
42484
|
+
if (!cache) {
|
|
42485
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
42486
|
+
}
|
|
42487
|
+
const timestamp = Date.now();
|
|
42488
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > listen`);
|
|
42489
|
+
const postsLiveCollection = new SearchPostLiveCollectionController(params, callback);
|
|
42490
|
+
const disposers = postsLiveCollection.startSubscription();
|
|
42491
|
+
const cacheKey = postsLiveCollection.getCacheKey();
|
|
42492
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
42493
|
+
return () => {
|
|
42494
|
+
log(`searchPostsByHashtag(tmpid: ${timestamp}) > dispose`);
|
|
42495
|
+
disposers.forEach(fn => fn());
|
|
42496
|
+
};
|
|
42497
|
+
};
|
|
42498
|
+
/* end_public_function */
|
|
42499
|
+
|
|
41648
42500
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
41649
42501
|
__proto__: null,
|
|
41650
42502
|
getPostByIds: getPostByIds,
|
|
@@ -41668,11 +42520,12 @@ var index$8 = /*#__PURE__*/Object.freeze({
|
|
|
41668
42520
|
onPostUnflagged: onPostUnflagged,
|
|
41669
42521
|
onPostReactionAdded: onPostReactionAdded,
|
|
41670
42522
|
onPostReactionRemoved: onPostReactionRemoved,
|
|
41671
|
-
getPost: getPost
|
|
42523
|
+
getPost: getPost,
|
|
41672
42524
|
getPosts: getPosts,
|
|
41673
42525
|
getPinnedPosts: getPinnedPosts,
|
|
41674
42526
|
getGlobalPinnedPosts: getGlobalPinnedPosts,
|
|
41675
|
-
semanticSearchPosts: semanticSearchPosts
|
|
42527
|
+
semanticSearchPosts: semanticSearchPosts,
|
|
42528
|
+
searchPostsByHashtag: searchPostsByHashtag
|
|
41676
42529
|
});
|
|
41677
42530
|
|
|
41678
42531
|
/* begin_public_function
|
|
@@ -42277,8 +43130,8 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
42277
43130
|
* const created = await createPoll({
|
|
42278
43131
|
* question: 'question',
|
|
42279
43132
|
* answers: [
|
|
42280
|
-
* { dataType: 'text', data: 'answer1' },
|
|
42281
|
-
* { dataType: 'text', data: 'answer2' },
|
|
43133
|
+
* { dataType: 'text', data: 'answer1', fileId: 'fileId1' },
|
|
43134
|
+
* { dataType: 'text', data: 'answer2', fileId: 'fileId2' },
|
|
42282
43135
|
* ],
|
|
42283
43136
|
* closedIn: 1649136484
|
|
42284
43137
|
* }))
|
|
@@ -42551,7 +43404,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
|
|
|
42551
43404
|
getPoll: getPoll
|
|
42552
43405
|
});
|
|
42553
43406
|
|
|
42554
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
43407
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
42555
43408
|
/*
|
|
42556
43409
|
* The crypto algorithm used for importing key and signing string
|
|
42557
43410
|
*/
|
|
@@ -44866,4 +45719,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
44866
45719
|
getReactions: getReactions
|
|
44867
45720
|
});
|
|
44868
45721
|
|
|
44869
|
-
export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$
|
|
45722
|
+
export { API_REGIONS, index$3 as AdRepository, index$b as CategoryRepository, index$f as ChannelRepository, index$o as Client, index$a as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$c as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, FeedDataTypeEnum, index$9 as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$l as FileRepository, FileType, index$1 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index as LiveReactionRepository, index$5 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$j as MessageRepository, index$6 as PollRepository, PostContentType, index$8 as PostRepository, index$k as ReactionRepository, index$4 as StoryRepository, index$7 as StreamRepository, index$i as SubChannelRepository, SubscriptionLevels, index$m as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$2 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|