@amityco/ts-sdk 7.2.0 → 7.2.1-3663404.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 (97) 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 +45 -1
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/file.d.ts +1 -20
  9. package/dist/@types/domains/file.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/domains/post.d.ts +4 -0
  13. package/dist/@types/domains/post.d.ts.map +1 -1
  14. package/dist/@types/index.d.ts +1 -0
  15. package/dist/@types/index.d.ts.map +1 -1
  16. package/dist/core/events.d.ts +3 -3
  17. package/dist/core/events.d.ts.map +1 -1
  18. package/dist/core/model/idResolvers.d.ts.map +1 -1
  19. package/dist/core/model/index.d.ts.map +1 -1
  20. package/dist/fileRepository/api/index.d.ts +1 -0
  21. package/dist/fileRepository/api/index.d.ts.map +1 -1
  22. package/dist/fileRepository/api/updateAltText.d.ts +17 -0
  23. package/dist/fileRepository/api/updateAltText.d.ts.map +1 -0
  24. package/dist/fileRepository/api/uploadImage.d.ts +2 -1
  25. package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
  26. package/dist/index.cjs.js +526 -50
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.esm.js +509 -34
  30. package/dist/index.umd.js +4 -4
  31. package/dist/notificationTray/api/index.d.ts +3 -0
  32. package/dist/notificationTray/api/index.d.ts.map +1 -0
  33. package/dist/notificationTray/api/markItemsSeen.d.ts +16 -0
  34. package/dist/notificationTray/api/markItemsSeen.d.ts.map +1 -0
  35. package/dist/notificationTray/api/markTraySeen.d.ts +19 -0
  36. package/dist/notificationTray/api/markTraySeen.d.ts.map +1 -0
  37. package/dist/notificationTray/events/index.d.ts +2 -0
  38. package/dist/notificationTray/events/index.d.ts.map +1 -0
  39. package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts +17 -0
  40. package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
  41. package/dist/notificationTray/index.d.ts +4 -0
  42. package/dist/notificationTray/index.d.ts.map +1 -0
  43. package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts +30 -0
  44. package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts.map +1 -0
  45. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
  46. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
  47. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
  48. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
  49. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
  50. package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
  51. package/dist/notificationTray/observers/getNotificationTrayItems.d.ts +12 -0
  52. package/dist/notificationTray/observers/getNotificationTrayItems.d.ts.map +1 -0
  53. package/dist/notificationTray/observers/getNotificationTraySeen.d.ts +20 -0
  54. package/dist/notificationTray/observers/getNotificationTraySeen.d.ts.map +1 -0
  55. package/dist/notificationTray/observers/index.d.ts +3 -0
  56. package/dist/notificationTray/observers/index.d.ts.map +1 -0
  57. package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
  58. package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts.map +1 -0
  59. package/dist/utils/linkedObject/index.d.ts +1 -0
  60. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  61. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +2 -0
  62. package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -0
  63. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  64. package/dist/utils/postTypePredicate.d.ts +4 -0
  65. package/dist/utils/postTypePredicate.d.ts.map +1 -0
  66. package/package.json +1 -1
  67. package/src/@types/core/events.ts +5 -0
  68. package/src/@types/core/model.ts +6 -0
  69. package/src/@types/core/payload.ts +52 -1
  70. package/src/@types/domains/file.ts +1 -21
  71. package/src/@types/domains/notification.ts +94 -0
  72. package/src/@types/domains/post.ts +4 -0
  73. package/src/@types/index.ts +1 -0
  74. package/src/core/model/idResolvers.ts +3 -0
  75. package/src/core/model/index.ts +2 -0
  76. package/src/fileRepository/api/index.ts +1 -0
  77. package/src/fileRepository/api/updateAltText.ts +39 -0
  78. package/src/fileRepository/api/uploadImage.ts +22 -3
  79. package/src/index.ts +2 -0
  80. package/src/notificationTray/api/index.ts +2 -0
  81. package/src/notificationTray/api/markItemsSeen.ts +62 -0
  82. package/src/notificationTray/api/markTraySeen.ts +65 -0
  83. package/src/notificationTray/events/index.ts +1 -0
  84. package/src/notificationTray/events/onNotificationTraySeenUpdated.ts +36 -0
  85. package/src/notificationTray/index.ts +3 -0
  86. package/src/notificationTray/internalApi/getNotificationTraySeen.ts +80 -0
  87. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +96 -0
  88. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
  89. package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
  90. package/src/notificationTray/observers/getNotificationTrayItems.ts +44 -0
  91. package/src/notificationTray/observers/getNotificationTraySeen.ts +60 -0
  92. package/src/notificationTray/observers/index.ts +2 -0
  93. package/src/notificationTray/utils/prepareNotificationTrayItemsPayload.ts +12 -0
  94. package/src/utils/linkedObject/index.ts +2 -0
  95. package/src/utils/linkedObject/notificationTrayLinkedObject.ts +19 -0
  96. package/src/utils/linkedObject/postLinkedObject.ts +29 -0
  97. package/src/utils/postTypePredicate.ts +27 -0
