@amityco/ts-sdk 7.8.0 → 7.8.1-1ae26ac.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.
Files changed (260) hide show
  1. package/.env +26 -26
  2. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts +4 -0
  3. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.d.ts.map +1 -1
  4. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/client.js.map +1 -1
  5. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts +4 -0
  6. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.d.ts.map +1 -1
  7. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/feed.js.map +1 -1
  8. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts +11 -0
  9. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.d.ts.map +1 -0
  10. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js +2 -0
  11. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/hashtag.js.map +1 -0
  12. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts +2 -1
  13. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.d.ts.map +1 -1
  14. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/notification.js.map +1 -1
  15. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts +14 -1
  16. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts.map +1 -1
  17. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.js.map +1 -1
  18. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts +1 -0
  19. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.d.ts.map +1 -1
  20. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js +1 -0
  21. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/index.js.map +1 -1
  22. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
  23. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
  24. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js +21 -0
  25. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/getShareableLinkConfiguration.js.map +1 -0
  26. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.d.ts +1 -0
  27. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.d.ts.map +1 -1
  28. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.js +1 -0
  29. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/client/api/index.js.map +1 -1
  30. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js +6 -6
  31. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/commentRepository/api/deleteComment.js.map +1 -1
  32. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.d.ts.map +1 -1
  33. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.js +2 -1
  34. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/core/model/index.js.map +1 -1
  35. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts +0 -1
  36. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.d.ts.map +1 -1
  37. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js +0 -1
  38. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/index.js.map +1 -1
  39. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
  40. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  41. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js +3 -0
  42. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/queryGlobalFeed.js.map +1 -1
  43. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts +2 -1
  44. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.d.ts.map +1 -1
  45. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js +2 -1
  46. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/index.js.map +1 -1
  47. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
  48. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
  49. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js +60 -0
  50. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.js.map +1 -0
  51. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
  52. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
  53. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js +13 -0
  54. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.js.map +1 -0
  55. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
  56. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
  57. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js +66 -0
  58. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.js.map +1 -0
  59. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
  60. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
  61. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js +45 -0
  62. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getCustomRankingGlobalFeed.js.map +1 -0
  63. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
  64. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
  65. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js +60 -0
  66. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.js.map +1 -0
  67. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
  68. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
  69. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js +13 -0
  70. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/PaginationController.js.map +1 -0
  71. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
  72. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
  73. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js +66 -0
  74. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.js.map +1 -0
  75. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
  76. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
  77. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js +45 -0
  78. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/getGlobalFeed.js.map +1 -0
  79. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts +3 -0
  80. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.d.ts.map +1 -0
  81. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js +3 -0
  82. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/index.js.map +1 -0
  83. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts +6 -0
  84. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.d.ts.map +1 -0
  85. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js +60 -0
  86. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/observers/utils.js.map +1 -0
  87. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.d.ts +1 -1
  88. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createPost.js.map +1 -1
  89. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.d.ts +1 -1
  90. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/editPost.js.map +1 -1
  91. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js +2 -2
  92. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/queryPosts.js.map +1 -1
  93. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.d.ts.map +1 -1
  94. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js +26 -1
  95. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/events/utils.js.map +1 -1
  96. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
  97. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js +5 -0
  98. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.js.map +1 -1
  99. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
  100. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js +5 -1
  101. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.js.map +1 -1
  102. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
  103. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  104. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js +17 -0
  105. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.js.map +1 -1
  106. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
  107. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js +2 -50
  108. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPosts/PostLiveCollectionController.js.map +1 -1
  109. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
  110. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
  111. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js +126 -0
  112. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.js.map +1 -0
  113. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
  114. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
  115. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js +27 -0
  116. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.js.map +1 -0
  117. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
  118. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
  119. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js +65 -0
  120. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.js.map +1 -0
  121. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts +1 -0
  122. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.d.ts.map +1 -1
  123. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js +1 -0
  124. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/index.js.map +1 -1
  125. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
  126. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
  127. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js +45 -0
  128. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/searchPostsByHashtag.js.map +1 -0
  129. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts +13 -0
  130. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.d.ts.map +1 -0
  131. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js +61 -0
  132. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/observers/utils.js.map +1 -0
  133. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
  134. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js +1 -1
  135. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/addReaction.js.map +1 -1
  136. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
  137. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js +1 -1
  138. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/reactionRepository/api/removeReaction.js.map +1 -1
  139. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  140. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js +9 -4
  141. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js.map +1 -1
  142. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
  143. package/dist/@types/domains/client.d.ts +4 -0
  144. package/dist/@types/domains/client.d.ts.map +1 -1
  145. package/dist/@types/domains/feed.d.ts +4 -0
  146. package/dist/@types/domains/feed.d.ts.map +1 -1
  147. package/dist/@types/domains/hashtag.d.ts +11 -0
  148. package/dist/@types/domains/hashtag.d.ts.map +1 -0
  149. package/dist/@types/domains/notification.d.ts +2 -1
  150. package/dist/@types/domains/notification.d.ts.map +1 -1
  151. package/dist/@types/domains/post.d.ts +14 -1
  152. package/dist/@types/domains/post.d.ts.map +1 -1
  153. package/dist/@types/index.d.ts +1 -0
  154. package/dist/@types/index.d.ts.map +1 -1
  155. package/dist/client/api/getShareableLinkConfiguration.d.ts +16 -0
  156. package/dist/client/api/getShareableLinkConfiguration.d.ts.map +1 -0
  157. package/dist/client/api/index.d.ts +1 -0
  158. package/dist/client/api/index.d.ts.map +1 -1
  159. package/dist/core/model/index.d.ts.map +1 -1
  160. package/dist/feedRepository/api/index.d.ts +0 -1
  161. package/dist/feedRepository/api/index.d.ts.map +1 -1
  162. package/dist/feedRepository/api/queryGlobalFeed.d.ts +3 -0
  163. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  164. package/dist/feedRepository/index.d.ts +2 -1
  165. package/dist/feedRepository/index.d.ts.map +1 -1
  166. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts +13 -0
  167. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.d.ts.map +1 -0
  168. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts +5 -0
  169. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.d.ts.map +1 -0
  170. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts +15 -0
  171. package/dist/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.d.ts.map +1 -0
  172. package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts +22 -0
  173. package/dist/feedRepository/observers/getCustomRankingGlobalFeed.d.ts.map +1 -0
  174. package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts +13 -0
  175. package/dist/feedRepository/observers/getGlobalFeed/LiveCollectionController.d.ts.map +1 -0
  176. package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts +5 -0
  177. package/dist/feedRepository/observers/getGlobalFeed/PaginationController.d.ts.map +1 -0
  178. package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts +15 -0
  179. package/dist/feedRepository/observers/getGlobalFeed/QueryStreamController.d.ts.map +1 -0
  180. package/dist/feedRepository/observers/getGlobalFeed.d.ts +22 -0
  181. package/dist/feedRepository/observers/getGlobalFeed.d.ts.map +1 -0
  182. package/dist/feedRepository/observers/index.d.ts +3 -0
  183. package/dist/feedRepository/observers/index.d.ts.map +1 -0
  184. package/dist/feedRepository/observers/utils.d.ts +6 -0
  185. package/dist/feedRepository/observers/utils.d.ts.map +1 -0
  186. package/dist/index.cjs.js +1887 -1275
  187. package/dist/index.esm.js +1793 -1181
  188. package/dist/index.umd.js +4 -4
  189. package/dist/postRepository/api/createPost.d.ts +1 -1
  190. package/dist/postRepository/api/editPost.d.ts +1 -1
  191. package/dist/postRepository/events/utils.d.ts.map +1 -1
  192. package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.d.ts.map +1 -1
  193. package/dist/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.d.ts.map +1 -1
  194. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts +6 -0
  195. package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
  196. package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
  197. package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts +14 -0
  198. package/dist/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.d.ts.map +1 -0
  199. package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts +5 -0
  200. package/dist/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.d.ts.map +1 -0
  201. package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts +15 -0
  202. package/dist/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.d.ts.map +1 -0
  203. package/dist/postRepository/observers/index.d.ts +1 -0
  204. package/dist/postRepository/observers/index.d.ts.map +1 -1
  205. package/dist/postRepository/observers/searchPostsByHashtag.d.ts +22 -0
  206. package/dist/postRepository/observers/searchPostsByHashtag.d.ts.map +1 -0
  207. package/dist/postRepository/observers/utils.d.ts +13 -0
  208. package/dist/postRepository/observers/utils.d.ts.map +1 -0
  209. package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
  210. package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
  211. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  212. package/package.json +1 -1
  213. package/src/@types/domains/client.ts +5 -0
  214. package/src/@types/domains/feed.ts +16 -0
  215. package/src/@types/domains/hashtag.ts +11 -0
  216. package/src/@types/domains/notification.ts +1 -0
  217. package/src/@types/domains/post.ts +18 -1
  218. package/src/@types/index.ts +1 -0
  219. package/src/client/api/getShareableLinkConfiguration.ts +26 -0
  220. package/src/client/api/index.ts +2 -0
  221. package/src/commentRepository/api/deleteComment.ts +6 -6
  222. package/src/core/model/index.ts +2 -1
  223. package/src/feedRepository/api/index.ts +0 -1
  224. package/src/feedRepository/api/queryGlobalFeed.ts +3 -0
  225. package/src/feedRepository/index.ts +2 -1
  226. package/src/feedRepository/observers/getCustomRankingGlobalFeed/LiveCollectionController.ts +95 -0
  227. package/src/feedRepository/observers/getCustomRankingGlobalFeed/PaginationController.ts +25 -0
  228. package/src/feedRepository/observers/getCustomRankingGlobalFeed/QueryStreamController.ts +101 -0
  229. package/src/feedRepository/observers/getCustomRankingGlobalFeed.ts +56 -0
  230. package/src/feedRepository/observers/getGlobalFeed/LiveCollectionController.ts +91 -0
  231. package/src/feedRepository/observers/getGlobalFeed/PaginationController.ts +23 -0
  232. package/src/feedRepository/observers/getGlobalFeed/QueryStreamController.ts +99 -0
  233. package/src/feedRepository/observers/getGlobalFeed.ts +56 -0
  234. package/src/feedRepository/observers/index.ts +2 -0
  235. package/src/feedRepository/observers/utils.ts +85 -0
  236. package/src/postRepository/api/createPost.ts +1 -1
  237. package/src/postRepository/api/editPost.ts +1 -1
  238. package/src/postRepository/api/queryPosts.ts +2 -2
  239. package/src/postRepository/events/utils.ts +35 -1
  240. package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostLiveCollectionController.ts +5 -0
  241. package/src/postRepository/observers/getPinnedPosts/PinnedPostLiveCollectionController.ts +7 -1
  242. package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +27 -0
  243. package/src/postRepository/observers/getPosts/PostLiveCollectionController.ts +2 -74
  244. package/src/postRepository/observers/getPostsByHashtag/SearchPostLiveCollectionController.ts +183 -0
  245. package/src/postRepository/observers/getPostsByHashtag/SearchPostPaginationController.ts +49 -0
  246. package/src/postRepository/observers/getPostsByHashtag/SearchPostQueryStreamController.ts +99 -0
  247. package/src/postRepository/observers/index.ts +1 -0
  248. package/src/postRepository/observers/searchPostsByHashtag.ts +56 -0
  249. package/src/postRepository/observers/utils.ts +97 -0
  250. package/src/reactionRepository/api/addReaction.ts +1 -0
  251. package/src/reactionRepository/api/removeReaction.ts +1 -0
  252. package/src/utils/linkedObject/postLinkedObject.ts +3 -3
  253. package/tsconfig.tsbuildinfo +1 -1
  254. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
  255. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
  256. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js +0 -83
  257. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/feedRepository/api/getCustomRankingGlobalFeed.js.map +0 -1
  258. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +0 -37
  259. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +0 -1
  260. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +0 -115
package/dist/index.cjs.js CHANGED
@@ -658,7 +658,8 @@ const PAYLOAD2MODEL = {
658
658
  };
659
659
  /** hidden */
660
660
  const isOutdated = (prevData, nextData) => {
661
- if ('updatedAt' in nextData && 'updatedAt' in nextData) {
661
+ // Check if the new value is outdated.
662
+ if ('updatedAt' in nextData && 'updatedAt' in prevData) {
662
663
  return new Date(nextData.updatedAt) < new Date(prevData.updatedAt);
663
664
  }
664
665
  return false;
@@ -9781,6 +9782,26 @@ const fetchLinkPreview = async (url) => {
9781
9782
  return data;
9782
9783
  };
9783
9784
 
9785
+ /**
9786
+ * ```js
9787
+ * import Client from '@amityco/ts-sdk'
9788
+ * const shareableLinkConfiguration = await Client.getShareableLinkConfiguration()
9789
+ * const postLinkPattern = shareableLinkConfiguration.post
9790
+ * ```
9791
+ *
9792
+ * Fetches a {@link Amity.ShareableLinkConfiguration} object
9793
+ *
9794
+ * @returns A Promise of {@link Amity.ShareableLinkConfiguration} object
9795
+ *
9796
+ * @category Client API
9797
+ * @async
9798
+ */
9799
+ const getShareableLinkConfiguration = async () => {
9800
+ const client = getActiveClient();
9801
+ const { data } = await client.http.get(`/api/v3/network-settings/shareable-deep-links`);
9802
+ return data;
9803
+ };
9804
+
9784
9805
  /**
9785
9806
  * ```js
9786
9807
  * import { onChannelMarkerFetched } from '@amityco/ts-sdk'
@@ -10150,6 +10171,7 @@ var index$o = /*#__PURE__*/Object.freeze({
10150
10171
  enableUnreadCount: enableUnreadCount,
10151
10172
  setUploadedFileAccessType: setUploadedFileAccessType,
10152
10173
  fetchLinkPreview: fetchLinkPreview,
10174
+ getShareableLinkConfiguration: getShareableLinkConfiguration,
10153
10175
  onConnectionError: onConnectionError,
10154
10176
  onClientDisconnected: onClientDisconnected,
10155
10177
  onClientBanned: onClientBanned,
@@ -11853,15 +11875,18 @@ function isAmityClipPost(post) {
11853
11875
  }
11854
11876
 
11855
11877
  const postLinkedObject = (post) => {
11856
- return Object.assign(Object.assign({}, post), { childrenPosts: post.children
11878
+ return shallowClone(post, {
11879
+ childrenPosts: post.children
11857
11880
  .map(childPost => { var _a; return (_a = pullFromCache(['post', 'get', childPost])) === null || _a === void 0 ? void 0 : _a.data; })
11858
11881
  .filter(isNonNullable)
11859
- .map(postLinkedObject), analytics: {
11882
+ .map(postLinkedObject),
11883
+ analytics: {
11860
11884
  markAsViewed: () => {
11861
11885
  const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
11862
11886
  analyticsEngineInstance.markPostAsViewed(post.postId);
11863
11887
  },
11864
- }, get latestComments() {
11888
+ },
11889
+ get latestComments() {
11865
11890
  if (!post.comments)
11866
11891
  return [];
11867
11892
  return (post.comments
@@ -11935,7 +11960,8 @@ const postLinkedObject = (post) => {
11935
11960
  return isAmityClipPost(post)
11936
11961
  ? (_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
11937
11962
  : undefined;
11938
- } });
11963
+ },
11964
+ });
11939
11965
  };
11940
11966
 
11941
11967
  const getCachedMarker = (message) => {
@@ -14930,7 +14956,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
14930
14956
  ]);
14931
14957
  if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
14932
14958
  return true;
14933
- 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 }) });
14959
+ 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() });
14934
14960
  if (referenceType === 'comment') {
14935
14961
  fireEvent('local.comment.addReaction', {
14936
14962
  comment: updatedModel,
@@ -15053,7 +15079,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
15053
15079
  ]);
15054
15080
  if (!model)
15055
15081
  return true;
15056
- 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) }) });
15082
+ 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() });
15057
15083
  if (referenceType === 'comment') {
15058
15084
  fireEvent('local.comment.removeReaction', {
15059
15085
  comment: updatedModel,
@@ -15167,6 +15193,26 @@ const prepareSemanticSearchPostPayload = (_a) => {
15167
15193
  return Object.assign(Object.assign({}, processedPostPayload), { polls });
15168
15194
  };
15169
15195
 
15196
+ const processDeleteChildPost = (payload) => {
15197
+ var _a;
15198
+ const post = payload.posts[0];
15199
+ if (!post.parentId)
15200
+ return;
15201
+ const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
15202
+ if (!parentPost)
15203
+ return;
15204
+ pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: parentPost.children.filter(childId => childId !== post.postId) }));
15205
+ };
15206
+ const processCreateChildPost = (payload) => {
15207
+ var _a;
15208
+ const post = payload.posts[0];
15209
+ if (!post.parentId)
15210
+ return;
15211
+ const parentPost = (_a = pullFromCache(['post', 'get', post.parentPostId])) === null || _a === void 0 ? void 0 : _a.data;
15212
+ if (!parentPost)
15213
+ return;
15214
+ pushToCache(['post', 'get', parentPost.postId], Object.assign(Object.assign({}, parentPost), { children: [...new Set([post.postId, ...parentPost.children])] }));
15215
+ };
15170
15216
  const createPostEventSubscriber = (event, callback) => {
15171
15217
  const client = getActiveClient();
15172
15218
  const filter = (payload) => {
@@ -15191,6 +15237,7 @@ const createPostEventSubscriber = (event, callback) => {
15191
15237
  }
15192
15238
  if (event === 'post.deleted') {
15193
15239
  const { postId, postedUserId } = payload.posts[0];
15240
+ processDeleteChildPost(payload);
15194
15241
  try {
15195
15242
  isInTombstone('post', postId);
15196
15243
  }
@@ -15217,6 +15264,8 @@ const createPostEventSubscriber = (event, callback) => {
15217
15264
  }
15218
15265
  queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
15219
15266
  }
15267
+ if (event === 'post.created')
15268
+ processCreateChildPost(payload);
15220
15269
  callback(post.data);
15221
15270
  }
15222
15271
  };
@@ -15243,6 +15292,8 @@ const createLocalPostEventSubscriber = (event, callback) => {
15243
15292
  });
15244
15293
  }
15245
15294
  const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
15295
+ if (event === 'local.post.deleted')
15296
+ processDeleteChildPost(payload);
15246
15297
  callback(post.data);
15247
15298
  }
15248
15299
  };
