@amityco/ts-sdk-react-native 7.2.0 → 7.3.1-1cd86e2.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 (80) hide show
  1. package/.env +26 -26
  2. package/dist/@types/core/events.d.ts +4 -0
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/model.d.ts +4 -0
  5. package/dist/@types/core/model.d.ts.map +1 -1
  6. package/dist/@types/core/payload.d.ts +24 -0
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/ad.d.ts +1 -1
  9. package/dist/@types/domains/ad.d.ts.map +1 -1
  10. package/dist/@types/domains/notification.d.ts +78 -0
  11. package/dist/@types/domains/notification.d.ts.map +1 -0
  12. package/dist/@types/index.d.ts +1 -0
  13. package/dist/@types/index.d.ts.map +1 -1
  14. package/dist/core/events.d.ts +3 -3
  15. package/dist/core/events.d.ts.map +1 -1
  16. package/dist/core/model/idResolvers.d.ts.map +1 -1
  17. package/dist/core/model/index.d.ts.map +1 -1
  18. package/dist/index.cjs.js +434 -47
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.esm.js +417 -31
  22. package/dist/index.umd.js +3 -3
  23. package/dist/notificationTray/api/index.d.ts +3 -0
  24. package/dist/notificationTray/api/index.d.ts.map +1 -0
  25. package/dist/notificationTray/api/markItemsSeen.d.ts +16 -0
  26. package/dist/notificationTray/api/markItemsSeen.d.ts.map +1 -0
  27. package/dist/notificationTray/api/markTraySeen.d.ts +19 -0
  28. package/dist/notificationTray/api/markTraySeen.d.ts.map +1 -0
  29. package/dist/notificationTray/events/index.d.ts +2 -0
  30. package/dist/notificationTray/events/index.d.ts.map +1 -0
  31. package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts +17 -0
  32. package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
  33. package/dist/notificationTray/index.d.ts +4 -0
  34. package/dist/notificationTray/index.d.ts.map +1 -0
  35. package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts +30 -0
  36. package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts.map +1 -0
  37. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
  38. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
  39. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
  40. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
  41. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
  42. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
  43. package/dist/notificationTray/observers/getNotificationTrayItems.d.ts +12 -0
  44. package/dist/notificationTray/observers/getNotificationTrayItems.d.ts.map +1 -0
  45. package/dist/notificationTray/observers/getNotificationTraySeen.d.ts +20 -0
  46. package/dist/notificationTray/observers/getNotificationTraySeen.d.ts.map +1 -0
  47. package/dist/notificationTray/observers/index.d.ts +3 -0
  48. package/dist/notificationTray/observers/index.d.ts.map +1 -0
  49. package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
  50. package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts.map +1 -0
  51. package/dist/utils/linkedObject/index.d.ts +1 -0
  52. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  53. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +2 -0
  54. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -0
  55. package/package.json +1 -1
  56. package/src/@types/core/events.ts +5 -0
  57. package/src/@types/core/model.ts +6 -0
  58. package/src/@types/core/payload.ts +29 -0
  59. package/src/@types/domains/ad.ts +1 -1
  60. package/src/@types/domains/notification.ts +94 -0
  61. package/src/@types/index.ts +1 -0
  62. package/src/core/model/idResolvers.ts +3 -0
  63. package/src/core/model/index.ts +2 -0
  64. package/src/index.ts +2 -0
  65. package/src/notificationTray/api/index.ts +2 -0
  66. package/src/notificationTray/api/markItemsSeen.ts +62 -0
  67. package/src/notificationTray/api/markTraySeen.ts +65 -0
  68. package/src/notificationTray/events/index.ts +1 -0
  69. package/src/notificationTray/events/onNotificationTraySeenUpdated.ts +36 -0
  70. package/src/notificationTray/index.ts +3 -0
  71. package/src/notificationTray/internalApi/getNotificationTraySeen.ts +80 -0
  72. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +96 -0
  73. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
  74. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
  75. package/src/notificationTray/observers/getNotificationTrayItems.ts +44 -0
  76. package/src/notificationTray/observers/getNotificationTraySeen.ts +60 -0
  77. package/src/notificationTray/observers/index.ts +2 -0
  78. package/src/notificationTray/utils/prepareNotificationTrayItemsPayload.ts +12 -0
  79. package/src/utils/linkedObject/index.ts +2 -0
  80. package/src/utils/linkedObject/notificationTrayLinkedObject.ts +19 -0
