@amityco/ts-sdk 7.27.1-fe406650.0 → 7.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/@types/core/errors.d.ts +1 -2
  2. package/dist/@types/core/errors.d.ts.map +1 -1
  3. package/dist/@types/core/events.d.ts +0 -5
  4. package/dist/@types/core/events.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +0 -26
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/core/permissions.d.ts +4 -10
  8. package/dist/@types/core/permissions.d.ts.map +1 -1
  9. package/dist/@types/core/transport.d.ts +0 -1
  10. package/dist/@types/core/transport.d.ts.map +1 -1
  11. package/dist/@types/domains/analytics.d.ts +1 -3
  12. package/dist/@types/domains/analytics.d.ts.map +1 -1
  13. package/dist/@types/domains/channel.d.ts +0 -5
  14. package/dist/@types/domains/channel.d.ts.map +1 -1
  15. package/dist/@types/domains/client.d.ts +0 -104
  16. package/dist/@types/domains/client.d.ts.map +1 -1
  17. package/dist/@types/domains/comment.d.ts +0 -27
  18. package/dist/@types/domains/comment.d.ts.map +1 -1
  19. package/dist/@types/domains/community.d.ts +0 -1
  20. package/dist/@types/domains/community.d.ts.map +1 -1
  21. package/dist/@types/domains/post.d.ts +0 -11
  22. package/dist/@types/domains/post.d.ts.map +1 -1
  23. package/dist/@types/index.d.ts +1 -3
  24. package/dist/@types/index.d.ts.map +1 -1
  25. package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +0 -3
  26. package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
  27. package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +0 -3
  28. package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
  29. package/dist/channelRepository/events/index.d.ts +0 -2
  30. package/dist/channelRepository/events/index.d.ts.map +1 -1
  31. package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts +0 -22
  32. package/dist/channelRepository/events/onChannelMemberRoleAdded.d.ts.map +1 -1
  33. package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts +0 -22
  34. package/dist/channelRepository/events/onChannelMemberRoleRemoved.d.ts.map +1 -1
  35. package/dist/channelRepository/observers/getChannel.d.ts.map +1 -1
  36. package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
  37. package/dist/channelRepository/observers/getMyMembership.d.ts.map +1 -1
  38. package/dist/channelRepository/observers/searchChannels/SearchChannelLiveCollectionController.d.ts.map +1 -1
  39. package/dist/channelRepository/utils/index.d.ts +0 -2
  40. package/dist/channelRepository/utils/index.d.ts.map +1 -1
  41. package/dist/client/api/createClient.d.ts +1 -5
  42. package/dist/client/api/createClient.d.ts.map +1 -1
  43. package/dist/client/api/getSocialSettings.d.ts.map +1 -1
  44. package/dist/client/api/index.d.ts +0 -1
  45. package/dist/client/api/index.d.ts.map +1 -1
  46. package/dist/client/api/setupLoginSubscriptions.d.ts.map +1 -1
  47. package/dist/client/index.d.ts +0 -1
  48. package/dist/client/index.d.ts.map +1 -1
  49. package/dist/commentRepository/api/createComment.d.ts +1 -12
  50. package/dist/commentRepository/api/createComment.d.ts.map +1 -1
  51. package/dist/commentRepository/api/deleteComment.d.ts.map +1 -1
  52. package/dist/commentRepository/api/index.d.ts +0 -2
  53. package/dist/commentRepository/api/index.d.ts.map +1 -1
  54. package/dist/commentRepository/api/updateComment.d.ts.map +1 -1
  55. package/dist/commentRepository/events/index.d.ts +0 -1
  56. package/dist/commentRepository/events/index.d.ts.map +1 -1
  57. package/dist/commentRepository/events/utils.d.ts.map +1 -1
  58. package/dist/commentRepository/internalApi/getComment.d.ts.map +1 -1
  59. package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
  60. package/dist/commentRepository/observers/getComments/CommentLiveCollectionController.d.ts +1 -1
  61. package/dist/commentRepository/observers/getComments/CommentLiveCollectionController.d.ts.map +1 -1
  62. package/dist/commentRepository/observers/getComments/CommentQueryStreamController.d.ts.map +1 -1
  63. package/dist/commentRepository/observers/getComments/enums.d.ts +0 -1
  64. package/dist/commentRepository/observers/getComments/enums.d.ts.map +1 -1
  65. package/dist/commentRepository/observers/index.d.ts +0 -1
  66. package/dist/commentRepository/observers/index.d.ts.map +1 -1
  67. package/dist/commentRepository/utils/payload.d.ts +0 -6
  68. package/dist/commentRepository/utils/payload.d.ts.map +1 -1
  69. package/dist/communityRepository/api/createCommunity.d.ts +1 -1
  70. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  71. package/dist/communityRepository/api/updateCommunity.d.ts +1 -1
  72. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  73. package/dist/core/device.d.ts +1 -1
  74. package/dist/core/device.d.ts.map +1 -1
  75. package/dist/core/errors.d.ts +0 -20
  76. package/dist/core/errors.d.ts.map +1 -1
  77. package/dist/core/events.d.ts +3 -3
  78. package/dist/core/events.d.ts.map +1 -1
  79. package/dist/core/transports/http.d.ts.map +1 -1
  80. package/dist/core/transports/mqtt.d.ts.map +1 -1
  81. package/dist/core/transports/tests/mqtt.connackTimeout.test.d.ts +2 -0
  82. package/dist/core/transports/tests/mqtt.connackTimeout.test.d.ts.map +1 -0
  83. package/dist/core/transports/utils.d.ts +0 -8
  84. package/dist/core/transports/utils.d.ts.map +1 -1
  85. package/dist/index.cjs.js +479 -1948
  86. package/dist/index.d.ts +0 -3
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.esm.js +455 -1921
  89. package/dist/index.umd.js +2 -2
  90. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +0 -1
  91. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
  92. package/dist/messageRepository/api/index.d.ts +0 -2
  93. package/dist/messageRepository/api/index.d.ts.map +1 -1
  94. package/dist/postRepository/utils/PostCommentCountEngine/PostCommentCountEngine.d.ts +1 -25
  95. package/dist/postRepository/utils/PostCommentCountEngine/PostCommentCountEngine.d.ts.map +1 -1
  96. package/dist/postRepository/utils/payload.d.ts.map +1 -1
  97. package/dist/utils/constants.d.ts +0 -4
  98. package/dist/utils/constants.d.ts.map +1 -1
  99. package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -1
  100. package/dist/utils/linkedObject/index.d.ts +0 -1
  101. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  102. package/dist/utils/linkedObject/messageLinkedObject.d.ts.map +1 -1
  103. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  104. package/dist/utils/tests/dummy/comment.d.ts +0 -1
  105. package/dist/utils/tests/dummy/comment.d.ts.map +1 -1
  106. package/dist/utils/tests/dummy/index.d.ts +0 -1
  107. package/dist/utils/tests/dummy/index.d.ts.map +1 -1
  108. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  109. package/package.json +2 -3
  110. package/dist/@types/domains/curatedContent.d.ts +0 -25
  111. package/dist/@types/domains/curatedContent.d.ts.map +0 -1
  112. package/dist/@types/domains/pinnedMessage.d.ts +0 -43
  113. package/dist/@types/domains/pinnedMessage.d.ts.map +0 -1
  114. package/dist/channelRepository/events/onChannelMessagePinned.d.ts +0 -24
  115. package/dist/channelRepository/events/onChannelMessagePinned.d.ts.map +0 -1
  116. package/dist/channelRepository/events/onChannelMessageUnpinned.d.ts +0 -21
  117. package/dist/channelRepository/events/onChannelMessageUnpinned.d.ts.map +0 -1
  118. package/dist/channelRepository/events/onChannelPinnedMessageDeleted.d.ts +0 -12
  119. package/dist/channelRepository/events/onChannelPinnedMessageDeleted.d.ts.map +0 -1
  120. package/dist/channelRepository/events/tests/onChannelMemberRoleAdded.test.d.ts +0 -2
  121. package/dist/channelRepository/events/tests/onChannelMemberRoleAdded.test.d.ts.map +0 -1
  122. package/dist/channelRepository/events/tests/onChannelMemberRoleRemoved.test.d.ts +0 -2
  123. package/dist/channelRepository/events/tests/onChannelMemberRoleRemoved.test.d.ts.map +0 -1
  124. package/dist/channelRepository/events/tests/onChannelMessagePinned.test.d.ts +0 -2
  125. package/dist/channelRepository/events/tests/onChannelMessagePinned.test.d.ts.map +0 -1
  126. package/dist/channelRepository/utils/applyChannelRolePayload.d.ts +0 -21
  127. package/dist/channelRepository/utils/applyChannelRolePayload.d.ts.map +0 -1
  128. package/dist/channelRepository/utils/tests/pinnedMessage.test.d.ts +0 -2
  129. package/dist/channelRepository/utils/tests/pinnedMessage.test.d.ts.map +0 -1
  130. package/dist/channelRepository/utils/updatePinnedMessageCache.d.ts +0 -24
  131. package/dist/channelRepository/utils/updatePinnedMessageCache.d.ts.map +0 -1
  132. package/dist/client/api/getModuleSettings.d.ts +0 -25
  133. package/dist/client/api/getModuleSettings.d.ts.map +0 -1
  134. package/dist/client/api/tests/getSocialSettings.test.d.ts +0 -2
  135. package/dist/client/api/tests/getSocialSettings.test.d.ts.map +0 -1
  136. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts +0 -2
  137. package/dist/client/api/tests/integration/moduleSettings.integration.test.d.ts.map +0 -1
  138. package/dist/client/utils/parseModuleSettings.d.ts +0 -9
  139. package/dist/client/utils/parseModuleSettings.d.ts.map +0 -1
  140. package/dist/client/utils/resolveModuleAvailability.d.ts +0 -39
  141. package/dist/client/utils/resolveModuleAvailability.d.ts.map +0 -1
  142. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts +0 -2
  143. package/dist/client/utils/tests/resolveModuleAvailability.test.d.ts.map +0 -1
  144. package/dist/commentRepository/api/approveComment.d.ts +0 -17
  145. package/dist/commentRepository/api/approveComment.d.ts.map +0 -1
  146. package/dist/commentRepository/api/declineComment.d.ts +0 -18
  147. package/dist/commentRepository/api/declineComment.d.ts.map +0 -1
  148. package/dist/commentRepository/api/tests/approveComment.test.d.ts +0 -2
  149. package/dist/commentRepository/api/tests/approveComment.test.d.ts.map +0 -1
  150. package/dist/commentRepository/api/tests/createComment.optimistic.test.d.ts +0 -2
  151. package/dist/commentRepository/api/tests/createComment.optimistic.test.d.ts.map +0 -1
  152. package/dist/commentRepository/api/tests/declineComment.test.d.ts +0 -2
  153. package/dist/commentRepository/api/tests/declineComment.test.d.ts.map +0 -1
  154. package/dist/commentRepository/events/onCommentApproved.d.ts +0 -17
  155. package/dist/commentRepository/events/onCommentApproved.d.ts.map +0 -1
  156. package/dist/commentRepository/events/tests/onCommentApproved.test.d.ts +0 -2
  157. package/dist/commentRepository/events/tests/onCommentApproved.test.d.ts.map +0 -1
  158. package/dist/commentRepository/events/tests/onCommentCreated.count.test.d.ts +0 -2
  159. package/dist/commentRepository/events/tests/onCommentCreated.count.test.d.ts.map +0 -1
  160. package/dist/commentRepository/observers/getCommentReviewQueue/LiveCollectionController.d.ts +0 -13
  161. package/dist/commentRepository/observers/getCommentReviewQueue/LiveCollectionController.d.ts.map +0 -1
  162. package/dist/commentRepository/observers/getCommentReviewQueue/PaginationController.d.ts +0 -5
  163. package/dist/commentRepository/observers/getCommentReviewQueue/PaginationController.d.ts.map +0 -1
  164. package/dist/commentRepository/observers/getCommentReviewQueue/QueryStreamController.d.ts +0 -15
  165. package/dist/commentRepository/observers/getCommentReviewQueue/QueryStreamController.d.ts.map +0 -1
  166. package/dist/commentRepository/observers/getCommentReviewQueue.d.ts +0 -22
  167. package/dist/commentRepository/observers/getCommentReviewQueue.d.ts.map +0 -1
  168. package/dist/commentRepository/observers/tests/integrations/getCommentReviewQueue.integration.test.d.ts +0 -2
  169. package/dist/commentRepository/observers/tests/integrations/getCommentReviewQueue.integration.test.d.ts.map +0 -1
  170. package/dist/commentRepository/utils/approval.d.ts +0 -49
  171. package/dist/commentRepository/utils/approval.d.ts.map +0 -1
  172. package/dist/commentRepository/utils/tests/approval.test.d.ts +0 -2
  173. package/dist/commentRepository/utils/tests/approval.test.d.ts.map +0 -1
  174. package/dist/commentRepository/utils/tests/payload.test.d.ts +0 -2
  175. package/dist/commentRepository/utils/tests/payload.test.d.ts.map +0 -1
  176. package/dist/core/tests/device.test.d.ts +0 -2
  177. package/dist/core/tests/device.test.d.ts.map +0 -1
  178. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts +0 -2
  179. package/dist/core/transports/tests/moduleNotEntitled.test.d.ts.map +0 -1
  180. package/dist/curatedContentRepository/api/getPool.d.ts +0 -2
  181. package/dist/curatedContentRepository/api/getPool.d.ts.map +0 -1
  182. package/dist/curatedContentRepository/api/index.d.ts +0 -2
  183. package/dist/curatedContentRepository/api/index.d.ts.map +0 -1
  184. package/dist/curatedContentRepository/api/tests/getPool.test.d.ts +0 -2
  185. package/dist/curatedContentRepository/api/tests/getPool.test.d.ts.map +0 -1
  186. package/dist/curatedContentRepository/api/tests/integration/getPool.integration.test.d.ts +0 -2
  187. package/dist/curatedContentRepository/api/tests/integration/getPool.integration.test.d.ts.map +0 -1
  188. package/dist/curatedContentRepository/index.d.ts +0 -2
  189. package/dist/curatedContentRepository/index.d.ts.map +0 -1
  190. package/dist/messageRepository/api/pinMessage.d.ts +0 -29
  191. package/dist/messageRepository/api/pinMessage.d.ts.map +0 -1
  192. package/dist/messageRepository/api/tests/pinMessage.test.d.ts +0 -2
  193. package/dist/messageRepository/api/tests/pinMessage.test.d.ts.map +0 -1
  194. package/dist/messageRepository/api/tests/unpinMessage.test.d.ts +0 -2
  195. package/dist/messageRepository/api/tests/unpinMessage.test.d.ts.map +0 -1
  196. package/dist/messageRepository/api/unpinMessage.d.ts +0 -28
  197. package/dist/messageRepository/api/unpinMessage.d.ts.map +0 -1
  198. package/dist/messageRepository/utils/refreshChannelPermissionsForMessage.d.ts +0 -13
  199. package/dist/messageRepository/utils/refreshChannelPermissionsForMessage.d.ts.map +0 -1
  200. package/dist/postRepository/utils/PostCommentCountEngine/ApproveTask.d.ts +0 -16
  201. package/dist/postRepository/utils/PostCommentCountEngine/ApproveTask.d.ts.map +0 -1
  202. package/dist/postRepository/utils/PostCommentCountEngine/postCommentCountEngineOnLoginHandler.d.ts +0 -9
  203. package/dist/postRepository/utils/PostCommentCountEngine/postCommentCountEngineOnLoginHandler.d.ts.map +0 -1
  204. package/dist/postRepository/utils/PostCommentCountEngine/tests/getLocalCommentCount.test.d.ts +0 -2
  205. package/dist/postRepository/utils/PostCommentCountEngine/tests/getLocalCommentCount.test.d.ts.map +0 -1
  206. package/dist/postRepository/utils/PostCommentCountEngine/tests/pendingAuthoredComments.test.d.ts +0 -2
  207. package/dist/postRepository/utils/PostCommentCountEngine/tests/pendingAuthoredComments.test.d.ts.map +0 -1
  208. package/dist/postRepository/utils/latestComments.d.ts +0 -10
  209. package/dist/postRepository/utils/latestComments.d.ts.map +0 -1
  210. package/dist/postRepository/utils/tests/latestComments.test.d.ts +0 -2
  211. package/dist/postRepository/utils/tests/latestComments.test.d.ts.map +0 -1
  212. package/dist/postRepository/utils/tests/payload.test.d.ts +0 -2
  213. package/dist/postRepository/utils/tests/payload.test.d.ts.map +0 -1
  214. package/dist/utils/linkedObject/curatedContentTopicLinkedObject.d.ts +0 -2
  215. package/dist/utils/linkedObject/curatedContentTopicLinkedObject.d.ts.map +0 -1
  216. package/dist/utils/linkedObject/tests/postLinkedObject.test.d.ts +0 -2
  217. package/dist/utils/linkedObject/tests/postLinkedObject.test.d.ts.map +0 -1
  218. package/dist/utils/tests/dummy/pinnedMessage.d.ts +0 -2
  219. package/dist/utils/tests/dummy/pinnedMessage.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -7,9 +7,8 @@ var mitt = require('mitt');
7
7
  var debug = require('debug');
8
8
  var axios = require('axios');
9
9
  var HttpAgent = require('agentkeepalive');
10
- var uuid$1 = require('react-native-uuid');
11
10
  var mqtt = require('mqtt');
12
- var uaParserJs = require('ua-parser-js');
11
+ var uuid$1 = require('react-native-uuid');
13
12
  var jwtDecode = require('jwt-decode');
14
13
  var hash = require('object-hash');
15
14
  var Hls = require('hls.js');
@@ -20,8 +19,8 @@ var mitt__default = /*#__PURE__*/_interopDefaultLegacy(mitt);
20
19
  var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
21
20
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
22
21
  var HttpAgent__default = /*#__PURE__*/_interopDefaultLegacy(HttpAgent);
23
- var uuid__default = /*#__PURE__*/_interopDefaultLegacy(uuid$1);
24
22
  var mqtt__default = /*#__PURE__*/_interopDefaultLegacy(mqtt);
23
+ var uuid__default = /*#__PURE__*/_interopDefaultLegacy(uuid$1);
25
24
  var jwtDecode__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecode);
26
25
  var hash__default = /*#__PURE__*/_interopDefaultLegacy(hash);
27
26
  var Hls__default = /*#__PURE__*/_interopDefaultLegacy(Hls);
@@ -332,8 +331,8 @@ exports.AmityLiveViewerCountMode = void 0;
332
331
 
333
332
  function getVersion() {
334
333
  try {
335
- // the string ''v7.27.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
336
- return 'v7.27.0-cjs';
334
+ // the string ''v7.27.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
335
+ return 'v7.27.1-cjs';
337
336
  }
338
337
  catch (error) {
339
338
  return '__dev__';
@@ -342,7 +341,6 @@ function getVersion() {
342
341
  const VERSION = getVersion();
343
342
 
344
343
  const COLLECTION_DEFAULT_PAGINATION_LIMIT = 5;
345
- const LATEST_COMMENTS_LIMIT = 5;
346
344
  const COLLECTION_DEFAULT_PAGINATION_SIZE = 20;
347
345
  const COLLECTION_DEFAULT_CACHING_POLICY = 'cache_then_server';
348
346
  const ENABLE_CACHE_MESSAGE = 'For using Live Collection feature you need to enable Cache!';
@@ -358,11 +356,7 @@ const YEAR = 365 * DAY;
358
356
  const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
359
357
  const API_ENDPOINTS = {
360
358
  forYouFeed: '/api/v1/feeds/for-you',
361
- commentReviewQueue: (communityId) => `/api/v3/communities/${encodeURIComponent(communityId)}/comments/review-queue`,
362
359
  };
363
- // The review-queue route defaults to 10, not the SDK-wide page size, and caps at 100
364
- const COMMENT_REVIEW_QUEUE_DEFAULT_PAGINATION_SIZE = 10;
365
- const COMMENT_REVIEW_QUEUE_MAX_PAGINATION_SIZE = 100;
366
360
 
367
361
  // cache constants
368
362
  const CACHE_KEY_GET = 'get';
@@ -812,28 +806,6 @@ class ASCConnectionError extends ASCError {
812
806
  this.event = event;
813
807
  }
814
808
  }
815
- /**
816
- * Thrown when the network does not own a module the call needs. Raised from
817
- * any module endpoint under `enforce` enforcement, mapped from app code
818
- * `400325` — never from HTTP 403 alone, which already covers a role problem
819
- * (`400300` / `400301`), a visitor (`403999`) and a bot (`403998`).
820
- *
821
- * `modules` carries **every** key the refusal named, as raw strings, so a
822
- * caller can say which entitlement is absent without a second request.
823
- *
824
- * @category Errors
825
- */
826
- class AmityModuleNotEntitledError extends ASCApiError {
827
- /**
828
- * @param message The server's message, e.g. `Module not entitled: chat, live`
829
- * @param modules Every module key from the rejection's `data.modules`
830
- */
831
- constructor(message, modules = []) {
832
- super(message, 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */, "error" /* Amity.ErrorLevel.ERROR */);
833
- this.modules = modules;
834
- this.type = 'AmityModuleNotEntitledError';
835
- }
836
- }
837
809
 
838
810
  let activeClient = null;
839
811
  /**
@@ -1981,24 +1953,6 @@ function computeUrl(type, region) {
1981
1953
  return URLS[type].replace('{region}', region);
1982
1954
  }
1983
1955
 
1984
- const uuid = () => uuid__default["default"].v4().toString();
1985
-
1986
- /**
1987
- * Reads the module keys a `MODULE_NOT_ENTITLED` rejection named.
1988
- *
1989
- * Every entry is kept, as a raw string: one call can need more than one
1990
- * module, and a key this build predates is still the only part of the
1991
- * payload a customer can act on.
1992
- *
1993
- * @category Transport
1994
- * @hidden
1995
- */
1996
- const extractNotEntitledModules = (data) => {
1997
- const { modules } = data !== null && data !== void 0 ? data : {};
1998
- if (!Array.isArray(modules))
1999
- return [];
2000
- return modules.filter((module) => typeof module === 'string');
2001
- };
2002
1956
  /**
2003
1957
  * Unwraps v3 server payload (for error handling and type extraction)
2004
1958
  *
@@ -2018,38 +1972,11 @@ const unwrapPayload = (response) => {
2018
1972
  throw new ASCUnknownError(response.code);
2019
1973
  }
2020
1974
  else if (response.status === 'error') {
2021
- /*
2022
- * An entitlement refusal must not arrive as a generic failure: a customer
2023
- * cannot then tell a module they have not bought from an outage. Keyed on
2024
- * the app code, never on the HTTP status, so a role or membership problem
2025
- * still maps to the generic error.
2026
- */
2027
- if (response.code === 400325 /* Amity.ServerError.MODULE_NOT_ENTITLED */) {
2028
- throw new AmityModuleNotEntitledError(response.message, extractNotEntitledModules(response.data));
2029
- }
2030
1975
  throw new ASCApiError(response.message, response.code, "error" /* Amity.ErrorLevel.ERROR */);
2031
1976
  }
2032
1977
  // unjust, but helps force uncast "T | undefined" to allow deconstruction without warnings
2033
1978
  return undefined;
2034
1979
  };
2035
- /**
2036
- * Builds a hex string of `bytes` length from the SDK's uuid helper (a v4 UUID is
2037
- * 16 bytes / 32 hex chars once hyphens are removed) — avoids a new crypto dependency.
2038
- */
2039
- const randomHex = (bytes) => {
2040
- let hex = '';
2041
- while (hex.length < bytes * 2)
2042
- hex += uuid().replace(/-/g, '');
2043
- return hex.slice(0, bytes * 2);
2044
- };
2045
- /**
2046
- * W3C Trace Context `traceparent`: `version-<16-byte trace-id>-<8-byte span-id>-<flags>`.
2047
- * The SDK is the trace originator, so it mints a fresh trace + span id per request; flags `01` = sampled.
2048
- *
2049
- * @category Transport
2050
- * @hidden
2051
- */
2052
- const generateTraceparent = () => `00-${randomHex(16)}-${randomHex(8)}-01`;
2053
1980
 
