@amityco/ts-sdk 7.6.0 → 7.6.1-65b44ce1.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/domains/channel.d.ts +2 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +4 -0
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/channelRepository/api/createChannel.d.ts +3 -1
- package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
- package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
- package/dist/index.cjs.js +5838 -5679
- package/dist/index.esm.js +5714 -5555
- package/dist/index.umd.js +2 -2
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +2 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
- package/dist/messageRepository/api/deleteMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/utils/payload.d.ts.map +1 -1
- package/dist/streamRepository/api/createStream.d.ts +1 -1
- package/dist/streamRepository/api/createStream.d.ts.map +1 -1
- package/dist/streamRepository/api/editStream.d.ts +18 -0
- package/dist/streamRepository/api/editStream.d.ts.map +1 -0
- package/dist/streamRepository/api/index.d.ts +1 -0
- package/dist/streamRepository/api/index.d.ts.map +1 -1
- package/dist/streamRepository/api/updateStream.d.ts +4 -1
- package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
- package/dist/streamRepository/internalApi/getLiveChat.d.ts +16 -0
- package/dist/streamRepository/internalApi/getLiveChat.d.ts.map +1 -0
- package/dist/streamRepository/internalApi/getStream.d.ts +2 -2
- package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +5 -3
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +3 -0
- package/src/@types/domains/post.ts +3 -0
- package/src/@types/domains/stream.ts +4 -0
- package/src/channelRepository/api/createChannel.ts +12 -9
- package/src/channelRepository/internalApi/getChannel.ts +0 -1
- package/src/channelRepository/utils/constructChannelObject.ts +2 -2
- package/src/messageRepository/api/deleteMessage.ts +16 -0
- package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +13 -0
- package/src/postRepository/api/createPost.ts +3 -2
- package/src/postRepository/utils/payload.ts +37 -1
- package/src/streamRepository/api/createStream.ts +4 -1
- package/src/streamRepository/api/editStream.ts +51 -0
- package/src/streamRepository/api/index.ts +1 -0
- package/src/streamRepository/api/updateStream.ts +8 -1
- package/src/streamRepository/internalApi/getLiveChat.ts +59 -0
- package/src/streamRepository/internalApi/getStream.ts +3 -3
- package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +1 -1
- package/src/utils/linkedObject/postLinkedObject.ts +32 -2
- package/src/utils/linkedObject/streamLinkedObject.ts +2 -0
- package/src/utils/postTypePredicate.ts +26 -3
|
@@ -2,12 +2,23 @@ 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 {
|
|
5
|
+
import {
|
|
6
|
+
isAmityFilePost,
|
|
7
|
+
isAmityImagePost,
|
|
8
|
+
isAmityLivestreamPost,
|
|
9
|
+
isAmityPollPost,
|
|
10
|
+
isAmityVideoPost,
|
|
11
|
+
} from '../postTypePredicate';
|
|
12
|
+
import { streamLinkedObject } from './streamLinkedObject';
|
|
13
|
+
import { isNonNullable } from '..';
|
|
6
14
|
|
|
7
15
|
export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
|
|
8
16
|
return {
|
|
9
17
|
...post,
|
|
10
|
-
|
|
18
|
+
childrenPosts: post.children
|
|
19
|
+
.map(childPost => pullFromCache<Amity.InternalPost>(['post', 'get', childPost])?.data)
|
|
20
|
+
.filter(isNonNullable)
|
|
21
|
+
.map(postLinkedObject),
|
|
11
22
|
analytics: {
|
|
12
23
|
markAsViewed: () => {
|
|
13
24
|
const analyticsEngineInstance = AnalyticsEngine.getInstance();
|
|
@@ -64,5 +75,24 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
|
|
|
64
75
|
? pullFromCache<Amity.File<'file'>>(['file', 'get', post?.data?.fileId])?.data
|
|
65
76
|
: undefined;
|
|
66
77
|
},
|
|
78
|
+
|
|
79
|
+
getLivestreamInfo(): Amity.Stream | undefined {
|
|
80
|
+
if (!isAmityLivestreamPost(post)) return;
|
|
81
|
+
const cache = pullFromCache<Amity.InternalStream>([
|
|
82
|
+
'stream',
|
|
83
|
+
'get',
|
|
84
|
+
post?.data?.streamId,
|
|
85
|
+
])?.data;
|
|
86
|
+
if (!cache) return;
|
|
87
|
+
|
|
88
|
+
return streamLinkedObject(cache);
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
getPollInfo(): Amity.Poll | undefined {
|
|
92
|
+
if (!isAmityPollPost(post)) return;
|
|
93
|
+
const cache = pullFromCache<Amity.Poll>(['poll', 'get', post?.data?.pollId])?.data;
|
|
94
|
+
if (!cache) return;
|
|
95
|
+
return cache;
|
|
96
|
+
},
|
|
67
97
|
};
|
|
68
98
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pullFromCache } from '~/cache/api';
|
|
2
|
+
import { getLiveChat as _getLiveChat } from '~/streamRepository/internalApi/getLiveChat';
|
|
2
3
|
|
|
3
4
|
export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream => {
|
|
4
5
|
return {
|
|
@@ -18,5 +19,6 @@ export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream =
|
|
|
18
19
|
get user() {
|
|
19
20
|
return pullFromCache<Amity.User>(['user', 'get', stream.userId])?.data;
|
|
20
21
|
},
|
|
22
|
+
getLiveChat: () => _getLiveChat(stream),
|
|
21
23
|
};
|
|
22
24
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export function isAmityImagePost(post
|
|
1
|
+
export function isAmityImagePost(post?: Amity.InternalPost): post is Amity.Post<'image'> {
|
|
2
2
|
return !!(
|
|
3
|
+
post &&
|
|
3
4
|
post.data &&
|
|
4
5
|
typeof post.data !== 'string' &&
|
|
5
6
|
'fileId' in post.data &&
|
|
@@ -7,8 +8,9 @@ export function isAmityImagePost(post: Amity.InternalPost): post is Amity.Post<'
|
|
|
7
8
|
);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export function isAmityFilePost(post
|
|
11
|
+
export function isAmityFilePost(post?: Amity.InternalPost): post is Amity.Post<'file'> {
|
|
11
12
|
return !!(
|
|
13
|
+
post &&
|
|
12
14
|
post.data &&
|
|
13
15
|
typeof post.data !== 'string' &&
|
|
14
16
|
'fileId' in post.data &&
|
|
@@ -16,8 +18,9 @@ export function isAmityFilePost(post: Amity.InternalPost): post is Amity.Post<'f
|
|
|
16
18
|
);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export function isAmityVideoPost(post
|
|
21
|
+
export function isAmityVideoPost(post?: Amity.InternalPost): post is Amity.Post<'video'> {
|
|
20
22
|
return !!(
|
|
23
|
+
post &&
|
|
21
24
|
post.data &&
|
|
22
25
|
typeof post.data !== 'string' &&
|
|
23
26
|
'videoFileId' in post.data &&
|
|
@@ -25,3 +28,23 @@ export function isAmityVideoPost(post: Amity.InternalPost): post is Amity.Post<'
|
|
|
25
28
|
post.dataType === 'video'
|
|
26
29
|
);
|
|
27
30
|
}
|
|
31
|
+
|
|
32
|
+
export function isAmityLivestreamPost(post?: Amity.InternalPost): post is Amity.Post<'liveStream'> {
|
|
33
|
+
return !!(
|
|
34
|
+
post &&
|
|
35
|
+
post.data &&
|
|
36
|
+
typeof post.data !== 'string' &&
|
|
37
|
+
'streamId' in post.data &&
|
|
38
|
+
post.dataType === 'liveStream'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isAmityPollPost(post?: Amity.InternalPost): post is Amity.Post<'poll'> {
|
|
43
|
+
return !!(
|
|
44
|
+
post &&
|
|
45
|
+
post.data &&
|
|
46
|
+
typeof post.data !== 'string' &&
|
|
47
|
+
'pollId' in post.data &&
|
|
48
|
+
post.dataType === 'poll'
|
|
49
|
+
);
|
|
50
|
+
}
|