@amityco/ts-sdk 7.12.1-8bbe30f.0 → 7.12.1-df30e76f.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 (51) hide show
  1. package/dist/@types/core/model.d.ts +2 -0
  2. package/dist/@types/core/model.d.ts.map +1 -1
  3. package/dist/@types/core/payload.d.ts +4 -0
  4. package/dist/@types/core/payload.d.ts.map +1 -1
  5. package/dist/@types/domains/client.d.ts +3 -0
  6. package/dist/@types/domains/client.d.ts.map +1 -1
  7. package/dist/@types/domains/post.d.ts +1 -0
  8. package/dist/@types/domains/post.d.ts.map +1 -1
  9. package/dist/@types/domains/product.d.ts +77 -0
  10. package/dist/@types/domains/product.d.ts.map +1 -0
  11. package/dist/@types/index.d.ts +1 -0
  12. package/dist/@types/index.d.ts.map +1 -1
  13. package/dist/client/api/getProductCatalogueSetting.d.ts +15 -0
  14. package/dist/client/api/getProductCatalogueSetting.d.ts.map +1 -0
  15. package/dist/client/api/index.d.ts +1 -0
  16. package/dist/client/api/index.d.ts.map +1 -1
  17. package/dist/core/model/idResolvers.d.ts.map +1 -1
  18. package/dist/core/model/index.d.ts.map +1 -1
  19. package/dist/index.cjs.js +329 -66
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.esm.js +306 -44
  23. package/dist/index.umd.js +3 -3
  24. package/dist/postRepository/api/createPost.d.ts +2 -0
  25. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  26. package/dist/postRepository/api/editPost.d.ts +2 -0
  27. package/dist/postRepository/api/editPost.d.ts.map +1 -1
  28. package/dist/productRepository/index.d.ts +2 -0
  29. package/dist/productRepository/index.d.ts.map +1 -0
  30. package/dist/productRepository/internalApi/getProduct.d.ts +5 -0
  31. package/dist/productRepository/internalApi/getProduct.d.ts.map +1 -0
  32. package/dist/productRepository/internalApi/index.d.ts +2 -0
  33. package/dist/productRepository/internalApi/index.d.ts.map +1 -0
  34. package/dist/productRepository/observers/getProduct.d.ts +21 -0
  35. package/dist/productRepository/observers/getProduct.d.ts.map +1 -0
  36. package/dist/productRepository/observers/index.d.ts +3 -0
  37. package/dist/productRepository/observers/index.d.ts.map +1 -0
  38. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts +15 -0
  39. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts.map +1 -0
  40. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts +5 -0
  41. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts.map +1 -0
  42. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts +8 -0
  43. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts.map +1 -0
  44. package/dist/productRepository/observers/searchProducts.d.ts +25 -0
  45. package/dist/productRepository/observers/searchProducts.d.ts.map +1 -0
  46. package/dist/roomRepository/api/analytics/AmityRoomAnalytics.d.ts +1 -0
  47. package/dist/roomRepository/api/analytics/AmityRoomAnalytics.d.ts.map +1 -1
  48. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  49. package/dist/utils/linkedObject/productTagLinkedObject.d.ts +2 -0
  50. package/dist/utils/linkedObject/productTagLinkedObject.d.ts.map +1 -0
  51. package/package.json +1 -1
package/dist/index.cjs.js CHANGED
@@ -689,6 +689,7 @@ const idResolvers = {
689
689
  viewer: ({ userId }) => userId,
690
690
  event: ({ eventId }) => eventId,
691
691
  eventResponse: ({ userId }) => userId,
692
+ product: ({ _id }) => _id,
692
693
  };
693
694
  /**
694
695
  * Retrieve the id resolver matching a domain name
@@ -748,6 +749,7 @@ const PAYLOAD2MODEL = {
748
749
  events: 'event',
749
750
  viewers: 'viewer',
750
751
  eventResponses: 'eventResponse',
752
+ products: 'product',
751
753
  };
752
754
  /** hidden */
753
755
  const isOutdated = (prevData, nextData) => {
@@ -10063,6 +10065,29 @@ const getShareableLinkConfiguration = async () => {
10063
10065
  return data;
10064
10066
  };
10065
10067
 
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
+
10066
10091
  /**
10067
10092
  * Retrieves a pair of {@link Amity.Tokens} necessary for connection
10068
10093
  *
@@ -10555,7 +10580,7 @@ const getUserUnread = (callback) => {
10555
10580
  };
10556
10581
  };
10557
10582
 
10558
- var index$r = /*#__PURE__*/Object.freeze({
10583
+ var index$s = /*#__PURE__*/Object.freeze({
10559
10584
  __proto__: null,
10560
10585
  getActiveClient: getActiveClient,
10561
10586
  getActiveUser: getActiveUser,
@@ -10575,6 +10600,7 @@ var index$r = /*#__PURE__*/Object.freeze({
10575
10600
  getLinkPreviewMetadata: getLinkPreviewMetadata,
10576
10601
  getSocialSettings: getSocialSettings,
10577
10602
  getShareableLinkConfiguration: getShareableLinkConfiguration,
10603
+ getProductCatalogueSetting: getProductCatalogueSetting,
10578
10604
  loginAsVisitor: loginAsVisitor,
10579
10605
  loginAsBot: loginAsBot,
10580
10606
  getCurrentUser: getCurrentUser,
@@ -11775,7 +11801,7 @@ const getMyFollowInfo = (callback) => {
11775
11801
  };
11776
11802
  /* end_public_function */
11777
11803
 
11778
- var index$q = /*#__PURE__*/Object.freeze({
11804
+ var index$r = /*#__PURE__*/Object.freeze({
11779
11805
  __proto__: null,
11780
11806
  blockUser: blockUser,
11781
11807
  unBlockUser: unBlockUser,
@@ -12605,7 +12631,7 @@ const getWatchSessionStorage = () => {
12605
12631
  return storageInstance;
12606
12632
  };
12607
12633
 
12608
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbj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7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
12609
12635
  /*
12610
12636
  * The crypto algorithm used for importing key and signing string
12611
12637
  */
@@ -12867,6 +12893,7 @@ const waitForNetwork = (maxWaitTime = 60000) => {
12867
12893
  class AmityRoomAnalytics {
12868
12894
  constructor(room) {
12869
12895
  this.storage = getWatchSessionStorage();
12896
+ this.client = getActiveClient();
12870
12897
  this.room = room;
12871
12898
  }
12872
12899
  /**
@@ -12881,7 +12908,7 @@ class AmityRoomAnalytics {
12881
12908
  throw new ASCApiError('room is not in watchable state', 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
12882
12909
  }
12883
12910
  // Generate session ID with prefix
12884
- const prefix = this.room.status === 'live' ? 'live_' : 'playback_';
12911
+ const prefix = this.room.status === 'live' ? 'room_' : 'room_playback_';
12885
12912
  const sessionId = prefix + uuid__default["default"].v4();
12886
12913
  // Create watch session entity
12887
12914
  const session = {
@@ -12923,23 +12950,23 @@ class AmityRoomAnalytics {
12923
12950
  syncPendingWatchSessions() {
12924
12951
  // Execute with jitter delay (5-30 seconds)
12925
12952
  const jitterDelay = getJitterDelay();
12926
- console.log('[SDK AmityRoomAnalytics] syncPendingWatchSessions called, jitter delay:', `${jitterDelay}ms`);
12953
+ this.client.log('room/RoomAnalytics: syncPendingWatchSessions called, jitter delay:', `${jitterDelay}ms`);
12927
12954
  setTimeout(async () => {
12928
- console.log('[SDK AmityRoomAnalytics] Jitter delay completed, starting sync process');
12955
+ this.client.log('room/RoomAnalytics: Jitter delay completed, starting sync process');
12929
12956
  try {
12930
12957
  // Reset any SYNCING sessions back to PENDING
12931
12958
  const syncingSessions = this.storage.getSyncingSessions();
12932
- console.log('[SDK AmityRoomAnalytics] SYNCING sessions to reset:', syncingSessions.length);
12959
+ this.client.log('room/RoomAnalytics: SYNCING sessions to reset:', syncingSessions.length);
12933
12960
  syncingSessions.forEach(session => {
12934
12961
  this.storage.updateSession(session.sessionId, { syncState: 'PENDING' });
12935
12962
  });
12936
12963
  // Wait for network connection (max 60 seconds)
12937
12964
  await waitForNetwork(60000);
12938
- console.log('[SDK AmityRoomAnalytics] Network available');
12965
+ this.client.log('room/RoomAnalytics: Network available');
12939
12966
  // Sync pending sessions
12940
- console.log('[SDK AmityRoomAnalytics] Calling syncWatchSessions()');
12967
+ this.client.log('room/RoomAnalytics: Calling syncWatchSessions()');
12941
12968
  await syncWatchSessions();
12942
- console.log('[SDK AmityRoomAnalytics] syncWatchSessions completed');
12969
+ this.client.log('room/RoomAnalytics: syncWatchSessions completed');
12943
12970
  }
12944
12971
  catch (error) {
12945
12972
  // Error is already handled in syncWatchSessions
@@ -13882,6 +13909,11 @@ const communityLinkedObject = (community) => {
13882
13909
  } });
13883
13910
  };
13884
13911
 
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
+
13885
13917
  const postLinkedObject = (post) => {
13886
13918
  return shallowClone(post, {
13887
13919
  childrenPosts: post.children
@@ -13894,6 +13926,10 @@ const postLinkedObject = (post) => {
13894
13926
  analyticsEngineInstance.markPostAsViewed(post.postId);
13895
13927
  },
13896
13928
  },
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
+ },
13897
13933
  get latestComments() {
13898
13934
  if (!post.comments)
13899
13935
  return [];
@@ -15883,9 +15919,9 @@ var AmityUserSearchMatchType;
15883
15919
  AmityUserSearchMatchType["PARTIAL"] = "partial";
15884
15920
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
15885
15921
 
15886
- var index$p = /*#__PURE__*/Object.freeze({
15922
+ var index$q = /*#__PURE__*/Object.freeze({
15887
15923
  __proto__: null,
15888
- Relationship: index$q,
15924
+ Relationship: index$r,
15889
15925
  getUserByIds: getUserByIds,
15890
15926
  updateUser: updateUser,
15891
15927
  flagUser: flagUser,
@@ -16288,7 +16324,7 @@ const uploadAudio = async (formData, onProgress) => {
16288
16324
  };
16289
16325
  /* end_public_function */
16290
16326
 
16291
- var index$o = /*#__PURE__*/Object.freeze({
16327
+ var index$p = /*#__PURE__*/Object.freeze({
16292
16328
  __proto__: null,
16293
16329
  getFile: getFile,
16294
16330
  uploadFile: uploadFile,
@@ -18100,7 +18136,7 @@ const getReactions$1 = (params, callback, config) => {
18100
18136
  };
18101
18137
  /* end_public_function */
18102
18138
 
18103
- var index$n = /*#__PURE__*/Object.freeze({
18139
+ var index$o = /*#__PURE__*/Object.freeze({
18104
18140
  __proto__: null,
18105
18141
  addReaction: addReaction,
18106
18142
  removeReaction: removeReaction,
@@ -19872,7 +19908,7 @@ const getMessages = (params, callback, config) => {
19872
19908
  };
19873
19909
  /* end_public_function */
19874
19910
 
19875
- var index$m = /*#__PURE__*/Object.freeze({
19911
+ var index$n = /*#__PURE__*/Object.freeze({
19876
19912
  __proto__: null,
19877
19913
  createMessage: createMessage,
19878
19914
  updateMessage: updateMessage,
@@ -20398,7 +20434,7 @@ const stopMessageReceiptSync = (subChannelId) => {
20398
20434
  };
20399
20435
  /* end_public_function */
20400
20436
 
20401
- var index$l = /*#__PURE__*/Object.freeze({
20437
+ var index$m = /*#__PURE__*/Object.freeze({
20402
20438
  __proto__: null,
20403
20439
  getSubChannelByIds: getSubChannels$1,
20404
20440
  createSubChannel: createSubChannel,
@@ -21725,7 +21761,7 @@ const searchMembers$1 = (params, callback, config) => {
21725
21761
  };
21726
21762
  /* end_public_function */
21727
21763
 
21728
- var index$k = /*#__PURE__*/Object.freeze({
21764
+ var index$l = /*#__PURE__*/Object.freeze({
21729
21765
  __proto__: null,
21730
21766
  addMembers: addMembers$1,
21731
21767
  removeMembers: removeMembers$1,
@@ -21928,7 +21964,7 @@ const unmuteMembers = async (channelId, userIds) => {
21928
21964
  };
21929
21965
  /* end_public_function */
21930
21966
 
21931
- var index$j = /*#__PURE__*/Object.freeze({
21967
+ var index$k = /*#__PURE__*/Object.freeze({
21932
21968
  __proto__: null,
21933
21969
  addRole: addRole,
21934
21970
  removeRole: removeRole,
@@ -21938,10 +21974,10 @@ var index$j = /*#__PURE__*/Object.freeze({
21938
21974
  unmuteMembers: unmuteMembers
21939
21975
  });
21940
21976
 
21941
- var index$i = /*#__PURE__*/Object.freeze({
21977
+ var index$j = /*#__PURE__*/Object.freeze({
21942
21978
  __proto__: null,
21943
- Membership: index$k,
21944
- Moderation: index$j,
21979
+ Membership: index$l,
21980
+ Moderation: index$k,
21945
21981
  getChannelByIds: getChannelByIds$1,
21946
21982
  createChannel: createChannel,
21947
21983
  updateChannel: updateChannel,
@@ -23344,7 +23380,7 @@ const searchMembers = (params, callback, config) => {
23344
23380
  };
23345
23381
  /* end_public_function */
23346
23382
 
23347
- var index$h = /*#__PURE__*/Object.freeze({
23383
+ var index$i = /*#__PURE__*/Object.freeze({
23348
23384
  __proto__: null,
23349
23385
  addMembers: addMembers,
23350
23386
  removeMembers: removeMembers,
@@ -24595,7 +24631,7 @@ const unbanMembers = async (communityId, userIds) => {
24595
24631
  };
24596
24632
  /* end_public_function */
24597
24633
 
24598
- var index$g = /*#__PURE__*/Object.freeze({
24634
+ var index$h = /*#__PURE__*/Object.freeze({
24599
24635
  __proto__: null,
24600
24636
  addRoles: addRoles,
24601
24637
  removeRoles: removeRoles,
@@ -24603,10 +24639,10 @@ var index$g = /*#__PURE__*/Object.freeze({
24603
24639
  unbanMembers: unbanMembers
24604
24640
  });
24605
24641
 
24606
- var index$f = /*#__PURE__*/Object.freeze({
24642
+ var index$g = /*#__PURE__*/Object.freeze({
24607
24643
  __proto__: null,
24608
- Moderation: index$g,
24609
- Membership: index$h,
24644
+ Moderation: index$h,
24645
+ Membership: index$i,
24610
24646
  getCommunityByIds: getCommunities$1,
24611
24647
  createCommunity: createCommunity,
24612
24648
  updateCommunity: updateCommunity,
@@ -24840,7 +24876,7 @@ const getCategories = (params, callback, config) => {
24840
24876
  };
24841
24877
  /* end_public_function */
24842
24878
 
24843
- var index$e = /*#__PURE__*/Object.freeze({
24879
+ var index$f = /*#__PURE__*/Object.freeze({
24844
24880
  __proto__: null,
24845
24881
  getCategory: getCategory,
24846
24882
  getCategories: getCategories
@@ -25899,7 +25935,7 @@ const getComments = (params, callback, config) => {
25899
25935
  };
25900
25936
  /* end_public_function */
25901
25937
 
25902
- var index$d = /*#__PURE__*/Object.freeze({
25938
+ var index$e = /*#__PURE__*/Object.freeze({
25903
25939
  __proto__: null,
25904
25940
  getCommentByIds: getCommentByIds,
25905
25941
  createComment: createComment,
@@ -26570,7 +26606,7 @@ const getUserFeed = (params, callback, config) => {
26570
26606
  };
26571
26607
  /* end_public_function */
26572
26608
 
26573
- var index$c = /*#__PURE__*/Object.freeze({
26609
+ var index$d = /*#__PURE__*/Object.freeze({
26574
26610
  __proto__: null,
26575
26611
  queryGlobalFeed: queryGlobalFeed,
26576
26612
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -26685,7 +26721,15 @@ const createPost = async (bundle) => {
26685
26721
  // eslint-disable-next-line no-param-reassign
26686
26722
  delete bundle.dataType;
26687
26723
  }
26688
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
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 }));
26689
26733
  fireEvent('post.created', payload);
26690
26734
  const data = preparePostPayload(payload);
26691
26735
  const cachedAt = client.cache && Date.now();
@@ -26722,7 +26766,15 @@ const createPost = async (bundle) => {
26722
26766
  const editPost = async (postId, patch) => {
26723
26767
  const client = getActiveClient();
26724
26768
  client.log('user/editPost', patch);
26725
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, 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 }));
26726
26778
  const data = prepareMembershipPayload(payload, 'communityUsers');
26727
26779
  const cachedAt = client.cache && Date.now();
26728
26780
  if (client.cache)
@@ -29366,7 +29418,7 @@ const getRooms = (params, callback, config) => {
29366
29418
  };
29367
29419
  /* end_public_function */
29368
29420
 
29369
- var index$b = /*#__PURE__*/Object.freeze({
29421
+ var index$c = /*#__PURE__*/Object.freeze({
29370
29422
  __proto__: null,
29371
29423
  createRoom: createRoom,
29372
29424
  updateRoom: updateRoom,
@@ -29662,7 +29714,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
29662
29714
  };
29663
29715
  /* end_public_function */
29664
29716
 
29665
- var index$a = /*#__PURE__*/Object.freeze({
29717
+ var index$b = /*#__PURE__*/Object.freeze({
29666
29718
  __proto__: null,
29667
29719
  getPostByIds: getPostByIds,
29668
29720
  createPost: createPost,
@@ -30272,7 +30324,7 @@ const getStreams = (params, callback, config) => {
30272
30324
  };
30273
30325
  };
30274
30326
 
30275
- var index$9 = /*#__PURE__*/Object.freeze({
30327
+ var index$a = /*#__PURE__*/Object.freeze({
30276
30328
  __proto__: null,
30277
30329
  createStream: createStream,
30278
30330
  updateStream: updateStream,
@@ -30575,7 +30627,7 @@ const stopHeartbeat = (roomId) => {
30575
30627
  };
30576
30628
  /* end_public_function */
30577
30629
 
30578
- var index$8 = /*#__PURE__*/Object.freeze({
30630
+ var index$9 = /*#__PURE__*/Object.freeze({
30579
30631
  __proto__: null,
30580
30632
  getRoomOnlineUsers: getRoomOnlineUsers,
30581
30633
  getRoomUserCount: getRoomUserCount,
@@ -30883,7 +30935,7 @@ const getPoll = (pollId, callback) => {
30883
30935
  };
30884
30936
  /* end_public_function */
30885
30937
 
30886
- var index$7 = /*#__PURE__*/Object.freeze({
30938
+ var index$8 = /*#__PURE__*/Object.freeze({
30887
30939
  __proto__: null,
30888
30940
  createPoll: createPoll,
30889
30941
  closePoll: closePoll,
@@ -31187,7 +31239,7 @@ const getPlayer = async (parameters) => {
31187
31239
  return video;
31188
31240
  };
31189
31241
 
31190
- var index$6 = /*#__PURE__*/Object.freeze({
31242
+ var index$7 = /*#__PURE__*/Object.freeze({
31191
31243
  __proto__: null,
31192
31244
  getPlayer: getPlayer
31193
31245
  });
@@ -32360,7 +32412,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
32360
32412
  };
32361
32413
  };
32362
32414
 
32363
- var index$5 = /*#__PURE__*/Object.freeze({
32415
+ var index$6 = /*#__PURE__*/Object.freeze({
32364
32416
  __proto__: null,
32365
32417
  createImageStory: createImageStory,
32366
32418
  createVideoStory: createVideoStory,
@@ -32397,7 +32449,7 @@ const getNetworkAds = async () => {
32397
32449
  };
32398
32450
  };
32399
32451
 
32400
- var index$4 = /*#__PURE__*/Object.freeze({
32452
+ var index$5 = /*#__PURE__*/Object.freeze({
32401
32453
  __proto__: null,
32402
32454
  getNetworkAds: getNetworkAds
32403
32455
  });
@@ -32788,7 +32840,7 @@ const markTraySeen = async (lastSeenAt) => {
32788
32840
  };
32789
32841
  /* end_public_function */
32790
32842
 
32791
- var index$3 = /*#__PURE__*/Object.freeze({
32843
+ var index$4 = /*#__PURE__*/Object.freeze({
32792
32844
  __proto__: null,
32793
32845
  getNotificationTraySeen: getNotificationTraySeen,
32794
32846
  getNotificationTrayItems: getNotificationTrayItems,
@@ -33086,7 +33138,7 @@ const getInvitations = (params, callback) => {
33086
33138
  };
33087
33139
  };
33088
33140
 
33089
- var index$2 = /*#__PURE__*/Object.freeze({
33141
+ var index$3 = /*#__PURE__*/Object.freeze({
33090
33142
  __proto__: null,
33091
33143
  cancelInvitation: cancelInvitation,
33092
33144
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -33235,7 +33287,7 @@ const getReactions = (postId, callback) => {
33235
33287
  };
33236
33288
  };
33237
33289
 
33238
- var index$1 = /*#__PURE__*/Object.freeze({
33290
+ var index$2 = /*#__PURE__*/Object.freeze({
33239
33291
  __proto__: null,
33240
33292
  createReaction: createReaction,
33241
33293
  onLiveReactionCreated: onLiveReactionCreated,
@@ -33718,7 +33770,7 @@ const getMyEvents = (params, callback, config) => {
33718
33770
  };
33719
33771
  };
33720
33772
 
33721
- var index = /*#__PURE__*/Object.freeze({
33773
+ var index$1 = /*#__PURE__*/Object.freeze({
33722
33774
  __proto__: null,
33723
33775
  createEvent: createEvent,
33724
33776
  updateEvent: updateEvent,
@@ -33739,38 +33791,249 @@ var index = /*#__PURE__*/Object.freeze({
33739
33791
  getRSVPs: getRSVPs
33740
33792
  });
33741
33793
 
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
+
33742
34004
  exports.API_REGIONS = API_REGIONS;
33743
- exports.AdRepository = index$4;
33744
- exports.CategoryRepository = index$e;
33745
- exports.ChannelRepository = index$i;
33746
- exports.Client = index$r;
33747
- exports.CommentRepository = index$d;
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;
33748
34010
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
33749
34011
  exports.CommunityPostSettings = CommunityPostSettings;
33750
- exports.CommunityRepository = index$f;
34012
+ exports.CommunityRepository = index$g;
33751
34013
  exports.ContentFeedType = ContentFeedType;
33752
34014
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
33753
- exports.EventRepository = index;
33754
- exports.FeedRepository = index$c;
33755
- exports.FileRepository = index$o;
34015
+ exports.EventRepository = index$1;
34016
+ exports.FeedRepository = index$d;
34017
+ exports.FileRepository = index$p;
33756
34018
  exports.FileType = FileType;
33757
34019
  exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
33758
- exports.InvitationRepository = index$2;
33759
- exports.LiveReactionRepository = index$1;
33760
- exports.LiveStreamPlayer = index$6;
34020
+ exports.InvitationRepository = index$3;
34021
+ exports.LiveReactionRepository = index$2;
34022
+ exports.LiveStreamPlayer = index$7;
33761
34023
  exports.MessageContentType = MessageContentType;
33762
- exports.MessageRepository = index$m;
33763
- exports.PollRepository = index$7;
34024
+ exports.MessageRepository = index$n;
34025
+ exports.PollRepository = index$8;
33764
34026
  exports.PostContentType = PostContentType;
33765
- exports.PostRepository = index$a;
34027
+ exports.PostRepository = index$b;
33766
34028
  exports.PostStructureType = PostStructureType;
33767
- exports.ReactionRepository = index$n;
33768
- exports.RoomPresenceRepository = index$8;
33769
- exports.RoomRepository = index$b;
33770
- exports.StoryRepository = index$5;
33771
- exports.StreamRepository = index$9;
33772
- exports.SubChannelRepository = index$l;
33773
- exports.UserRepository = index$p;
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;
33774
34037
  exports.VERSION = VERSION;
33775
34038
  exports.VideoResolution = VideoResolution;
33776
34039
  exports.VideoSize = VideoSize;
@@ -33826,7 +34089,7 @@ exports.isPaged = isPaged;
33826
34089
  exports.isReportedByMe = isReportedByMe;
33827
34090
  exports.isSkip = isSkip;
33828
34091
  exports.mergeInCache = mergeInCache;
33829
- exports.notificationTray = index$3;
34092
+ exports.notificationTray = index$4;
33830
34093
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
33831
34094
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
33832
34095
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;