@amityco/ts-sdk-react-native 7.15.2-9c10dc7b.0 → 7.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/@types/core/events.d.ts +2 -1
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +2 -0
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +5 -0
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/analytics.d.ts +2 -1
  8. package/dist/@types/domains/analytics.d.ts.map +1 -1
  9. package/dist/@types/domains/client.d.ts +6 -0
  10. package/dist/@types/domains/client.d.ts.map +1 -1
  11. package/dist/@types/domains/feed.d.ts +2 -0
  12. package/dist/@types/domains/feed.d.ts.map +1 -1
  13. package/dist/@types/domains/notification.d.ts +4 -2
  14. package/dist/@types/domains/notification.d.ts.map +1 -1
  15. package/dist/@types/domains/post.d.ts +5 -1
  16. package/dist/@types/domains/post.d.ts.map +1 -1
  17. package/dist/@types/domains/product.d.ts +93 -0
  18. package/dist/@types/domains/product.d.ts.map +1 -0
  19. package/dist/@types/domains/room.d.ts +2 -1
  20. package/dist/@types/domains/room.d.ts.map +1 -1
  21. package/dist/@types/domains/stream.d.ts +2 -1
  22. package/dist/@types/domains/stream.d.ts.map +1 -1
  23. package/dist/@types/index.d.ts +1 -0
  24. package/dist/@types/index.d.ts.map +1 -1
  25. package/dist/analytic/service/analytic/AnalyticsEngine.d.ts +2 -0
  26. package/dist/analytic/service/analytic/AnalyticsEngine.d.ts.map +1 -1
  27. package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts +2 -0
  28. package/dist/analytic/service/analytic/AnalyticsEventCapturer.d.ts.map +1 -1
  29. package/dist/analytic/service/analytic/AnalyticsService.d.ts +12 -0
  30. package/dist/analytic/service/analytic/AnalyticsService.d.ts.map +1 -1
  31. package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
  32. package/dist/channelRepository/events/index.d.ts +0 -1
  33. package/dist/channelRepository/events/index.d.ts.map +1 -1
  34. package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
  35. package/dist/client/api/createClient.d.ts.map +1 -1
  36. package/dist/client/api/getProductCatalogueSetting.d.ts +15 -0
  37. package/dist/client/api/getProductCatalogueSetting.d.ts.map +1 -0
  38. package/dist/client/api/index.d.ts +1 -0
  39. package/dist/client/api/index.d.ts.map +1 -1
  40. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  41. package/dist/core/events.d.ts +3 -3
  42. package/dist/core/events.d.ts.map +1 -1
  43. package/dist/core/model/idResolvers.d.ts.map +1 -1
  44. package/dist/core/model/index.d.ts.map +1 -1
  45. package/dist/core/query/sorting.d.ts +23 -0
  46. package/dist/core/query/sorting.d.ts.map +1 -1
  47. package/dist/core/subscription.d.ts +2 -2
  48. package/dist/core/subscription.d.ts.map +1 -1
  49. package/dist/feedRepository/observers/getCommunityFeed/LiveCollectionController.d.ts +1 -0
  50. package/dist/feedRepository/observers/getCommunityFeed/LiveCollectionController.d.ts.map +1 -1
  51. package/dist/feedRepository/observers/getCommunityFeed/PaginationController.d.ts.map +1 -1
  52. package/dist/feedRepository/observers/getCommunityFeed/QueryStreamController.d.ts +3 -0
  53. package/dist/feedRepository/observers/getCommunityFeed/QueryStreamController.d.ts.map +1 -1
  54. package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts +1 -0
  55. package/dist/feedRepository/observers/getUserFeed/LiveCollectionController.d.ts.map +1 -1
  56. package/dist/feedRepository/observers/getUserFeed/PaginationController.d.ts.map +1 -1
  57. package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts +3 -0
  58. package/dist/feedRepository/observers/getUserFeed/QueryStreamController.d.ts.map +1 -1
  59. package/dist/fileRepository/api/uploadAudio.d.ts.map +1 -1
  60. package/dist/index.cjs.js +975 -110
  61. package/dist/index.d.ts +2 -0
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.esm.js +948 -88
  64. package/dist/index.umd.js +3 -3
  65. package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +1 -1
  66. package/dist/postRepository/api/createAudioPost.d.ts +2 -0
  67. package/dist/postRepository/api/createAudioPost.d.ts.map +1 -1
  68. package/dist/postRepository/api/createClipPost.d.ts +2 -0
  69. package/dist/postRepository/api/createClipPost.d.ts.map +1 -1
  70. package/dist/postRepository/api/createMixedMediaPost.d.ts +2 -0
  71. package/dist/postRepository/api/createMixedMediaPost.d.ts.map +1 -1
  72. package/dist/postRepository/api/createPost.d.ts +3 -0
  73. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  74. package/dist/postRepository/api/createRoomPost.d.ts +29 -0
  75. package/dist/postRepository/api/createRoomPost.d.ts.map +1 -0
  76. package/dist/postRepository/api/editPost.d.ts +3 -0
  77. package/dist/postRepository/api/editPost.d.ts.map +1 -1
  78. package/dist/postRepository/api/getPost.d.ts +1 -1
  79. package/dist/postRepository/api/index.d.ts +4 -0
  80. package/dist/postRepository/api/index.d.ts.map +1 -1
  81. package/dist/postRepository/api/pinProduct.d.ts +15 -0
  82. package/dist/postRepository/api/pinProduct.d.ts.map +1 -0
  83. package/dist/postRepository/api/tests/integration/createPost.integration.test.d.ts +2 -0
  84. package/dist/postRepository/api/tests/integration/createPost.integration.test.d.ts.map +1 -0
  85. package/dist/postRepository/api/tests/integration/getPost.integration.test.d.ts +2 -0
  86. package/dist/postRepository/api/tests/integration/getPost.integration.test.d.ts.map +1 -0
  87. package/dist/postRepository/api/tests/integration/getPosts.integration.test.d.ts +2 -0
  88. package/dist/postRepository/api/tests/integration/getPosts.integration.test.d.ts.map +1 -0
  89. package/dist/postRepository/api/tests/integration/setup.d.ts +64 -0
  90. package/dist/postRepository/api/tests/integration/setup.d.ts.map +1 -0
  91. package/dist/postRepository/api/unpinProduct.d.ts +14 -0
  92. package/dist/postRepository/api/unpinProduct.d.ts.map +1 -0
  93. package/dist/postRepository/api/updateProductTags.d.ts +15 -0
  94. package/dist/postRepository/api/updateProductTags.d.ts.map +1 -0
  95. package/dist/postRepository/observers/enums.d.ts +4 -1
  96. package/dist/postRepository/observers/enums.d.ts.map +1 -1
  97. package/dist/postRepository/observers/getPosts/PostLiveCollectionController.d.ts.map +1 -1
  98. package/dist/postRepository/observers/getPosts/PostPaginationController.d.ts.map +1 -1
  99. package/dist/postRepository/observers/getPosts/PostQueryStreamController.d.ts +3 -0
  100. package/dist/postRepository/observers/getPosts/PostQueryStreamController.d.ts.map +1 -1
  101. package/dist/postRepository/utils/payload.d.ts.map +1 -1
  102. package/dist/productRepository/helpers/AttachmentProductTags.d.ts +41 -0
  103. package/dist/productRepository/helpers/AttachmentProductTags.d.ts.map +1 -0
  104. package/dist/productRepository/helpers/index.d.ts +2 -0
  105. package/dist/productRepository/helpers/index.d.ts.map +1 -0
  106. package/dist/productRepository/index.d.ts +2 -0
  107. package/dist/productRepository/index.d.ts.map +1 -0
  108. package/dist/productRepository/internalApi/getProduct.d.ts +5 -0
  109. package/dist/productRepository/internalApi/getProduct.d.ts.map +1 -0
  110. package/dist/productRepository/internalApi/index.d.ts +2 -0
  111. package/dist/productRepository/internalApi/index.d.ts.map +1 -0
  112. package/dist/productRepository/observers/getProduct.d.ts +21 -0
  113. package/dist/productRepository/observers/getProduct.d.ts.map +1 -0
  114. package/dist/productRepository/observers/index.d.ts +3 -0
  115. package/dist/productRepository/observers/index.d.ts.map +1 -0
  116. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts +15 -0
  117. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts.map +1 -0
  118. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts +5 -0
  119. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts.map +1 -0
  120. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts +8 -0
  121. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts.map +1 -0
  122. package/dist/productRepository/observers/searchProducts.d.ts +25 -0
  123. package/dist/productRepository/observers/searchProducts.d.ts.map +1 -0
  124. package/dist/productRepository/tests/integration/getProduct.integration.test.d.ts +2 -0
  125. package/dist/productRepository/tests/integration/getProduct.integration.test.d.ts.map +1 -0
  126. package/dist/productRepository/tests/integration/searchProducts.integration.test.d.ts +2 -0
  127. package/dist/productRepository/tests/integration/searchProducts.integration.test.d.ts.map +1 -0
  128. package/dist/productRepository/tests/integration/setup.d.ts +11 -0
  129. package/dist/productRepository/tests/integration/setup.d.ts.map +1 -0
  130. package/dist/roomRepository/api/index.d.ts +1 -0
  131. package/dist/roomRepository/api/index.d.ts.map +1 -1
  132. package/dist/roomRepository/api/updateCohostPermission.d.ts +18 -0
  133. package/dist/roomRepository/api/updateCohostPermission.d.ts.map +1 -0
  134. package/dist/roomRepository/events/index.d.ts +2 -0
  135. package/dist/roomRepository/events/index.d.ts.map +1 -1
  136. package/dist/roomRepository/events/onLocalRoomDidUpdate.d.ts +17 -0
  137. package/dist/roomRepository/events/onLocalRoomDidUpdate.d.ts.map +1 -0
  138. package/dist/roomRepository/events/onRoomDidUpdate.d.ts +17 -0
  139. package/dist/roomRepository/events/onRoomDidUpdate.d.ts.map +1 -0
  140. package/dist/roomRepository/observers/enums.d.ts +2 -1
  141. package/dist/roomRepository/observers/enums.d.ts.map +1 -1
  142. package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
  143. package/dist/roomRepository/observers/utils.d.ts.map +1 -1
  144. package/dist/utils/linkedObject/index.d.ts +1 -0
  145. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  146. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  147. package/dist/utils/linkedObject/productLinkedObject.d.ts +2 -0
  148. package/dist/utils/linkedObject/productLinkedObject.d.ts.map +1 -0
  149. package/dist/utils/linkedObject/productTagLinkedObject.d.ts +2 -0
  150. package/dist/utils/linkedObject/productTagLinkedObject.d.ts.map +1 -0
  151. package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
  152. package/dist/utils/tests/dummy/comment.d.ts.map +1 -1
  153. package/dist/utils/tests/dummy/file.d.ts.map +1 -1
  154. package/dist/utils/tests/dummy/member.d.ts.map +1 -1
  155. package/dist/utils/tests/dummy/post.d.ts +4 -0
  156. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  157. package/dist/utils/tests/dummy/user.d.ts.map +1 -1
  158. package/package.json +4 -2
  159. package/dist/channelRepository/events/onChannelCreatedLocal.d.ts +0 -2
  160. package/dist/channelRepository/events/onChannelCreatedLocal.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -270,10 +270,16 @@ exports.AmityEventOrderOption = void 0;
270
270
  AmityEventOrderOption["Descending"] = "desc";
271
271
  })(exports.AmityEventOrderOption || (exports.AmityEventOrderOption = {}));
272
272
 
