@amityco/ts-sdk 7.12.1-df30e76f.0 → 7.12.1-e2c3e656.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 (72) hide show
  1. package/dist/@types/core/events.d.ts +1 -1
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +0 -2
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +0 -4
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/client.d.ts +0 -3
  8. package/dist/@types/domains/client.d.ts.map +1 -1
  9. package/dist/@types/domains/post.d.ts +0 -1
  10. package/dist/@types/domains/post.d.ts.map +1 -1
  11. package/dist/@types/domains/room.d.ts +1 -1
  12. package/dist/@types/domains/room.d.ts.map +1 -1
  13. package/dist/@types/index.d.ts +0 -1
  14. package/dist/@types/index.d.ts.map +1 -1
  15. package/dist/client/api/index.d.ts +0 -1
  16. package/dist/client/api/index.d.ts.map +1 -1
  17. package/dist/client/api/setSessionState.d.ts +1 -1
  18. package/dist/client/api/setSessionState.d.ts.map +1 -1
  19. package/dist/client/events/onSessionStateChange.d.ts +1 -1
  20. package/dist/client/events/onSessionStateChange.d.ts.map +1 -1
  21. package/dist/client/utils/SessionWatcher.d.ts +2 -2
  22. package/dist/client/utils/SessionWatcher.d.ts.map +1 -1
  23. package/dist/core/events.d.ts +1 -1
  24. package/dist/core/events.d.ts.map +1 -1
  25. package/dist/core/model/idResolvers.d.ts.map +1 -1
  26. package/dist/core/model/index.d.ts.map +1 -1
  27. package/dist/feedRepository/observers/utils.d.ts +1 -1
  28. package/dist/index.cjs.js +74 -329
  29. package/dist/index.d.ts +0 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.esm.js +52 -306
  32. package/dist/index.umd.js +2 -2
  33. package/dist/postRepository/api/createPost.d.ts +0 -2
  34. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  35. package/dist/postRepository/api/editPost.d.ts +0 -2
  36. package/dist/postRepository/api/editPost.d.ts.map +1 -1
  37. package/dist/postRepository/observers/utils.d.ts +2 -2
  38. package/dist/reactionRepository/events/onReactionAdded.d.ts +1 -1
  39. package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
  40. package/dist/reactionRepository/events/onReactionRemoved.d.ts +1 -1
  41. package/dist/reactionRepository/events/onReactionRemoved.d.ts.map +1 -1
  42. package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
  43. package/dist/utils/event.d.ts +1 -1
  44. package/dist/utils/event.d.ts.map +1 -1
  45. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  46. package/dist/utils/liveObject.d.ts +1 -1
  47. package/dist/utils/liveObject.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/dist/@types/domains/product.d.ts +0 -77
  50. package/dist/@types/domains/product.d.ts.map +0 -1
  51. package/dist/client/api/getProductCatalogueSetting.d.ts +0 -15
  52. package/dist/client/api/getProductCatalogueSetting.d.ts.map +0 -1
  53. package/dist/productRepository/index.d.ts +0 -2
  54. package/dist/productRepository/index.d.ts.map +0 -1
  55. package/dist/productRepository/internalApi/getProduct.d.ts +0 -5
  56. package/dist/productRepository/internalApi/getProduct.d.ts.map +0 -1
  57. package/dist/productRepository/internalApi/index.d.ts +0 -2
  58. package/dist/productRepository/internalApi/index.d.ts.map +0 -1
  59. package/dist/productRepository/observers/getProduct.d.ts +0 -21
  60. package/dist/productRepository/observers/getProduct.d.ts.map +0 -1
  61. package/dist/productRepository/observers/index.d.ts +0 -3
  62. package/dist/productRepository/observers/index.d.ts.map +0 -1
  63. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts +0 -15
  64. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts.map +0 -1
  65. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts +0 -5
  66. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts.map +0 -1
  67. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts +0 -8
  68. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts.map +0 -1
  69. package/dist/productRepository/observers/searchProducts.d.ts +0 -25
  70. package/dist/productRepository/observers/searchProducts.d.ts.map +0 -1
  71. package/dist/utils/linkedObject/productTagLinkedObject.d.ts +0 -2
  72. package/dist/utils/linkedObject/productTagLinkedObject.d.ts.map +0 -1
package/dist/index.cjs.js CHANGED
@@ -689,7 +689,6 @@ const idResolvers = {
689
689
  viewer: ({ userId }) => userId,
690
690
  event: ({ eventId }) => eventId,
691
691
  eventResponse: ({ userId }) => userId,
692
- product: ({ _id }) => _id,
693
692
  };