@@ -23018,6 +23069,9 @@ var index$b = /*#__PURE__*/Object.freeze({
23018
23069
  id: feed.query.global_feed
23019
23070
  */
23020
23071
  /**
23072
+ *
23073
+ * @deprecated This function will to be deprecated. Please use getGlobalFeed instead.
23074
+ *
23021
23075
  * ```js
23022
23076
  * import { queryGlobalFeed } from '@amityco/ts-sdk'
23023
23077
  * const posts = await queryGlobalFeed()
@@ -23100,1564 +23154,1914 @@ queryGlobalFeed.locally = (query) => {
23100
23154
  : undefined;
23101
23155
  };
23102
23156
 
23103
- /* begin_public_function
23104
- id: feed.query.custom_ranking_feed
23105
- */
23106
- /**
23107
- * ```js
23108
- * import { FeedRepository } from '@amityco/ts-sdk'
23109
- * const posts = await FeedRepository.getCustomRankingGlobalFeed()
23110
- * ```
23111
- *
23112
- * Queries a paginable list of {@link Amity.Post} objects
23113
- *
23114
- * @param query The query parameters
23115
- * @returns A page of {@link Amity.Post} objects
23116
- *
23117
- * @category Feed API
23118
- * @async
23119
- * */
23120
- const getCustomRankingGlobalFeed = async (query) => {
23121
- const client = getActiveClient();
23122
- client.log('feed/getCustomRankingGlobalFeed', query);
23123
- const _a = query !== null && query !== void 0 ? query : {}, { queryToken, limit } = _a, params = __rest(_a, ["queryToken", "limit"]);
23124
- const options = (() => {
23125
- if (queryToken)
23126
- return { token: queryToken };
23127
- return undefined;
23128
- })();
23129
- const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
23130
- params: Object.assign(Object.assign({}, params), { limit: !queryToken ? limit : undefined, options }),
23131
- });
23132
- const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
23133
- const data = prepareMembershipPayload(payload, 'communityUsers');
23134
- const { posts } = data;
23135
- const cachedAt = client.cache && Date.now();
23136
- if (client.cache) {
23137
- ingestInCache(data);
23138
- const cacheKey = ['customGlobalFeed', 'query', Object.assign(Object.assign({}, params), { options })];
23139
- pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
23157
+ class CustomRankingGlobalFeedPaginationController extends PaginationController {
23158
+ async getRequest(queryParams, token) {
23159
+ const { limit } = queryParams, params = __rest(queryParams, ["limit"]);
23160
+ const options = token ? { token } : { limit };
23161
+ const { data: queryResponse } = await this.http.get(`/api/v5/me/global-feeds`, {
23162
+ params: Object.assign(Object.assign({}, params), { options }),
23163
+ });
23164
+ return queryResponse;
23140
23165
  }
23141
- return { data: posts.map(LinkedObject.post), cachedAt, paging };
23142
- };
23143
- /* end_public_function */
23144
- /**
23145
- * ```js
23146
- * import { FeedRepository } from '@amityco/ts-sdk'
23147
- * const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
23148
- * ```
23149
- *
23150
- * Queries a paginable list of {@link Amity.Post} objects from cache
23151
- *
23152
- * @param query The query parameters
23153
- * @returns A page of {@link Amity.Post} objects
23154
- *
23155
- * @category Feed API
23156
- * @async
23157
- * */
23158
- getCustomRankingGlobalFeed.locally = (query) => {
23159
- var _a, _b;
23160
- const client = getActiveClient();
23161
- client.log('post/getCustomRankingGlobalFeed.locally', query);
23162
- if (!client.cache)
23163
- return;
23164
- const params = __rest(query !== null && query !== void 0 ? query : {}, []);
23165
- const queryKey = ['customGlobalFeed', 'query', Object.assign({}, params)];
23166
- const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
23167
- if (!(data === null || data === void 0 ? void 0 : data.posts.length))
23168
- return;
23169
- const posts = data.posts
23170
- .map(postId => pullFromCache(['post', 'get', postId]))
23171
- .filter(Boolean)
23172
- .map(({ data }) => data);
23173
- const { paging } = data;
23174
- return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
23175
- ? { data: posts.map(LinkedObject.post), cachedAt, paging }
23176
- : undefined;
23177
- };
23166
+ }
23178
23167
 
23179
- var index$a = /*#__PURE__*/Object.freeze({
23180
- __proto__: null,
23181
- queryGlobalFeed: queryGlobalFeed,
23182
- getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
23183
- });
23168
+ var EnumPostActions;
23169
+ (function (EnumPostActions) {
23170
+ EnumPostActions["OnPostCreated"] = "onPostCreated";
23171
+ EnumPostActions["OnPostUpdated"] = "onPostUpdated";
23172
+ EnumPostActions["OnPostDeleted"] = "onPostDeleted";
23173
+ EnumPostActions["OnPostFlagged"] = "onPostFlagged";
23174
+ EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
23175
+ EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
23176
+ EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
23177
+ EnumPostActions["OnPostApproved"] = "onPostApproved";
23178
+ EnumPostActions["OnPostDeclined"] = "onPostDeclined";
23179
+ })(EnumPostActions || (EnumPostActions = {}));
23180
+
23181
+ class CustomRankingGlobalFeedQueryStreamController extends QueryStreamController {
23182
+ constructor(query, cacheKey, notifyChange, preparePayload) {
23183
+ super(query, cacheKey);
23184
+ this.notifyChange = notifyChange;
23185
+ this.preparePayload = preparePayload;
23186
+ }
23187
+ async saveToMainDB(response) {
23188
+ const processedPayload = await this.preparePayload(response);
23189
+ const client = getActiveClient();
23190
+ const cachedAt = client.cache && Date.now();
23191
+ if (client.cache) {
23192
+ ingestInCache(processedPayload, { cachedAt });
23193
+ }
23194
+ }
23195
+ appendToQueryStream(response, direction, refresh = false) {
23196
+ var _a, _b;
23197
+ if (refresh) {
23198
+ pushToCache(this.cacheKey, {
23199
+ data: response.posts.map(getResolver('post')),
23200
+ });
23201
+ }
23202
+ else {
23203
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23204
+ const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
23205
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
23206
+ }
23207
+ }
23208
+ reactor(action) {
23209
+ return (post) => {
23210
+ var _a;
23211
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23212
+ if (!collection)
23213
+ return;
23214
+ if (post.parentPostId && !collection.data.includes(post.parentPostId))
23215
+ return;
23216
+ // Delete Action
23217
+ if (action === EnumPostActions.OnPostDeleted) {
23218
+ // Parent Post - Remove from collection
23219
+ collection.data = collection.data.filter(postId => postId !== post.postId);
23220
+ }
23221
+ if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
23222
+ // If the query has dataTypes array with value, check if post.dataType is include in the array
23223
+ if (this.query.dataTypes && this.query.dataTypes.length > 0) {
23224
+ if (!this.query.dataTypes.includes(post.dataType))
23225
+ return;
23226
+ }
23227
+ collection.data = [...new Set([post.postId, ...collection.data])];
23228
+ }
23229
+ if (action === EnumPostActions.OnPostDeclined) {
23230
+ collection.data = collection.data.filter(postId => postId !== post.postId);
23231
+ }
23232
+ pushToCache(this.cacheKey, collection);
23233
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
23234
+ };
23235
+ }
23236
+ subscribeRTE(createSubscriber) {
23237
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
23238
+ }
23239
+ }
23184
23240
 
23185
23241
  /* begin_public_function
23186
- id: post.get_by_ids
23242
+ id: comment.get_by_ids
23187
23243
  */
23188
23244
  /**
23189
23245
  * ```js
23190
- * import { getPostByIds } from '@amityco/ts-sdk'
23191
- * const { data: posts } = await getPostByIds(['foo', 'bar'])
23246
+ * import { CommentRepository } from '@amityco/ts-sdk'
23247
+ * const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
23192
23248
  * ```
23193
23249
  *
23194
- * Fetches a collection of {@link Amity.Post} objects
23250
+ * Fetches a collection of {@link Amity.Comment} objects
23195
23251
  *
23196
- * @param postIds the IDs of the {@link Amity.Post} to fetch
23197
- * @returns the associated collection of {@link Amity.Post} objects
23252
+ * @param commentIds the IDs of the {@link Amity.Comment} to fetch
23253
+ * @returns the associated collection of {@link Amity.Comment} objects
23198
23254
  *
23199
- * @category Post API
23255
+ * @category Comment API
23200
23256
  * @async
23201
23257
  */
23202
- const getPostByIds = async (postIds) => {
23258
+ const getCommentByIds = async (commentIds) => {
23203
23259
  const client = getActiveClient();
23204
- client.log('post/getPostByIds', postIds);
23205
- const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
23206
- let payload;
23260
+ client.log('comment/getCommentByIds', commentIds);
23261
+ const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
23262
+ let data;
23207
23263
  try {
23208
23264
  // API-FIX: endpoint should not be /list, parameters should be querystring.
23209
- const response = await client.http.get(`/api/v3/posts/list`, {
23210
- params: { postIds: encodedPostIds },
23265
+ const response = await client.http.get(`/api/v3/comments/list`, {
23266
+ params: { commentIds: encodedCommentIds },
23211
23267
  });
23212
- payload = response.data;
23268
+ data = response.data;
23213
23269
  }
23214
23270
  catch (error) {
23215
- postIds.forEach(postId => {
23271
+ commentIds.forEach(commentId => {
23216
23272
  if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
23217
- pushToTombstone('post', postId);
23273
+ pushToTombstone('comment', commentId);
23218
23274
  }
23219
23275
  });
23220
23276
  throw error;
23221
23277
  }
23222
- const data = prepareMembershipPayload(payload, 'communityUsers');
23223
23278
  const cachedAt = client.cache && Date.now();
23224
23279
  if (client.cache)
23225
23280
  ingestInCache(data, { cachedAt });
23226
23281
  return {
23227
- data: data.posts.map(LinkedObject.post),
23282
+ data: data.comments.map(comment => LinkedObject.comment(comment)),
23228
23283
  cachedAt,
23229
23284
  };
23230
23285
  };
23231
23286
  /* end_public_function */
23232
23287
  /**
23233
23288
  * ```js
23234
- * import { getPostByIds } from '@amityco/ts-sdk'
23235
- * const { data: posts } = getPostByIds.locally(['foo', 'bar'])
23289
+ * import { getCommentByIds } from '@amityco/ts-sdk'
23290
+ * const comments = getCommentByIds.locally(['foo', 'bar'])
23236
23291
  * ```
23237
23292
  *
23238
- * Fetches a collection of {@link Amity.Post} objects from cache
23293
+ * Fetches a collection of {@link Amity.Comment} objects from cache
23239
23294
  *
23240
- * @param postIds the IDs of the {@link Amity.Post} to fetch
23241
- * @returns the associated collection of {@link Amity.Post} objects
23295
+ * @param commentIds the IDs of the {@link Amity.Comment} to fetch
23296
+ * @returns the associated collection of {@link Amity.Comment} objects
23242
23297
  *
23243
- * @category Post API
23298
+ * @category Comment API
23244
23299
  */
23245
- getPostByIds.locally = (postIds) => {
23300
+ getCommentByIds.locally = (commentIds) => {
23246
23301
  var _a;
23247
23302
  const client = getActiveClient();
23248
- client.log('post/getPostByIds.locally', postIds);
23303
+ client.log('comment/getCommentByIds.locally', commentIds);
23249
23304
  if (!client.cache)
23250
23305
  return;
23251
- const cached = postIds
23252
- .map(postId => pullFromCache(['post', 'get', postId]))
23306
+ const cached = commentIds
23307
+ .map(commentId => pullFromCache(['comment', 'get', commentId]))
23253
23308
  .filter(Boolean);
23254
- const posts = cached.map(({ data }) => data);
23309
+ const comments = cached.map(({ data }) => data);
23255
23310
  const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
23256
- if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
23311
+ if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
23257
23312
  return;
23258
23313
  return {
23259
- data: posts.map(LinkedObject.post),
23314
+ data: comments.map(comment => LinkedObject.comment(comment)),
23260
23315
  cachedAt: oldest.cachedAt,
23261
23316
  };
23262
23317
  };
23263
23318
 
23264
23319
  /* begin_public_function
23265
- 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
23320
+ id: comment.create
23266
23321
  */
23267
23322
  /**
23268
23323
  * ```js
23269
- * import { PostRepository } from '@amityco/ts-sdk'
23270
- * const created = await PostRepository.createPost({
23271
- * targetType: 'user',
23272
- * targetId: 'foobar',
23273
- * data: { text: 'hello world' }
23274
- * }))
23324
+ * import { CommentRepository } from '@amityco/ts-sdk'
23325
+ * const newComment = await CommentRepository.createComment(bundle)
23275
23326
  * ```
23276
23327
  *
23277
- * Creates an {@link Amity.Post}
23328
+ * Creates an {@link Amity.Comment}
23278
23329
  *
23279
- * @param bundle The data necessary to create a new {@link Amity.Post}
23280
- * @returns The newly created {@link Amity.Post}
23330
+ * @param bundle The data necessary to create a new {@link Amity.Comment}
23331
+ * @returns The newly created {@link Amity.Comment}
23281
23332
  *
23282
- * @category Post API
23333
+ * @category Comment API
23283
23334
  * @async
23284
23335
  */
23285
- const createPost = async (bundle) => {
23336
+ const createComment = async (bundle) => {
23337
+ var _a;
23286
23338
  const client = getActiveClient();
23287
- client.log('post/createPost', bundle);
23288
- if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
23289
- // eslint-disable-next-line no-param-reassign
23290
- delete bundle.dataType;
23291
- }
23292
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
23293
- fireEvent('post.created', payload);
23294
- const data = preparePostPayload(payload);
23295
- const cachedAt = client.cache && Date.now();
23296
- if (client.cache)
23297
- ingestInCache(data, { cachedAt });
23298
- const { posts } = data;
23339
+ client.log('comment/createComment', bundle);
23340
+ const { data } = await client.http.post('/api/v3/comments', bundle);
23341
+ const { comments } = data;
23342
+ // BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
23343
+ if (comments.length === 0)
23344
+ throw new Error('Comment not created');
23345
+ const cachedAt = client.cache && Date.now();
23346
+ if (client.cache)
23347
+ ingestInCache(data, { cachedAt });
23348
+ if (['post', 'content'].includes(bundle.referenceType)) {
23349
+ const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
23350
+ if (post) {
23351
+ post.commentsCount += 1;
23352
+ fireEvent('local.post.updated', {
23353
+ posts: [post],
23354
+ categories: [],
23355
+ comments: [],
23356
+ communities: [],
23357
+ communityUsers: data.communityUsers,
23358
+ feeds: [],
23359
+ files: data.files,
23360
+ postChildren: [],
23361
+ users: data.users,
23362
+ videoStreamings: [],
23363
+ });
23364
+ }
23365
+ }
23366
+ else if (bundle.referenceType === 'story') {
23367
+ const storyIndex = pullFromCache([
23368
+ "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
23369
+ bundle.referenceId,
23370
+ ]);
23371
+ if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
23372
+ const cacheStory = pullFromCache([
23373
+ "story" /* STORY_KEY_CACHE.STORY */,
23374
+ 'get',
23375
+ storyIndex.data,
23376
+ ]);
23377
+ if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
23378
+ fireEvent('story.updated', {
23379
+ stories: [
23380
+ Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
23381
+ ],
23382
+ categories: [],
23383
+ comments,
23384
+ communities: [],
23385
+ communityUsers: data.communityUsers,
23386
+ files: data.files,
23387
+ users: data.users,
23388
+ });
23389
+ }
23390
+ }
23391
+ }
23392
+ fireEvent('local.comment.created', data);
23299
23393
  return {
23300
- data: LinkedObject.post(posts[0]),
23394
+ data: LinkedObject.comment(comments[0]),
23301
23395
  cachedAt,
23302
23396
  };
23303
23397
  };
23304
23398
  /* end_public_function */
23305
23399
 
23306
23400
  /* begin_public_function
23307
- id: post.edit, post.edit.custom_post
23401
+ id: comment.update_comment
23308
23402
  */
23309
23403
  /**
23310
23404
  * ```js
23311
- * import { PostRepository } from '@amityco/ts-sdk'
23312
- * const updated = await PostRepository.editPost(postId, {
23405
+ * import { CommentRepository } from '@amityco/ts-sdk'
23406
+ * const updated = await CommentRepository.updateComment(commentId, {
23313
23407
  * data: { text: 'hello world' }
23314
23408
  * })
23315
23409
  * ```
23316
23410
  *
23317
- * Updates an {@link Amity.Post}
23411
+ * Updates an {@link Amity.Comment}
23318
23412
  *
23319
- * @param postId The ID of the {@link Amity.Post} to edit
23413
+ * @param commentId The ID of the {@link Amity.Comment} to edit
23320
23414
  * @param patch The patch data to apply
23321
- * @returns the updated {@link Amity.Post} object
23415
+ * @returns the updated {@link Amity.Comment} object
23322
23416
  *
23323
- * @category Post API
23417
+ * @category Comment API
23324
23418
  * @async
23325
23419
  */
23326
- const editPost = async (postId, patch) => {
23420
+ const updateComment = async (commentId, patch) => {
23327
23421
  const client = getActiveClient();
23328
- client.log('user/editPost', patch);
23329
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
23330
- const data = prepareMembershipPayload(payload, 'communityUsers');
23422
+ client.log('user/updateComment', patch);
23423
+ const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
23331
23424
  const cachedAt = client.cache && Date.now();
23332
23425
  if (client.cache)
23333
23426
  ingestInCache(data, { cachedAt });
23334
- fireEvent('local.post.updated', data);
23335
- const { posts } = data;
23427
+ fireEvent('comment.updated', data);
23428
+ const { comments } = data;
23336
23429
  return {
23337
- data: LinkedObject.post(posts.find(post => post.postId === postId)),
23430
+ data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
23338
23431
  cachedAt,
23339
23432
  };
23340
23433
  };
23341
23434
  /* end_public_function */
23342
23435
 
23436
+ // Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
23437
+ const applyMissingField = (rawData, isCreated = false) => {
23438
+ const { storyId, referenceId } = rawData;
23439
+ if (!isCreated) {
23440
+ if (referenceId)
23441
+ return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
23442
+ }
23443
+ return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
23444
+ };
23445
+ const convertRawStoryToInternal = (data, isCreated = false) => {
23446
+ const { stories } = data;
23447
+ const storiesData = stories.map(story => applyMissingField(story, isCreated));
23448
+ return Object.assign(Object.assign({}, data), { stories: storiesData });
23449
+ };
23450
+
23451
+ const getStoryByStoryId$1 = async (storyId) => {
23452
+ const client = getActiveClient();
23453
+ client.log('story/getStoryByStoryId', storyId);
23454
+ // Get story referenceId from cache
23455
+ const cacheReferenceId = pullFromCache([
23456
+ "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
23457
+ storyId,
23458
+ ]);
23459
+ if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
23460
+ const { data: referenceId } = cacheReferenceId;
23461
+ isInTombstone('story', referenceId);
23462
+ }
23463
+ let data;
23464
+ try {
23465
+ const response = await client.http.get(`/api/v4/stories/${storyId}`);
23466
+ data = convertRawStoryToInternal(response.data);
23467
+ }
23468
+ catch (error) {
23469
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
23470
+ pushToTombstone('story', storyId);
23471
+ }
23472
+ throw error;
23473
+ }
23474
+ const cachedAt = client.cache && Date.now();
23475
+ if (client.cache) {
23476
+ ingestInCache(data, { cachedAt });
23477
+ }
23478
+ return {
23479
+ data: data.stories[0],
23480
+ cachedAt,
23481
+ };
23482
+ };
23483
+ getStoryByStoryId$1.locally = (storyId) => {
23484
+ const client = getActiveClient();
23485
+ client.log('story/getStorybyStoryId', storyId);
23486
+ // Get story referenceId from cache
23487
+ const cacheReferenceId = pullFromCache([
23488
+ "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
23489
+ storyId,
23490
+ ]);
23491
+ if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
23492
+ const { data: referenceId } = cacheReferenceId;
23493
+ isInTombstone('story', referenceId);
23494
+ }
23495
+ const cachedAt = client.cache && Date.now();
23496
+ const storyCache = pullFromCache(['story', 'get', storyId]);
23497
+ if (!storyCache)
23498
+ return;
23499
+ return {
23500
+ data: storyCache.data,
23501
+ cachedAt,
23502
+ };
23503
+ };
23504
+
23505
+ /* begin_public_function
23506
+ id: comment.soft_delete, comment.hard_delete
23507
+ */
23343
23508
  /**
23344
23509
  * ```js
23345
- * import { deletePost } from '@amityco/ts-sdk'
23346
- * const success = await deletePost('foobar')
23510
+ * import { CommentRepository } from '@amityco/ts-sdk'
23511
+ * const success = await CommentRepository.deleteComment('foobar')
23347
23512
  * ```
23348
23513
  *
23349
- * Deletes a {@link Amity.Post}
23514
+ * Deletes a {@link Amity.Comment}
23350
23515
  *
23351
- * @param postId The {@link Amity.Post} ID to delete
23352
- * @return A success boolean if the {@link Amity.Post} was deleted
23516
+ * @param commentId The {@link Amity.Comment} ID to delete
23517
+ * @return A success boolean if the {@link Amity.Comment} was deleted
23353
23518
  *
23354
- * @private
23519
+ * @category Comment API
23355
23520
  * @async
23356
23521
  */
23357
- const deletePost = async (postId, permanent = false) => {
23522
+ const deleteComment = async (commentId, permanent = false) => {
23358
23523
  var _a;
23359
23524
  const client = getActiveClient();
23360
- const post = await getPost$2(postId);
23361
- await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
23525
+ const comment = await getComment$2(commentId);
23526
+ // API-FIX: This endpoint has not been implemented yet.
23527
+ await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
23362
23528
  params: {
23363
- postId,
23529
+ commentId,
23364
23530
  permanent,
23365
23531
  },
23366
23532
  });
23367
- // there is currently a limitation which doesn't allow us to fire event to tell that community
23368
- // has been updated. reason is that, when the object is deleted, we don't have its `communityId`
23369
- // and so we cannot refetch the community or advertise on events. hopefully this should be solved
23370
- // later when realtime events covers that for us.
23371
- if (post.data.targetType === 'community') {
23372
- const community = await getCommunity$1(post.data.targetId);
23373
- const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
23374
- const communityUsers = communityUsersCache
23375
- .filter(({ key }) => {
23376
- // cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
23377
- if (key[0] !== 'communityUsers')
23378
- return false;
23379
- if (key[1] !== 'get')
23380
- return false;
23381
- if (typeof key[2] === 'string')
23382
- return key[2].includes(community.data.communityId);
23383
- return false;
23384
- })
23385
- .map(({ data }) => data);
23386
- fireEvent('community.updated', {
23387
- communities: [community.data],
23533
+ // to support hard deletion
23534
+ const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
23535
+ if (permanent) {
23536
+ scheduleTask(() => pushToTombstone('comment', commentId));
23537
+ }
23538
+ else {
23539
+ upsertInCache(['comment', 'get', commentId], { isDeleted: true });
23540
+ }
23541
+ if (comment.data.referenceType === 'story') {
23542
+ const story = await getStoryByStoryId$1(comment.data.referenceId);
23543
+ fireEvent('local.story.updated', {
23544
+ stories: [story.data],
23388
23545
  categories: [],
23389
- communityUsers,
23390
- feeds: [],
23546
+ comments: [],
23547
+ communities: [],
23548
+ communityUsers: [],
23391
23549
  files: [],
23392
23550
  users: [],
23393
23551
  });
23394
23552
  }
23395
- // to support hard deletion
23396
- const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
23397
- if (permanent) {
23398
- setTimeout(() => {
23399
- pushToTombstone('post', postId);
23400
- }, 0);
23401
- }
23402
23553
  else {
23403
- upsertInCache(['post', 'get', postId], { isDeleted: true });
23554
+ const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
23555
+ if (post) {
23556
+ let removeCount;
23557
+ if (!deleted.parentId) {
23558
+ // NOTE: delete the parent comment will remove all children comments
23559
+ removeCount = deleted.childrenNumber + 1;
23560
+ }
23561
+ else
23562
+ removeCount = 1;
23563
+ post.commentsCount -= removeCount;
23564
+ fireEvent('local.post.updated', {
23565
+ posts: [post],
23566
+ categories: [],
23567
+ comments: [],
23568
+ communities: [],
23569
+ communityUsers: [],
23570
+ feeds: [],
23571
+ files: [],
23572
+ postChildren: [],
23573
+ users: [],
23574
+ videoStreamings: [],
23575
+ });
23576
+ }
23404
23577
  }
23405
- fireEvent('local.post.deleted', {
23406
- posts: [deleted],
23407
- categories: [],
23408
- comments: [],
23409
- communities: [],
23410
- communityUsers: [],
23411
- feeds: [],
23578
+ fireEvent('local.comment.deleted', {
23579
+ comments: [deleted],
23580
+ commentChildren: [],
23412
23581
  files: [],
23413
- postChildren: [],
23414
23582
  users: [],
23415
- videoStreamings: [],
23583
+ communityUsers: [],
23416
23584
  });
23417
- return LinkedObject.post(deleted);
23418
- };
23419
-
23420
- /* begin_public_function
23421
- id: post.soft_delete
23422
- */
23423
- /**
23424
- * ```js
23425
- * import { PostRepository } from '@amityco/ts-sdk'
23426
- * const success = await PostRepository.softDeletePost('foobar')
23427
- * ```
23428
- *
23429
- * Soft deletes a {@link Amity.Post}
23430
- *
23431
- * @param postId The {@link Amity.Post} ID to soft delete
23432
- * @return A success boolean if the {@link Amity.Post} was deleted
23433
- *
23434
- * @category Post API
23435
- * @async
23436
- */
23437
- const softDeletePost = async (postId) => {
23438
- const client = getActiveClient();
23439
- client.log('post/softDeletePost', postId);
23440
- const softDeleted = await deletePost(postId, false);
23441
- return LinkedObject.post(softDeleted);
23442
- };
23443
- /* end_public_function */
23444
-
23445
- /* begin_public_function
23446
- id: post.hard_delete
23447
- */
23448
- /**
23449
- * ```js
23450
- * import { hardDeletePost } from '@amityco/ts-sdk'
23451
- * const success = await hardDeletePost('foobar')
23452
- * ```
23453
- *
23454
- * Hard deletes a {@link Amity.Post}
23455
- *
23456
- * @param postId The {@link Amity.Post} ID to be hard delete
23457
- * @return A success boolean if the {@link Amity.Post} was deleted
23458
- *
23459
- * @category Post API
23460
- * @async
23461
- */
23462
- const hardDeletePost = async (postId) => {
23463
- const client = getActiveClient();
23464
- client.log('post/hardDeletePost', postId);
23465
- const hardDeleted = await deletePost(postId, true);
23466
- return LinkedObject.post(hardDeleted);
23585
+ return deleted;
23467
23586
  };
23468
23587
  /* end_public_function */
23469
23588
 
23470
23589
  /* begin_public_function
23471
- id: post.approve
23590
+ id: comment.soft_delete
23472
23591
  */
23473
23592
  /**
23474
23593
  * ```js
23475
- * import { approvePost } from '@amityco/ts-sdk'
23476
- *
23477
- * const { data: post } = await approvePost('postId')
23594
+ * import { CommentRepository } from '@amityco/ts-sdk'
23595
+ * const success = await CommentRepository.softDeleteComment('foobar')
23478
23596
  * ```
23479
23597
  *
23480
- * Approves a {@link Amity.Post}
23598
+ * Deletes a {@link Amity.Comment}
23481
23599
  *
23482
- * @param postId The {@link Amity.Post} ID to be approved
23483
- * @return A {@link Amity.Post} that was approved
23600
+ * @param commentId The {@link Amity.Comment} ID to delete
23601
+ * @return A success boolean if the {@link Amity.Comment} was deleted
23484
23602
  *
23485
- * @category Post API
23603
+ * @category Comment API
23486
23604
  * @async
23487
23605
  */
23488
- const approvePost = async (postId) => {
23606
+ const softDeleteComment = async (commentId) => {
23489
23607
  const client = getActiveClient();
23490
- client.log('post/approvePost', postId);
23491
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
23492
- fireEvent('post.approved', payload);
23493
- // fire virtual event for community update
23494
- if (payload.posts[0].targetType === 'community') {
23495
- fireEvent('community.updated', payload);
23496
- }
23497
- const data = prepareMembershipPayload(payload, 'communityUsers');
23498
- const cachedAt = client.cache && Date.now();
23499
- if (client.cache)
23500
- ingestInCache(data, { cachedAt });
23501
- return {
23502
- data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
23503
- cachedAt,
23504
- };
23608
+ client.log('comment/softDeleteComment', commentId);
23609
+ const softDeleted = deleteComment(commentId);
23610
+ return softDeleted;
23505
23611
  };
23506
23612
  /* end_public_function */
23507
23613
 
23508
23614
  /* begin_public_function
23509
- id: post.decline
23615
+ id: comment.hard_delete
23510
23616
  */
23511
23617
  /**
23512
23618
  * ```js
23513
- * import { declinePost } from '@amityco/ts-sdk'
23514
- *
23515
- * const {data: post} = await declinePost('postId')
23619
+ * import { CommentRepository } from '@amityco/ts-sdk'
23620
+ * const success = await CommentRepository.hardDeleteComment('foobar')
23516
23621
  * ```
23517
23622
  *
23518
- * Declines a {@link Amity.Post}
23623
+ * Deletes a {@link Amity.Comment}
23519
23624
  *
23520
- * @param postId The {@link Amity.Post} ID to be declined
23521
- * @return A {@link Amity.Post} that was declined
23625
+ * @param commentId The {@link Amity.Comment} ID to delete
23626
+ * @return A success boolean if the {@link Amity.Comment} was deleted
23522
23627
  *
23523
- * @category Post API
23628
+ * @category Comment API
23524
23629
  * @async
23525
23630
  */
23526
- const declinePost = async (postId) => {
23631
+ const hardDeleteComment = async (commentId) => {
23527
23632
  const client = getActiveClient();
23528
- client.log('post/declinePost', postId);
23529
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
23530
- // fire virtual event
23531
- if (payload.posts[0].targetType === 'community') {
23532
- fireEvent('community.updated', payload);
23533
- }
23534
- fireEvent('post.declined', payload);
23535
- const data = prepareMembershipPayload(payload, 'communityUsers');
23536
- const cachedAt = client.cache && Date.now();
23537
- if (client.cache)
23538
- ingestInCache(data, { cachedAt });
23539
- return {
23540
- data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
23541
- cachedAt,
23542
- };
23633
+ client.log('comment/hardDeleteComment', commentId);
23634
+ const hardDeleted = deleteComment(commentId, true);
23635
+ return hardDeleted;
23543
23636
  };
23544
23637
  /* end_public_function */
23545
23638
 
23546
23639
  /* begin_public_function
23547
- id: post.flag
23640
+ id: comment.flag
23548
23641
  */
23549
23642
  /**
23550
23643
  * ```js
23551
- * import { PostRepository } from '@amityco/ts-sdk'
23552
- * const flagged = await PostRepository.flagPost(postId, reason)
23644
+ * import { CommentRepository } from '@amityco/ts-sdk'
23645
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
23553
23646
  * ```
23554
23647
  *
23555
- * @param postId of the post to flag
23556
- * @param reason the reason to flag the post
23557
- * @returns a boolean
23648
+ * @param commentId The ID of the comment to flag
23649
+ * @param reason the reason to flag the comment
23650
+ * @returns the created report result
23558
23651
  *
23559
- * @category Post API
23652
+ * @category Comment API
23560
23653
  * @async
23561
23654
  * */
23562
- const flagPost = async (postId, reason) => {
23655
+ const flagComment = async (commentId, reason) => {
23563
23656
  const client = getActiveClient();
23564
- client.log('post/flagPost', postId);
23657
+ client.log('comment/flagComment', commentId);
23565
23658
  const isPredefinedReason = reason &&
23566
23659
  Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
23567
23660
  const body = {
23568
23661
  reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
23569
23662
  detail: reason && !isPredefinedReason ? reason : '',
23570
23663
  };
23571
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
23664
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
23572
23665
  if (client.cache) {
23573
- ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
23666
+ ingestInCache(payload);
23574
23667
  }
23575
- fireEvent('post.flagged', payload);
23668
+ fireEvent('comment.flagged', payload);
23576
23669
  return !!payload;
23577
23670
  };
23578
23671
  /* end_public_function */
23579
23672
 
23580
23673
  /* begin_public_function
23581
- id: post.unflag
23674
+ id: comment.unflag
23582
23675
  */
23583
23676
  /**
23584
23677
  * ```js
23585
- * import { PostRepository } from '@amityco/ts-sdk'
23586
- * const unflagged = await PostRepository.unflagPost(postId)
23678
+ * import { CommentRepository } from '@amityco/ts-sdk'
23679
+ * const unflagged = await CommentRepository.unflagComment('commentId')
23587
23680
  * ```
23588
23681
  *
23589
- * @param postId of the post to unflag
23590
- * @returns the unflag post result
23682
+ * @param commentId The ID of comment to unflag
23683
+ * @returns the unflagged result
23591
23684
  *
23592
- * @category Post API
23685
+ * @category Comment API
23593
23686
  * @async
23594
23687
  * */
23595
- const unflagPost = async (postId) => {
23688
+ const unflagComment = async (commentId) => {
23596
23689
  const client = getActiveClient();
23597
- client.log('post/unflagPost', postId);
23598
- const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
23690
+ client.log('comment/unflagComment', commentId);
23691
+ const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
23599
23692
  if (client.cache) {
23600
- ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
23693
+ ingestInCache(payload);
23601
23694
  }
23602
- fireEvent('post.unflagged', payload);
23695
+ fireEvent('comment.unflagged', payload);
23603
23696
  return !!payload;
23604
23697
  };
23605
23698
  /* end_public_function */
23606
23699
 
23607
23700
  /* begin_public_function
23608
- id: post.check_flag_by_me
23701
+ id: comment.check_flag_by_me
23609
23702
  */
23610
23703
  /**
23611
23704
  * ```js
23612
- * import { PostRepository } from '@amityco/ts-sdk'
23613
- * const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
23705
+ * import { CommentRepository } from '@amityco/ts-sdk'
23706
+ * const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
23614
23707
  * ```
23615
23708
  *
23616
- * @param postId of the post to check if flagged by current user
23617
- * @returns `true` if the post is flagged by me, `false` if doesn't.
23709
+ * @param commentId The ID of the comment to check if flagged by current user
23710
+ * @returns `true` if the comment is flagged by me, `false` if doesn't.
23618
23711
  *
23619
- * @category Post API
23712
+ * @category Comment API
23620
23713
  * @async
23621
23714
  * */
23622
- const isPostFlaggedByMe = async (postId) => {
23715
+ const isCommentFlaggedByMe = async (commentId) => {
23623
23716
  const client = getActiveClient();
23624
- client.log('post/isPostFlaggedByMe', postId);
23625
- const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
23717
+ client.log('comment/isCommentFlaggedByMe', commentId);
23718
+ const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
23626
23719
  return result;
23627
23720
  };
23628
23721
  /* end_public_function */
23629
23722
 
23630
- /* begin_public_function
23631
- id: post.create.clip_post
23632
- */
23633
- /**
23634
- * ```js
23635
- * import { PostRepository } from '@amityco/ts-sdk'
23636
- * const created = await PostRepository.createClipPost({
23637
- * targetType: 'user',
23638
- * targetId: 'foobar',
23639
- * dataType: 'clip',
23640
- * data: { text: 'hello world' },
23641
- * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
23642
- * }))
23643
- * ```
23644
- *
23645
- * Creates an {@link Amity.Post}
23646
- *
23647
- * @param bundle The data necessary to create a new {@link Amity.Post}
23648
- * @returns The newly created {@link Amity.Post}
23649
- *
23650
- * @category Post API
23651
- * @async
23652
- */
23653
- const createClipPost = async (bundle) => {
23723
+ const getComment$1 = async (commentId) => {
23654
23724
  const client = getActiveClient();
23655
- client.log('post/createPost', bundle);
23656
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
23657
- fireEvent('post.created', payload);
23658
- const data = prepareMembershipPayload(payload, 'communityUsers');
23725
+ client.log('comment/getComment', commentId);
23726
+ isInTombstone('comment', commentId);
23727
+ let data;
23728
+ try {
23729
+ // API-FIX: endpoint should not be /list, parameters should be querystring.
23730
+ const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
23731
+ data = response.data;
23732
+ }
23733
+ catch (error) {
23734
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
23735
+ pushToTombstone('comment', commentId);
23736
+ }
23737
+ throw error;
23738
+ }
23659
23739
  const cachedAt = client.cache && Date.now();
23660
23740
  if (client.cache)
23661
23741
  ingestInCache(data, { cachedAt });
23662
- const { posts } = data;
23742
+ const { comments } = data;
23663
23743
  return {
23664
- data: LinkedObject.post(posts[0]),
23744
+ data: comments.find(comment => comment.commentId === commentId),
23665
23745
  cachedAt,
23666
23746
  };
23667
23747
  };
23668
- /* end_public_function */
23748
+ getComment$1.locally = (commentId) => {
23749
+ const client = getActiveClient();
23750
+ client.log('comment/getComment.locally', commentId);
23751
+ if (!client.cache)
23752
+ return;
23753
+ const cached = pullFromCache(['comment', 'get', commentId]);
23754
+ if (!cached)
23755
+ return;
23756
+ return {
23757
+ data: cached.data,
23758
+ cachedAt: cached.cachedAt,
23759
+ };
23760
+ };
23669
23761
 
23670
- /* begin_public_function
23671
- id: comment.get_by_ids
23672
- */
23673
23762
  /**
23674
23763
  * ```js
23675
- * import { CommentRepository } from '@amityco/ts-sdk'
23676
- * const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
23677
- * ```
23678
- *
23679
- * Fetches a collection of {@link Amity.Comment} objects
23764
+ * import { onCommentDeleteLocal } from '@amityco/ts-sdk'
23765
+ * const dispose = onCommentDeleteLocal(comment => {
23766
+ * // ...
23767
+ * })
23768
+ * ```
23680
23769
  *
23681
- * @param commentIds the IDs of the {@link Amity.Comment} to fetch
23682
- * @returns the associated collection of {@link Amity.Comment} objects
23770
+ * Fired when a {@link Amity.InternalComment} has been deleted
23683
23771
  *
23684
- * @category Comment API
23685
- * @async
23772
+ * @param callback The function to call when the event was fired
23773
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
23774
+ *
23775
+ * @category Comment Events
23686
23776
  */
23687
- const getCommentByIds = async (commentIds) => {
23688
- const client = getActiveClient();
23689
- client.log('comment/getCommentByIds', commentIds);
23690
- const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
23691
- let data;
23692
- try {
23693
- // API-FIX: endpoint should not be /list, parameters should be querystring.
23694
- const response = await client.http.get(`/api/v3/comments/list`, {
23695
- params: { commentIds: encodedCommentIds },
23696
- });
23697
- data = response.data;
23698
- }
23699
- catch (error) {
23700
- commentIds.forEach(commentId => {
23701
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
23702
- pushToTombstone('comment', commentId);
23703
- }
23704
- });
23705
- throw error;
23706
- }
23707
- const cachedAt = client.cache && Date.now();
23708
- if (client.cache)
23709
- ingestInCache(data, { cachedAt });
23710
- return {
23711
- data: data.comments.map(comment => LinkedObject.comment(comment)),
23712
- cachedAt,
23713
- };
23714
- };
23715
- /* end_public_function */
23777
+ const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
23778
+
23716
23779
  /**
23717
23780
  * ```js
23718
- * import { getCommentByIds } from '@amityco/ts-sdk'
23719
- * const comments = getCommentByIds.locally(['foo', 'bar'])
23781
+ * import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
23782
+ * const dispose = onLocalCommentReactionAdded(comment => {
23783
+ * // ...
23784
+ * })
23720
23785
  * ```
23721
23786
  *
23722
- * Fetches a collection of {@link Amity.Comment} objects from cache
23787
+ * Fired when a {@link Amity.InternalComment} has been reacted
23723
23788
  *
23724
- * @param commentIds the IDs of the {@link Amity.Comment} to fetch
23725
- * @returns the associated collection of {@link Amity.Comment} objects
23789
+ * @param callback The function to call when the event was fired
23790
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
23726
23791
  *
23727
- * @category Comment API
23792
+ * @category Comment Events
23728
23793
  */
23729
- getCommentByIds.locally = (commentIds) => {
23730
- var _a;
23794
+ const onLocalCommentReactionAdded = (callback) => {
23731
23795
  const client = getActiveClient();
23732
- client.log('comment/getCommentByIds.locally', commentIds);
23733
- if (!client.cache)
23734
- return;
23735
- const cached = commentIds
23736
- .map(commentId => pullFromCache(['comment', 'get', commentId]))
23737
- .filter(Boolean);
23738
- const comments = cached.map(({ data }) => data);
23739
- const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
23740
- if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
23741
- return;
23742
- return {
23743
- data: comments.map(comment => LinkedObject.comment(comment)),
23744
- cachedAt: oldest.cachedAt,
23796
+ const filter = ({ comment }) => {
23797
+ if (!client.cache) {
23798
+ callback(comment);
23799
+ }
23800
+ else {
23801
+ upsertInCache(['comment', 'get', comment.commentId], comment);
23802
+ callback(commentLinkedObject(comment));
23803
+ }
23745
23804
  };
23805
+ return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
23746
23806
  };
23747
23807
 
23748
- /* begin_public_function
23749
- id: comment.create
23750
- */
23751
23808
  /**
23752
23809
  * ```js
23753
- * import { CommentRepository } from '@amityco/ts-sdk'
23754
- * const newComment = await CommentRepository.createComment(bundle)
23810
+ * import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
23811
+ * const dispose = onLocalCommentReactionRemoved(comment => {
23812
+ * // ...
23813
+ * })
23755
23814
  * ```
23756
23815
  *
23757
- * Creates an {@link Amity.Comment}
23816
+ * Fired when a {@link Amity.InternalComment} has been reacted
23758
23817
  *
23759
- * @param bundle The data necessary to create a new {@link Amity.Comment}
23760
- * @returns The newly created {@link Amity.Comment}
23818
+ * @param callback The function to call when the event was fired
23819
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
23761
23820
  *
23762
- * @category Comment API
23763
- * @async
23821
+ * @category Comment Events
23764
23822
  */
23765
- const createComment = async (bundle) => {
23766
- var _a;
23823
+ const onLocalCommentReactionRemoved = (callback) => {
23767
23824
  const client = getActiveClient();
23768
- client.log('comment/createComment', bundle);
23769
- const { data } = await client.http.post('/api/v3/comments', bundle);
23770
- const { comments } = data;
23771
- // BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
23772
- if (comments.length === 0)
23773
- throw new Error('Comment not created');
23774
- const cachedAt = client.cache && Date.now();
23775
- if (client.cache)
23776
- ingestInCache(data, { cachedAt });
23777
- if (['post', 'content'].includes(bundle.referenceType)) {
23778
- const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
23779
- if (post) {
23780
- post.commentsCount += 1;
23781
- fireEvent('local.post.updated', {
23782
- posts: [post],
23783
- categories: [],
23784
- comments: [],
23785
- communities: [],
23786
- communityUsers: data.communityUsers,
23787
- feeds: [],
23788
- files: data.files,
23789
- postChildren: [],
23790
- users: data.users,
23791
- videoStreamings: [],
23792
- });
23825
+ const filter = ({ comment }) => {
23826
+ if (!client.cache) {
23827
+ callback(comment);
23793
23828
  }
23794
- }
23795
- else if (bundle.referenceType === 'story') {
23796
- const storyIndex = pullFromCache([
23797
- "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
23798
- bundle.referenceId,
23799
- ]);
23800
- if (storyIndex === null || storyIndex === void 0 ? void 0 : storyIndex.data) {
23801
- const cacheStory = pullFromCache([
23802
- "story" /* STORY_KEY_CACHE.STORY */,
23803
- 'get',
23804
- storyIndex.data,
23805
- ]);
23806
- if (cacheStory === null || cacheStory === void 0 ? void 0 : cacheStory.data) {
23807
- fireEvent('story.updated', {
23808
- stories: [
23809
- Object.assign(Object.assign({}, cacheStory.data), { commentsCount: cacheStory.data.commentsCount + 1, comments: [...new Set([...cacheStory.data.comments, comments[0].commentId])] }),
23810
- ],
23811
- categories: [],
23812
- comments,
23813
- communities: [],
23814
- communityUsers: data.communityUsers,
23815
- files: data.files,
23816
- users: data.users,
23817
- });
23818
- }
23829
+ else {
23830
+ upsertInCache(['comment', 'get', comment.commentId], comment);
23831
+ callback(commentLinkedObject(comment));
23819
23832
  }
23820
- }
23821
- fireEvent('local.comment.created', data);
23822
- return {
23823
- data: LinkedObject.comment(comments[0]),
23824
- cachedAt,
23825
23833
  };
23834
+ return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
23826
23835
  };
23827
- /* end_public_function */
23828
23836
 
23829
23837
  /* begin_public_function
23830
- id: comment.update_comment
23838
+ id: comment.get
23831
23839
  */
23832
23840
  /**
23833
23841
  * ```js
23834
- * import { CommentRepository } from '@amityco/ts-sdk'
23835
- * const updated = await CommentRepository.updateComment(commentId, {
23836
- * data: { text: 'hello world' }
23837
- * })
23842
+ * import { CommentRepository } from '@amityco/ts-sdk';
23843
+ *
23844
+ * let comment;
23845
+ *
23846
+ * const unsub = CommentRepository.getComment(commentId, response => {
23847
+ * comment = response.data;
23848
+ * });
23838
23849
  * ```
23839
23850
  *
23840
- * Updates an {@link Amity.Comment}
23851
+ * Observe all mutation on a given {@link Amity.Comment}
23841
23852
  *
23842
- * @param commentId The ID of the {@link Amity.Comment} to edit
23843
- * @param patch The patch data to apply
23844
- * @returns the updated {@link Amity.Comment} object
23853
+ * @param commentId the ID of the comment to observe
23854
+ * @param callback the function to call when new data are available
23855
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
23845
23856
  *
23846
- * @category Comment API
23847
- * @async
23857
+ * @category Comment Live Object
23848
23858
  */
23849
- const updateComment = async (commentId, patch) => {
23850
- const client = getActiveClient();
23851
- client.log('user/updateComment', patch);
23852
- const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
23853
- const cachedAt = client.cache && Date.now();
23854
- if (client.cache)
23855
- ingestInCache(data, { cachedAt });
23856
- fireEvent('comment.updated', data);
23857
- const { comments } = data;
23858
- return {
23859
- data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
23860
- cachedAt,
23861
- };
23859
+ const getComment = (commentId, callback) => {
23860
+ return liveObject(commentId, callback, 'commentId', getComment$1, [
23861
+ onCommentDeleteLocal,
23862
+ onCommentDeleted,
23863
+ onCommentFlagged,
23864
+ onCommentReactionAdded,
23865
+ onCommentReactionRemoved,
23866
+ onCommentUnflagged,
23867
+ onCommentUpdated,
23868
+ onLocalCommentReactionAdded,
23869
+ onLocalCommentReactionRemoved,
23870
+ ]);
23862
23871
  };
23863
23872
  /* end_public_function */
23864
23873
 
23865
- // Due to we have optimistic logic, we will use referenceId as a id in SDK instead of storyId
23866
- const applyMissingField = (rawData, isCreated = false) => {
23867
- const { storyId, referenceId } = rawData;
23868
- if (!isCreated) {
23869
- if (referenceId)
23870
- return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */ });
23874
+ class CommentPaginationController extends PaginationController {
23875
+ async getRequest(queryParams, token) {
23876
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
23877
+ const baseOptions = {
23878
+ type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
23879
+ };
23880
+ const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
23881
+ const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
23882
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
23883
+ });
23884
+ return queryResponse;
23871
23885
  }
23872
- return Object.assign(Object.assign({}, rawData), { syncState: "synced" /* Amity.SyncState.Synced */, referenceId: storyId });
23873
- };
23874
- const convertRawStoryToInternal = (data, isCreated = false) => {
23875
- const { stories } = data;
23876
- const storiesData = stories.map(story => applyMissingField(story, isCreated));
23877
- return Object.assign(Object.assign({}, data), { stories: storiesData });
23878
- };
23886
+ }
23879
23887
 
23880
- const getStoryByStoryId$1 = async (storyId) => {
23881
- const client = getActiveClient();
23882
- client.log('story/getStoryByStoryId', storyId);
23883
- // Get story referenceId from cache
23884
- const cacheReferenceId = pullFromCache([
23885
- "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
23886
- storyId,
23887
- ]);
23888
- if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
23889
- const { data: referenceId } = cacheReferenceId;
23890
- isInTombstone('story', referenceId);
23891
- }
23892
- let data;
23888
+ var EnumCommentActions;
23889
+ (function (EnumCommentActions) {
23890
+ EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
23891
+ EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
23892
+ EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
23893
+ EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
23894
+ EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
23895
+ EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
23896
+ EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
23897
+ })(EnumCommentActions || (EnumCommentActions = {}));
23898
+
23899
+ class CommentQueryStreamController extends QueryStreamController {
23900
+ constructor(query, cacheKey, notifyChange, preparePayload) {
23901
+ super(query, cacheKey);
23902
+ this.notifyChange = notifyChange;
23903
+ this.preparePayload = preparePayload;
23904
+ }
23905
+ async saveToMainDB(response) {
23906
+ const processedPayload = await this.preparePayload(response);
23907
+ const client = getActiveClient();
23908
+ const cachedAt = client.cache && Date.now();
23909
+ if (client.cache) {
23910
+ ingestInCache(processedPayload, { cachedAt });
23911
+ }
23912
+ }
23913
+ appendToQueryStream(response, direction, refresh = false) {
23914
+ var _a, _b;
23915
+ if (refresh) {
23916
+ pushToCache(this.cacheKey, {
23917
+ data: response.comments.map(getResolver('comment')),
23918
+ });
23919
+ }
23920
+ else {
23921
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23922
+ const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
23923
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
23924
+ }
23925
+ }
23926
+ reactor(action) {
23927
+ return (comment) => {
23928
+ var _a;
23929
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23930
+ if (this.query.referenceId !== comment.referenceId ||
23931
+ this.query.referenceType !== comment.referenceType ||
23932
+ !collection) {
23933
+ return;
23934
+ }
23935
+ if (this.query.parentId && this.query.parentId !== comment.parentId) {
23936
+ return;
23937
+ }
23938
+ if (!this.query.parentId && comment.parentId) {
23939
+ return;
23940
+ }
23941
+ if (action === EnumCommentActions.OnCommentCreated) {
23942
+ collection.data = [...new Set([comment.commentId, ...collection.data])];
23943
+ }
23944
+ pushToCache(this.cacheKey, collection);
23945
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
23946
+ };
23947
+ }
23948
+ subscribeRTE(createSubscriber) {
23949
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
23950
+ }
23951
+ }
23952
+
23953
+ /**
23954
+ * ```js
23955
+ * import { onCommentCreated } from '@amityco/ts-sdk'
23956
+ * const dispose = onCommentCreated(comment => {
23957
+ * // ...
23958
+ * })
23959
+ * ```
23960
+ *
23961
+ * Fired when a {@link Amity.InternalComment} has been created
23962
+ *
23963
+ * @param callback The function to call when the event was fired
23964
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
23965
+ *
23966
+ * @category Comment Events
23967
+ */
23968
+ const onCommentCreatedLocal = (callback) => {
23969
+ return createLocalCommentEventSubscriber('local.comment.created', callback);
23970
+ };
23971
+
23972
+ class CommentLiveCollectionController extends LiveCollectionController {
23973
+ constructor(query, callback) {
23974
+ const queryStreamId = hash__default["default"](query);
23975
+ const cacheKey = ['comments', 'collection', queryStreamId];
23976
+ const paginationController = new CommentPaginationController(query);
23977
+ super(paginationController, queryStreamId, cacheKey, callback);
23978
+ this.query = query;
23979
+ this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
23980
+ this.callback = callback.bind(this);
23981
+ this.loadPage({ initial: true });
23982
+ }
23983
+ setup() {
23984
+ var _a;
23985
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23986
+ if (!collection) {
23987
+ pushToCache(this.cacheKey, {
23988
+ data: [],
23989
+ params: {},
23990
+ });
23991
+ }
23992
+ }
23993
+ async persistModel(queryPayload) {
23994
+ await this.queryStreamController.saveToMainDB(queryPayload);
23995
+ }
23996
+ persistQueryStream({ response, direction, refresh, }) {
23997
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
23998
+ }
23999
+ startSubscription() {
24000
+ return this.queryStreamController.subscribeRTE([
24001
+ { fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
24002
+ { fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
24003
+ { fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
24004
+ { fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
24005
+ { fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
24006
+ { fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
24007
+ { fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
24008
+ { fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
24009
+ { fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
24010
+ { fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
24011
+ { fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
24012
+ ]);
24013
+ }
24014
+ notifyChange({ origin, loading, error }) {
24015
+ var _a, _b;
24016
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24017
+ if (!collection)
24018
+ return;
24019
+ const data = this.applyFilter((_b = collection.data
24020
+ .map(id => pullFromCache(['comment', 'get', id]))
24021
+ .filter(isNonNullable)
24022
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
24023
+ if (!this.shouldNotify(data) && origin === 'event')
24024
+ return;
24025
+ this.callback({
24026
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
24027
+ data,
24028
+ hasNextPage: !!this.paginationController.getNextToken(),
24029
+ loading,
24030
+ error,
24031
+ });
24032
+ }
24033
+ applyFilter(data) {
24034
+ let comments = data;
24035
+ if (!this.query.includeDeleted) {
24036
+ comments = filterByPropEquality(comments, 'isDeleted', false);
24037
+ }
24038
+ if (this.query.parentId) {
24039
+ comments = comments.filter(comment => comment.parentId === this.query.parentId);
24040
+ }
24041
+ if (typeof this.query.hasFlag === 'boolean') {
24042
+ if (this.query.hasFlag) {
24043
+ comments = comments.filter(comment => comment.hashFlag != null);
24044
+ }
24045
+ else {
24046
+ comments = comments.filter(comment => comment.hashFlag == null);
24047
+ }
24048
+ }
24049
+ if (this.query.dataTypes) {
24050
+ if (this.query.dataTypes.matchType === 'exact') {
24051
+ comments = comments.filter(comment => {
24052
+ var _a, _b;
24053
+ const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
24054
+ const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
24055
+ if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
24056
+ return false;
24057
+ }
24058
+ return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
24059
+ });
24060
+ }
24061
+ if (this.query.dataTypes.matchType === 'any') {
24062
+ 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); }); });
24063
+ }
24064
+ }
24065
+ switch (this.query.sortBy) {
24066
+ case 'firstCreated':
24067
+ comments = comments.sort(sortByFirstCreated);
24068
+ break;
24069
+ case 'lastCreated':
24070
+ default:
24071
+ comments = comments.sort(sortByLastCreated);
24072
+ break;
24073
+ }
24074
+ return comments;
24075
+ }
24076
+ }
24077
+
24078
+ /* begin_public_function
24079
+ id: comment.query
24080
+ */
24081
+ /**
24082
+ * ```js
24083
+ * import { getComments } from '@amityco/ts-sdk'
24084
+ *
24085
+ * let comments = []
24086
+ * const unsub = getComments({
24087
+ * referenceType: Amity.InternalComment['referenceType'];
24088
+ * referenceId: Amity.InternalComment['referenceId'];
24089
+ * }, response => merge(comments, response.data))
24090
+ * ```
24091
+ *
24092
+ * Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
24093
+ *
24094
+ * @param referenceType the type of the target
24095
+ * @param referenceId the ID of the target
24096
+ * @param callback the function to call when new data are available
24097
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
24098
+ *
24099
+ * @category Comments Live Collection
24100
+ */
24101
+ const getComments = (params, callback, config) => {
24102
+ const { log, cache } = getActiveClient();
24103
+ if (!cache) {
24104
+ console.log('For using Live Collection feature you need to enable Cache!');
24105
+ }
24106
+ const timestamp = Date.now();
24107
+ log(`getComments(tmpid: ${timestamp}) > listen`);
24108
+ const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
24109
+ const disposers = commentsLiveCollection.startSubscription();
24110
+ const cacheKey = commentsLiveCollection.getCacheKey();
24111
+ disposers.push(() => dropFromCache(cacheKey));
24112
+ return () => {
24113
+ log(`getComments(tmpid: ${timestamp}) > dispose`);
24114
+ disposers.forEach(fn => fn());
24115
+ };
24116
+ };
24117
+ /* end_public_function */
24118
+
24119
+ var index$a = /*#__PURE__*/Object.freeze({
24120
+ __proto__: null,
24121
+ getCommentByIds: getCommentByIds,
24122
+ createComment: createComment,
24123
+ updateComment: updateComment,
24124
+ deleteComment: deleteComment,
24125
+ softDeleteComment: softDeleteComment,
24126
+ hardDeleteComment: hardDeleteComment,
24127
+ flagComment: flagComment,
24128
+ unflagComment: unflagComment,
24129
+ isCommentFlaggedByMe: isCommentFlaggedByMe,
24130
+ onCommentCreated: onCommentCreated,
24131
+ onCommentUpdated: onCommentUpdated,
24132
+ onCommentDeleted: onCommentDeleted,
24133
+ onCommentFlagged: onCommentFlagged,
24134
+ onCommentUnflagged: onCommentUnflagged,
24135
+ onCommentReactionAdded: onCommentReactionAdded,
24136
+ onCommentReactionRemoved: onCommentReactionRemoved,
24137
+ getComment: getComment,
24138
+ getComments: getComments
24139
+ });
24140
+
24141
+ const getPost$1 = async (postId) => {
24142
+ const client = getActiveClient();
24143
+ client.log('post/getPost', postId);
24144
+ isInTombstone('post', postId);
24145
+ let payload;
23893
24146
  try {
23894
- const response = await client.http.get(`/api/v4/stories/${storyId}`);
23895
- data = convertRawStoryToInternal(response.data);
24147
+ // API-FIX: endpoint should not be /list, parameters should be querystring.
24148
+ const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
24149
+ payload = response.data;
24150
+ }
24151
+ catch (error) {
24152
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
24153
+ pushToTombstone('post', postId);
24154
+ }
24155
+ throw error;
24156
+ }
24157
+ const data = prepareMembershipPayload(payload, 'communityUsers');
24158
+ const cachedAt = client.cache && Date.now();
24159
+ if (client.cache)
24160
+ ingestInCache(data, { cachedAt });
24161
+ const { posts } = data;
24162
+ const result = posts.find(post => post.postId === postId);
24163
+ return {
24164
+ data: result,
24165
+ cachedAt,
24166
+ };
24167
+ };
24168
+ getPost$1.locally = (postId) => {
24169
+ const client = getActiveClient();
24170
+ client.log('post/getPost.locally', postId);
24171
+ if (!client.cache)
24172
+ return;
24173
+ const cached = pullFromCache(['post', 'get', postId]);
24174
+ if (!cached)
24175
+ return;
24176
+ return {
24177
+ data: cached.data,
24178
+ cachedAt: cached.cachedAt,
24179
+ };
24180
+ };
24181
+
24182
+ /**
24183
+ * ```js
24184
+ * import { onLocalPostDeleted } from '@amityco/ts-sdk'
24185
+ * const dispose = onLocalPostDeleted(post => {
24186
+ * // ...
24187
+ * })
24188
+ * ```
24189
+ *
24190
+ * Fired when a {@link Amity.InternalPost} has been deleted
24191
+ *
24192
+ * @param callback The function to call when the event was fired
24193
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
24194
+ *
24195
+ * @category Post Events
24196
+ */
24197
+ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
24198
+
24199
+ /**
24200
+ * ```js
24201
+ * import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
24202
+ * const dispose = onPostReactionAdded(post => {
24203
+ * // ...
24204
+ * })
24205
+ * ```
24206
+ *
24207
+ * Fired when a {@link Amity.InternalPost} has been reacted
24208
+ *
24209
+ * @param callback The function to call when the event was fired
24210
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
24211
+ *
24212
+ * @category Post Events
24213
+ */
24214
+ const onLocalPostReactionAdded = (callback) => {
24215
+ const client = getActiveClient();
24216
+ const filter = ({ post }) => {
24217
+ if (!client.cache) {
24218
+ callback(post);
24219
+ }
24220
+ else {
24221
+ upsertInCache(['post', 'get', post.postId], post);
24222
+ callback(post);
24223
+ }
24224
+ };
24225
+ return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
24226
+ };
24227
+
24228
+ /**
24229
+ * ```js
24230
+ * import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
24231
+ * const dispose = onPostReactionRemoved(post => {
24232
+ * // ...
24233
+ * })
24234
+ * ```
24235
+ *
24236
+ * Fired when a {@link Amity.InternalPost} has been reacted
24237
+ *
24238
+ * @param callback The function to call when the event was fired
24239
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
24240
+ *
24241
+ * @category Post Events
24242
+ */
24243
+ const onLocalPostReactionRemoved = (callback) => {
24244
+ const client = getActiveClient();
24245
+ const filter = ({ post }) => {
24246
+ if (!client.cache) {
24247
+ callback(post);
24248
+ }
24249
+ else {
24250
+ upsertInCache(['post', 'get', post.postId], post);
24251
+ callback(post);
24252
+ }
24253
+ };
24254
+ return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
24255
+ };
24256
+
24257
+ /**
24258
+ * ```js
24259
+ * import { onPostUpdatedLocal } from '@amityco/ts-sdk'
24260
+ * const dispose = onPostUpdatedLocal(post => {
24261
+ * // ...
24262
+ * })
24263
+ * ```
24264
+ *
24265
+ * Fired when a {@link Amity.InternalPost} has been updated
24266
+ *
24267
+ * @param callback The function to call when the event was fired
24268
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
24269
+ *
24270
+ * @category Post Events
24271
+ */
24272
+ const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
24273
+
24274
+ const commentEventHandler$1 = (callback, eventHandler, cacheKey) => {
24275
+ return eventHandler(async (comment) => {
24276
+ var _a;
24277
+ const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24278
+ if (!currentCollection || !currentCollection.data.includes(comment.referenceId))
24279
+ return;
24280
+ await getPost$1(comment.referenceId);
24281
+ callback(comment);
24282
+ });
24283
+ };
24284
+ const generateCommentSubscriptions$1 = (cacheKey) => {
24285
+ const eventHandlers = [
24286
+ onCommentCreated,
24287
+ onCommentDeleted,
24288
+ onCommentReactionAdded,
24289
+ onCommentReactionRemoved,
24290
+ onCommentCreatedLocal,
24291
+ onCommentDeleteLocal,
24292
+ onLocalCommentReactionAdded,
24293
+ onLocalCommentReactionRemoved,
24294
+ ];
24295
+ return eventHandlers.map(handler => ({
24296
+ fn: convertEventPayload((callback) => commentEventHandler$1(callback, handler, cacheKey), 'referenceId', 'post'),
24297
+ action: EnumPostActions.OnPostUpdated,
24298
+ }));
24299
+ };
24300
+ const getGlobalFeedSubscriptions = (cacheKey) => {
24301
+ return [
24302
+ { fn: onPostCreated, action: EnumPostActions.OnPostCreated },
24303
+ { fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
24304
+ { fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
24305
+ { fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
24306
+ { fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
24307
+ { fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
24308
+ { fn: onPostApproved, action: EnumPostActions.OnPostApproved },
24309
+ { fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
24310
+ { fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
24311
+ { fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
24312
+ { fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
24313
+ { fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
24314
+ { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
24315
+ ...generateCommentSubscriptions$1(cacheKey),
24316
+ ];
24317
+ };
24318
+
24319
+ class CustomRankingGlobalFeedLiveCollectionController extends LiveCollectionController {
24320
+ constructor(query, callback) {
24321
+ const queryStreamId = hash__default["default"](query);
24322
+ const cacheKey = ['customRankingGlobalFeed', 'collection', queryStreamId];
24323
+ const paginationController = new CustomRankingGlobalFeedPaginationController(query);
24324
+ super(paginationController, queryStreamId, cacheKey, callback);
24325
+ this.query = query;
24326
+ this.queryStreamController = new CustomRankingGlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
24327
+ this.callback = callback.bind(this);
24328
+ this.loadPage({ initial: true });
23896
24329
  }
23897
- catch (error) {
23898
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
23899
- pushToTombstone('story', storyId);
24330
+ setup() {
24331
+ var _a;
24332
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24333
+ if (!collection) {
24334
+ pushToCache(this.cacheKey, {
24335
+ data: [],
24336
+ params: {},
24337
+ });
23900
24338
  }
23901
- throw error;
23902
24339
  }
23903
- const cachedAt = client.cache && Date.now();
23904
- if (client.cache) {
23905
- ingestInCache(data, { cachedAt });
24340
+ async persistModel(queryPayload) {
24341
+ await this.queryStreamController.saveToMainDB(queryPayload);
23906
24342
  }
23907
- return {
23908
- data: data.stories[0],
23909
- cachedAt,
23910
- };
23911
- };
23912
- getStoryByStoryId$1.locally = (storyId) => {
23913
- const client = getActiveClient();
23914
- client.log('story/getStorybyStoryId', storyId);
23915
- // Get story referenceId from cache
23916
- const cacheReferenceId = pullFromCache([
23917
- "story-reference" /* STORY_KEY_CACHE.STORY_ID_TO_REFERENCE_ID */,
23918
- storyId,
23919
- ]);
23920
- if (cacheReferenceId === null || cacheReferenceId === void 0 ? void 0 : cacheReferenceId.data) {
23921
- const { data: referenceId } = cacheReferenceId;
23922
- isInTombstone('story', referenceId);
24343
+ persistQueryStream({ response, direction, refresh, }) {
24344
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
23923
24345
  }
23924
- const cachedAt = client.cache && Date.now();
23925
- const storyCache = pullFromCache(['story', 'get', storyId]);
23926
- if (!storyCache)
23927
- return;
23928
- return {
23929
- data: storyCache.data,
23930
- cachedAt,
23931
- };
23932
- };
24346
+ startSubscription() {
24347
+ return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
24348
+ }
24349
+ notifyChange({ origin, loading, error }) {
24350
+ var _a, _b;
24351
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24352
+ if (!collection)
24353
+ return;
24354
+ const data = ((_b = collection.data
24355
+ .map(id => pullFromCache(['post', 'get', id]))
24356
+ .filter(isNonNullable)
24357
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
24358
+ if (!this.shouldNotify(data) && origin === 'event')
24359
+ return;
24360
+ this.callback({
24361
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
24362
+ data,
24363
+ hasNextPage: !!this.paginationController.getNextToken(),
24364
+ loading,
24365
+ error,
24366
+ });
24367
+ }
24368
+ }
23933
24369
 
23934
24370
  /* begin_public_function
23935
- id: comment.soft_delete, comment.hard_delete
24371
+ id: feed.query.custom_ranking_feed
23936
24372
  */
23937
24373
  /**
23938
24374
  * ```js
23939
- * import { CommentRepository } from '@amityco/ts-sdk'
23940
- * const success = await CommentRepository.deleteComment('foobar')
24375
+ * import { FeedRepository } from '@amityco/ts-sdk'
24376
+ *
24377
+ * let posts = []
24378
+ * const unsub = FeedRepository.getGlobalFeed({
24379
+ * dataTypes: ['video','image'],
24380
+ * resolveParent: true,
24381
+ * }, response => processResponse(response))
23941
24382
  * ```
23942
24383
  *
23943
- * Deletes a {@link Amity.Comment}
24384
+ * Observe all mutations on a list of {@link Amity.Post} for a given target object
23944
24385
  *
23945
- * @param commentId The {@link Amity.Comment} ID to delete
23946
- * @return A success boolean if the {@link Amity.Comment} was deleted
24386
+ * @param params.dataTypes array of data types for the posts
24387
+ * @param callback the function to call when new data are available
24388
+ * @param config
24389
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
23947
24390
  *
23948
- * @category Comment API
23949
- * @async
24391
+ * @category Posts Live Collection
23950
24392
  */
23951
- const deleteComment = async (commentId, permanent = false) => {
23952
- var _a;
23953
- const client = getActiveClient();
23954
- const comment = await getComment$2(commentId);
23955
- // API-FIX: This endpoint has not been implemented yet.
23956
- await client.http.delete(`/api/v4/comments/${encodeURIComponent(commentId)}`, {
23957
- params: {
23958
- commentId,
23959
- permanent,
23960
- },
23961
- });
23962
- // to support hard deletion
23963
- const deleted = Object.assign(Object.assign({}, comment.data), { isDeleted: true });
23964
- if (comment.data.referenceType === 'story') {
23965
- const story = await getStoryByStoryId$1(comment.data.referenceId);
23966
- fireEvent('local.story.updated', {
23967
- stories: [story.data],
23968
- categories: [],
23969
- comments: [],
23970
- communities: [],
23971
- communityUsers: [],
23972
- files: [],
23973
- users: [],
24393
+ const getCustomRankingGlobalFeed = (params, callback, config) => {
24394
+ const { log, cache } = getActiveClient();
24395
+ if (!cache) {
24396
+ console.log(ENABLE_CACHE_MESSAGE);
24397
+ }
24398
+ const timestamp = Date.now();
24399
+ log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > listen`);
24400
+ const liveCollection = new CustomRankingGlobalFeedLiveCollectionController(params, callback);
24401
+ const disposers = liveCollection.startSubscription();
24402
+ const cacheKey = liveCollection.getCacheKey();
24403
+ disposers.push(() => dropFromCache(cacheKey));
24404
+ return () => {
24405
+ log(`getCustomRankingGlobalFeed(tmpid: ${timestamp}) > dispose`);
24406
+ disposers.forEach(fn => fn());
24407
+ };
24408
+ };
24409
+ /* end_public_function */
24410
+
24411
+ class GlobalFeedPaginationController extends PaginationController {
24412
+ async getRequest(queryParams, token) {
24413
+ const { limit, resolveParent } = queryParams, params = __rest(queryParams, ["limit", "resolveParent"]);
24414
+ const options = token ? { token } : { limit };
24415
+ const { data: queryResponse } = await this.http.get(`/api/v4/me/global-feeds`, {
24416
+ params: Object.assign(Object.assign({}, params), { resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
23974
24417
  });
24418
+ return queryResponse;
23975
24419
  }
23976
- else {
23977
- const post = (_a = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
23978
- if (post) {
23979
- let removeCount;
23980
- if (!deleted.parentId) {
23981
- // NOTE: delete the parent comment will remove all children comments
23982
- removeCount = deleted.childrenNumber + 1;
24420
+ }
24421
+
24422
+ class GlobalFeedQueryStreamController extends QueryStreamController {
24423
+ constructor(query, cacheKey, notifyChange, preparePayload) {
24424
+ super(query, cacheKey);
24425
+ this.notifyChange = notifyChange;
24426
+ this.preparePayload = preparePayload;
24427
+ }
24428
+ async saveToMainDB(response) {
24429
+ const processedPayload = await this.preparePayload(response);
24430
+ const client = getActiveClient();
24431
+ const cachedAt = client.cache && Date.now();
24432
+ if (client.cache) {
24433
+ ingestInCache(processedPayload, { cachedAt });
24434
+ }
24435
+ }
24436
+ appendToQueryStream(response, direction, refresh = false) {
24437
+ var _a, _b;
24438
+ if (refresh) {
24439
+ pushToCache(this.cacheKey, {
24440
+ data: response.posts.map(getResolver('post')),
24441
+ });
24442
+ }
24443
+ else {
24444
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24445
+ const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
24446
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
24447
+ }
24448
+ }
24449
+ reactor(action) {
24450
+ return (post) => {
24451
+ var _a;
24452
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24453
+ if (!collection)
24454
+ return;
24455
+ if (post.parentPostId && !collection.data.includes(post.parentPostId))
24456
+ return;
24457
+ // Delete Action
24458
+ if (action === EnumPostActions.OnPostDeleted) {
24459
+ // Parent Post - Remove from collection
24460
+ collection.data = collection.data.filter(postId => postId !== post.postId);
23983
24461
  }
23984
- else
23985
- removeCount = 1;
23986
- post.commentsCount -= removeCount;
23987
- fireEvent('local.post.updated', {
23988
- posts: [post],
23989
- categories: [],
23990
- comments: [],
23991
- communities: [],
23992
- communityUsers: [],
23993
- feeds: [],
23994
- files: [],
23995
- postChildren: [],
23996
- users: [],
23997
- videoStreamings: [],
24462
+ if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
24463
+ // If the query has dataTypes array with value, check if post.dataType is include in the array
24464
+ if (this.query.dataTypes && this.query.dataTypes.length > 0) {
24465
+ if (!this.query.dataTypes.includes(post.dataType))
24466
+ return;
24467
+ }
24468
+ collection.data = [...new Set([post.postId, ...collection.data])];
24469
+ }
24470
+ if (action === EnumPostActions.OnPostDeclined) {
24471
+ collection.data = collection.data.filter(postId => postId !== post.postId);
24472
+ }
24473
+ pushToCache(this.cacheKey, collection);
24474
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
24475
+ };
24476
+ }
24477
+ subscribeRTE(createSubscriber) {
24478
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
24479
+ }
24480
+ }
24481
+
24482
+ class GlobalFeedLiveCollectionController extends LiveCollectionController {
24483
+ constructor(query, callback) {
24484
+ const queryStreamId = hash__default["default"](query);
24485
+ const cacheKey = ['globalFeed', 'collection', queryStreamId];
24486
+ const paginationController = new GlobalFeedPaginationController(query);
24487
+ super(paginationController, queryStreamId, cacheKey, callback);
24488
+ this.query = query;
24489
+ this.queryStreamController = new GlobalFeedQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
24490
+ this.callback = callback.bind(this);
24491
+ this.loadPage({ initial: true });
24492
+ }
24493
+ setup() {
24494
+ var _a;
24495
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24496
+ if (!collection) {
24497
+ pushToCache(this.cacheKey, {
24498
+ data: [],
24499
+ params: {},
23998
24500
  });
23999
24501
  }
24000
24502
  }
24001
- fireEvent('local.comment.deleted', {
24002
- comments: [deleted],
24003
- commentChildren: [],
24004
- files: [],
24005
- users: [],
24006
- communityUsers: [],
24007
- });
24008
- if (permanent) {
24009
- scheduleTask(() => pushToTombstone('comment', commentId));
24503
+ async persistModel(queryPayload) {
24504
+ await this.queryStreamController.saveToMainDB(queryPayload);
24010
24505
  }
24011
- else {
24012
- upsertInCache(['comment', 'get', commentId], { isDeleted: true });
24506
+ persistQueryStream({ response, direction, refresh, }) {
24507
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
24508
+ }
24509
+ startSubscription() {
24510
+ return this.queryStreamController.subscribeRTE(getGlobalFeedSubscriptions(this.cacheKey));
24511
+ }
24512
+ notifyChange({ origin, loading, error }) {
24513
+ var _a, _b;
24514
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24515
+ if (!collection)
24516
+ return;
24517
+ const data = ((_b = collection.data
24518
+ .map(id => pullFromCache(['post', 'get', id]))
24519
+ .filter(isNonNullable)
24520
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
24521
+ if (!this.shouldNotify(data) && origin === 'event')
24522
+ return;
24523
+ this.callback({
24524
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
24525
+ data,
24526
+ hasNextPage: !!this.paginationController.getNextToken(),
24527
+ loading,
24528
+ error,
24529
+ });
24013
24530
  }
24014
- return deleted;
24015
- };
24016
- /* end_public_function */
24531
+ }
24017
24532
 
24018
24533
  /* begin_public_function
24019
- id: comment.soft_delete
24534
+ id: feed.query.global_feed
24020
24535
  */
24021
24536
  /**
24022
24537
  * ```js
24023
- * import { CommentRepository } from '@amityco/ts-sdk'
24024
- * const success = await CommentRepository.softDeleteComment('foobar')
24025
- * ```
24026
- *
24027
- * Deletes a {@link Amity.Comment}
24028
- *
24029
- * @param commentId The {@link Amity.Comment} ID to delete
24030
- * @return A success boolean if the {@link Amity.Comment} was deleted
24538
+ * import { FeedRepository } from '@amityco/ts-sdk'
24031
24539
  *
24032
- * @category Comment API
24033
- * @async
24034
- */
24035
- const softDeleteComment = async (commentId) => {
24036
- const client = getActiveClient();
24037
- client.log('comment/softDeleteComment', commentId);
24038
- const softDeleted = deleteComment(commentId);
24039
- return softDeleted;
24040
- };
24041
- /* end_public_function */
24042
-
24043
- /* begin_public_function
24044
- id: comment.hard_delete
24045
- */
24046
- /**
24047
- * ```js
24048
- * import { CommentRepository } from '@amityco/ts-sdk'
24049
- * const success = await CommentRepository.hardDeleteComment('foobar')
24540
+ * let posts = []
24541
+ * const unsub = FeedRepository.getGlobalFeed({
24542
+ * dataTypes: ['video','image'],
24543
+ * resolveParent: true,
24544
+ * }, response => processResponse(response))
24050
24545
  * ```
24051
24546
  *
24052
- * Deletes a {@link Amity.Comment}
24053
- *
24054
- * @param commentId The {@link Amity.Comment} ID to delete
24055
- * @return A success boolean if the {@link Amity.Comment} was deleted
24547
+ * Observe all mutations on a list of {@link Amity.Post} for global feed
24548
+ * @param params.dataTypes array of data types for the posts
24549
+ * @param params.resolveParent
24550
+ * @param callback the function to call when new data are available
24551
+ * @param config
24552
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
24056
24553
  *
24057
- * @category Comment API
24058
- * @async
24554
+ * @category Posts Live Collection
24059
24555
  */
24060
- const hardDeleteComment = async (commentId) => {
24061
- const client = getActiveClient();
24062
- client.log('comment/hardDeleteComment', commentId);
24063
- const hardDeleted = deleteComment(commentId, true);
24064
- return hardDeleted;
24065
- };
24066
- /* end_public_function */
24067
-
24068
- /* begin_public_function
24069
- id: comment.flag
24070
- */
24071
- /**
24072
- * ```js
24073
- * import { CommentRepository } from '@amityco/ts-sdk'
24074
- * const flagged = await CommentRepository.flagComment(commentId, reason)
24075
- * ```
24076
- *
24077
- * @param commentId The ID of the comment to flag
24078
- * @param reason the reason to flag the comment
24079
- * @returns the created report result
24080
- *
24081
- * @category Comment API
24082
- * @async
24083
- * */
24084
- const flagComment = async (commentId, reason) => {
24085
- const client = getActiveClient();
24086
- client.log('comment/flagComment', commentId);
24087
- const isPredefinedReason = reason &&
24088
- Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
24089
- const body = {
24090
- reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
24091
- detail: reason && !isPredefinedReason ? reason : '',
24092
- };
24093
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
24094
- if (client.cache) {
24095
- ingestInCache(payload);
24556
+ const getGlobalFeed = (params, callback, config) => {
24557
+ const { log, cache } = getActiveClient();
24558
+ if (!cache) {
24559
+ console.log(ENABLE_CACHE_MESSAGE);
24096
24560
  }
24097
- fireEvent('comment.flagged', payload);
24098
- return !!payload;
24561
+ const timestamp = Date.now();
24562
+ log(`getGlobalFeed(tmpid: ${timestamp}) > listen`);
24563
+ const liveCollection = new GlobalFeedLiveCollectionController(params, callback);
24564
+ const disposers = liveCollection.startSubscription();
24565
+ const cacheKey = liveCollection.getCacheKey();
24566
+ disposers.push(() => dropFromCache(cacheKey));
24567
+ return () => {
24568
+ log(`getGlobalFeed(tmpid: ${timestamp}) > dispose`);
24569
+ disposers.forEach(fn => fn());
24570
+ };
24099
24571
  };
24100
24572
  /* end_public_function */
24101
24573
 
24102
- /* begin_public_function
24103
- id: comment.unflag
24104
- */
24105
- /**
24106
- * ```js
24107
- * import { CommentRepository } from '@amityco/ts-sdk'
24108
- * const unflagged = await CommentRepository.unflagComment('commentId')
24109
- * ```
24110
- *
24111
- * @param commentId The ID of comment to unflag
24112
- * @returns the unflagged result
24113
- *
24114
- * @category Comment API
24115
- * @async
24116
- * */
24117
- const unflagComment = async (commentId) => {
24118
- const client = getActiveClient();
24119
- client.log('comment/unflagComment', commentId);
24120
- const { data: payload } = await client.http.delete(`/api/v3/comments/${encodeURIComponent(commentId)}/unflag`);
24121
- if (client.cache) {
24122
- ingestInCache(payload);
24123
- }
24124
- fireEvent('comment.unflagged', payload);
24125
- return !!payload;
24126
- };
24127
- /* end_public_function */
24574
+ var index$9 = /*#__PURE__*/Object.freeze({
24575
+ __proto__: null,
24576
+ queryGlobalFeed: queryGlobalFeed,
24577
+ getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
24578
+ getGlobalFeed: getGlobalFeed
24579
+ });
24128
24580
 
24129
24581
  /* begin_public_function
24130
- id: comment.check_flag_by_me
24582
+ id: post.get_by_ids
24131
24583
  */
24132
24584
  /**
24133
24585
  * ```js
24134
- * import { CommentRepository } from '@amityco/ts-sdk'
24135
- * const isReported = await CommentRepository.isCommentFlaggedByMe('commentId')
24586
+ * import { getPostByIds } from '@amityco/ts-sdk'
24587
+ * const { data: posts } = await getPostByIds(['foo', 'bar'])
24136
24588
  * ```
24137
24589
  *
24138
- * @param commentId The ID of the comment to check if flagged by current user
24139
- * @returns `true` if the comment is flagged by me, `false` if doesn't.
24590
+ * Fetches a collection of {@link Amity.Post} objects
24140
24591
  *
24141
- * @category Comment API
24592
+ * @param postIds the IDs of the {@link Amity.Post} to fetch
24593
+ * @returns the associated collection of {@link Amity.Post} objects
24594
+ *
24595
+ * @category Post API
24142
24596
  * @async
24143
- * */
24144
- const isCommentFlaggedByMe = async (commentId) => {
24145
- const client = getActiveClient();
24146
- client.log('comment/isCommentFlaggedByMe', commentId);
24147
- const { data: { result }, } = await client.http.get(`/api/v3/comments/${commentId}/isflagbyme`);
24148
- return result;
24149
- };
24150
- /* end_public_function */
24151
-
24152
- const getComment$1 = async (commentId) => {
24597
+ */
24598
+ const getPostByIds = async (postIds) => {
24153
24599
  const client = getActiveClient();
24154
- client.log('comment/getComment', commentId);
24155
- isInTombstone('comment', commentId);
24156
- let data;
24600
+ client.log('post/getPostByIds', postIds);
24601
+ const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
24602
+ let payload;
24157
24603
  try {
24158
24604
  // API-FIX: endpoint should not be /list, parameters should be querystring.
24159
- const response = await client.http.get(`/api/v3/comments/${encodeURIComponent(commentId)}`);
24160
- data = response.data;
24605
+ const response = await client.http.get(`/api/v3/posts/list`, {
24606
+ params: { postIds: encodedPostIds },
24607
+ });
24608
+ payload = response.data;
24161
24609
  }
24162
24610
  catch (error) {
24163
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
24164
- pushToTombstone('comment', commentId);
24165
- }
24611
+ postIds.forEach(postId => {
24612
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
24613
+ pushToTombstone('post', postId);
24614
+ }
24615
+ });
24166
24616
  throw error;
24167
24617
  }
24618
+ const data = prepareMembershipPayload(payload, 'communityUsers');
24168
24619
  const cachedAt = client.cache && Date.now();
24169
24620
  if (client.cache)
24170
24621
  ingestInCache(data, { cachedAt });
24171
- const { comments } = data;
24172
24622
  return {
24173
- data: comments.find(comment => comment.commentId === commentId),
24623
+ data: data.posts.map(LinkedObject.post),
24174
24624
  cachedAt,
24175
24625
  };
24176
24626
  };
24177
- getComment$1.locally = (commentId) => {
24627
+ /* end_public_function */
24628
+ /**
24629
+ * ```js
24630
+ * import { getPostByIds } from '@amityco/ts-sdk'
24631
+ * const { data: posts } = getPostByIds.locally(['foo', 'bar'])
24632
+ * ```
24633
+ *
24634
+ * Fetches a collection of {@link Amity.Post} objects from cache
24635
+ *
24636
+ * @param postIds the IDs of the {@link Amity.Post} to fetch
24637
+ * @returns the associated collection of {@link Amity.Post} objects
24638
+ *
24639
+ * @category Post API
24640
+ */
24641
+ getPostByIds.locally = (postIds) => {
24642
+ var _a;
24178
24643
  const client = getActiveClient();
24179
- client.log('comment/getComment.locally', commentId);
24644
+ client.log('post/getPostByIds.locally', postIds);
24180
24645
  if (!client.cache)
24181
24646
  return;
24182
- const cached = pullFromCache(['comment', 'get', commentId]);
24183
- if (!cached)
24647
+ const cached = postIds
24648
+ .map(postId => pullFromCache(['post', 'get', postId]))
24649
+ .filter(Boolean);
24650
+ const posts = cached.map(({ data }) => data);
24651
+ const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
24652
+ if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
24184
24653
  return;
24185
24654
  return {
24186
- data: cached.data,
24187
- cachedAt: cached.cachedAt,
24655
+ data: posts.map(LinkedObject.post),
24656
+ cachedAt: oldest.cachedAt,
24188
24657
  };
24189
24658
  };
24190
24659
 
24660
+ /* begin_public_function
24661
+ 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
24662
+ */
24191
24663
  /**
24192
24664
  * ```js
24193
- * import { onCommentDeleteLocal } from '@amityco/ts-sdk'
24194
- * const dispose = onCommentDeleteLocal(comment => {
24195
- * // ...
24196
- * })
24665
+ * import { PostRepository } from '@amityco/ts-sdk'
24666
+ * const created = await PostRepository.createPost({
24667
+ * targetType: 'user',
24668
+ * targetId: 'foobar',
24669
+ * data: { text: 'hello world' }
24670
+ * }))
24197
24671
  * ```
24198
24672
  *
24199
- * Fired when a {@link Amity.InternalComment} has been deleted
24673
+ * Creates an {@link Amity.Post}
24200
24674
  *
24201
- * @param callback The function to call when the event was fired
24202
- * @returns an {@link Amity.Unsubscriber} function to stop listening
24675
+ * @param bundle The data necessary to create a new {@link Amity.Post}
24676
+ * @returns The newly created {@link Amity.Post}
24203
24677
  *
24204
- * @category Comment Events
24678
+ * @category Post API
24679
+ * @async
24205
24680
  */
24206
- const onCommentDeleteLocal = (callback) => createLocalCommentEventSubscriber('local.comment.deleted', callback);
24681
+ const createPost = async (bundle) => {
24682
+ const client = getActiveClient();
24683
+ client.log('post/createPost', bundle);
24684
+ if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
24685
+ // eslint-disable-next-line no-param-reassign
24686
+ delete bundle.dataType;
24687
+ }
24688
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
24689
+ fireEvent('post.created', payload);
24690
+ const data = preparePostPayload(payload);
24691
+ const cachedAt = client.cache && Date.now();
24692
+ if (client.cache)
24693
+ ingestInCache(data, { cachedAt });
24694
+ const { posts } = data;
24695
+ return {
24696
+ data: LinkedObject.post(posts[0]),
24697
+ cachedAt,
24698
+ };
24699
+ };
24700
+ /* end_public_function */
24207
24701
 
24702
+ /* begin_public_function
24703
+ id: post.edit, post.edit.custom_post
24704
+ */
24208
24705
  /**
24209
24706
  * ```js
24210
- * import { onLocalCommentReactionAdded } from '@amityco/ts-sdk'
24211
- * const dispose = onLocalCommentReactionAdded(comment => {
24212
- * // ...
24707
+ * import { PostRepository } from '@amityco/ts-sdk'
24708
+ * const updated = await PostRepository.editPost(postId, {
24709
+ * data: { text: 'hello world' }
24213
24710
  * })
24214
24711
  * ```
24215
24712
  *
24216
- * Fired when a {@link Amity.InternalComment} has been reacted
24713
+ * Updates an {@link Amity.Post}
24217
24714
  *
24218
- * @param callback The function to call when the event was fired
24219
- * @returns an {@link Amity.Unsubscriber} function to stop listening
24715
+ * @param postId The ID of the {@link Amity.Post} to edit
24716
+ * @param patch The patch data to apply
24717
+ * @returns the updated {@link Amity.Post} object
24220
24718
  *
24221
- * @category Comment Events
24719
+ * @category Post API
24720
+ * @async
24222
24721
  */
24223
- const onLocalCommentReactionAdded = (callback) => {
24722
+ const editPost = async (postId, patch) => {
24224
24723
  const client = getActiveClient();
24225
- const filter = ({ comment }) => {
24226
- if (!client.cache) {
24227
- callback(comment);
24228
- }
24229
- else {
24230
- upsertInCache(['comment', 'get', comment.commentId], comment);
24231
- callback(commentLinkedObject(comment));
24232
- }
24724
+ client.log('user/editPost', patch);
24725
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
24726
+ const data = prepareMembershipPayload(payload, 'communityUsers');
24727
+ const cachedAt = client.cache && Date.now();
24728
+ if (client.cache)
24729
+ ingestInCache(data, { cachedAt });
24730
+ fireEvent('local.post.updated', data);
24731
+ const { posts } = data;
24732
+ return {
24733
+ data: LinkedObject.post(posts.find(post => post.postId === postId)),
24734
+ cachedAt,
24233
24735
  };
24234
- return createEventSubscriber(client, 'local.comment.addReaction', 'local.comment.addReaction', filter);
24235
24736
  };
24737
+ /* end_public_function */
24236
24738
 
24237
24739
  /**
24238
24740
  * ```js
24239
- * import { onLocalCommentReactionRemoved } from '@amityco/ts-sdk'
24240
- * const dispose = onLocalCommentReactionRemoved(comment => {
24241
- * // ...
24242
- * })
24741
+ * import { deletePost } from '@amityco/ts-sdk'
24742
+ * const success = await deletePost('foobar')
24243
24743
  * ```
24244
24744
  *
24245
- * Fired when a {@link Amity.InternalComment} has been reacted
24745
+ * Deletes a {@link Amity.Post}
24246
24746
  *
24247
- * @param callback The function to call when the event was fired
24248
- * @returns an {@link Amity.Unsubscriber} function to stop listening
24747
+ * @param postId The {@link Amity.Post} ID to delete
24748
+ * @return A success boolean if the {@link Amity.Post} was deleted
24249
24749
  *
24250
- * @category Comment Events
24750
+ * @private
24751
+ * @async
24251
24752
  */
24252
- const onLocalCommentReactionRemoved = (callback) => {
24753
+ const deletePost = async (postId, permanent = false) => {
24754
+ var _a;
24253
24755
  const client = getActiveClient();
24254
- const filter = ({ comment }) => {
24255
- if (!client.cache) {
24256
- callback(comment);
24257
- }
24258
- else {
24259
- upsertInCache(['comment', 'get', comment.commentId], comment);
24260
- callback(commentLinkedObject(comment));
24261
- }
24262
- };
24263
- return createEventSubscriber(client, 'local.comment.removeReaction', 'local.comment.removeReaction', filter);
24756
+ const post = await getPost$2(postId);
24757
+ await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
24758
+ params: {
24759
+ postId,
24760
+ permanent,
24761
+ },
24762
+ });
24763
+ // there is currently a limitation which doesn't allow us to fire event to tell that community
24764
+ // has been updated. reason is that, when the object is deleted, we don't have its `communityId`
24765
+ // and so we cannot refetch the community or advertise on events. hopefully this should be solved
24766
+ // later when realtime events covers that for us.
24767
+ if (post.data.targetType === 'community') {
24768
+ const community = await getCommunity$1(post.data.targetId);
24769
+ const communityUsersCache = (_a = queryCache(['communityUsers', 'get'])) !== null && _a !== void 0 ? _a : [];
24770
+ const communityUsers = communityUsersCache
24771
+ .filter(({ key }) => {
24772
+ // cache key is ['communityUsers', 'get', `${communityId}#`${userId}`}]
24773
+ if (key[0] !== 'communityUsers')
24774
+ return false;
24775
+ if (key[1] !== 'get')
24776
+ return false;
24777
+ if (typeof key[2] === 'string')
24778
+ return key[2].includes(community.data.communityId);
24779
+ return false;
24780
+ })
24781
+ .map(({ data }) => data);
24782
+ fireEvent('community.updated', {
24783
+ communities: [community.data],
24784
+ categories: [],
24785
+ communityUsers,
24786
+ feeds: [],
24787
+ files: [],
24788
+ users: [],
24789
+ });
24790
+ }
24791
+ // to support hard deletion
24792
+ const deleted = Object.assign(Object.assign({}, post.data), { isDeleted: true });
24793
+ if (permanent) {
24794
+ setTimeout(() => {
24795
+ pushToTombstone('post', postId);
24796
+ }, 0);
24797
+ }
24798
+ else {
24799
+ upsertInCache(['post', 'get', postId], { isDeleted: true });
24800
+ }
24801
+ fireEvent('local.post.deleted', {
24802
+ posts: [deleted],
24803
+ categories: [],
24804
+ comments: [],
24805
+ communities: [],
24806
+ communityUsers: [],
24807
+ feeds: [],
24808
+ files: [],
24809
+ postChildren: [],
24810
+ users: [],
24811
+ videoStreamings: [],
24812
+ });
24813
+ return LinkedObject.post(deleted);
24264
24814
  };
24265
24815
 
24266
24816
  /* begin_public_function
24267
- id: comment.get
24817
+ id: post.soft_delete
24268
24818
  */
24269
24819
  /**
24270
24820
  * ```js
24271
- * import { CommentRepository } from '@amityco/ts-sdk';
24272
- *
24273
- * let comment;
24274
- *
24275
- * const unsub = CommentRepository.getComment(commentId, response => {
24276
- * comment = response.data;
24277
- * });
24821
+ * import { PostRepository } from '@amityco/ts-sdk'
24822
+ * const success = await PostRepository.softDeletePost('foobar')
24278
24823
  * ```
24279
24824
  *
24280
- * Observe all mutation on a given {@link Amity.Comment}
24825
+ * Soft deletes a {@link Amity.Post}
24281
24826
  *
24282
- * @param commentId the ID of the comment to observe
24283
- * @param callback the function to call when new data are available
24284
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
24827
+ * @param postId The {@link Amity.Post} ID to soft delete
24828
+ * @return A success boolean if the {@link Amity.Post} was deleted
24285
24829
  *
24286
- * @category Comment Live Object
24830
+ * @category Post API
24831
+ * @async
24287
24832
  */
24288
- const getComment = (commentId, callback) => {
24289
- return liveObject(commentId, callback, 'commentId', getComment$1, [
24290
- onCommentDeleteLocal,
24291
- onCommentDeleted,
24292
- onCommentFlagged,
24293
- onCommentReactionAdded,
24294
- onCommentReactionRemoved,
24295
- onCommentUnflagged,
24296
- onCommentUpdated,
24297
- onLocalCommentReactionAdded,
24298
- onLocalCommentReactionRemoved,
24299
- ]);
24833
+ const softDeletePost = async (postId) => {
24834
+ const client = getActiveClient();
24835
+ client.log('post/softDeletePost', postId);
24836
+ const softDeleted = await deletePost(postId, false);
24837
+ return LinkedObject.post(softDeleted);
24300
24838
  };
24301
24839
  /* end_public_function */
24302
24840
 
24303
- class CommentPaginationController extends PaginationController {
24304
- async getRequest(queryParams, token) {
24305
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted"]);
24306
- const baseOptions = {
24307
- type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
24308
- };
24309
- const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
24310
- const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
24311
- params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
24312
- });
24313
- return queryResponse;
24314
- }
24315
- }
24316
-
24317
- var EnumCommentActions;
24318
- (function (EnumCommentActions) {
24319
- EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
24320
- EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
24321
- EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
24322
- EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
24323
- EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
24324
- EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
24325
- EnumCommentActions["OnCommentReactionRemoved"] = "onCommentReactionRemoved";
24326
- })(EnumCommentActions || (EnumCommentActions = {}));
24327
-
24328
- class CommentQueryStreamController extends QueryStreamController {
24329
- constructor(query, cacheKey, notifyChange, preparePayload) {
24330
- super(query, cacheKey);
24331
- this.notifyChange = notifyChange;
24332
- this.preparePayload = preparePayload;
24333
- }
24334
- async saveToMainDB(response) {
24335
- const processedPayload = await this.preparePayload(response);
24336
- const client = getActiveClient();
24337
- const cachedAt = client.cache && Date.now();
24338
- if (client.cache) {
24339
- ingestInCache(processedPayload, { cachedAt });
24340
- }
24341
- }
24342
- appendToQueryStream(response, direction, refresh = false) {
24343
- var _a, _b;
24344
- if (refresh) {
24345
- pushToCache(this.cacheKey, {
24346
- data: response.comments.map(getResolver('comment')),
24347
- });
24348
- }
24349
- else {
24350
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24351
- const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
24352
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
24353
- }
24354
- }
24355
- reactor(action) {
24356
- return (comment) => {
24357
- var _a;
24358
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24359
- if (this.query.referenceId !== comment.referenceId ||
24360
- this.query.referenceType !== comment.referenceType ||
24361
- !collection) {
24362
- return;
24363
- }
24364
- if (this.query.parentId && this.query.parentId !== comment.parentId) {
24365
- return;
24366
- }
24367
- if (!this.query.parentId && comment.parentId) {
24368
- return;
24369
- }
24370
- if (action === EnumCommentActions.OnCommentCreated) {
24371
- collection.data = [...new Set([comment.commentId, ...collection.data])];
24372
- }
24373
- pushToCache(this.cacheKey, collection);
24374
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
24375
- };
24376
- }
24377
- subscribeRTE(createSubscriber) {
24378
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
24379
- }
24380
- }
24841
+ /* begin_public_function
24842
+ id: post.hard_delete
24843
+ */
24844
+ /**
24845
+ * ```js
24846
+ * import { hardDeletePost } from '@amityco/ts-sdk'
24847
+ * const success = await hardDeletePost('foobar')
24848
+ * ```
24849
+ *
24850
+ * Hard deletes a {@link Amity.Post}
24851
+ *
24852
+ * @param postId The {@link Amity.Post} ID to be hard delete
24853
+ * @return A success boolean if the {@link Amity.Post} was deleted
24854
+ *
24855
+ * @category Post API
24856
+ * @async
24857
+ */
24858
+ const hardDeletePost = async (postId) => {
24859
+ const client = getActiveClient();
24860
+ client.log('post/hardDeletePost', postId);
24861
+ const hardDeleted = await deletePost(postId, true);
24862
+ return LinkedObject.post(hardDeleted);
24863
+ };
24864
+ /* end_public_function */
24381
24865
 
24866
+ /* begin_public_function
24867
+ id: post.approve
24868
+ */
24382
24869
  /**
24383
24870
  * ```js
24384
- * import { onCommentCreated } from '@amityco/ts-sdk'
24385
- * const dispose = onCommentCreated(comment => {
24386
- * // ...
24387
- * })
24871
+ * import { approvePost } from '@amityco/ts-sdk'
24872
+ *
24873
+ * const { data: post } = await approvePost('postId')
24388
24874
  * ```
24389
24875
  *
24390
- * Fired when a {@link Amity.InternalComment} has been created
24876
+ * Approves a {@link Amity.Post}
24391
24877
  *
24392
- * @param callback The function to call when the event was fired
24393
- * @returns an {@link Amity.Unsubscriber} function to stop listening
24878
+ * @param postId The {@link Amity.Post} ID to be approved
24879
+ * @return A {@link Amity.Post} that was approved
24394
24880
  *
24395
- * @category Comment Events
24881
+ * @category Post API
24882
+ * @async
24396
24883
  */
24397
- const onCommentCreatedLocal = (callback) => {
24398
- return createLocalCommentEventSubscriber('local.comment.created', callback);
24399
- };
24400
-
24401
- class CommentLiveCollectionController extends LiveCollectionController {
24402
- constructor(query, callback) {
24403
- const queryStreamId = hash__default["default"](query);
24404
- const cacheKey = ['comments', 'collection', queryStreamId];
24405
- const paginationController = new CommentPaginationController(query);
24406
- super(paginationController, queryStreamId, cacheKey, callback);
24407
- this.query = query;
24408
- this.queryStreamController = new CommentQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareCommentPayload);
24409
- this.callback = callback.bind(this);
24410
- this.loadPage({ initial: true });
24411
- }
24412
- setup() {
24413
- var _a;
24414
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24415
- if (!collection) {
24416
- pushToCache(this.cacheKey, {
24417
- data: [],
24418
- params: {},
24419
- });
24420
- }
24421
- }
24422
- async persistModel(queryPayload) {
24423
- await this.queryStreamController.saveToMainDB(queryPayload);
24424
- }
24425
- persistQueryStream({ response, direction, refresh, }) {
24426
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
24427
- }
24428
- startSubscription() {
24429
- return this.queryStreamController.subscribeRTE([
24430
- { fn: onCommentCreatedLocal, action: EnumCommentActions.OnCommentCreated },
24431
- { fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
24432
- { fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
24433
- { fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
24434
- { fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
24435
- { fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
24436
- { fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
24437
- { fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
24438
- { fn: onCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
24439
- { fn: onLocalCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
24440
- { fn: onLocalCommentReactionRemoved, action: EnumCommentActions.OnCommentReactionRemoved },
24441
- ]);
24442
- }
24443
- notifyChange({ origin, loading, error }) {
24444
- var _a, _b;
24445
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24446
- if (!collection)
24447
- return;
24448
- const data = this.applyFilter((_b = collection.data
24449
- .map(id => pullFromCache(['comment', 'get', id]))
24450
- .filter(isNonNullable)
24451
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.comment);
24452
- if (!this.shouldNotify(data) && origin === 'event')
24453
- return;
24454
- this.callback({
24455
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
24456
- data,
24457
- hasNextPage: !!this.paginationController.getNextToken(),
24458
- loading,
24459
- error,
24460
- });
24461
- }
24462
- applyFilter(data) {
24463
- let comments = data;
24464
- if (!this.query.includeDeleted) {
24465
- comments = filterByPropEquality(comments, 'isDeleted', false);
24466
- }
24467
- if (this.query.parentId) {
24468
- comments = comments.filter(comment => comment.parentId === this.query.parentId);
24469
- }
24470
- if (typeof this.query.hasFlag === 'boolean') {
24471
- if (this.query.hasFlag) {
24472
- comments = comments.filter(comment => comment.hashFlag != null);
24473
- }
24474
- else {
24475
- comments = comments.filter(comment => comment.hashFlag == null);
24476
- }
24477
- }
24478
- if (this.query.dataTypes) {
24479
- if (this.query.dataTypes.matchType === 'exact') {
24480
- comments = comments.filter(comment => {
24481
- var _a, _b;
24482
- const sortedDataTypesQueryValue = ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.values.sort()) || [];
24483
- const sortedDataTypesCommentValue = ((_b = comment.dataTypes) === null || _b === void 0 ? void 0 : _b.sort()) || [];
24484
- if (sortedDataTypesCommentValue.length !== sortedDataTypesQueryValue.length) {
24485
- return false;
24486
- }
24487
- return sortedDataTypesQueryValue.every((value, index) => value === sortedDataTypesCommentValue[index]);
24488
- });
24489
- }
24490
- if (this.query.dataTypes.matchType === 'any') {
24491
- 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); }); });
24492
- }
24493
- }
24494
- switch (this.query.sortBy) {
24495
- case 'firstCreated':
24496
- comments = comments.sort(sortByFirstCreated);
24497
- break;
24498
- case 'lastCreated':
24499
- default:
24500
- comments = comments.sort(sortByLastCreated);
24501
- break;
24502
- }
24503
- return comments;
24884
+ const approvePost = async (postId) => {
24885
+ const client = getActiveClient();
24886
+ client.log('post/approvePost', postId);
24887
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/approve`);
24888
+ fireEvent('post.approved', payload);
24889
+ // fire virtual event for community update
24890
+ if (payload.posts[0].targetType === 'community') {
24891
+ fireEvent('community.updated', payload);
24504
24892
  }
24505
- }
24893
+ const data = prepareMembershipPayload(payload, 'communityUsers');
24894
+ const cachedAt = client.cache && Date.now();
24895
+ if (client.cache)
24896
+ ingestInCache(data, { cachedAt });
24897
+ return {
24898
+ data: LinkedObject.post(data.posts.find(post => post.postId === postId)),
24899
+ cachedAt,
24900
+ };
24901
+ };
24902
+ /* end_public_function */
24506
24903
 
24507
24904
  /* begin_public_function
24508
- id: comment.query
24905
+ id: post.decline
24509
24906
  */
24510
24907
  /**
24511
24908
  * ```js
24512
- * import { getComments } from '@amityco/ts-sdk'
24909
+ * import { declinePost } from '@amityco/ts-sdk'
24513
24910
  *
24514
- * let comments = []
24515
- * const unsub = getComments({
24516
- * referenceType: Amity.InternalComment['referenceType'];
24517
- * referenceId: Amity.InternalComment['referenceId'];
24518
- * }, response => merge(comments, response.data))
24911
+ * const {data: post} = await declinePost('postId')
24519
24912
  * ```
24520
24913
  *
24521
- * Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
24914
+ * Declines a {@link Amity.Post}
24522
24915
  *
24523
- * @param referenceType the type of the target
24524
- * @param referenceId the ID of the target
24525
- * @param callback the function to call when new data are available
24526
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
24916
+ * @param postId The {@link Amity.Post} ID to be declined
24917
+ * @return A {@link Amity.Post} that was declined
24527
24918
  *
24528
- * @category Comments Live Collection
24919
+ * @category Post API
24920
+ * @async
24529
24921
  */
24530
- const getComments = (params, callback, config) => {
24531
- const { log, cache } = getActiveClient();
24532
- if (!cache) {
24533
- console.log('For using Live Collection feature you need to enable Cache!');
24922
+ const declinePost = async (postId) => {
24923
+ const client = getActiveClient();
24924
+ client.log('post/declinePost', postId);
24925
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/decline`);
24926
+ // fire virtual event
24927
+ if (payload.posts[0].targetType === 'community') {
24928
+ fireEvent('community.updated', payload);
24534
24929
  }
24535
- const timestamp = Date.now();
24536
- log(`getComments(tmpid: ${timestamp}) > listen`);
24537
- const commentsLiveCollection = new CommentLiveCollectionController(params, callback);
24538
- const disposers = commentsLiveCollection.startSubscription();
24539
- const cacheKey = commentsLiveCollection.getCacheKey();
24540
- disposers.push(() => dropFromCache(cacheKey));
24541
- return () => {
24542
- log(`getComments(tmpid: ${timestamp}) > dispose`);
24543
- disposers.forEach(fn => fn());
24930
+ fireEvent('post.declined', payload);
24931
+ const data = prepareMembershipPayload(payload, 'communityUsers');
24932
+ const cachedAt = client.cache && Date.now();
24933
+ if (client.cache)
24934
+ ingestInCache(data, { cachedAt });
24935
+ return {
24936
+ data: LinkedObject.post(payload.posts.find(post => post.postId === postId)),
24937
+ cachedAt,
24544
24938
  };
24545
24939
  };
24546
24940
  /* end_public_function */
24547
24941
 
24548
- var index$9 = /*#__PURE__*/Object.freeze({
24549
- __proto__: null,
24550
- getCommentByIds: getCommentByIds,
24551
- createComment: createComment,
24552
- updateComment: updateComment,
24553
- deleteComment: deleteComment,
24554
- softDeleteComment: softDeleteComment,
24555
- hardDeleteComment: hardDeleteComment,
24556
- flagComment: flagComment,
24557
- unflagComment: unflagComment,
24558
- isCommentFlaggedByMe: isCommentFlaggedByMe,
24559
- onCommentCreated: onCommentCreated,
24560
- onCommentUpdated: onCommentUpdated,
24561
- onCommentDeleted: onCommentDeleted,
24562
- onCommentFlagged: onCommentFlagged,
24563
- onCommentUnflagged: onCommentUnflagged,
24564
- onCommentReactionAdded: onCommentReactionAdded,
24565
- onCommentReactionRemoved: onCommentReactionRemoved,
24566
- getComment: getComment,
24567
- getComments: getComments
24568
- });
24569
-
24942
+ /* begin_public_function
24943
+ id: post.flag
24944
+ */
24570
24945
  /**
24571
24946
  * ```js
24572
- * import { onPostUpdatedLocal } from '@amityco/ts-sdk'
24573
- * const dispose = onPostUpdatedLocal(post => {
24574
- * // ...
24575
- * })
24947
+ * import { PostRepository } from '@amityco/ts-sdk'
24948
+ * const flagged = await PostRepository.flagPost(postId, reason)
24576
24949
  * ```
24577
24950
  *
24578
- * Fired when a {@link Amity.InternalPost} has been updated
24579
- *
24580
- * @param callback The function to call when the event was fired
24581
- * @returns an {@link Amity.Unsubscriber} function to stop listening
24951
+ * @param postId of the post to flag
24952
+ * @param reason the reason to flag the post
24953
+ * @returns a boolean
24582
24954
  *
24583
- * @category Post Events
24584
- */
24585
- const onPostUpdatedLocal = (callback) => createLocalPostEventSubscriber('local.post.updated', callback);
24955
+ * @category Post API
24956
+ * @async
24957
+ * */
24958
+ const flagPost = async (postId, reason) => {
24959
+ const client = getActiveClient();
24960
+ client.log('post/flagPost', postId);
24961
+ const isPredefinedReason = reason &&
24962
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
24963
+ const body = {
24964
+ reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
24965
+ detail: reason && !isPredefinedReason ? reason : '',
24966
+ };
24967
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
24968
+ if (client.cache) {
24969
+ ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
24970
+ }
24971
+ fireEvent('post.flagged', payload);
24972
+ return !!payload;
24973
+ };
24974
+ /* end_public_function */
24586
24975
 
24976
+ /* begin_public_function
24977
+ id: post.unflag
24978
+ */
24587
24979
  /**
24588
24980
  * ```js
24589
- * import { onLocalPostReactionAdded } from '@amityco/ts-sdk'
24590
- * const dispose = onPostReactionAdded(post => {
24591
- * // ...
24592
- * })
24981
+ * import { PostRepository } from '@amityco/ts-sdk'
24982
+ * const unflagged = await PostRepository.unflagPost(postId)
24593
24983
  * ```
24594
24984
  *
24595
- * Fired when a {@link Amity.InternalPost} has been reacted
24596
- *
24597
- * @param callback The function to call when the event was fired
24598
- * @returns an {@link Amity.Unsubscriber} function to stop listening
24985
+ * @param postId of the post to unflag
24986
+ * @returns the unflag post result
24599
24987
  *
24600
- * @category Post Events
24601
- */
24602
- const onLocalPostReactionAdded = (callback) => {
24988
+ * @category Post API
24989
+ * @async
24990
+ * */
24991
+ const unflagPost = async (postId) => {
24603
24992
  const client = getActiveClient();
24604
- const filter = ({ post }) => {
24605
- if (!client.cache) {
24606
- callback(post);
24607
- }
24608
- else {
24609
- upsertInCache(['post', 'get', post.postId], post);
24610
- callback(post);
24611
- }
24612
- };
24613
- return createEventSubscriber(client, 'local.post.addReaction', 'local.post.addReaction', filter);
24993
+ client.log('post/unflagPost', postId);
24994
+ const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
24995
+ if (client.cache) {
24996
+ ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
24997
+ }
24998
+ fireEvent('post.unflagged', payload);
24999
+ return !!payload;
24614
25000
  };
25001
+ /* end_public_function */
24615
25002
 
25003
+ /* begin_public_function
25004
+ id: post.check_flag_by_me
25005
+ */
24616
25006
  /**
24617
25007
  * ```js
24618
- * import { onLocalPostReactionRemoved } from '@amityco/ts-sdk'
24619
- * const dispose = onPostReactionRemoved(post => {
24620
- * // ...
24621
- * })
25008
+ * import { PostRepository } from '@amityco/ts-sdk'
25009
+ * const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
24622
25010
  * ```
24623
25011
  *
24624
- * Fired when a {@link Amity.InternalPost} has been reacted
24625
- *
24626
- * @param callback The function to call when the event was fired
24627
- * @returns an {@link Amity.Unsubscriber} function to stop listening
25012
+ * @param postId of the post to check if flagged by current user
25013
+ * @returns `true` if the post is flagged by me, `false` if doesn't.
24628
25014
  *
24629
- * @category Post Events
24630
- */
24631
- const onLocalPostReactionRemoved = (callback) => {
25015
+ * @category Post API
25016
+ * @async
25017
+ * */
25018
+ const isPostFlaggedByMe = async (postId) => {
24632
25019
  const client = getActiveClient();
24633
- const filter = ({ post }) => {
24634
- if (!client.cache) {
24635
- callback(post);
24636
- }
24637
- else {
24638
- upsertInCache(['post', 'get', post.postId], post);
24639
- callback(post);
24640
- }
24641
- };
24642
- return createEventSubscriber(client, 'local.post.removeReaction', 'local.post.removeReaction', filter);
25020
+ client.log('post/isPostFlaggedByMe', postId);
25021
+ const { data: { result }, } = await client.http.get(`/api/v3/posts/${postId}/isflagbyme`);
25022
+ return result;
24643
25023
  };
25024
+ /* end_public_function */
24644
25025
 
25026
+ /* begin_public_function
25027
+ id: post.create.clip_post
25028
+ */
24645
25029
  /**
24646
25030
  * ```js
24647
- * import { onLocalPostDeleted } from '@amityco/ts-sdk'
24648
- * const dispose = onLocalPostDeleted(post => {
24649
- * // ...
24650
- * })
25031
+ * import { PostRepository } from '@amityco/ts-sdk'
25032
+ * const created = await PostRepository.createClipPost({
25033
+ * targetType: 'user',
25034
+ * targetId: 'foobar',
25035
+ * dataType: 'clip',
25036
+ * data: { text: 'hello world' },
25037
+ * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
25038
+ * }))
24651
25039
  * ```
24652
25040
  *
24653
- * Fired when a {@link Amity.InternalPost} has been deleted
25041
+ * Creates an {@link Amity.Post}
24654
25042
  *
24655
- * @param callback The function to call when the event was fired
24656
- * @returns an {@link Amity.Unsubscriber} function to stop listening
25043
+ * @param bundle The data necessary to create a new {@link Amity.Post}
25044
+ * @returns The newly created {@link Amity.Post}
24657
25045
  *
24658
- * @category Post Events
25046
+ * @category Post API
25047
+ * @async
24659
25048
  */
24660
- const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.post.deleted', callback);
25049
+ const createClipPost = async (bundle) => {
25050
+ const client = getActiveClient();
25051
+ client.log('post/createPost', bundle);
25052
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
25053
+ fireEvent('post.created', payload);
25054
+ const data = prepareMembershipPayload(payload, 'communityUsers');
25055
+ const cachedAt = client.cache && Date.now();
25056
+ if (client.cache)
25057
+ ingestInCache(data, { cachedAt });
25058
+ const { posts } = data;
25059
+ return {
25060
+ data: LinkedObject.post(posts[0]),
25061
+ cachedAt,
25062
+ };
25063
+ };
25064
+ /* end_public_function */
24661
25065
 
24662
25066
  /* begin_public_function
24663
25067
  id: post.get
@@ -24681,7 +25085,7 @@ const onLocalPostDeleted = (callback) => createLocalPostEventSubscriber('local.p
24681
25085
  *
24682
25086
  * @category Post Live Object
24683
25087
  */
24684
- const getPost$1 = (postId, callback) => {
25088
+ const getPost = (postId, callback) => {
24685
25089
  const responder = (snapshot) => {
24686
25090
  const { data } = snapshot;
24687
25091
  callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.post(snapshot.data) : data }));
@@ -24770,19 +25174,6 @@ class PostPaginationController extends PaginationController {
24770
25174
  }
24771
25175
  }
24772
25176
 
24773
- var EnumPostActions;
24774
- (function (EnumPostActions) {
24775
- EnumPostActions["OnPostCreated"] = "onPostCreated";
24776
- EnumPostActions["OnPostUpdated"] = "onPostUpdated";
24777
- EnumPostActions["OnPostDeleted"] = "onPostDeleted";
24778
- EnumPostActions["OnPostFlagged"] = "onPostFlagged";
24779
- EnumPostActions["OnPostUnflagged"] = "onPostUnflagged";
24780
- EnumPostActions["OnPostReactionAdded"] = "onPostReactionAdded";
24781
- EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
24782
- EnumPostActions["OnPostApproved"] = "onPostApproved";
24783
- EnumPostActions["OnPostDeclined"] = "onPostDeclined";
24784
- })(EnumPostActions || (EnumPostActions = {}));
24785
-
24786
25177
  class PostQueryStreamController extends QueryStreamController {
24787
25178
  constructor(query, cacheKey, notifyChange, preparePayload) {
24788
25179
  super(query, cacheKey);
@@ -24848,116 +25239,81 @@ class PostQueryStreamController extends QueryStreamController {
24848
25239
  }
24849
25240
  }
24850
25241
 
24851
- const getPost = async (postId) => {
24852
- const client = getActiveClient();
24853
- client.log('post/getPost', postId);
24854
- isInTombstone('post', postId);
24855
- let payload;
24856
- try {
24857
- // API-FIX: endpoint should not be /list, parameters should be querystring.
24858
- const response = await client.http.get(`/api/v3/posts/${encodeURIComponent(postId)}`);
24859
- payload = response.data;
24860
- }
24861
- catch (error) {
24862
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
24863
- pushToTombstone('post', postId);
24864
- }
24865
- throw error;
24866
- }
24867
- const data = prepareMembershipPayload(payload, 'communityUsers');
24868
- const cachedAt = client.cache && Date.now();
24869
- if (client.cache)
24870
- ingestInCache(data, { cachedAt });
24871
- const { posts } = data;
24872
- const result = posts.find(post => post.postId === postId);
24873
- return {
24874
- data: result,
24875
- cachedAt,
24876
- };
25242
+ const commentEventHandler = (callback, eventHandler, cacheKey, resolveId) => {
25243
+ return eventHandler(async (comment) => {
25244
+ var _a;
25245
+ const currentCollection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25246
+ if (!currentCollection ||
25247
+ !currentCollection.data.includes(resolveId ? resolveId(comment.referenceId) : comment.referenceId))
25248
+ return;
25249
+ await getPost$1(comment.referenceId);
25250
+ callback(comment);
25251
+ });
24877
25252
  };
24878
- getPost.locally = (postId) => {
24879
- const client = getActiveClient();
24880
- client.log('post/getPost.locally', postId);
24881
- if (!client.cache)
24882
- return;
24883
- const cached = pullFromCache(['post', 'get', postId]);
24884
- if (!cached)
24885
- return;
24886
- return {
24887
- data: cached.data,
24888
- cachedAt: cached.cachedAt,
24889
- };
25253
+ const generateCommentSubscriptions = ({ cacheKey, resolveId, }) => {
25254
+ const eventHandlers = [
25255
+ onCommentCreated,
25256
+ onCommentDeleted,
25257
+ onCommentReactionAdded,
25258
+ onCommentReactionRemoved,
25259
+ onCommentCreatedLocal,
25260
+ onCommentDeleteLocal,
25261
+ onLocalCommentReactionAdded,
25262
+ onLocalCommentReactionRemoved,
25263
+ ];
25264
+ return eventHandlers.map(handler => ({
25265
+ fn: convertEventPayload((callback) => commentEventHandler(callback, handler, cacheKey, resolveId), 'referenceId', 'post'),
25266
+ action: EnumPostActions.OnPostUpdated,
25267
+ }));
25268
+ };
25269
+ const getPostSubscription = (cacheKey) => {
25270
+ return [
25271
+ { fn: onPostCreated, action: EnumPostActions.OnPostCreated },
25272
+ { fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
25273
+ { fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
25274
+ { fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
25275
+ { fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
25276
+ { fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
25277
+ { fn: onPostApproved, action: EnumPostActions.OnPostApproved },
25278
+ { fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
25279
+ { fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
25280
+ { fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
25281
+ { fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
25282
+ { fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
25283
+ { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
25284
+ ...generateCommentSubscriptions({ cacheKey }),
25285
+ ];
24890
25286
  };
24891
25287
 
24892
25288
  class PostLiveCollectionController extends LiveCollectionController {
24893
25289
  constructor(query, callback) {
24894
- const queryStreamId = hash__default["default"](query);
24895
- const cacheKey = ['posts', 'collection', queryStreamId];
24896
- const paginationController = new PostPaginationController(query);
24897
- super(paginationController, queryStreamId, cacheKey, callback);
24898
- this.query = query;
24899
- this.queryStreamController = new PostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
24900
- this.callback = callback.bind(this);
24901
- this.loadPage({ initial: true });
24902
- }
24903
- setup() {
24904
- var _a;
24905
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24906
- if (!collection) {
24907
- pushToCache(this.cacheKey, {
24908
- data: [],
24909
- params: {},
24910
- });
24911
- }
24912
- }
24913
- async persistModel(queryPayload) {
24914
- await this.queryStreamController.saveToMainDB(queryPayload);
24915
- }
24916
- persistQueryStream({ response, direction, refresh, }) {
24917
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
24918
- }
24919
- startSubscription() {
24920
- return this.queryStreamController.subscribeRTE([
24921
- { fn: onPostCreated, action: EnumPostActions.OnPostCreated },
24922
- { fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
24923
- { fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
24924
- { fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
24925
- { fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
24926
- { fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
24927
- { fn: onPostApproved, action: EnumPostActions.OnPostApproved },
24928
- { fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
24929
- { fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
24930
- { fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
24931
- { fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
24932
- { fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
24933
- { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
24934
- {
24935
- fn: convertEventPayload((callback) => {
24936
- return onCommentCreated(async (comment) => {
24937
- var _a;
24938
- const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24939
- if (!currentCollection || currentCollection.data.includes(comment.referenceId))
24940
- return;
24941
- await getPost(comment.referenceId);
24942
- callback(comment);
24943
- });
24944
- }, 'referenceId', 'post'),
24945
- action: EnumPostActions.OnPostUpdated,
24946
- },
24947
- {
24948
- fn: convertEventPayload((callback) => {
24949
- return onCommentDeleted(async (comment) => {
24950
- var _a;
24951
- const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
24952
- if (!currentCollection || currentCollection.data.includes(comment.referenceId))
24953
- return;
24954
- await getPost(comment.referenceId);
24955
- callback(comment);
24956
- });
24957
- }, 'referenceId', 'post'),
24958
- action: EnumPostActions.OnPostUpdated,
24959
- },
24960
- ]);
25290
+ const queryStreamId = hash__default["default"](query);
25291
+ const cacheKey = ['posts', 'collection', queryStreamId];
25292
+ const paginationController = new PostPaginationController(query);
25293
+ super(paginationController, queryStreamId, cacheKey, callback);
25294
+ this.query = query;
25295
+ this.queryStreamController = new PostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
25296
+ this.callback = callback.bind(this);
25297
+ this.loadPage({ initial: true });
25298
+ }
25299
+ setup() {
25300
+ var _a;
25301
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25302
+ if (!collection) {
25303
+ pushToCache(this.cacheKey, {
25304
+ data: [],
25305
+ params: {},
25306
+ });
25307
+ }
25308
+ }
25309
+ async persistModel(queryPayload) {
25310
+ await this.queryStreamController.saveToMainDB(queryPayload);
25311
+ }
25312
+ persistQueryStream({ response, direction, refresh, }) {
25313
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
25314
+ }
25315
+ startSubscription() {
25316
+ return this.queryStreamController.subscribeRTE(getPostSubscription(this.cacheKey));
24961
25317
  }
24962
25318
  notifyChange({ origin, loading, error }) {
24963
25319
  var _a, _b;
@@ -25092,6 +25448,22 @@ class PinnedPostQueryStreamController extends QueryStreamController {
25092
25448
  });
25093
25449
  }
25094
25450
  }
25451
+ reactor(action) {
25452
+ return (post) => {
25453
+ var _a;
25454
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25455
+ if (!collection)
25456
+ return;
25457
+ if (action === EnumPostActions.OnPostDeleted) {
25458
+ collection.data = collection.data.filter(referenceId => referenceId !== `global#${post.postId}`);
25459
+ }
25460
+ pushToCache(this.cacheKey, collection);
25461
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
25462
+ };
25463
+ }
25464
+ subscribeRTE(createSubscriber) {
25465
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
25466
+ }
25095
25467
  }
25096
25468
 
25097
25469
  class PinnedPostLiveCollectionController extends LiveCollectionController {
@@ -25123,7 +25495,10 @@ class PinnedPostLiveCollectionController extends LiveCollectionController {
25123
25495
  }
25124
25496
  // eslint-disable-next-line class-methods-use-this
25125
25497
  startSubscription() {
25126
- return [];
25498
+ return this.queryStreamController.subscribeRTE(generateCommentSubscriptions({
25499
+ cacheKey: this.cacheKey,
25500
+ resolveId: id => `${this.query.placement}#${id}`,
25501
+ }));
25127
25502
  }
25128
25503
  notifyChange({ origin, loading, error }) {
25129
25504
  var _a, _b;
@@ -25275,6 +25650,10 @@ class GlobalPinnedPostLiveCollectionController extends LiveCollectionController
25275
25650
  fn: onPostDeleted,
25276
25651
  action: EnumPostActions.OnPostDeleted,
25277
25652
  },
25653
+ ...generateCommentSubscriptions({
25654
+ cacheKey: this.cacheKey,
25655
+ resolveId: id => `global#${id}`,
25656
+ }),
25278
25657
  ]);
25279
25658
  }
25280
25659
  notifyChange({ origin, loading, error }) {
@@ -25554,6 +25933,238 @@ const semanticSearchPosts = (params, callback, config) => {
25554
25933
  };
25555
25934
  };
25556
25935
 
25936
+ class SearchPostPaginationController extends PaginationController {
25937
+ async getRequest(queryParams, token) {
25938
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, matchingOnlyParentPost, hashtags, dataTypes, targetType = 'all' } = queryParams, params = __rest(queryParams, ["limit", "matchingOnlyParentPost", "hashtags", "dataTypes", "targetType"]);
25939
+ const baseOptions = {
25940
+ type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
25941
+ };
25942
+ const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
25943
+ const { data: queryResponse } = await this.http.get(`/api/v1/search/posts`, {
25944
+ params: Object.assign(Object.assign({}, params), { hashtags,
25945
+ dataTypes,
25946
+ targetType,
25947
+ /*
25948
+ * when creating post like image, file, video BE will create 2 posts
25949
+ * 1. parent post to store text with dataType=text
25950
+ * 2. child post to store dataTypes post data
25951
+ *
25952
+ * By default, BE queries only parent post
25953
+ */
25954
+ matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length), options }),
25955
+ });
25956
+ return queryResponse;
25957
+ }
25958
+ }
25959
+
25960
+ class SearchPostQueryStreamController extends QueryStreamController {
25961
+ constructor(query, cacheKey, notifyChange, preparePayload) {
25962
+ super(query, cacheKey);
25963
+ this.notifyChange = notifyChange;
25964
+ this.preparePayload = preparePayload;
25965
+ }
25966
+ async saveToMainDB(response) {
25967
+ const processedPayload = await this.preparePayload(response);
25968
+ const client = getActiveClient();
25969
+ const cachedAt = client.cache && Date.now();
25970
+ if (client.cache) {
25971
+ ingestInCache(processedPayload, { cachedAt });
25972
+ }
25973
+ }
25974
+ appendToQueryStream(response, direction, refresh = false) {
25975
+ var _a, _b;
25976
+ if (refresh) {
25977
+ pushToCache(this.cacheKey, {
25978
+ data: response.posts.map(getResolver('post')),
25979
+ });
25980
+ }
25981
+ else {
25982
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25983
+ const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
25984
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
25985
+ }
25986
+ }
25987
+ reactor(action) {
25988
+ return (post) => {
25989
+ var _a, _b;
25990
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
25991
+ if (!collection)
25992
+ return;
25993
+ if (post.parentPostId && post.isDeleted) {
25994
+ const parentPost = (_b = pullFromCache([
25995
+ 'post',
25996
+ 'get',
25997
+ post.parentPostId,
25998
+ ])) === null || _b === void 0 ? void 0 : _b.data;
25999
+ if (!parentPost)
26000
+ return;
26001
+ parentPost.children = parentPost.children.filter(childId => childId !== post.postId);
26002
+ pushToCache(['post', 'get', parentPost.postId], parentPost);
26003
+ }
26004
+ if (action === EnumPostActions.OnPostDeclined) {
26005
+ collection.data = collection.data.filter(postId => postId !== post.postId);
26006
+ }
26007
+ if (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) {
26008
+ collection.data = [...new Set([post.postId, ...collection.data])];
26009
+ }
26010
+ pushToCache(this.cacheKey, collection);
26011
+ this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
26012
+ };
26013
+ }
26014
+ subscribeRTE(createSubscriber) {
26015
+ return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
26016
+ }
26017
+ }
26018
+
26019
+ class SearchPostLiveCollectionController extends LiveCollectionController {
26020
+ constructor(query, callback) {
26021
+ const queryStreamId = hash__default["default"](query);
26022
+ const cacheKey = ['posts', 'collection', queryStreamId];
26023
+ const paginationController = new SearchPostPaginationController(query);
26024
+ super(paginationController, queryStreamId, cacheKey, callback);
26025
+ this.query = query;
26026
+ this.queryStreamController = new SearchPostQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), preparePostPayload);
26027
+ this.callback = callback.bind(this);
26028
+ this.loadPage({ initial: true });
26029
+ }
26030
+ setup() {
26031
+ var _a;
26032
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26033
+ if (!collection) {
26034
+ pushToCache(this.cacheKey, {
26035
+ data: [],
26036
+ params: {},
26037
+ });
26038
+ }
26039
+ }
26040
+ async persistModel(queryPayload) {
26041
+ await this.queryStreamController.saveToMainDB(queryPayload);
26042
+ }
26043
+ persistQueryStream({ response, direction, refresh, }) {
26044
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
26045
+ }
26046
+ startSubscription() {
26047
+ return this.queryStreamController.subscribeRTE([
26048
+ { fn: onPostCreated, action: EnumPostActions.OnPostCreated },
26049
+ { fn: onPostUpdated, action: EnumPostActions.OnPostUpdated },
26050
+ { fn: onPostUpdatedLocal, action: EnumPostActions.OnPostUpdated },
26051
+ { fn: onPostDeleted, action: EnumPostActions.OnPostDeleted },
26052
+ { fn: onPostFlagged, action: EnumPostActions.OnPostFlagged },
26053
+ { fn: onPostUnflagged, action: EnumPostActions.OnPostUnflagged },
26054
+ { fn: onPostApproved, action: EnumPostActions.OnPostApproved },
26055
+ { fn: onPostDeclined, action: EnumPostActions.OnPostDeclined },
26056
+ { fn: onPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
26057
+ { fn: onPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
26058
+ { fn: onLocalPostReactionAdded, action: EnumPostActions.OnPostReactionAdded },
26059
+ { fn: onLocalPostReactionRemoved, action: EnumPostActions.OnPostReactionRemoved },
26060
+ { fn: onLocalPostDeleted, action: EnumPostActions.OnPostDeleted },
26061
+ {
26062
+ fn: convertEventPayload((callback) => {
26063
+ return onCommentCreated(async (comment) => {
26064
+ var _a;
26065
+ const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26066
+ if (!currentCollection || currentCollection.data.includes(comment.referenceId))
26067
+ return;
26068
+ await getPost$1(comment.referenceId);
26069
+ callback(comment);
26070
+ });
26071
+ }, 'referenceId', 'post'),
26072
+ action: EnumPostActions.OnPostUpdated,
26073
+ },
26074
+ {
26075
+ fn: convertEventPayload((callback) => {
26076
+ return onCommentDeleted(async (comment) => {
26077
+ var _a;
26078
+ const currentCollection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26079
+ if (!currentCollection || currentCollection.data.includes(comment.referenceId))
26080
+ return;
26081
+ await getPost$1(comment.referenceId);
26082
+ callback(comment);
26083
+ });
26084
+ }, 'referenceId', 'post'),
26085
+ action: EnumPostActions.OnPostUpdated,
26086
+ },
26087
+ ]);
26088
+ }
26089
+ notifyChange({ origin, loading, error }) {
26090
+ var _a, _b;
26091
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26092
+ if (!collection)
26093
+ return;
26094
+ const data = this.applyFilter((_b = collection.data
26095
+ .map(id => pullFromCache(['post', 'get', id]))
26096
+ .filter(isNonNullable)
26097
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
26098
+ if (!this.shouldNotify(data) && origin === 'event')
26099
+ return;
26100
+ this.callback({
26101
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
26102
+ data,
26103
+ hasNextPage: !!this.paginationController.getNextToken(),
26104
+ loading,
26105
+ error,
26106
+ });
26107
+ }
26108
+ applyFilter(data) {
26109
+ var _a;
26110
+ let posts = data;
26111
+ if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
26112
+ posts = filterByPostDataTypes(posts, this.query.dataTypes);
26113
+ }
26114
+ switch (this.query.sortBy) {
26115
+ case 'firstCreated':
26116
+ posts = posts.sort(sortByFirstCreated);
26117
+ break;
26118
+ case 'lastCreated':
26119
+ default:
26120
+ posts = posts.sort(sortByLastCreated);
26121
+ break;
26122
+ }
26123
+ return posts;
26124
+ }
26125
+ }
26126
+
26127
+ /* begin_public_function
26128
+ id: post.query
26129
+ */
26130
+ /**
26131
+ * ```js
26132
+ * import { PostRepository } from '@amityco/ts-sdk'
26133
+ *
26134
+ * let posts = []
26135
+ * const unsub = PostRepository.searchPostsByHashtag({
26136
+ * hashtags: ['amity'],
26137
+ * limit: 10,
26138
+ * }, response => merge(posts, response.data))
26139
+ * ```
26140
+ *
26141
+ * Observe all mutations on a list of {@link Amity.Post} for a given target object
26142
+ *
26143
+ * @param params.hashtags the hashtags to search for
26144
+ * @param callback the function to call when new data are available
26145
+ * @param config
26146
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
26147
+ *
26148
+ * @category Posts Live Collection
26149
+ */
26150
+ const searchPostsByHashtag = (params, callback, config) => {
26151
+ const { log, cache } = getActiveClient();
26152
+ if (!cache) {
26153
+ console.log(ENABLE_CACHE_MESSAGE);
26154
+ }
26155
+ const timestamp = Date.now();
26156
+ log(`searchPostsByHashtag(tmpid: ${timestamp}) > listen`);
26157
+ const postsLiveCollection = new SearchPostLiveCollectionController(params, callback);
26158
+ const disposers = postsLiveCollection.startSubscription();
26159
+ const cacheKey = postsLiveCollection.getCacheKey();
26160
+ disposers.push(() => dropFromCache(cacheKey));
26161
+ return () => {
26162
+ log(`searchPostsByHashtag(tmpid: ${timestamp}) > dispose`);
26163
+ disposers.forEach(fn => fn());
26164
+ };
26165
+ };
26166
+ /* end_public_function */
26167
+
25557
26168
  var index$8 = /*#__PURE__*/Object.freeze({
25558
26169
  __proto__: null,
25559
26170
  getPostByIds: getPostByIds,
@@ -25577,11 +26188,12 @@ var index$8 = /*#__PURE__*/Object.freeze({
25577
26188
  onPostUnflagged: onPostUnflagged,
25578
26189
  onPostReactionAdded: onPostReactionAdded,
25579
26190
  onPostReactionRemoved: onPostReactionRemoved,
25580
- getPost: getPost$1,
26191
+ getPost: getPost,
25581
26192
  getPosts: getPosts,
25582
26193
  getPinnedPosts: getPinnedPosts,
25583
26194
  getGlobalPinnedPosts: getGlobalPinnedPosts,
25584
- semanticSearchPosts: semanticSearchPosts
26195
+ semanticSearchPosts: semanticSearchPosts,
26196
+ searchPostsByHashtag: searchPostsByHashtag
25585
26197
  });
25586
26198
 
25587
26199
  /* begin_public_function
@@ -26460,7 +27072,7 @@ var index$6 = /*#__PURE__*/Object.freeze({
26460
27072
  getPoll: getPoll
26461
27073
  });
26462
27074
 
26463
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
27075
+ 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-----";
26464
27076
  /*
26465
27077
  * The crypto algorithm used for importing key and signing string
26466
27078
  */
@@ -28780,13 +29392,13 @@ exports.AdRepository = index$3;
28780
29392
  exports.CategoryRepository = index$b;
28781
29393
  exports.ChannelRepository = index$f;
28782
29394
  exports.Client = index$o;
28783
- exports.CommentRepository = index$9;
29395
+ exports.CommentRepository = index$a;
28784
29396
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
28785
29397
  exports.CommunityPostSettings = CommunityPostSettings;
28786
29398
  exports.CommunityRepository = index$c;
28787
29399
  exports.ContentFeedType = ContentFeedType;
28788
29400
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
28789
- exports.FeedRepository = index$a;
29401
+ exports.FeedRepository = index$9;
28790
29402
  exports.FileRepository = index$l;
28791
29403
  exports.FileType = FileType;
28792
29404
  exports.InvitationRepository = index$1;