273
+ exports.AnalyticsSourceTypeEnum = void 0;
274
+ (function (AnalyticsSourceTypeEnum) {
275
+ AnalyticsSourceTypeEnum["POST"] = "post";
276
+ AnalyticsSourceTypeEnum["ROOM"] = "room";
277
+ })(exports.AnalyticsSourceTypeEnum || (exports.AnalyticsSourceTypeEnum = {}));
278
+
273
279
  function getVersion() {
274
280
  try {
275
- // the string ''v7.15.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
276
- return 'v7.15.1-cjs';
281
+ // the string ''v7.16.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
282
+ return 'v7.16.0-cjs';
277
283
  }
278
284
  catch (error) {
279
285
  return '__dev__';
@@ -722,6 +728,7 @@ const idResolvers = {
722
728
  viewer: ({ userId }) => userId,
723
729
  event: ({ eventId }) => eventId,
724
730
  eventResponse: ({ userId }) => userId,
731
+ product: ({ productId }) => productId,
725
732
  };
726
733
  /**
727
734
  * Retrieve the id resolver matching a domain name
@@ -781,6 +788,7 @@ const PAYLOAD2MODEL = {
781
788
  events: 'event',
782
789
  viewers: 'viewer',
783
790
  eventResponses: 'eventResponse',
791
+ products: 'product',
784
792
  };
785
793
  /** hidden */
786
794
  const isOutdated = (prevData, nextData) => {
@@ -1457,6 +1465,54 @@ const sortByLastUpdated = ({ updatedAt: a = 0 }, { updatedAt: b = 0 }) => new Da
1457
1465
  * Sorting a collection by the items with most recent activity
1458
1466
  */
1459
1467
  const sortByLastActivity = ({ lastActivity: a }, { lastActivity: b }) => new Date(b).valueOf() - new Date(a).valueOf();
1468
+ /**
1469
+ * Filter items by untilAt timestamp based on sort direction
1470
+ * - For 'lastCreated' (newest first): untilAt acts as lower bound, excludes items older than boundary
1471
+ * - For 'firstCreated' (oldest first): untilAt acts as upper bound, excludes items newer than boundary
1472
+ * - Comparison is exclusive: posts with createdAt === untilAt are excluded
1473
+ */
1474
+ const filterByUntilAt = (items, untilAt, sortBy) => {
1475
+ const untilAtTimestamp = new Date(untilAt).valueOf();
1476
+ if (sortBy === 'firstCreated') {
1477
+ // For oldest first: exclude posts newer than boundary (keep posts where createdAt < untilAt)
1478
+ return items.filter(item => new Date(item.createdAt).valueOf() < untilAtTimestamp);
1479
+ }
1480
+ // For newest first: exclude posts older than boundary (keep posts where createdAt > untilAt)
1481
+ return items.filter(item => new Date(item.createdAt).valueOf() > untilAtTimestamp);
1482
+ };
1483
+ /**
1484
+ * Validates untilAt parameter and returns undefined if invalid
1485
+ * @param untilAt - The untilAt value to validate
1486
+ * @returns The validated untilAt value or undefined if invalid
1487
+ */
1488
+ const validateUntilAt = (untilAt) => {
1489
+ if (untilAt === undefined)
1490
+ return undefined;
1491
+ // Check if the value is an Invalid Date
1492
+ const timestamp = new Date(untilAt).valueOf();
1493
+ if (Number.isNaN(timestamp)) {
1494
+ console.warn('untilAt is an invalid Date — ignoring, pagination will not be bounded');
1495
+ return undefined;
1496
+ }
1497
+ return untilAt;
1498
+ };
1499
+ /**
1500
+ * Checks if a post should be excluded based on untilAt boundary
1501
+ * @param createdAt - The post's createdAt timestamp
1502
+ * @param untilAt - The untilAt boundary
1503
+ * @param sortBy - The sort direction
1504
+ * @returns true if the post exceeds the boundary (should be excluded)
1505
+ */
1506
+ const exceedsUntilAtBoundary = (createdAt, untilAt, sortBy) => {
1507
+ const createdAtTimestamp = new Date(createdAt).valueOf();
1508
+ const untilAtTimestamp = new Date(untilAt).valueOf();
1509
+ if (sortBy === 'firstCreated') {
1510
+ // For oldest first: exceeds if createdAt >= untilAt
1511
+ return createdAtTimestamp >= untilAtTimestamp;
1512
+ }
1513
+ // For newest first: exceeds if createdAt <= untilAt
1514
+ return createdAtTimestamp <= untilAtTimestamp;
1515
+ };
1460
1516
 
1461
1517
  let activeUser = null;
1462
1518
  /* begin_public_function
@@ -1727,14 +1783,10 @@ const getLiveReactionTopic = (post) => {
1727
1783
  };
1728
1784
  const getRoomWatcherTopic = (room) => {
1729
1785
  const user = getCurrentUser();
1730
- if (!user)
1731
- return;
1732
1786
  return `${getNetworkId(user)}/room/${room._id}`;
1733
1787
  };
1734
1788
  const getRoomStreamerTopic = (room) => {
1735
1789
  const user = getCurrentUser();
1736
- if (!user)
1737
- return;
1738
1790
  return `${getNetworkId(user)}/room/${room.roomId}/streamer`;
1739
1791
  };
1740
1792
  function subscribeTopic(topic, callback) {
@@ -6350,11 +6402,6 @@ const onChannelCreated = (callback) => {
6350
6402
  return () => dispose$c(callback);
6351
6403
  };
6352
6404
 
6353
- const onChannelCreatedLocal = (callback) => {
6354
- const client = getActiveClient();
6355
- return createEventSubscriber(client, 'onChannelCreatedLocal', 'local.channel.created', callback);
6356
- };
6357
-
6358
6405
  const callbacks$b = [];
6359
6406
  const mainDisposers = [];
6360
6407
  const dispose$b = (cb) => {
@@ -7223,6 +7270,29 @@ const getSocialSettings = async () => {
7223
7270
  return data.socialNetworkSetting;
7224
7271
  };
7225
7272
 
7273
+ /* begin_public_function
7274
+ id: client.getProductCatalogueSetting
7275
+ */
7276
+ /**
7277
+ * ```js
7278
+ * import { getProductCatalogueSetting } from '@amityco/ts-sdk'
7279
+ * const productCatalogueSetting = await getProductCatalogueSetting()
7280
+ * ```
7281
+ *
7282
+ * Fetches a {@link Amity.ProductCatalogueSetting} object
7283
+ *
7284
+ * @returns A Promise of {@link Amity.ProductCatalogueSetting} object
7285
+ *
7286
+ * @category Client API
7287
+ * @async
7288
+ */
7289
+ const getProductCatalogueSetting = async () => {
7290
+ const client = getActiveClient();
7291
+ const { data } = await client.http.get(`/api/v3/network-settings/product`);
7292
+ return data;
7293
+ };
7294
+ /* end_public_function */
7295
+
7226
7296
  const checkUserPermission = (userId, permission) => {
7227
7297
  var _a;
7228
7298
  const user = (_a = pullFromCache(['user', 'get', userId])) === null || _a === void 0 ? void 0 : _a.data;
@@ -7884,6 +7954,36 @@ class AnalyticsEventCapturer {
7884
7954
  metadata,
7885
7955
  });
7886
7956
  }
7957
+ markProductAsClicked(product, location, sourceType, sourceId) {
7958
+ const metadata = {
7959
+ location,
7960
+ sourceType,
7961
+ sourceId,
7962
+ };
7963
+ const activityType = "linkClicked" /* Amity.AnalyticEventActivityType.Click */;
7964
+ this.markAs({
7965
+ uniqueId: `${product.productId}.${activityType}.${location}`,
7966
+ contentId: product.productId,
7967
+ contentType: "product" /* Amity.AnalyticEventContentType.Product */,
7968
+ activityType,
7969
+ metadata,
7970
+ });
7971
+ }
7972
+ markProductAsViewed(product, location, sourceType, sourceId) {
7973
+ const metadata = {
7974
+ location,
7975
+ sourceType,
7976
+ sourceId,
7977
+ };
7978
+ const activityType = "view" /* Amity.AnalyticEventActivityType.View */;
7979
+ this.markAs({
7980
+ uniqueId: `${product.productId}.${activityType}.${location}`,
7981
+ contentId: product.productId,
7982
+ contentType: "product" /* Amity.AnalyticEventContentType.Product */,
7983
+ activityType,
7984
+ metadata,
7985
+ });
7986
+ }
7887
7987
  }
7888
7988
 
7889
7989
  class AnalyticsEngine {
@@ -7924,6 +8024,18 @@ class AnalyticsEngine {
7924
8024
  this._eventCapturer.markStoryAsClicked(story);
7925
8025
  }
7926
8026
  }
8027
+ markProductAsClicked(product, location, sourceType, sourceId) {
8028
+ if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
8029
+ this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
8030
+ this._eventCapturer.markProductAsClicked(product, location, sourceType, sourceId);
8031
+ }
8032
+ }
8033
+ markProductAsViewed(product, location, sourceType, sourceId) {
8034
+ if (this._client.sessionState === "established" /* Amity.SessionStates.ESTABLISHED */ ||
8035
+ this._client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */) {
8036
+ this._eventCapturer.markProductAsViewed(product, location, sourceType, sourceId);
8037
+ }
8038
+ }
7927
8039
  established() {
7928
8040
  this._eventSyncer.start();
7929
8041
  }
@@ -10171,6 +10283,7 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
10171
10283
  isUnreadCountEnabled,
10172
10284
  useLegacyUnreadCount,
10173
10285
  getMarkerSyncConsistentMode,
