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