@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.
- package/.env +26 -26
- package/dist/@types/core/events.d.ts +4 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +45 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +1 -20
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +78 -0
- package/dist/@types/domains/notification.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +4 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/fileRepository/api/index.d.ts +1 -0
- package/dist/fileRepository/api/index.d.ts.map +1 -1
- package/dist/fileRepository/api/updateAltText.d.ts +17 -0
- package/dist/fileRepository/api/updateAltText.d.ts.map +1 -0
- package/dist/fileRepository/api/uploadImage.d.ts +2 -1
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
- package/dist/index.cjs.js +526 -50
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +509 -34
- package/dist/index.umd.js +4 -4
- package/dist/notificationTray/api/index.d.ts +3 -0
- package/dist/notificationTray/api/index.d.ts.map +1 -0
- package/dist/notificationTray/api/markItemsSeen.d.ts +16 -0
- package/dist/notificationTray/api/markItemsSeen.d.ts.map +1 -0
- package/dist/notificationTray/api/markTraySeen.d.ts +19 -0
- package/dist/notificationTray/api/markTraySeen.d.ts.map +1 -0
- package/dist/notificationTray/events/index.d.ts +2 -0
- package/dist/notificationTray/events/index.d.ts.map +1 -0
- package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts +17 -0
- package/dist/notificationTray/events/onNotificationTraySeenUpdated.d.ts.map +1 -0
- package/dist/notificationTray/index.d.ts +4 -0
- package/dist/notificationTray/index.d.ts.map +1 -0
- package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts +30 -0
- package/dist/notificationTray/internalApi/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts +13 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts +9 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts +9 -0
- package/dist/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTrayItems.d.ts +12 -0
- package/dist/notificationTray/observers/getNotificationTrayItems.d.ts.map +1 -0
- package/dist/notificationTray/observers/getNotificationTraySeen.d.ts +20 -0
- package/dist/notificationTray/observers/getNotificationTraySeen.d.ts.map +1 -0
- package/dist/notificationTray/observers/index.d.ts +3 -0
- package/dist/notificationTray/observers/index.d.ts.map +1 -0
- package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts +2 -0
- package/dist/notificationTray/utils/prepareNotificationTrayItemsPayload.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/notificationTrayLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +4 -0
- package/dist/utils/postTypePredicate.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/core/events.ts +5 -0
- package/src/@types/core/model.ts +6 -0
- package/src/@types/core/payload.ts +52 -1
- package/src/@types/domains/file.ts +1 -21
- package/src/@types/domains/notification.ts +94 -0
- package/src/@types/domains/post.ts +4 -0
- package/src/@types/index.ts +1 -0
- package/src/core/model/idResolvers.ts +3 -0
- package/src/core/model/index.ts +2 -0
- package/src/fileRepository/api/index.ts +1 -0
- package/src/fileRepository/api/updateAltText.ts +39 -0
- package/src/fileRepository/api/uploadImage.ts +22 -3
- package/src/index.ts +2 -0
- package/src/notificationTray/api/index.ts +2 -0
- package/src/notificationTray/api/markItemsSeen.ts +62 -0
- package/src/notificationTray/api/markTraySeen.ts +65 -0
- package/src/notificationTray/events/index.ts +1 -0
- package/src/notificationTray/events/onNotificationTraySeenUpdated.ts +36 -0
- package/src/notificationTray/index.ts +3 -0
- package/src/notificationTray/internalApi/getNotificationTraySeen.ts +80 -0
- package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsLiveCollectionController.ts +96 -0
- package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsPaginationController.ts +31 -0
- package/src/notificationTray/observers/getNotificationTrayItems/NotificationTrayItemsQuerystreamController.ts +68 -0
- package/src/notificationTray/observers/getNotificationTrayItems.ts +44 -0
- package/src/notificationTray/observers/getNotificationTraySeen.ts +60 -0
- package/src/notificationTray/observers/index.ts +2 -0
- package/src/notificationTray/utils/prepareNotificationTrayItemsPayload.ts +12 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/notificationTrayLinkedObject.ts +19 -0
- package/src/utils/linkedObject/postLinkedObject.ts +29 -0
- 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
|
+
}
|