694
693
  /**
695
694
  * Retrieve the id resolver matching a domain name
@@ -749,7 +748,6 @@ const PAYLOAD2MODEL = {
749
748
  events: 'event',
750
749
  viewers: 'viewer',
751
750
  eventResponses: 'eventResponse',
752
- products: 'product',
753
751
  };
754
752
  /** hidden */
755
753
  const isOutdated = (prevData, nextData) => {
@@ -6830,11 +6828,11 @@ class SessionWatcher {
6830
6828
  this._listener.delete(callback);
6831
6829
  };
6832
6830
  }
6833
- setSessionState(state) {
6831
+ setSessionState(state, reason) {
6834
6832
  if (this._sessionState === state)
6835
6833
  return;
6836
6834
  this._sessionState = state;
6837
- this._listener.forEach(cb => cb(state));
6835
+ this._listener.forEach(cb => cb(state, reason));
6838
6836
  }
6839
6837
  destroy() {
6840
6838
  this._listener.clear();
@@ -7274,9 +7272,9 @@ const isValidStateChange = (prevState, nextState) => {
7274
7272
  *
7275
7273
  * @category private
7276
7274
  */
7277
- const setSessionState = (state) => {
7275
+ const setSessionState = (state, reason) => {
7278
7276
  const client = getActiveClient();
7279
- client.log('client/api/setSessionState', state);
7277
+ client.log('client/api/setSessionState', state, reason);
7280
7278
  const { sessionState: prevState } = client;
7281
7279
  if (prevState === state)
7282
7280
  return false;
@@ -7285,7 +7283,7 @@ const setSessionState = (state) => {
7285
7283
  throw new ASCError(`Session state cannot change from ${prevState} to ${state}`, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
7286
7284
  }
7287
7285
  client.sessionState = state;
7288
- SessionWatcher$1.getInstance().setSessionState(state);
7286
+ SessionWatcher$1.getInstance().setSessionState(state, reason);
7289
7287
  return true;
7290
7288
  };
7291
7289
 
@@ -8738,7 +8736,7 @@ const logout = async () => {
8738
8736
  */
8739
8737
  const terminateClient = (terminationReason) => {
8740
8738
  const client = getActiveClient();
8741
- setSessionState("terminated" /* Amity.SessionStates.TERMINATED */);
8739
+ setSessionState("terminated" /* Amity.SessionStates.TERMINATED */, terminationReason);
8742
8740
  if (client.http.defaults.metadata) {
8743
8741
  if (terminationReason === "globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */)
8744
8742
  client.http.defaults.metadata.isGlobalBanned = true;
@@ -10065,29 +10063,6 @@ const getShareableLinkConfiguration = async () => {
10065
10063
  return data;
10066
10064
  };
10067
10065
 
10068
- /* begin_public_function
10069
- id: client.getProductCatalogueSetting
10070
- */
10071
- /**
10072
- * ```js
10073
- * import { getProductCatalogueSetting } from '@amityco/ts-sdk'
10074
- * const productCatalogueSetting = await getProductCatalogueSetting()
10075
- * ```
10076
- *
10077
- * Fetches a {@link Amity.ProductCatalogueSetting} object
10078
- *
10079
- * @returns A Promise of {@link Amity.ProductCatalogueSetting} object
10080
- *
10081
- * @category Client API
10082
- * @async
10083
- */
10084
- const getProductCatalogueSetting = async () => {
10085
- const client = getActiveClient();
10086
- const { data } = await client.http.get(`/api/v3/network-settings/product-catalogue`);
10087
- return data;
10088
- };
10089
- /* end_public_function */
10090
-
10091
10066
  /**
10092
10067
  * Retrieves a pair of {@link Amity.Tokens} necessary for connection
10093
10068
  *
@@ -10580,7 +10555,7 @@ const getUserUnread = (callback) => {
10580
10555
  };
10581
10556
  };
10582
10557
 
10583
- var index$s = /*#__PURE__*/Object.freeze({
10558
+ var index$r = /*#__PURE__*/Object.freeze({
10584
10559
  __proto__: null,
10585
10560
  getActiveClient: getActiveClient,
10586
10561
  getActiveUser: getActiveUser,
@@ -10600,7 +10575,6 @@ var index$s = /*#__PURE__*/Object.freeze({
10600
10575
  getLinkPreviewMetadata: getLinkPreviewMetadata,
10601
10576
  getSocialSettings: getSocialSettings,
10602
10577
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10603
- getProductCatalogueSetting: getProductCatalogueSetting,
10604
10578
  loginAsVisitor: loginAsVisitor,
10605
10579
  loginAsBot: loginAsBot,
10606
10580
  getCurrentUser: getCurrentUser,
@@ -10658,12 +10632,19 @@ const blockUser = async (userId) => {
10658
10632
  const { data } = await client.http.post(`/api/v4/me/user-blocks/${userId}`);
10659
10633
  const cachedAt = client.cache && Date.now();
10660
10634
  const { follows, followCounts } = data;
10661
- const followStatus = { follows };
10635
+ const blockedFollowStatus = { follows };
10662
10636
  if (client.cache) {
10663
- ingestInCache(followStatus, { cachedAt });
10637
+ ingestInCache(blockedFollowStatus, { cachedAt });
10664
10638
  upsertInCache(['followInfo', 'get', userId], followCounts[0], { cachedAt });
10665
10639
  }
10666
- const payload = prepareFollowStatusPayload(followStatus);
10640
+ // need to swap {from} and {to} to get the correct id for unfollow event to filter from follower live collection
10641
+ const blockedUnfollowStatus = {
10642
+ follows: follows.map(follow => {
10643
+ const unfollowStatus = Object.assign(Object.assign({}, follow), { to: follow.from, from: follow.to, status: 'none' });
10644
+ return follow.status === 'blocked' ? unfollowStatus : follow;
10645
+ }),
10646
+ };
10647
+ const payload = prepareFollowStatusPayload(blockedUnfollowStatus);
10667
10648
  fireEvent('local.follow.unfollowed', payload);
10668
10649
  return data;
10669
10650
  };
@@ -11801,7 +11782,7 @@ const getMyFollowInfo = (callback) => {
11801
11782
  };
11802
11783
  /* end_public_function */
11803
11784
 
11804
- var index$r = /*#__PURE__*/Object.freeze({
11785
+ var index$q = /*#__PURE__*/Object.freeze({
11805
11786
  __proto__: null,
11806
11787
  blockUser: blockUser,
11807
11788
  unBlockUser: unBlockUser,
@@ -13909,11 +13890,6 @@ const communityLinkedObject = (community) => {
13909
13890
  } });
13910
13891
  };
13911
13892
 
13912
- const productTagLinkedObject = (productTag) => {
13913
- var _a;
13914
- return Object.assign(Object.assign({}, productTag), { product: (_a = pullFromCache(['product', 'get', productTag.productId])) === null || _a === void 0 ? void 0 : _a.data });
13915
- };
13916
-
13917
13893
  const postLinkedObject = (post) => {
13918
13894
  return shallowClone(post, {
13919
13895
  childrenPosts: post.children
@@ -13926,10 +13902,6 @@ const postLinkedObject = (post) => {
13926
13902
  analyticsEngineInstance.markPostAsViewed(post.postId);
13927
13903
  },
13928
13904
  },
13929
- get productTags() {
13930
- var _a, _b;
13931
- return (_b = (_a = post.productTags) === null || _a === void 0 ? void 0 : _a.map(productTag => productTagLinkedObject(productTag))) !== null && _b !== void 0 ? _b : [];
13932
- },
13933
13905
  get latestComments() {
13934
13906
  if (!post.comments)
13935
13907
  return [];
@@ -15919,9 +15891,9 @@ var AmityUserSearchMatchType;
15919
15891
  AmityUserSearchMatchType["PARTIAL"] = "partial";
15920
15892
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
15921
15893
 
15922
- var index$q = /*#__PURE__*/Object.freeze({
15894
+ var index$p = /*#__PURE__*/Object.freeze({
15923
15895
  __proto__: null,
15924
- Relationship: index$r,
15896
+ Relationship: index$q,
15925
15897
  getUserByIds: getUserByIds,
15926
15898
  updateUser: updateUser,
15927
15899
  flagUser: flagUser,
@@ -16324,7 +16296,7 @@ const uploadAudio = async (formData, onProgress) => {
16324
16296
  };
16325
16297
  /* end_public_function */
16326
16298
 
16327
- var index$p = /*#__PURE__*/Object.freeze({
16299
+ var index$o = /*#__PURE__*/Object.freeze({
16328
16300
  __proto__: null,
16329
16301
  getFile: getFile,
16330
16302
  uploadFile: uploadFile,
@@ -18136,7 +18108,7 @@ const getReactions$1 = (params, callback, config) => {
18136
18108
  };
18137
18109
  /* end_public_function */
18138
18110
 
18139
- var index$o = /*#__PURE__*/Object.freeze({
18111
+ var index$n = /*#__PURE__*/Object.freeze({
18140
18112
  __proto__: null,
18141
18113
  addReaction: addReaction,
18142
18114
  removeReaction: removeReaction,
@@ -19908,7 +19880,7 @@ const getMessages = (params, callback, config) => {
19908
19880
  };
19909
19881
  /* end_public_function */
19910
19882
 
19911
- var index$n = /*#__PURE__*/Object.freeze({
19883
+ var index$m = /*#__PURE__*/Object.freeze({
19912
19884
  __proto__: null,
19913
19885
  createMessage: createMessage,
19914
19886
  updateMessage: updateMessage,
@@ -20434,7 +20406,7 @@ const stopMessageReceiptSync = (subChannelId) => {
20434
20406
  };
20435
20407
  /* end_public_function */
20436
20408
 
20437
- var index$m = /*#__PURE__*/Object.freeze({
20409
+ var index$l = /*#__PURE__*/Object.freeze({
20438
20410
  __proto__: null,
20439
20411
  getSubChannelByIds: getSubChannels$1,
20440
20412
  createSubChannel: createSubChannel,
@@ -21761,7 +21733,7 @@ const searchMembers$1 = (params, callback, config) => {
21761
21733
  };
21762
21734
  /* end_public_function */
21763
21735
 
21764
- var index$l = /*#__PURE__*/Object.freeze({
21736
+ var index$k = /*#__PURE__*/Object.freeze({
21765
21737
  __proto__: null,
21766
21738
  addMembers: addMembers$1,
21767
21739
  removeMembers: removeMembers$1,
@@ -21964,7 +21936,7 @@ const unmuteMembers = async (channelId, userIds) => {
21964
21936
  };
21965
21937
  /* end_public_function */
21966
21938
 
21967
- var index$k = /*#__PURE__*/Object.freeze({
21939
+ var index$j = /*#__PURE__*/Object.freeze({
21968
21940
  __proto__: null,
21969
21941
  addRole: addRole,
21970
21942
  removeRole: removeRole,
@@ -21974,10 +21946,10 @@ var index$k = /*#__PURE__*/Object.freeze({
21974
21946
  unmuteMembers: unmuteMembers
21975
21947
  });
21976
21948
 
21977
- var index$j = /*#__PURE__*/Object.freeze({
21949
+ var index$i = /*#__PURE__*/Object.freeze({
21978
21950
  __proto__: null,
21979
- Membership: index$l,
21980
- Moderation: index$k,
21951
+ Membership: index$k,
21952
+ Moderation: index$j,
21981
21953
  getChannelByIds: getChannelByIds$1,
21982
21954
  createChannel: createChannel,
21983
21955
  updateChannel: updateChannel,
@@ -23380,7 +23352,7 @@ const searchMembers = (params, callback, config) => {
23380
23352
  };
23381
23353
  /* end_public_function */
23382
23354
 
23383
- var index$i = /*#__PURE__*/Object.freeze({
23355
+ var index$h = /*#__PURE__*/Object.freeze({
23384
23356
  __proto__: null,
23385
23357
  addMembers: addMembers,
23386
23358
  removeMembers: removeMembers,
@@ -24631,7 +24603,7 @@ const unbanMembers = async (communityId, userIds) => {
24631
24603
  };
24632
24604
  /* end_public_function */
24633
24605
 
24634
- var index$h = /*#__PURE__*/Object.freeze({
24606
+ var index$g = /*#__PURE__*/Object.freeze({
24635
24607
  __proto__: null,
24636
24608
  addRoles: addRoles,
24637
24609
  removeRoles: removeRoles,
@@ -24639,10 +24611,10 @@ var index$h = /*#__PURE__*/Object.freeze({
24639
24611
  unbanMembers: unbanMembers
24640
24612
  });
24641
24613
 
24642
- var index$g = /*#__PURE__*/Object.freeze({
24614
+ var index$f = /*#__PURE__*/Object.freeze({
24643
24615
  __proto__: null,
24644
- Moderation: index$h,
24645
- Membership: index$i,
24616
+ Moderation: index$g,
24617
+ Membership: index$h,
24646
24618
  getCommunityByIds: getCommunities$1,
24647
24619
  createCommunity: createCommunity,
24648
24620
  updateCommunity: updateCommunity,
@@ -24876,7 +24848,7 @@ const getCategories = (params, callback, config) => {
24876
24848
  };
24877
24849
  /* end_public_function */
24878
24850
 
24879
- var index$f = /*#__PURE__*/Object.freeze({
24851
+ var index$e = /*#__PURE__*/Object.freeze({
24880
24852
  __proto__: null,
24881
24853
  getCategory: getCategory,
24882
24854
  getCategories: getCategories
@@ -25935,7 +25907,7 @@ const getComments = (params, callback, config) => {
25935
25907
  };
25936
25908
  /* end_public_function */
25937
25909
 
25938
- var index$e = /*#__PURE__*/Object.freeze({
25910
+ var index$d = /*#__PURE__*/Object.freeze({
25939
25911
  __proto__: null,
25940
25912
  getCommentByIds: getCommentByIds,
25941
25913
  createComment: createComment,
@@ -26606,7 +26578,7 @@ const getUserFeed = (params, callback, config) => {
26606
26578
  };
26607
26579
  /* end_public_function */
26608
26580
 
26609
- var index$d = /*#__PURE__*/Object.freeze({
26581
+ var index$c = /*#__PURE__*/Object.freeze({
26610
26582
  __proto__: null,
26611
26583
  queryGlobalFeed: queryGlobalFeed,
26612
26584
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -26721,15 +26693,7 @@ const createPost = async (bundle) => {
26721
26693
  // eslint-disable-next-line no-param-reassign
26722
26694
  delete bundle.dataType;
26723
26695
  }
26724
- const { attachments } = bundle;
26725
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
26726
- ? attachments.map(attachment => {
26727
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
26728
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
26729
- return attachment;
26730
- })
26731
- : attachments;
26732
- const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { attachments: processedAttachments }));
26696
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
26733
26697
  fireEvent('post.created', payload);
26734
26698
  const data = preparePostPayload(payload);
26735
26699
  const cachedAt = client.cache && Date.now();
@@ -26766,15 +26730,7 @@ const createPost = async (bundle) => {
26766
26730
  const editPost = async (postId, patch) => {
26767
26731
  const client = getActiveClient();
26768
26732
  client.log('user/editPost', patch);
26769
- const { attachments } = patch;
26770
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
26771
- ? attachments.map(attachment => {
26772
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
26773
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
26774
- return attachment;
26775
- })
26776
- : attachments;
26777
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
26733
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
26778
26734
  const data = prepareMembershipPayload(payload, 'communityUsers');
26779
26735
  const cachedAt = client.cache && Date.now();
26780
26736
  if (client.cache)
@@ -29418,7 +29374,7 @@ const getRooms = (params, callback, config) => {
29418
29374
  };
29419
29375
  /* end_public_function */
29420
29376
 
29421
- var index$c = /*#__PURE__*/Object.freeze({
29377
+ var index$b = /*#__PURE__*/Object.freeze({
29422
29378
  __proto__: null,
29423
29379
  createRoom: createRoom,
29424
29380
  updateRoom: updateRoom,
@@ -29714,7 +29670,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
29714
29670
  };
29715
29671
  /* end_public_function */
29716
29672
 
29717
- var index$b = /*#__PURE__*/Object.freeze({
29673
+ var index$a = /*#__PURE__*/Object.freeze({
29718
29674
  __proto__: null,
29719
29675
  getPostByIds: getPostByIds,
29720
29676
  createPost: createPost,
@@ -30324,7 +30280,7 @@ const getStreams = (params, callback, config) => {
30324
30280
  };
30325
30281
  };
30326
30282
 
30327
- var index$a = /*#__PURE__*/Object.freeze({
30283
+ var index$9 = /*#__PURE__*/Object.freeze({
30328
30284
  __proto__: null,
30329
30285
  createStream: createStream,
30330
30286
  updateStream: updateStream,
@@ -30627,7 +30583,7 @@ const stopHeartbeat = (roomId) => {
30627
30583
  };
30628
30584
  /* end_public_function */
30629
30585
 
30630
- var index$9 = /*#__PURE__*/Object.freeze({
30586
+ var index$8 = /*#__PURE__*/Object.freeze({
30631
30587
  __proto__: null,
30632
30588
  getRoomOnlineUsers: getRoomOnlineUsers,
30633
30589
  getRoomUserCount: getRoomUserCount,
@@ -30935,7 +30891,7 @@ const getPoll = (pollId, callback) => {
30935
30891
  };
30936
30892
  /* end_public_function */
30937
30893
 
30938
- var index$8 = /*#__PURE__*/Object.freeze({
30894
+ var index$7 = /*#__PURE__*/Object.freeze({
30939
30895
  __proto__: null,
30940
30896
  createPoll: createPoll,
30941
30897
  closePoll: closePoll,
@@ -31239,7 +31195,7 @@ const getPlayer = async (parameters) => {
31239
31195
  return video;
31240
31196
  };
31241
31197
 
31242
- var index$7 = /*#__PURE__*/Object.freeze({
31198
+ var index$6 = /*#__PURE__*/Object.freeze({
31243
31199
  __proto__: null,
31244
31200
  getPlayer: getPlayer
31245
31201
  });
@@ -32412,7 +32368,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
32412
32368
  };
32413
32369
  };
32414
32370
 
32415
- var index$6 = /*#__PURE__*/Object.freeze({
32371
+ var index$5 = /*#__PURE__*/Object.freeze({
32416
32372
  __proto__: null,
32417
32373
  createImageStory: createImageStory,
32418
32374
  createVideoStory: createVideoStory,
@@ -32449,7 +32405,7 @@ const getNetworkAds = async () => {
32449
32405
  };
32450
32406
  };
32451
32407
 
32452
- var index$5 = /*#__PURE__*/Object.freeze({
32408
+ var index$4 = /*#__PURE__*/Object.freeze({
32453
32409
  __proto__: null,
32454
32410
  getNetworkAds: getNetworkAds
32455
32411
  });
@@ -32840,7 +32796,7 @@ const markTraySeen = async (lastSeenAt) => {
32840
32796
  };
32841
32797
  /* end_public_function */
32842
32798
 
32843
- var index$4 = /*#__PURE__*/Object.freeze({
32799
+ var index$3 = /*#__PURE__*/Object.freeze({
32844
32800
  __proto__: null,
32845
32801
  getNotificationTraySeen: getNotificationTraySeen,
32846
32802
  getNotificationTrayItems: getNotificationTrayItems,
@@ -33138,7 +33094,7 @@ const getInvitations = (params, callback) => {
33138
33094
  };
33139
33095
  };
33140
33096
 
33141
- var index$3 = /*#__PURE__*/Object.freeze({
33097
+ var index$2 = /*#__PURE__*/Object.freeze({
33142
33098
  __proto__: null,
33143
33099
  cancelInvitation: cancelInvitation,
33144
33100
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -33287,7 +33243,7 @@ const getReactions = (postId, callback) => {
33287
33243
  };
33288
33244
  };
33289
33245
 
33290
- var index$2 = /*#__PURE__*/Object.freeze({
33246
+ var index$1 = /*#__PURE__*/Object.freeze({
33291
33247
  __proto__: null,
33292
33248
  createReaction: createReaction,
33293
33249
  onLiveReactionCreated: onLiveReactionCreated,
@@ -33770,7 +33726,7 @@ const getMyEvents = (params, callback, config) => {
33770
33726
  };
33771
33727
  };
33772
33728
 
33773
- var index$1 = /*#__PURE__*/Object.freeze({
33729
+ var index = /*#__PURE__*/Object.freeze({
33774
33730
  __proto__: null,
33775
33731
  createEvent: createEvent,
33776
33732
  updateEvent: updateEvent,
@@ -33791,249 +33747,38 @@ var index$1 = /*#__PURE__*/Object.freeze({
33791
33747
  getRSVPs: getRSVPs
33792
33748
  });
33793
33749
 
33794
- const getProduct$1 = async (productId) => {
33795
- const client = getActiveClient();
33796
- client.log('product/getProduct', productId);
33797
- isInTombstone('product', productId);
33798
- let payload;
33799
- try {
33800
- const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
33801
- payload = response.data;
33802
- }
33803
- catch (error) {
33804
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
33805
- pushToTombstone('product', productId);
33806
- }
33807
- throw error;
33808
- }
33809
- const cachedAt = client.cache && Date.now();
33810
- if (client.cache)
33811
- ingestInCache(payload, { cachedAt });
33812
- const { products } = payload;
33813
- const result = products.find(product => product.productId === productId);
33814
- return {
33815
- data: result,
33816
- cachedAt,
33817
- };
33818
- };
33819
- getProduct$1.locally = (productId) => {
33820
- const client = getActiveClient();
33821
- client.log('product/getProduct.locally', productId);
33822
- if (!client.cache)
33823
- return;
33824
- const cached = pullFromCache(['product', 'get', productId]);
33825
- if (!cached)
33826
- return;
33827
- return {
33828
- data: cached.data,
33829
- cachedAt: cached.cachedAt,
33830
- };
33831
- };
33832
-
33833
- /* begin_public_function
33834
- id: product.get
33835
- */
33836
- /**
33837
- * ```js
33838
- * import { ProductRepository } from '@amityco/ts-sdk';
33839
- *
33840
- * let product;
33841
- *
33842
- * const unsub = ProductRepository.getProduct(productId, response => {
33843
- * product = response.data;
33844
- * });
33845
- * ```
33846
- *
33847
- * Observe all mutation on a given {@link Amity.Product}
33848
- *
33849
- * @param productId the ID of the product to observe
33850
- * @param callback the function to call when new data are available
33851
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
33852
- *
33853
- * @category Product Live Object
33854
- */
33855
- const getProduct = (productId, callback) => {
33856
- const responder = (snapshot) => {
33857
- callback(snapshot);
33858
- };
33859
- return liveObject(productId, responder, 'productId', getProduct$1, []);
33860
- };
33861
- /* end_public_function */
33862
-
33863
- class SearchProductPaginationController extends PaginationController {
33864
- async getRequest(queryParams, token) {
33865
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
33866
- const options = token ? { token } : { limit };
33867
- const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
33868
- params: Object.assign(Object.assign({}, params), { options }),
33869
- });
33870
- return queryResponse;
33871
- }
33872
- }
33873
-
33874
- class SearchProductQueryStreamController extends QueryStreamController {
33875
- constructor(query, cacheKey, notifyChange) {
33876
- super(query, cacheKey);
33877
- this.notifyChange = notifyChange;
33878
- }
33879
- // eslint-disable-next-line class-methods-use-this
33880
- saveToMainDB(response) {
33881
- const client = getActiveClient();
33882
- const cachedAt = client.cache && Date.now();
33883
- if (client.cache) {
33884
- ingestInCache(response, { cachedAt });
33885
- }
33886
- }
33887
- appendToQueryStream(response, direction, refresh = false) {
33888
- var _a, _b;
33889
- if (refresh) {
33890
- pushToCache(this.cacheKey, {
33891
- data: response.products.map(getResolver('product')),
33892
- });
33893
- }
33894
- else {
33895
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
33896
- const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
33897
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
33898
- }
33899
- }
33900
- }
33901
-
33902
- class SearchProductLiveCollectionController extends LiveCollectionController {
33903
- constructor(query, callback) {
33904
- const queryStreamId = hash__default["default"](query);
33905
- const cacheKey = ['products', 'collection', queryStreamId];
33906
- const paginationController = new SearchProductPaginationController(query);
33907
- super(paginationController, queryStreamId, cacheKey, callback);
33908
- this.query = query;
33909
- this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
33910
- this.callback = callback.bind(this);
33911
- this.loadPage({ initial: true });
33912
- }
33913
- setup() {
33914
- var _a;
33915
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
33916
- if (!collection) {
33917
- pushToCache(this.cacheKey, {
33918
- data: [],
33919
- params: {},
33920
- });
33921
- }
33922
- }
33923
- async persistModel(queryPayload) {
33924
- await this.queryStreamController.saveToMainDB(queryPayload);
33925
- }
33926
- persistQueryStream({ response, direction, refresh, }) {
33927
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
33928
- }
33929
- // eslint-disable-next-line class-methods-use-this
33930
- startSubscription() {
33931
- return [];
33932
- }
33933
- notifyChange({ origin, loading, error }) {
33934
- var _a, _b;
33935
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
33936
- if (!collection)
33937
- return;
33938
- const data = (_b = collection.data
33939
- .map(id => pullFromCache(['product', 'get', id]))
33940
- .filter(isNonNullable)
33941
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
33942
- if (!this.shouldNotify(data) && origin === 'event')
33943
- return;
33944
- this.callback({
33945
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
33946
- data,
33947
- hasNextPage: !!this.paginationController.getNextToken(),
33948
- loading,
33949
- error,
33950
- });
33951
- }
33952
- }
33953
-
33954
- /* begin_public_function
33955
- id: product.search
33956
- */
33957
- /**
33958
- * ```js
33959
- * import { ProductRepository } from '@amityco/ts-sdk'
33960
- *
33961
- * let products = []
33962
- * const unsub = ProductRepository.searchProducts({
33963
- * keyword: string,
33964
- * }, response => merge(products, response.data))
33965
- * ```
33966
- *
33967
- * Observe all mutations on a list of {@link Amity.Product}
33968
- *
33969
- * @param params.keyword the search keyword
33970
- * @param params.isActive filter by active status
33971
- * @param params.isDeleted filter by deleted status
33972
- * @param params.sortBy sort option
33973
- * @param params.sortOrder order option
33974
- * @param callback the function to call when new data are available
33975
- * @param config
33976
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
33977
- *
33978
- * @category Products Live Collection
33979
- */
33980
- const searchProducts = (params, callback, config) => {
33981
- const { log, cache } = getActiveClient();
33982
- if (!cache) {
33983
- console.log(ENABLE_CACHE_MESSAGE);
33984
- }
33985
- const timestamp = Date.now();
33986
- log(`searchProducts(tmpid: ${timestamp}) > listen`);
33987
- const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
33988
- const disposers = productsLiveCollection.startSubscription();
33989
- const cacheKey = productsLiveCollection.getCacheKey();
33990
- disposers.push(() => dropFromCache(cacheKey));
33991
- return () => {
33992
- log(`searchProducts(tmpid: ${timestamp}) > dispose`);
33993
- disposers.forEach(fn => fn());
33994
- };
33995
- };
33996
- /* end_public_function */
33997
-
33998
- var index = /*#__PURE__*/Object.freeze({
33999
- __proto__: null,
34000
- getProduct: getProduct,
34001
- searchProducts: searchProducts
34002
- });
34003
-
34004
33750
  exports.API_REGIONS = API_REGIONS;
34005
- exports.AdRepository = index$5;
34006
- exports.CategoryRepository = index$f;
34007
- exports.ChannelRepository = index$j;
34008
- exports.Client = index$s;
34009
- exports.CommentRepository = index$e;
33751
+ exports.AdRepository = index$4;
33752
+ exports.CategoryRepository = index$e;
33753
+ exports.ChannelRepository = index$i;
33754
+ exports.Client = index$r;
33755
+ exports.CommentRepository = index$d;
34010
33756
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
34011
33757
  exports.CommunityPostSettings = CommunityPostSettings;
34012
- exports.CommunityRepository = index$g;
33758
+ exports.CommunityRepository = index$f;
34013
33759
  exports.ContentFeedType = ContentFeedType;
34014
33760
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
34015
- exports.EventRepository = index$1;
34016
- exports.FeedRepository = index$d;
34017
- exports.FileRepository = index$p;
33761
+ exports.EventRepository = index;
33762
+ exports.FeedRepository = index$c;
33763
+ exports.FileRepository = index$o;
34018
33764
  exports.FileType = FileType;
34019
33765
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
34020
- exports.InvitationRepository = index$3;
34021
- exports.LiveReactionRepository = index$2;
34022
- exports.LiveStreamPlayer = index$7;
33766
+ exports.InvitationRepository = index$2;
33767
+ exports.LiveReactionRepository = index$1;
33768
+ exports.LiveStreamPlayer = index$6;
34023
33769
  exports.MessageContentType = MessageContentType;
34024
- exports.MessageRepository = index$n;
34025
- exports.PollRepository = index$8;
33770
+ exports.MessageRepository = index$m;
33771
+ exports.PollRepository = index$7;
34026
33772
  exports.PostContentType = PostContentType;
34027
- exports.PostRepository = index$b;
33773
+ exports.PostRepository = index$a;
34028
33774
  exports.PostStructureType = PostStructureType;
34029
- exports.ProductRepository = index;
34030
- exports.ReactionRepository = index$o;
34031
- exports.RoomPresenceRepository = index$9;
34032
- exports.RoomRepository = index$c;
34033
- exports.StoryRepository = index$6;
34034
- exports.StreamRepository = index$a;
34035
- exports.SubChannelRepository = index$m;
34036
- exports.UserRepository = index$q;
33775
+ exports.ReactionRepository = index$n;
33776
+ exports.RoomPresenceRepository = index$8;
33777
+ exports.RoomRepository = index$b;
33778
+ exports.StoryRepository = index$5;
33779
+ exports.StreamRepository = index$9;
33780
+ exports.SubChannelRepository = index$l;
33781
+ exports.UserRepository = index$p;
34037
33782
  exports.VERSION = VERSION;
34038
33783
  exports.VideoResolution = VideoResolution;
34039
33784
  exports.VideoSize = VideoSize;
@@ -34089,7 +33834,7 @@ exports.isPaged = isPaged;
34089
33834
  exports.isReportedByMe = isReportedByMe;
34090
33835
  exports.isSkip = isSkip;
34091
33836
  exports.mergeInCache = mergeInCache;
34092
- exports.notificationTray = index$4;
33837
+ exports.notificationTray = index$3;
34093
33838
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
34094
33839
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
34095
33840
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;