@amityco/ts-sdk 7.12.1-4d56f961.0 → 7.12.1-5cb139d3.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 (49) hide show
  1. package/dist/@types/core/model.d.ts +0 -2
  2. package/dist/@types/core/model.d.ts.map +1 -1
  3. package/dist/@types/core/payload.d.ts +0 -4
  4. package/dist/@types/core/payload.d.ts.map +1 -1
  5. package/dist/@types/domains/client.d.ts +0 -3
  6. package/dist/@types/domains/client.d.ts.map +1 -1
  7. package/dist/@types/domains/post.d.ts +0 -1
  8. package/dist/@types/domains/post.d.ts.map +1 -1
  9. package/dist/@types/index.d.ts +0 -1
  10. package/dist/@types/index.d.ts.map +1 -1
  11. package/dist/client/api/index.d.ts +0 -1
  12. package/dist/client/api/index.d.ts.map +1 -1
  13. package/dist/core/model/index.d.ts.map +1 -1
  14. package/dist/index.cjs.js +64 -321
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.esm.js +42 -298
  18. package/dist/index.umd.js +2 -2
  19. package/dist/postRepository/api/createPost.d.ts +0 -2
  20. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  21. package/dist/postRepository/api/editPost.d.ts +0 -2
  22. package/dist/postRepository/api/editPost.d.ts.map +1 -1
  23. package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
  24. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/dist/@types/domains/product.d.ts +0 -76
  27. package/dist/@types/domains/product.d.ts.map +0 -1
  28. package/dist/client/api/getProductCatalogueSetting.d.ts +0 -15
  29. package/dist/client/api/getProductCatalogueSetting.d.ts.map +0 -1
  30. package/dist/productRepository/index.d.ts +0 -2
  31. package/dist/productRepository/index.d.ts.map +0 -1
  32. package/dist/productRepository/internalApi/getProduct.d.ts +0 -5
  33. package/dist/productRepository/internalApi/getProduct.d.ts.map +0 -1
  34. package/dist/productRepository/internalApi/index.d.ts +0 -2
  35. package/dist/productRepository/internalApi/index.d.ts.map +0 -1
  36. package/dist/productRepository/observers/getProduct.d.ts +0 -21
  37. package/dist/productRepository/observers/getProduct.d.ts.map +0 -1
  38. package/dist/productRepository/observers/index.d.ts +0 -3
  39. package/dist/productRepository/observers/index.d.ts.map +0 -1
  40. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts +0 -15
  41. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts.map +0 -1
  42. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts +0 -5
  43. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts.map +0 -1
  44. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts +0 -8
  45. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts.map +0 -1
  46. package/dist/productRepository/observers/searchProducts.d.ts +0 -25
  47. package/dist/productRepository/observers/searchProducts.d.ts.map +0 -1
  48. package/dist/utils/linkedObject/productTagLinkedObject.d.ts +0 -2
  49. package/dist/utils/linkedObject/productTagLinkedObject.d.ts.map +0 -1
package/dist/index.esm.js CHANGED
@@ -733,7 +733,6 @@ const PAYLOAD2MODEL = {
733
733
  events: 'event',
734
734
  viewers: 'viewer',
735
735
  eventResponses: 'eventResponse',
736
- products: 'product',
737
736
  };
738
737
  /** hidden */