package/dist/index.cjs.js CHANGED
@@ -123,8 +123,8 @@ const PostContentType = Object.freeze({
123
123
 
124
124
  function getVersion() {
125
125
  try {
126
- // the string ''v7.2.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
127
- return 'v7.2.0-cjs';
126
+ // the string ''v7.3.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
127
+ return 'v7.3.0-cjs';
128
128
  }
129
129
  catch (error) {
130
130
  return '__dev__';
@@ -142,6 +142,7 @@ const SECOND$1 = 1000;
142
142
  const MINUTE = 60 * SECOND$1;
143
143
  const HOUR = 60 * MINUTE;
144
144
  const DAY = 24 * HOUR;
145
+ const WEEK = 7 * DAY;
145
146
  const YEAR = 365 * DAY;
146
147
  const ACCESS_TOKEN_WATCHER_INTERVAL = 10 * MINUTE;
147
148
 
@@ -564,6 +565,8 @@ const idResolvers = {
564
565
  advertiser: ({ advertiserId }) => advertiserId,
565
566
  pin: ({ placement, referenceId }) => `${placement}#${referenceId}`,
566
567
  pinTarget: ({ targetId }) => targetId,
568
+ notificationTrayItem: ({ _id }) => _id,
569
+ notificationTraySeen: ({ userId }) => userId,
567
570
  };
568
571
  /**
569
572
  * Retrieve the id resolver matching a domain name
@@ -615,6 +618,7 @@ const PAYLOAD2MODEL = {
615
618
  advertisers: 'advertiser',
616
619
  pinTargets: 'pinTarget',
617
620
  pins: 'pin',
621
+ notificationTrayItems: 'notificationTrayItem',
618
622
  };
619
623
  /** hidden */
620
624
  const isOutdated = (prevData, nextData) => {
@@ -6297,6 +6301,14 @@ const pinnedPostLinkedObject = (pinnedPost) => {
6297
6301
  } });
6298
6302
  };
6299
6303
 
6304
+ const notificationTrayLinkedObject = (noti) => {
6305
+ return Object.assign(Object.assign({}, noti), { isSeen: noti.lastSeenAt > noti.lastOccurredAt, isRecent: new Date(noti.lastOccurredAt).getTime() >= Date.now() - WEEK, users: noti.actors
6306
+ .map(({ publicId }) => pullFromCache(['user', 'get', publicId]))
6307
+ .filter(isNonNullable)
6308
+ .map(({ data }) => data)
6309
+ .map(user => userLinkedObject(user)) });
6310
+ };
6311
+
6300
6312
  const LinkedObject = {
6301
6313
  ad: adLinkedObject,
6302
6314
  comment: commentLinkedObject,
@@ -6310,6 +6322,7 @@ const LinkedObject = {
6310
6322
  reactor: reactorLinkedObject,
6311
6323
  channel: channelLinkedObject,
6312
6324
  pinnedPost: pinnedPostLinkedObject,
6325
+ notificationTray: notificationTrayLinkedObject,
6313
6326
  };
6314
6327
 
6315
6328
  const getChannelMessagePreviewWithUser = (channel) => {
@@ -10299,7 +10312,7 @@ const getUserUnread = (callback) => {
10299
10312
  };
10300
10313
  };
10301
10314
 
10302
- var index$l = /*#__PURE__*/Object.freeze({
10315
+ var index$m = /*#__PURE__*/Object.freeze({
10303
10316
  __proto__: null,
10304
10317
  getActiveClient: getActiveClient,
10305
10318
  getActiveUser: getActiveUser,
@@ -11509,7 +11522,7 @@ const getMyFollowInfo = (callback) => {
11509
11522
  };
11510
11523
  /* end_public_function */
11511
11524
 
11512
- var index$k = /*#__PURE__*/Object.freeze({
11525
+ var index$l = /*#__PURE__*/Object.freeze({
11513
11526
  __proto__: null,
11514
11527
  blockUser: blockUser,
11515
11528
  unBlockUser: unBlockUser,
@@ -12524,9 +12537,9 @@ var AmityUserSearchMatchType;
12524
12537
  AmityUserSearchMatchType["PARTIAL"] = "partial";
12525
12538
  })(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
12526
12539
 
12527
- var index$j = /*#__PURE__*/Object.freeze({
12540
+ var index$k = /*#__PURE__*/Object.freeze({
12528
12541
  __proto__: null,
12529
- Relationship: index$k,
12542
+ Relationship: index$l,
12530
12543
  getUserByIds: getUserByIds,
12531
12544
  updateUser: updateUser,
12532
12545
  flagUser: flagUser,
@@ -12790,7 +12803,7 @@ const uploadImage = async (formData, onProgress) => {
12790
12803
  };
12791
12804
  /* end_public_function */
12792
12805
 
12793
- var index$i = /*#__PURE__*/Object.freeze({
12806
+ var index$j = /*#__PURE__*/Object.freeze({
12794
12807
  __proto__: null,
12795
12808
  getFile: getFile,
12796
12809
  uploadFile: uploadFile,
@@ -14657,7 +14670,7 @@ const getReactions = (params, callback, config) => {
14657
14670
  };
14658
14671
  /* end_public_function */
14659
14672
 
14660
- var index$h = /*#__PURE__*/Object.freeze({
14673
+ var index$i = /*#__PURE__*/Object.freeze({
14661
14674
  __proto__: null,
14662
14675
  addReaction: addReaction,
14663
14676
  removeReaction: removeReaction,
@@ -16473,7 +16486,7 @@ const getMessages = (params, callback, config) => {
16473
16486
  };
16474
16487
  /* end_public_function */
16475
16488
 
16476
- var index$g = /*#__PURE__*/Object.freeze({
16489
+ var index$h = /*#__PURE__*/Object.freeze({
16477
16490
  __proto__: null,
16478
16491
  createMessage: createMessage,
16479
16492
  updateMessage: updateMessage,
@@ -16999,7 +17012,7 @@ const stopMessageReceiptSync = (subChannelId) => {
16999
17012
  };
17000
17013
  /* end_public_function */
17001
17014
 
17002
- var index$f = /*#__PURE__*/Object.freeze({
17015
+ var index$g = /*#__PURE__*/Object.freeze({
17003
17016
  __proto__: null,
17004
17017
  getSubChannelByIds: getSubChannels$1,
17005
17018
  createSubChannel: createSubChannel,
@@ -18313,7 +18326,7 @@ const searchMembers$1 = (params, callback, config) => {
18313
18326
  };
18314
18327
  /* end_public_function */
18315
18328
 
18316
- var index$e = /*#__PURE__*/Object.freeze({
18329
+ var index$f = /*#__PURE__*/Object.freeze({
18317
18330
  __proto__: null,
18318
18331
  addMembers: addMembers$1,
18319
18332
  removeMembers: removeMembers$1,
@@ -18516,7 +18529,7 @@ const unmuteMembers = async (channelId, userIds) => {
18516
18529
  };
18517
18530
  /* end_public_function */
18518
18531
 
18519
- var index$d = /*#__PURE__*/Object.freeze({
18532
+ var index$e = /*#__PURE__*/Object.freeze({
18520
18533
  __proto__: null,
18521
18534
  addRole: addRole,
18522
18535
  removeRole: removeRole,
@@ -18526,10 +18539,10 @@ var index$d = /*#__PURE__*/Object.freeze({
18526
18539
  unmuteMembers: unmuteMembers
18527
18540
  });
18528
18541
 
18529
- var index$c = /*#__PURE__*/Object.freeze({
18542
+ var index$d = /*#__PURE__*/Object.freeze({
18530
18543
  __proto__: null,
18531
- Membership: index$e,
18532
- Moderation: index$d,
18544
+ Membership: index$f,
18545
+ Moderation: index$e,
18533
18546
  getChannelByIds: getChannelByIds$1,
18534
18547
  createChannel: createChannel,
18535
18548
  updateChannel: updateChannel,
@@ -19909,7 +19922,7 @@ const searchMembers = (params, callback, config) => {
19909
19922
  };
19910
19923
  /* end_public_function */
19911
19924
 
19912
- var index$b = /*#__PURE__*/Object.freeze({
19925
+ var index$c = /*#__PURE__*/Object.freeze({
19913
19926
  __proto__: null,
19914
19927
  addMembers: addMembers,
19915
19928
  removeMembers: removeMembers,
@@ -20934,7 +20947,7 @@ const unbanMembers = async (communityId, userIds) => {
20934
20947
  };
20935
20948
  /* end_public_function */
20936
20949
 
20937
- var index$a = /*#__PURE__*/Object.freeze({
20950
+ var index$b = /*#__PURE__*/Object.freeze({
20938
20951
  __proto__: null,
20939
20952
  addRoles: addRoles,
20940
20953
  removeRoles: removeRoles,
@@ -20942,10 +20955,10 @@ var index$a = /*#__PURE__*/Object.freeze({
20942
20955
  unbanMembers: unbanMembers
20943
20956
  });
20944
20957
 
20945
- var index$9 = /*#__PURE__*/Object.freeze({
20958
+ var index$a = /*#__PURE__*/Object.freeze({
20946
20959
  __proto__: null,
20947
- Moderation: index$a,
20948
- Membership: index$b,
20960
+ Moderation: index$b,
20961
+ Membership: index$c,
20949
20962
  getCommunityByIds: getCommunities$1,
20950
20963
  createCommunity: createCommunity,
20951
20964
  updateCommunity: updateCommunity,
@@ -21178,7 +21191,7 @@ const getCategories = (params, callback, config) => {
21178
21191
  };
21179
21192
  /* end_public_function */
21180
21193
 
21181
- var index$8 = /*#__PURE__*/Object.freeze({
21194
+ var index$9 = /*#__PURE__*/Object.freeze({
21182
21195
  __proto__: null,
21183
21196
  getCategory: getCategory,
21184
21197
  getCategories: getCategories
@@ -21346,7 +21359,7 @@ getCustomRankingGlobalFeed.locally = (query) => {
21346
21359
  : undefined;
21347
21360
  };
21348
21361
 
21349
- var index$7 = /*#__PURE__*/Object.freeze({
21362
+ var index$8 = /*#__PURE__*/Object.freeze({
21350
21363
  __proto__: null,
21351
21364
  queryGlobalFeed: queryGlobalFeed,
21352
21365
  getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
@@ -22661,7 +22674,7 @@ const getComments = (params, callback, config) => {
22661
22674
  };
22662
22675
  /* end_public_function */
22663
22676
 
22664
- var index$6 = /*#__PURE__*/Object.freeze({
22677
+ var index$7 = /*#__PURE__*/Object.freeze({
22665
22678
  __proto__: null,
22666
22679
  getCommentByIds: getCommentByIds,
22667
22680
  createComment: createComment,
@@ -23668,7 +23681,7 @@ const semanticSearchPosts = (params, callback, config) => {
23668
23681
  };
23669
23682
  };
23670
23683
 
23671
- var index$5 = /*#__PURE__*/Object.freeze({
23684
+ var index$6 = /*#__PURE__*/Object.freeze({
23672
23685
  __proto__: null,
23673
23686
  getPostByIds: getPostByIds,
23674
23687
  createPost: createPost,
@@ -24197,7 +24210,7 @@ const getStreams = (params, callback, config) => {
24197
24210
  };
24198
24211
  /* end_public_function */
24199
24212
 
24200
- var index$4 = /*#__PURE__*/Object.freeze({
24213
+ var index$5 = /*#__PURE__*/Object.freeze({
24201
24214
  __proto__: null,
24202
24215
  createStream: createStream,
24203
24216
  updateStream: updateStream,
@@ -24484,7 +24497,7 @@ const getPoll = (pollId, callback) => {
24484
24497
  };
24485
24498
  /* end_public_function */
24486
24499
 
24487
- var index$3 = /*#__PURE__*/Object.freeze({
24500
+ var index$4 = /*#__PURE__*/Object.freeze({
24488
24501
  __proto__: null,
24489
24502
  createPoll: createPoll,
24490
24503
  closePoll: closePoll,
@@ -24495,7 +24508,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
24495
24508
  getPoll: getPoll
24496
24509
  });
24497
24510
 
24498
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTF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mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
24499
24512
  /*
24500
24513
  * The crypto algorithm used for importing key and signing string
24501
24514
  */
@@ -24855,7 +24868,7 @@ const getPlayer = async (parameters) => {
24855
24868
  return video;
24856
24869
  };
24857
24870
 
24858
- var index$2 = /*#__PURE__*/Object.freeze({
24871
+ var index$3 = /*#__PURE__*/Object.freeze({
24859
24872
  __proto__: null,
24860
24873
  getPlayer: getPlayer
24861
24874
  });
@@ -26027,7 +26040,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
26027
26040
  };
26028
26041
  };
26029
26042
 
26030
- var index$1 = /*#__PURE__*/Object.freeze({
26043
+ var index$2 = /*#__PURE__*/Object.freeze({
26031
26044
  __proto__: null,
26032
26045
  createImageStory: createImageStory,
26033
26046
  createVideoStory: createVideoStory,
@@ -26064,7 +26077,7 @@ const getNetworkAds = async () => {
26064
26077
  };
26065
26078
  };
26066
26079
 
26067
- var index = /*#__PURE__*/Object.freeze({
26080
+ var index$1 = /*#__PURE__*/Object.freeze({
26068
26081
  __proto__: null,
26069
26082
  getNetworkAds: getNetworkAds
26070
26083
  });
@@ -26091,31 +26104,404 @@ const createUserToken = async (apiKey, apiRegion, params) => {
26091
26104
  return { accessToken: data.accessToken };
26092
26105
  };
26093
26106
 
26107
+ /* begin_public_function
26108
+ id: notificationTray.getNotificationTraySeen
26109
+ */
26110
+ /**
26111
+ * ```js
26112
+ * import { notificationTray } from '@amityco/ts-sdk'
26113
+ * const notificationTraySeen = await notificationTray.getNotificationTraySeen()
26114
+ * ```
26115
+ *
26116
+ *
26117
+ * @returns A page of {@link Amity.NotificationTraySeen} objects
26118
+ *
26119
+ * @category NotificationTray API
26120
+ * @async
26121
+ * */
26122
+ const getNotificationTraySeen$1 = async () => {
26123
+ const client = getActiveClient();
26124
+ client.log('notificationTray/getNotificationTraySeen', {});
26125
+ const { data: payload } = await client.http.get(`api/v1/notification-tray/tray/seen`);
26126
+ const cachedAt = client.cache && Date.now();
26127
+ if (client.cache) {
26128
+ const cacheKey = ['notificationTraySeen', 'get', client.userId];
26129
+ pushToCache(cacheKey, {
26130
+ userId: client.userId,
26131
+ lastTraySeenAt: payload.lastTraySeenAt,
26132
+ lastTrayOccuredAt: payload.lastTrayOccurredAt,
26133
+ });
26134
+ }
26135
+ return {
26136
+ data: {
26137
+ userId: client.userId,
26138
+ lastTraySeenAt: payload.lastTraySeenAt,
26139
+ lastTrayOccurredAt: payload.lastTrayOccurredAt,
26140
+ isSeen: payload.lastTraySeenAt > payload.lastTrayOccurredAt,
26141
+ },
26142
+ cachedAt,
26143
+ };
26144
+ };
26145
+ /* end_public_function */
26146
+ /**
26147
+ * ```js
26148
+ * import { notificationTray } from '@amityco/ts-sdk'
26149
+ * const notificationTraySeen = await notificationTray.getNotificationTraySeen.locally()
26150
+ * ```
26151
+ *
26152
+ * Queries a paginable list of {@link Amity.NotificationTraySeen} objects from cache
26153
+ *
26154
+ * @returns A page of {@link Amity.NotificationTraySeen} objects
26155
+ *
26156
+ * @category NotificationTray API
26157
+ * @async
26158
+ * */
26159
+ getNotificationTraySeen$1.locally = () => {
26160
+ var _a;
26161
+ const client = getActiveClient();
26162
+ client.log('notificationTray/getNotificationTraySeen.locally', {});
26163
+ if (!client.cache)
26164
+ return;
26165
+ const queryKey = ['notificationTraySeen', 'get'];
26166
+ const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
26167
+ if (!data)
26168
+ return;
26169
+ return { data, cachedAt };
26170
+ };
26171
+
26172
+ /**
26173
+ * ```js
26174
+ * import { onNotificationTraySeenUpdated } from '@amityco/ts-sdk'
26175
+ * const dispose = onNotificationTraySeenUpdated(data => {
26176
+ * // ...
26177
+ * })
26178
+ * ```
26179
+ *
26180
+ * Fired when an {@link Amity.NotificationTraySeen} has been updated
26181
+ *
26182
+ * @param callback The function to call when the event was fired
26183
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
26184
+ *
26185
+ * @category NotificationTraySeen Events
26186
+ */
26187
+ const onNotificationTraySeenUpdated = (callback) => {
26188
+ const client = getActiveClient();
26189
+ const disposers = [
26190
+ createEventSubscriber(client, 'onNotificationTraySeenUpdated', 'local.notificationTraySeen.updated', payload => callback(payload)),
26191
+ ];
26192
+ return () => {
26193
+ disposers.forEach(fn => fn());
26194
+ };
26195
+ };
26196
+
26197
+ /* begin_public_function
26198
+ id: notificationTray.getNotificationTraySeen
26199
+ */
26200
+ /**
26201
+ * ```js
26202
+ * import { notificationTray } from '@amityco/ts-sdk';
26203
+ *
26204
+ * let notificationTraySeen;
26205
+ *
26206
+ * const unsubscribe = getNotificationTraySeen(response => {
26207
+ * notificationTraySeen = response.data;
26208
+ * });
26209
+ * ```
26210
+ *
26211
+ * Observe all mutation on a given {@link Amity.NotificationTraySeen}
26212
+ *
26213
+ * @param callback the function to call when new data are available
26214
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the message
26215
+ *
26216
+ * @category NotificationTraySeen Live Object
26217
+ */
26218
+ const getNotificationTraySeen = (callback) => {
26219
+ const { userId } = getActiveUser();
26220
+ return liveObject(userId, callback, 'userId', getNotificationTraySeen$1, [onNotificationTraySeenUpdated], {
26221
+ callbackDataSelector: (data) => {
26222
+ let isSeen = true;
26223
+ if (data === null || data === void 0 ? void 0 : data.lastTrayOccurredAt) {
26224
+ if (!data.lastTraySeenAt) {
26225
+ isSeen = false;
26226
+ }
26227
+ else {
26228
+ isSeen =
26229
+ convertDateStringToTimestamp(data.lastTraySeenAt) >
26230
+ convertDateStringToTimestamp(data.lastTrayOccurredAt);
26231
+ }
26232
+ }
26233
+ return {
26234
+ lastTrayOccurredAt: data === null || data === void 0 ? void 0 : data.lastTrayOccurredAt,
26235
+ lastTraySeenAt: data === null || data === void 0 ? void 0 : data.lastTraySeenAt,
26236
+ isSeen,
26237
+ };
26238
+ },
26239
+ });
26240
+ };
26241
+ /* end_public_function */
26242
+
26243
+ /**
26244
+ * TODO: handle cache receive cache option, and cache policy
26245
+ * TODO: check if querybyIds is supported
26246
+ */
26247
+ class NotificationTrayItemsPaginationController extends PaginationController {
26248
+ async getRequest(queryParams, token) {
26249
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
26250
+ const options = token ? { token } : { limit };
26251
+ const { data: queryResponse } = await this.http.get(`/api/v1/notification-tray`, {
26252
+ params: Object.assign(Object.assign({}, params), { options }),
26253
+ });
26254
+ return queryResponse;
26255
+ }
26256
+ }
26257
+
26258
+ class NotificationTrayItemsQuerystreamController extends QueryStreamController {
26259
+ constructor(query, cacheKey, notifyChange, preparePayload) {
26260
+ super(query, cacheKey);
26261
+ this.notifyChange = notifyChange;
26262
+ this.preparePayload = preparePayload;
26263
+ }
26264
+ async saveToMainDB(response) {
26265
+ const processedPayload = await this.preparePayload(response);
26266
+ const client = getActiveClient();
26267
+ const cachedAt = client.cache && Date.now();
26268
+ if (client.cache) {
26269
+ ingestInCache(processedPayload, { cachedAt });
26270
+ }
26271
+ }
26272
+ appendToQueryStream(response, direction, refresh = false) {
26273
+ var _a, _b;
26274
+ if (refresh) {
26275
+ pushToCache(this.cacheKey, {
26276
+ data: response.notificationTrayItems.map(getResolver('notificationTrayItem')),
26277
+ });
26278
+ }
26279
+ else {
26280
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26281
+ const notifications = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
26282
+ pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
26283
+ ...new Set([
26284
+ ...notifications,
26285
+ ...response.notificationTrayItems.map(getResolver('notificationTrayItem')),
26286
+ ]),
26287
+ ] }));
26288
+ }
26289
+ }
26290
+ }
26291
+
26292
+ const prepareNotificationTrayItemsPayload = (rawPayload) => {
26293
+ const users = rawPayload.users.map(convertRawUserToInternalUser);
26294
+ return Object.assign(Object.assign({}, rawPayload), { users });
26295
+ };
26296
+
26297
+ class NotificationTrayItemsLiveCollectionController extends LiveCollectionController {
26298
+ constructor(query, callback) {
26299
+ const queryStreamId = hash__default["default"](query);
26300
+ const cacheKey = ['notificationTrayItem', 'collection', queryStreamId];
26301
+ const paginationController = new NotificationTrayItemsPaginationController(query);
26302
+ super(paginationController, queryStreamId, cacheKey, callback);
26303
+ this.query = query;
26304
+ this.queryStreamController = new NotificationTrayItemsQuerystreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareNotificationTrayItemsPayload);
26305
+ this.callback = callback.bind(this);
26306
+ this.loadPage({ initial: true });
26307
+ }
26308
+ setup() {
26309
+ var _a;
26310
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26311
+ if (!collection) {
26312
+ pushToCache(this.cacheKey, {
26313
+ data: [],
26314
+ params: {},
26315
+ });
26316
+ }
26317
+ }
26318
+ async persistModel(queryPayload) {
26319
+ await this.queryStreamController.saveToMainDB(queryPayload);
26320
+ }
26321
+ persistQueryStream({ response, direction, refresh, }) {
26322
+ this.queryStreamController.appendToQueryStream(response, direction, refresh);
26323
+ }
26324
+ // eslint-disable-next-line class-methods-use-this
26325
+ startSubscription() {
26326
+ return [];
26327
+ }
26328
+ notifyChange({ origin, loading, error }) {
26329
+ var _a, _b;
26330
+ const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
26331
+ if (!collection)
26332
+ return;
26333
+ const data = ((_b = collection.data
26334
+ .map(id => pullFromCache(['notificationTrayItem', 'get', id]))
26335
+ .filter(isNonNullable)
26336
+ .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.notificationTray);
26337
+ if (!this.shouldNotify(data) && origin === 'event')
26338
+ return;
26339
+ this.callback({
26340
+ onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
26341
+ data,
26342
+ hasNextPage: !!this.paginationController.getNextToken(),
26343
+ loading,
26344
+ error,
26345
+ });
26346
+ }
26347
+ }
26348
+
26349
+ /**
26350
+ * Get notification tray items for a notification tray page
26351
+ *
26352
+ * @param params the limit query parameters
26353
+ * @param callback the callback to be called when the notification tray items are updated
26354
+ * @returns items in the notification tray
26355
+ *
26356
+ * @category Notification tray items Live Collection
26357
+ *
26358
+ */
26359
+ const getNotificationTrayItems = (params, callback, config) => {
26360
+ const { log, cache } = getActiveClient();
26361
+ if (!cache) {
26362
+ console.log(ENABLE_CACHE_MESSAGE);
26363
+ }
26364
+ const timestamp = Date.now();
26365
+ log(`getNotificationTrayItems(tmpid: ${timestamp}) > listen`);
26366
+ const notiTrayItemsLiveCollection = new NotificationTrayItemsLiveCollectionController(params, callback);
26367
+ const disposers = notiTrayItemsLiveCollection.startSubscription();
26368
+ const cacheKey = notiTrayItemsLiveCollection.getCacheKey();
26369
+ disposers.push(() => dropFromCache(cacheKey));
26370
+ return () => {
26371
+ log(`getNotificationTrayItems(tmpid: ${timestamp}) > dispose`);
26372
+ disposers.forEach(fn => fn());
26373
+ };
26374
+ };
26375
+
26376
+ /* begin_public_function
26377
+ id: notificationTrayItem.markSeen
26378
+ */
26379
+ /**
26380
+ * ```js
26381
+ * import { notificationTray } from '@amityco/ts-sdk'
26382
+ * const updated = await notificationTray.markItemsSeen()
26383
+ * ```
26384
+ *
26385
+ * Updates an {@link Amity.NotificationItemSeen}
26386
+ *
26387
+ * @param trayItems[] that include id and lastTraySeenAt, The ID of the {@link Amity.NotificationItemSeen} to edit
26388
+ * @returns the updated {@link Amity.NotificationItemSeen} object
26389
+ *
26390
+ * @category NotificationItemSeen API
26391
+ * @async
26392
+ */
26393
+ const markItemsSeen = async (trayItems) => {
26394
+ const client = getActiveClient();
26395
+ client.log('notificationTray/markItemsSeen', {});
26396
+ const { data: payload } = await client.http.post(`api/v1/notification-tray/items/seen`, {
26397
+ trayItems: trayItems.map(item => ({
26398
+ id: item.id,
26399
+ lastSeenAt: item.lastSeenAt,
26400
+ })),
26401
+ });
26402
+ const updatedData = payload.trayItems
26403
+ .map(patchItem => {
26404
+ var _a;
26405
+ const cacheData = (_a = pullFromCache([
26406
+ 'notificationTrayItem',
26407
+ 'get',
26408
+ patchItem.id,
26409
+ ])) === null || _a === void 0 ? void 0 : _a.data;
26410
+ if (!cacheData)
26411
+ return;
26412
+ const data = Object.assign(Object.assign({}, cacheData), { lastSeenAt: patchItem.lastSeenAt });
26413
+ if (client.cache) {
26414
+ const cachedAt = Date.now();
26415
+ pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
26416
+ }
26417
+ return data;
26418
+ })
26419
+ .filter(Boolean);
26420
+ fireEvent('local.notificationTrayItem.updated', { notificationTrayItems: updatedData });
26421
+ };
26422
+ /* end_public_function */
26423
+
26424
+ /* begin_public_function
26425
+ id: notificationTray.markSeen
26426
+ */
26427
+ /**
26428
+ * ```js
26429
+ * import { notificationTray } from '@amityco/ts-sdk'
26430
+ * const updated = await notificationTray.markTraySeen({
26431
+ * lastSeenAt: Amity.timestamp,
26432
+ * })
26433
+ * ```
26434
+ *
26435
+ * Updates an {@link Amity.NotificationTraySeen}
26436
+ *
26437
+ * @param userId The ID of the {@link Amity.NotificationTraySeen} to edit
26438
+ * @param lastSeenAt The patch data to apply
26439
+ * @returns the updated {@link Amity.NotificationTraySeen} object
26440
+ *
26441
+ * @category Post API
26442
+ * @async
26443
+ */
26444
+ const markTraySeen = async (lastSeenAt) => {
26445
+ var _a;
26446
+ const client = getActiveClient();
26447
+ client.log('notificationTray/markTraySeen', {});
26448
+ const { data: payload } = await client.http.post(`api/v1/notification-tray/tray/seen`, {
26449
+ lastSeenAt,
26450
+ });
26451
+ const cacheData = (_a = pullFromCache([
26452
+ 'notificationTraySeen',
26453
+ 'get',
26454
+ ])) === null || _a === void 0 ? void 0 : _a.data;
26455
+ const data = {
26456
+ userId: client.userId,
26457
+ lastTraySeenAt: payload.lastSeenAt,
26458
+ };
26459
+ const updateCacheData = Object.assign(Object.assign({}, cacheData), data);
26460
+ const cachedAt = client.cache && Date.now();
26461
+ if (client.cache)
26462
+ pushToCache(['notificationTraySeen', 'get', client.userId], updateCacheData, { cachedAt });
26463
+ fireEvent('local.notificationTraySeen.updated', data);
26464
+ return {
26465
+ data: payload,
26466
+ cachedAt,
26467
+ };
26468
+ };
26469
+ /* end_public_function */
26470
+
26471
+ var index = /*#__PURE__*/Object.freeze({
26472
+ __proto__: null,
26473
+ getNotificationTraySeen: getNotificationTraySeen,
26474
+ getNotificationTrayItems: getNotificationTrayItems,
26475
+ markItemsSeen: markItemsSeen,
26476
+ markTraySeen: markTraySeen,
26477
+ onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
26478
+ });
26479
+
26094
26480
  exports.API_REGIONS = API_REGIONS;
26095
- exports.AdRepository = index;
26096
- exports.CategoryRepository = index$8;
26097
- exports.ChannelRepository = index$c;
26098
- exports.Client = index$l;
26099
- exports.CommentRepository = index$6;
26481
+ exports.AdRepository = index$1;
26482
+ exports.CategoryRepository = index$9;
26483
+ exports.ChannelRepository = index$d;
26484
+ exports.Client = index$m;
26485
+ exports.CommentRepository = index$7;
26100
26486
  exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
26101
26487
  exports.CommunityPostSettings = CommunityPostSettings;
26102
- exports.CommunityRepository = index$9;
26488
+ exports.CommunityRepository = index$a;
26103
26489
  exports.ContentFeedType = ContentFeedType;
26104
26490
  exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
26105
- exports.FeedRepository = index$7;
26106
- exports.FileRepository = index$i;
26491
+ exports.FeedRepository = index$8;
26492
+ exports.FileRepository = index$j;
26107
26493
  exports.FileType = FileType;
26108
- exports.LiveStreamPlayer = index$2;
26494
+ exports.LiveStreamPlayer = index$3;
26109
26495
  exports.MessageContentType = MessageContentType;
26110
- exports.MessageRepository = index$g;
26111
- exports.PollRepository = index$3;
26496
+ exports.MessageRepository = index$h;
26497
+ exports.PollRepository = index$4;
26112
26498
  exports.PostContentType = PostContentType;
26113
- exports.PostRepository = index$5;
26114
- exports.ReactionRepository = index$h;
26115
- exports.StoryRepository = index$1;
26116
- exports.StreamRepository = index$4;
26117
- exports.SubChannelRepository = index$f;
26118
- exports.UserRepository = index$j;
26499
+ exports.PostRepository = index$6;
26500
+ exports.ReactionRepository = index$i;
26501
+ exports.StoryRepository = index$2;
26502
+ exports.StreamRepository = index$5;
26503
+ exports.SubChannelRepository = index$g;
26504
+ exports.UserRepository = index$k;
26119
26505
  exports.VERSION = VERSION;
26120
26506
  exports.VideoResolution = VideoResolution;
26121
26507
  exports.VideoSize = VideoSize;
@@ -26168,6 +26554,7 @@ exports.isPaged = isPaged;
26168
26554
  exports.isReportedByMe = isReportedByMe;
26169
26555
  exports.isSkip = isSkip;
26170
26556
  exports.mergeInCache = mergeInCache;
26557
+ exports.notificationTray = index;
26171
26558
  exports.onChannelMarkerFetched = onChannelMarkerFetched;
26172
26559
  exports.onFeedMarkerFetched = onFeedMarkerFetched;
26173
26560
  exports.onFeedMarkerUpdated = onFeedMarkerUpdated;