10286
+ getProductCatalogueSetting,
10174
10287
  /**
10175
10288
  * Prefix for the deviceId key in the local storage or async storage.
10176
10289
  * This is allow user to have multiple SDK client and Mqtt client within the same app.
@@ -11035,7 +11148,7 @@ const getUserUnread = (callback) => {
11035
11148
  };
11036
11149
  };
11037
11150
 
11038
- var index$r = /*#__PURE__*/Object.freeze({
11151
+ var index$s = /*#__PURE__*/Object.freeze({
11039
11152
  __proto__: null,
11040
11153
  getActiveClient: getActiveClient,
11041
11154
  getActiveUser: getActiveUser,
@@ -11059,6 +11172,7 @@ var index$r = /*#__PURE__*/Object.freeze({
11059
11172
  getLinkPreviewMetadata: getLinkPreviewMetadata,
11060
11173
  getSocialSettings: getSocialSettings,
11061
11174
  getShareableLinkConfiguration: getShareableLinkConfiguration,
11175
+ getProductCatalogueSetting: getProductCatalogueSetting,
11062
11176
  loginAsVisitor: loginAsVisitor,
11063
11177
  loginAsBot: loginAsBot,
11064
11178
  getCurrentUser: getCurrentUser,
@@ -12267,7 +12381,7 @@ const getMyFollowInfo = (callback) => {
12267
12381
  };
12268
12382
  /* end_public_function */
12269
12383
 
12270
- var index$q = /*#__PURE__*/Object.freeze({
12384
+ var index$r = /*#__PURE__*/Object.freeze({
12271
12385
  __proto__: null,
12272
12386
  blockUser: blockUser,
12273
12387
  unBlockUser: unBlockUser,
@@ -12525,7 +12639,6 @@ const createChannel = async (bundle) => {
12525
12639
  const cachedAt = client.cache && Date.now();
12526
12640
  if (client.cache)
12527
12641
  ingestInCache(data, { cachedAt });
12528
- fireEvent('local.channel.created', data.channels[0]);
12529
12642
  const { channels } = data;
12530
12643
  return {
12531
12644
  data: constructChannelObject(channels[0]),
@@ -13098,7 +13211,7 @@ const getWatchSessionStorage = () => {
13098
13211
  return storageInstance;
13099
13212
  };
13100
13213
 
13101
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
13214
+ 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-----";
13102
13215
  /*
13103
13216
  * The crypto algorithm used for importing key and signing string
13104
13217
  */
@@ -13525,7 +13638,9 @@ function updateMembershipStatus(communities, communityUsers) {
13525
13638
  if ((cachedCommunity === null || cachedCommunity === void 0 ? void 0 : cachedCommunity.data) && (cachedCommunity === null || cachedCommunity === void 0 ? void 0 : cachedCommunity.data.hasOwnProperty('isJoined'))) {
13526
13639
  return Object.assign(Object.assign({}, cachedCommunity.data), c);
13527
13640
  }
13528
- const isJoined = communityUsers.some(m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership));
13641
+ const isJoined = c.isJoined !== undefined
13642
+ ? c.isJoined
13643
+ : communityUsers.some(m => isCurrentUserPartOfCommunity(c, m) && isMember(m.communityMembership));
13529
13644
  return Object.assign(Object.assign({}, c), { isJoined });
13530
13645
  });
13531
13646
  }
@@ -14376,6 +14491,28 @@ const communityLinkedObject = (community) => {
14376
14491
  } });
14377
14492
  };
14378
14493
 
14494
+ const productLinkedObject = (product) => {
14495
+ const analyticsEngineInstance = AnalyticsEngine$1.getInstance();
14496
+ return Object.assign(Object.assign({}, product), { analytics: {
14497
+ markAsClicked: (location, sourceType, sourceId) => {
14498
+ analyticsEngineInstance.markProductAsClicked(product, location, sourceType, sourceId);
14499
+ },
14500
+ markAsViewed: (location, sourceType, sourceId) => {
14501
+ analyticsEngineInstance.markProductAsViewed(product, location, sourceType, sourceId);
14502
+ },
14503
+ } });
14504
+ };
14505
+
14506
+ const productTagLinkedObject = (productTag) => {
14507
+ var _a;
14508
+ const internalProduct = (_a = pullFromCache([
14509
+ 'product',
14510
+ 'get',
14511
+ productTag.productId,
14512
+ ])) === null || _a === void 0 ? void 0 : _a.data;
14513
+ return Object.assign(Object.assign({}, productTag), { product: internalProduct ? productLinkedObject(internalProduct) : undefined });
14514
+ };
14515
+
14379
14516
  const postLinkedObject = (post) => {
14380
14517
  return shallowClone(post, {
14381
14518
  childrenPosts: post.children
@@ -14388,6 +14525,10 @@ const postLinkedObject = (post) => {
14388
14525
  analyticsEngineInstance.markPostAsViewed(post.postId);
14389
14526
  },
14390
14527
  },
14528
+ get productTags() {
14529
+ var _a, _b;
14530
+ return (_b = (_a = post.productTags) === null || _a === void 0 ? void 0 : _a.map(productTag => productTagLinkedObject(productTag))) !== null && _b !== void 0 ? _b : [];
14531
+ },
14391
14532
  get latestComments() {
14392
14533
  if (!post.comments)
14393
14534
  return [];
@@ -15387,6 +15528,7 @@ const LinkedObject = {
15387
15528
  room: roomLinkedObject,
15388
15529
  event: eventLinkedObject,
15389
15530
  eventResponse: eventResponseLinkedObject,
15531
+ product: productLinkedObject,
15390
15532
  };
15391
15533
 
15392
15534
  /* begin_public_function
@@ -16377,9 +16519,9 @@ var AmityUserSearchMatchType;
16377
16519
  AmityUserSearchMatchType["PARTIAL"] = "partial";
16378
16520
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
16379
16521
 
16380
- var index$p = /*#__PURE__*/Object.freeze({
16522
+ var index$q = /*#__PURE__*/Object.freeze({
16381
16523
  __proto__: null,
16382
- Relationship: index$q,
16524
+ Relationship: index$r,
16383
16525
  getUserByIds: getUserByIds,
16384
16526
  updateUser: updateUser,
16385
16527
  flagUser: flagUser,
@@ -16759,13 +16901,12 @@ const uploadClip = async (formData, feedType, onProgress) => {
16759
16901
  const uploadAudio = async (formData, onProgress) => {
16760
16902
  const client = getActiveClient();
16761
16903
  client.log('file/uploadAudio', formData);
16762
- const files = formData.getAll('file');
16763
- if (files.length === 0)
16904
+ const file = formData.get('file');
16905
+ if (!file)
16764
16906
  throw new Error('The formData object must have a `file` key with audio file.');
16765
- const file = files[0];
16766
16907
  const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
16767
16908
  formData.append('accessType', accessType);
16768
- formData.append('preferredFilename', file === null || file === void 0 ? void 0 : file.name);
16909
+ formData.append('preferredFilename', file.name);
16769
16910
  const headers = { 'content-type': 'multipart/form-data' };
16770
16911
  const { data } = await client.upload.post('/api/v4/audios', formData, {
16771
16912
  headers,
@@ -16783,7 +16924,7 @@ const uploadAudio = async (formData, onProgress) => {
16783
16924
  };
16784
16925
  /* end_public_function */
16785
16926
 
16786
- var index$o = /*#__PURE__*/Object.freeze({
16927
+ var index$p = /*#__PURE__*/Object.freeze({
16787
16928
  __proto__: null,
16788
16929
  getFile: getFile,
16789
16930
  uploadFile: uploadFile,
@@ -16982,7 +17123,7 @@ getMessage$1.locally = (messageId) => {
16982
17123
  * const { data: post } = await getPost('foobar')
16983
17124
  * ```
16984
17125
  *
16985
- * Fetches a {@link Amity.Post} object
17126
+ * Fetches a {@link Amity.InternalPost} object
16986
17127
  *
16987
17128
  * @param postId the ID of the {@link Amity.Post} to fetch
16988
17129
  * @returns the associated {@link Amity.Post} object
@@ -17603,7 +17744,7 @@ const preparePostPayload = (payload) => {
17603
17744
  // Queue ResetTask for this post
17604
17745
  PostCommentCountEngine$1.getInstance().queueCommentChangeTask(new ResetTask(post.postId, latestCreatedAt, (_c = post.commentsCount) !== null && _c !== void 0 ? _c : 0));
17605
17746
  return Object.assign(Object.assign({}, post), { childPosts,
17606
- feedType, localCommentCount: (_d = post.localCommentCount) !== null && _d !== void 0 ? _d : post.commentsCount });
17747
+ feedType, localCommentCount: (_d = post.localCommentCount) !== null && _d !== void 0 ? _d : post.commentsCount, pinnedProductId: post === null || post === void 0 ? void 0 : post.pinnedProductId });
17607
17748
  });
17608
17749
  return Object.assign(Object.assign({}, postPayload), { postChildren, videoStreamings: mappedNewStream, posts, communities: communityWithMembershipStatus, communityUsers: mappedCommunityUsers });
17609
17750
  };
@@ -18760,7 +18901,7 @@ const getReactions$1 = (params, callback, config) => {
18760
18901
  };
18761
18902
  /* end_public_function */
18762
18903
 
18763
- var index$n = /*#__PURE__*/Object.freeze({
18904
+ var index$o = /*#__PURE__*/Object.freeze({
18764
18905
  __proto__: null,
18765
18906
  addReaction: addReaction,
18766
18907
  removeReaction: removeReaction,
@@ -20532,7 +20673,7 @@ const getMessages = (params, callback, config) => {
20532
20673
  };
20533
20674
  /* end_public_function */
20534
20675
 
20535
- var index$m = /*#__PURE__*/Object.freeze({
20676
+ var index$n = /*#__PURE__*/Object.freeze({
20536
20677
  __proto__: null,
20537
20678
  createMessage: createMessage,
20538
20679
  updateMessage: updateMessage,
@@ -21058,7 +21199,7 @@ const stopMessageReceiptSync = (subChannelId) => {
21058
21199
  };
21059
21200
  /* end_public_function */
21060
21201
 
21061
- var index$l = /*#__PURE__*/Object.freeze({
21202
+ var index$m = /*#__PURE__*/Object.freeze({
21062
21203
  __proto__: null,
21063
21204
  getSubChannelByIds: getSubChannels$1,
21064
21205
  createSubChannel: createSubChannel,
@@ -21856,15 +21997,6 @@ class ChannelLiveCollectionController extends LiveCollectionController {
21856
21997
  },
21857
21998
  action: "onCreate" /* Amity.ChannelActionType.OnCreate */,
21858
21999
  },
21859
- {
21860
- fn: (callback) => {
21861
- return onChannelCreatedLocal(channel => {
21862
- resolveUnreadInfoOnChannelEvent(channel);
21863
- callback(channel);
21864
- });
21865
- },
21866
- action: "onCreate" /* Amity.ChannelActionType.OnCreate */,
21867
- },
21868
22000
  ];
21869
22001
  }
21870
22002
  return subscriptions;
@@ -22394,7 +22526,7 @@ const searchMembers$1 = (params, callback, config) => {
22394
22526
  };
22395
22527
  /* end_public_function */
22396
22528
 
22397
- var index$k = /*#__PURE__*/Object.freeze({
22529
+ var index$l = /*#__PURE__*/Object.freeze({
22398
22530
  __proto__: null,
22399
22531
  addMembers: addMembers$1,
22400
22532
  removeMembers: removeMembers$1,
@@ -22597,7 +22729,7 @@ const unmuteMembers = async (channelId, userIds) => {
22597
22729
  };
22598
22730
  /* end_public_function */
22599
22731
 
22600
- var index$j = /*#__PURE__*/Object.freeze({
22732
+ var index$k = /*#__PURE__*/Object.freeze({
22601
22733
  __proto__: null,
22602
22734
  addRole: addRole,
22603
22735
  removeRole: removeRole,
@@ -22607,10 +22739,10 @@ var index$j = /*#__PURE__*/Object.freeze({
22607
22739
  unmuteMembers: unmuteMembers
22608
22740
  });
22609
22741
 
22610
- var index$i = /*#__PURE__*/Object.freeze({
22742
+ var index$j = /*#__PURE__*/Object.freeze({
22611
22743
  __proto__: null,
22612
- Membership: index$k,
22613
- Moderation: index$j,
22744
+ Membership: index$l,
22745
+ Moderation: index$k,
22614
22746
  getChannelByIds: getChannelByIds$1,
22615
22747
  createChannel: createChannel,
22616
22748
  updateChannel: updateChannel,
@@ -22620,7 +22752,6 @@ var index$i = /*#__PURE__*/Object.freeze({
22620
22752
  muteChannel: muteChannel,
22621
22753
  unmuteChannel: unmuteChannel,
22622
22754
  onChannelCreated: onChannelCreated,
22623
- onChannelCreatedLocal: onChannelCreatedLocal,
22624
22755
  onChannelUpdated: onChannelUpdated,
22625
22756
  onChannelDeleted: onChannelDeleted,
22626
22757
  onChannelJoined: onChannelJoined,
@@ -24014,7 +24145,7 @@ const searchMembers = (params, callback, config) => {
24014
24145
  };
24015
24146
  /* end_public_function */
24016
24147
 
24017
- var index$h = /*#__PURE__*/Object.freeze({
24148
+ var index$i = /*#__PURE__*/Object.freeze({
24018
24149
  __proto__: null,
24019
24150
  addMembers: addMembers,
24020
24151
  removeMembers: removeMembers,
@@ -25265,7 +25396,7 @@ const unbanMembers = async (communityId, userIds) => {
25265
25396
  };
25266
25397
  /* end_public_function */
25267
25398
 
25268
- var index$g = /*#__PURE__*/Object.freeze({
25399
+ var index$h = /*#__PURE__*/Object.freeze({
25269
25400
  __proto__: null,
25270
25401
  addRoles: addRoles,
25271
25402
  removeRoles: removeRoles,
@@ -25273,10 +25404,10 @@ var index$g = /*#__PURE__*/Object.freeze({
25273
25404
  unbanMembers: unbanMembers
25274
25405
  });
25275
25406
 
25276
- var index$f = /*#__PURE__*/Object.freeze({
25407
+ var index$g = /*#__PURE__*/Object.freeze({
25277
25408
  __proto__: null,
25278
- Moderation: index$g,
25279
- Membership: index$h,
25409
+ Moderation: index$h,
25410
+ Membership: index$i,
25280
25411
  getCommunityByIds: getCommunities$1,
25281
25412
  createCommunity: createCommunity,
25282
25413
  updateCommunity: updateCommunity,
@@ -25510,7 +25641,7 @@ const getCategories = (params, callback, config) => {
25510
25641
  };
25511
25642
  /* end_public_function */
25512
25643
 
25513
- var index$e = /*#__PURE__*/Object.freeze({
25644
+ var index$f = /*#__PURE__*/Object.freeze({
25514
25645
  __proto__: null,
25515
25646
  getCategory: getCategory,
25516
25647
  getCategories: getCategories
@@ -25629,6 +25760,9 @@ var EnumPostActions;
25629
25760
  EnumPostActions["OnPostReactionRemoved"] = "onPostReactionRemoved";
25630
25761
  EnumPostActions["OnPostApproved"] = "onPostApproved";
25631
25762
  EnumPostActions["OnPostDeclined"] = "onPostDeclined";
25763
+ EnumPostActions["OnPostPinProduct"] = "onPostPinProduct";
25764
+ EnumPostActions["OnPostUnpinProduct"] = "onPostUnpinProduct";
25765
+ EnumPostActions["OnPostUpdateProductTags"] = "onPostUpdateProductTags";
25632
25766
  })(EnumPostActions || (EnumPostActions = {}));
25633
25767
 
25634
25768
  class CustomRankingGlobalFeedQueryStreamController extends QueryStreamController {
@@ -26541,7 +26675,7 @@ const getComments = (params, callback, config) => {
26541
26675
  };
26542
26676
  /* end_public_function */
26543
26677
 
26544
- var index$d = /*#__PURE__*/Object.freeze({
26678
+ var index$e = /*#__PURE__*/Object.freeze({
26545
26679
  __proto__: null,
26546
26680
  getCommentByIds: getCommentByIds,
26547
26681
  createComment: createComment,
@@ -26952,7 +27086,7 @@ const getGlobalFeed = (params, callback, config) => {
26952
27086
 
26953
27087
  class UserFeedPaginationController extends PaginationController {
26954
27088
  async getRequest(queryParams, token) {
26955
- const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit"]);
27089
+ const { userId, feedSources, dataTypes, includeDeleted, matchingOnlyParentPost, limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, untilAt } = queryParams, params = __rest(queryParams, ["userId", "feedSources", "dataTypes", "includeDeleted", "matchingOnlyParentPost", "limit", "untilAt"]);
26956
27090
  const options = token ? { token } : { limit };
26957
27091
  const { data: queryResponse } = await this.http.get(`/api/v4/user-feeds/${userId}`, {
26958
27092
  params: Object.assign(Object.assign({}, params), { options, dataTypes: (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) ? dataTypes : undefined, includePostedFeed: feedSources, isDeleted: inferIsDeleted(includeDeleted), matchingOnlyParentPost: matchingOnlyParentPost !== null && matchingOnlyParentPost !== void 0 ? matchingOnlyParentPost : !(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length) }),
@@ -26964,8 +27098,11 @@ class UserFeedPaginationController extends PaginationController {
26964
27098
  class UserFeedQueryStreamController extends QueryStreamController {
26965
27099
  constructor(query, cacheKey, notifyChange, preparePayload) {
26966
27100
  super(query, cacheKey);
27101
+ this.boundaryReached = false;
26967
27102
  this.notifyChange = notifyChange;
26968
27103
  this.preparePayload = preparePayload;
27104
+ // Validate untilAt on initialization
27105
+ this.validatedUntilAt = query.untilAt ? validateUntilAt(query.untilAt) : undefined;
26969
27106
  }
26970
27107
  async saveToMainDB(response) {
26971
27108
  const processedPayload = await this.preparePayload(response);
@@ -26977,28 +27114,57 @@ class UserFeedQueryStreamController extends QueryStreamController {
26977
27114
  }
26978
27115
  appendToQueryStream(response, direction, refresh = false) {
26979
27116
  var _a, _b;
27117
+ let postsToAdd = response.posts;
27118
+ // Reset boundary flag on refresh since we're starting fresh
27119
+ if (refresh) {
27120
+ this.boundaryReached = false;
27121
+ }
27122
+ // Apply untilAt filtering if present
27123
+ if (this.validatedUntilAt !== undefined) {
27124
+ const sortBy = this.query.sortBy === 'firstCreated' ? 'firstCreated' : 'lastCreated';
27125
+ const filteredPosts = postsToAdd.filter(post => !exceedsUntilAtBoundary(post.createdAt, this.validatedUntilAt, sortBy));
27126
+ // If any posts were filtered out, mark boundary as reached
27127
+ if (filteredPosts.length < postsToAdd.length) {
27128
+ this.boundaryReached = true;
27129
+ }
27130
+ postsToAdd = filteredPosts;
27131
+ }
26980
27132
  if (refresh) {
26981
27133
  pushToCache(this.cacheKey, {
26982
- data: response.posts.map(getResolver('post')),
27134
+ data: postsToAdd.map(getResolver('post')),
26983
27135
  });
26984
27136
  }
26985
27137
  else {
26986
27138
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26987
27139
  const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
26988
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
27140
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...postsToAdd.map(getResolver('post'))])] }));
26989
27141
  }
26990
27142
  }
26991
27143
  reactor(action) {
26992
27144
  return (post) => {
26993
27145
  var _a, _b;
26994
27146
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26995
- if (!collection)
27147
+ if (!collection) {
26996
27148
  return;
27149
+ }
26997
27150
  // if the collection is parent post collection and
26998
27151
  // post is not included in the collection or post is child post
26999
27152
  if ((!this.query.dataTypes || this.query.dataTypes.length === 0) &&
27000
- !collection.data.includes(post.parentPostId ? post.parentPostId : post.postId))
27153
+ !collection.data.includes(post.parentPostId ? post.parentPostId : post.postId)) {
27001
27154
  return;
27155
+ }
27156
+ // Check untilAt boundary for new/updated posts from real-time events
27157
+ // Apply to OnPostUpdated as well since comment events might bring in posts that exceed the boundary
27158
+ if (this.validatedUntilAt !== undefined &&
27159
+ (action === EnumPostActions.OnPostCreated ||
27160
+ action === EnumPostActions.OnPostApproved ||
27161
+ action === EnumPostActions.OnPostUpdated)) {
27162
+ const sortBy = this.query.sortBy === 'firstCreated' ? 'firstCreated' : 'lastCreated';
27163
+ if (exceedsUntilAtBoundary(post.createdAt, this.validatedUntilAt, sortBy)) {
27164
+ // Post exceeds boundary, do not add to query stream or update
27165
+ return;
27166
+ }
27167
+ }
27002
27168
  if (action === EnumPostActions.OnPostDeleted) {
27003
27169
  collection.data = collection.data.filter(postId => postId !== post.postId);
27004
27170
  }
@@ -27031,6 +27197,9 @@ class UserFeedQueryStreamController extends QueryStreamController {
27031
27197
  subscribeRTE(createSubscriber) {
27032
27198
  return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
27033
27199
  }
27200
+ hasBoundaryReached() {
27201
+ return this.boundaryReached;
27202
+ }
27034
27203
  }
27035
27204
 
27036
27205
  const getPost$1 = async (postId) => {
@@ -27149,20 +27318,51 @@ class UserFeedLiveCollectionController extends LiveCollectionController {
27149
27318
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27150
27319
  if (!collection)
27151
27320
  return;
27152
- const data = ((_b = collection.data
27321
+ const rawPosts = (_b = collection.data
27153
27322
  .map(id => pullFromCache(['post', 'get', id]))
27154
27323
  .filter(isNonNullable)
27155
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
27324
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
27325
+ const data = this.applyFilter(rawPosts).map(LinkedObject.post);
27156
27326
  if (!this.shouldNotify(data) && origin === 'event')
27157
27327
  return;
27328
+ // If untilAt boundary was reached, hasNextPage should be false
27329
+ const hasNextPage = this.queryStreamController.hasBoundaryReached()
27330
+ ? false
27331
+ : !!this.paginationController.getNextToken();
27158
27332
  this.callback({
27159
27333
  onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
27160
27334
  data,
27161
- hasNextPage: !!this.paginationController.getNextToken(),
27335
+ hasNextPage,
27162
27336
  loading,
27163
27337
  error,
27164
27338
  });
27165
27339
  }
27340
+ applyFilter(data) {
27341
+ var _a;
27342
+ let posts = data;
27343
+ if (!this.query.includeDeleted) {
27344
+ posts = filterByPropEquality(posts, 'isDeleted', false);
27345
+ }
27346
+ if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
27347
+ posts = filterByPostDataTypes(posts, this.query.dataTypes);
27348
+ }
27349
+ // Apply untilAt filtering if present (as a safety net)
27350
+ if (this.query.untilAt) {
27351
+ const validatedUntilAt = validateUntilAt(this.query.untilAt);
27352
+ const sortBy = this.query.sortBy === 'firstCreated' ? 'firstCreated' : 'lastCreated';
27353
+ posts = posts.filter(post => !exceedsUntilAtBoundary(post.createdAt, validatedUntilAt, sortBy));
27354
+ }
27355
+ switch (this.query.sortBy) {
27356
+ case 'firstCreated':
27357
+ posts = posts.sort(sortByFirstCreated);
27358
+ break;
27359
+ case 'lastCreated':
27360
+ default:
27361
+ posts = posts.sort(sortByLastCreated);
27362
+ break;
27363
+ }
27364
+ return posts;
27365
+ }
27166
27366
  }
27167
27367
 
27168
27368
  /* begin_public_function
@@ -27209,7 +27409,7 @@ const getUserFeed = (params, callback, config) => {
27209
27409
 
27210
27410
  class CommunityFeedPaginationController extends PaginationController {
27211
27411
  async getRequest(queryParams, token) {
27212
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted, communityId } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted", "communityId"]);
27412
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted, communityId, untilAt } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted", "communityId", "untilAt"]);
27213
27413
  const options = token ? { token } : { limit };
27214
27414
  const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
27215
27415
  params: Object.assign(Object.assign({}, params), { targetId: communityId, targetType: 'community', isDeleted: inferIsDeleted(includeDeleted), matchingOnlyParentPost: true, options }),
@@ -27221,8 +27421,11 @@ class CommunityFeedPaginationController extends PaginationController {
27221
27421
  class CommunityFeedQueryStreamController extends QueryStreamController {
27222
27422
  constructor(query, cacheKey, notifyChange, preparePayload) {
27223
27423
  super(query, cacheKey);
27424
+ this.boundaryReached = false;
27224
27425
  this.notifyChange = notifyChange;
27225
27426
  this.preparePayload = preparePayload;
27427
+ // Validate untilAt on initialization
27428
+ this.validatedUntilAt = query.untilAt ? validateUntilAt(query.untilAt) : undefined;
27226
27429
  }
27227
27430
  async saveToMainDB(response) {
27228
27431
  const processedPayload = await this.preparePayload(response);
@@ -27234,15 +27437,32 @@ class CommunityFeedQueryStreamController extends QueryStreamController {
27234
27437
  }
27235
27438
  appendToQueryStream(response, direction, refresh = false) {
27236
27439
  var _a, _b;
27440
+ let postsToAdd = response.posts;
27441
+ // Reset boundary flag on refresh since we're starting fresh
27442
+ if (refresh) {
27443
+ this.boundaryReached = false;
27444
+ }
27445
+ // Apply untilAt filtering if present (only for createdAt-based sorts)
27446
+ if (this.validatedUntilAt !== undefined &&
27447
+ this.query.sortBy !== "firstUpdated" /* FeedSortByEnum.FirstUpdated */ &&
27448
+ this.query.sortBy !== "lastUpdated" /* FeedSortByEnum.LastUpdated */) {
27449
+ const sortBy = this.query.sortBy === "firstCreated" /* FeedSortByEnum.FirstCreated */ ? 'firstCreated' : 'lastCreated';
27450
+ const filteredPosts = postsToAdd.filter(post => !exceedsUntilAtBoundary(post.createdAt, this.validatedUntilAt, sortBy));
27451
+ // If any posts were filtered out, mark boundary as reached
27452
+ if (filteredPosts.length < postsToAdd.length) {
27453
+ this.boundaryReached = true;
27454
+ }
27455
+ postsToAdd = filteredPosts;
27456
+ }
27237
27457
  if (refresh) {
27238
27458
  pushToCache(this.cacheKey, {
27239
- data: response.posts.map(getResolver('post')),
27459
+ data: postsToAdd.map(getResolver('post')),
27240
27460
  });
27241
27461
  }
27242
27462
  else {
27243
27463
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27244
27464
  const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
27245
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
27465
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...postsToAdd.map(getResolver('post'))])] }));
27246
27466
  }
27247
27467
  }
27248
27468
  reactor(action) {
@@ -27251,6 +27471,17 @@ class CommunityFeedQueryStreamController extends QueryStreamController {
27251
27471
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27252
27472
  if (!collection)
27253
27473
  return;
27474
+ // Check untilAt boundary for new/updated posts from real-time events
27475
+ if (this.validatedUntilAt !== undefined &&
27476
+ (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved) &&
27477
+ this.query.sortBy !== "firstUpdated" /* FeedSortByEnum.FirstUpdated */ &&
27478
+ this.query.sortBy !== "lastUpdated" /* FeedSortByEnum.LastUpdated */) {
27479
+ const sortBy = this.query.sortBy === "firstCreated" /* FeedSortByEnum.FirstCreated */ ? 'firstCreated' : 'lastCreated';
27480
+ if (exceedsUntilAtBoundary(post.createdAt, this.validatedUntilAt, sortBy)) {
27481
+ // Post exceeds boundary, do not add to query stream
27482
+ return;
27483
+ }
27484
+ }
27254
27485
  if (action === EnumPostActions.OnPostDeleted) {
27255
27486
  collection.data = collection.data.filter(postId => postId !== post.postId);
27256
27487
  }
@@ -27278,6 +27509,9 @@ class CommunityFeedQueryStreamController extends QueryStreamController {
27278
27509
  subscribeRTE(createSubscriber) {
27279
27510
  return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
27280
27511
  }
27512
+ hasBoundaryReached() {
27513
+ return this.boundaryReached;
27514
+ }
27281
27515
  }
27282
27516
 
27283
27517
  const commentEventHandler = (callback, eventHandler, cacheKey, resolveId) => {
@@ -27365,20 +27599,57 @@ class CommunityFeedLiveCollectionController extends LiveCollectionController {
27365
27599
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
27366
27600
  if (!collection)
27367
27601
  return;
27368
- const data = ((_b = collection.data
27602
+ const data = this.applyFilter((_b = collection.data
27369
27603
  .map(id => pullFromCache(['post', 'get', id]))
27370
27604
  .filter(isNonNullable)
27371
27605
  .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
27372
27606
  if (!this.shouldNotify(data) && origin === 'event')
27373
27607
  return;
27608
+ // If untilAt boundary was reached, hasNextPage should be false
27609
+ const hasNextPage = this.queryStreamController.hasBoundaryReached()
27610
+ ? false
27611
+ : !!this.paginationController.getNextToken();
27374
27612
  this.callback({
27375
27613
  onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
27376
27614
  data,
27377
- hasNextPage: !!this.paginationController.getNextToken(),
27615
+ hasNextPage,
27378
27616
  loading,
27379
27617
  error,
27380
27618
  });
27381
27619
  }
27620
+ applyFilter(data) {
27621
+ let posts = data;
27622
+ if (!this.query.includeDeleted) {
27623
+ posts = filterByPropEquality(posts, 'isDeleted', false);
27624
+ }
27625
+ if (this.query.tags) {
27626
+ posts = posts.filter(p => { var _a; return (_a = p.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = this.query.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
27627
+ }
27628
+ // Apply untilAt filtering if present (only for createdAt-based sorts, as a safety net)
27629
+ if (this.query.untilAt &&
27630
+ this.query.sortBy !== "firstUpdated" /* FeedSortByEnum.FirstUpdated */ &&
27631
+ this.query.sortBy !== "lastUpdated" /* FeedSortByEnum.LastUpdated */) {
27632
+ const validatedUntilAt = validateUntilAt(this.query.untilAt);
27633
+ const sortBy = this.query.sortBy === "firstCreated" /* FeedSortByEnum.FirstCreated */ ? 'firstCreated' : 'lastCreated';
27634
+ posts = posts.filter(post => !exceedsUntilAtBoundary(post.createdAt, validatedUntilAt, sortBy));
27635
+ }
27636
+ switch (this.query.sortBy) {
27637
+ case "firstCreated" /* FeedSortByEnum.FirstCreated */:
27638
+ posts = posts.sort(sortByFirstCreated);
27639
+ break;
27640
+ case "firstUpdated" /* FeedSortByEnum.FirstUpdated */:
27641
+ posts = posts.sort(sortByFirstUpdated);
27642
+ break;
27643
+ case "lastUpdated" /* FeedSortByEnum.LastUpdated */:
27644
+ posts = posts.sort(sortByLastUpdated);
27645
+ break;
27646
+ case "lastCreated" /* FeedSortByEnum.LastCreated */:
27647
+ default:
27648
+ posts = posts.sort(sortByLastCreated);
27649
+ break;
27650
+ }
27651
+ return posts;
27652
+ }
27382
27653
  }
27383
27654
 
27384
27655
  /* begin_public_function
@@ -27434,7 +27705,7 @@ const getCommunityFeed = (params, callback, config) => {
27434
27705
  };
27435
27706
  /* end_public_function */
27436
27707
 
27437
- var index$c = /*#__PURE__*/Object.freeze({
27708
+ var index$d = /*#__PURE__*/Object.freeze({
27438
27709
  __proto__: null,
27439
27710
  queryGlobalFeed: queryGlobalFeed,
27440
27711
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -27550,7 +27821,17 @@ const createPost = async (bundle) => {
27550
27821
  // eslint-disable-next-line no-param-reassign
27551
27822
  delete bundle.dataType;
27552
27823
  }
27553
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
27824
+ const { attachments, attachmentProductTags } = bundle, rest = __rest(bundle, ["attachments", "attachmentProductTags"]);
27825
+ const processedAttachments = attachments && attachments.length > 0 && bundle.attachmentProductTags
27826
+ ? attachments.map(attachment => {
27827
+ var _a;
27828
+ const productTags = (_a = bundle.attachmentProductTags) === null || _a === void 0 ? void 0 : _a.get(attachment.fileId);
27829
+ if (productTags)
27830
+ return Object.assign(Object.assign({}, attachment), { productTags });
27831
+ return attachment;
27832
+ })
27833
+ : attachments;
27834
+ const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, rest), { attachments: processedAttachments }));
27554
27835
  fireEvent('post.created', payload);
27555
27836
  const data = preparePostPayload(payload);
27556
27837
  const cachedAt = client.cache && Date.now();
@@ -27587,7 +27868,17 @@ const createPost = async (bundle) => {
27587
27868
  const editPost = async (postId, patch) => {
27588
27869
  const client = getActiveClient();
27589
27870
  client.log('user/editPost', patch);
27590
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
27871
+ const { attachments } = patch;
27872
+ const processedAttachments = attachments && attachments.length > 0 && patch.attachmentProductTags
27873
+ ? attachments.map(attachment => {
27874
+ var _a;
27875
+ const productTags = (_a = patch.attachmentProductTags) === null || _a === void 0 ? void 0 : _a.get(attachment.fileId);
27876
+ if (productTags)
27877
+ return Object.assign(Object.assign({}, attachment), { productTags });
27878
+ return attachment;
27879
+ })
27880
+ : attachments;
27881
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
27591
27882
  const data = prepareMembershipPayload(payload, 'communityUsers');
27592
27883
  const cachedAt = client.cache && Date.now();
27593
27884
  if (client.cache)
@@ -27914,7 +28205,17 @@ const isPostFlaggedByMe = async (postId) => {
27914
28205
  const createClipPost = async (bundle) => {
27915
28206
  const client = getActiveClient();
27916
28207
  client.log('post/createPost', bundle);
27917
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
28208
+ const { attachments, attachmentProductTags } = bundle, rest = __rest(bundle, ["attachments", "attachmentProductTags"]);
28209
+ const processedAttachments = attachments && attachments.length > 0 && bundle.attachmentProductTags
28210
+ ? attachments.map(attachment => {
28211
+ var _a;
28212
+ const productTags = (_a = bundle.attachmentProductTags) === null || _a === void 0 ? void 0 : _a.get(attachment.fileId);
28213
+ if (productTags)
28214
+ return Object.assign(Object.assign({}, attachment), { productTags });
28215
+ return attachment;
28216
+ })
28217
+ : attachments;
28218
+ const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, rest), { attachments: processedAttachments }));
27918
28219
  fireEvent('post.created', payload);
27919
28220
  const data = prepareMembershipPayload(payload, 'communityUsers');
27920
28221
  const cachedAt = client.cache && Date.now();
@@ -27953,7 +28254,16 @@ const createClipPost = async (bundle) => {
27953
28254
  const createAudioPost = async (bundle) => {
27954
28255
  const client = getActiveClient();
27955
28256
  client.log('post/createAudioPost', bundle);
27956
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
28257
+ const { attachments, attachmentProductTags } = bundle, rest = __rest(bundle, ["attachments", "attachmentProductTags"]);
28258
+ const processedAttachments = attachments && attachments.length > 0 && attachmentProductTags
28259
+ ? attachments.map(attachment => {
28260
+ const productTags = attachmentProductTags === null || attachmentProductTags === void 0 ? void 0 : attachmentProductTags.get(attachment.fileId);
28261
+ if (productTags)
28262
+ return Object.assign(Object.assign({}, attachment), { productTags });
28263
+ return attachment;
28264
+ })
28265
+ : attachments;
28266
+ const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, rest), { attachments: processedAttachments }));
27957
28267
  fireEvent('post.created', payload);
27958
28268
  const data = preparePostPayload(payload);
27959
28269
  const cachedAt = client.cache && Date.now();
@@ -27997,7 +28307,17 @@ const createMixedMediaPost = async (bundle) => {
27997
28307
  var _a;
27998
28308
  const client = getActiveClient();
27999
28309
  client.log('post/createMixedMediaPost', bundle);
28000
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
28310
+ const { attachments, attachmentProductTags } = bundle, rest = __rest(bundle, ["attachments", "attachmentProductTags"]);
28311
+ const processedAttachments = attachments && attachments.length > 0 && bundle.attachmentProductTags
28312
+ ? attachments.map(attachment => {
28313
+ var _a;
28314
+ const productTags = (_a = bundle.attachmentProductTags) === null || _a === void 0 ? void 0 : _a.get(attachment.fileId);
28315
+ if (productTags)
28316
+ return Object.assign(Object.assign({}, attachment), { productTags });
28317
+ return attachment;
28318
+ })
28319
+ : attachments;
28320
+ const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, rest), { attachments: processedAttachments }));
28001
28321
  fireEvent('post.created', payload);
28002
28322
  const data = preparePostPayload(payload);
28003
28323
  const cachedAt = client.cache && Date.now();
@@ -28010,6 +28330,143 @@ const createMixedMediaPost = async (bundle) => {
28010
28330
  };
28011
28331
  /* end_public_function */
28012
28332
 
28333
+ /* begin_public_function
28334
+ id: post.create_room_post
28335
+ */
28336
+ /**
28337
+ * ```js
28338
+ * import { PostRepository } from '@amityco/ts-sdk'
28339
+ * const created = await PostRepository.createRoomPost({
28340
+ * targetType: 'user',
28341
+ * targetId: 'foobar',
28342
+ * data: { text: 'hello world', title: 'Room Title', roomId: 'roomId123' }
28343
+ * }))
28344
+ * ```
28345
+ *
28346
+ * Creates an {@link Amity.Post}
28347
+ *
28348
+ * @param bundle The data necessary to create a new {@link Amity.Post}
28349
+ * @returns The newly created {@link Amity.Post}
28350
+ *
28351
+ * @category Post API
28352
+ * @async
28353
+ */
28354
+ const createRoomPost = async (bundle) => {
28355
+ const client = getActiveClient();
28356
+ client.log('post/createRoomPost', bundle);
28357
+ const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { dataType: 'room' }));
28358
+ fireEvent('post.created', payload);
28359
+ const data = preparePostPayload(payload);
28360
+ const cachedAt = client.cache && Date.now();
28361
+ if (client.cache)
28362
+ ingestInCache(data, { cachedAt });
28363
+ const { posts } = data;
28364
+ return {
28365
+ data: LinkedObject.post(posts[0]),
28366
+ cachedAt,
28367
+ };
28368
+ };
28369
+ /* end_public_function */
28370
+
28371
+ /* begin_public_function
28372
+ id: post.pin_product
28373
+ */
28374
+ /**
28375
+ * ```js
28376
+ * import { PostRepository } from '@amityco/ts-sdk'
28377
+ * const pinProduct = await PostRepository.pinProduct(postId, pinnedProductId)
28378
+ * ```
28379
+ *
28380
+ * @param postId The ID of the post to unpin the product from
28381
+ * @param productId the ID of the product to pin
28382
+ * @returns Amity.Post
28383
+ *
28384
+ * @category Post API
28385
+ * @async
28386
+ * */
28387
+ const pinProduct = async (postId, pinnedProductId) => {
28388
+ const client = getActiveClient();
28389
+ client.log('post/pinProduct', postId);
28390
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, {
28391
+ pinnedProductId,
28392
+ });
28393
+ const data = preparePostPayload(payload);
28394
+ const cachedAt = client.cache && Date.now();
28395
+ if (client.cache)
28396
+ ingestInCache(payload, { cachedAt });
28397
+ fireEvent('local.post.updated', payload);
28398
+ return {
28399
+ data: postLinkedObject(data === null || data === void 0 ? void 0 : data.posts[0]),
28400
+ cachedAt,
28401
+ };
28402
+ };
28403
+ /* end_public_function */
28404
+
28405
+ /* begin_public_function
28406
+ id: post.unpin_product
28407
+ */
28408
+ /**
28409
+ * ```js
28410
+ * import { PostRepository } from '@amityco/ts-sdk'
28411
+ * const unpinProduct = await PostRepository.unpinProduct(postId)
28412
+ * ```
28413
+ *
28414
+ * @param postId The ID of the post to unpin the product from
28415
+ * @returns Amity.Post
28416
+ *
28417
+ * @category Post API
28418
+ * @async
28419
+ * */
28420
+ const unpinProduct = async (postId) => {
28421
+ const client = getActiveClient();
28422
+ client.log('post/unpinProduct', postId);
28423
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, { pinnedProductId: null });
28424
+ const data = preparePostPayload(payload);
28425
+ const cachedAt = client.cache && Date.now();
28426
+ if (client.cache)
28427
+ ingestInCache(payload, { cachedAt });
28428
+ fireEvent('local.post.updated', payload);
28429
+ return {
28430
+ data: postLinkedObject(data === null || data === void 0 ? void 0 : data.posts[0]),
28431
+ cachedAt,
28432
+ };
28433
+ };
28434
+ /* end_public_function */
28435
+
28436
+ /* begin_public_function
28437
+ id: post.update_product_tags
28438
+ */
28439
+ /**
28440
+ * ```js
28441
+ * import { PostRepository } from '@amityco/ts-sdk'
28442
+ * const updateProductTags = await PostRepository.updateProductTags(postId, productTags)
28443
+ * ```
28444
+ *
28445
+ * @param postId of child room
28446
+ * @param productTags the array of product tags to set on the post
28447
+ * @returns Amity.Post
28448
+ *
28449
+ * @category Post API
28450
+ * @async
28451
+ * */
28452
+ const updateProductTags = async (postId, productTags) => {
28453
+ const client = getActiveClient();
28454
+ client.log('post/updateProductTags', postId);
28455
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, {
28456
+ productTags,
28457
+ });
28458
+ const data = preparePostPayload(payload);
28459
+ const cachedAt = client.cache && Date.now();
28460
+ if (client.cache)
28461
+ ingestInCache(payload, { cachedAt });
28462
+ fireEvent('local.post.updated', payload);
28463
+ return {
28464
+ data: postLinkedObject(data === null || data === void 0 ? void 0 : data.posts[0]),
28465
+ cachedAt,
28466
+ };
28467
+ };
28468
+ /* end_public_function */
28469
+
28013
28470
  /* begin_public_function
28014
28471
  id: post.get
28015
28472
  */
@@ -28100,7 +28557,7 @@ const getPost = (postId, callback) => {
28100
28557
 
28101
28558
  class PostPaginationController extends PaginationController {
28102
28559
  async getRequest(queryParams, token) {
28103
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted, matchingOnlyParentPost } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted", "matchingOnlyParentPost"]);
28560
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, includeDeleted, matchingOnlyParentPost, untilAt } = queryParams, params = __rest(queryParams, ["limit", "includeDeleted", "matchingOnlyParentPost", "untilAt"]);
28104
28561
  const { dataTypes } = params;
28105
28562
  const baseOptions = {
28106
28563
  type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
@@ -28124,8 +28581,11 @@ class PostPaginationController extends PaginationController {
28124
28581
  class PostQueryStreamController extends QueryStreamController {
28125
28582
  constructor(query, cacheKey, notifyChange, preparePayload) {
28126
28583
  super(query, cacheKey);
28584
+ this.boundaryReached = false;
28127
28585
  this.notifyChange = notifyChange;
28128
28586
  this.preparePayload = preparePayload;
28587
+ // Validate untilAt on initialization
28588
+ this.validatedUntilAt = query.untilAt ? validateUntilAt(query.untilAt) : undefined;
28129
28589
  }
28130
28590
  async saveToMainDB(response) {
28131
28591
  const processedPayload = await this.preparePayload(response);
@@ -28137,15 +28597,30 @@ class PostQueryStreamController extends QueryStreamController {
28137
28597
  }
28138
28598
  appendToQueryStream(response, direction, refresh = false) {
28139
28599
  var _a, _b;
28600
+ let postsToAdd = response.posts;
28601
+ // Reset boundary flag on refresh since we're starting fresh
28602
+ if (refresh) {
28603
+ this.boundaryReached = false;
28604
+ }
28605
+ // Apply untilAt filtering if present
28606
+ if (this.validatedUntilAt !== undefined) {
28607
+ const sortBy = this.query.sortBy || 'lastCreated';
28608
+ const filteredPosts = postsToAdd.filter(post => !exceedsUntilAtBoundary(post.createdAt, this.validatedUntilAt, sortBy));
28609
+ // If any posts were filtered out, mark boundary as reached
28610
+ if (filteredPosts.length < postsToAdd.length) {
28611
+ this.boundaryReached = true;
28612
+ }
28613
+ postsToAdd = filteredPosts;
28614
+ }
28140
28615
  if (refresh) {
28141
28616
  pushToCache(this.cacheKey, {
28142
- data: response.posts.map(getResolver('post')),
28617
+ data: postsToAdd.map(getResolver('post')),
28143
28618
  });
28144
28619
  }
28145
28620
  else {
28146
28621
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28147
28622
  const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
28148
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...response.posts.map(getResolver('post'))])] }));
28623
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...posts, ...postsToAdd.map(getResolver('post'))])] }));
28149
28624
  }
28150
28625
  }
28151
28626
  reactor(action) {
@@ -28154,6 +28629,15 @@ class PostQueryStreamController extends QueryStreamController {
28154
28629
  const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
28155
28630
  if (!collection)
28156
28631
  return;
28632
+ // Check untilAt boundary for new/updated posts from real-time events
28633
+ if (this.validatedUntilAt !== undefined &&
28634
+ (action === EnumPostActions.OnPostCreated || action === EnumPostActions.OnPostApproved)) {
28635
+ const sortBy = this.query.sortBy || 'lastCreated';
28636
+ if (exceedsUntilAtBoundary(post.createdAt, this.validatedUntilAt, sortBy)) {
28637
+ // Post exceeds boundary, do not add to query stream
28638
+ return;
28639
+ }
28640
+ }
28157
28641
  if (post.parentPostId && post.isDeleted) {
28158
28642
  const parentPost = (_b = pullFromCache([
28159
28643
  'post',
@@ -28184,6 +28668,9 @@ class PostQueryStreamController extends QueryStreamController {
28184
28668
  subscribeRTE(createSubscriber) {
28185
28669
  return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
28186
28670
  }
28671
+ hasBoundaryReached() {
28672
+ return this.boundaryReached;
28673
+ }
28187
28674
  }
28188
28675
 
28189
28676
  class PostLiveCollectionController extends LiveCollectionController {
@@ -28227,10 +28714,14 @@ class PostLiveCollectionController extends LiveCollectionController {
28227
28714
  .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.post);
28228
28715
  if (!this.shouldNotify(data) && origin === 'event')
28229
28716
  return;
28717
+ // If untilAt boundary was reached, hasNextPage should be false
28718
+ const hasNextPage = this.queryStreamController.hasBoundaryReached()
28719
+ ? false
28720
+ : !!this.paginationController.getNextToken();
28230
28721
  this.callback({
28231
28722
  onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
28232
28723
  data,
28233
- hasNextPage: !!this.paginationController.getNextToken(),
28724
+ hasNextPage,
28234
28725
  loading,
28235
28726
  error,
28236
28727
  });
@@ -28250,6 +28741,12 @@ class PostLiveCollectionController extends LiveCollectionController {
28250
28741
  if ((_a = this.query.dataTypes) === null || _a === void 0 ? void 0 : _a.length) {
28251
28742
  posts = filterByPostDataTypes(posts, this.query.dataTypes);
28252
28743
  }
28744
+ // Apply untilAt filtering if present (as a safety net)
28745
+ if (this.query.untilAt) {
28746
+ const validatedUntilAt = validateUntilAt(this.query.untilAt);
28747
+ const sortBy = this.query.sortBy || 'lastCreated';
28748
+ posts = posts.filter(post => !exceedsUntilAtBoundary(post.createdAt, validatedUntilAt, sortBy));
28749
+ }
28253
28750
  switch (this.query.sortBy) {
28254
28751
  case 'firstCreated':
28255
28752
  posts = posts.sort(sortByFirstCreated);
@@ -29362,6 +29859,41 @@ const leaveRoom = async (roomId) => {
29362
29859
  };
29363
29860
  /* end_public_function */
29364
29861
 
29862
+ /* begin_public_function
29863
+ id: room.update_cohost_permissions
29864
+ */
29865
+ /**
29866
+ * ```js
29867
+ * import { updateCohostPermission } from '@amityco/ts-sdk'
29868
+ * const updated = await updateCohostPermission('roomId', 'cohostId', true)
29869
+ * ```
29870
+ *
29871
+ * Updates an {@link Amity.InternalRoom}
29872
+ *
29873
+ * @param roomId The ID of the room to update
29874
+ * @param cohostId The ID of the cohost to update
29875
+ * @param canManageProductTags The permission to manage product tags
29876
+ * @returns The updated {@link Amity.InternalRoom}
29877
+ *
29878
+ * @category Room API
29879
+ * @async
29880
+ */
29881
+ const updateCohostPermission = async (roomId, cohostId, canManageProductTags) => {
29882
+ const client = getActiveClient();
29883
+ client.log('room/updatedCoHostPermission', { roomId, cohostId, canManageProductTags });
29884
+ const { data } = await client.http.put(`/api/v1/rooms/${roomId}/participants/${cohostId}`, { canManageProductTags });
29885
+ fireEvent('local.room.didUpdate', data);
29886
+ const cachedAt = client.cache && Date.now();
29887
+ if (client.cache)
29888
+ ingestInCache(data, { cachedAt });
29889
+ const { rooms } = data;
29890
+ return {
29891
+ data: roomLinkedObject(rooms[0]),
29892
+ cachedAt,
29893
+ };
29894
+ };
29895
+ /* end_public_function */
29896
+
29365
29897
  /**
29366
29898
  * ```js
29367
29899
  * import { onRoomStartBroadcasting } from '@amityco/ts-sdk-react-native'
@@ -29736,6 +30268,30 @@ const onRoomTerminated = (callback) => {
29736
30268
  return createEventSubscriber(client, 'room/onRoomTerminated', 'room.terminated', filter);
29737
30269
  };
29738
30270
 
30271
+ /**
30272
+ * ```js
30273
+ * import { onRoomDidUpdate } from '@amityco/ts-sdk'
30274
+ * const dispose = onRoomDidUpdate(room => {
30275
+ * // ...
30276
+ * })
30277
+ * ```
30278
+ *
30279
+ * Fired when a {@link Amity.Room} has been updated locally
30280
+ *
30281
+ * @param callback The function to call when the event was fired
30282
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30283
+ *
30284
+ * @category Room Events
30285
+ */
30286
+ const onRoomDidUpdate = (callback) => {
30287
+ const client = getActiveClient();
30288
+ const filter = (payload) => {
30289
+ ingestInCache(payload);
30290
+ callback(payload.rooms[0]);
30291
+ };
30292
+ return createEventSubscriber(client, 'room/onRoomDidUpdate', 'local.room.didUpdate', filter);
30293
+ };
30294
+
29739
30295
  /**
29740
30296
  * ```js
29741
30297
  * import { onRoomCreated } from '@amityco/ts-sdk-react-native'
@@ -29884,6 +30440,30 @@ const onRoomLeft = (callback) => {
29884
30440
  return createEventSubscriber(client, 'room/onRoomLeft', 'local.room.left', filter);
29885
30441
  };
29886
30442
 
30443
+ /**
30444
+ * ```js
30445
+ * import { onLocalRoomDidUpdate } from '@amityco/ts-sdk'
30446
+ * const dispose = onLocalRoomDidUpdate(room => {
30447
+ * // ...
30448
+ * })
30449
+ * ```
30450
+ *
30451
+ * Fired when a {@link Amity.Room} has been updated locally
30452
+ *
30453
+ * @param callback The function to call when the event was fired
30454
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
30455
+ *
30456
+ * @category Room Events
30457
+ */
30458
+ const onLocalRoomDidUpdate = (callback) => {
30459
+ const client = getActiveClient();
30460
+ const filter = (payload) => {
30461
+ ingestInCache(payload);
30462
+ callback(payload.rooms[0]);
30463
+ };
30464
+ return createEventSubscriber(client, 'room/onLocalRoomDidUpdate', 'room.didUpdate', filter);
30465
+ };
30466
+
29887
30467
  /**
29888
30468
  * ```js
29889
30469
  * import { onRoomParticipantRemoved } from '@amityco/ts-sdk-react-native'
@@ -29917,6 +30497,7 @@ var EnumRoomActions;
29917
30497
  EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
29918
30498
  EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
29919
30499
  EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
30500
+ EnumRoomActions["OnRoomDidUpdate"] = "OnRoomDidUpdate";
29920
30501
  })(EnumRoomActions || (EnumRoomActions = {}));
29921
30502
 
29922
30503
  const convertToRoomEventPayload = (eventHandler) => (callback) => eventHandler((payload) => {
@@ -29968,10 +30549,17 @@ const getRoomSubscription = () => [
29968
30549
  fn: convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
29969
30550
  action: EnumRoomActions.OnRoomUpdated,
29970
30551
  },
30552
+ {
30553
+ fn: onRoomDidUpdate,
30554
+ action: EnumRoomActions.OnRoomDidUpdate,
30555
+ },
30556
+ {
30557
+ fn: onLocalRoomDidUpdate,
30558
+ action: EnumRoomActions.OnRoomDidUpdate,
30559
+ },
29971
30560
  ];
29972
30561
 
29973
30562
  const getRoom = (roomId, callback) => {
29974
- // TODO: add callbackDataSelector if there are linked object fields
29975
30563
  return liveObject(roomId, callback, '_id', getRoomById, [
29976
30564
  onRoomEndBroadcasting,
29977
30565
  onRoomStartBroadcasting,
@@ -29984,6 +30572,8 @@ const getRoom = (roomId, callback) => {
29984
30572
  onRoomParticipantRemovedLocal,
29985
30573
  convertToRoomEventPayload(onRoomParticipantStageJoined),
29986
30574
  convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
30575
+ onRoomDidUpdate,
30576
+ onLocalRoomDidUpdate,
29987
30577
  ], {
29988
30578
  callbackDataSelector: (data) => {
29989
30579
  if (!data)
@@ -30176,7 +30766,7 @@ const getRooms = (params, callback, config) => {
30176
30766
  };
30177
30767
  /* end_public_function */
30178
30768
 
30179
- var index$b = /*#__PURE__*/Object.freeze({
30769
+ var index$c = /*#__PURE__*/Object.freeze({
30180
30770
  __proto__: null,
30181
30771
  createRoom: createRoom,
30182
30772
  updateRoom: updateRoom,
@@ -30190,6 +30780,7 @@ var index$b = /*#__PURE__*/Object.freeze({
30190
30780
  WatchSessionStorage: WatchSessionStorage,
30191
30781
  getWatchSessionStorage: getWatchSessionStorage,
30192
30782
  syncWatchSessions: syncWatchSessions,
30783
+ updateCohostPermission: updateCohostPermission,
30193
30784
  onRoomStartBroadcasting: onRoomStartBroadcasting,
30194
30785
  onRoomWaitingReconnect: onRoomWaitingReconnect,
30195
30786
  onRoomEndBroadcasting: onRoomEndBroadcasting,
@@ -30203,12 +30794,14 @@ var index$b = /*#__PURE__*/Object.freeze({
30203
30794
  onRoomParticipantStageLeft: onRoomParticipantStageLeft,
30204
30795
  onRoomParticipantStageJoined: onRoomParticipantStageJoined,
30205
30796
  onRoomTerminated: onRoomTerminated,
30797
+ onRoomDidUpdate: onRoomDidUpdate,
30206
30798
  onRoomCreated: onRoomCreated,
30207
30799
  onRoomUpdated: onRoomUpdated,
30208
30800
  onRoomDeleted: onRoomDeleted,
30209
30801
  onRoomStopped: onRoomStopped,
30210
30802
  onRoomParticipantRemoved: onRoomParticipantRemoved,
30211
30803
  onRoomLeft: onRoomLeft,
30804
+ onLocalRoomDidUpdate: onLocalRoomDidUpdate,
30212
30805
  getRoom: getRoom,
30213
30806
  getRooms: getRooms
30214
30807
  });
@@ -30472,7 +31065,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
30472
31065
  };
30473
31066
  /* end_public_function */
30474
31067
 
30475
- var index$a = /*#__PURE__*/Object.freeze({
31068
+ var index$b = /*#__PURE__*/Object.freeze({
30476
31069
  __proto__: null,
30477
31070
  getPostByIds: getPostByIds,
30478
31071
  createPost: createPost,
@@ -30488,6 +31081,10 @@ var index$a = /*#__PURE__*/Object.freeze({
30488
31081
  createClipPost: createClipPost,
30489
31082
  createAudioPost: createAudioPost,
30490
31083
  createMixedMediaPost: createMixedMediaPost,
31084
+ createRoomPost: createRoomPost,
31085
+ pinProduct: pinProduct,
31086
+ unpinProduct: unpinProduct,
31087
+ updateProductTags: updateProductTags,
30491
31088
  onPostCreated: onPostCreated,
30492
31089
  onPostUpdated: onPostUpdated,
30493
31090
  onPostDeleted: onPostDeleted,
@@ -31075,7 +31672,7 @@ const getStreams = (params, callback, config) => {
31075
31672
  };
31076
31673
  /* end_public_function */
31077
31674
 
31078
- var index$9 = /*#__PURE__*/Object.freeze({
31675
+ var index$a = /*#__PURE__*/Object.freeze({
31079
31676
  __proto__: null,
31080
31677
  createStream: createStream,
31081
31678
  updateStream: updateStream,
@@ -31378,7 +31975,7 @@ const stopHeartbeat = (roomId) => {
31378
31975
  };
31379
31976
  /* end_public_function */
31380
31977
 
31381
- var index$8 = /*#__PURE__*/Object.freeze({
31978
+ var index$9 = /*#__PURE__*/Object.freeze({
31382
31979
  __proto__: null,
31383
31980
  getRoomOnlineUsers: getRoomOnlineUsers,
31384
31981
  getRoomUserCount: getRoomUserCount,
@@ -31686,7 +32283,7 @@ const getPoll = (pollId, callback) => {
31686
32283
  };
31687
32284
  /* end_public_function */
31688
32285
 
31689
- var index$7 = /*#__PURE__*/Object.freeze({
32286
+ var index$8 = /*#__PURE__*/Object.freeze({
31690
32287
  __proto__: null,
31691
32288
  createPoll: createPoll,
31692
32289
  closePoll: closePoll,
@@ -31990,7 +32587,7 @@ const getPlayer = async (parameters) => {
31990
32587
  return video;
31991
32588
  };
31992
32589
 
31993
- var index$6 = /*#__PURE__*/Object.freeze({
32590
+ var index$7 = /*#__PURE__*/Object.freeze({
31994
32591
  __proto__: null,
31995
32592
  getPlayer: getPlayer
31996
32593
  });
@@ -33162,7 +33759,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
33162
33759
  };
33163
33760
  };
33164
33761
 
33165
- var index$5 = /*#__PURE__*/Object.freeze({
33762
+ var index$6 = /*#__PURE__*/Object.freeze({
33166
33763
  __proto__: null,
33167
33764
  createImageStory: createImageStory,
33168
33765
  createVideoStory: createVideoStory,
@@ -33199,7 +33796,7 @@ const getNetworkAds = async () => {
33199
33796
  };
33200
33797
  };
33201
33798
 
33202
- var index$4 = /*#__PURE__*/Object.freeze({
33799
+ var index$5 = /*#__PURE__*/Object.freeze({
33203
33800
  __proto__: null,
33204
33801
  getNetworkAds: getNetworkAds
33205
33802
  });
@@ -33590,7 +34187,7 @@ const markTraySeen = async (lastSeenAt) => {
33590
34187
  };
33591
34188
  /* end_public_function */
33592
34189
 
33593
- var index$3 = /*#__PURE__*/Object.freeze({
34190
+ var index$4 = /*#__PURE__*/Object.freeze({
33594
34191
  __proto__: null,
33595
34192
  getNotificationTraySeen: getNotificationTraySeen,
33596
34193
  getNotificationTrayItems: getNotificationTrayItems,
@@ -33638,7 +34235,11 @@ class MyInvitationsPaginationController extends PaginationController {
33638
34235
  const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
33639
34236
  const options = token ? { token } : { limit };
33640
34237
  const { data } = await this.http.get('/api/v1/invitations/me', { params: Object.assign(Object.assign({}, params), { options }) });
33641
- await getCommunities$1(data.invitations.map(invitation => invitation.communityId));
34238
+ const communityIds = data.invitations
34239
+ .filter((invitation) => invitation.targetType === 'community' && !!invitation.communityId)
34240
+ .map(invitation => invitation.communityId);
34241
+ if ((communityIds === null || communityIds === void 0 ? void 0 : communityIds.length) > 0)
34242
+ await getCommunities$1(communityIds);
33642
34243
  return data;
33643
34244
  }
33644
34245
  }
@@ -33888,7 +34489,7 @@ const getInvitations = (params, callback) => {
33888
34489
  };
33889
34490
  };
33890
34491
 
33891
- var index$2 = /*#__PURE__*/Object.freeze({
34492
+ var index$3 = /*#__PURE__*/Object.freeze({
33892
34493
  __proto__: null,
33893
34494
  cancelInvitation: cancelInvitation,
33894
34495
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -34037,7 +34638,7 @@ const getReactions = (postId, callback) => {
34037
34638
  };
34038
34639
  };
34039
34640
 
34040
- var index$1 = /*#__PURE__*/Object.freeze({
34641
+ var index$2 = /*#__PURE__*/Object.freeze({
34041
34642
  __proto__: null,
34042
34643
  createReaction: createReaction,
34043
34644
  onLiveReactionCreated: onLiveReactionCreated,
@@ -34520,7 +35121,7 @@ const getMyEvents = (params, callback, config) => {
34520
35121
  };
34521
35122
  };
34522
35123
 
34523
- var index = /*#__PURE__*/Object.freeze({
35124
+ var index$1 = /*#__PURE__*/Object.freeze({
34524
35125
  __proto__: null,
34525
35126
  createEvent: createEvent,
34526
35127
  updateEvent: updateEvent,
@@ -34541,38 +35142,299 @@ var index = /*#__PURE__*/Object.freeze({
34541
35142
  getRSVPs: getRSVPs
34542
35143
  });
34543
35144
 
35145
+ const getProduct$1 = async (productId) => {
35146
+ const client = getActiveClient();
35147
+ client.log('product/getProduct', productId);
35148
+ isInTombstone('product', productId);
35149
+ let payload;
35150
+ try {
35151
+ const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
35152
+ payload = response.data;
35153
+ }
35154
+ catch (error) {
35155
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
35156
+ pushToTombstone('product', productId);
35157
+ }
35158
+ throw error;
35159
+ }
35160
+ const cachedAt = client.cache && Date.now();
35161
+ if (client.cache)
35162
+ ingestInCache(payload, { cachedAt });
35163
+ const { products } = payload;
35164
+ const result = products.find(product => product.productId === productId);
35165
+ return {
35166
+ data: result,
35167
+ cachedAt,
35168
+ };
35169
+ };
35170
+ getProduct$1.locally = (productId) => {
35171
+ const client = getActiveClient();
35172
+ client.log('product/getProduct.locally', productId);
35173
+ if (!client.cache)
35174
+ return;
35175
+ const cached = pullFromCache(['product', 'get', productId]);
35176
+ if (!cached)
35177
+ return;
35178
+ return {
35179
+ data: cached.data,
35180
+ cachedAt: cached.cachedAt,
35181
+ };
35182
+ };
35183
+
35184
+ /* begin_public_function
35185
+ id: product.get
35186
+ */
35187
+ /**
35188
+ * ```js
35189
+ * import { ProductRepository } from '@amityco/ts-sdk';
35190
+ *
35191
+ * let product;
35192
+ *
35193
+ * const unsub = ProductRepository.getProduct(productId, response => {
35194
+ * product = response.data;
35195
+ * });
35196
+ * ```
35197
+ *
35198
+ * Observe all mutation on a given {@link Amity.Product}
35199
+ *
35200
+ * @param productId the ID of the product to observe
35201
+ * @param callback the function to call when new data are available
35202
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
35203
+ *
35204
+ * @category Product Live Object
35205
+ */
35206
+ const getProduct = (productId, callback) => {
35207
+ const responder = (snapshot) => {
35208
+ const { data } = snapshot;
35209
+ callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.product(data) : data }));
35210
+ };
35211
+ return liveObject(productId, responder, 'productId', getProduct$1, []);
35212
+ };
35213
+ /* end_public_function */
35214
+
35215
+ class SearchProductPaginationController extends PaginationController {
35216
+ async getRequest(queryParams, token) {
35217
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
35218
+ const options = token ? { token } : { limit };
35219
+ const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
35220
+ params: Object.assign(Object.assign({}, params), { options }),
35221
+ });
35222
+ return queryResponse;
35223
+ }
35224
+ }
35225
+
35226
+ class SearchProductQueryStreamController extends QueryStreamController {
35227
+ constructor(query, cacheKey, notifyChange) {
35228
+ super(query, cacheKey);
35229
+ this.notifyChange = notifyChange;
35230
+ }
35231
+ // eslint-disable-next-line class-methods-use-this
35232
+ saveToMainDB(response) {
35233
+ const client = getActiveClient();
35234
+ const cachedAt = client.cache && Date.now();
35235
+ if (client.cache) {
35236
+ ingestInCache(response, { cachedAt });
35237
+ }
35238
+ }
35239
+ appendToQueryStream(response, direction, refresh = false) {
35240
+ var _a, _b;
35241
+ if (refresh) {
35242
+ pushToCache(this.cacheKey, {
35243
+ data: response.products.map(getResolver('product')),
35244
+ });
35245
+ }
35246
+ else {
35247
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
35248
+ const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
35249
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
35250
+ }
35251
+ }
35252
+ }
35253
+
35254
+ class SearchProductLiveCollectionController extends LiveCollectionController {
35255
+ constructor(query, callback) {
35256
+ const queryStreamId = hash__default["default"](query);
35257
+ const cacheKey = ['products', 'collection', queryStreamId];
35258
+ const paginationController = new SearchProductPaginationController(query);
35259
+ super(paginationController, queryStreamId, cacheKey, callback);
35260
+ this.query = query;
35261
+ this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
35262
+ this.callback = callback.bind(this);
35263
+ this.loadPage({ initial: true });
35264
+ }
35265
+ setup() {
35266
+ var _a;
35267
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
35268
+ if (!collection) {
35269
+ pushToCache(this.cacheKey, {
35270
+ data: [],
35271
+ params: {},
35272
+ });
35273
+ }
35274
+ }
35275
+ async persistModel(queryPayload) {
35276
+ await this.queryStreamController.saveToMainDB(queryPayload);
35277
+ }
35278
+ persistQueryStream({ response, direction, refresh, }) {
35279
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
35280
+ }
35281
+ // eslint-disable-next-line class-methods-use-this
35282
+ startSubscription() {
35283
+ return [];
35284
+ }
35285
+ notifyChange({ origin, loading, error }) {
35286
+ var _a, _b;
35287
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
35288
+ if (!collection)
35289
+ return;
35290
+ const data = (_b = collection.data
35291
+ .map(id => pullFromCache(['product', 'get', id]))
35292
+ .filter(isNonNullable)
35293
+ .map(({ data }) => data)
35294
+ .map(LinkedObject.product)) !== null && _b !== void 0 ? _b : [];
35295
+ if (!this.shouldNotify(data) && origin === 'event')
35296
+ return;
35297
+ this.callback({
35298
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
35299
+ data,
35300
+ hasNextPage: !!this.paginationController.getNextToken(),
35301
+ loading,
35302
+ error,
35303
+ });
35304
+ }
35305
+ }
35306
+
35307
+ /* begin_public_function
35308
+ id: product.search
35309
+ */
35310
+ /**
35311
+ * ```js
35312
+ * import { ProductRepository } from '@amityco/ts-sdk'
35313
+ *
35314
+ * let products = []
35315
+ * const unsub = ProductRepository.searchProducts({
35316
+ * keyword: string,
35317
+ * }, response => merge(products, response.data))
35318
+ * ```
35319
+ *
35320
+ * Observe all mutations on a list of {@link Amity.Product}
35321
+ *
35322
+ * @param params.keyword the search keyword
35323
+ * @param params.isActive filter by active status
35324
+ * @param params.isDeleted filter by deleted status
35325
+ * @param params.sortBy sort option
35326
+ * @param params.sortOrder order option
35327
+ * @param callback the function to call when new data are available
35328
+ * @param config
35329
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
35330
+ *
35331
+ * @category Products Live Collection
35332
+ */
35333
+ const searchProducts = (params, callback, config) => {
35334
+ const { log, cache } = getActiveClient();
35335
+ if (!cache) {
35336
+ console.log(ENABLE_CACHE_MESSAGE);
35337
+ }
35338
+ const timestamp = Date.now();
35339
+ log(`searchProducts(tmpid: ${timestamp}) > listen`);
35340
+ const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
35341
+ const disposers = productsLiveCollection.startSubscription();
35342
+ const cacheKey = productsLiveCollection.getCacheKey();
35343
+ disposers.push(() => dropFromCache(cacheKey));
35344
+ return () => {
35345
+ log(`searchProducts(tmpid: ${timestamp}) > dispose`);
35346
+ disposers.forEach(fn => fn());
35347
+ };
35348
+ };
35349
+ /* end_public_function */
35350
+
35351
+ var index = /*#__PURE__*/Object.freeze({
35352
+ __proto__: null,
35353
+ getProduct: getProduct,
35354
+ searchProducts: searchProducts
35355
+ });
35356
+
35357
+ /**
35358
+ * Helper class for managing product tags per media attachment.
35359
+ *
35360
+ * This class provides a convenient way to organize product tags by file ID,
35361
+ * allowing you to associate multiple products with individual media attachments
35362
+ * (images, videos) in a post.
35363
+ *
35364
+ * @example
35365
+ * ```typescript
35366
+ * const attachmentTags = new AmityAttachmentProductTags();
35367
+ *
35368
+ * // Set tags to specific images
35369
+ *
35370
+ * attachmentTags.set('image-file-2', [
35371
+ * { productId: 'product-3' },
35372
+ * { productId: 'product-4' },
35373
+ * ]);
35374
+ *
35375
+ * // Get tags for a specific file
35376
+ * const tagsOnImage1 = attachmentTags.get('image-file-1');
35377
+ * // Returns: [{ productId: 'product-1' }, { productId: 'product-2' }]
35378
+ * ```
35379
+ */
35380
+ class AmityAttachmentProductTags {
35381
+ constructor() {
35382
+ this.map = new Map();
35383
+ }
35384
+ /**
35385
+ * Get all product tags associated with a specific file.
35386
+ *
35387
+ * @param fileId - The ID of the file (image/video)
35388
+ * @returns Array of product tags for the file, empty array if none exist
35389
+ */
35390
+ get(fileId) {
35391
+ return this.map.get(fileId) || [];
35392
+ }
35393
+ /**
35394
+ * Set product tags for a specific file, replacing any existing tags.
35395
+ *
35396
+ * @param fileId - The ID of the file (image/video)
35397
+ * @param tags - Array of product tags to set for the file
35398
+ */
35399
+ set(fileId, tags) {
35400
+ this.map.set(fileId, tags);
35401
+ }
35402
+ }
35403
+
34544
35404
  exports.API_REGIONS = API_REGIONS;
34545
- exports.AdRepository = index$4;
34546
- exports.CategoryRepository = index$e;
34547
- exports.ChannelRepository = index$i;
34548
- exports.Client = index$r;
34549
- exports.CommentRepository = index$d;
35405
+ exports.AdRepository = index$5;
35406
+ exports.AmityAttachmentProductTags = AmityAttachmentProductTags;
35407
+ exports.CategoryRepository = index$f;
35408
+ exports.ChannelRepository = index$j;
35409
+ exports.Client = index$s;
35410
+ exports.CommentRepository = index$e;
34550
35411
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
34551
35412
  exports.CommunityPostSettings = CommunityPostSettings;
34552
- exports.CommunityRepository = index$f;
35413
+ exports.CommunityRepository = index$g;
34553
35414
  exports.ContentFeedType = ContentFeedType;
34554
35415
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
34555
- exports.EventRepository = index;
34556
- exports.FeedRepository = index$c;
34557
- exports.FileRepository = index$o;
35416
+ exports.EventRepository = index$1;
35417
+ exports.FeedRepository = index$d;
35418
+ exports.FileRepository = index$p;
34558
35419
  exports.FileType = FileType;
34559
35420
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
34560
- exports.InvitationRepository = index$2;
34561
- exports.LiveReactionRepository = index$1;
34562
- exports.LiveStreamPlayer = index$6;
35421
+ exports.InvitationRepository = index$3;
35422
+ exports.LiveReactionRepository = index$2;
35423
+ exports.LiveStreamPlayer = index$7;
34563
35424
  exports.MessageContentType = MessageContentType;
34564
- exports.MessageRepository = index$m;
34565
- exports.PollRepository = index$7;
35425
+ exports.MessageRepository = index$n;
35426
+ exports.PollRepository = index$8;
34566
35427
  exports.PostContentType = PostContentType;
34567
- exports.PostRepository = index$a;
35428
+ exports.PostRepository = index$b;
34568
35429
  exports.PostStructureType = PostStructureType;
34569
- exports.ReactionRepository = index$n;
34570
- exports.RoomPresenceRepository = index$8;
34571
- exports.RoomRepository = index$b;
34572
- exports.StoryRepository = index$5;
34573
- exports.StreamRepository = index$9;
34574
- exports.SubChannelRepository = index$l;
34575
- exports.UserRepository = index$p;
35430
+ exports.ProductRepository = index;
35431
+ exports.ReactionRepository = index$o;
35432
+ exports.RoomPresenceRepository = index$9;
35433
+ exports.RoomRepository = index$c;
35434
+ exports.StoryRepository = index$6;
35435
+ exports.StreamRepository = index$a;
35436
+ exports.SubChannelRepository = index$m;
35437
+ exports.UserRepository = index$q;
34576
35438
  exports.VERSION = VERSION;
34577
35439
  exports.VideoResolution = VideoResolution;
34578
35440
  exports.VideoSize = VideoSize;
@@ -34585,6 +35447,7 @@ exports.deleteReport = deleteReport;
34585
35447
  exports.disableCache = disableCache;
34586
35448
  exports.dropFromCache = dropFromCache;
34587
35449
  exports.enableCache = enableCache;
35450
+ exports.exceedsUntilAtBoundary = exceedsUntilAtBoundary;
34588
35451
  exports.filterByChannelMembership = filterByChannelMembership;
34589
35452
  exports.filterByCommunityMembership = filterByCommunityMembership;
34590
35453
  exports.filterByFeedType = filterByFeedType;
@@ -34594,6 +35457,7 @@ exports.filterByPropInclusion = filterByPropInclusion;
34594
35457
  exports.filterByPropIntersection = filterByPropIntersection;
34595
35458
  exports.filterBySearchTerm = filterBySearchTerm;
34596
35459
  exports.filterByStringComparePartially = filterByStringComparePartially;
35460
+ exports.filterByUntilAt = filterByUntilAt;
34597
35461
  exports.getChannelTopic = getChannelTopic;
34598
35462
  exports.getCommentTopic = getCommentTopic;
34599
35463
  exports.getCommunityStoriesTopic = getCommunityStoriesTopic;
@@ -34628,7 +35492,7 @@ exports.isPaged = isPaged;
34628
35492
  exports.isReportedByMe = isReportedByMe;
34629
35493
  exports.isSkip = isSkip;
34630
35494
  exports.mergeInCache = mergeInCache;
34631
- exports.notificationTray = index$3;
35495
+ exports.notificationTray = index$4;
34632
35496
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
34633
35497
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
34634
35498
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;
@@ -34660,4 +35524,5 @@ exports.toPage = toPage;
34660
35524
  exports.toPageRaw = toPageRaw;
34661
35525
  exports.toToken = toToken;
34662
35526
  exports.upsertInCache = upsertInCache;
35527
+ exports.validateUntilAt = validateUntilAt;
34663
35528
  exports.wipeCache = wipeCache;