@@ -2,16 +2,19 @@ import { pullFromCache } from '~/cache/api';
2
2
  import { commentLinkedObject } from '~/utils/linkedObject/commentLinkedObject';
3
3
  import AnalyticsEngine from '../../analytic/service/analytic/AnalyticsEngine';
4
4
  import { userLinkedObject } from './userLinkedObject';
5
+ import { isAmityFilePost, isAmityImagePost, isAmityVideoPost } from '../postTypePredicate';
5
6
 
6
7
  export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
7
8
  return {
8
9
  ...post,
10
+
9
11
  analytics: {
10
12
  markAsViewed: () => {
11
13
  const analyticsEngineInstance = AnalyticsEngine.getInstance();
12
14
  analyticsEngineInstance.markPostAsViewed(post.postId);
13
15
  },
14
16
  },
17
+
15
18
  get latestComments(): (Amity.Comment | null)[] {
16
19
  if (!post.comments) return [];
17
20
  return (
@@ -30,10 +33,36 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
30
33
  .filter(Boolean) || []
31
34
  );
32
35
  },
36
+
33
37
  get creator(): Amity.User | undefined {
34
38
  const cacheData = pullFromCache<Amity.User>(['user', 'get', post.postedUserId]);
35
39
  if (!cacheData?.data) return;
36
40
  return userLinkedObject(cacheData.data);
37
41
  },
42
+
43
+ getImageInfo(): Amity.File<'image'> | undefined {
44
+ return isAmityImagePost(post)
45
+ ? pullFromCache<Amity.File<'image'>>(['file', 'get', post?.data?.fileId])?.data
46
+ : undefined;
47
+ },
48
+
49
+ getVideoInfo(): Amity.File<'video'> | undefined {
50
+ return isAmityVideoPost(post)
51
+ ? pullFromCache<Amity.File<'video'>>(['file', 'get', post?.data?.videoFileId?.original])
52
+ ?.data
53
+ : undefined;
54
+ },
55
+
56
+ getVideoThumbnailInfo(): Amity.File<'image'> | undefined {
57
+ return isAmityVideoPost(post)
58
+ ? pullFromCache<Amity.File<'image'>>(['file', 'get', post?.data?.thumbnailFileId])?.data
59
+ : undefined;
60
+ },
61
+
62
+ getFileInfo(): Amity.File<'file'> | undefined {
63
+ return isAmityFilePost(post)
64
+ ? pullFromCache<Amity.File<'file'>>(['file', 'get', post?.data?.fileId])?.data
65
+ : undefined;
66
+ },
38
67
  };
39
68
  };
@@ -0,0 +1,27 @@
1
+ export function isAmityImagePost(post: Amity.InternalPost): post is Amity.Post<'image'> {
2
+ return !!(
3
+ post.data &&
4
+ typeof post.data !== 'string' &&
5
+ 'fileId' in post.data &&
6
+ post.dataType === 'image'
7
+ );
8
+ }
9
+
10
+ export function isAmityFilePost(post: Amity.InternalPost): post is Amity.Post<'file'> {
11
+ return !!(
12
+ post.data &&
13
+ typeof post.data !== 'string' &&
14
+ 'fileId' in post.data &&
15
+ post.dataType === 'file'
16
+ );
17
+ }
18
+
19
+ export function isAmityVideoPost(post: Amity.InternalPost): post is Amity.Post<'video'> {
20
+ return !!(
21
+ post.data &&
22
+ typeof post.data !== 'string' &&
23
+ 'videoFileId' in post.data &&
24
+ 'thumbnailFileId' in post.data &&
25
+ post.dataType === 'video'
26
+ );
27
+ }