@amityco/ts-sdk 7.7.0 → 7.7.1-99f7166.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 +6 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +25 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +5 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/liveReaction.d.ts +20 -0
- package/dist/@types/domains/liveReaction.d.ts.map +1 -0
- 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 +9 -1
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.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/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/events/index.d.ts +1 -1
- package/dist/channelRepository/events/index.d.ts.map +1 -1
- package/dist/channelRepository/events/onChannelSetMuted.d.ts +2 -0
- package/dist/channelRepository/events/onChannelSetMuted.d.ts.map +1 -0
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts +2 -0
- package/dist/channelRepository/events/onChannelSetUserMuted.d.ts.map +1 -0
- package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
- package/dist/channelRepository/observers/getChannels/ChannelLiveCollectionController.d.ts.map +1 -1
- package/dist/client/api/login.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/subscription.d.ts +2 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/index.cjs.js +6380 -5797
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +6187 -5606
- package/dist/index.umd.js +3 -3
- package/dist/liveReactionRepository/api/createReaction.d.ts +20 -0
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -0
- package/dist/liveReactionRepository/api/index.d.ts +2 -0
- package/dist/liveReactionRepository/api/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/events/index.d.ts +2 -0
- package/dist/liveReactionRepository/events/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts +17 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreated.d.ts.map +1 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts +17 -0
- package/dist/liveReactionRepository/events/onLiveReactionCreatedLocal.d.ts.map +1 -0
- package/dist/liveReactionRepository/index.d.ts +4 -0
- package/dist/liveReactionRepository/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +20 -0
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +1 -0
- package/dist/liveReactionRepository/observers/getReactions.d.ts +19 -0
- package/dist/liveReactionRepository/observers/getReactions.d.ts.map +1 -0
- package/dist/liveReactionRepository/observers/index.d.ts +2 -0
- package/dist/liveReactionRepository/observers/index.d.ts.map +1 -0
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +26 -0
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -0
- package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts +3 -0
- package/dist/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.d.ts.map +1 -0
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +4 -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/getMessage.d.ts.map +1 -1
- package/dist/messageRepository/observers/getMessages/MessageLiveCollectionController.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/events/onStreamViewerBanned.d.ts +17 -0
- package/dist/streamRepository/events/onStreamViewerBanned.d.ts.map +1 -0
- package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts +17 -0
- package/dist/streamRepository/events/onStreamViewerUnbanned.d.ts.map +1 -0
- 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/streamRepository/observers/getStreamById.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.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 +2 -0
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +9 -1
- package/src/@types/core/payload.ts +32 -0
- package/src/@types/domains/channel.ts +6 -0
- package/src/@types/domains/liveReaction.ts +25 -0
- package/src/@types/domains/post.ts +3 -0
- package/src/@types/domains/stream.ts +12 -1
- package/src/@types/index.ts +1 -0
- package/src/channelRepository/api/createChannel.ts +12 -9
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +2 -0
- package/src/channelRepository/events/index.ts +1 -1
- package/src/channelRepository/events/onChannelSetMuted.ts +48 -0
- package/src/channelRepository/events/onChannelSetUserMuted.ts +67 -0
- package/src/channelRepository/internalApi/getChannel.ts +0 -1
- package/src/channelRepository/observers/getChannel.ts +2 -2
- package/src/channelRepository/observers/getChannels/ChannelLiveCollectionController.ts +2 -2
- package/src/channelRepository/utils/constructChannelObject.ts +2 -2
- package/src/client/api/login.ts +2 -0
- package/src/core/events.ts +1 -0
- package/src/core/subscription.ts +10 -6
- package/src/index.ts +2 -0
- package/src/liveReactionRepository/api/createReaction.ts +58 -0
- package/src/liveReactionRepository/api/index.ts +1 -0
- package/src/liveReactionRepository/events/index.ts +1 -0
- package/src/liveReactionRepository/events/onLiveReactionCreated.ts +37 -0
- package/src/liveReactionRepository/events/onLiveReactionCreatedLocal.ts +29 -0
- package/src/liveReactionRepository/index.ts +3 -0
- package/src/liveReactionRepository/internalApi/createLiveReaction.ts +42 -0
- package/src/liveReactionRepository/observers/getReactions.ts +59 -0
- package/src/liveReactionRepository/observers/index.ts +1 -0
- package/src/liveReactionRepository/service/ReactionSyncEngine.ts +138 -0
- package/src/liveReactionRepository/utils/ReactionSyncEngineOnLoginHandler.ts +19 -0
- package/src/messageRepository/api/deleteMessage.ts +16 -0
- package/src/messageRepository/observers/getMessage.ts +2 -0
- package/src/messageRepository/observers/getMessages/MessageLiveCollectionController.ts +2 -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/events/onStreamViewerBanned.ts +58 -0
- package/src/streamRepository/events/onStreamViewerUnbanned.ts +47 -0
- package/src/streamRepository/internalApi/getLiveChat.ts +59 -0
- package/src/streamRepository/internalApi/getStream.ts +3 -3
- package/src/streamRepository/observers/getStreamById.ts +2 -0
- package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +5 -1
- package/src/utils/linkedObject/postLinkedObject.ts +28 -2
- package/src/utils/linkedObject/streamLinkedObject.ts +4 -0
- package/src/utils/postTypePredicate.ts +18 -0
- package/dist/channelRepository/events/onChannelMuted.d.ts +0 -2
- package/dist/channelRepository/events/onChannelMuted.d.ts.map +0 -1
- package/src/channelRepository/events/onChannelMuted.ts +0 -39
|
@@ -3,16 +3,23 @@ import { commentLinkedObject } from '~/utils/linkedObject/commentLinkedObject';
|
|
|
3
3
|
import AnalyticsEngine from '../../analytic/service/analytic/AnalyticsEngine';
|
|
4
4
|
import { userLinkedObject } from './userLinkedObject';
|
|
5
5
|
import {
|
|
6
|
-
isAmityClipPost,
|
|
7
6
|
isAmityFilePost,
|
|
8
7
|
isAmityImagePost,
|
|
8
|
+
isAmityLivestreamPost,
|
|
9
|
+
isAmityPollPost,
|
|
9
10
|
isAmityVideoPost,
|
|
11
|
+
isAmityClipPost,
|
|
10
12
|
} from '../postTypePredicate';
|
|
13
|
+
import { streamLinkedObject } from './streamLinkedObject';
|
|
14
|
+
import { isNonNullable } from '..';
|
|
11
15
|
|
|
12
16
|
export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
|
|
13
17
|
return {
|
|
14
18
|
...post,
|
|
15
|
-
|
|
19
|
+
childrenPosts: post.children
|
|
20
|
+
.map(childPost => pullFromCache<Amity.InternalPost>(['post', 'get', childPost])?.data)
|
|
21
|
+
.filter(isNonNullable)
|
|
22
|
+
.map(postLinkedObject),
|
|
16
23
|
analytics: {
|
|
17
24
|
markAsViewed: () => {
|
|
18
25
|
const analyticsEngineInstance = AnalyticsEngine.getInstance();
|
|
@@ -69,7 +76,26 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
|
|
|
69
76
|
? pullFromCache<Amity.File<'file'>>(['file', 'get', post?.data?.fileId])?.data
|
|
70
77
|
: undefined;
|
|
71
78
|
},
|
|
79
|
+
|
|
80
|
+
getLivestreamInfo(): Amity.Stream | undefined {
|
|
81
|
+
if (!isAmityLivestreamPost(post)) return;
|
|
82
|
+
const cache = pullFromCache<Amity.InternalStream>([
|
|
83
|
+
'stream',
|
|
84
|
+
'get',
|
|
85
|
+
post?.data?.streamId,
|
|
86
|
+
])?.data;
|
|
87
|
+
if (!cache) return;
|
|
72
88
|
|
|
89
|
+
return streamLinkedObject(cache);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
getPollInfo(): Amity.Poll | undefined {
|
|
93
|
+
if (!isAmityPollPost(post)) return;
|
|
94
|
+
const cache = pullFromCache<Amity.Poll>(['poll', 'get', post?.data?.pollId])?.data;
|
|
95
|
+
if (!cache) return;
|
|
96
|
+
return cache;
|
|
97
|
+
},
|
|
98
|
+
|
|
73
99
|
getClipInfo(): Amity.File<'clip'> | undefined {
|
|
74
100
|
return isAmityClipPost(post)
|
|
75
101
|
? pullFromCache<Amity.File<'clip'>>(['file', 'get', post?.data?.fileId])?.data
|
|
@@ -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,8 @@ 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),
|
|
23
|
+
isBanned: !stream.watcherUrl,
|
|
24
|
+
watcherUrl: null,
|
|
21
25
|
};
|
|
22
26
|
};
|
|
@@ -26,6 +26,24 @@ export function isAmityVideoPost(post: Amity.InternalPost): post is Amity.Post<'
|
|
|
26
26
|
);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export function isAmityLivestreamPost(post: Amity.InternalPost): post is Amity.Post<'liveStream'> {
|
|
30
|
+
return !!(
|
|
31
|
+
post.data &&
|
|
32
|
+
typeof post.data !== 'string' &&
|
|
33
|
+
'streamId' in post.data &&
|
|
34
|
+
post.dataType === 'liveStream'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function isAmityPollPost(post: Amity.InternalPost): post is Amity.Post<'poll'> {
|
|
39
|
+
return !!(
|
|
40
|
+
post.data &&
|
|
41
|
+
typeof post.data !== 'string' &&
|
|
42
|
+
'pollId' in post.data &&
|
|
43
|
+
post.dataType === 'poll'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
29
47
|
export function isAmityClipPost(post: Amity.InternalPost): post is Amity.Post<'clip'> {
|
|
30
48
|
return !!(
|
|
31
49
|
post.data &&
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onChannelMuted.d.ts","sourceRoot":"","sources":["../../../src/channelRepository/events/onChannelMuted.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,cAAc,aAAc,MAAM,QAAQ,CAAC,MAAM,qBAAqB,CAAC,eAgBnF,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
import { createEventSubscriber } from '~/core/events';
|
|
3
|
-
|
|
4
|
-
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
|
-
|
|
6
|
-
import { prepareChannelPayload } from '../utils';
|
|
7
|
-
import { constructChannelDynamicValue } from '../utils/constructChannelDynamicValue';
|
|
8
|
-
|
|
9
|
-
type CallbackFn = Amity.Listener<Amity.StaticInternalChannel>;
|
|
10
|
-
const callbacks: CallbackFn[] = [];
|
|
11
|
-
let mainDisposer: (() => void) | null = null;
|
|
12
|
-
|
|
13
|
-
const dispose = (cb: CallbackFn) => {
|
|
14
|
-
const index = callbacks.indexOf(cb);
|
|
15
|
-
if (index > -1) {
|
|
16
|
-
callbacks.splice(index, 1);
|
|
17
|
-
}
|
|
18
|
-
if (callbacks.length === 0) {
|
|
19
|
-
mainDisposer?.();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const onChannelMuted = (callback: Amity.Listener<Amity.StaticInternalChannel>) => {
|
|
24
|
-
if (callbacks.length === 0) {
|
|
25
|
-
const client = getActiveClient();
|
|
26
|
-
|
|
27
|
-
const filter = async (payload: Amity.ChannelPayload) => {
|
|
28
|
-
const data = await prepareChannelPayload(payload);
|
|
29
|
-
|
|
30
|
-
ingestInCache(data);
|
|
31
|
-
callbacks.forEach(cb => cb(data.channels[0]));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
mainDisposer = createEventSubscriber(client, 'onChannelMuted', 'channel.setMuted', filter);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
callbacks.push(callback);
|
|
38
|
-
return () => dispose(callback);
|
|
39
|
-
};
|