@amityco/ts-sdk 7.6.1-b83cbdc.0 → 7.6.1-c97e594b.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/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/communityRepository/api/getCommunity.d.ts +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/index.cjs.js +5726 -5562
- package/dist/index.esm.js +5718 -5554
- 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 +4 -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/communityRepository/api/getCommunity.ts +9 -0
- 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
|
@@ -22,7 +22,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
22
22
|
*/
|
|
23
23
|
export const getStream = async (
|
|
24
24
|
streamId: Amity.Stream['streamId'],
|
|
25
|
-
): Promise<Amity.Cached<Amity.
|
|
25
|
+
): Promise<Amity.Cached<Amity.InternalStream>> => {
|
|
26
26
|
const client = getActiveClient();
|
|
27
27
|
client.log('stream/getStream', streamId);
|
|
28
28
|
|
|
@@ -57,13 +57,13 @@ export const getStream = async (
|
|
|
57
57
|
*/
|
|
58
58
|
getStream.locally = (
|
|
59
59
|
streamId: Amity.Stream['streamId'],
|
|
60
|
-
): Amity.Cached<Amity.
|
|
60
|
+
): Amity.Cached<Amity.InternalStream> | undefined => {
|
|
61
61
|
const client = getActiveClient();
|
|
62
62
|
client.log('stream/getStream', streamId);
|
|
63
63
|
|
|
64
64
|
if (!client.cache) return;
|
|
65
65
|
|
|
66
|
-
const cached = pullFromCache<Amity.
|
|
66
|
+
const cached = pullFromCache<Amity.InternalStream>(['stream', 'get', streamId]);
|
|
67
67
|
|
|
68
68
|
if (!cached) return;
|
|
69
69
|
|
|
@@ -102,7 +102,7 @@ export class GetStreamsLiveCollectionController extends LiveCollectionController
|
|
|
102
102
|
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
private applyFilter = (data: Amity.
|
|
105
|
+
private applyFilter = (data: Amity.Stream[]): Amity.Stream[] => {
|
|
106
106
|
let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
|
|
107
107
|
|
|
108
108
|
streams = streams.sort(
|
|
@@ -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
|
+
}
|