@amityco/ts-sdk 7.12.1-df30e76f.0 → 7.12.1-e2c3e656.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/@types/core/events.d.ts +1 -1
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +0 -2
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +0 -4
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/client.d.ts +0 -3
  8. package/dist/@types/domains/client.d.ts.map +1 -1
  9. package/dist/@types/domains/post.d.ts +0 -1
  10. package/dist/@types/domains/post.d.ts.map +1 -1
  11. package/dist/@types/domains/room.d.ts +1 -1
  12. package/dist/@types/domains/room.d.ts.map +1 -1
  13. package/dist/@types/index.d.ts +0 -1
  14. package/dist/@types/index.d.ts.map +1 -1
  15. package/dist/client/api/index.d.ts +0 -1
  16. package/dist/client/api/index.d.ts.map +1 -1
  17. package/dist/client/api/setSessionState.d.ts +1 -1
  18. package/dist/client/api/setSessionState.d.ts.map +1 -1
  19. package/dist/client/events/onSessionStateChange.d.ts +1 -1
  20. package/dist/client/events/onSessionStateChange.d.ts.map +1 -1
  21. package/dist/client/utils/SessionWatcher.d.ts +2 -2
  22. package/dist/client/utils/SessionWatcher.d.ts.map +1 -1
  23. package/dist/core/events.d.ts +1 -1
  24. package/dist/core/events.d.ts.map +1 -1
  25. package/dist/core/model/idResolvers.d.ts.map +1 -1
  26. package/dist/core/model/index.d.ts.map +1 -1
  27. package/dist/feedRepository/observers/utils.d.ts +1 -1
  28. package/dist/index.cjs.js +74 -329
  29. package/dist/index.d.ts +0 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.esm.js +52 -306
  32. package/dist/index.umd.js +2 -2
  33. package/dist/postRepository/api/createPost.d.ts +0 -2
  34. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  35. package/dist/postRepository/api/editPost.d.ts +0 -2
  36. package/dist/postRepository/api/editPost.d.ts.map +1 -1
  37. package/dist/postRepository/observers/utils.d.ts +2 -2
  38. package/dist/reactionRepository/events/onReactionAdded.d.ts +1 -1
  39. package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
  40. package/dist/reactionRepository/events/onReactionRemoved.d.ts +1 -1
  41. package/dist/reactionRepository/events/onReactionRemoved.d.ts.map +1 -1
  42. package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
  43. package/dist/utils/event.d.ts +1 -1
  44. package/dist/utils/event.d.ts.map +1 -1
  45. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  46. package/dist/utils/liveObject.d.ts +1 -1
  47. package/dist/utils/liveObject.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/dist/@types/domains/product.d.ts +0 -77
  50. package/dist/@types/domains/product.d.ts.map +0 -1
  51. package/dist/client/api/getProductCatalogueSetting.d.ts +0 -15
  52. package/dist/client/api/getProductCatalogueSetting.d.ts.map +0 -1
  53. package/dist/productRepository/index.d.ts +0 -2
  54. package/dist/productRepository/index.d.ts.map +0 -1
  55. package/dist/productRepository/internalApi/getProduct.d.ts +0 -5
  56. package/dist/productRepository/internalApi/getProduct.d.ts.map +0 -1
  57. package/dist/productRepository/internalApi/index.d.ts +0 -2
  58. package/dist/productRepository/internalApi/index.d.ts.map +0 -1
  59. package/dist/productRepository/observers/getProduct.d.ts +0 -21
  60. package/dist/productRepository/observers/getProduct.d.ts.map +0 -1
  61. package/dist/productRepository/observers/index.d.ts +0 -3
  62. package/dist/productRepository/observers/index.d.ts.map +0 -1
  63. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts +0 -15
  64. package/dist/productRepository/observers/searchProducts/LiveCollectionController.d.ts.map +0 -1
  65. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts +0 -5
  66. package/dist/productRepository/observers/searchProducts/PaginationController.d.ts.map +0 -1
  67. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts +0 -8
  68. package/dist/productRepository/observers/searchProducts/QueryStreamController.d.ts.map +0 -1
  69. package/dist/productRepository/observers/searchProducts.d.ts +0 -25
  70. package/dist/productRepository/observers/searchProducts.d.ts.map +0 -1
  71. package/dist/utils/linkedObject/productTagLinkedObject.d.ts +0 -2
  72. package/dist/utils/linkedObject/productTagLinkedObject.d.ts.map +0 -1