739
738
  const isOutdated = (prevData, nextData) => {
@@ -26156,29 +26155,6 @@ const getShareableLinkConfiguration = async () => {
26156
26155
  return data;
26157
26156
  };
26158
26157
 
26159
- /* begin_public_function
26160
- id: client.getProductCatalogueSetting
26161
- */
26162
- /**
26163
- * ```js
26164
- * import { getProductCatalogueSetting } from '@amityco/ts-sdk'
26165
- * const productCatalogueSetting = await getProductCatalogueSetting()
26166
- * ```
26167
- *
26168
- * Fetches a {@link Amity.ProductCatalogueSetting} object
26169
- *
26170
- * @returns A Promise of {@link Amity.ProductCatalogueSetting} object
26171
- *
26172
- * @category Client API
26173
- * @async
26174
- */
26175
- const getProductCatalogueSetting = async () => {
26176
- const client = getActiveClient();
26177
- const { data } = await client.http.get(`/api/v3/network-settings/product-catalogue`);
26178
- return data;
26179
- };
26180
- /* end_public_function */
26181
-
26182
26158
  /**
26183
26159
  * Retrieves a pair of {@link Amity.Tokens} necessary for connection
26184
26160
  *
@@ -26671,7 +26647,7 @@ const getUserUnread = (callback) => {
26671
26647
  };
26672
26648
  };
26673
26649
 
26674
- var index$s = /*#__PURE__*/Object.freeze({
26650
+ var index$r = /*#__PURE__*/Object.freeze({
26675
26651
  __proto__: null,
26676
26652
  getActiveClient: getActiveClient,
26677
26653
  getActiveUser: getActiveUser,
@@ -26691,7 +26667,6 @@ var index$s = /*#__PURE__*/Object.freeze({
26691
26667
  getLinkPreviewMetadata: getLinkPreviewMetadata,
26692
26668
  getSocialSettings: getSocialSettings,
26693
26669
  getShareableLinkConfiguration: getShareableLinkConfiguration,
26694
- getProductCatalogueSetting: getProductCatalogueSetting,
26695
26670
  loginAsVisitor: loginAsVisitor,
26696
26671
  loginAsBot: loginAsBot,
26697
26672
  getCurrentUser: getCurrentUser,
@@ -26749,12 +26724,15 @@ const blockUser = async (userId) => {
26749
26724
  const { data } = await client.http.post(`/api/v4/me/user-blocks/${userId}`);
26750
26725
  const cachedAt = client.cache && Date.now();
26751
26726
  const { follows, followCounts } = data;
26752
- const followStatus = { follows };
26727
+ const blockedFollowStatus = { follows };
26753
26728
  if (client.cache) {
26754
- ingestInCache(followStatus, { cachedAt });
26729
+ ingestInCache(blockedFollowStatus, { cachedAt });
26755
26730
  upsertInCache(['followInfo', 'get', userId], followCounts[0], { cachedAt });
26756
26731
  }
26757
- const payload = prepareFollowStatusPayload(followStatus);
26732
+ const blockedUnfollowStatus = {
26733
+ follows: follows.map(follow => follow.status === 'blocked' ? Object.assign(Object.assign({}, follow), { to: follow.from, from: follow.to }) : follow),
26734
+ };
26735
+ const payload = prepareFollowStatusPayload(blockedUnfollowStatus);
26758
26736
  fireEvent('local.follow.unfollowed', payload);
26759
26737
  return data;
26760
26738
  };
@@ -27892,7 +27870,7 @@ const getMyFollowInfo = (callback) => {
27892
27870
  };
27893
27871
  /* end_public_function */
27894
27872
 
27895
- var index$r = /*#__PURE__*/Object.freeze({
27873
+ var index$q = /*#__PURE__*/Object.freeze({
27896
27874
  __proto__: null,
27897
27875
  blockUser: blockUser,
27898
27876
  unBlockUser: unBlockUser,
@@ -30000,11 +29978,6 @@ const communityLinkedObject = (community) => {
30000
29978
  } });
30001
29979
  };
30002
29980
 
30003
- const productTagLinkedObject = (productTag) => {
30004
- var _a;
30005
- return Object.assign(Object.assign({}, productTag), { product: (_a = pullFromCache(['product', 'get', productTag.productId])) === null || _a === void 0 ? void 0 : _a.data });
30006
- };
30007
-
30008
29981
  const postLinkedObject = (post) => {
30009
29982
  return shallowClone(post, {
30010
29983
  childrenPosts: post.children
@@ -30017,9 +29990,6 @@ const postLinkedObject = (post) => {
30017
29990
  analyticsEngineInstance.markPostAsViewed(post.postId);
30018
29991
  },
30019
29992
  },
30020
- get productTags() {
30021
- return post.productTags.map(productTag => productTagLinkedObject(productTag));
30022
- },
30023
29993
  get latestComments() {
30024
29994
  if (!post.comments)
30025
29995
  return [];
@@ -32009,9 +31979,9 @@ var AmityUserSearchMatchType;
32009
31979
  AmityUserSearchMatchType["PARTIAL"] = "partial";
32010
31980
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
32011
31981
 
32012
- var index$q = /*#__PURE__*/Object.freeze({
31982
+ var index$p = /*#__PURE__*/Object.freeze({
32013
31983
  __proto__: null,
32014
- Relationship: index$r,
31984
+ Relationship: index$q,
32015
31985
  getUserByIds: getUserByIds,
32016
31986
  updateUser: updateUser,
32017
31987
  flagUser: flagUser,
@@ -32414,7 +32384,7 @@ const uploadAudio = async (formData, onProgress) => {
32414
32384
  };
32415
32385
  /* end_public_function */
32416
32386
 
32417
- var index$p = /*#__PURE__*/Object.freeze({
32387
+ var index$o = /*#__PURE__*/Object.freeze({
32418
32388
  __proto__: null,
32419
32389
  getFile: getFile,
32420
32390
  uploadFile: uploadFile,
@@ -34226,7 +34196,7 @@ const getReactions$1 = (params, callback, config) => {
34226
34196
  };
34227
34197
  /* end_public_function */
34228
34198
 
34229
- var index$o = /*#__PURE__*/Object.freeze({
34199
+ var index$n = /*#__PURE__*/Object.freeze({
34230
34200
  __proto__: null,
34231
34201
  addReaction: addReaction,
34232
34202
  removeReaction: removeReaction,
@@ -35998,7 +35968,7 @@ const getMessages = (params, callback, config) => {
35998
35968
  };
35999
35969
  /* end_public_function */
36000
35970
 
36001
- var index$n = /*#__PURE__*/Object.freeze({
35971
+ var index$m = /*#__PURE__*/Object.freeze({
36002
35972
  __proto__: null,
36003
35973
  createMessage: createMessage,
36004
35974
  updateMessage: updateMessage,
@@ -36524,7 +36494,7 @@ const stopMessageReceiptSync = (subChannelId) => {
36524
36494
  };
36525
36495
  /* end_public_function */
36526
36496
 
36527
- var index$m = /*#__PURE__*/Object.freeze({
36497
+ var index$l = /*#__PURE__*/Object.freeze({
36528
36498
  __proto__: null,
36529
36499
  getSubChannelByIds: getSubChannels$1,
36530
36500
  createSubChannel: createSubChannel,
@@ -37851,7 +37821,7 @@ const searchMembers$1 = (params, callback, config) => {
37851
37821
  };
37852
37822
  /* end_public_function */
37853
37823
 
37854
- var index$l = /*#__PURE__*/Object.freeze({
37824
+ var index$k = /*#__PURE__*/Object.freeze({
37855
37825
  __proto__: null,
37856
37826
  addMembers: addMembers$1,
37857
37827
  removeMembers: removeMembers$1,
@@ -38054,7 +38024,7 @@ const unmuteMembers = async (channelId, userIds) => {
38054
38024
  };
38055
38025
  /* end_public_function */
38056
38026
 
38057
- var index$k = /*#__PURE__*/Object.freeze({
38027
+ var index$j = /*#__PURE__*/Object.freeze({
38058
38028
  __proto__: null,
38059
38029
  addRole: addRole,
38060
38030
  removeRole: removeRole,
@@ -38064,10 +38034,10 @@ var index$k = /*#__PURE__*/Object.freeze({
38064
38034
  unmuteMembers: unmuteMembers
38065
38035
  });
38066
38036
 
38067
- var index$j = /*#__PURE__*/Object.freeze({
38037
+ var index$i = /*#__PURE__*/Object.freeze({
38068
38038
  __proto__: null,
38069
- Membership: index$l,
38070
- Moderation: index$k,
38039
+ Membership: index$k,
38040
+ Moderation: index$j,
38071
38041
  getChannelByIds: getChannelByIds$1,
38072
38042
  createChannel: createChannel,
38073
38043
  updateChannel: updateChannel,
@@ -39470,7 +39440,7 @@ const searchMembers = (params, callback, config) => {
39470
39440
  };
39471
39441
  /* end_public_function */
39472
39442
 
39473
- var index$i = /*#__PURE__*/Object.freeze({
39443
+ var index$h = /*#__PURE__*/Object.freeze({
39474
39444
  __proto__: null,
39475
39445
  addMembers: addMembers,
39476
39446
  removeMembers: removeMembers,
@@ -40721,7 +40691,7 @@ const unbanMembers = async (communityId, userIds) => {
40721
40691
  };
40722
40692
  /* end_public_function */
40723
40693
 
40724
- var index$h = /*#__PURE__*/Object.freeze({
40694
+ var index$g = /*#__PURE__*/Object.freeze({
40725
40695
  __proto__: null,
40726
40696
  addRoles: addRoles,
40727
40697
  removeRoles: removeRoles,
@@ -40729,10 +40699,10 @@ var index$h = /*#__PURE__*/Object.freeze({
40729
40699
  unbanMembers: unbanMembers
40730
40700
  });
40731
40701
 
40732
- var index$g = /*#__PURE__*/Object.freeze({
40702
+ var index$f = /*#__PURE__*/Object.freeze({
40733
40703
  __proto__: null,
40734
- Moderation: index$h,
40735
- Membership: index$i,
40704
+ Moderation: index$g,
40705
+ Membership: index$h,
40736
40706
  getCommunityByIds: getCommunities$1,
40737
40707
  createCommunity: createCommunity,
40738
40708
  updateCommunity: updateCommunity,
@@ -40966,7 +40936,7 @@ const getCategories = (params, callback, config) => {
40966
40936
  };
40967
40937
  /* end_public_function */
40968
40938
 
40969
- var index$f = /*#__PURE__*/Object.freeze({
40939
+ var index$e = /*#__PURE__*/Object.freeze({
40970
40940
  __proto__: null,
40971
40941
  getCategory: getCategory,
40972
40942
  getCategories: getCategories
@@ -42025,7 +41995,7 @@ const getComments = (params, callback, config) => {
42025
41995
  };
42026
41996
  /* end_public_function */
42027
41997
 
42028
- var index$e = /*#__PURE__*/Object.freeze({
41998
+ var index$d = /*#__PURE__*/Object.freeze({
42029
41999
  __proto__: null,
42030
42000
  getCommentByIds: getCommentByIds,
42031
42001
  createComment: createComment,
@@ -42696,7 +42666,7 @@ const getUserFeed = (params, callback, config) => {
42696
42666
  };
42697
42667
  /* end_public_function */
42698
42668
 
42699
- var index$d = /*#__PURE__*/Object.freeze({
42669
+ var index$c = /*#__PURE__*/Object.freeze({
42700
42670
  __proto__: null,
42701
42671
  queryGlobalFeed: queryGlobalFeed,
42702
42672
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -42811,15 +42781,7 @@ const createPost = async (bundle) => {
42811
42781
  // eslint-disable-next-line no-param-reassign
42812
42782
  delete bundle.dataType;
42813
42783
  }
42814
- const { attachments } = bundle;
42815
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
42816
- ? attachments.map(attachment => {
42817
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
42818
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
42819
- return attachment;
42820
- })
42821
- : attachments;
42822
- const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { attachments: processedAttachments }));
42784
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
42823
42785
  fireEvent('post.created', payload);
42824
42786
  const data = preparePostPayload(payload);
42825
42787
  const cachedAt = client.cache && Date.now();
@@ -42856,15 +42818,7 @@ const createPost = async (bundle) => {
42856
42818
  const editPost = async (postId, patch) => {
42857
42819
  const client = getActiveClient();
42858
42820
  client.log('user/editPost', patch);
42859
- const { attachments } = patch;
42860
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
42861
- ? attachments.map(attachment => {
42862
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
42863
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
42864
- return attachment;
42865
- })
42866
- : attachments;
42867
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
42821
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
42868
42822
  const data = prepareMembershipPayload(payload, 'communityUsers');
42869
42823
  const cachedAt = client.cache && Date.now();
42870
42824
  if (client.cache)
@@ -45508,7 +45462,7 @@ const getRooms = (params, callback, config) => {
45508
45462
  };
45509
45463
  /* end_public_function */
45510
45464
 
45511
- var index$c = /*#__PURE__*/Object.freeze({
45465
+ var index$b = /*#__PURE__*/Object.freeze({
45512
45466
  __proto__: null,
45513
45467
  createRoom: createRoom,
45514
45468
  updateRoom: updateRoom,
@@ -45804,7 +45758,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
45804
45758
  };
45805
45759
  /* end_public_function */
45806
45760
 
45807
- var index$b = /*#__PURE__*/Object.freeze({
45761
+ var index$a = /*#__PURE__*/Object.freeze({
45808
45762
  __proto__: null,
45809
45763
  getPostByIds: getPostByIds,
45810
45764
  createPost: createPost,
@@ -46414,7 +46368,7 @@ const getStreams = (params, callback, config) => {
46414
46368
  };
46415
46369
  };
46416
46370
 
46417
- var index$a = /*#__PURE__*/Object.freeze({
46371
+ var index$9 = /*#__PURE__*/Object.freeze({
46418
46372
  __proto__: null,
46419
46373
  createStream: createStream,
46420
46374
  updateStream: updateStream,
@@ -46717,7 +46671,7 @@ const stopHeartbeat = (roomId) => {
46717
46671
  };
46718
46672
  /* end_public_function */
46719
46673
 
46720
- var index$9 = /*#__PURE__*/Object.freeze({
46674
+ var index$8 = /*#__PURE__*/Object.freeze({
46721
46675
  __proto__: null,
46722
46676
  getRoomOnlineUsers: getRoomOnlineUsers,
46723
46677
  getRoomUserCount: getRoomUserCount,
@@ -47025,7 +46979,7 @@ const getPoll = (pollId, callback) => {
47025
46979
  };
47026
46980
  /* end_public_function */
47027
46981
 
47028
- var index$8 = /*#__PURE__*/Object.freeze({
46982
+ var index$7 = /*#__PURE__*/Object.freeze({
47029
46983
  __proto__: null,
47030
46984
  createPoll: createPoll,
47031
46985
  closePoll: closePoll,
@@ -47329,7 +47283,7 @@ const getPlayer = async (parameters) => {
47329
47283
  return video;
47330
47284
  };
47331
47285
 
47332
- var index$7 = /*#__PURE__*/Object.freeze({
47286
+ var index$6 = /*#__PURE__*/Object.freeze({
47333
47287
  __proto__: null,
47334
47288
  getPlayer: getPlayer
47335
47289
  });
@@ -48502,7 +48456,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
48502
48456
  };
48503
48457
  };
48504
48458
 
48505
- var index$6 = /*#__PURE__*/Object.freeze({
48459
+ var index$5 = /*#__PURE__*/Object.freeze({
48506
48460
  __proto__: null,
48507
48461
  createImageStory: createImageStory,
48508
48462
  createVideoStory: createVideoStory,
@@ -48539,7 +48493,7 @@ const getNetworkAds = async () => {
48539
48493
  };
48540
48494
  };
48541
48495
 
48542
- var index$5 = /*#__PURE__*/Object.freeze({
48496
+ var index$4 = /*#__PURE__*/Object.freeze({
48543
48497
  __proto__: null,
48544
48498
  getNetworkAds: getNetworkAds
48545
48499
  });
@@ -48930,7 +48884,7 @@ const markTraySeen = async (lastSeenAt) => {
48930
48884
  };
48931
48885
  /* end_public_function */
48932
48886
 
48933
- var index$4 = /*#__PURE__*/Object.freeze({
48887
+ var index$3 = /*#__PURE__*/Object.freeze({
48934
48888
  __proto__: null,
48935
48889
  getNotificationTraySeen: getNotificationTraySeen,
48936
48890
  getNotificationTrayItems: getNotificationTrayItems,
@@ -49228,7 +49182,7 @@ const getInvitations = (params, callback) => {
49228
49182
  };
49229
49183
  };
49230
49184
 
49231
- var index$3 = /*#__PURE__*/Object.freeze({
49185
+ var index$2 = /*#__PURE__*/Object.freeze({
49232
49186
  __proto__: null,
49233
49187
  cancelInvitation: cancelInvitation,
49234
49188
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -49377,7 +49331,7 @@ const getReactions = (postId, callback) => {
49377
49331
  };
49378
49332
  };
49379
49333
 
49380
- var index$2 = /*#__PURE__*/Object.freeze({
49334
+ var index$1 = /*#__PURE__*/Object.freeze({
49381
49335
  __proto__: null,
49382
49336
  createReaction: createReaction,
49383
49337
  onLiveReactionCreated: onLiveReactionCreated,
@@ -49860,7 +49814,7 @@ const getMyEvents = (params, callback, config) => {
49860
49814
  };
49861
49815
  };
49862
49816
 
49863
- var index$1 = /*#__PURE__*/Object.freeze({
49817
+ var index = /*#__PURE__*/Object.freeze({
49864
49818
  __proto__: null,
49865
49819
  createEvent: createEvent,
49866
49820
  updateEvent: updateEvent,
@@ -49881,214 +49835,4 @@ var index$1 = /*#__PURE__*/Object.freeze({
49881
49835
  getRSVPs: getRSVPs
49882
49836
  });
49883
49837
 
49884
- const getProduct$1 = async (productId) => {
49885
- const client = getActiveClient();
49886
- client.log('product/getProduct', productId);
49887
- isInTombstone('product', productId);
49888
- let payload;
49889
- try {
49890
- const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
49891
- payload = response.data;
49892
- }
49893
- catch (error) {
49894
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
49895
- pushToTombstone('product', productId);
49896
- }
49897
- throw error;
49898
- }
49899
- const cachedAt = client.cache && Date.now();
49900
- if (client.cache)
49901
- ingestInCache(payload, { cachedAt });
49902
- const { products } = payload;
49903
- const result = products.find(product => product.productId === productId);
49904
- return {
49905
- data: result,
49906
- cachedAt,
49907
- };
49908
- };
49909
- getProduct$1.locally = (productId) => {
49910
- const client = getActiveClient();
49911
- client.log('product/getProduct.locally', productId);
49912
- if (!client.cache)
49913
- return;
49914
- const cached = pullFromCache(['product', 'get', productId]);
49915
- if (!cached)
49916
- return;
49917
- return {
49918
- data: cached.data,
49919
- cachedAt: cached.cachedAt,
49920
- };
49921
- };
49922
-
49923
- /* begin_public_function
49924
- id: product.get
49925
- */
49926
- /**
49927
- * ```js
49928
- * import { ProductRepository } from '@amityco/ts-sdk';
49929
- *
49930
- * let product;
49931
- *
49932
- * const unsub = ProductRepository.getProduct(productId, response => {
49933
- * product = response.data;
49934
- * });
49935
- * ```
49936
- *
49937
- * Observe all mutation on a given {@link Amity.Product}
49938
- *
49939
- * @param productId the ID of the product to observe
49940
- * @param callback the function to call when new data are available
49941
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
49942
- *
49943
- * @category Product Live Object
49944
- */
49945
- const getProduct = (productId, callback) => {
49946
- const responder = (snapshot) => {
49947
- callback(snapshot);
49948
- };
49949
- return liveObject(productId, responder, 'productId', getProduct$1, []);
49950
- };
49951
- /* end_public_function */
49952
-
49953
- class SearchProductPaginationController extends PaginationController {
49954
- async getRequest(queryParams, token) {
49955
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
49956
- const options = token ? { token } : { limit };
49957
- const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
49958
- params: Object.assign(Object.assign({}, params), { options }),
49959
- });
49960
- return queryResponse;
49961
- }
49962
- }
49963
-
49964
- class SearchProductQueryStreamController extends QueryStreamController {
49965
- constructor(query, cacheKey, notifyChange) {
49966
- super(query, cacheKey);
49967
- this.notifyChange = notifyChange;
49968
- }
49969
- // eslint-disable-next-line class-methods-use-this
49970
- saveToMainDB(response) {
49971
- const client = getActiveClient();
49972
- const cachedAt = client.cache && Date.now();
49973
- if (client.cache) {
49974
- ingestInCache(response, { cachedAt });
49975
- }
49976
- }
49977
- appendToQueryStream(response, direction, refresh = false) {
49978
- var _a, _b;
49979
- if (refresh) {
49980
- pushToCache(this.cacheKey, {
49981
- data: response.products.map(getResolver('product')),
49982
- });
49983
- }
49984
- else {
49985
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
49986
- const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
49987
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
49988
- }
49989
- }
49990
- }
49991
-
49992
- class SearchProductLiveCollectionController extends LiveCollectionController {
49993
- constructor(query, callback) {
49994
- const queryStreamId = hash(query);
49995
- const cacheKey = ['products', 'collection', queryStreamId];
49996
- const paginationController = new SearchProductPaginationController(query);
49997
- super(paginationController, queryStreamId, cacheKey, callback);
49998
- this.query = query;
49999
- this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
50000
- this.callback = callback.bind(this);
50001
- this.loadPage({ initial: true });
50002
- }
50003
- setup() {
50004
- var _a;
50005
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
50006
- if (!collection) {
50007
- pushToCache(this.cacheKey, {
50008
- data: [],
50009
- params: {},
50010
- });
50011
- }
50012
- }
50013
- async persistModel(queryPayload) {
50014
- await this.queryStreamController.saveToMainDB(queryPayload);
50015
- }
50016
- persistQueryStream({ response, direction, refresh, }) {
50017
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
50018
- }
50019
- // eslint-disable-next-line class-methods-use-this
50020
- startSubscription() {
50021
- return [];
50022
- }
50023
- notifyChange({ origin, loading, error }) {
50024
- var _a, _b;
50025
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
50026
- if (!collection)
50027
- return;
50028
- const data = (_b = collection.data
50029
- .map(id => pullFromCache(['product', 'get', id]))
50030
- .filter(isNonNullable)
50031
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
50032
- if (!this.shouldNotify(data) && origin === 'event')
50033
- return;
50034
- this.callback({
50035
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
50036
- data,
50037
- hasNextPage: !!this.paginationController.getNextToken(),
50038
- loading,
50039
- error,
50040
- });
50041
- }
50042
- }
50043
-
50044
- /* begin_public_function
50045
- id: product.search
50046
- */
50047
- /**
50048
- * ```js
50049
- * import { ProductRepository } from '@amityco/ts-sdk'
50050
- *
50051
- * let products = []
50052
- * const unsub = ProductRepository.searchProducts({
50053
- * keyword: string,
50054
- * }, response => merge(products, response.data))
50055
- * ```
50056
- *
50057
- * Observe all mutations on a list of {@link Amity.Product}
50058
- *
50059
- * @param params.keyword the search keyword
50060
- * @param params.isActive filter by active status
50061
- * @param params.isDeleted filter by deleted status
50062
- * @param params.sortBy sort option
50063
- * @param params.sortOrder order option
50064
- * @param callback the function to call when new data are available
50065
- * @param config
50066
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
50067
- *
50068
- * @category Products Live Collection
50069
- */
50070
- const searchProducts = (params, callback, config) => {
50071
- const { log, cache } = getActiveClient();
50072
- if (!cache) {
50073
- console.log(ENABLE_CACHE_MESSAGE);
50074
- }
50075
- const timestamp = Date.now();
50076
- log(`searchProducts(tmpid: ${timestamp}) > listen`);
50077
- const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
50078
- const disposers = productsLiveCollection.startSubscription();
50079
- const cacheKey = productsLiveCollection.getCacheKey();
50080
- disposers.push(() => dropFromCache(cacheKey));
50081
- return () => {
50082
- log(`searchProducts(tmpid: ${timestamp}) > dispose`);
50083
- disposers.forEach(fn => fn());
50084
- };
50085
- };
50086
- /* end_public_function */
50087
-
50088
- var index = /*#__PURE__*/Object.freeze({
50089
- __proto__: null,
50090
- getProduct: getProduct,
50091
- searchProducts: searchProducts
50092
- });
50093
-
50094
- export { API_REGIONS, index$5 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$f as CategoryRepository, index$j as ChannelRepository, index$s as Client, index$e as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$g as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$1 as EventRepository, FeedDataTypeEnum, index$d as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$p as FileRepository, FileType, GET_WATCHER_URLS, index$3 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$2 as LiveReactionRepository, index$7 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$n as MessageRepository, index$8 as PollRepository, PostContentType, index$b as PostRepository, PostStructureType, index as ProductRepository, index$o as ReactionRepository, index$9 as RoomPresenceRepository, index$c as RoomRepository, index$6 as StoryRepository, index$a as StreamRepository, index$m as SubChannelRepository, SubscriptionLevels, index$q as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$4 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
49838
+ export { API_REGIONS, index$4 as AdRepository, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, index$e as CategoryRepository, index$i as ChannelRepository, index$r as Client, index$d as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$f as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index as EventRepository, FeedDataTypeEnum, index$c as FeedRepository, FeedSortByEnum, FeedSourceEnum, FileAccessTypeEnum, index$o as FileRepository, FileType, GET_WATCHER_URLS, index$2 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$1 as LiveReactionRepository, index$6 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$m as MessageRepository, index$7 as PollRepository, PostContentType, index$a as PostRepository, PostStructureType, index$n as ReactionRepository, index$8 as RoomPresenceRepository, index$b as RoomRepository, index$5 as StoryRepository, index$9 as StreamRepository, index$l as SubChannelRepository, SubscriptionLevels, index$p as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$3 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };