@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.cjs.js CHANGED
@@ -748,7 +748,6 @@ const PAYLOAD2MODEL = {
748
748
  events: 'event',
749
749
  viewers: 'viewer',
750
750
  eventResponses: 'eventResponse',
751
- products: 'product',
752
751
  };
753
752
  /** hidden */
754
753
  const isOutdated = (prevData, nextData) => {
@@ -10064,29 +10063,6 @@ const getShareableLinkConfiguration = async () => {
10064
10063
  return data;
10065
10064
  };
10066
10065
 
10067
- /* begin_public_function
10068
- id: client.getProductCatalogueSetting
10069
- */
10070
- /**
10071
- * ```js
10072
- * import { getProductCatalogueSetting } from '@amityco/ts-sdk'
10073
- * const productCatalogueSetting = await getProductCatalogueSetting()
10074
- * ```
10075
- *
10076
- * Fetches a {@link Amity.ProductCatalogueSetting} object
10077
- *
10078
- * @returns A Promise of {@link Amity.ProductCatalogueSetting} object
10079
- *
10080
- * @category Client API
10081
- * @async
10082
- */
10083
- const getProductCatalogueSetting = async () => {
10084
- const client = getActiveClient();
10085
- const { data } = await client.http.get(`/api/v3/network-settings/product-catalogue`);
10086
- return data;
10087
- };
10088
- /* end_public_function */
10089
-
10090
10066
  /**
10091
10067
  * Retrieves a pair of {@link Amity.Tokens} necessary for connection
10092
10068
  *
@@ -10579,7 +10555,7 @@ const getUserUnread = (callback) => {
10579
10555
  };
10580
10556
  };
10581
10557
 
10582
- var index$s = /*#__PURE__*/Object.freeze({
10558
+ var index$r = /*#__PURE__*/Object.freeze({
10583
10559
  __proto__: null,
10584
10560
  getActiveClient: getActiveClient,
10585
10561
  getActiveUser: getActiveUser,
@@ -10599,7 +10575,6 @@ var index$s = /*#__PURE__*/Object.freeze({
10599
10575
  getLinkPreviewMetadata: getLinkPreviewMetadata,
10600
10576
  getSocialSettings: getSocialSettings,
10601
10577
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10602
- getProductCatalogueSetting: getProductCatalogueSetting,
10603
10578
  loginAsVisitor: loginAsVisitor,
10604
10579
  loginAsBot: loginAsBot,
10605
10580
  getCurrentUser: getCurrentUser,
@@ -10657,12 +10632,15 @@ const blockUser = async (userId) => {
10657
10632
  const { data } = await client.http.post(`/api/v4/me/user-blocks/${userId}`);
10658
10633
  const cachedAt = client.cache && Date.now();
10659
10634
  const { follows, followCounts } = data;
10660
- const followStatus = { follows };
10635
+ const blockedFollowStatus = { follows };
10661
10636
  if (client.cache) {
10662
- ingestInCache(followStatus, { cachedAt });
10637
+ ingestInCache(blockedFollowStatus, { cachedAt });
10663
10638
  upsertInCache(['followInfo', 'get', userId], followCounts[0], { cachedAt });
10664
10639
  }
10665
- const payload = prepareFollowStatusPayload(followStatus);
10640
+ const blockedUnfollowStatus = {
10641
+ follows: follows.map(follow => follow.status === 'blocked' ? Object.assign(Object.assign({}, follow), { to: follow.from, from: follow.to }) : follow),
10642
+ };
10643
+ const payload = prepareFollowStatusPayload(blockedUnfollowStatus);
10666
10644
  fireEvent('local.follow.unfollowed', payload);
10667
10645
  return data;
10668
10646
  };
@@ -11800,7 +11778,7 @@ const getMyFollowInfo = (callback) => {
11800
11778
  };
11801
11779
  /* end_public_function */
11802
11780
 
11803
- var index$r = /*#__PURE__*/Object.freeze({
11781
+ var index$q = /*#__PURE__*/Object.freeze({
11804
11782
  __proto__: null,
11805
11783
  blockUser: blockUser,
11806
11784
  unBlockUser: unBlockUser,
@@ -13908,11 +13886,6 @@ const communityLinkedObject = (community) => {
13908
13886
  } });
13909
13887
  };
13910
13888
 
13911
- const productTagLinkedObject = (productTag) => {
13912
- var _a;
13913
- return Object.assign(Object.assign({}, productTag), { product: (_a = pullFromCache(['product', 'get', productTag.productId])) === null || _a === void 0 ? void 0 : _a.data });
13914
- };
13915
-
13916
13889
  const postLinkedObject = (post) => {
13917
13890
  return shallowClone(post, {
13918
13891
  childrenPosts: post.children
@@ -13925,9 +13898,6 @@ const postLinkedObject = (post) => {
13925
13898
  analyticsEngineInstance.markPostAsViewed(post.postId);
13926
13899
  },
13927
13900
  },
13928
- get productTags() {
13929
- return post.productTags.map(productTag => productTagLinkedObject(productTag));
13930
- },
13931
13901
  get latestComments() {
13932
13902
  if (!post.comments)
13933
13903
  return [];
@@ -15917,9 +15887,9 @@ var AmityUserSearchMatchType;
15917
15887
  AmityUserSearchMatchType["PARTIAL"] = "partial";
15918
15888
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
15919
15889
 
15920
- var index$q = /*#__PURE__*/Object.freeze({
15890
+ var index$p = /*#__PURE__*/Object.freeze({
15921
15891
  __proto__: null,
15922
- Relationship: index$r,
15892
+ Relationship: index$q,
15923
15893
  getUserByIds: getUserByIds,
15924
15894
  updateUser: updateUser,
15925
15895
  flagUser: flagUser,
@@ -16322,7 +16292,7 @@ const uploadAudio = async (formData, onProgress) => {
16322
16292
  };
16323
16293
  /* end_public_function */
16324
16294
 
16325
- var index$p = /*#__PURE__*/Object.freeze({
16295
+ var index$o = /*#__PURE__*/Object.freeze({
16326
16296
  __proto__: null,
16327
16297
  getFile: getFile,
16328
16298
  uploadFile: uploadFile,
@@ -18134,7 +18104,7 @@ const getReactions$1 = (params, callback, config) => {
18134
18104
  };
18135
18105
  /* end_public_function */
18136
18106
 
18137
- var index$o = /*#__PURE__*/Object.freeze({
18107
+ var index$n = /*#__PURE__*/Object.freeze({
18138
18108
  __proto__: null,
18139
18109
  addReaction: addReaction,
18140
18110
  removeReaction: removeReaction,
@@ -19906,7 +19876,7 @@ const getMessages = (params, callback, config) => {
19906
19876
  };
19907
19877
  /* end_public_function */
19908
19878
 
19909
- var index$n = /*#__PURE__*/Object.freeze({
19879
+ var index$m = /*#__PURE__*/Object.freeze({
19910
19880
  __proto__: null,
19911
19881
  createMessage: createMessage,
19912
19882
  updateMessage: updateMessage,
@@ -20432,7 +20402,7 @@ const stopMessageReceiptSync = (subChannelId) => {
20432
20402
  };
20433
20403
  /* end_public_function */
20434
20404
 
20435
- var index$m = /*#__PURE__*/Object.freeze({
20405
+ var index$l = /*#__PURE__*/Object.freeze({
20436
20406
  __proto__: null,
20437
20407
  getSubChannelByIds: getSubChannels$1,
20438
20408
  createSubChannel: createSubChannel,
@@ -21759,7 +21729,7 @@ const searchMembers$1 = (params, callback, config) => {
21759
21729
  };
21760
21730
  /* end_public_function */
21761
21731
 
21762
- var index$l = /*#__PURE__*/Object.freeze({
21732
+ var index$k = /*#__PURE__*/Object.freeze({
21763
21733
  __proto__: null,
21764
21734
  addMembers: addMembers$1,
21765
21735
  removeMembers: removeMembers$1,
@@ -21962,7 +21932,7 @@ const unmuteMembers = async (channelId, userIds) => {
21962
21932
  };
21963
21933
  /* end_public_function */
21964
21934
 
21965
- var index$k = /*#__PURE__*/Object.freeze({
21935
+ var index$j = /*#__PURE__*/Object.freeze({
21966
21936
  __proto__: null,
21967
21937
  addRole: addRole,
21968
21938
  removeRole: removeRole,
@@ -21972,10 +21942,10 @@ var index$k = /*#__PURE__*/Object.freeze({
21972
21942
  unmuteMembers: unmuteMembers
21973
21943
  });
21974
21944
 
21975
- var index$j = /*#__PURE__*/Object.freeze({
21945
+ var index$i = /*#__PURE__*/Object.freeze({
21976
21946
  __proto__: null,
21977
- Membership: index$l,
21978
- Moderation: index$k,
21947
+ Membership: index$k,
21948
+ Moderation: index$j,
21979
21949
  getChannelByIds: getChannelByIds$1,
21980
21950
  createChannel: createChannel,
21981
21951
  updateChannel: updateChannel,
@@ -23378,7 +23348,7 @@ const searchMembers = (params, callback, config) => {
23378
23348
  };
23379
23349
  /* end_public_function */
23380
23350
 
23381
- var index$i = /*#__PURE__*/Object.freeze({
23351
+ var index$h = /*#__PURE__*/Object.freeze({
23382
23352
  __proto__: null,
23383
23353
  addMembers: addMembers,
23384
23354
  removeMembers: removeMembers,
@@ -24629,7 +24599,7 @@ const unbanMembers = async (communityId, userIds) => {
24629
24599
  };
24630
24600
  /* end_public_function */
24631
24601
 
24632
- var index$h = /*#__PURE__*/Object.freeze({
24602
+ var index$g = /*#__PURE__*/Object.freeze({
24633
24603
  __proto__: null,
24634
24604
  addRoles: addRoles,
24635
24605
  removeRoles: removeRoles,
@@ -24637,10 +24607,10 @@ var index$h = /*#__PURE__*/Object.freeze({
24637
24607
  unbanMembers: unbanMembers
24638
24608
  });
24639
24609
 
24640
- var index$g = /*#__PURE__*/Object.freeze({
24610
+ var index$f = /*#__PURE__*/Object.freeze({
24641
24611
  __proto__: null,
24642
- Moderation: index$h,
24643
- Membership: index$i,
24612
+ Moderation: index$g,
24613
+ Membership: index$h,
24644
24614
  getCommunityByIds: getCommunities$1,
24645
24615
  createCommunity: createCommunity,
24646
24616
  updateCommunity: updateCommunity,
@@ -24874,7 +24844,7 @@ const getCategories = (params, callback, config) => {
24874
24844
  };
24875
24845
  /* end_public_function */
24876
24846
 
24877
- var index$f = /*#__PURE__*/Object.freeze({
24847
+ var index$e = /*#__PURE__*/Object.freeze({
24878
24848
  __proto__: null,
24879
24849
  getCategory: getCategory,
24880
24850
  getCategories: getCategories
@@ -25933,7 +25903,7 @@ const getComments = (params, callback, config) => {
25933
25903
  };
25934
25904
  /* end_public_function */
25935
25905
 
25936
- var index$e = /*#__PURE__*/Object.freeze({
25906
+ var index$d = /*#__PURE__*/Object.freeze({
25937
25907
  __proto__: null,
25938
25908
  getCommentByIds: getCommentByIds,
25939
25909
  createComment: createComment,
@@ -26604,7 +26574,7 @@ const getUserFeed = (params, callback, config) => {
26604
26574
  };
26605
26575
  /* end_public_function */
26606
26576
 
26607
- var index$d = /*#__PURE__*/Object.freeze({
26577
+ var index$c = /*#__PURE__*/Object.freeze({
26608
26578
  __proto__: null,
26609
26579
  queryGlobalFeed: queryGlobalFeed,
26610
26580
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -26719,15 +26689,7 @@ const createPost = async (bundle) => {
26719
26689
  // eslint-disable-next-line no-param-reassign
26720
26690
  delete bundle.dataType;
26721
26691
  }
26722
- const { attachments } = bundle;
26723
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
26724
- ? attachments.map(attachment => {
26725
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
26726
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
26727
- return attachment;
26728
- })
26729
- : attachments;
26730
- const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { attachments: processedAttachments }));
26692
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
26731
26693
  fireEvent('post.created', payload);
26732
26694
  const data = preparePostPayload(payload);
26733
26695
  const cachedAt = client.cache && Date.now();
@@ -26764,15 +26726,7 @@ const createPost = async (bundle) => {
26764
26726
  const editPost = async (postId, patch) => {
26765
26727
  const client = getActiveClient();
26766
26728
  client.log('user/editPost', patch);
26767
- const { attachments } = patch;
26768
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
26769
- ? attachments.map(attachment => {
26770
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
26771
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
26772
- return attachment;
26773
- })
26774
- : attachments;
26775
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
26729
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
26776
26730
  const data = prepareMembershipPayload(payload, 'communityUsers');
26777
26731
  const cachedAt = client.cache && Date.now();
26778
26732
  if (client.cache)
@@ -29416,7 +29370,7 @@ const getRooms = (params, callback, config) => {
29416
29370
  };
29417
29371
  /* end_public_function */
29418
29372
 
29419
- var index$c = /*#__PURE__*/Object.freeze({
29373
+ var index$b = /*#__PURE__*/Object.freeze({
29420
29374
  __proto__: null,
29421
29375
  createRoom: createRoom,
29422
29376
  updateRoom: updateRoom,
@@ -29712,7 +29666,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
29712
29666
  };
29713
29667
  /* end_public_function */
29714
29668
 
29715
- var index$b = /*#__PURE__*/Object.freeze({
29669
+ var index$a = /*#__PURE__*/Object.freeze({
29716
29670
  __proto__: null,
29717
29671
  getPostByIds: getPostByIds,
29718
29672
  createPost: createPost,
@@ -30322,7 +30276,7 @@ const getStreams = (params, callback, config) => {
30322
30276
  };
30323
30277
  };
30324
30278
 
30325
- var index$a = /*#__PURE__*/Object.freeze({
30279
+ var index$9 = /*#__PURE__*/Object.freeze({
30326
30280
  __proto__: null,
30327
30281
  createStream: createStream,
30328
30282
  updateStream: updateStream,
@@ -30625,7 +30579,7 @@ const stopHeartbeat = (roomId) => {
30625
30579
  };
30626
30580
  /* end_public_function */
30627
30581
 
30628
- var index$9 = /*#__PURE__*/Object.freeze({
30582
+ var index$8 = /*#__PURE__*/Object.freeze({
30629
30583
  __proto__: null,
30630
30584
  getRoomOnlineUsers: getRoomOnlineUsers,
30631
30585
  getRoomUserCount: getRoomUserCount,
@@ -30933,7 +30887,7 @@ const getPoll = (pollId, callback) => {
30933
30887
  };
30934
30888
  /* end_public_function */
30935
30889
 
30936
- var index$8 = /*#__PURE__*/Object.freeze({
30890
+ var index$7 = /*#__PURE__*/Object.freeze({
30937
30891
  __proto__: null,
30938
30892
  createPoll: createPoll,
30939
30893
  closePoll: closePoll,
@@ -31237,7 +31191,7 @@ const getPlayer = async (parameters) => {
31237
31191
  return video;
31238
31192
  };
31239
31193
 
31240
- var index$7 = /*#__PURE__*/Object.freeze({
31194
+ var index$6 = /*#__PURE__*/Object.freeze({
31241
31195
  __proto__: null,
31242
31196
  getPlayer: getPlayer
31243
31197
  });
@@ -32410,7 +32364,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
32410
32364
  };
32411
32365
  };
32412
32366
 
32413
- var index$6 = /*#__PURE__*/Object.freeze({
32367
+ var index$5 = /*#__PURE__*/Object.freeze({
32414
32368
  __proto__: null,
32415
32369
  createImageStory: createImageStory,
32416
32370
  createVideoStory: createVideoStory,
@@ -32447,7 +32401,7 @@ const getNetworkAds = async () => {
32447
32401
  };
32448
32402
  };
32449
32403
 
32450
- var index$5 = /*#__PURE__*/Object.freeze({
32404
+ var index$4 = /*#__PURE__*/Object.freeze({
32451
32405
  __proto__: null,
32452
32406
  getNetworkAds: getNetworkAds
32453
32407
  });
@@ -32838,7 +32792,7 @@ const markTraySeen = async (lastSeenAt) => {
32838
32792
  };
32839
32793
  /* end_public_function */
32840
32794
 
32841
- var index$4 = /*#__PURE__*/Object.freeze({
32795
+ var index$3 = /*#__PURE__*/Object.freeze({
32842
32796
  __proto__: null,
32843
32797
  getNotificationTraySeen: getNotificationTraySeen,
32844
32798
  getNotificationTrayItems: getNotificationTrayItems,
@@ -33136,7 +33090,7 @@ const getInvitations = (params, callback) => {
33136
33090
  };
33137
33091
  };
33138
33092
 
33139
- var index$3 = /*#__PURE__*/Object.freeze({
33093
+ var index$2 = /*#__PURE__*/Object.freeze({
33140
33094
  __proto__: null,
33141
33095
  cancelInvitation: cancelInvitation,
33142
33096
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -33285,7 +33239,7 @@ const getReactions = (postId, callback) => {
33285
33239
  };
33286
33240
  };
33287
33241
 
33288
- var index$2 = /*#__PURE__*/Object.freeze({
33242
+ var index$1 = /*#__PURE__*/Object.freeze({
33289
33243
  __proto__: null,
33290
33244
  createReaction: createReaction,
33291
33245
  onLiveReactionCreated: onLiveReactionCreated,
@@ -33768,7 +33722,7 @@ const getMyEvents = (params, callback, config) => {
33768
33722
  };
33769
33723
  };
33770
33724
 
33771
- var index$1 = /*#__PURE__*/Object.freeze({
33725
+ var index = /*#__PURE__*/Object.freeze({
33772
33726
  __proto__: null,
33773
33727
  createEvent: createEvent,
33774
33728
  updateEvent: updateEvent,
@@ -33789,249 +33743,38 @@ var index$1 = /*#__PURE__*/Object.freeze({
33789
33743
  getRSVPs: getRSVPs
33790
33744
  });
33791
33745
 
33792
- const getProduct$1 = async (productId) => {
33793
- const client = getActiveClient();
33794
- client.log('product/getProduct', productId);
33795
- isInTombstone('product', productId);
33796
- let payload;
33797
- try {
33798
- const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
33799
- payload = response.data;
33800
- }
33801
- catch (error) {
33802
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
33803
- pushToTombstone('product', productId);
33804
- }
33805
- throw error;
33806
- }
33807
- const cachedAt = client.cache && Date.now();
33808
- if (client.cache)
33809
- ingestInCache(payload, { cachedAt });
33810
- const { products } = payload;
33811
- const result = products.find(product => product.productId === productId);
33812
- return {
33813
- data: result,
33814
- cachedAt,
33815
- };
33816
- };
33817
- getProduct$1.locally = (productId) => {
33818
- const client = getActiveClient();
33819
- client.log('product/getProduct.locally', productId);
33820
- if (!client.cache)
33821
- return;
33822
- const cached = pullFromCache(['product', 'get', productId]);
33823
- if (!cached)
33824
- return;
33825
- return {
33826
- data: cached.data,
33827
- cachedAt: cached.cachedAt,
33828
- };
33829
- };
33830
-
33831
- /* begin_public_function
33832
- id: product.get
33833
- */
33834
- /**
33835
- * ```js
33836
- * import { ProductRepository } from '@amityco/ts-sdk';
33837
- *
33838
- * let product;
33839
- *
33840
- * const unsub = ProductRepository.getProduct(productId, response => {
33841
- * product = response.data;
33842
- * });
33843
- * ```
33844
- *
33845
- * Observe all mutation on a given {@link Amity.Product}
33846
- *
33847
- * @param productId the ID of the product to observe
33848
- * @param callback the function to call when new data are available
33849
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
33850
- *
33851
- * @category Product Live Object
33852
- */
33853
- const getProduct = (productId, callback) => {
33854
- const responder = (snapshot) => {
33855
- callback(snapshot);
33856
- };
33857
- return liveObject(productId, responder, 'productId', getProduct$1, []);
33858
- };
33859
- /* end_public_function */
33860
-
33861
- class SearchProductPaginationController extends PaginationController {
33862
- async getRequest(queryParams, token) {
33863
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
33864
- const options = token ? { token } : { limit };
33865
- const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
33866
- params: Object.assign(Object.assign({}, params), { options }),
33867
- });
33868
- return queryResponse;
33869
- }
33870
- }
33871
-
33872
- class SearchProductQueryStreamController extends QueryStreamController {
33873
- constructor(query, cacheKey, notifyChange) {
33874
- super(query, cacheKey);
33875
- this.notifyChange = notifyChange;
33876
- }
33877
- // eslint-disable-next-line class-methods-use-this
33878
- saveToMainDB(response) {
33879
- const client = getActiveClient();
33880
- const cachedAt = client.cache && Date.now();
33881
- if (client.cache) {
33882
- ingestInCache(response, { cachedAt });
33883
- }
33884
- }
33885
- appendToQueryStream(response, direction, refresh = false) {
33886
- var _a, _b;
33887
- if (refresh) {
33888
- pushToCache(this.cacheKey, {
33889
- data: response.products.map(getResolver('product')),
33890
- });
33891
- }
33892
- else {
33893
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
33894
- const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
33895
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
33896
- }
33897
- }
33898
- }
33899
-
33900
- class SearchProductLiveCollectionController extends LiveCollectionController {
33901
- constructor(query, callback) {
33902
- const queryStreamId = hash__default["default"](query);
33903
- const cacheKey = ['products', 'collection', queryStreamId];
33904
- const paginationController = new SearchProductPaginationController(query);
33905
- super(paginationController, queryStreamId, cacheKey, callback);
33906
- this.query = query;
33907
- this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
33908
- this.callback = callback.bind(this);
33909
- this.loadPage({ initial: true });
33910
- }
33911
- setup() {
33912
- var _a;
33913
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
33914
- if (!collection) {
33915
- pushToCache(this.cacheKey, {
33916
- data: [],
33917
- params: {},
33918
- });
33919
- }
33920
- }
33921
- async persistModel(queryPayload) {
33922
- await this.queryStreamController.saveToMainDB(queryPayload);
33923
- }
33924
- persistQueryStream({ response, direction, refresh, }) {
33925
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
33926
- }
33927
- // eslint-disable-next-line class-methods-use-this
33928
- startSubscription() {
33929
- return [];
33930
- }
33931
- notifyChange({ origin, loading, error }) {
33932
- var _a, _b;
33933
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
33934
- if (!collection)
33935
- return;
33936
- const data = (_b = collection.data
33937
- .map(id => pullFromCache(['product', 'get', id]))
33938
- .filter(isNonNullable)
33939
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
33940
- if (!this.shouldNotify(data) && origin === 'event')
33941
- return;
33942
- this.callback({
33943
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
33944
- data,
33945
- hasNextPage: !!this.paginationController.getNextToken(),
33946
- loading,
33947
- error,
33948
- });
33949
- }
33950
- }
33951
-
33952
- /* begin_public_function
33953
- id: product.search
33954
- */
33955
- /**
33956
- * ```js
33957
- * import { ProductRepository } from '@amityco/ts-sdk'
33958
- *
33959
- * let products = []
33960
- * const unsub = ProductRepository.searchProducts({
33961
- * keyword: string,
33962
- * }, response => merge(products, response.data))
33963
- * ```
33964
- *
33965
- * Observe all mutations on a list of {@link Amity.Product}
33966
- *
33967
- * @param params.keyword the search keyword
33968
- * @param params.isActive filter by active status
33969
- * @param params.isDeleted filter by deleted status
33970
- * @param params.sortBy sort option
33971
- * @param params.sortOrder order option
33972
- * @param callback the function to call when new data are available
33973
- * @param config
33974
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
33975
- *
33976
- * @category Products Live Collection
33977
- */
33978
- const searchProducts = (params, callback, config) => {
33979
- const { log, cache } = getActiveClient();
33980
- if (!cache) {
33981
- console.log(ENABLE_CACHE_MESSAGE);
33982
- }
33983
- const timestamp = Date.now();
33984
- log(`searchProducts(tmpid: ${timestamp}) > listen`);
33985
- const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
33986
- const disposers = productsLiveCollection.startSubscription();
33987
- const cacheKey = productsLiveCollection.getCacheKey();
33988
- disposers.push(() => dropFromCache(cacheKey));
33989
- return () => {
33990
- log(`searchProducts(tmpid: ${timestamp}) > dispose`);
33991
- disposers.forEach(fn => fn());
33992
- };
33993
- };
33994
- /* end_public_function */
33995
-
33996
- var index = /*#__PURE__*/Object.freeze({
33997
- __proto__: null,
33998
- getProduct: getProduct,
33999
- searchProducts: searchProducts
34000
- });
34001
-
34002
33746
  exports.API_REGIONS = API_REGIONS;
34003
- exports.AdRepository = index$5;
34004
- exports.CategoryRepository = index$f;
34005
- exports.ChannelRepository = index$j;
34006
- exports.Client = index$s;
34007
- exports.CommentRepository = index$e;
33747
+ exports.AdRepository = index$4;
33748
+ exports.CategoryRepository = index$e;
33749
+ exports.ChannelRepository = index$i;
33750
+ exports.Client = index$r;
33751
+ exports.CommentRepository = index$d;
34008
33752
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
34009
33753
  exports.CommunityPostSettings = CommunityPostSettings;
34010
- exports.CommunityRepository = index$g;
33754
+ exports.CommunityRepository = index$f;
34011
33755
  exports.ContentFeedType = ContentFeedType;
34012
33756
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
34013
- exports.EventRepository = index$1;
34014
- exports.FeedRepository = index$d;
34015
- exports.FileRepository = index$p;
33757
+ exports.EventRepository = index;
33758
+ exports.FeedRepository = index$c;
33759
+ exports.FileRepository = index$o;
34016
33760
  exports.FileType = FileType;
34017
33761
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
34018
- exports.InvitationRepository = index$3;
34019
- exports.LiveReactionRepository = index$2;
34020
- exports.LiveStreamPlayer = index$7;
33762
+ exports.InvitationRepository = index$2;
33763
+ exports.LiveReactionRepository = index$1;
33764
+ exports.LiveStreamPlayer = index$6;
34021
33765
  exports.MessageContentType = MessageContentType;
34022
- exports.MessageRepository = index$n;
34023
- exports.PollRepository = index$8;
33766
+ exports.MessageRepository = index$m;
33767
+ exports.PollRepository = index$7;
34024
33768
  exports.PostContentType = PostContentType;
34025
- exports.PostRepository = index$b;
33769
+ exports.PostRepository = index$a;
34026
33770
  exports.PostStructureType = PostStructureType;
34027
- exports.ProductRepository = index;
34028
- exports.ReactionRepository = index$o;
34029
- exports.RoomPresenceRepository = index$9;
34030
- exports.RoomRepository = index$c;
34031
- exports.StoryRepository = index$6;
34032
- exports.StreamRepository = index$a;
34033
- exports.SubChannelRepository = index$m;
34034
- exports.UserRepository = index$q;
33771
+ exports.ReactionRepository = index$n;
33772
+ exports.RoomPresenceRepository = index$8;
33773
+ exports.RoomRepository = index$b;
33774
+ exports.StoryRepository = index$5;
33775
+ exports.StreamRepository = index$9;
33776
+ exports.SubChannelRepository = index$l;
33777
+ exports.UserRepository = index$p;
34035
33778
  exports.VERSION = VERSION;
34036
33779
  exports.VideoResolution = VideoResolution;
34037
33780
  exports.VideoSize = VideoSize;
@@ -34087,7 +33830,7 @@ exports.isPaged = isPaged;
34087
33830
  exports.isReportedByMe = isReportedByMe;
34088
33831
  exports.isSkip = isSkip;
34089
33832
  exports.mergeInCache = mergeInCache;
34090
- exports.notificationTray = index$4;
33833
+ exports.notificationTray = index$3;
34091
33834
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
34092
33835
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
34093
33836
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;
package/dist/index.d.ts CHANGED
@@ -32,5 +32,4 @@ export * as InvitationRepository from './invitationRepository';
32
32
  export * as LiveReactionRepository from './liveReactionRepository';
33
33
  export { GET_WATCHER_URLS } from './utils/linkedObject/streamLinkedObject';
34
34
  export * as EventRepository from './eventRepository';
35
- export * as ProductRepository from './productRepository';
36
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AAEzB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAE5B,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,cAAc,YAAY,CAAC;AAG3B,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAE3D,cAAc,cAAc,CAAC;AAG7B,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAE/D,cAAc,iBAAiB,CAAC;AAGhC,OAAO,KAAK,mBAAmB,MAAM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