package/dist/index.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,uBAAuB,CAAC;AAC7D,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAG/C,cAAc,gBAAgB,CAAC;AAE/B,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC"}
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,uBAAuB,CAAC;AAC7D,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAG/C,cAAc,gBAAgB,CAAC;AAE/B,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AAEvD,OAAO,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC"}
package/dist/index.esm.js CHANGED
@@ -674,7 +674,6 @@ const idResolvers = {
674
674
  viewer: ({ userId }) => userId,
675
675
  event: ({ eventId }) => eventId,
676
676
  eventResponse: ({ userId }) => userId,
677
- product: ({ _id }) => _id,
678
677
  };
679
678
  /**
680
679
  * Retrieve the id resolver matching a domain name
@@ -734,7 +733,6 @@ const PAYLOAD2MODEL = {
734
733
  events: 'event',
735
734
  viewers: 'viewer',
736
735
  eventResponses: 'eventResponse',
737
- products: 'product',
738
736
  };
739
737
  /** hidden */
740
738
  const isOutdated = (prevData, nextData) => {
@@ -22922,11 +22920,11 @@ class SessionWatcher {
22922
22920
  this._listener.delete(callback);
22923
22921
  };
22924
22922
  }
22925
- setSessionState(state) {
22923
+ setSessionState(state, reason) {
22926
22924
  if (this._sessionState === state)
22927
22925
  return;
22928
22926
  this._sessionState = state;
22929
- this._listener.forEach(cb => cb(state));
22927
+ this._listener.forEach(cb => cb(state, reason));
22930
22928
  }
22931
22929
  destroy() {
22932
22930
  this._listener.clear();
@@ -23366,9 +23364,9 @@ const isValidStateChange = (prevState, nextState) => {
23366
23364
  *
23367
23365
  * @category private
23368
23366
  */
23369
- const setSessionState = (state) => {
23367
+ const setSessionState = (state, reason) => {
23370
23368
  const client = getActiveClient();
23371
- client.log('client/api/setSessionState', state);
23369
+ client.log('client/api/setSessionState', state, reason);
23372
23370
  const { sessionState: prevState } = client;
23373
23371
  if (prevState === state)
23374
23372
  return false;
@@ -23377,7 +23375,7 @@ const setSessionState = (state) => {
23377
23375
  throw new ASCError(`Session state cannot change from ${prevState} to ${state}`, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
23378
23376
  }
23379
23377
  client.sessionState = state;
23380
- SessionWatcher$1.getInstance().setSessionState(state);
23378
+ SessionWatcher$1.getInstance().setSessionState(state, reason);
23381
23379
  return true;
23382
23380
  };
23383
23381
 
@@ -24830,7 +24828,7 @@ const logout = async () => {
24830
24828
  */
24831
24829
  const terminateClient = (terminationReason) => {
24832
24830
  const client = getActiveClient();
24833
- setSessionState("terminated" /* Amity.SessionStates.TERMINATED */);
24831
+ setSessionState("terminated" /* Amity.SessionStates.TERMINATED */, terminationReason);
24834
24832
  if (client.http.defaults.metadata) {
24835
24833
  if (terminationReason === "globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */)
24836
24834
  client.http.defaults.metadata.isGlobalBanned = true;
@@ -26157,29 +26155,6 @@ const getShareableLinkConfiguration = async () => {
26157
26155
  return data;
26158
26156
  };
26159
26157
 
26160
- /* begin_public_function
26161
- id: client.getProductCatalogueSetting
26162
- */
26163
- /**
26164
- * ```js
26165
- * import { getProductCatalogueSetting } from '@amityco/ts-sdk'
26166
- * const productCatalogueSetting = await getProductCatalogueSetting()
26167
- * ```
26168
- *
26169
- * Fetches a {@link Amity.ProductCatalogueSetting} object
26170
- *
26171
- * @returns A Promise of {@link Amity.ProductCatalogueSetting} object
26172
- *
26173
- * @category Client API
26174
- * @async
26175
- */
26176
- const getProductCatalogueSetting = async () => {
26177
- const client = getActiveClient();
26178
- const { data } = await client.http.get(`/api/v3/network-settings/product-catalogue`);
26179
- return data;
26180
- };
26181
- /* end_public_function */
26182
-
26183
26158
  /**
26184
26159
  * Retrieves a pair of {@link Amity.Tokens} necessary for connection
26185
26160
  *
@@ -26672,7 +26647,7 @@ const getUserUnread = (callback) => {
26672
26647
  };
26673
26648
  };
26674
26649
 
26675
- var index$s = /*#__PURE__*/Object.freeze({
26650
+ var index$r = /*#__PURE__*/Object.freeze({
26676
26651
  __proto__: null,
26677
26652
  getActiveClient: getActiveClient,
26678
26653
  getActiveUser: getActiveUser,
@@ -26692,7 +26667,6 @@ var index$s = /*#__PURE__*/Object.freeze({
26692
26667
  getLinkPreviewMetadata: getLinkPreviewMetadata,
26693
26668
  getSocialSettings: getSocialSettings,
26694
26669
  getShareableLinkConfiguration: getShareableLinkConfiguration,
26695
- getProductCatalogueSetting: getProductCatalogueSetting,
26696
26670
  loginAsVisitor: loginAsVisitor,
26697
26671
  loginAsBot: loginAsBot,
26698
26672
  getCurrentUser: getCurrentUser,
@@ -26750,12 +26724,19 @@ const blockUser = async (userId) => {
26750
26724
  const { data } = await client.http.post(`/api/v4/me/user-blocks/${userId}`);
26751
26725
  const cachedAt = client.cache && Date.now();
26752
26726
  const { follows, followCounts } = data;
26753
- const followStatus = { follows };
26727
+ const blockedFollowStatus = { follows };
26754
26728
  if (client.cache) {
26755
- ingestInCache(followStatus, { cachedAt });
26729
+ ingestInCache(blockedFollowStatus, { cachedAt });
26756
26730
  upsertInCache(['followInfo', 'get', userId], followCounts[0], { cachedAt });
26757
26731
  }
26758
- const payload = prepareFollowStatusPayload(followStatus);
26732
+ // need to swap {from} and {to} to get the correct id for unfollow event to filter from follower live collection
26733
+ const blockedUnfollowStatus = {
26734
+ follows: follows.map(follow => {
26735
+ const unfollowStatus = Object.assign(Object.assign({}, follow), { to: follow.from, from: follow.to, status: 'none' });
26736
+ return follow.status === 'blocked' ? unfollowStatus : follow;
26737
+ }),
26738
+ };
26739
+ const payload = prepareFollowStatusPayload(blockedUnfollowStatus);
26759
26740
  fireEvent('local.follow.unfollowed', payload);
26760
26741
  return data;
26761
26742
  };
@@ -27893,7 +27874,7 @@ const getMyFollowInfo = (callback) => {
27893
27874
  };
27894
27875
  /* end_public_function */
27895
27876
 
27896
- var index$r = /*#__PURE__*/Object.freeze({
27877
+ var index$q = /*#__PURE__*/Object.freeze({
27897
27878
  __proto__: null,
27898
27879
  blockUser: blockUser,
27899
27880
  unBlockUser: unBlockUser,
@@ -30001,11 +29982,6 @@ const communityLinkedObject = (community) => {
30001
29982
  } });
30002
29983
  };
30003
29984
 
30004
- const productTagLinkedObject = (productTag) => {
30005
- var _a;
30006
- return Object.assign(Object.assign({}, productTag), { product: (_a = pullFromCache(['product', 'get', productTag.productId])) === null || _a === void 0 ? void 0 : _a.data });
30007
- };
30008
-
30009
29985
  const postLinkedObject = (post) => {
30010
29986
  return shallowClone(post, {
30011
29987
  childrenPosts: post.children
@@ -30018,10 +29994,6 @@ const postLinkedObject = (post) => {
30018
29994
  analyticsEngineInstance.markPostAsViewed(post.postId);
30019
29995
  },
30020
29996
  },
30021
- get productTags() {
30022
- var _a, _b;
30023
- return (_b = (_a = post.productTags) === null || _a === void 0 ? void 0 : _a.map(productTag => productTagLinkedObject(productTag))) !== null && _b !== void 0 ? _b : [];
30024
- },
30025
29997
  get latestComments() {
30026
29998
  if (!post.comments)
30027
29999
  return [];
@@ -32011,9 +31983,9 @@ var AmityUserSearchMatchType;
32011
31983
  AmityUserSearchMatchType["PARTIAL"] = "partial";
32012
31984
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
32013
31985
 
32014
- var index$q = /*#__PURE__*/Object.freeze({
31986
+ var index$p = /*#__PURE__*/Object.freeze({
32015
31987
  __proto__: null,
32016
- Relationship: index$r,
31988
+ Relationship: index$q,
32017
31989
  getUserByIds: getUserByIds,
32018
31990
  updateUser: updateUser,
32019
31991
  flagUser: flagUser,
@@ -32416,7 +32388,7 @@ const uploadAudio = async (formData, onProgress) => {
32416
32388
  };
32417
32389
  /* end_public_function */
32418
32390
 
32419
- var index$p = /*#__PURE__*/Object.freeze({
32391
+ var index$o = /*#__PURE__*/Object.freeze({
32420
32392
  __proto__: null,
32421
32393
  getFile: getFile,
32422
32394
  uploadFile: uploadFile,
@@ -34228,7 +34200,7 @@ const getReactions$1 = (params, callback, config) => {
34228
34200
  };
34229
34201
  /* end_public_function */
34230
34202
 
34231
- var index$o = /*#__PURE__*/Object.freeze({
34203
+ var index$n = /*#__PURE__*/Object.freeze({
34232
34204
  __proto__: null,
34233
34205
  addReaction: addReaction,
34234
34206
  removeReaction: removeReaction,
@@ -36000,7 +35972,7 @@ const getMessages = (params, callback, config) => {
36000
35972
  };
36001
35973
  /* end_public_function */
36002
35974
 
36003
- var index$n = /*#__PURE__*/Object.freeze({
35975
+ var index$m = /*#__PURE__*/Object.freeze({
36004
35976
  __proto__: null,
36005
35977
  createMessage: createMessage,
36006
35978
  updateMessage: updateMessage,
@@ -36526,7 +36498,7 @@ const stopMessageReceiptSync = (subChannelId) => {
36526
36498
  };
36527
36499
  /* end_public_function */
36528
36500
 
36529
- var index$m = /*#__PURE__*/Object.freeze({
36501
+ var index$l = /*#__PURE__*/Object.freeze({
36530
36502
  __proto__: null,
36531
36503
  getSubChannelByIds: getSubChannels$1,
36532
36504
  createSubChannel: createSubChannel,
@@ -37853,7 +37825,7 @@ const searchMembers$1 = (params, callback, config) => {
37853
37825
  };
37854
37826
  /* end_public_function */
37855
37827
 
37856
- var index$l = /*#__PURE__*/Object.freeze({
37828
+ var index$k = /*#__PURE__*/Object.freeze({
37857
37829
  __proto__: null,
37858
37830
  addMembers: addMembers$1,
37859
37831
  removeMembers: removeMembers$1,
@@ -38056,7 +38028,7 @@ const unmuteMembers = async (channelId, userIds) => {
38056
38028
  };
38057
38029
  /* end_public_function */
38058
38030
 
38059
- var index$k = /*#__PURE__*/Object.freeze({
38031
+ var index$j = /*#__PURE__*/Object.freeze({
38060
38032
  __proto__: null,
38061
38033
  addRole: addRole,
38062
38034
  removeRole: removeRole,
@@ -38066,10 +38038,10 @@ var index$k = /*#__PURE__*/Object.freeze({
38066
38038
  unmuteMembers: unmuteMembers
38067
38039
  });
38068
38040
 
38069
- var index$j = /*#__PURE__*/Object.freeze({
38041
+ var index$i = /*#__PURE__*/Object.freeze({
38070
38042
  __proto__: null,
38071
- Membership: index$l,
38072
- Moderation: index$k,
38043
+ Membership: index$k,
38044
+ Moderation: index$j,
38073
38045
  getChannelByIds: getChannelByIds$1,
38074
38046
  createChannel: createChannel,
38075
38047
  updateChannel: updateChannel,
@@ -39472,7 +39444,7 @@ const searchMembers = (params, callback, config) => {
39472
39444
  };
39473
39445
  /* end_public_function */
39474
39446
 
39475
- var index$i = /*#__PURE__*/Object.freeze({
39447
+ var index$h = /*#__PURE__*/Object.freeze({
39476
39448
  __proto__: null,
39477
39449
  addMembers: addMembers,
39478
39450
  removeMembers: removeMembers,
@@ -40723,7 +40695,7 @@ const unbanMembers = async (communityId, userIds) => {
40723
40695
  };
40724
40696
  /* end_public_function */
40725
40697
 
40726
- var index$h = /*#__PURE__*/Object.freeze({
40698
+ var index$g = /*#__PURE__*/Object.freeze({
40727
40699
  __proto__: null,
40728
40700
  addRoles: addRoles,
40729
40701
  removeRoles: removeRoles,
@@ -40731,10 +40703,10 @@ var index$h = /*#__PURE__*/Object.freeze({
40731
40703
  unbanMembers: unbanMembers
40732
40704
  });
40733
40705
 
40734
- var index$g = /*#__PURE__*/Object.freeze({
40706
+ var index$f = /*#__PURE__*/Object.freeze({
40735
40707
  __proto__: null,
40736
- Moderation: index$h,
40737
- Membership: index$i,
40708
+ Moderation: index$g,
40709
+ Membership: index$h,
40738
40710
  getCommunityByIds: getCommunities$1,
40739
40711
  createCommunity: createCommunity,
40740
40712
  updateCommunity: updateCommunity,
@@ -40968,7 +40940,7 @@ const getCategories = (params, callback, config) => {
40968
40940
  };
40969
40941
  /* end_public_function */
40970
40942
 
40971
- var index$f = /*#__PURE__*/Object.freeze({
40943
+ var index$e = /*#__PURE__*/Object.freeze({
40972
40944
  __proto__: null,
40973
40945
  getCategory: getCategory,
40974
40946
  getCategories: getCategories
@@ -42027,7 +41999,7 @@ const getComments = (params, callback, config) => {
42027
41999
  };
42028
42000
  /* end_public_function */
42029
42001
 
42030
- var index$e = /*#__PURE__*/Object.freeze({
42002
+ var index$d = /*#__PURE__*/Object.freeze({
42031
42003
  __proto__: null,
42032
42004
  getCommentByIds: getCommentByIds,
42033
42005
  createComment: createComment,
@@ -42698,7 +42670,7 @@ const getUserFeed = (params, callback, config) => {
42698
42670
  };
42699
42671
  /* end_public_function */
42700
42672
 
42701
- var index$d = /*#__PURE__*/Object.freeze({
42673
+ var index$c = /*#__PURE__*/Object.freeze({
42702
42674
  __proto__: null,
42703
42675
  queryGlobalFeed: queryGlobalFeed,
42704
42676
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
@@ -42813,15 +42785,7 @@ const createPost = async (bundle) => {
42813
42785
  // eslint-disable-next-line no-param-reassign
42814
42786
  delete bundle.dataType;
42815
42787
  }
42816
- const { attachments } = bundle;
42817
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
42818
- ? attachments.map(attachment => {
42819
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
42820
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
42821
- return attachment;
42822
- })
42823
- : attachments;
42824
- const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { attachments: processedAttachments }));
42788
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
42825
42789
  fireEvent('post.created', payload);
42826
42790
  const data = preparePostPayload(payload);
42827
42791
  const cachedAt = client.cache && Date.now();
@@ -42858,15 +42822,7 @@ const createPost = async (bundle) => {
42858
42822
  const editPost = async (postId, patch) => {
42859
42823
  const client = getActiveClient();
42860
42824
  client.log('user/editPost', patch);
42861
- const { attachments } = patch;
42862
- const processedAttachments = attachments && (attachments === null || attachments === void 0 ? void 0 : attachments.length) > 0
42863
- ? attachments.map(attachment => {
42864
- if (attachment.productTags && (attachment === null || attachment === void 0 ? void 0 : attachment.productTags.length) > 0)
42865
- return Object.assign(Object.assign({}, attachment), { productTags: attachment.productTags.map(productId => ({ productId })) });
42866
- return attachment;
42867
- })
42868
- : attachments;
42869
- const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, Object.assign(Object.assign({}, patch), { attachments: processedAttachments }));
42825
+ const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
42870
42826
  const data = prepareMembershipPayload(payload, 'communityUsers');
42871
42827
  const cachedAt = client.cache && Date.now();
42872
42828
  if (client.cache)
@@ -45510,7 +45466,7 @@ const getRooms = (params, callback, config) => {
45510
45466
  };
45511
45467
  /* end_public_function */
45512
45468
 
45513
- var index$c = /*#__PURE__*/Object.freeze({
45469
+ var index$b = /*#__PURE__*/Object.freeze({
45514
45470
  __proto__: null,
45515
45471
  createRoom: createRoom,
45516
45472
  updateRoom: updateRoom,
@@ -45806,7 +45762,7 @@ const getCommunityLiveRoomPosts = (params, callback, config) => {
45806
45762
  };
45807
45763
  /* end_public_function */
45808
45764
 
45809
- var index$b = /*#__PURE__*/Object.freeze({
45765
+ var index$a = /*#__PURE__*/Object.freeze({
45810
45766
  __proto__: null,
45811
45767
  getPostByIds: getPostByIds,
45812
45768
  createPost: createPost,
@@ -46416,7 +46372,7 @@ const getStreams = (params, callback, config) => {
46416
46372
  };
46417
46373
  };
46418
46374
 
46419
- var index$a = /*#__PURE__*/Object.freeze({
46375
+ var index$9 = /*#__PURE__*/Object.freeze({
46420
46376
  __proto__: null,
46421
46377
  createStream: createStream,
46422
46378
  updateStream: updateStream,
@@ -46719,7 +46675,7 @@ const stopHeartbeat = (roomId) => {
46719
46675
  };
46720
46676
  /* end_public_function */
46721
46677
 
46722
- var index$9 = /*#__PURE__*/Object.freeze({
46678
+ var index$8 = /*#__PURE__*/Object.freeze({
46723
46679
  __proto__: null,
46724
46680
  getRoomOnlineUsers: getRoomOnlineUsers,
46725
46681
  getRoomUserCount: getRoomUserCount,
@@ -47027,7 +46983,7 @@ const getPoll = (pollId, callback) => {
47027
46983
  };
47028
46984
  /* end_public_function */
47029
46985
 
47030
- var index$8 = /*#__PURE__*/Object.freeze({
46986
+ var index$7 = /*#__PURE__*/Object.freeze({
47031
46987
  __proto__: null,
47032
46988
  createPoll: createPoll,
47033
46989
  closePoll: closePoll,
@@ -47331,7 +47287,7 @@ const getPlayer = async (parameters) => {
47331
47287
  return video;
47332
47288
  };
47333
47289
 
47334
- var index$7 = /*#__PURE__*/Object.freeze({
47290
+ var index$6 = /*#__PURE__*/Object.freeze({
47335
47291
  __proto__: null,
47336
47292
  getPlayer: getPlayer
47337
47293
  });
@@ -48504,7 +48460,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
48504
48460
  };
48505
48461
  };
48506
48462
 
48507
- var index$6 = /*#__PURE__*/Object.freeze({
48463
+ var index$5 = /*#__PURE__*/Object.freeze({
48508
48464
  __proto__: null,
48509
48465
  createImageStory: createImageStory,
48510
48466
  createVideoStory: createVideoStory,
@@ -48541,7 +48497,7 @@ const getNetworkAds = async () => {
48541
48497
  };
48542
48498
  };
48543
48499
 
48544
- var index$5 = /*#__PURE__*/Object.freeze({
48500
+ var index$4 = /*#__PURE__*/Object.freeze({
48545
48501
  __proto__: null,
48546
48502
  getNetworkAds: getNetworkAds
48547
48503
  });
@@ -48932,7 +48888,7 @@ const markTraySeen = async (lastSeenAt) => {
48932
48888
  };
48933
48889
  /* end_public_function */
48934
48890
 
48935
- var index$4 = /*#__PURE__*/Object.freeze({
48891
+ var index$3 = /*#__PURE__*/Object.freeze({
48936
48892
  __proto__: null,
48937
48893
  getNotificationTraySeen: getNotificationTraySeen,
48938
48894
  getNotificationTrayItems: getNotificationTrayItems,
@@ -49230,7 +49186,7 @@ const getInvitations = (params, callback) => {
49230
49186
  };
49231
49187
  };
49232
49188
 
49233
- var index$3 = /*#__PURE__*/Object.freeze({
49189
+ var index$2 = /*#__PURE__*/Object.freeze({
49234
49190
  __proto__: null,
49235
49191
  cancelInvitation: cancelInvitation,
49236
49192
  onLocalInvitationCreated: onLocalInvitationCreated,
@@ -49379,7 +49335,7 @@ const getReactions = (postId, callback) => {
49379
49335
  };
49380
49336
  };
49381
49337
 
49382
- var index$2 = /*#__PURE__*/Object.freeze({
49338
+ var index$1 = /*#__PURE__*/Object.freeze({
49383
49339
  __proto__: null,
49384
49340
  createReaction: createReaction,
49385
49341
  onLiveReactionCreated: onLiveReactionCreated,
@@ -49862,7 +49818,7 @@ const getMyEvents = (params, callback, config) => {
49862
49818
  };
49863
49819
  };
49864
49820
 
49865
- var index$1 = /*#__PURE__*/Object.freeze({
49821
+ var index = /*#__PURE__*/Object.freeze({
49866
49822
  __proto__: null,
49867
49823
  createEvent: createEvent,
49868
49824
  updateEvent: updateEvent,
@@ -49883,214 +49839,4 @@ var index$1 = /*#__PURE__*/Object.freeze({
49883
49839
  getRSVPs: getRSVPs
49884
49840
  });
49885
49841
 
49886
- const getProduct$1 = async (productId) => {
49887
- const client = getActiveClient();
49888
- client.log('product/getProduct', productId);
49889
- isInTombstone('product', productId);
49890
- let payload;
49891
- try {
49892
- const response = await client.http.get(`/api/v1/products/${encodeURIComponent(productId)}`);
49893
- payload = response.data;
49894
- }
49895
- catch (error) {
49896
- if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
49897
- pushToTombstone('product', productId);
49898
- }
49899
- throw error;
49900
- }
49901
- const cachedAt = client.cache && Date.now();
49902
- if (client.cache)
49903
- ingestInCache(payload, { cachedAt });
49904
- const { products } = payload;
49905
- const result = products.find(product => product.productId === productId);
49906
- return {
49907
- data: result,
49908
- cachedAt,
49909
- };
49910
- };
49911
- getProduct$1.locally = (productId) => {
49912
- const client = getActiveClient();
49913
- client.log('product/getProduct.locally', productId);
49914
- if (!client.cache)
49915
- return;
49916
- const cached = pullFromCache(['product', 'get', productId]);
49917
- if (!cached)
49918
- return;
49919
- return {
49920
- data: cached.data,
49921
- cachedAt: cached.cachedAt,
49922
- };
49923
- };
49924
-
49925
- /* begin_public_function
49926
- id: product.get
49927
- */
49928
- /**
49929
- * ```js
49930
- * import { ProductRepository } from '@amityco/ts-sdk';
49931
- *
49932
- * let product;
49933
- *
49934
- * const unsub = ProductRepository.getProduct(productId, response => {
49935
- * product = response.data;
49936
- * });
49937
- * ```
49938
- *
49939
- * Observe all mutation on a given {@link Amity.Product}
49940
- *
49941
- * @param productId the ID of the product to observe
49942
- * @param callback the function to call when new data are available
49943
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the product
49944
- *
49945
- * @category Product Live Object
49946
- */
49947
- const getProduct = (productId, callback) => {
49948
- const responder = (snapshot) => {
49949
- callback(snapshot);
49950
- };
49951
- return liveObject(productId, responder, 'productId', getProduct$1, []);
49952
- };
49953
- /* end_public_function */
49954
-
49955
- class SearchProductPaginationController extends PaginationController {
49956
- async getRequest(queryParams, token) {
49957
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
49958
- const options = token ? { token } : { limit };
49959
- const { data: queryResponse } = await this.http.get(`/api/v1/products/search`, {
49960
- params: Object.assign(Object.assign({}, params), { options }),
49961
- });
49962
- return queryResponse;
49963
- }
49964
- }
49965
-
49966
- class SearchProductQueryStreamController extends QueryStreamController {
49967
- constructor(query, cacheKey, notifyChange) {
49968
- super(query, cacheKey);
49969
- this.notifyChange = notifyChange;
49970
- }
49971
- // eslint-disable-next-line class-methods-use-this
49972
- saveToMainDB(response) {
49973
- const client = getActiveClient();
49974
- const cachedAt = client.cache && Date.now();
49975
- if (client.cache) {
49976
- ingestInCache(response, { cachedAt });
49977
- }
49978
- }
49979
- appendToQueryStream(response, direction, refresh = false) {
49980
- var _a, _b;
49981
- if (refresh) {
49982
- pushToCache(this.cacheKey, {
49983
- data: response.products.map(getResolver('product')),
49984
- });
49985
- }
49986
- else {
49987
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
49988
- const products = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
49989
- pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...products, ...response.products.map(getResolver('product'))])] }));
49990
- }
49991
- }
49992
- }
49993
-
49994
- class SearchProductLiveCollectionController extends LiveCollectionController {
49995
- constructor(query, callback) {
49996
- const queryStreamId = hash(query);
49997
- const cacheKey = ['products', 'collection', queryStreamId];
49998
- const paginationController = new SearchProductPaginationController(query);
49999
- super(paginationController, queryStreamId, cacheKey, callback);
50000
- this.query = query;
50001
- this.queryStreamController = new SearchProductQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this));
50002
- this.callback = callback.bind(this);
50003
- this.loadPage({ initial: true });
50004
- }
50005
- setup() {
50006
- var _a;
50007
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
50008
- if (!collection) {
50009
- pushToCache(this.cacheKey, {
50010
- data: [],
50011
- params: {},
50012
- });
50013
- }
50014
- }
50015
- async persistModel(queryPayload) {
50016
- await this.queryStreamController.saveToMainDB(queryPayload);
50017
- }
50018
- persistQueryStream({ response, direction, refresh, }) {
50019
- this.queryStreamController.appendToQueryStream(response, direction, refresh);
50020
- }
50021
- // eslint-disable-next-line class-methods-use-this
50022
- startSubscription() {
50023
- return [];
50024
- }
50025
- notifyChange({ origin, loading, error }) {
50026
- var _a, _b;
50027
- const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
50028
- if (!collection)
50029
- return;
50030
- const data = (_b = collection.data
50031
- .map(id => pullFromCache(['product', 'get', id]))
50032
- .filter(isNonNullable)
50033
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
50034
- if (!this.shouldNotify(data) && origin === 'event')
50035
- return;
50036
- this.callback({
50037
- onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
50038
- data,
50039
- hasNextPage: !!this.paginationController.getNextToken(),
50040
- loading,
50041
- error,
50042
- });
50043
- }
50044
- }
50045
-
50046
- /* begin_public_function
50047
- id: product.search
50048
- */
50049
- /**
50050
- * ```js
50051
- * import { ProductRepository } from '@amityco/ts-sdk'
50052
- *
50053
- * let products = []
50054
- * const unsub = ProductRepository.searchProducts({
50055
- * keyword: string,
50056
- * }, response => merge(products, response.data))
50057
- * ```
50058
- *
50059
- * Observe all mutations on a list of {@link Amity.Product}
50060
- *
50061
- * @param params.keyword the search keyword
50062
- * @param params.isActive filter by active status
50063
- * @param params.isDeleted filter by deleted status
50064
- * @param params.sortBy sort option
50065
- * @param params.sortOrder order option
50066
- * @param callback the function to call when new data are available
50067
- * @param config
50068
- * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the products
50069
- *
50070
- * @category Products Live Collection
50071
- */
50072
- const searchProducts = (params, callback, config) => {
50073
- const { log, cache } = getActiveClient();
50074
- if (!cache) {
50075
- console.log(ENABLE_CACHE_MESSAGE);
50076
- }
50077
- const timestamp = Date.now();
50078
- log(`searchProducts(tmpid: ${timestamp}) > listen`);
50079
- const productsLiveCollection = new SearchProductLiveCollectionController(params, callback);
50080
- const disposers = productsLiveCollection.startSubscription();
50081
- const cacheKey = productsLiveCollection.getCacheKey();
50082
- disposers.push(() => dropFromCache(cacheKey));
50083
- return () => {
50084
- log(`searchProducts(tmpid: ${timestamp}) > dispose`);
50085
- disposers.forEach(fn => fn());
50086
- };
50087
- };
50088
- /* end_public_function */
50089
-
50090
- var index = /*#__PURE__*/Object.freeze({
50091
- __proto__: null,
50092
- getProduct: getProduct,
50093
- searchProducts: searchProducts
50094
- });
50095
-
50096
- 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 };
49842
+ 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 };