2054
1981
  class NetworkActivitiesWatcher {
2055
1982
  constructor() {
@@ -2174,10 +2101,6 @@ const createHttpTransport = (endpoint) => {
2174
2101
  });
2175
2102
  instance.defaults.withCredentials = false;
2176
2103
  instance.interceptors.request.use(config => {
2177
- // Request tracing — set on every outbound request (login included), never persisted.
2178
- // Must run before the session-url early-return below so /api/v5/sessions carries them too.
2179
- config.headers.set('x-request-id', uuid());
2180
- config.headers.set('traceparent', generateTraceparent());
2181
2104
  // do not check expiration for token creation url
2182
2105
  if (config.url === '/api/v5/sessions') {
2183
2106
  return config;
@@ -2440,6 +2363,8 @@ const getItem = async (key) => {
2440
2363
  });
2441
2364
  };
2442
2365
 
2366
+ const uuid = () => uuid__default["default"].v4().toString();
2367
+
2443
2368
  // TODO: find a way to uniquely identify the device
2444
2369
  let tabIndex = 0;
2445
2370
  // This logic is running on browser only
@@ -2499,60 +2424,22 @@ const getMQTTClientId = async (userId) => {
2499
2424
  };
2500
2425
  /** @hidden */
2501
2426
  const getDeviceModel = () => {
2502
- var _a;
2427
+ var _a, _b;
2503
2428
  if ((_a = safeProcess.versions) === null || _a === void 0 ? void 0 : _a.node)
2504
2429
  return safeProcess.versions.node;
2505
- return undefined;
2506
- };
2507
- const hasNavigator = () => typeof navigator !== 'undefined' && !!navigator;
2508
- const getLocale = () => (hasNavigator() ? navigator.language : undefined);
2509
- const getTimezone = () => {
2510
- try {
2511
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
2512
- }
2513
- catch (_a) {
2514
- return undefined;
2515
- }
2516
- };
2517
- const getNetworkType = () => {
2518
- var _a;
2519
- if (!hasNavigator())
2520
- return undefined;
2521
- return (_a = navigator.connection) === null || _a === void 0 ? void 0 : _a.effectiveType;
2522
- };
2523
- const isNode = () => { var _a; return !!((_a = safeProcess.versions) === null || _a === void 0 ? void 0 : _a.node); };
2524
- const parseUserAgent = () => {
2525
- if (!hasNavigator() || !navigator.userAgent)
2526
- return {};
2527
- const { os, browser, device } = new uaParserJs.UAParser(navigator.userAgent).getResult();
2528
- const result = {};
2529
- if (os.name)
2530
- result.osName = os.name;
2531
- if (os.version)
2532
- result.osVersion = os.version;
2533
- if (browser.name)
2534
- result.browserName = browser.name;
2535
- if (browser.version)
2536
- result.browserVersion = browser.version;
2537
- if (device.type === 'tablet')
2538
- result.deviceType = 'tablet';
2539
- else if (device.type === 'mobile')
2540
- result.deviceType = 'mobile';
2541
- else
2542
- result.deviceType = 'desktop';
2543
- return result;
2430
+ if (navigator)
2431
+ return `${navigator.product.toLowerCase()}#${(_b = navigator.userAgent) !== null && _b !== void 0 ? _b : 'unknown_agent'}`;
2432
+ return 'unknown_model';
2544
2433
  };
2545
2434
  /** @hidden */
2546
2435
  const getDeviceInfo = () => {
2547
- var _a;
2548
- let client;
2549
- try {
2550
- client = getActiveClient();
2551
- }
2552
- catch (_b) {
2553
- client = undefined;
2554
- }
2555
- return Object.assign({ kind: isNode() ? 'node' : 'web', model: getDeviceModel(), sdkVersion: VERSION, product: (_a = client === null || client === void 0 ? void 0 : client.product) !== null && _a !== void 0 ? _a : 'sdk', uikitVersion: client === null || client === void 0 ? void 0 : client.uikitVersion, appId: client === null || client === void 0 ? void 0 : client.appId, appVersion: client === null || client === void 0 ? void 0 : client.appVersion, locale: getLocale(), timezone: getTimezone(), networkType: getNetworkType() }, parseUserAgent());
2436
+ const model = getDeviceModel();
2437
+ return {
2438
+ // TODO: replace with: kind: process.versions ? 'node' : 'web', when backend has fixed this
2439
+ kind: 'web',
2440
+ model,
2441
+ sdkVersion: VERSION,
2442
+ };
2556
2443
  };
2557
2444
 
2558
2445
  /* eslint-disable no-console */
@@ -2611,6 +2498,9 @@ const createMqttTransport = (endpoint) => {
2611
2498
  const clientId = await getMQTTClientId(params.userId);
2612
2499
  if (mqttClient) {
2613
2500
  mqttClient.removeAllListeners();
2501
+ mqttClient.on('error', error => {
2502
+ console.warn('MQTT discarded connection error:', error === null || error === void 0 ? void 0 : error.message);
2503
+ });
2614
2504
  mqttClient.end(true);
2615
2505
  }
2616
2506
  mqttClient = mqtt__default["default"].connect(endpoint, getMqttOptions({
@@ -3961,95 +3851,6 @@ const prepareChannelPayload = async (rawPayload, options = { isMessagePreviewUpd
3961
3851
  channelUsers });
3962
3852
  };
3963
3853
 
3964
- const channelCacheKey = (channel) => [
3965
- 'channel',
3966
- 'get',
3967
- getResolver('channel')(channel),
3968
- ];
3969
- /**
3970
- * Find a cached channel by any of its ids (internal, public, or `channelId`).
3971
- *
3972
- * The channel cache is keyed by the channel internal id (see `idResolvers.channel`), but
3973
- * realtime payloads reference channels by different ids: pin events carry the **public**
3974
- * id, messages carry `channelId`. Try the cheap direct lookup first, then scan.
3975
- */
3976
- const findCachedChannelByAnyId = (id) => {
3977
- var _a, _b, _c;
3978
- if (!id)
3979
- return undefined;
3980
- const direct = (_a = pullFromCache(['channel', 'get', id])) === null || _a === void 0 ? void 0 : _a.data;
3981
- if (direct)
3982
- return direct;
3983
- return (_c = (_b = queryCache(['channel', 'get'])) === null || _b === void 0 ? void 0 : _b.find(({ data }) => data.channelInternalId === id || data.channelPublicId === id || data.channelId === id)) === null || _c === void 0 ? void 0 : _c.data;
3984
- };
3985
- /**
3986
- * Resolve the cached channel a `channel.messagePinned` / `channel.messageUnpinned` event
3987
- * refers to. `data.channelId` is the channel public id; a pinned message body (present on
3988
- * `messagePinned` only) also carries the internal id, which is the direct cache key.
3989
- */
3990
- const findCachedChannelForPin = (payload) => {
3991
- var _a, _b;
3992
- return (_b = findCachedChannelByAnyId((_a = payload.pinnedMessage) === null || _a === void 0 ? void 0 : _a.channelId)) !== null && _b !== void 0 ? _b : findCachedChannelByAnyId(payload.channelId);
3993
- };
3994
- /**
3995
- * Write a new pin snapshot (or `null` to clear) on a cached channel and ingest any
3996
- * users delivered with it (the pin author and the message author), so the banner can
3997
- * render a byline without a second fetch.
3998
- *
3999
- * Every `messagePinned` payload is a full snapshot — "this is the pin now" — so the last
4000
- * one received always wins; there is no merging with the previous pin.
4001
- */
4002
- const updatePinnedMessageCache = (channel, pinnedMessage, users) => {
4003
- if (users && users.length > 0) {
4004
- ingestInCache({ users: users.map(convertRawUserToInternalUser) });
4005
- }
4006
- const updated = Object.assign(Object.assign({}, channel), { pinnedMessage });
4007
- pushToCache(channelCacheKey(channel), updated);
4008
- return updated;
4009
- };
4010
-
4011
- /**
4012
- * Applies a `channel.roleAdded` / `channel.roleRemoved` realtime payload to the cache.
4013
- *
4014
- * The event names every member the role request affected together with the
4015
- * roles and channel-scoped permissions each of them is left holding. That is a
4016
- * full state, not a delta, so it is written straight over the cached membership.
4017
- *
4018
- * Members the SDK has not fetched yet are skipped: the payload does not carry
4019
- * enough to build a full {@link Amity.Membership} and the live collections only
4020
- * emit rows that already exist in cache.
4021
- *
4022
- * @param payload the `data` of the realtime event
4023
- * @returns the refreshed channel (when resolvable) and the updated cached memberships
4024
- *
4025
- * @hidden
4026
- */
4027
- const applyChannelRolePayload = (payload) => {
4028
- var _a, _b, _c;
4029
- const { channelId, users = [], channels = [] } = payload;
4030
- const rawChannel = (_a = channels.find(channel => channel.channelId === channelId)) !== null && _a !== void 0 ? _a : channels[0];
4031
- let channel;
4032
- if (rawChannel) {
4033
- const channelKey = ['channel', 'get', getResolver('channel')(rawChannel)];
4034
- // the role event does not touch message previews, keep whatever preview is cached
4035
- const converted = convertFromRaw(rawChannel, { isMessagePreviewUpdated: false });
4036
- upsertInCache(channelKey, converted);
4037
- channel = (_c = (_b = pullFromCache(channelKey)) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : converted;
4038
- }
4039
- const members = [];
4040
- users.forEach(({ userId, roles, permissions }) => {
4041
- var _a, _b, _c;
4042
- const memberKey = ['channelUsers', 'get', getResolver('channelUsers')({ channelId, userId })];
4043
- const cached = (_a = pullFromCache(memberKey)) === null || _a === void 0 ? void 0 : _a.data;
4044
- if (!cached)
4045
- return;
4046
- const updated = Object.assign(Object.assign({}, cached), { roles, permissions });
4047
- pushToCache(memberKey, updated);
4048
- members.push((_c = (_b = pullFromCache(memberKey)) === null || _b === void 0 ? void 0 : _b.data) !== null && _c !== void 0 ? _c : updated);
4049
- });
4050
- return { channel, members };
4051
- };
4052
-
4053
3854
  /**
4054
3855
  * ```js
4055
3856
  * import { getSubChannelMarkers } from '@amityco/ts-sdk'
@@ -4235,6 +4036,32 @@ const channelMemberLinkedObject = (channelMember) => {
4235
4036
  } });
4236
4037
  };
4237
4038
 
4039
+ /**
4040
+ *
4041
+ * get current user's membership data
4042
+ *
4043
+ * @returns the {@link Amity.Membership<'channel'>} objects
4044
+ *
4045
+ * @category Channel API
4046
+ * @async
4047
+ */
4048
+ const getMyMembership$1 = (channelId) => {
4049
+ const client = getActiveClient();
4050
+ client.log('channel/getMyMembership.locally');
4051
+ const cacheChannelUser = pullFromCache([
4052
+ 'channelUsers',
4053
+ 'get',
4054
+ `${channelId}#${client.userId}`,
4055
+ ]);
4056
+ if (!cacheChannelUser) {
4057
+ throw new ASCApiError('Item not found!', 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
4058
+ }
4059
+ return {
4060
+ data: cacheChannelUser.data,
4061
+ cachedAt: cacheChannelUser.cachedAt,
4062
+ };
4063
+ };
4064
+
4238
4065
  /**
4239
4066
  * ```js
4240
4067
  * import { isEqual } from '~/utils/isEqual'
@@ -4305,81 +4132,55 @@ function isEqual(x, y) {
4305
4132
  }));
4306
4133
  }
4307
4134
 
4308
- /**
4309
- *
4310
- * get current user's membership data
4311
- *
4312
- * @returns the {@link Amity.Membership<'channel'>} objects
4313
- *
4314
- * @category Channel API
4315
- * @async
4316
- */
4317
- const getMyMembership$1 = (channelId) => {
4318
- const client = getActiveClient();
4319
- client.log('channel/getMyMembership.locally');
4320
- const cacheChannelUser = pullFromCache([
4321
- 'channelUsers',
4322
- 'get',
4323
- `${channelId}#${client.userId}`,
4324
- ]);
4325
- if (!cacheChannelUser) {
4326
- throw new ASCApiError('Item not found!', 400400 /* Amity.ServerError.ITEM_NOT_FOUND */, "error" /* Amity.ErrorLevel.ERROR */);
4327
- }
4328
- return {
4329
- data: cacheChannelUser.data,
4330
- cachedAt: cacheChannelUser.cachedAt,
4331
- };
4332
- };
4333
-
4334
- const callbacks$e = [];
4135
+ const callbacks$c = [];
4335
4136
  let mainDisposer$b = null;
4336
- const dispose$e = (cb) => {
4337
- const index = callbacks$e.indexOf(cb);
4137
+ const dispose$c = (cb) => {
4138
+ const index = callbacks$c.indexOf(cb);
4338
4139
  if (index > -1) {
4339
- callbacks$e.splice(index, 1);
4140
+ callbacks$c.splice(index, 1);
4340
4141
  }
4341
- if (callbacks$e.length === 0) {
4142
+ if (callbacks$c.length === 0) {
4342
4143
  mainDisposer$b === null || mainDisposer$b === void 0 ? void 0 : mainDisposer$b();
4343
4144
  }
4344
4145
  };
4345
4146
  const onChannelCreated = (callback) => {
4346
- if (callbacks$e.length === 0) {
4147
+ if (callbacks$c.length === 0) {
4347
4148
  const client = getActiveClient();
4348
4149
  const filter = async (payload) => {
4349
4150
  const data = await prepareChannelPayload(payload);
4350
4151
  ingestInCache(data);
4351
- callbacks$e.forEach(cb => cb(data.channels[0]));
4152
+ callbacks$c.forEach(cb => cb(data.channels[0]));
4352
4153
  };
4353
4154
  mainDisposer$b = createEventSubscriber(client, 'onChannelCreated', 'channel.created', filter);
4354
4155
  }
4355
- callbacks$e.push(callback);
4356
- return () => dispose$e(callback);
4156
+ callbacks$c.push(callback);
4157
+ return () => dispose$c(callback);
4357
4158
  };
4358
4159
 
4359
- const callbacks$d = [];
4360
- const mainDisposers$2 = [];
4361
- const dispose$d = (cb) => {
4362
- const index = callbacks$d.indexOf(cb);
4160
+ const callbacks$b = [];
4161
+ const mainDisposers = [];
4162
+ const dispose$b = (cb) => {
4163
+ const index = callbacks$b.indexOf(cb);
4363
4164
  if (index > -1) {
4364
- callbacks$d.splice(index, 1);
4165
+ callbacks$b.splice(index, 1);
4365
4166
  }
4366
- if (callbacks$d.length === 0) {
4367
- mainDisposers$2.forEach(fn => fn());
4167
+ if (callbacks$b.length === 0) {
4168
+ mainDisposers.forEach(fn => fn());
4368
4169
  }
4369
4170
  };
4370
4171
  const onChannelUpdated = (callback) => {
4371
4172
  const client = getActiveClient();
4372
- if (callbacks$d.length === 0) {
4173
+ if (callbacks$b.length === 0) {
4373
4174
  const filter = async (payload) => {
4374
4175
  const data = await prepareChannelPayload(payload);
4375
4176
  ingestInCache(data);
4376
- callbacks$d.forEach(cb => cb(data.channels[0]));
4177
+ callbacks$b.forEach(cb => cb(data.channels[0]));
4377
4178
  };
4378
- mainDisposers$2.push(createEventSubscriber(client, 'onChannelUpdated', 'channel.updated', filter));
4379
- mainDisposers$2.push(createEventSubscriber(client, 'onChannelUpdated', 'local.channel.updated', payload => callbacks$d.forEach(cb => cb(payload.channels[0]))));
4179
+ mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'channel.updated', filter));
4180
+ mainDisposers.push(createEventSubscriber(client, 'onChannelUpdated', 'local.channel.updated', payload => callbacks$b.forEach(cb => cb(payload.channels[0]))));
4380
4181
  }
4381
- callbacks$d.push(callback);
4382
- return () => dispose$d(callback);
4182
+ callbacks$b.push(callback);
4183
+ return () => dispose$b(callback);
4383
4184
  };
4384
4185
 
4385
4186
  const addFlagIsDeletedSubChannelUnreadByChannelId = (channelId) => {
@@ -4402,19 +4203,19 @@ const deleteChannelUnreadByChannelId = (channelId) => {
4402
4203
  }
4403
4204
  };
4404
4205
 
4405
- const callbacks$c = [];
4206
+ const callbacks$a = [];
4406
4207
  let mainDisposer$a = null;
4407
- const dispose$c = (cb) => {
4408
- const index = callbacks$c.indexOf(cb);
4208
+ const dispose$a = (cb) => {
4209
+ const index = callbacks$a.indexOf(cb);
4409
4210
  if (index > -1) {
4410
- callbacks$c.splice(index, 1);
4211
+ callbacks$a.splice(index, 1);
4411
4212
  }
4412
- if (callbacks$c.length === 0) {
4213
+ if (callbacks$a.length === 0) {
4413
4214
  mainDisposer$a === null || mainDisposer$a === void 0 ? void 0 : mainDisposer$a();
4414
4215
  }
4415
4216
  };
4416
4217
  const onChannelDeleted = (callback) => {
4417
- if (callbacks$c.length === 0) {
4218
+ if (callbacks$a.length === 0) {
4418
4219
  const client = getActiveClient();
4419
4220
  const filter = async (payload) => {
4420
4221
  const data = await prepareChannelPayload(payload);
@@ -4434,53 +4235,53 @@ const onChannelDeleted = (callback) => {
4434
4235
  }
4435
4236
  });
4436
4237
  ingestInCache(data);
4437
- callbacks$c.forEach(cb => cb(data.channels[0]));
4238
+ callbacks$a.forEach(cb => cb(data.channels[0]));
4438
4239
  };
4439
4240
  mainDisposer$a = createEventSubscriber(client, 'onChannelDeleted', 'channel.deleted', filter);
4440
4241
  }
4441
- callbacks$c.push(callback);
4442
- return () => dispose$c(callback);
4242
+ callbacks$a.push(callback);
4243
+ return () => dispose$a(callback);
4443
4244
  };
4444
4245
 
4445
- const callbacks$b = [];
4246
+ const callbacks$9 = [];
4446
4247
  let mainDisposer$9 = null;
4447
- const dispose$b = (cb) => {
4448
- const index = callbacks$b.indexOf(cb);
4248
+ const dispose$9 = (cb) => {
4249
+ const index = callbacks$9.indexOf(cb);
4449
4250
  if (index > -1) {
4450
- callbacks$b.splice(index, 1);
4251
+ callbacks$9.splice(index, 1);
4451
4252
  }
4452
- if (callbacks$b.length === 0) {
4253
+ if (callbacks$9.length === 0) {
4453
4254
  mainDisposer$9 === null || mainDisposer$9 === void 0 ? void 0 : mainDisposer$9();
4454
4255
  }
4455
4256
  };
4456
4257
  const onChannelJoined = (callback) => {
4457
- if (callbacks$b.length === 0) {
4258
+ if (callbacks$9.length === 0) {
4458
4259
  const client = getActiveClient();
4459
4260
  const filter = async (payload) => {
4460
4261
  const preparedPayload = await prepareChannelPayload(payload);
4461
4262
  const { channels, channelUsers } = preparedPayload;
4462
4263
  ingestInCache(preparedPayload);
4463
- callbacks$b.forEach(cb => cb(channels[0], channelUsers[0]));
4264
+ callbacks$9.forEach(cb => cb(channels[0], channelUsers[0]));
4464
4265
  };
4465
4266
  mainDisposer$9 = createEventSubscriber(client, 'onChannelJoined', 'channel.joined', filter);
4466
4267
  }
4467
- callbacks$b.push(callback);
4468
- return () => dispose$b(callback);
4268
+ callbacks$9.push(callback);
4269
+ return () => dispose$9(callback);
4469
4270
  };
4470
4271
 
4471
- const callbacks$a = [];
4272
+ const callbacks$8 = [];
4472
4273
  let mainDisposer$8 = null;
4473
- const dispose$a = (cb) => {
4474
- const index = callbacks$a.indexOf(cb);
4274
+ const dispose$8 = (cb) => {
4275
+ const index = callbacks$8.indexOf(cb);
4475
4276
  if (index > -1) {
4476
- callbacks$a.splice(index, 1);
4277
+ callbacks$8.splice(index, 1);
4477
4278
  }
4478
- if (callbacks$a.length === 0) {
4279
+ if (callbacks$8.length === 0) {
4479
4280
  mainDisposer$8 === null || mainDisposer$8 === void 0 ? void 0 : mainDisposer$8();
4480
4281
  }
4481
4282
  };
4482
4283
  const onChannelLeft = (callback) => {
4483
- if (callbacks$a.length === 0) {
4284
+ if (callbacks$8.length === 0) {
4484
4285
  const client = getActiveClient();
4485
4286
  const filter = async (payload) => {
4486
4287
  const { userId } = getActiveClient();
@@ -4504,27 +4305,27 @@ const onChannelLeft = (callback) => {
4504
4305
  }
4505
4306
  const { channels, channelUsers } = preparedPayload;
4506
4307
  ingestInCache(preparedPayload);
4507
- callbacks$a.forEach(cb => cb(channels[0], channelUsers[0]));
4308
+ callbacks$8.forEach(cb => cb(channels[0], channelUsers[0]));
4508
4309
  };
4509
4310
  mainDisposer$8 = createEventSubscriber(client, 'onChannelLeft', 'channel.left', filter);
4510
4311
  }
4511
- callbacks$a.push(callback);
4512
- return () => dispose$a(callback);
4312
+ callbacks$8.push(callback);
4313
+ return () => dispose$8(callback);
4513
4314
  };
4514
4315
 
4515
- const callbacks$9 = [];
4316
+ const callbacks$7 = [];
4516
4317
  let mainDisposer$7 = null;
4517
- const dispose$9 = (cb) => {
4518
- const index = callbacks$9.indexOf(cb);
4318
+ const dispose$7 = (cb) => {
4319
+ const index = callbacks$7.indexOf(cb);
4519
4320
  if (index > -1) {
4520
- callbacks$9.splice(index, 1);
4321
+ callbacks$7.splice(index, 1);
4521
4322
  }
4522
- if (callbacks$9.length === 0) {
4323
+ if (callbacks$7.length === 0) {
4523
4324
  mainDisposer$7 === null || mainDisposer$7 === void 0 ? void 0 : mainDisposer$7();
4524
4325
  }
4525
4326
  };
4526
4327
  const onChannelSetMuted = (callback) => {
4527
- if (callbacks$9.length === 0) {
4328
+ if (callbacks$7.length === 0) {
4528
4329
  const client = getActiveClient();
4529
4330
  const filter = async (payload) => {
4530
4331
  var _a;
@@ -4539,124 +4340,24 @@ const onChannelSetMuted = (callback) => {
4539
4340
  payload.channelId,
4540
4341
  ])) === null || _a === void 0 ? void 0 : _a.data;
4541
4342
  if (channel) {
4542
- callbacks$9.forEach(cb => cb(channel));
4343
+ callbacks$7.forEach(cb => cb(channel));
4543
4344
  }
4544
4345
  };
4545
4346
  mainDisposer$7 = createEventSubscriber(client, 'onChannelMute', 'channel.setMuted', filter);
4546
4347
  }
4547
- callbacks$9.push(callback);
4548
- return () => dispose$9(callback);
4549
- };
4550
-
4551
- const callbacks$8 = [];
4552
- let mainDisposer$6 = null;
4553
- const dispose$8 = (cb) => {
4554
- const index = callbacks$8.indexOf(cb);
4555
- if (index > -1) {
4556
- callbacks$8.splice(index, 1);
4557
- }
4558
- if (callbacks$8.length === 0) {
4559
- mainDisposer$6 === null || mainDisposer$6 === void 0 ? void 0 : mainDisposer$6();
4560
- }
4561
- };
4562
- /* begin_public_function
4563
- id: channel.event.message_pinned
4564
- */
4565
- /**
4566
- * ```js
4567
- * import { onChannelMessagePinned } from '@amityco/ts-sdk'
4568
- * const dispose = onChannelMessagePinned(channel => {
4569
- * // channel.pinnedMessage is the new pin
4570
- * })
4571
- * ```
4572
- *
4573
- * Fired when a message is pinned in a channel (the `channel.messagePinned` realtime
4574
- * event). Pinning a different message while one is already pinned emits a single
4575
- * `messagePinned` carrying the replacement — treat every payload as a full snapshot.
4576
- *
4577
- * The updated channel is written to cache before the callback runs, so
4578
- * `ChannelRepository.getChannel` observers see `channel.pinnedMessage` change.
4579
- *
4580
- * @param callback The function to call when the event was fired
4581
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4582
- *
4583
- * @category Channel Events
4584
- */
4585
- const onChannelMessagePinned = (callback) => {
4586
- if (callbacks$8.length === 0) {
4587
- const client = getActiveClient();
4588
- const filter = (payload) => {
4589
- var _a;
4590
- const channel = findCachedChannelForPin(payload);
4591
- if (!channel)
4592
- return;
4593
- const updated = updatePinnedMessageCache(channel, (_a = payload.pinnedMessage) !== null && _a !== void 0 ? _a : null, payload.users);
4594
- callbacks$8.forEach(cb => cb(updated));
4595
- };
4596
- mainDisposer$6 = createEventSubscriber(client, 'onChannelMessagePinned', 'channel.messagePinned', filter);
4597
- }
4598
- callbacks$8.push(callback);
4599
- return () => dispose$8(callback);
4600
- };
4601
- /* end_public_function */
4602
-
4603
- const callbacks$7 = [];
4604
- let mainDisposer$5 = null;
4605
- const dispose$7 = (cb) => {
4606
- const index = callbacks$7.indexOf(cb);
4607
- if (index > -1) {
4608
- callbacks$7.splice(index, 1);
4609
- }
4610
- if (callbacks$7.length === 0) {
4611
- mainDisposer$5 === null || mainDisposer$5 === void 0 ? void 0 : mainDisposer$5();
4612
- }
4613
- };
4614
- /* begin_public_function
4615
- id: channel.event.message_unpinned
4616
- */
4617
- /**
4618
- * ```js
4619
- * import { onChannelMessageUnpinned } from '@amityco/ts-sdk'
4620
- * const dispose = onChannelMessageUnpinned(channel => {
4621
- * // channel.pinnedMessage is now null
4622
- * })
4623
- * ```
4624
- *
4625
- * Fired when a channel's pinned message is removed (the `channel.messageUnpinned`
4626
- * realtime event) — either by an explicit unpin or automatically by the server when the
4627
- * pinned message is deleted or its author is banned from the channel / globally.
4628
- *
4629
- * @param callback The function to call when the event was fired
4630
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4631
- *
4632
- * @category Channel Events
4633
- */
4634
- const onChannelMessageUnpinned = (callback) => {
4635
- if (callbacks$7.length === 0) {
4636
- const client = getActiveClient();
4637
- const filter = (payload) => {
4638
- const channel = findCachedChannelForPin(payload);
4639
- if (!channel)
4640
- return;
4641
- const updated = updatePinnedMessageCache(channel, null);
4642
- callbacks$7.forEach(cb => cb(updated));
4643
- };
4644
- mainDisposer$5 = createEventSubscriber(client, 'onChannelMessageUnpinned', 'channel.messageUnpinned', filter);
4645
- }
4646
4348
  callbacks$7.push(callback);
4647
4349
  return () => dispose$7(callback);
4648
4350
  };
4649
- /* end_public_function */
4650
4351
 
4651
4352
  const callbacks$6 = [];
4652
- let mainDisposer$4 = null;
4353
+ let mainDisposer$6 = null;
4653
4354
  const dispose$6 = (cb) => {
4654
4355
  const index = callbacks$6.indexOf(cb);
4655
4356
  if (index > -1) {
4656
4357
  callbacks$6.splice(index, 1);
4657
4358
  }
4658
4359
  if (callbacks$6.length === 0) {
4659
- mainDisposer$4 === null || mainDisposer$4 === void 0 ? void 0 : mainDisposer$4();
4360
+ mainDisposer$6 === null || mainDisposer$6 === void 0 ? void 0 : mainDisposer$6();
4660
4361
  }
4661
4362
  };
4662
4363
  const onChannelMemberAdded = (callback) => {
@@ -4668,21 +4369,21 @@ const onChannelMemberAdded = (callback) => {
4668
4369
  ingestInCache(preparedPayload);
4669
4370
  callbacks$6.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'member')));
4670
4371
  };
4671
- mainDisposer$4 = createEventSubscriber(client, 'onChannelMemberAdded', 'channel.membersAdded', filter);
4372
+ mainDisposer$6 = createEventSubscriber(client, 'onChannelMemberAdded', 'channel.membersAdded', filter);
4672
4373
  }
4673
4374
  callbacks$6.push(callback);
4674
4375
  return () => dispose$6(callback);
4675
4376
  };
4676
4377
 
4677
4378
  const callbacks$5 = [];
4678
- let mainDisposer$3 = null;
4379
+ let mainDisposer$5 = null;
4679
4380
  const dispose$5 = (cb) => {
4680
4381
  const index = callbacks$5.indexOf(cb);
4681
4382
  if (index > -1) {
4682
4383
  callbacks$5.splice(index, 1);
4683
4384
  }
4684
4385
  if (callbacks$5.length === 0) {
4685
- mainDisposer$3 === null || mainDisposer$3 === void 0 ? void 0 : mainDisposer$3();
4386
+ mainDisposer$5 === null || mainDisposer$5 === void 0 ? void 0 : mainDisposer$5();
4686
4387
  }
4687
4388
  };
4688
4389
  const onChannelMemberRemoved = (callback) => {
@@ -4694,21 +4395,21 @@ const onChannelMemberRemoved = (callback) => {
4694
4395
  ingestInCache(preparedPayload);
4695
4396
  callbacks$5.forEach(cb => cb(channels[0], channelUsers[0]));
4696
4397
  };
4697
- mainDisposer$3 = createEventSubscriber(client, 'onChannelMemberRemoved', 'channel.membersRemoved', filter);
4398
+ mainDisposer$5 = createEventSubscriber(client, 'onChannelMemberRemoved', 'channel.membersRemoved', filter);
4698
4399
  }
4699
4400
  callbacks$5.push(callback);
4700
4401
  return () => dispose$5(callback);
4701
4402
  };
4702
4403
 
4703
4404
  const callbacks$4 = [];
4704
- let mainDisposer$2 = null;
4405
+ let mainDisposer$4 = null;
4705
4406
  const dispose$4 = (cb) => {
4706
4407
  const index = callbacks$4.indexOf(cb);
4707
4408
  if (index > -1) {
4708
4409
  callbacks$4.splice(index, 1);
4709
4410
  }
4710
4411
  if (callbacks$4.length === 0) {
4711
- mainDisposer$2 === null || mainDisposer$2 === void 0 ? void 0 : mainDisposer$2();
4412
+ mainDisposer$4 === null || mainDisposer$4 === void 0 ? void 0 : mainDisposer$4();
4712
4413
  }
4713
4414
  };
4714
4415
  const onChannelMemberBanned = (callback) => {
@@ -4728,20 +4429,20 @@ const onChannelMemberBanned = (callback) => {
4728
4429
  ingestInCache(preparedPayload);
4729
4430
  callbacks$4.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'banned')));
4730
4431
  };
4731
- mainDisposer$2 = createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
4432
+ mainDisposer$4 = createEventSubscriber(client, 'onChannelMemberBanned', 'channel.banned', filter);
4732
4433
  callbacks$4.push(callback);
4733
4434
  return () => dispose$4(callback);
4734
4435
  };
4735
4436
 
4736
4437
  const callbacks$3 = [];
4737
- let mainDisposer$1 = null;
4438
+ let mainDisposer$3 = null;
4738
4439
  const dispose$3 = (cb) => {
4739
4440
  const index = callbacks$3.indexOf(cb);
4740
4441
  if (index > -1) {
4741
4442
  callbacks$3.splice(index, 1);
4742
4443
  }
4743
4444
  if (callbacks$3.length === 0) {
4744
- mainDisposer$1 === null || mainDisposer$1 === void 0 ? void 0 : mainDisposer$1();
4445
+ mainDisposer$3 === null || mainDisposer$3 === void 0 ? void 0 : mainDisposer$3();
4745
4446
  }
4746
4447
  };
4747
4448
  const onChannelMemberUnbanned = (callback) => {
@@ -4753,127 +4454,59 @@ const onChannelMemberUnbanned = (callback) => {
4753
4454
  ingestInCache(preparedPayload);
4754
4455
  callbacks$3.forEach(cb => cb(channels[0], channelUsers.find(cu => cu.membership === 'none')));
4755
4456
  };
4756
- mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
4457
+ mainDisposer$3 = createEventSubscriber(client, 'onChannelMemberUnbanned', 'channel.unbanned', filter);
4757
4458
  }
4758
4459
  callbacks$3.push(callback);
4759
4460
  return () => dispose$3(callback);
4760
4461
  };
4761
4462
 
4762
4463
  const callbacks$2 = [];
4763
- const mainDisposers$1 = [];
4464
+ let mainDisposer$2 = null;
4764
4465
  const dispose$2 = (cb) => {
4765
4466
  const index = callbacks$2.indexOf(cb);
4766
4467
  if (index > -1) {
4767
4468
  callbacks$2.splice(index, 1);
4768
4469
  }
4769
4470
  if (callbacks$2.length === 0) {
4770
- mainDisposers$1.forEach(fn => fn());
4771
- mainDisposers$1.length = 0;
4471
+ mainDisposer$2 === null || mainDisposer$2 === void 0 ? void 0 : mainDisposer$2();
4772
4472
  }
4773
4473
  };
4774
- /* begin_public_function
4775
- id: channel.event.member_role_added
4776
- */
4777
- /**
4778
- * ```js
4779
- * import { onChannelMemberRoleAdded } from '@amityco/ts-sdk'
4780
- * const dispose = onChannelMemberRoleAdded((channel, member) => {
4781
- * // member.roles and member.permissions are the member's resulting state
4782
- * })
4783
- * ```
4784
- *
4785
- * Fired when a role is added to a member of a {@link Amity.Channel}, either by the
4786
- * local `ChannelRepository.Moderation.addRole` call or by the `channel.roleAdded` realtime
4787
- * event coming from any client or the admin console.
4788
- *
4789
- * The realtime event reaches every subscriber of the channel topic (see `getChannelTopic`),
4790
- * not only the actor or the affected members. It carries the affected members' resulting
4791
- * channel roles and channel-scoped permissions, which are written to cache before the
4792
- * callback runs. The callback is invoked once per affected member already held in cache.
4793
- *
4794
- * @param callback The function to call when the event was fired
4795
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4796
- *
4797
- * @category Channel Events
4798
- */
4799
4474
  const onChannelMemberRoleAdded = (callback) => {
4800
4475
  if (callbacks$2.length === 0) {
4801
4476
  const client = getActiveClient();
4802
- const onLocal = async (payload) => {
4477
+ const filter = async (payload) => {
4803
4478
  const { channels, channelUsers } = payload;
4804
4479
  callbacks$2.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
4805
4480
  };
4806
- const onRealtime = (payload) => {
4807
- const { channel, members } = applyChannelRolePayload(payload);
4808
- if (!channel)
4809
- return;
4810
- members.forEach(member => callbacks$2.forEach(cb => cb(channel, member)));
4811
- };
4812
- mainDisposers$1.push(createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', onLocal));
4813
- mainDisposers$1.push(createEventSubscriber(client, 'onChannelMemberRoleAdded', 'channel.roleAdded', onRealtime));
4481
+ mainDisposer$2 = createEventSubscriber(client, 'onChannelMemberRoleAdded', 'local.channel-moderator.role-added', filter);
4814
4482
  }
4815
4483
  callbacks$2.push(callback);
4816
4484
  return () => dispose$2(callback);
4817
4485
  };
4818
- /* end_public_function */
4819
4486
 
4820
4487
  const callbacks$1 = [];
4821
- const mainDisposers = [];
4488
+ let mainDisposer$1 = null;
4822
4489
  const dispose$1 = (cb) => {
4823
4490
  const index = callbacks$1.indexOf(cb);
4824
4491
  if (index > -1) {
4825
4492
  callbacks$1.splice(index, 1);
4826
4493
  }
4827
4494
  if (callbacks$1.length === 0) {
4828
- mainDisposers.forEach(fn => fn());
4829
- mainDisposers.length = 0;
4495
+ mainDisposer$1 === null || mainDisposer$1 === void 0 ? void 0 : mainDisposer$1();
4830
4496
  }
4831
4497
  };
4832
- /* begin_public_function
4833
- id: channel.event.member_role_removed
4834
- */
4835
- /**
4836
- * ```js
4837
- * import { onChannelMemberRoleRemoved } from '@amityco/ts-sdk'
4838
- * const dispose = onChannelMemberRoleRemoved((channel, member) => {
4839
- * // member.roles and member.permissions are the member's resulting state
4840
- * })
4841
- * ```
4842
- *
4843
- * Fired when a role is removed from a member of a {@link Amity.Channel}, either by the
4844
- * local `ChannelRepository.Moderation.removeRole` call or by the `channel.roleRemoved` realtime
4845
- * event coming from any client or the admin console.
4846
- *
4847
- * The realtime event reaches every subscriber of the channel topic (see `getChannelTopic`),
4848
- * not only the actor or the affected members. It carries the affected members' resulting
4849
- * channel roles and channel-scoped permissions, which are written to cache before the
4850
- * callback runs. The callback is invoked once per affected member already held in cache.
4851
- *
4852
- * @param callback The function to call when the event was fired
4853
- * @returns an {@link Amity.Unsubscriber} function to run when willing to stop listening
4854
- *
4855
- * @category Channel Events
4856
- */
4857
4498
  const onChannelMemberRoleRemoved = (callback) => {
4858
4499
  if (callbacks$1.length === 0) {
4859
4500
  const client = getActiveClient();
4860
- const onLocal = async (payload) => {
4501
+ const filter = async (payload) => {
4861
4502
  const { channels, channelUsers } = payload;
4862
4503
  callbacks$1.forEach(cb => cb(channels[0], channelUsers.find(channelUser => channelUser.membership === 'member')));
4863
4504
  };
4864
- const onRealtime = (payload) => {
4865
- const { channel, members } = applyChannelRolePayload(payload);
4866
- if (!channel)
4867
- return;
4868
- members.forEach(member => callbacks$1.forEach(cb => cb(channel, member)));
4869
- };
4870
- mainDisposers.push(createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', onLocal));
4871
- mainDisposers.push(createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'channel.roleRemoved', onRealtime));
4505
+ mainDisposer$1 = createEventSubscriber(client, 'onChannelMemberRoleRemoved', 'local.channel-moderator.role-removed', filter);
4872
4506
  }
4873
4507
  callbacks$1.push(callback);
4874
4508
  return () => dispose$1(callback);
4875
4509
  };
4876
- /* end_public_function */
4877
4510
 
4878
4511
  /**
4879
4512
  * Fired when a {@link Amity.Channel} has been archived by the active user.
@@ -4997,8 +4630,6 @@ const getMyMembership = (channelId, callback) => {
4997
4630
  disposers.push(onChannelMemberBanned(realtimeRouter));
4998
4631
  disposers.push(onChannelMemberUnbanned(realtimeRouter));
4999
4632
  disposers.push(onChannelSetUserMuted(realtimeRouter));
5000
- disposers.push(onChannelMemberRoleAdded(realtimeRouter));
5001
- disposers.push(onChannelMemberRoleRemoved(realtimeRouter));
5002
4633
  onFetch();
5003
4634
  return () => {
5004
4635
  disposers.forEach(fn => fn());
@@ -5392,9 +5023,7 @@ const initializeMessagePreviewSetting = async () => {
5392
5023
  const getSocialSettings = async () => {
5393
5024
  const client = getActiveClient();
5394
5025
  const { data } = await client.http.get(`/api/v3/network-settings/social`);
5395
- return Object.assign(Object.assign({}, data.socialNetworkSetting), {
5396
- // Networks that never set the comment edit switch allow the edit
5397
- isAllowEditCommentWhenReviewingEnabled: data.socialNetworkSetting.isAllowEditCommentWhenReviewingEnabled });
5026
+ return data.socialNetworkSetting;
5398
5027
  };
5399
5028
 
5400
5029
  /**
@@ -5512,95 +5141,6 @@ const getForYouFeedSetting = async () => {
5512
5141
  };
5513
5142
  /* end_public_function */
5514
5143
 
5515
- const ENFORCEMENT_MODES = ['off', 'shadow', 'enforce'];
5516
- /**
5517
- * An unrecognised mode decodes to `off`, and so does an absent one. A mode
5518
- * this build does not know must not withhold anything — defaulting to
5519
- * `enforce` would let a server-side rename black out a customer's app.
5520
- *
5521
- * @category private
5522
- */
5523
- const parseEnforcement = (mode) => {
5524
- const match = ENFORCEMENT_MODES.find(value => value === mode);
5525
- return match !== null && match !== void 0 ? match : 'off';
5526
- };
5527
- const parseGrants = (modules) => {
5528
- const grants = {};
5529
- Object.entries(modules !== null && modules !== void 0 ? modules : {}).forEach(([key, granted]) => {
5530
- grants[key] = granted === true;
5531
- });
5532
- return grants;
5533
- };
5534
- /**
5535
- * Every catalog entry survives, including one whose key this build has never
5536
- * heard of, so a module added server-side is still listable.
5537
- *
5538
- * @category private
5539
- */
5540
- const parseCatalog = (catalog) => {
5541
- const parsed = {};
5542
- Object.entries(catalog !== null && catalog !== void 0 ? catalog : {}).forEach(([key, definition]) => {
5543
- const rawRequires = definition === null || definition === void 0 ? void 0 : definition.requires;
5544
- const requires = Array.isArray(rawRequires)
5545
- ? rawRequires.filter((entry) => typeof entry === 'string')
5546
- : [];
5547
- parsed[key] = {
5548
- label: typeof (definition === null || definition === void 0 ? void 0 : definition.label) === 'string' ? definition.label : key,
5549
- kind: (definition === null || definition === void 0 ? void 0 : definition.kind) === 'setting' ? 'setting' : 'api',
5550
- requires,
5551
- };
5552
- });
5553
- return parsed;
5554
- };
5555
- /**
5556
- * Decodes `GET /api/v3/network-settings/modules`. Nothing is trimmed: the
5557
- * catalog is the dependency table callers resolve against, and a client that
5558
- * cannot see it has to hardcode one.
5559
- *
5560
- * @category private
5561
- */
5562
- const parseModuleSettings = (raw) => {
5563
- var _a;
5564
- return ({
5565
- enforcement: parseEnforcement((_a = raw === null || raw === void 0 ? void 0 : raw.enforcement) !== null && _a !== void 0 ? _a : raw === null || raw === void 0 ? void 0 : raw.mode),
5566
- modules: parseGrants(raw === null || raw === void 0 ? void 0 : raw.modules),
5567
- catalog: parseCatalog(raw === null || raw === void 0 ? void 0 : raw.catalog),
5568
- });
5569
- };
5570
-
5571
- /* begin_public_function
5572
- id: client.getModuleSettings
5573
- */
5574
- /**
5575
- * ```js
5576
- * import { Client } from '@amityco/ts-sdk'
5577
- * const moduleSettings = await Client.getModuleSettings()
5578
- * ```
5579
- *
5580
- * Fetches the network's module entitlements: which modules the network was
5581
- * granted, whether core is enforcing those grants, and the catalog of all
5582
- * modules with their dependency chains.
5583
- *
5584
- * The payload is returned whole — `catalog` is the dependency table
5585
- * {@link resolveModuleAvailability} reads, and a client that cannot see it has
5586
- * to hardcode one.
5587
- *
5588
- * The read is **advisory**. It tells a host what to offer; under `enforce` the
5589
- * backend refuses a call to an unowned module regardless of what was resolved
5590
- * here, and that refusal arrives as `AmityModuleNotEntitledError`.
5591
- *
5592
- * @returns A Promise of {@link Amity.ModuleSettings} object
5593
- *
5594
- * @category Client API
5595
- * @async
5596
- */
5597
- const getModuleSettings = async () => {
5598
- const client = getActiveClient();
5599
- const { data } = await client.http.get(`/api/v3/network-settings/modules`);
5600
- return parseModuleSettings(data);
5601
- };
5602
- /* end_public_function */
5603
-
5604
5144
  const checkUserPermission = (userId, permission) => {
5605
5145
  var _a;
5606
5146
  const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -6169,32 +5709,6 @@ class AnalyticsEventCapturer {
6169
5709
  activityType: "view" /* Amity.AnalyticEventActivityType.View */,
6170
5710
  });
6171
5711
  }
6172
- markCuratedContentWidgetAsViewed(topicId) {
6173
- this.markAs({
6174
- uniqueId: `curatedContentWidget.${topicId}`,
6175
- contentId: topicId,
6176
- contentType: "curated_content_widget" /* Amity.AnalyticEventContentType.CuratedContentWidget */,
6177
- activityType: "view" /* Amity.AnalyticEventActivityType.View */,
6178
- });
6179
- }
6180
- markCuratedContentPostAsViewed(postId, topicId) {
6181
- this.markAs({
6182
- uniqueId: `curatedContentPost.${postId}.view`,
6183
- contentId: postId,
6184
- contentType: "curated_content_post" /* Amity.AnalyticEventContentType.CuratedContentPost */,
6185
- activityType: "view" /* Amity.AnalyticEventActivityType.View */,
6186
- metadata: { topicId },
6187
- });
6188
- }
6189
- markCuratedContentPostAsClicked(postId, topicId) {
6190
- this.markAs({
6191
- uniqueId: `curatedContentPost.${postId}.click`,
6192
- contentId: postId,
6193
- contentType: "curated_content_post" /* Amity.AnalyticEventContentType.CuratedContentPost */,
6194
- activityType: "linkClicked" /* Amity.AnalyticEventActivityType.Click */,
6195
- metadata: { topicId },
6196
- });
6197
- }
6198
5712
  markPostAsMeaningfullyViewed(postId, feedRenderPosition) {
6199
5713
  var _a;
6200
5714
  const cached = (_a = pullFromCache(['feedMetadata', 'get', postId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -6358,24 +5872,6 @@ class AnalyticsEngine {
6358
5872
  this._eventCapturer.markPostAsViewed(postId);
6359
5873
  }
6360
5874
  }
6361
- markCuratedContentWidgetAsViewed(topicId) {
6362
- if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
6363
- this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
6364
- this._eventCapturer.markCuratedContentWidgetAsViewed(topicId);
6365
- }
6366
- }
6367
- markCuratedContentPostAsViewed(postId, topicId) {
6368
- if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
6369
- this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
6370
- this._eventCapturer.markCuratedContentPostAsViewed(postId, topicId);
6371
- }
6372
- }
6373
- markCuratedContentPostAsClicked(postId, topicId) {
6374
- if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
6375
- this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
6376
- this._eventCapturer.markCuratedContentPostAsClicked(postId, topicId);
6377
- }
6378
- }
6379
5875
  markPostAsMeaningfullyViewed(postId, feedRenderPosition) {
6380
5876
  if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
6381
5877
  this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
@@ -7772,265 +7268,6 @@ class CursorController {
7772
7268
  }
7773
7269
  }
7774
7270
 
7775
- class ResetTask {
7776
- constructor(postId, latestCreatedAt, serverCommentCount) {
7777
- this.postId = postId;
7778
- this.latestCreatedAt = latestCreatedAt;
7779
- this.serverCommentCount = serverCommentCount;
7780
- }
7781
- }
7782
-
7783
- // Task to track comment creation
7784
- class CreateTask {
7785
- constructor(postId, commentId, createdAt) {
7786
- this.postId = postId;
7787
- this.commentId = commentId;
7788
- this.createdAt = createdAt;
7789
- }
7790
- }
7791
-
7792
- /**
7793
- * A pending comment was approved and now counts publicly. Unlike `CreateTask` it carries no
7794
- * `createdAt` and bypasses the age guard on purpose: the comment was written before the last post
7795
- * payload (so its `createdAt` is old) but entered the server count only now. Same rule as iOS.
7796
- *
7797
- * Accepted trade-off (plan 40 §9): if a `ResetTask` that already includes this comment lands
7798
- * between the approve response and the late `comment.approved` event, the count reads +1 until
7799
- * the next server sync — the same self-correcting drift accepted for stale deletes.
7800
- */
7801
- class ApproveTask {
7802
- constructor(postId, commentId) {
7803
- this.postId = postId;
7804
- this.commentId = commentId;
7805
- }
7806
- }
7807
-
7808
- // Task to track comment deletion
7809
- class DeleteTask {
7810
- constructor(postId, commentId) {
7811
- this.postId = postId;
7812
- this.commentId = commentId;
7813
- }
7814
- }
7815
-
7816
- class CommentChange {
7817
- constructor(latestCreatedAt, serverCommentCount) {
7818
- this.latestCommentCreatedAt = latestCreatedAt;
7819
- this.serverCommentCount = serverCommentCount;
7820
- this.createdCommentIds = new Set();
7821
- this.deletedCommentIds = new Set();
7822
- }
7823
- }
7824
-
7825
- class PostCommentCountEngine {
7826
- constructor() {
7827
- this.isProcessing = false;
7828
- this.tasks = [];
7829
- this.commentChangeTracker = new Map();
7830
- // Ids of the LOGGED-IN USER's own pending comments, per post. Survives ResetTask, so the
7831
- // author's +1 does not vanish on the next post refresh; emptied only when the comment leaves
7832
- // the pending state (approval hands it to createdCommentIds, decline/delete drops it).
7833
- this.pendingAuthoredCommentIds = new Map();
7834
- }
7835
- queueCommentChangeTask(task) {
7836
- this.tasks.push(task);
7837
- if (!this.isProcessing) {
7838
- this.processCommentChangeTask();
7839
- }
7840
- }
7841
- addPendingAuthoredComment(postId, commentId, { publish = true } = {}) {
7842
- var _a;
7843
- const ids = (_a = this.pendingAuthoredCommentIds.get(postId)) !== null && _a !== void 0 ? _a : new Set();
7844
- if (ids.has(commentId))
7845
- return;
7846
- ids.add(commentId);
7847
- this.pendingAuthoredCommentIds.set(postId, ids);
7848
- if (publish)
7849
- this.publishIfTracked(postId);
7850
- }
7851
- removePendingAuthoredComment(postId, commentId, { publish = true } = {}) {
7852
- const ids = this.pendingAuthoredCommentIds.get(postId);
7853
- if (!(ids === null || ids === void 0 ? void 0 : ids.delete(commentId)))
7854
- return false;
7855
- if (ids.size === 0)
7856
- this.pendingAuthoredCommentIds.delete(postId);
7857
- if (publish)
7858
- this.publishIfTracked(postId);
7859
- return true;
7860
- }
7861
- /** Whether a post payload has seeded this post; without one every count is `0`. */
7862
- hasTracker(postId) {
7863
- return this.commentChangeTracker.has(postId);
7864
- }
7865
- isPendingAuthoredComment(postId, commentId) {
7866
- var _a, _b;
7867
- return (_b = (_a = this.pendingAuthoredCommentIds.get(postId)) === null || _a === void 0 ? void 0 : _a.has(commentId)) !== null && _b !== void 0 ? _b : false;
7868
- }
7869
- // Drops every per-post state. Called on logout / user switch.
7870
- reset() {
7871
- this.tasks = [];
7872
- this.commentChangeTracker.clear();
7873
- this.pendingAuthoredCommentIds.clear();
7874
- }
7875
- publishIfTracked(postId) {
7876
- // Without a tracker there is no server figure to add to; the next ResetTask picks it up.
7877
- if (!this.commentChangeTracker.has(postId))
7878
- return;
7879
- PostCommentCountEngine.publishUpdate(postId, this.getLocalCommentCount(postId, true));
7880
- }
7881
- processCommentChangeTask() {
7882
- if (this.isProcessing) {
7883
- return;
7884
- }
7885
- this.isProcessing = true;
7886
- if (this.tasks.length === 0) {
7887
- this.isProcessing = false;
7888
- return;
7889
- }
7890
- // Process in capped batches, coalescing updates
7891
- const batch = this.tasks.splice(0, PostCommentCountEngine.BATCH_SIZE);
7892
- const modifiedPostIds = new Set();
7893
- batch.forEach(task => {
7894
- let modified = false;
7895
- if (task instanceof ResetTask) {
7896
- modified = this.processResetTaskInternal(task);
7897
- }
7898
- else if (task instanceof CreateTask) {
7899
- modified = this.processCreateTaskInternal(task);
7900
- }
7901
- else if (task instanceof ApproveTask) {
7902
- modified = this.processApproveTaskInternal(task);
7903
- }
7904
- else if (task instanceof DeleteTask) {
7905
- modified = this.processDeleteTaskInternal(task);
7906
- }
7907
- if (modified) {
7908
- modifiedPostIds.add(task.postId);
7909
- }
7910
- });
7911
- // Publish one update per modified post
7912
- modifiedPostIds.forEach(postId => {
7913
- PostCommentCountEngine.publishUpdate(postId, this.getLocalCommentCount(postId, true));
7914
- });
7915
- this.isProcessing = false;
7916
- // Recurse if more tasks remain
7917
- if (this.tasks.length > 0) {
7918
- this.processCommentChangeTask();
7919
- }
7920
- }
7921
- processResetTaskInternal(task) {
7922
- // Always creates/overwrites tracker
7923
- this.commentChangeTracker.set(task.postId, new CommentChange(task.latestCreatedAt, task.serverCommentCount));
7924
- return true;
7925
- }
7926
- processCreateTaskInternal(task) {
7927
- // The comment is public now: the author-local +1 hands over to the normal path, so the
7928
- // count stays put instead of moving twice.
7929
- const wasPendingAuthored = this.removePendingAuthoredComment(task.postId, task.commentId, {
7930
- publish: false,
7931
- });
7932
- const tracker = this.commentChangeTracker.get(task.postId);
7933
- if (!tracker)
7934
- return false; // No tracker, skip
7935
- if (tracker.deletedCommentIds.delete(task.commentId))
7936
- return true; // Re-approval cancels the earlier removal
7937
- if (tracker.createdCommentIds.has(task.commentId))
7938
- return wasPendingAuthored; // Deduplication
7939
- if (task.createdAt <= tracker.latestCommentCreatedAt)
7940
- return wasPendingAuthored; // Timestamp filtering
7941
- tracker.createdCommentIds.add(task.commentId);
7942
- return true;
7943
- }
7944
- processApproveTaskInternal(task) {
7945
- // The comment is public now: the author-local +1 hands over to the normal path, so the
7946
- // count stays put instead of moving twice.
7947
- const wasPendingAuthored = this.removePendingAuthoredComment(task.postId, task.commentId, {
7948
- publish: false,
7949
- });
7950
- const tracker = this.commentChangeTracker.get(task.postId);
7951
- if (!tracker)
7952
- return false; // No tracker, skip
7953
- if (tracker.deletedCommentIds.delete(task.commentId))
7954
- return true; // Re-approval cancels the earlier re-review removal
7955
- if (tracker.createdCommentIds.has(task.commentId))
7956
- return wasPendingAuthored; // Approve response and comment.approved event dedupe by id
7957
- // No timestamp filtering: approval is the moment the comment enters the count, not createdAt
7958
- tracker.createdCommentIds.add(task.commentId);
7959
- return true;
7960
- }
7961
- processDeleteTaskInternal(task) {
7962
- const tracker = this.commentChangeTracker.get(task.postId);
7963
- if (!tracker)
7964
- return false; // No tracker, skip
7965
- if (tracker.deletedCommentIds.has(task.commentId))
7966
- return false; // Deduplication
7967
- tracker.deletedCommentIds.add(task.commentId);
7968
- return true;
7969
- }
7970
- /**
7971
- * The count as this session sees it: the last server figure plus the local delta.
7972
- *
7973
- * `includePending` adds the logged-in user's own pending comments — the author's view. A
7974
- * pending id is added only while the public delta does not already count it, so a comment
7975
- * present in both sets counts once: a `comment.created` that arrives pending after the
7976
- * `comment.approved` hand-over adds nothing, while an approved comment sent back to review
7977
- * (created, deleted and pending all hold its id) keeps the author's +1.
7978
- *
7979
- * `0` for a post no payload has seeded yet; callers fall back to the post's own figure.
7980
- */
7981
- getLocalCommentCount(postId, includePending = false) {
7982
- var _a;
7983
- const tracker = this.commentChangeTracker.get(postId);
7984
- if (!tracker)
7985
- return 0;
7986
- const publicDelta = tracker.createdCommentIds.size - tracker.deletedCommentIds.size;
7987
- if (!includePending)
7988
- return Math.max(0, tracker.serverCommentCount + publicDelta);
7989
- let pendingExtra = 0;
7990
- (_a = this.pendingAuthoredCommentIds.get(postId)) === null || _a === void 0 ? void 0 : _a.forEach(commentId => {
7991
- const countedPublicly = tracker.createdCommentIds.has(commentId) && !tracker.deletedCommentIds.has(commentId);
7992
- if (!countedPublicly)
7993
- pendingExtra += 1;
7994
- });
7995
- return Math.max(0, tracker.serverCommentCount + publicDelta + pendingExtra);
7996
- }
7997
- static publishUpdate(postId, newCount) {
7998
- var _a;
7999
- const queryKey = ['post', 'get', postId];
8000
- mergeInCache(queryKey, {
8001
- localCommentCount: newCount,
8002
- });
8003
- const postPayload = (_a = pullFromCache(queryKey)) === null || _a === void 0 ? void 0 : _a.data;
8004
- if (!postPayload)
8005
- return;
8006
- fireEvent('local.post.updated', {
8007
- posts: [postPayload],
8008
- });
8009
- }
8010
- }
8011
- PostCommentCountEngine.BATCH_SIZE = 50;
8012
- let instance$1;
8013
- var PostCommentCountEngine$1 = {
8014
- getInstance: () => {
8015
- if (!instance$1) {
8016
- instance$1 = new PostCommentCountEngine();
8017
- }
8018
- return instance$1;
8019
- },
8020
- };
8021
-
8022
- /**
8023
- * Comment-count state is per user — in particular the ids of the logged-in user's own pending
8024
- * comments — so it must not survive a logout or a user switch.
8025
- *
8026
- * @category private
8027
- */
8028
- const postCommentCountEngineOnLoginHandler = () => onSessionStateChange(state => {
8029
- if (state === "notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */ || state === "terminated" /* Amity.SessionStates.TERMINATED */) {
8030
- PostCommentCountEngine$1.getInstance().reset();
8031
- }
8032
- });
8033
-
8034
7271
  const EVENTS = [
8035
7272
  'disconnected',
8036
7273
  'error',
@@ -8220,7 +7457,7 @@ const setupLoginSubscriptions = (unsubWatcher) => {
8220
7457
  // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
8221
7458
  // the channel because currently backend can't handle this, so every time a user is banned from
8222
7459
  // a channel or the channel is deleted the channel's unread count will not be reset to zero
8223
- onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout(), postCommentCountEngineOnLoginHandler());
7460
+ onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler(), reactionSyncEngineOnLoginHandler(), blockedUserSyncEngineOnLoginHandler(), blockingUserSyncEngineOnLoginHandler(), blockRealtimeOnLoginHandler(), resetAutoSubscriptionsOnLogout(), CursorController.clearOnLogout());
8224
7461
  if (client.useLegacyUnreadCount) {
8225
7462
  subscriptions.push(readReceiptSyncEngineOnLoginHandler());
8226
7463
  }
@@ -9256,7 +8493,7 @@ const DEFAULT_DEBUG_SESSION = 'amity';
9256
8493
  *
9257
8494
  * @category Client API
9258
8495
  * */
9259
- const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, rteEnabled = true, product, uikitVersion, appId, appVersion, } = {}) => {
8496
+ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAULT_DEBUG_SESSION, apiEndpoint, prefixDeviceIdKey, rteEnabled = true, } = {}) => {
9260
8497
  var _a, _b, _c;
9261
8498
  const log = createLogger(debugSession);
9262
8499
  log('client/api/createClient', {
@@ -9285,10 +8522,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
9285
8522
  const useLegacyUnreadCount = true;
9286
8523
  const client = {
9287
8524
  version: `${VERSION}`,
9288
- product,
9289
- uikitVersion,
9290
- appId,
9291
- appVersion,
9292
8525
  apiKey,
9293
8526
  /*
9294
8527
  * SDK Components
@@ -9325,7 +8558,6 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
9325
8558
  getMarkerSyncConsistentMode,
9326
8559
  getProductCatalogueSetting,
9327
8560
  getForYouFeedSetting,
9328
- getModuleSettings,
9329
8561
  /**
9330
8562
  * Prefix for the deviceId key in the local storage or async storage.
9331
8563
  * This is allow user to have multiple SDK client and Mqtt client within the same app.
@@ -9528,13 +8760,13 @@ class GlobalFileAccessType {
9528
8760
  }
9529
8761
  }
9530
8762
  _GlobalFileAccessType_fileAccessType = new WeakMap();
9531
- let instance;
8763
+ let instance$1;
9532
8764
  var GlobalFileAccessType$1 = {
9533
8765
  getInstance: () => {
9534
- if (!instance) {
9535
- instance = new GlobalFileAccessType();
8766
+ if (!instance$1) {
8767
+ instance$1 = new GlobalFileAccessType();
9536
8768
  }
9537
- return instance;
8769
+ return instance$1;
9538
8770
  },
9539
8771
  };
9540
8772
 
@@ -10371,93 +9603,7 @@ const getUserUnread = (callback) => {
10371
9603
  };
10372
9604
  };
10373
9605
 
10374
- /**
10375
- * ```js
10376
- * import { Client, resolveModuleAvailability } from '@amityco/ts-sdk'
10377
- *
10378
- * const moduleSettings = await Client.getModuleSettings()
10379
- *
10380
- * if (resolveModuleAvailability(moduleSettings, 'live').isAvailable) {
10381
- * // offer the Live entry point
10382
- * }
10383
- * ```
10384
- *
10385
- * Resolves whether one module is usable on this network.
10386
- *
10387
- * Availability is a function of all three fields of
10388
- * {@link Amity.ModuleSettings} — the enforcement mode, the module's own grant,
10389
- * and its prerequisite chain — combined in that order. Reading `modules`
10390
- * directly contradicts the mode: staging answers `mode: 'off'` with
10391
- * `modules: {}`, and every module still works.
10392
- *
10393
- * The dependency table comes from the payload's `catalog`, never from a
10394
- * hardcoded copy, so a chain the backend changes takes effect without an SDK
10395
- * release.
10396
- *
10397
- * The SDK does not hold the settings — the caller keeps what it fetched and
10398
- * resolves against it. With no settings at all (a fetch that never succeeded)
10399
- * the caller reads that as every module available: under `enforce` the backend
10400
- * refuses the calls anyway, so the exposure is a screen that offers too much,
10401
- * not one that withholds what a customer paid for.
10402
- *
10403
- * @param moduleSettings The network's module settings
10404
- * @param moduleKey The module to resolve — an {@link Amity.ModuleKey}, so the
10405
- * 15 keys this build knows complete and type-check while a catalog entry it
10406
- * does not know still resolves.
10407
- * @returns An {@link Amity.ModuleAvailability} answer
10408
- *
10409
- * @category Client API
10410
- */
10411
- const resolveModuleAvailability = (moduleSettings, moduleKey, seen = new Set()) => {
10412
- var _a, _b, _c, _d, _e;
10413
- const isGranted = (_a = moduleSettings.modules[moduleKey]) !== null && _a !== void 0 ? _a : false;
10414
- /*
10415
- * Not enforcing: nothing is withheld, and no graph walk is needed. This has
10416
- * to come first — `off` and `shadow` resolve available whatever the grant
10417
- * says, and a cycle would otherwise return unavailable under `off` too.
10418
- */
10419
- if (moduleSettings.enforcement !== 'enforce') {
10420
- return { moduleKey, isAvailable: true, isGranted };
10421
- }
10422
- // A cycle in `requires` resolves unavailable rather than recursing.
10423
- if (seen.has(moduleKey)) {
10424
- return {
10425
- moduleKey,
10426
- isAvailable: false,
10427
- isGranted,
10428
- reason: 'prerequisiteUnavailable',
10429
- unsatisfied: (_c = (_b = moduleSettings.catalog[moduleKey]) === null || _b === void 0 ? void 0 : _b.requires) !== null && _c !== void 0 ? _c : [],
10430
- };
10431
- }
10432
- // The module's own grant is evaluated before its prerequisites, so
10433
- // `notGranted` is reported in preference when both hold.
10434
- if (!isGranted) {
10435
- return { moduleKey, isAvailable: false, isGranted, reason: 'notGranted' };
10436
- }
10437
- const requires = (_e = (_d = moduleSettings.catalog[moduleKey]) === null || _d === void 0 ? void 0 : _d.requires) !== null && _e !== void 0 ? _e : [];
10438
- if (requires.length === 0)
10439
- return { moduleKey, isAvailable: true, isGranted };
10440
- // `requires` is satisfied by any one entry, transitively.
10441
- const isSatisfied = requires.some(dependency => resolveModuleAvailability(moduleSettings, dependency, new Set([...seen, moduleKey]))
10442
- .isAvailable);
10443
- if (isSatisfied)
10444
- return { moduleKey, isAvailable: true, isGranted };
10445
- /*
10446
- * `unsatisfied` carries the whole `requires` list rather than one entry. Any
10447
- * one of them would have satisfied the requirement, so naming a single
10448
- * module misdirects: telling a Community-only customer "Comment needs post"
10449
- * hides that Story would also have done.
10450
- */
10451
- return {
10452
- moduleKey,
10453
- isAvailable: false,
10454
- isGranted,
10455
- reason: 'prerequisiteUnavailable',
10456
- unsatisfied: requires,
10457
- };
10458
- };
10459
-
10460
- var index$t = /*#__PURE__*/Object.freeze({
9606
+ var index$s = /*#__PURE__*/Object.freeze({
10461
9607
  __proto__: null,
10462
9608
  getActiveClient: getActiveClient,
10463
9609
  getActiveUser: getActiveUser,
@@ -10480,7 +9626,6 @@ var index$t = /*#__PURE__*/Object.freeze({
10480
9626
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10481
9627
  getProductCatalogueSetting: getProductCatalogueSetting,
10482
9628
  getForYouFeedSetting: getForYouFeedSetting,
10483
- getModuleSettings: getModuleSettings,
10484
9629
  loginAsVisitor: loginAsVisitor,
10485
9630
  loginAsBot: loginAsBot,
10486
9631
  getCurrentUser: getCurrentUser,
@@ -10508,8 +9653,7 @@ var index$t = /*#__PURE__*/Object.freeze({
10508
9653
  startMarkerSync: startMarkerSync,
10509
9654
  startUnreadSync: startUnreadSync,
10510
9655
  stopUnreadSync: stopUnreadSync,
10511
- getMarkerSyncConsistentMode: getMarkerSyncConsistentMode,
10512
- resolveModuleAvailability: resolveModuleAvailability
9656
+ getMarkerSyncConsistentMode: getMarkerSyncConsistentMode
10513
9657
  });
10514
9658
 
10515
9659
  /* begin_public_function
@@ -11685,7 +10829,7 @@ const getMyFollowInfo = (callback) => {
11685
10829
  };
11686
10830
  /* end_public_function */
11687
10831
 
11688
- var index$s = /*#__PURE__*/Object.freeze({
10832
+ var index$r = /*#__PURE__*/Object.freeze({
11689
10833
  __proto__: null,
11690
10834
  blockUser: blockUser,
11691
10835
  unBlockUser: unBlockUser,
@@ -13197,32 +12341,8 @@ const streamLinkedObject = (stream) => {
13197
12341
  } });
13198
12342
  };
13199
12343
 
13200
- const KNOWN_APPROVAL_STATUSES = [
13201
- "pending" /* Amity.CommentApprovalStatusEnum.Pending */,
13202
- "approved" /* Amity.CommentApprovalStatusEnum.Approved */,
13203
- "rejected" /* Amity.CommentApprovalStatusEnum.Rejected */,
13204
- ];
13205
- /**
13206
- * The server sends `approvalStatus` only while a comment is held for review or after it was
13207
- * rejected. Absent, `null`, or an unrecognised value all resolve to `approved` — never to
13208
- * `pending`, which would mark every comment written before the feature as unpublished.
13209
- */
13210
- const resolveCommentApprovalStatus = (approvalStatus) => {
13211
- if (approvalStatus && KNOWN_APPROVAL_STATUSES.includes(approvalStatus)) {
13212
- return approvalStatus;
13213
- }
13214
- return "approved" /* Amity.CommentApprovalStatusEnum.Approved */;
13215
- };
13216
- const prepareComment = (comment) => (Object.assign(Object.assign(Object.assign({}, (comment.hasOwnProperty('myReactions') ? {} : { myReactions: [] })), comment), { approvalStatus: resolveCommentApprovalStatus(comment.approvalStatus) }));
13217
- function prepareCommentPayload(commentPayload) {
13218
- const { comments, commentChildren } = commentPayload;
13219
- return Object.assign(Object.assign(Object.assign({}, commentPayload), { comments: comments.map(prepareComment) }), (commentChildren ? { commentChildren: commentChildren.map(prepareComment) } : {}));
13220
- }
13221
-
13222
12344
  const commentLinkedObject = (comment) => {
13223
- return Object.assign(Object.assign({}, comment), {
13224
- // Non-optional on the public model: absent on the wire means approved
13225
- approvalStatus: resolveCommentApprovalStatus(comment.approvalStatus), get target() {
12345
+ return Object.assign(Object.assign({}, comment), { get target() {
13226
12346
  const commentTypes = {
13227
12347
  type: comment.targetType,
13228
12348
  };
@@ -13430,7 +12550,7 @@ const getWatchSessionStorage = () => {
13430
12550
  return storageInstance;
13431
12551
  };
13432
12552
 
13433
- const privateKey = "MIIEpQIBAAKCAQEAwAEc/oZgYIvKSUG/C3mONYLR4ZPgAjMEX4bJ+xqqakUDRtqlNO+eZs2blQ1Ko0DBkqPExyQezvjibH5W2UZBV5RaBTlTcNVKTToMBEGesAfaEcM3qUyQHxdbFYZv6P4sb14dcwxTQ8usmaV8ooiR1Fcaso5ZWYcZ8Hb46FbQ7OoVumsBtPWwfZ4f003o5VCl6AIM6lcLv9UDLlFVYhE+PeXpRHtfWlGqxMvqC9oinlwhL6nWv6VjQXW4nhcib72dPBzfHT7k/PMKto2SxALYdb68ENiAGuJLWi3AUHSyYCJK2w7wIlWfJUAI0v26ub10IpExr6D5QuW2577jjP93iwIDAQABAoIBAFWfqXhwIIatkFY+9Z1+ZcbDQimgsmMIsUiQaX6Lk7e0cxOj6czDlxYtVtaPiNtow2pLkjNkjkCqiP7tEHnwdK9DvylZOTa2R15NJpK3WLcTqVIGhsn/FL5owfvFah6zSsmXZParZm5zY9NZE03ALZhOB9/cz0e3kf/EbpfeL2mW7MApyiUt5i09ycchroOpcWp73ipIxvgigtZyUGFmsQicWhUs28F0D7w4Qfk76yG3nqXeb+BAMhCaIaa/k/aAxhiZG/ygEQWQrcC8gfe+jyicMAQPDEVS9YuUMGsLjIjKuVLZzp2xirQnhc2i2zVNEIvG6soprPOBEMQugzrtX5ECgYEA3b7KAbBIbDl1e4ZSCWhHdHkiWVZHaopsR/LhqDDNhXjWjq3AesgV6k0j9EdziMn/HmmOso0bz99GTV3JZf4A9ztTLumJlkHbdVtlgOqSjrFLj12rH9KXTheyIhWSpUmm8+WB1xasFbqpvJaGo7F3pd2Fqj1XR4mp5BO7c/t7LJ0CgYEA3aouEzXQ9THRKYocdfY69EI1Il1t/d/RSqqd9BxEjxBgxkM13ZiYIn/R4WW/nCUrlmhxG44Aa2Gob4Ahfsui2xKTg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
12553
+ 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-----";
13434
12554
  /*
13435
12555
  * The crypto algorithm used for importing key and signing string
13436
12556
  */
@@ -13873,122 +12993,6 @@ const fileLinkedObject = (file) => {
13873
12993
  return file;
13874
12994
  };
13875
12995
 
13876
- const isCommentPending = (comment) => resolveCommentApprovalStatus(comment.approvalStatus) === "pending" /* Amity.CommentApprovalStatusEnum.Pending */;
13877
- const isCommentApproved = (comment) => resolveCommentApprovalStatus(comment.approvalStatus) === "approved" /* Amity.CommentApprovalStatusEnum.Approved */;
13878
- // Only post and content references feed PostCommentCountEngine; story counts live on the story.
13879
- const isCountedReference = (comment) => ['post', 'content'].includes(comment.referenceType);
13880
- const isAuthoredByCurrentUser = (comment) => comment.userId === getActiveClient().userId;
13881
- /**
13882
- * Whether a comment on this reference would be held for review, read from the cached post's
13883
- * community. `true` when that cannot be known — the post or its community is not cached yet.
13884
- * A pending guess that turns out approved is corrected by the response and the comment then
13885
- * enters the list; an approved guess that turns out pending has already been shown in a public
13886
- * list with nothing to take it back out. Only shapes the optimistic object — the server
13887
- * response is the authority on the actual status.
13888
- */
13889
- const isCommentApprovalRequired = (bundle) => {
13890
- var _a, _b;
13891
- // Only comments on community posts are gated; every other reference is known-off
13892
- if (bundle.referenceType !== 'post')
13893
- return false;
13894
- const post = (_a = pullFromCache(['post', 'get', bundle.referenceId])) === null || _a === void 0 ? void 0 : _a.data;
13895
- if (!post)
13896
- return true;
13897
- // A user-feed post is known-off
13898
- if (post.targetType !== 'community')
13899
- return false;
13900
- const community = (_b = pullFromCache([
13901
- 'community',
13902
- 'get',
13903
- post.targetId,
13904
- ])) === null || _b === void 0 ? void 0 : _b.data;
13905
- if (!community)
13906
- return true;
13907
- return community.needApprovalOnCommentCreation === true;
13908
- };
13909
- /**
13910
- * An approved comment arrived over realtime: one `CreateTask` carrying its own `createdAt`, so
13911
- * the timestamp filter skips anything the last post payload already counted. The author's own
13912
- * comment reaches here as an echo too; the engine de-duplicates it by id against the task the
13913
- * create response queued.
13914
- */
13915
- const applyCommentCreatedCount = (comment) => {
13916
- if (!isCountedReference(comment))
13917
- return;
13918
- PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new CreateTask(comment.referenceId, comment.commentId, comment.createdAt));
13919
- };
13920
- /**
13921
- * The author's own pending comment counts in their view only. Recorded as separate engine state
13922
- * so it survives a post refresh (`ResetTask`).
13923
- */
13924
- const recordPendingAuthoredComment = (comment, options) => {
13925
- if (!isCountedReference(comment) || !isAuthoredByCurrentUser(comment))
13926
- return;
13927
- PostCommentCountEngine$1.getInstance().addPendingAuthoredComment(comment.referenceId, comment.commentId, options);
13928
- };
13929
- /**
13930
- * A pending comment was declined or deleted: it was never in the server count, so no
13931
- * `DeleteTask` — only the author-local +1 goes away.
13932
- */
13933
- const releasePendingAuthoredComment = (comment) => {
13934
- if (!isCountedReference(comment))
13935
- return;
13936
- PostCommentCountEngine$1.getInstance().removePendingAuthoredComment(comment.referenceId, comment.commentId);
13937
- };
13938
- /**
13939
- * Reveal: exactly one `ApproveTask`. The engine de-duplicates by comment id, so the approve
13940
- * response and the `comment.approved` event may both call this. `ApproveTask` bypasses the age
13941
- * guard on purpose — the comment was written before the last server sync but enters the public
13942
- * count now — matching the iOS `ApproveTask` (plan 40 §9, guard off for approve).
13943
- */
13944
- const applyCommentApprovedCount = (comment) => {
13945
- if (!isCountedReference(comment))
13946
- return;
13947
- PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new ApproveTask(comment.referenceId, comment.commentId));
13948
- };
13949
- /**
13950
- * Re-review: an approved comment edited back to pending leaves the public count once. The
13951
- * author keeps their own +1 through the pending set, so their count does not move.
13952
- */
13953
- const applyCommentReReviewCount = (comment) => {
13954
- if (!isCountedReference(comment))
13955
- return;
13956
- recordPendingAuthoredComment(comment, { publish: false });
13957
- PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new DeleteTask(comment.referenceId, comment.commentId));
13958
- };
13959
- /** Adds a reply to its cached parent's `children` (and count) once. */
13960
- const linkCommentToParent = (comment) => {
13961
- var _a;
13962
- if (!comment.parentId)
13963
- return;
13964
- const parentKey = ['comment', 'get', comment.parentId];
13965
- const parent = (_a = pullFromCache(parentKey)) === null || _a === void 0 ? void 0 : _a.data;
13966
- if (!parent || parent.children.includes(comment.commentId))
13967
- return;
13968
- pushToCache(parentKey, Object.assign(Object.assign({}, parent), { childrenNumber: parent.childrenNumber + 1, children: [...new Set([...parent.children, comment.commentId])] }));
13969
- };
13970
- /** Removes a reply from its cached parent's `children` (and count) once. */
13971
- const unlinkCommentFromParent = (comment) => {
13972
- var _a;
13973
- if (!comment.parentId)
13974
- return;
13975
- const parentKey = ['comment', 'get', comment.parentId];
13976
- const parent = (_a = pullFromCache(parentKey)) === null || _a === void 0 ? void 0 : _a.data;
13977
- if (!parent || !parent.children.includes(comment.commentId))
13978
- return;
13979
- pushToCache(parentKey, Object.assign(Object.assign({}, parent), { childrenNumber: parent.childrenNumber - 1, children: parent.children.filter(id => id !== comment.commentId) }));
13980
- };
13981
-
13982
- /**
13983
- * The server's list is oldest → newest, so the newest ids are the last ones. Kept unique so the
13984
- * create response, the local event and the realtime echo cannot each add the same comment.
13985
- */
13986
- const capLatestCommentIds = (commentIds) => [...new Set(commentIds)].slice(-LATEST_COMMENTS_LIMIT);
13987
- /** A comment belongs in the post preview only while it is cached, not deleted and public. */
13988
- const isPreviewableComment = (comment) => comment !== undefined && !comment.isDeleted && isCommentApproved(comment);
13989
- /** The post's preview list after one of the user's own top-level comments is created. */
13990
- const appendLatestCommentId = (post, commentId) => { var _a; return capLatestCommentIds([...((_a = post.comments) !== null && _a !== void 0 ? _a : []), commentId]); };
13991
-
13992
12996
  const postLinkedObject = (post) => {
13993
12997
  return shallowClone(post, {
13994
12998
  childrenPosts: post.children
@@ -14012,13 +13016,19 @@ const postLinkedObject = (post) => {
14012
13016
  get latestComments() {
14013
13017
  if (!post.comments)
14014
13018
  return [];
14015
- // Same rule as the server's own list and as iOS: deleted and non-public comments are
14016
- // dropped first, then the newest LATEST_COMMENTS_LIMIT remain
14017
- return post.comments
14018
- .map(commentId => { var _a; return (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data; })
14019
- .filter(isPreviewableComment)
14020
- .slice(-LATEST_COMMENTS_LIMIT)
14021
- .map(commentLinkedObject);
13019
+ return (post.comments
13020
+ .map(commentId => {
13021
+ var _a;
13022
+ const commentCached = (_a = pullFromCache([
13023
+ 'comment',
13024
+ 'get',
13025
+ commentId,
13026
+ ])) === null || _a === void 0 ? void 0 : _a.data;
13027
+ if (!commentCached)
13028
+ return null;
13029
+ return commentLinkedObject(commentCached);
13030
+ })
13031
+ .filter(Boolean) || []);
14022
13032
  },
14023
13033
  get creator() {
14024
13034
  // The id is checked for a value, not just for presence: a payload can
@@ -14031,15 +13041,6 @@ const postLinkedObject = (post) => {
14031
13041
  return undefined;
14032
13042
  return userLinkedObject(cacheData.data);
14033
13043
  },
14034
- getLocalCommentCount(includePending = false) {
14035
- var _a;
14036
- const engine = PostCommentCountEngine$1.getInstance();
14037
- // Before any payload has seeded the engine for this post there is no tracker; the
14038
- // post's own figure is the best answer then.
14039
- return engine.hasTracker(post.postId)
14040
- ? engine.getLocalCommentCount(post.postId, includePending)
14041
- : (_a = post.localCommentCount) !== null && _a !== void 0 ? _a : post.commentsCount;
14042
- },
14043
13044
  get targetCommunity() {
14044
13045
  var _a;
14045
13046
  if (!post.targetId)
@@ -14404,8 +13405,7 @@ const messageLinkedObject = (message) => {
14404
13405
  },
14405
13406
  get creator() {
14406
13407
  var _a;
14407
- const creator = (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
14408
- return creator ? userLinkedObject(creator) : undefined;
13408
+ return (_a = pullFromCache(['user', 'get', message.creatorId])) === null || _a === void 0 ? void 0 : _a.data;
14409
13409
  }, markRead: () => markReadMessage(message), addReaction: (reactionName) => addReactionToMessage(reactionName, message), removeReaction: (reactionName) => removeReactionToMessage(reactionName, message) });
14410
13410
  };
14411
13411
 
@@ -15066,22 +14066,6 @@ const eventLinkedObject = (event) => {
15066
14066
  } });
15067
14067
  };
15068
14068
 
15069
- const curatedContentTopicLinkedObject = (topic) => {
15070
- return shallowClone(topic, {
15071
- analytics: {
15072
- markAsViewed: () => {
15073
- AnalyticsEngine$1.getInstance().markCuratedContentWidgetAsViewed(topic.topicId);
15074
- },
15075
- markPostAsViewed: (postId) => {
15076
- AnalyticsEngine$1.getInstance().markCuratedContentPostAsViewed(postId, topic.topicId);
15077
- },
15078
- markPostClick: (postId) => {
15079
- AnalyticsEngine$1.getInstance().markCuratedContentPostAsClicked(postId, topic.topicId);
15080
- },
15081
- },
15082
- });
15083
- };
15084
-
15085
14069
  const LinkedObject = {
15086
14070
  file: fileLinkedObject,
15087
14071
  ad: adLinkedObject,
@@ -15106,7 +14090,6 @@ const LinkedObject = {
15106
14090
  eventResponse: eventResponseLinkedObject,
15107
14091
  product: productLinkedObject,
15108
14092
  poll: pollLinkedObject,
15109
- curatedContentTopic: curatedContentTopicLinkedObject,
15110
14093
  };
15111
14094
 
15112
14095
  /* begin_public_function
@@ -16429,9 +15412,9 @@ var AmityUserSearchMatchType;
16429
15412
  AmityUserSearchMatchType["PARTIAL"] = "partial";
16430
15413
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
16431
15414
 
16432
- var index$r = /*#__PURE__*/Object.freeze({
15415
+ var index$q = /*#__PURE__*/Object.freeze({
16433
15416
  __proto__: null,
16434
- Relationship: index$s,
15417
+ Relationship: index$r,
16435
15418
  getUserByIds: getUserByIds,
16436
15419
  updateUser: updateUser,
16437
15420
  flagUser: flagUser,
@@ -16839,7 +15822,7 @@ const uploadAudio = async (formData, onProgress) => {
16839
15822
  };
16840
15823
  /* end_public_function */
16841
15824
 
16842
- var index$q = /*#__PURE__*/Object.freeze({
15825
+ var index$p = /*#__PURE__*/Object.freeze({
16843
15826
  __proto__: null,
16844
15827
  getFile: getFile,
16845
15828
  uploadFile: uploadFile,
@@ -17032,6 +16015,147 @@ getMessage$1.locally = (messageId) => {
17032
16015
  };
17033
16016
  };
17034
16017
 
16018
+ class ResetTask {
16019
+ constructor(postId, latestCreatedAt, serverCommentCount) {
16020
+ this.postId = postId;
16021
+ this.latestCreatedAt = latestCreatedAt;
16022
+ this.serverCommentCount = serverCommentCount;
16023
+ }
16024
+ }
16025
+
16026
+ // Task to track comment creation
16027
+ class CreateTask {
16028
+ constructor(postId, commentId, createdAt) {
16029
+ this.postId = postId;
16030
+ this.commentId = commentId;
16031
+ this.createdAt = createdAt;
16032
+ }
16033
+ }
16034
+
16035
+ // Task to track comment deletion
16036
+ class DeleteTask {
16037
+ constructor(postId, commentId) {
16038
+ this.postId = postId;
16039
+ this.commentId = commentId;
16040
+ }
16041
+ }
16042
+
16043
+ class CommentChange {
16044
+ constructor(latestCreatedAt, serverCommentCount) {
16045
+ this.latestCommentCreatedAt = latestCreatedAt;
16046
+ this.serverCommentCount = serverCommentCount;
16047
+ this.createdCommentIds = new Set();
16048
+ this.deletedCommentIds = new Set();
16049
+ }
16050
+ }
16051
+
16052
+ class PostCommentCountEngine {
16053
+ constructor() {
16054
+ this.isProcessing = false;
16055
+ this.tasks = [];
16056
+ this.commentChangeTracker = new Map();
16057
+ }
16058
+ queueCommentChangeTask(task) {
16059
+ this.tasks.push(task);
16060
+ if (!this.isProcessing) {
16061
+ this.processCommentChangeTask();
16062
+ }
16063
+ }
16064
+ processCommentChangeTask() {
16065
+ if (this.isProcessing) {
16066
+ return;
16067
+ }
16068
+ this.isProcessing = true;
16069
+ if (this.tasks.length === 0) {
16070
+ this.isProcessing = false;
16071
+ return;
16072
+ }
16073
+ // Process in capped batches, coalescing updates
16074
+ const batch = this.tasks.splice(0, PostCommentCountEngine.BATCH_SIZE);
16075
+ const modifiedPostIds = new Set();
16076
+ batch.forEach(task => {
16077
+ let modified = false;
16078
+ if (task instanceof ResetTask) {
16079
+ modified = this.processResetTaskInternal(task);
16080
+ }
16081
+ else if (task instanceof CreateTask) {
16082
+ modified = this.processCreateTaskInternal(task);
16083
+ }
16084
+ else if (task instanceof DeleteTask) {
16085
+ modified = this.processDeleteTaskInternal(task);
16086
+ }
16087
+ if (modified) {
16088
+ modifiedPostIds.add(task.postId);
16089
+ }
16090
+ });
16091
+ // Publish one update per modified post
16092
+ modifiedPostIds.forEach(postId => {
16093
+ const count = this.computeCommentCount(postId);
16094
+ PostCommentCountEngine.publishUpdate(postId, count);
16095
+ });
16096
+ this.isProcessing = false;
16097
+ // Recurse if more tasks remain
16098
+ if (this.tasks.length > 0) {
16099
+ this.processCommentChangeTask();
16100
+ }
16101
+ }
16102
+ processResetTaskInternal(task) {
16103
+ // Always creates/overwrites tracker
16104
+ this.commentChangeTracker.set(task.postId, new CommentChange(task.latestCreatedAt, task.serverCommentCount));
16105
+ return true;
16106
+ }
16107
+ processCreateTaskInternal(task) {
16108
+ const tracker = this.commentChangeTracker.get(task.postId);
16109
+ if (!tracker)
16110
+ return false; // No tracker, skip
16111
+ if (tracker.createdCommentIds.has(task.commentId))
16112
+ return false; // Deduplication
16113
+ if (task.createdAt <= tracker.latestCommentCreatedAt)
16114
+ return false; // Timestamp filtering
16115
+ tracker.createdCommentIds.add(task.commentId);
16116
+ return true;
16117
+ }
16118
+ processDeleteTaskInternal(task) {
16119
+ const tracker = this.commentChangeTracker.get(task.postId);
16120
+ if (!tracker)
16121
+ return false; // No tracker, skip
16122
+ if (tracker.deletedCommentIds.has(task.commentId))
16123
+ return false; // Deduplication
16124
+ tracker.deletedCommentIds.add(task.commentId);
16125
+ return true;
16126
+ }
16127
+ computeCommentCount(postId) {
16128
+ const tracker = this.commentChangeTracker.get(postId);
16129
+ if (!tracker)
16130
+ return 0;
16131
+ const count = tracker.serverCommentCount + tracker.createdCommentIds.size - tracker.deletedCommentIds.size;
16132
+ return Math.max(0, count);
16133
+ }
16134
+ static publishUpdate(postId, newCount) {
16135
+ var _a;
16136
+ const queryKey = ['post', 'get', postId];
16137
+ mergeInCache(queryKey, {
16138
+ localCommentCount: newCount,
16139
+ });
16140
+ const postPayload = (_a = pullFromCache(queryKey)) === null || _a === void 0 ? void 0 : _a.data;
16141
+ if (!postPayload)
16142
+ return;
16143
+ fireEvent('local.post.updated', {
16144
+ posts: [postPayload],
16145
+ });
16146
+ }
16147
+ }
16148
+ PostCommentCountEngine.BATCH_SIZE = 50;
16149
+ let instance;
16150
+ var PostCommentCountEngine$1 = {
16151
+ getInstance: () => {
16152
+ if (!instance) {
16153
+ instance = new PostCommentCountEngine();
16154
+ }
16155
+ return instance;
16156
+ },
16157
+ };
16158
+
17035
16159
  const updateStreamReferences = (streams, streamId, postId) => {
17036
16160
  if (!streamId)
17037
16161
  return streams;
@@ -17051,7 +16175,7 @@ const preparePostPayload = (payload) => {
17051
16175
  let mappedNewStream = [];
17052
16176
  // feed type
17053
16177
  const posts = postsData.map(post => {
17054
- var _a, _b, _c;
16178
+ var _a, _b, _c, _d;
17055
16179
  const feedType = (_a = postPayload.feeds.find(feed => feed.feedId === post.feedId)) === null || _a === void 0 ? void 0 : _a.feedType;
17056
16180
  const childPosts = payload.postChildren.filter(children => children.parentPostId === post.postId);
17057
16181
  if (childPosts.length > 0 && isAmityLivestreamPost(childPosts[0])) {
@@ -17070,11 +16194,7 @@ const preparePostPayload = (payload) => {
17070
16194
  // Queue ResetTask for this post
17071
16195
  PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new ResetTask(post.postId, latestCreatedAt, (_c = post.commentsCount) !== null && _c !== void 0 ? _c : 0));
17072
16196
  return Object.assign(Object.assign({}, post), { childPosts,
17073
- feedType,
17074
- // The ResetTask above has just seeded the engine, so this is the server figure plus the
17075
- // author's own pending comments. Reading `post.commentsCount` here instead would overwrite
17076
- // that +1 in the cache on every refresh, since the ingest that follows merges this object.
17077
- localCommentCount: PostCommentCountEngine$1.getInstance().getLocalCommentCount(post.postId, true), pinnedProductId: post === null || post === void 0 ? void 0 : post.pinnedProductId });
16197
+ feedType, localCommentCount: (_d = post.localCommentCount) !== null && _d !== void 0 ? _d : post.commentsCount, pinnedProductId: post === null || post === void 0 ? void 0 : post.pinnedProductId });
17078
16198
  });
17079
16199
  return Object.assign(Object.assign({}, postPayload), { postChildren, videoStreamings: mappedNewStream, posts, communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
17080
16200
  };
@@ -17827,67 +16947,62 @@ const onPostReactionRemoved = (callback) => {
17827
16947
  return createEventSubscriber(client, 'post.removeReaction', 'post.removeReaction', filter);
17828
16948
  };
17829
16949
 
17830
- /**
17831
- * `comment.created` fires while a comment is still pending, so delivery is not visibility. The
17832
- * two side effects that make a comment public — the parent link that feeds the reply list and
17833
- * the comment-count task — are gated here; `comment.approved` is the only reveal signal, and a
17834
- * decline arrives as `comment.deleted`.
17835
- */
17836
- const applyApprovalSideEffects = (event, comment, previous) => {
17837
- switch (event) {
17838
- case 'comment.created':
17839
- if (isCommentPending(comment)) {
17840
- recordPendingAuthoredComment(comment);
17841
- }
17842
- else {
17843
- linkCommentToParent(comment);
17844
- applyCommentCreatedCount(comment);
17845
- }
17846
- break;
17847
- case 'comment.approved':
17848
- linkCommentToParent(comment);
17849
- applyCommentApprovedCount(comment);
17850
- break;
17851
- case 'comment.updated':
17852
- // An effective edit in a gated community sends an approved comment back for review
17853
- if (isCommentPending(comment) && previous && isCommentApproved(previous)) {
17854
- unlinkCommentFromParent(comment);
17855
- applyCommentReReviewCount(comment);
17856
- }
17857
- break;
17858
- case 'comment.deleted':
17859
- unlinkCommentFromParent(comment);
17860
- // A pending comment was never counted, so its deletion (or decline) moves no count
17861
- if (previous && isCommentPending(previous))
17862
- releasePendingAuthoredComment(comment);
17863
- break;
17864
- }
17865
- };
17866
16950
  const createCommentEventSubscriber = (event, callback) => {
17867
16951
  const client = getActiveClient();
17868
16952
  const filter = (payload) => {
17869
- var _a, _b;
16953
+ var _a;
17870
16954
  if (!client.cache) {
17871
16955
  // TODO: here we are missing specific properties here!
17872
16956
  callback(LinkedObject.comment(payload.comments[0]));
17873
16957
  }
17874
16958
  else {
17875
- const flagged = ['comment.flagged', 'comment.unflagged'].includes(event)
16959
+ const processed = ['comment.flagged', 'comment.unflagged'].includes(event)
17876
16960
  ? prepareCommentFromFlaggedEvent(payload)
17877
16961
  : payload;
17878
- // Resolve `approvalStatus` before the merge: an absent value means approved and has to
17879
- // overwrite a cached `pending`, which a plain merge would leave in place.
17880
- const processed = prepareCommentPayload(flagged);
16962
+ // NOTE: The event data should be merge with existing cache rather than replace it
16963
+ ingestInCache(processed, undefined, false);
17881
16964
  const { comments } = processed;
17882
16965
  if (comments.length > 0) {
17883
- const commentKey = ['comment', 'get', comments[0].commentId];
17884
- const previous = (_a = pullFromCache(commentKey)) === null || _a === void 0 ? void 0 : _a.data;
17885
- // NOTE: The event data should be merge with existing cache rather than replace it
17886
- ingestInCache(processed, undefined, false);
17887
- const comment = pullFromCache(commentKey);
17888
- applyApprovalSideEffects(event, comment.data, previous);
16966
+ const comment = pullFromCache([
16967
+ 'comment',
16968
+ 'get',
16969
+ comments[0].commentId,
16970
+ ]);
16971
+ if (['comment.created'].includes(event)) {
16972
+ if (comments[0].parentId) {
16973
+ const parentComment = pullFromCache([
16974
+ 'comment',
16975
+ 'get',
16976
+ comments[0].parentId,
16977
+ ]);
16978
+ if (parentComment === null || parentComment === void 0 ? void 0 : parentComment.data) {
16979
+ // Skip to update parent childComment if current comment already exists
16980
+ if (!parentComment.data.children.includes(comments[0].commentId)) {
16981
+ pushToCache(['comment', 'get', comments[0].parentId], Object.assign(Object.assign({}, parentComment.data), { childrenNumber: parentComment.data.childrenNumber + 1, children: [...new Set([...parentComment.data.children, comments[0].commentId])] }));
16982
+ }
16983
+ }
16984
+ }
16985
+ }
17889
16986
  if (['comment.deleted'].includes(event)) {
17890
- const queries = (_b = queryCache(['comment', 'query'])) === null || _b === void 0 ? void 0 : _b.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
16987
+ if (comments[0].parentId) {
16988
+ const parentComment = pullFromCache([
16989
+ 'comment',
16990
+ 'get',
16991
+ comments[0].parentId,
16992
+ ]);
16993
+ if (parentComment === null || parentComment === void 0 ? void 0 : parentComment.data) {
16994
+ // Remove deleted comment in parent childComment if still exists
16995
+ if (parentComment.data.children.includes(comments[0].commentId)) {
16996
+ const newParentComment = Object.assign(Object.assign({}, parentComment.data), { childrenNumber: parentComment.data.childrenNumber - 1, children: [
16997
+ ...new Set([
16998
+ ...parentComment.data.children.filter(id => id !== comments[0].commentId),
16999
+ ]),
17000
+ ] });
17001
+ pushToCache(['comment', 'get', comments[0].parentId], newParentComment);
17002
+ }
17003
+ }
17004
+ }
17005
+ const queries = (_a = queryCache(['comment', 'query'])) === null || _a === void 0 ? void 0 : _a.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
17891
17006
  queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
17892
17007
  }
17893
17008
  callback(LinkedObject.comment(comment.data));
@@ -17899,13 +17014,13 @@ const createCommentEventSubscriber = (event, callback) => {
17899
17014
  const createLocalCommentEventSubscriber = (event, callback) => {
17900
17015
  const client = getActiveClient();
17901
17016
  const filter = (payload) => {
17902
- var _a, _b, _c, _d;
17017
+ var _a, _b, _c, _d, _e;
17903
17018
  if (!client.cache) {
17904
17019
  // TODO: here we are missing specific properties here!
17905
17020
  callback(LinkedObject.comment(payload.comments[0]));
17906
17021
  }
17907
17022
  else {
17908
- const processed = prepareCommentPayload(payload);
17023
+ const processed = payload;
17909
17024
  ingestInCache(processed);
17910
17025
  const { comments } = processed;
17911
17026
  if (comments.length > 0) {
@@ -17914,9 +17029,7 @@ const createLocalCommentEventSubscriber = (event, callback) => {
17914
17029
  'get',
17915
17030
  comments[0].commentId,
17916
17031
  ]);
17917
- // A pending comment is persisted for its author but never linked into the public
17918
- // surfaces (parent reply list, post comment list)
17919
- if (['local.comment.created'].includes(event) && isCommentApproved(comments[0])) {
17032
+ if (['local.comment.created'].includes(event)) {
17920
17033
  if (comments[0].parentId) {
17921
17034
  const parentComment = pullFromCache([
17922
17035
  'comment',
@@ -17945,11 +17058,11 @@ const createLocalCommentEventSubscriber = (event, callback) => {
17945
17058
  const postCacheKey = ['post', 'get', comments[0].referenceId];
17946
17059
  const postCache = (_a = pullFromCache(postCacheKey)) === null || _a === void 0 ? void 0 : _a.data;
17947
17060
  if (postCache) {
17948
- const updatedPostCache = Object.assign(Object.assign({}, postCache), { comments: appendLatestCommentId(postCache, comments[0].commentId) });
17061
+ const updatedPostCache = Object.assign(Object.assign({}, postCache), { comments: [...postCache.comments, (_b = comments[0]) === null || _b === void 0 ? void 0 : _b.commentId] });
17949
17062
  pushToCache(postCacheKey, updatedPostCache);
17950
17063
  }
17951
17064
  }
17952
- const queries = (_b = queryCache(['comment', 'query'])) === null || _b === void 0 ? void 0 : _b.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
17065
+ const queries = (_c = queryCache(['comment', 'query'])) === null || _c === void 0 ? void 0 : _c.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
17953
17066
  queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
17954
17067
  }
17955
17068
  if (['local.comment.deleted'].includes(event)) {
@@ -17983,13 +17096,13 @@ const createLocalCommentEventSubscriber = (event, callback) => {
17983
17096
  }
17984
17097
  else {
17985
17098
  const postCacheKey = ['post', 'get', comments[0].referenceId];
17986
- const postCache = (_c = pullFromCache(postCacheKey)) === null || _c === void 0 ? void 0 : _c.data;
17099
+ const postCache = (_d = pullFromCache(postCacheKey)) === null || _d === void 0 ? void 0 : _d.data;
17987
17100
  if (postCache) {
17988
17101
  const updatedPost = Object.assign(Object.assign({}, postCache), { comments: postCache === null || postCache === void 0 ? void 0 : postCache.comments.filter(commentId => { var _a; return commentId !== ((_a = comments[0]) === null || _a === void 0 ? void 0 : _a.commentId); }) });
17989
17102
  pushToCache(postCacheKey, updatedPost);
17990
17103
  }
17991
17104
  }
17992
- const queries = (_d = queryCache(['comment', 'query'])) === null || _d === void 0 ? void 0 : _d.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
17105
+ const queries = (_e = queryCache(['comment', 'query'])) === null || _e === void 0 ? void 0 : _e.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
17993
17106
  queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
17994
17107
  }
17995
17108
  callback(LinkedObject.comment(comment.data));
@@ -18050,23 +17163,6 @@ const onCommentUpdated = (callback) => createCommentEventSubscriber('comment.upd
18050
17163
  */
18051
17164
  const onCommentDeleted = (callback) => createCommentEventSubscriber('comment.deleted', callback);
18052
17165
 
18053
- /**
18054
- * ```js
18055
- * import { onCommentApproved } from '@amityco/ts-sdk'
18056
- * const dispose = onCommentApproved(comment => {
18057
- * // ...
18058
- * })
18059
- * ```
18060
- *
18061
- * Fired when a {@link Amity.InternalComment} held for review has been approved
18062
- *
18063
- * @param callback The function to call when the event was fired
18064
- * @returns an {@link Amity.Unsubscriber} function to stop listening
18065
- *
18066
- * @category Comment Events
18067
- */
18068
- const onCommentApproved = (callback) => createCommentEventSubscriber('comment.approved', callback);
18069
-
18070
17166
  /**
18071
17167
  * ```js
18072
17168
  * import { onCommentFlagged } from '@amityco/ts-sdk'
@@ -18699,7 +17795,7 @@ const getReactions$1 = (params, callback, config) => {
18699
17795
  };
18700
17796
  /* end_public_function */
18701
17797
 
18702
- var index$p = /*#__PURE__*/Object.freeze({
17798
+ var index$o = /*#__PURE__*/Object.freeze({
18703
17799
  __proto__: null,
18704
17800
  addReaction: addReaction,
18705
17801
  removeReaction: removeReaction,
@@ -18710,6 +17806,17 @@ var index$p = /*#__PURE__*/Object.freeze({
18710
17806
  getReactions: getReactions$1
18711
17807
  });
18712
17808
 
17809
+ function prepareCommentPayload(commentPayload) {
17810
+ const { comments } = commentPayload;
17811
+ return Object.assign(Object.assign({}, commentPayload), { comments: comments.map(comment => {
17812
+ if (comment.hasOwnProperty('myReactions'))
17813
+ return comment;
17814
+ // Sometimes `myReactions` field will not come with BE response because that field is empty
17815
+ // We need to put it with an empty array manually to make it show up in client side
17816
+ return Object.assign({ myReactions: [] }, comment);
17817
+ }) });
17818
+ }
17819
+
18713
17820
  const createMessageReport = async ({ client, referenceId, }) => {
18714
17821
  const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(referenceId)}/flags`);
18715
17822
  if (client.cache) {
@@ -19173,20 +18280,20 @@ const getArchivedChannelIds = async () => {
19173
18280
 
19174
18281
  /**
19175
18282
  * ```js
19176
- * import { onMessageDeleted } from '@amityco/ts-sdk'
19177
- * const dispose = onMessageDeleted(message => {
18283
+ * import { onMessageUpdated } from '@amityco/ts-sdk'
18284
+ * const dispose = onMessageUpdated(message => {
19178
18285
  * // ...
19179
18286
  * })
19180
18287
  * ```
19181
18288
  *
19182
- * Fired when an {@link Amity.Message} was deleted
18289
+ * Fired when an {@link Amity.Message} has been updated
19183
18290
  *
19184
18291
  * @param callback The function to call when the event was fired
19185
18292
  * @returns an {@link Amity.Unsubscriber} function to stop listening
19186
18293
  *
19187
18294
  * @category Message Events
19188
18295
  */
19189
- const onMessageDeleted = (callback) => {
18296
+ const onMessageUpdated = (callback) => {
19190
18297
  const client = getActiveClient();
19191
18298
  const filter = async (rawPayload) => {
19192
18299
  const payload = await prepareMessagePayload(rawPayload);
@@ -19194,48 +18301,30 @@ const onMessageDeleted = (callback) => {
19194
18301
  callback(payload.messages[0]);
19195
18302
  };
19196
18303
  const disposers = [
19197
- createEventSubscriber(client, 'message/onMessageDeleted', 'message.deleted', filter),
19198
- createEventSubscriber(client, 'message/onMessageDeleted', 'local.message.deleted', payload => callback(payload.messages[0])),
18304
+ createEventSubscriber(client, 'onMessageUpdated', 'message.updated', filter),
18305
+ createEventSubscriber(client, 'onMessageUpdated', 'local.message.updated', payload => callback(payload.messages[0])),
19199
18306
  ];
19200
18307
  return () => {
19201
18308
  disposers.forEach(fn => fn());
19202
18309
  };
19203
18310
  };
19204
18311
 
19205
- /**
19206
- * Defensive clear of `channel.pinnedMessage` when the pinned message itself is deleted.
19207
- *
19208
- * The server also emits `channel.messageUnpinned` in this case, but realtime events are
19209
- * fire-and-forget and their order is not guaranteed. Clearing on `message.deleted`
19210
- * (MQTT or local) makes the banner disappear even if the unpin event is lost; the
19211
- * server's own `messageUnpinned` then becomes a no-op.
19212
- *
19213
- * Internal — wired into the `getChannel` live object; not exported publicly.
19214
- */
19215
- const onChannelPinnedMessageDeleted = (callback) => onMessageDeleted(message => {
19216
- var _a;
19217
- const channel = findCachedChannelByAnyId(message.channelId);
19218
- if (!channel || ((_a = channel.pinnedMessage) === null || _a === void 0 ? void 0 : _a.messageId) !== message.messageId)
19219
- return;
19220
- callback(updatePinnedMessageCache(channel, null));
19221
- });
19222
-
19223
18312
  /**
19224
18313
  * ```js
19225
- * import { onMessageUpdated } from '@amityco/ts-sdk'
19226
- * const dispose = onMessageUpdated(message => {
18314
+ * import { onMessageDeleted } from '@amityco/ts-sdk'
18315
+ * const dispose = onMessageDeleted(message => {
19227
18316
  * // ...
19228
18317
  * })
19229
18318
  * ```
19230
18319
  *
19231
- * Fired when an {@link Amity.Message} has been updated
18320
+ * Fired when an {@link Amity.Message} was deleted
19232
18321
  *
19233
18322
  * @param callback The function to call when the event was fired
19234
18323
  * @returns an {@link Amity.Unsubscriber} function to stop listening
19235
18324
  *
19236
18325
  * @category Message Events
19237
18326
  */
19238
- const onMessageUpdated = (callback) => {
18327
+ const onMessageDeleted = (callback) => {
19239
18328
  const client = getActiveClient();
19240
18329
  const filter = async (rawPayload) => {
19241
18330
  const payload = await prepareMessagePayload(rawPayload);
@@ -19243,8 +18332,8 @@ const onMessageUpdated = (callback) => {
19243
18332
  callback(payload.messages[0]);
19244
18333
  };
19245
18334
  const disposers = [
19246
- createEventSubscriber(client, 'onMessageUpdated', 'message.updated', filter),
19247
- createEventSubscriber(client, 'onMessageUpdated', 'local.message.updated', payload => callback(payload.messages[0])),
18335
+ createEventSubscriber(client, 'message/onMessageDeleted', 'message.deleted', filter),
18336
+ createEventSubscriber(client, 'message/onMessageDeleted', 'local.message.deleted', payload => callback(payload.messages[0])),
19248
18337
  ];
19249
18338
  return () => {
19250
18339
  disposers.forEach(fn => fn());
@@ -19825,132 +18914,6 @@ softDeleteMessage.optimistically = (messageId) => {
19825
18914
  };
19826
18915
  /* end_public_function */
19827
18916
 
19828
- /**
19829
- * Fire-and-forget refresh of `channelUsers[...].permissions` for the channel a
19830
- * message belongs to. Used by `pinMessage` / `unpinMessage` on `403` so the next
19831
- * `hasPermission(PIN_MESSAGE).channel(channelId)` reflects a revoked role
19832
- * ([`pinMessage` REQ-010](../../@types/../..) / [`unpinMessage` REQ-008](../../@types/../..)).
19833
- *
19834
- * The API only receives a `messageId`, so the channel is resolved through the
19835
- * local cache: first the message row, then any cached channel whose current pin
19836
- * is that message. When nothing matches the refresh is skipped — the next
19837
- * channel read picks up the fresh permissions anyway.
19838
- */
19839
- const refreshChannelPermissionsForMessage = (messageId) => {
19840
- var _a, _b, _c;
19841
- const cachedMessage = (_a = getMessage$1.locally(messageId)) === null || _a === void 0 ? void 0 : _a.data;
19842
- let channelId = cachedMessage === null || cachedMessage === void 0 ? void 0 : cachedMessage.channelId;
19843
- if (!channelId) {
19844
- channelId = (_c = (_b = queryCache(['channel', 'get'])) === null || _b === void 0 ? void 0 : _b.find(({ data }) => { var _a; return ((_a = data.pinnedMessage) === null || _a === void 0 ? void 0 : _a.messageId) === messageId; })) === null || _c === void 0 ? void 0 : _c.data.channelId;
19845
- }
19846
- if (!channelId)
19847
- return;
19848
- getChannel$1(channelId).catch(() => {
19849
- /* silent per spec; UIKit renders no error toast */
19850
- });
19851
- };
19852
-
19853
- /* begin_public_function
19854
- id: message.pin
19855
- */
19856
- /**
19857
- * ```js
19858
- * import { MessageRepository } from '@amityco/ts-sdk'
19859
- * const channel = await MessageRepository.pinMessage(messageId)
19860
- * console.log(channel.pinnedMessage)
19861
- * ```
19862
- *
19863
- * Pins a {@link Amity.Message} in its livestream (`live`) channel. A channel holds at
19864
- * most one pinned message: pinning a different message replaces the current pin in a
19865
- * single step — no unpin is needed first. Pinning the message that is already pinned is
19866
- * rejected by the server (400).
19867
- *
19868
- * The caller must hold the `PIN_MESSAGE` permission in the channel (or be an admin with
19869
- * `ModerateChannel`). The server also rejects pinning a deleted message, a message whose
19870
- * author is banned from the channel or globally banned, and pinning in any channel type
19871
- * other than `live`. On any error the pin state is left unchanged.
19872
- *
19873
- * The response is the affected channel; it is ingested into cache and fires
19874
- * `local.channel.updated`, so `ChannelRepository.getChannel` observers update without
19875
- * waiting for the `channel.messagePinned` realtime event.
19876
- *
19877
- * @param messageId the **internal** ID of the {@link Amity.Message} to pin
19878
- * @returns the updated {@link Amity.Channel}, with `pinnedMessage` set
19879
- *
19880
- * @category Message API
19881
- * @async
19882
- */
19883
- const pinMessage = async (messageId) => {
19884
- const client = getActiveClient();
19885
- client.log('message/pinMessage', messageId);
19886
- let payload;
19887
- try {
19888
- ({ data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/pin`));
19889
- }
19890
- catch (error) {
19891
- if ((error === null || error === void 0 ? void 0 : error.code) === 400301 /* Amity.ServerError.PERMISSION_DENIED */) {
19892
- refreshChannelPermissionsForMessage(messageId);
19893
- }
19894
- throw error;
19895
- }
19896
- const data = await prepareChannelPayload(payload);
19897
- if (client.cache)
19898
- ingestInCache(data);
19899
- fireEvent('local.channel.updated', data);
19900
- return constructChannelObject(data.channels[0]);
19901
- };
19902
- /* end_public_function */
19903
-
19904
- /* begin_public_function
19905
- id: message.unpin
19906
- */
19907
- /**
19908
- * ```js
19909
- * import { MessageRepository } from '@amityco/ts-sdk'
19910
- * const channel = await MessageRepository.unpinMessage(messageId)
19911
- * console.log(channel.pinnedMessage) // null
19912
- * ```
19913
- *
19914
- * Removes the pin from a {@link Amity.Message}. `messageId` must be the message that is
19915
- * **currently** pinned in its channel; otherwise the server answers 400 — this is
19916
- * deliberate, so a stale client cannot clear a pin that someone else has since replaced.
19917
- * On that error, re-read the channel (or rely on the `channel.messagePinned` event) to
19918
- * get the current pin.
19919
- *
19920
- * The caller must hold the `PIN_MESSAGE` permission in the channel (or be an admin with
19921
- * `ModerateChannel`). Unpinning is allowed regardless of channel type and stream state.
19922
- *
19923
- * The response is the affected channel; it is ingested into cache and fires
19924
- * `local.channel.updated`, so `ChannelRepository.getChannel` observers update without
19925
- * waiting for the `channel.messageUnpinned` realtime event.
19926
- *
19927
- * @param messageId the **internal** ID of the currently pinned {@link Amity.Message}
19928
- * @returns the updated {@link Amity.Channel}, with `pinnedMessage` cleared
19929
- *
19930
- * @category Message API
19931
- * @async
19932
- */
19933
- const unpinMessage = async (messageId) => {
19934
- const client = getActiveClient();
19935
- client.log('message/unpinMessage', messageId);
19936
- let payload;
19937
- try {
19938
- ({ data: payload } = await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}/pin`));
19939
- }
19940
- catch (error) {
19941
- if ((error === null || error === void 0 ? void 0 : error.code) === 400301 /* Amity.ServerError.PERMISSION_DENIED */) {
19942
- refreshChannelPermissionsForMessage(messageId);
19943
- }
19944
- throw error;
19945
- }
19946
- const data = await prepareChannelPayload(payload);
19947
- if (client.cache)
19948
- ingestInCache(data);
19949
- fireEvent('local.channel.updated', data);
19950
- return constructChannelObject(data.channels[0]);
19951
- };
19952
- /* end_public_function */
19953
-
19954
18917
  /**
19955
18918
  * ```js
19956
18919
  * import { MessageRepository } from '@amityco/ts-sdk'
@@ -20847,15 +19810,13 @@ const searchMessage = (params, callback) => {
20847
19810
  };
20848
19811
  /* end_public_function */
20849
19812
 
20850
- var index$o = /*#__PURE__*/Object.freeze({
19813
+ var index$n = /*#__PURE__*/Object.freeze({
20851
19814
  __proto__: null,
20852
19815
  createMessage: createMessage,
20853
19816
  updateMessage: updateMessage,
20854
19817
  editMessage: editMessage,
20855
19818
  deleteMessage: deleteMessage,
20856
19819
  softDeleteMessage: softDeleteMessage,
20857
- pinMessage: pinMessage,
20858
- unpinMessage: unpinMessage,
20859
19820
  markAsDelivered: markAsDelivered,
20860
19821
  getReadUsers: getReadUsers,
20861
19822
  getDeliveredUsers: getDeliveredUsers,
@@ -21385,7 +20346,7 @@ const stopMessageReceiptSync = (subChannelId) => {
21385
20346
  };
21386
20347
  /* end_public_function */
21387
20348
 
21388
- var index$n = /*#__PURE__*/Object.freeze({
20349
+ var index$m = /*#__PURE__*/Object.freeze({
21389
20350
  __proto__: null,
21390
20351
  getSubChannelByIds: getSubChannels$1,
21391
20352
  createSubChannel: createSubChannel,
@@ -21493,9 +20454,6 @@ const getChannel = (channelId, callback) => {
21493
20454
  onChannelMemberBanned,
21494
20455
  onChannelMemberUnbanned,
21495
20456
  onChannelSetMuted,
21496
- onChannelMessagePinned,
21497
- onChannelMessageUnpinned,
21498
- onChannelPinnedMessageDeleted,
21499
20457
  convertEventPayload(onChannelMarkerFetched, 'entityId', 'channel'),
21500
20458
  convertEventPayload(onChannelMarkerUpdated, 'entityId', 'channel'),
21501
20459
  convertEventPayload((callback) => {
@@ -22121,14 +21079,6 @@ class ChannelLiveCollectionController extends LiveCollectionController {
22121
21079
  return;
22122
21080
  if (messagePreviewSetting ===
22123
21081
  "message-preview-not-include-deleted" /* Amity.MessagePreviewSetting.MESSAGE_PREVIEW_NOT_INCLUDE_DELETED */) {
22124
- // The replacement preview the server sends back is an OLDER
22125
- // message than the one just deleted, and
22126
- // updateChannelMessagePreviewCache drops any preview that is not
22127
- // newer than what is cached — so without clearing the entry
22128
- // first the refetch is a no-op and the channel keeps showing the
22129
- // deleted message. getChannel's own live object already does
22130
- // this; the live collections did not.
22131
- dropFromCache(['messagePreviewChannel', 'get', message.channelId]);
22132
21082
  await getChannel$1(message.channelId);
22133
21083
  }
22134
21084
  callback(message);
@@ -22853,14 +21803,6 @@ class SearchChannelLiveCollectionController extends LiveCollectionController {
22853
21803
  return;
22854
21804
  if (messagePreviewSetting ===
22855
21805
  "message-preview-not-include-deleted" /* Amity.MessagePreviewSetting.MESSAGE_PREVIEW_NOT_INCLUDE_DELETED */) {
22856
- // The replacement preview the server sends back is an OLDER
22857
- // message than the one just deleted, and
22858
- // updateChannelMessagePreviewCache drops any preview that is not
22859
- // newer than what is cached — so without clearing the entry
22860
- // first the refetch is a no-op and the channel keeps showing the
22861
- // deleted message. getChannel's own live object already does
22862
- // this; the live collections did not.
22863
- dropFromCache(['messagePreviewChannel', 'get', message.channelId]);
22864
21806
  await getChannel$1(message.channelId);
22865
21807
  }
22866
21808
  callback(message);
@@ -23355,7 +22297,7 @@ const searchMembers$1 = (params, callback, config) => {
23355
22297
  };
23356
22298
  /* end_public_function */
23357
22299
 
23358
- var index$m = /*#__PURE__*/Object.freeze({
22300
+ var index$l = /*#__PURE__*/Object.freeze({
23359
22301
  __proto__: null,
23360
22302
  addMembers: addMembers$1,
23361
22303
  removeMembers: removeMembers$1,
@@ -23577,7 +22519,7 @@ const unmuteMembers = async (channelId, userIds) => {
23577
22519
  };
23578
22520
  /* end_public_function */
23579
22521
 
23580
- var index$l = /*#__PURE__*/Object.freeze({
22522
+ var index$k = /*#__PURE__*/Object.freeze({
23581
22523
  __proto__: null,
23582
22524
  addRole: addRole,
23583
22525
  removeRole: removeRole,
@@ -23587,10 +22529,10 @@ var index$l = /*#__PURE__*/Object.freeze({
23587
22529
  unmuteMembers: unmuteMembers
23588
22530
  });
23589
22531
 
23590
- var index$k = /*#__PURE__*/Object.freeze({
22532
+ var index$j = /*#__PURE__*/Object.freeze({
23591
22533
  __proto__: null,
23592
- Membership: index$m,
23593
- Moderation: index$l,
22534
+ Membership: index$l,
22535
+ Moderation: index$k,
23594
22536
  getChannelByIds: getChannelByIds$1,
23595
22537
  createChannel: createChannel,
23596
22538
  updateChannel: updateChannel,
@@ -23608,8 +22550,6 @@ var index$k = /*#__PURE__*/Object.freeze({
23608
22550
  onChannelJoined: onChannelJoined,
23609
22551
  onChannelLeft: onChannelLeft,
23610
22552
  onChannelSetMuted: onChannelSetMuted,
23611
- onChannelMessagePinned: onChannelMessagePinned,
23612
- onChannelMessageUnpinned: onChannelMessageUnpinned,
23613
22553
  onChannelMemberAdded: onChannelMemberAdded,
23614
22554
  onChannelMemberRemoved: onChannelMemberRemoved,
23615
22555
  onChannelMemberBanned: onChannelMemberBanned,
@@ -23627,11 +22567,7 @@ var index$k = /*#__PURE__*/Object.freeze({
23627
22567
  isUnreadCountSupport: isUnreadCountSupport,
23628
22568
  convertFromRaw: convertFromRaw,
23629
22569
  preUpdateChannelCache: preUpdateChannelCache,
23630
- prepareChannelPayload: prepareChannelPayload,
23631
- findCachedChannelByAnyId: findCachedChannelByAnyId,
23632
- findCachedChannelForPin: findCachedChannelForPin,
23633
- updatePinnedMessageCache: updatePinnedMessageCache,
23634
- applyChannelRolePayload: applyChannelRolePayload
22570
+ prepareChannelPayload: prepareChannelPayload
23635
22571
  });
23636
22572
 
23637
22573
  const saveCommunityUsers = (communities, communityUsers) => {
@@ -25025,7 +23961,7 @@ const searchMembers = (params, callback, config) => {
25025
23961
  };
25026
23962
  /* end_public_function */
25027
23963
 
25028
- var index$j = /*#__PURE__*/Object.freeze({
23964
+ var index$i = /*#__PURE__*/Object.freeze({
25029
23965
  __proto__: null,
25030
23966
  addMembers: addMembers,
25031
23967
  removeMembers: removeMembers,
@@ -26276,7 +25212,7 @@ const unbanMembers = async (communityId, userIds) => {
26276
25212
  };
26277
25213
  /* end_public_function */
26278
25214
 
26279
- var index$i = /*#__PURE__*/Object.freeze({
25215
+ var index$h = /*#__PURE__*/Object.freeze({
26280
25216
  __proto__: null,
26281
25217
  addRoles: addRoles,
26282
25218
  removeRoles: removeRoles,
@@ -26284,10 +25220,10 @@ var index$i = /*#__PURE__*/Object.freeze({
26284
25220
  unbanMembers: unbanMembers
26285
25221
  });
26286
25222
 
26287
- var index$h = /*#__PURE__*/Object.freeze({
25223
+ var index$g = /*#__PURE__*/Object.freeze({
26288
25224
  __proto__: null,
26289
- Moderation: index$i,
26290
- Membership: index$j,
25225
+ Moderation: index$h,
25226
+ Membership: index$i,
26291
25227
  getCommunityByIds: getCommunities$1,
26292
25228
  createCommunity: createCommunity,
26293
25229
  updateCommunity: updateCommunity,
@@ -26523,7 +25459,7 @@ const getCategories = (params, callback, config) => {
26523
25459
  };
26524
25460
  /* end_public_function */
26525
25461
 
26526
- var index$g = /*#__PURE__*/Object.freeze({
25462
+ var index$f = /*#__PURE__*/Object.freeze({
26527
25463
  __proto__: null,
26528
25464
  getCategory: getCategory,
26529
25465
  getCategories: getCategories
@@ -26822,11 +25758,6 @@ const createCommentOptimistic = (bundle) => {
26822
25758
  targetType: 'community',
26823
25759
  dataType: 'text',
26824
25760
  syncState: "syncing" /* Amity.SyncState.Syncing */,
26825
- // In a gated community the optimistic object stays out of public collections until the
26826
- // response settles the status; the author's own view still updates through the local event
26827
- approvalStatus: isCommentApprovalRequired(bundle)
26828
- ? "pending" /* Amity.CommentApprovalStatusEnum.Pending */
26829
- : "approved" /* Amity.CommentApprovalStatusEnum.Approved */,
26830
25761
  };
26831
25762
  const cachedAt = UNSYNCED_OBJECT_CACHED_AT_VALUE;
26832
25763
  pushToCache(['comment', 'get', comment.commentId], comment, { cachedAt });
@@ -26843,57 +25774,32 @@ const createCommentOptimistic = (bundle) => {
26843
25774
  * ```js
26844
25775
  * import { CommentRepository } from '@amityco/ts-sdk'
26845
25776
  * const newComment = await CommentRepository.createComment(bundle)
26846
- *
26847
- * // Server-confirmed only: nothing is shown until the request succeeds
26848
- * const confirmed = await CommentRepository.createComment(bundle, false)
26849
25777
  * ```
26850
25778
  *
26851
25779
  * Creates an {@link Amity.Comment}
26852
25780
  *
26853
- * With `isOptimistic` (the default) a local comment appears at once with `syncState: 'syncing'`,
26854
- * moves to `'synced'` when the server confirms it and to `'error'` if the request fails, so the
26855
- * caller can offer a retry. With `isOptimistic: false` nothing is created locally until the
26856
- * server answers: on success the comment arrives already `'synced'`; on failure no comment
26857
- * entity exists anywhere and the promise rejects.
26858
- *
26859
25781
  * @param bundle The data necessary to create a new {@link Amity.Comment}
26860
- * @param isOptimistic Show a local comment before the server confirms it. Default `true`.
26861
- * Ignored when the client cache is disabled, since there is nowhere to hold the local comment.
26862
25782
  * @returns The newly created {@link Amity.Comment}
26863
25783
  *
26864
25784
  * @category Comment API
26865
25785
  * @async
26866
25786
  */
26867
- const createComment = async (bundle, isOptimistic = true) => {
25787
+ const createComment = async (bundle) => {
26868
25788
  const client = getActiveClient();
26869
- client.log('comment/createComment', Object.assign(Object.assign({}, bundle), { isOptimistic }));
26870
- // Without a local comment the server assigns the id; with one, the same id travels through the
26871
- // optimistic object, the response and every realtime event so each step recognises it.
26872
- const optimisticData = isOptimistic ? createCommentOptimistic(bundle) : undefined;
25789
+ client.log('comment/createComment', bundle);
25790
+ const optimisticData = createCommentOptimistic(bundle);
26873
25791
  const commentId = optimisticData === null || optimisticData === void 0 ? void 0 : optimisticData.commentId;
26874
25792
  try {
26875
- const { data: payload } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({}, bundle), { commentId }));
25793
+ const { data } = await client.http.post('/api/v3/comments', Object.assign(Object.assign({}, bundle), { commentId }));
25794
+ const { comments } = data;
26876
25795
  // BE always returns an array of comments If it got record 0 from BE it might have a problem on creation logic
26877
- if (payload.comments.length === 0)
25796
+ if (comments.length === 0)
26878
25797
  throw new Error('Comment not created');
26879
- // Absent `approvalStatus` means approved; the result is the only source of the status.
26880
- // The confirmed comment is written as `synced` so the cache itself tells the two states apart
26881
- // (a local-event subscriber is not guaranteed to be listening).
26882
- const prepared = prepareCommentPayload(payload);
26883
- const data = Object.assign(Object.assign({}, prepared), { comments: prepared.comments.map(comment => comment.commentId === (commentId !== null && commentId !== void 0 ? commentId : comment.commentId)
26884
- ? Object.assign(Object.assign({}, comment), { syncState: "synced" /* Amity.SyncState.Synced */ }) : comment) });
26885
- const { comments } = data;
26886
25798
  const cachedAt = client.cache && Date.now();
26887
25799
  if (client.cache)
26888
25800
  ingestInCache(data, { cachedAt });
26889
25801
  if (['post', 'content'].includes(bundle.referenceType)) {
26890
- if (isCommentPending(comments[0])) {
26891
- // Not counted for anyone else until approved; the author sees their own +1
26892
- recordPendingAuthoredComment(comments[0]);
26893
- }
26894
- else {
26895
- PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new CreateTask(bundle.referenceId, comments[0].commentId, comments[0].createdAt));
26896
- }
25802
+ PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new CreateTask(bundle.referenceId, comments[0].commentId, data.comments[0].createdAt));
26897
25803
  }
26898
25804
  else if (bundle.referenceType === 'story') {
26899
25805
  const storyIndex = pullFromCache([
@@ -26914,9 +25820,9 @@ const createComment = async (bundle, isOptimistic = true) => {
26914
25820
  categories: [],
26915
25821
  comments,
26916
25822
  communities: [],
26917
- communityUsers: payload.communityUsers,
26918
- files: payload.files,
26919
- users: payload.users,
25823
+ communityUsers: data.communityUsers,
25824
+ files: data.files,
25825
+ users: data.users,
26920
25826
  });
26921
25827
  }
26922
25828
  }
@@ -26924,9 +25830,9 @@ const createComment = async (bundle, isOptimistic = true) => {
26924
25830
  fireEvent('local.comment.created', {
26925
25831
  comments: [Object.assign(Object.assign({}, comments[0]), { syncState: "synced" /* Amity.SyncState.Synced */ })],
26926
25832
  commentChildren: data.commentChildren,
26927
- users: payload.users,
26928
- files: payload.files,
26929
- communityUsers: payload.communityUsers,
25833
+ users: data.users,
25834
+ files: data.files,
25835
+ communityUsers: data.communityUsers,
26930
25836
  });
26931
25837
  return {
26932
25838
  data: LinkedObject.comment(comments[0]),
@@ -26934,17 +25840,9 @@ const createComment = async (bundle, isOptimistic = true) => {
26934
25840
  };
26935
25841
  }
26936
25842
  catch (e) {
26937
- // Only a local comment has anything to mark as failed; a server-confirmed-only create leaves
26938
- // no entity behind
26939
25843
  if (optimisticData) {
26940
- const failed = Object.assign(Object.assign({}, optimisticData), { syncState: "error" /* Amity.SyncState.Error */ });
26941
- // Write the failure to the cache directly: the local event below only reaches pages that
26942
- // observe comments, and the caller's retry UI reads the cached state
26943
- pushToCache(['comment', 'get', failed.commentId], failed, {
26944
- cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
26945
- });
26946
25844
  fireEvent('local.comment.created', {
26947
- comments: [failed],
25845
+ comments: [Object.assign(Object.assign({}, optimisticData), { syncState: "error" /* Amity.SyncState.Error */ })],
26948
25846
  commentChildren: [],
26949
25847
  users: [],
26950
25848
  files: [],
@@ -26977,26 +25875,16 @@ const createComment = async (bundle, isOptimistic = true) => {
26977
25875
  * @async
26978
25876
  */
26979
25877
  const updateComment = async (commentId, patch) => {
26980
- var _a;
26981
25878
  const client = getActiveClient();
26982
25879
  client.log('user/updateComment', patch);
26983
- const previous = (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data;
26984
- const { data: payload } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
26985
- const data = prepareCommentPayload(payload);
26986
- const updated = data.comments.find(comment => comment.commentId === commentId);
25880
+ const { data } = await client.http.put(`/api/v3/comments/${encodeURIComponent(commentId)}`, patch);
26987
25881
  const cachedAt = client.cache && Date.now();
26988
25882
  if (client.cache)
26989
25883
  ingestInCache(data, { cachedAt });
26990
- // An effective edit in a gated community sends the comment back for review: it leaves the
26991
- // public reply list and the public count once. The `comment.updated` event below removes it
26992
- // from the comment collections; the realtime echo finds it already pending and does nothing.
26993
- if (isCommentPending(updated) && previous && isCommentApproved(previous)) {
26994
- unlinkCommentFromParent(updated);
26995
- applyCommentReReviewCount(updated);
26996
- }
26997
- fireEvent('comment.updated', payload);
25884
+ fireEvent('comment.updated', data);
25885
+ const { comments } = data;
26998
25886
  return {
26999
- data: LinkedObject.comment(updated),
25887
+ data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
27000
25888
  cachedAt,
27001
25889
  };
27002
25890
  };
@@ -27136,13 +26024,7 @@ const deleteComment = async (commentId, permanent = false) => {
27136
26024
  const post = (_b = pullFromCache(['post', 'get', comment.data.referenceId])) === null || _b === void 0 ? void 0 : _b.data;
27137
26025
  if (post) {
27138
26026
  const engine = PostCommentCountEngine$1.getInstance();
27139
- if (isCommentPending(comment.data)) {
27140
- // Never counted for anyone else; only the author's own +1 goes away
27141
- engine.removePendingAuthoredComment(post.postId, commentId);
27142
- }
27143
- else {
27144
- engine.queueCommentChangeTask(new DeleteTask(post.postId, commentId));
27145
- }
26027
+ engine.queueCommentChangeTask(new DeleteTask(post.postId, commentId));
27146
26028
  if (!deleted.parentId && ((_c = deleted.children /* c8 ignore next */) === null || _c === void 0 ? void 0 : _c.length) > 0) {
27147
26029
  // NOTE: delete the parent comment will also remove all children comments
27148
26030
  deleted.children.forEach((childCommentId) => {
@@ -27212,109 +26094,6 @@ const hardDeleteComment = async (commentId) => {
27212
26094
  };
27213
26095
  /* end_public_function */
27214
26096
 
27215
- /* begin_public_function
27216
- id: comment.approve
27217
- */
27218
- /**
27219
- * ```js
27220
- * import { CommentRepository } from '@amityco/ts-sdk'
27221
- *
27222
- * const { data: comment } = await CommentRepository.approveComment('commentId')
27223
- * ```
27224
- *
27225
- * Approves a {@link Amity.Comment} held for review, making it visible to everyone
27226
- *
27227
- * @param commentId The {@link Amity.Comment} ID to be approved
27228
- * @return The {@link Amity.Comment} that was approved
27229
- *
27230
- * @category Comment API
27231
- * @async
27232
- */
27233
- const approveComment = async (commentId) => {
27234
- const client = getActiveClient();
27235
- client.log('comment/approveComment', commentId);
27236
- // No request body, and nothing is revealed before the server confirms
27237
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/approve`);
27238
- const data = prepareCommentPayload(prepareMembershipPayload(payload, 'communityUsers'));
27239
- const approved = data.comments.find(comment => comment.commentId === commentId);
27240
- const cachedAt = client.cache && Date.now();
27241
- if (client.cache)
27242
- ingestInCache(data, { cachedAt });
27243
- // The reveal path: parent link and exactly one count task. Applied here so it does not depend
27244
- // on an observer being open; the event below and the realtime `comment.approved` that follows
27245
- // find the work done and reconcile by comment id (collection insert, queue removal).
27246
- linkCommentToParent(approved);
27247
- applyCommentApprovedCount(approved);
27248
- fireEvent('comment.approved', payload);
27249
- return {
27250
- data: LinkedObject.comment(approved),
27251
- cachedAt,
27252
- };
27253
- };
27254
- /* end_public_function */
27255
-
27256
- // Rejected is terminal and implies deleted
27257
- const markRejected = (comment) => (Object.assign(Object.assign({}, comment), { approvalStatus: "rejected" /* Amity.CommentApprovalStatusEnum.Rejected */, isDeleted: true }));
27258
- /* begin_public_function
27259
- id: comment.decline
27260
- */
27261
- /**
27262
- * ```js
27263
- * import { CommentRepository } from '@amityco/ts-sdk'
27264
- *
27265
- * const { data: comment } = await CommentRepository.declineComment('commentId', 'Off-topic')
27266
- * ```
27267
- *
27268
- * Declines a {@link Amity.Comment} held for review. A declined comment is also a deleted comment
27269
- *
27270
- * @param commentId The {@link Amity.Comment} ID to be declined
27271
- * @param reason Optional reviewer's note, at most 250 characters, kept for the moderation record only
27272
- * @return The {@link Amity.Comment} that was declined
27273
- *
27274
- * @category Comment API
27275
- * @async
27276
- */
27277
- const declineComment = async (commentId, reason) => {
27278
- var _a, _b, _c, _d, _e, _f;
27279
- const client = getActiveClient();
27280
- client.log('comment/declineComment', commentId, reason);
27281
- // Read before the request: the fallback when the response carries no comment
27282
- const cached = (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data;
27283
- // `reason` is surfaced to nobody; the key is absent from the body when the caller gives none
27284
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/decline`, reason ? { reason } : undefined);
27285
- // The BE contract (PDT-5135 §3) states the response body for approve only; for decline the
27286
- // standard comment payload is assumed. Ingest whatever came back, and when the body carries no
27287
- // comment fall back to the cached one so the delete path below still runs.
27288
- const returned = (_b = payload === null || payload === void 0 ? void 0 : payload.comments) === null || _b === void 0 ? void 0 : _b.some(comment => comment.commentId === commentId);
27289
- if (!returned && !cached)
27290
- throw new Error('Comment not found after decline');
27291
- const comments = returned
27292
- ? payload.comments.map(comment => comment.commentId === commentId ? markRejected(comment) : comment)
27293
- : [markRejected(cached)];
27294
- const declined = {
27295
- comments,
27296
- commentChildren: (_c = payload === null || payload === void 0 ? void 0 : payload.commentChildren) !== null && _c !== void 0 ? _c : [],
27297
- users: (_d = payload === null || payload === void 0 ? void 0 : payload.users) !== null && _d !== void 0 ? _d : [],
27298
- files: (_e = payload === null || payload === void 0 ? void 0 : payload.files) !== null && _e !== void 0 ? _e : [],
27299
- communityUsers: (_f = payload === null || payload === void 0 ? void 0 : payload.communityUsers) !== null && _f !== void 0 ? _f : [],
27300
- };
27301
- // There is no `comment.declined` event: the existing delete path drops the comment from every
27302
- // collection and the review queue, and moves no count because a pending comment was never counted.
27303
- const data = prepareCommentPayload(prepareMembershipPayload(declined, 'communityUsers'));
27304
- const rejected = data.comments.find(comment => comment.commentId === commentId);
27305
- const cachedAt = client.cache && Date.now();
27306
- if (client.cache)
27307
- ingestInCache(data, { cachedAt });
27308
- unlinkCommentFromParent(rejected);
27309
- releasePendingAuthoredComment(rejected);
27310
- fireEvent('comment.deleted', declined);
27311
- return {
27312
- data: LinkedObject.comment(rejected),
27313
- cachedAt,
27314
- };
27315
- };
27316
- /* end_public_function */
27317
-
27318
26097
  /* begin_public_function
27319
26098
  id: comment.flag
27320
26099
  */
@@ -27400,7 +26179,6 @@ const isCommentFlaggedByMe = async (commentId) => {
27400
26179
  /* end_public_function */
27401
26180
 
27402
26181
  const getComment$1 = async (commentId) => {
27403
- var _a;
27404
26182
  const client = getActiveClient();
27405
26183
  client.log('comment/getComment', commentId);
27406
26184
  isInTombstone('comment', commentId);
@@ -27411,11 +26189,7 @@ const getComment$1 = async (commentId) => {
27411
26189
  data = response.data;
27412
26190
  }
27413
26191
  catch (error) {
27414
- // A pending comment answers 404 to anyone but its author and reviewers. That is a
27415
- // visibility answer, not a deletion — never tombstone a comment known to be pending.
27416
- const cached = (_a = pullFromCache(['comment', 'get', commentId])) === null || _a === void 0 ? void 0 : _a.data;
27417
- const isKnownPending = !!cached && isCommentPending(cached);
27418
- if (!isKnownPending && checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
26192
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
27419
26193
  pushToTombstone('comment', commentId);
27420
26194
  }
27421
26195
  throw error;
@@ -27542,7 +26316,6 @@ const onLocalCommentReactionRemoved = (callback) => {
27542
26316
  */
27543
26317
  const getComment = (commentId, callback) => {
27544
26318
  return liveObject(commentId, callback, 'commentId', getComment$1, [
27545
- onCommentApproved,
27546
26319
  onCommentDeleteLocal,
27547
26320
  onCommentDeleted,
27548
26321
  onCommentFlagged,
@@ -27556,31 +26329,28 @@ const getComment = (commentId, callback) => {
27556
26329
  };
27557
26330
  /* end_public_function */
27558
26331
 
27559
- /**
27560
- * ```js
27561
- * import { onCommentCreated } from '@amityco/ts-sdk'
27562
- * const dispose = onCommentCreated(comment => {
27563
- * // ...
27564
- * })
27565
- * ```
27566
- *
27567
- * Fired when a {@link Amity.InternalComment} has been created
27568
- *
27569
- * @param callback The function to call when the event was fired
27570
- * @returns an {@link Amity.Unsubscriber} function to stop listening
27571
- *
27572
- * @category Comment Events
27573
- */
27574
- const onCommentCreatedLocal = (callback) => {
27575
- return createLocalCommentEventSubscriber('local.comment.created', callback);
27576
- };
26332
+ class CommentPaginationController extends PaginationController {
26333
+ async getRequest(queryParams, token) {
26334
+ var _a;
26335
+ const { pageSize, limit, includeDeleted } = queryParams, params = __rest(queryParams, ["pageSize", "limit", "includeDeleted"]);
26336
+ const effectiveLimit = (_a = pageSize !== null && pageSize !== void 0 ? pageSize : limit) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT;
26337
+ const baseOptions = {
26338
+ type: params.sortBy || queryParams.limit || queryParams.pageSize ? 'pagination' : undefined,
26339
+ };
26340
+ const options = token
26341
+ ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { pageSize: effectiveLimit, limit: effectiveLimit });
26342
+ const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
26343
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
26344
+ });
26345
+ return queryResponse;
26346
+ }
26347
+ }
27577
26348
 
27578
26349
  var EnumCommentActions;
27579
26350
  (function (EnumCommentActions) {
27580
26351
  EnumCommentActions["OnCommentCreated"] = "onCommentCreated";
27581
26352
  EnumCommentActions["OnCommentUpdated"] = "onCommentUpdated";
27582
26353
  EnumCommentActions["OnCommentDeleted"] = "onCommentDeleted";
27583
- EnumCommentActions["OnCommentApproved"] = "onCommentApproved";
27584
26354
  EnumCommentActions["OnCommentFlagged"] = "onCommentFlagged";
27585
26355
  EnumCommentActions["OnCommentUnflagged"] = "onCommentUnflagged";
27586
26356
  EnumCommentActions["OnCommentReactionAdded"] = "onCommentReactionAdded";
@@ -27603,17 +26373,15 @@ class CommentQueryStreamController extends QueryStreamController {
27603
26373
  }
27604
26374
  appendToQueryStream(response, direction, refresh = false) {
27605
26375
  var _a, _b;
27606
- // The public list is approved-only even when the server widens the read for a reviewer
27607
- const commentIds = response.comments.filter(isCommentApproved).map(getResolver('comment'));
27608
26376
  if (refresh) {
27609
26377
  pushToCache(this.cacheKey, {
27610
- data: commentIds,
26378
+ data: response.comments.map(getResolver('comment')),
27611
26379
  });
27612
26380
  }
27613
26381
  else {
27614
26382
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27615
26383
  const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
27616
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...commentIds])] }));
26384
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...response.comments.map(getResolver('comment'))])] }));
27617
26385
  }
27618
26386
  }
27619
26387
  reactor(action) {
@@ -27632,19 +26400,8 @@ class CommentQueryStreamController extends QueryStreamController {
27632
26400
  return;
27633
26401
  }
27634
26402
  if (action === EnumCommentActions.OnCommentCreated) {
27635
- // A pending comment reaches clients over realtime before anyone may see it: persist
27636
- // only, no insert and no emit. `comment.approved` is the reveal signal.
27637
- if (!isCommentApproved(comment))
27638
- return;
27639
26403
  collection.data = [...new Set([comment.commentId, ...collection.data])];
27640
26404
  }
27641
- if (action === EnumCommentActions.OnCommentApproved) {
27642
- collection.data = [...new Set([comment.commentId, ...collection.data])];
27643
- }
27644
- // An effective edit in a gated community returns the comment to review: it leaves the list
27645
- if (action === EnumCommentActions.OnCommentUpdated && isCommentPending(comment)) {
27646
- collection.data = collection.data.filter(commentId => commentId !== comment.commentId);
27647
- }
27648
26405
  pushToCache(this.cacheKey, collection);
27649
26406
  this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
27650
26407
  };
@@ -27654,22 +26411,24 @@ class CommentQueryStreamController extends QueryStreamController {
27654
26411
  }
27655
26412
  }
27656
26413
 
27657
- class CommentPaginationController extends PaginationController {
27658
- async getRequest(queryParams, token) {
27659
- var _a;
27660
- const { pageSize, limit, includeDeleted } = queryParams, params = __rest(queryParams, ["pageSize", "limit", "includeDeleted"]);
27661
- const effectiveLimit = (_a = pageSize !== null && pageSize !== void 0 ? pageSize : limit) !== null && _a !== void 0 ? _a : COLLECTION_DEFAULT_PAGINATION_LIMIT;
27662
- const baseOptions = {
27663
- type: params.sortBy || queryParams.limit || queryParams.pageSize ? 'pagination' : undefined,
27664
- };
27665
- const options = token
27666
- ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { pageSize: effectiveLimit, limit: effectiveLimit });
27667
- const { data: queryResponse } = await this.http.get(`/api/v3/comments`, {
27668
- params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options }),
27669
- });
27670
- return queryResponse;
27671
- }
27672
- }
26414
+ /**
26415
+ * ```js
26416
+ * import { onCommentCreated } from '@amityco/ts-sdk'
26417
+ * const dispose = onCommentCreated(comment => {
26418
+ * // ...
26419
+ * })
26420
+ * ```
26421
+ *
26422
+ * Fired when a {@link Amity.InternalComment} has been created
26423
+ *
26424
+ * @param callback The function to call when the event was fired
26425
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26426
+ *
26427
+ * @category Comment Events
26428
+ */
26429
+ const onCommentCreatedLocal = (callback) => {
26430
+ return createLocalCommentEventSubscriber('local.comment.created', callback);
26431
+ };
27673
26432
 
27674
26433
  class CommentLiveCollectionController extends LiveCollectionController {
27675
26434
  constructor(query, callback) {
@@ -27705,7 +26464,6 @@ class CommentLiveCollectionController extends LiveCollectionController {
27705
26464
  { fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
27706
26465
  { fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
27707
26466
  { fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
27708
- { fn: onCommentApproved, action: EnumCommentActions.OnCommentApproved },
27709
26467
  { fn: onCommentFlagged, action: EnumCommentActions.OnCommentFlagged },
27710
26468
  { fn: onCommentUnflagged, action: EnumCommentActions.OnCommentUnflagged },
27711
26469
  { fn: onCommentReactionAdded, action: EnumCommentActions.OnCommentReactionAdded },
@@ -27739,8 +26497,7 @@ class CommentLiveCollectionController extends LiveCollectionController {
27739
26497
  });
27740
26498
  }
27741
26499
  applyFilter(data) {
27742
- // Approved-only, for every caller including the author of a pending comment
27743
- let comments = data.filter(isCommentApproved);
26500
+ let comments = data;
27744
26501
  if (!this.query.includeDeleted) {
27745
26502
  comments = filterByPropEquality(comments, 'isDeleted', false);
27746
26503
  }
@@ -27828,202 +26585,7 @@ const getComments = (params, callback, config) => {
27828
26585
  };
27829
26586
  /* end_public_function */
27830
26587
 
27831
- class CommentReviewQueuePaginationController extends PaginationController {
27832
- async getRequest(queryParams, token) {
27833
- const { communityId, limit } = queryParams, params = __rest(queryParams, ["communityId", "limit"]);
27834
- // The route defaults to 10, not the SDK-wide 20, and rejects anything above 100
27835
- const effectiveLimit = Math.min(limit !== null && limit !== void 0 ? limit : COMMENT_REVIEW_QUEUE_DEFAULT_PAGINATION_SIZE, COMMENT_REVIEW_QUEUE_MAX_PAGINATION_SIZE);
27836
- // Token paging only. The route also accepts options[skip], but offset paging over a queue that
27837
- // drains from the front skips items, so the SDK never sends it.
27838
- const options = token ? { token } : { limit: effectiveLimit };
27839
- const { data: queryResponse } = await this.http.get(API_ENDPOINTS.commentReviewQueue(communityId), {
27840
- params: Object.assign(Object.assign({}, params), { options }),
27841
- });
27842
- return queryResponse;
27843
- }
27844
- }
27845
-
27846
- class CommentReviewQueueQueryStreamController extends QueryStreamController {
27847
- constructor(query, cacheKey, notifyChange) {
27848
- super(query, cacheKey);
27849
- this.notifyChange = notifyChange;
27850
- }
27851
- async saveToMainDB(response) {
27852
- const processedPayload = prepareCommentPayload(response);
27853
- const client = getActiveClient();
27854
- const cachedAt = client.cache && Date.now();
27855
- if (client.cache) {
27856
- ingestInCache(processedPayload, { cachedAt });
27857
- }
27858
- }
27859
- appendToQueryStream(response, direction, refresh = false) {
27860
- var _a, _b;
27861
- // Server order is queue-entry order, oldest first. Keep it: later pages append, nothing
27862
- // re-sorts by createdAt (the two diverge on re-review).
27863
- const commentIds = response.comments.map(getResolver('comment'));
27864
- if (refresh) {
27865
- pushToCache(this.cacheKey, {
27866
- data: commentIds,
27867
- });
27868
- }
27869
- else {
27870
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27871
- const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
27872
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...comments, ...commentIds])] }));
27873
- }
27874
- }
27875
- matchesQuery(comment) {
27876
- return (comment.targetType === 'community' &&
27877
- comment.targetId === this.query.communityId &&
27878
- (!this.query.postId || comment.referenceId === this.query.postId));
27879
- }
27880
- reactor(action) {
27881
- return (comment) => {
27882
- var _a;
27883
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27884
- if (!collection || !this.matchesQuery(comment))
27885
- return;
27886
- const isQueued = collection.data.includes(comment.commentId);
27887
- // A date-filtered queue is the server's to shape; live events only remove from it
27888
- const acceptsLiveInserts = !this.query.startDate && !this.query.endDate;
27889
- switch (action) {
27890
- case EnumCommentActions.OnCommentCreated:
27891
- case EnumCommentActions.OnCommentUpdated:
27892
- if (isCommentPending(comment) && !comment.isDeleted) {
27893
- if (isQueued || !acceptsLiveInserts)
27894
- return;
27895
- // Enters (or, after an edit, re-enters) the queue at the end
27896
- collection.data = [...collection.data, comment.commentId];
27897
- }
27898
- else {
27899
- if (!isQueued)
27900
- return;
27901
- collection.data = collection.data.filter(commentId => commentId !== comment.commentId);
27902
- }
27903
- break;
27904
- case EnumCommentActions.OnCommentApproved:
27905
- case EnumCommentActions.OnCommentDeleted:
27906
- if (!isQueued)
27907
- return;
27908
- collection.data = collection.data.filter(commentId => commentId !== comment.commentId);
27909
- break;
27910
- default:
27911
- return;
27912
- }
27913
- pushToCache(this.cacheKey, collection);
27914
- this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
27915
- };
27916
- }
27917
- subscribeRTE(createSubscriber) {
27918
- return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
27919
- }
27920
- }
27921
-
27922
- class CommentReviewQueueLiveCollectionController extends LiveCollectionController {
27923
- constructor(query, callback) {
27924
- const queryStreamId = hash__default["default"](query);
27925
- const cacheKey = ['commentReviewQueue', 'collection', queryStreamId];
27926
- const paginationController = new CommentReviewQueuePaginationController(query);
27927
- super(paginationController, queryStreamId, cacheKey, callback);
27928
- this.query = query;
27929
- this.queryStreamController = new CommentReviewQueueQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
27930
- this.callback = callback.bind(this);
27931
- this.loadPage({ initial: true });
27932
- }
27933
- setup() {
27934
- var _a;
27935
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27936
- if (!collection) {
27937
- pushToCache(this.cacheKey, {
27938
- data: [],
27939
- params: {},
27940
- });
27941
- }
27942
- }
27943
- async persistModel(queryPayload) {
27944
- await this.queryStreamController.saveToMainDB(queryPayload);
27945
- }
27946
- persistQueryStream({ response, direction, refresh, }) {
27947
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
27948
- }
27949
- startSubscription() {
27950
- // No `comment.declined` exists: a decline arrives as `comment.deleted`
27951
- return this.queryStreamController.subscribeRTE([
27952
- { fn: onCommentCreated, action: EnumCommentActions.OnCommentCreated },
27953
- { fn: onCommentUpdated, action: EnumCommentActions.OnCommentUpdated },
27954
- { fn: onCommentApproved, action: EnumCommentActions.OnCommentApproved },
27955
- { fn: onCommentDeleted, action: EnumCommentActions.OnCommentDeleted },
27956
- { fn: onCommentDeleteLocal, action: EnumCommentActions.OnCommentDeleted },
27957
- ]);
27958
- }
27959
- notifyChange({ origin, loading, error }) {
27960
- var _a;
27961
- // A caller who lost REVIEW_COMMUNITY_COMMENT must not keep reading stale pending content
27962
- if ((error === null || error === void 0 ? void 0 : error.code) === 400301 /* Amity.ServerError.PERMISSION_DENIED */) {
27963
- pushToCache(this.cacheKey, { data: [], params: {} });
27964
- }
27965
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27966
- if (!collection)
27967
- return;
27968
- const data = collection.data
27969
- .map(id => pullFromCache(['comment', 'get', id]))
27970
- .filter(isNonNullable)
27971
- .map(({ data }) => data)
27972
- .filter(comment => isCommentPending(comment) && !comment.isDeleted)
27973
- .map(LinkedObject.comment);
27974
- if (!this.shouldNotify(data) && origin === 'event')
27975
- return;
27976
- this.callback({
27977
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
27978
- data,
27979
- hasNextPage: !!this.paginationController.getNextToken(),
27980
- loading,
27981
- error,
27982
- });
27983
- }
27984
- }
27985
-
27986
- /* begin_public_function
27987
- id: comment.review_queue
27988
- */
27989
- /**
27990
- * ```js
27991
- * import { CommentRepository } from '@amityco/ts-sdk'
27992
- *
27993
- * const unsub = CommentRepository.getCommentReviewQueue(
27994
- * { communityId: 'communityId' },
27995
- * ({ data: comments, hasNextPage, onNextPage }) => {
27996
- * // every comment is awaiting review
27997
- * },
27998
- * )
27999
- * ```
28000
- *
28001
- * Observe the {@link Amity.Comment} list awaiting moderator review in a community, oldest first
28002
- *
28003
- * @param params the community to read the queue of, optionally narrowed to one post and a date range
28004
- * @param callback the function to call when new data are available
28005
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the queue
28006
- *
28007
- * @category Comments Live Collection
28008
- */
28009
- const getCommentReviewQueue = (params, callback) => {
28010
- const { log, cache } = getActiveClient();
28011
- if (!cache)
28012
- console.log(ENABLE_CACHE_MESSAGE);
28013
- const timestamp = Date.now();
28014
- log(`getCommentReviewQueue(tmpid: ${timestamp}) > listen`);
28015
- const commentReviewQueueLiveCollection = new CommentReviewQueueLiveCollectionController(params, callback);
28016
- const disposers = commentReviewQueueLiveCollection.startSubscription();
28017
- const cacheKey = commentReviewQueueLiveCollection.getCacheKey();
28018
- disposers.push(() => dropFromCache(cacheKey));
28019
- return () => {
28020
- log(`getCommentReviewQueue(tmpid: ${timestamp}) > dispose`);
28021
- disposers.forEach(fn => fn());
28022
- };
28023
- };
28024
- /* end_public_function */
28025
-
28026
- var index$f = /*#__PURE__*/Object.freeze({
26588
+ var index$e = /*#__PURE__*/Object.freeze({
28027
26589
  __proto__: null,
28028
26590
  getCommentByIds: getCommentByIds,
28029
26591
  createComment: createComment,
@@ -28031,22 +26593,18 @@ var index$f = /*#__PURE__*/Object.freeze({
28031
26593
  deleteComment: deleteComment,
28032
26594
  softDeleteComment: softDeleteComment,
28033
26595
  hardDeleteComment: hardDeleteComment,
28034
- approveComment: approveComment,
28035
- declineComment: declineComment,
28036
26596
  flagComment: flagComment,
28037
26597
  unflagComment: unflagComment,
28038
26598
  isCommentFlaggedByMe: isCommentFlaggedByMe,
28039
26599
  onCommentCreated: onCommentCreated,
28040
26600
  onCommentUpdated: onCommentUpdated,
28041
26601
  onCommentDeleted: onCommentDeleted,
28042
- onCommentApproved: onCommentApproved,
28043
26602
  onCommentFlagged: onCommentFlagged,
28044
26603
  onCommentUnflagged: onCommentUnflagged,
28045
26604
  onCommentReactionAdded: onCommentReactionAdded,
28046
26605
  onCommentReactionRemoved: onCommentReactionRemoved,
28047
26606
  getComment: getComment,
28048
- getComments: getComments,
28049
- getCommentReviewQueue: getCommentReviewQueue
26607
+ getComments: getComments
28050
26608
  });
28051
26609
 
28052
26610
  /**
@@ -29296,7 +27854,7 @@ const getForYouFeed = (callback) => {
29296
27854
  };
29297
27855
  /* end_public_function */
29298
27856
 
29299
- var index$e = /*#__PURE__*/Object.freeze({
27857
+ var index$d = /*#__PURE__*/Object.freeze({
29300
27858
  __proto__: null,
29301
27859
  queryGlobalFeed: queryGlobalFeed,
29302
27860
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -32441,7 +30999,7 @@ const getRooms = (params, callback, config) => {
32441
30999
  };
32442
31000
  /* end_public_function */
32443
31001
 
32444
- var index$d = /*#__PURE__*/Object.freeze({
31002
+ var index$c = /*#__PURE__*/Object.freeze({
32445
31003
  __proto__: null,
32446
31004
  createRoom: createRoom,
32447
31005
  updateRoom: updateRoom,
@@ -32740,7 +31298,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
32740
31298
  };
32741
31299
  /* end_public_function */
32742
31300
 
32743
- var index$c = /*#__PURE__*/Object.freeze({
31301
+ var index$b = /*#__PURE__*/Object.freeze({
32744
31302
  __proto__: null,
32745
31303
  getPostByIds: getPostByIds,
32746
31304
  createPost: createPost,
@@ -33355,7 +31913,7 @@ const getStreams = (params, callback, config) => {
33355
31913
  };
33356
31914
  };
33357
31915
 
33358
- var index$b = /*#__PURE__*/Object.freeze({
31916
+ var index$a = /*#__PURE__*/Object.freeze({
33359
31917
  __proto__: null,
33360
31918
  createStream: createStream,
33361
31919
  updateStream: updateStream,
@@ -33658,7 +32216,7 @@ const stopHeartbeat = (roomId) => {
33658
32216
  };
33659
32217
  /* end_public_function */
33660
32218
 
33661
- var index$a = /*#__PURE__*/Object.freeze({
32219
+ var index$9 = /*#__PURE__*/Object.freeze({
33662
32220
  __proto__: null,
33663
32221
  getRoomOnlineUsers: getRoomOnlineUsers,
33664
32222
  getRoomUserCount: getRoomUserCount,
@@ -33969,7 +32527,7 @@ const getPoll = (pollId, callback) => {
33969
32527
  };
33970
32528
  /* end_public_function */
33971
32529
 
33972
- var index$9 = /*#__PURE__*/Object.freeze({
32530
+ var index$8 = /*#__PURE__*/Object.freeze({
33973
32531
  __proto__: null,
33974
32532
  createPoll: createPoll,
33975
32533
  closePoll: closePoll,
@@ -34273,7 +32831,7 @@ const getPlayer = async (parameters) => {
34273
32831
  return video;
34274
32832
  };
34275
32833
 
34276
- var index$8 = /*#__PURE__*/Object.freeze({
32834
+ var index$7 = /*#__PURE__*/Object.freeze({
34277
32835
  __proto__: null,
34278
32836
  getPlayer: getPlayer
34279
32837
  });
@@ -35446,7 +34004,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
35446
34004
  };
35447
34005
  };
35448
34006
 
35449
- var index$7 = /*#__PURE__*/Object.freeze({
34007
+ var index$6 = /*#__PURE__*/Object.freeze({
35450
34008
  __proto__: null,
35451
34009
  createImageStory: createImageStory,
35452
34010
  createVideoStory: createVideoStory,
@@ -35483,7 +34041,7 @@ const getNetworkAds = async () => {
35483
34041
  };
35484
34042
  };
35485
34043
 
35486
- var index$6 = /*#__PURE__*/Object.freeze({
34044
+ var index$5 = /*#__PURE__*/Object.freeze({
35487
34045
  __proto__: null,
35488
34046
  getNetworkAds: getNetworkAds
35489
34047
  });
@@ -35874,7 +34432,7 @@ const markTraySeen = async (lastSeenAt) => {
35874
34432
  };
35875
34433
  /* end_public_function */
35876
34434
 
35877
- var index$5 = /*#__PURE__*/Object.freeze({
34435
+ var index$4 = /*#__PURE__*/Object.freeze({
35878
34436
  __proto__: null,
35879
34437
  getNotificationTraySeen: getNotificationTraySeen,
35880
34438
  getNotificationTrayItems: getNotificationTrayItems,
@@ -36176,7 +34734,7 @@ const getInvitations = (params, callback) => {
36176
34734
  };
36177
34735
  };
36178
34736
 
36179
- var index$4 = /*#__PURE__*/Object.freeze({
34737
+ var index$3 = /*#__PURE__*/Object.freeze({
36180
34738
  __proto__: null,
36181
34739
  cancelInvitation: cancelInvitation,
36182
34740
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -36325,7 +34883,7 @@ const getReactions = (postId, callback) => {
36325
34883
  };
36326
34884
  };
36327
34885
 
36328
- var index$3 = /*#__PURE__*/Object.freeze({
34886
+ var index$2 = /*#__PURE__*/Object.freeze({
36329
34887
  __proto__: null,
36330
34888
  createReaction: createReaction,
36331
34889
  onLiveReactionCreated: onLiveReactionCreated,
@@ -36808,7 +35366,7 @@ const getMyEvents = (params, callback, config) => {
36808
35366
  };
36809
35367
  };
36810
35368
 
36811
- var index$2 = /*#__PURE__*/Object.freeze({
35369
+ var index$1 = /*#__PURE__*/Object.freeze({
36812
35370
  __proto__: null,
36813
35371
  createEvent: createEvent,
36814
35372
  updateEvent: updateEvent,
@@ -37035,36 +35593,12 @@ const searchProducts = (params, callback, config) => {
37035
35593
  };
37036
35594
  /* end_public_function */
37037
35595
 
37038
- var index$1 = /*#__PURE__*/Object.freeze({
35596
+ var index = /*#__PURE__*/Object.freeze({
37039
35597
  __proto__: null,
37040
35598
  getProduct: getProduct,
37041
35599
  searchProducts: searchProducts
37042
35600
  });
37043
35601
 
37044
- const getPool = async (topicId, limit) => {
37045
- const client = getActiveClient();
37046
- if (!topicId)
37047
- throw new ASCError('topicId must not be empty', 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
37048
- if (limit !== undefined && (limit < 1 || limit > 100))
37049
- throw new ASCError('limit must be between 1 and 100', 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
37050
- const { data } = await client.http.get('/api/v5/curated-content/pool', { params: { topicId, limit } });
37051
- const { topic } = data, payload = __rest(data, ["topic"]);
37052
- const processedPayload = preparePostPayload(payload);
37053
- const cachedAt = client.cache && Date.now();
37054
- if (client.cache) {
37055
- ingestInCache(processedPayload, { cachedAt });
37056
- }
37057
- return {
37058
- topic: LinkedObject.curatedContentTopic(topic),
37059
- posts: processedPayload.posts.map(LinkedObject.post),
37060
- };
37061
- };
37062
-
37063
- var index = /*#__PURE__*/Object.freeze({
37064
- __proto__: null,
37065
- getPool: getPool
37066
- });
37067
-
37068
35602
  /**
37069
35603
  * Helper class for managing product tags per media attachment.
37070
35604
  *
@@ -37113,41 +35647,39 @@ class AmityAttachmentProductTags {
37113
35647
  }
37114
35648
 
37115
35649
  exports.API_REGIONS = API_REGIONS;
37116
- exports.AdRepository = index$6;
35650
+ exports.AdRepository = index$5;
37117
35651
  exports.AmityAttachmentProductTags = AmityAttachmentProductTags;
37118
- exports.AmityModuleNotEntitledError = AmityModuleNotEntitledError;
37119
- exports.CategoryRepository = index$g;
37120
- exports.ChannelRepository = index$k;
37121
- exports.Client = index$t;
37122
- exports.CommentRepository = index$f;
35652
+ exports.CategoryRepository = index$f;
35653
+ exports.ChannelRepository = index$j;
35654
+ exports.Client = index$s;
35655
+ exports.CommentRepository = index$e;
37123
35656
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
37124
35657
  exports.CommunityPostSettings = CommunityPostSettings;
37125
- exports.CommunityRepository = index$h;
35658
+ exports.CommunityRepository = index$g;
37126
35659
  exports.ContentFeedType = ContentFeedType;
37127
- exports.CuratedContentRepository = index;
37128
35660
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
37129
- exports.EventRepository = index$2;
37130
- exports.FeedRepository = index$e;
37131
- exports.FileRepository = index$q;
35661
+ exports.EventRepository = index$1;
35662
+ exports.FeedRepository = index$d;
35663
+ exports.FileRepository = index$p;
37132
35664
  exports.FileType = FileType;
37133
35665
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
37134
- exports.InvitationRepository = index$4;
37135
- exports.LiveReactionRepository = index$3;
37136
- exports.LiveStreamPlayer = index$8;
35666
+ exports.InvitationRepository = index$3;
35667
+ exports.LiveReactionRepository = index$2;
35668
+ exports.LiveStreamPlayer = index$7;
37137
35669
  exports.MessageContentType = MessageContentType;
37138
- exports.MessageRepository = index$o;
37139
- exports.PollRepository = index$9;
35670
+ exports.MessageRepository = index$n;
35671
+ exports.PollRepository = index$8;
37140
35672
  exports.PostContentType = PostContentType;
37141
- exports.PostRepository = index$c;
35673
+ exports.PostRepository = index$b;
37142
35674
  exports.PostStructureType = PostStructureType;
37143
- exports.ProductRepository = index$1;
37144
- exports.ReactionRepository = index$p;
37145
- exports.RoomPresenceRepository = index$a;
37146
- exports.RoomRepository = index$d;
37147
- exports.StoryRepository = index$7;
37148
- exports.StreamRepository = index$b;
37149
- exports.SubChannelRepository = index$n;
37150
- exports.UserRepository = index$r;
35675
+ exports.ProductRepository = index;
35676
+ exports.ReactionRepository = index$o;
35677
+ exports.RoomPresenceRepository = index$9;
35678
+ exports.RoomRepository = index$c;
35679
+ exports.StoryRepository = index$6;
35680
+ exports.StreamRepository = index$a;
35681
+ exports.SubChannelRepository = index$m;
35682
+ exports.UserRepository = index$q;
37151
35683
  exports.VERSION = VERSION;
37152
35684
  exports.VideoResolution = VideoResolution;
37153
35685
  exports.VideoSize = VideoSize;
@@ -37209,7 +35741,7 @@ exports.isPaged = isPaged;
37209
35741
  exports.isReportedByMe = isReportedByMe;
37210
35742
  exports.isSkip = isSkip;
37211
35743
  exports.mergeInCache = mergeInCache;
37212
- exports.notificationTray = index$5;
35744
+ exports.notificationTray = index$4;
37213
35745
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
37214
35746
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
37215
35747
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;
@@ -37224,7 +35756,6 @@ exports.pushToCache = pushToCache;
37224
35756
  exports.queryCache = queryCache;
37225
35757
  exports.queryOptions = queryOptions;
37226
35758
  exports.queryRoles = queryRoles;
37227
- exports.resolveModuleAvailability = resolveModuleAvailability;
37228
35759
  exports.restoreCache = restoreCache;
37229
35760
  exports.runQuery = runQuery;
37230
35761
  exports.sortByChannelSegment = sortByChannelSegment;