@amityco/ts-sdk 7.6.1-65b44ce1.0 → 7.6.1-a0961ea.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 (91) hide show
  1. package/dist/@types/core/payload.d.ts +1 -1
  2. package/dist/@types/core/payload.d.ts.map +1 -1
  3. package/dist/@types/domains/channel.d.ts +0 -2
  4. package/dist/@types/domains/channel.d.ts.map +1 -1
  5. package/dist/@types/domains/content.d.ts +8 -2
  6. package/dist/@types/domains/content.d.ts.map +1 -1
  7. package/dist/@types/domains/feed.d.ts +2 -1
  8. package/dist/@types/domains/feed.d.ts.map +1 -1
  9. package/dist/@types/domains/file.d.ts +3 -1
  10. package/dist/@types/domains/file.d.ts.map +1 -1
  11. package/dist/@types/domains/post.d.ts +3 -3
  12. package/dist/@types/domains/post.d.ts.map +1 -1
  13. package/dist/@types/domains/stream.d.ts +0 -4
  14. package/dist/@types/domains/stream.d.ts.map +1 -1
  15. package/dist/channelRepository/api/createChannel.d.ts +1 -3
  16. package/dist/channelRepository/api/createChannel.d.ts.map +1 -1
  17. package/dist/channelRepository/internalApi/getChannel.d.ts.map +1 -1
  18. package/dist/communityRepository/api/getCommunity.d.ts +1 -1
  19. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  20. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
  21. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
  22. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  23. package/dist/fileRepository/api/index.d.ts +1 -0
  24. package/dist/fileRepository/api/index.d.ts.map +1 -1
  25. package/dist/fileRepository/api/uploadClip.d.ts +17 -0
  26. package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
  27. package/dist/index.cjs.js +5775 -5832
  28. package/dist/index.esm.js +5685 -5742
  29. package/dist/index.umd.js +3 -3
  30. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +0 -2
  31. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts.map +1 -1
  32. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  33. package/dist/messageRepository/api/deleteMessage.d.ts.map +1 -1
  34. package/dist/messageRepository/observers/getMessages/MessageQueryStreamController.d.ts.map +1 -1
  35. package/dist/postRepository/api/createClipPost.d.ts +32 -0
  36. package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
  37. package/dist/postRepository/api/createPost.d.ts.map +1 -1
  38. package/dist/postRepository/api/index.d.ts +1 -0
  39. package/dist/postRepository/api/index.d.ts.map +1 -1
  40. package/dist/postRepository/utils/payload.d.ts.map +1 -1
  41. package/dist/streamRepository/api/createStream.d.ts +1 -1
  42. package/dist/streamRepository/api/createStream.d.ts.map +1 -1
  43. package/dist/streamRepository/api/index.d.ts +0 -1
  44. package/dist/streamRepository/api/index.d.ts.map +1 -1
  45. package/dist/streamRepository/api/updateStream.d.ts +1 -4
  46. package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
  47. package/dist/streamRepository/internalApi/getStream.d.ts +2 -2
  48. package/dist/streamRepository/internalApi/getStream.d.ts.map +1 -1
  49. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  50. package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -1
  51. package/dist/utils/postTypePredicate.d.ts +4 -5
  52. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  53. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  54. package/package.json +1 -1
  55. package/src/@types/core/payload.ts +1 -1
  56. package/src/@types/domains/channel.ts +0 -3
  57. package/src/@types/domains/content.ts +10 -0
  58. package/src/@types/domains/feed.ts +2 -1
  59. package/src/@types/domains/file.ts +5 -0
  60. package/src/@types/domains/post.ts +4 -3
  61. package/src/@types/domains/stream.ts +0 -4
  62. package/src/channelRepository/api/createChannel.ts +9 -12
  63. package/src/channelRepository/internalApi/getChannel.ts +1 -0
  64. package/src/channelRepository/utils/constructChannelObject.ts +2 -2
  65. package/src/communityRepository/api/getCommunity.ts +0 -9
  66. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
  67. package/src/feedRepository/api/queryGlobalFeed.ts +3 -1
  68. package/src/fileRepository/api/index.ts +1 -0
  69. package/src/fileRepository/api/uploadClip.ts +71 -0
  70. package/src/messageRepository/api/deleteMessage.ts +0 -16
  71. package/src/messageRepository/observers/getMessages/MessageQueryStreamController.ts +0 -13
  72. package/src/postRepository/api/createClipPost.ts +62 -0
  73. package/src/postRepository/api/createPost.ts +2 -3
  74. package/src/postRepository/api/index.ts +2 -0
  75. package/src/postRepository/api/queryPosts.ts +1 -1
  76. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  77. package/src/postRepository/utils/payload.ts +1 -37
  78. package/src/streamRepository/api/createStream.ts +1 -4
  79. package/src/streamRepository/api/index.ts +0 -1
  80. package/src/streamRepository/api/updateStream.ts +1 -8
  81. package/src/streamRepository/internalApi/getStream.ts +3 -3
  82. package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +1 -1
  83. package/src/utils/linkedObject/postLinkedObject.ts +6 -25
  84. package/src/utils/linkedObject/streamLinkedObject.ts +0 -2
  85. package/src/utils/postTypePredicate.ts +6 -20
  86. package/dist/streamRepository/api/editStream.d.ts +0 -18
  87. package/dist/streamRepository/api/editStream.d.ts.map +0 -1
  88. package/dist/streamRepository/internalApi/getLiveChat.d.ts +0 -16
  89. package/dist/streamRepository/internalApi/getLiveChat.d.ts.map +0 -1
  90. package/src/streamRepository/api/editStream.ts +0 -51
  91. package/src/streamRepository/internalApi/getLiveChat.ts +0 -59
@@ -0,0 +1,62 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+
3
+ import { ingestInCache } from '~/cache/api/ingestInCache';
4
+ import { fireEvent } from '~/core/events';
5
+ import { prepareMembershipPayload } from '~/group/utils';
6
+ import { LinkedObject } from '~/utils/linkedObject';
7
+
8
+ /* begin_public_function
9
+ id: post.create.clip_post
10
+ */
11
+ /**
12
+ * ```js
13
+ * import { PostRepository } from '@amityco/ts-sdk'
14
+ * const created = await PostRepository.createClipPost({
15
+ * targetType: 'user',
16
+ * targetId: 'foobar',
17
+ * dataType: 'clip',
18
+ * data: { text: 'hello world' },
19
+ * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
20
+ * }))
21
+ * ```
22
+ *
23
+ * Creates an {@link Amity.Post}
24
+ *
25
+ * @param bundle The data necessary to create a new {@link Amity.Post}
26
+ * @returns The newly created {@link Amity.Post}
27
+ *
28
+ * @category Post API
29
+ * @async
30
+ */
31
+ export const createClipPost = async <T extends Amity.PostContentType | string>(
32
+ bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &
33
+ Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags'>> & {
34
+ data: { [k: string]: any };
35
+ attachments: {
36
+ type: T;
37
+ fileId: Amity.File['fileId'];
38
+ displayMode?: Amity.ClipDisplayMode;
39
+ isMuted?: boolean;
40
+ }[];
41
+ },
42
+ ): Promise<Amity.Cached<Amity.Post>> => {
43
+ const client = getActiveClient();
44
+ client.log('post/createPost', bundle);
45
+
46
+ const { data: payload } = await client.http.post<Amity.PostPayload>('/api/v4/posts', bundle);
47
+
48
+ fireEvent('post.created', payload);
49
+
50
+ const data = prepareMembershipPayload(payload, 'communityUsers');
51
+ const cachedAt = client.cache && Date.now();
52
+
53
+ if (client.cache) ingestInCache(data, { cachedAt });
54
+
55
+ const { posts } = data;
56
+
57
+ return {
58
+ data: LinkedObject.post(posts[0]),
59
+ cachedAt,
60
+ };
61
+ };
62
+ /* end_public_function */
@@ -2,8 +2,8 @@ import { getActiveClient } from '~/client/api';
2
2
 
3
3
  import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
  import { fireEvent } from '~/core/events';
5
+ import { prepareMembershipPayload } from '~/group/utils';
5
6
  import { LinkedObject } from '~/utils/linkedObject';
6
- import { preparePostPayload } from '../utils/payload';
7
7
 
8
8
  /* begin_public_function
9
9
  id: post.create.text_post, post.create.image_post, post.create.file_post, post.create.video_post, post.create.poll_post, post.create.livestream_post, post.create.custom_post
@@ -46,8 +46,7 @@ export const createPost = async <T extends Amity.PostContentType | string>(
46
46
 
47
47
  fireEvent('post.created', payload);
48
48
 
49
- const data = preparePostPayload(payload);
50
-
49
+ const data = prepareMembershipPayload(payload, 'communityUsers');
51
50
  const cachedAt = client.cache && Date.now();
52
51
 
53
52
  if (client.cache) ingestInCache(data, { cachedAt });
@@ -13,3 +13,5 @@ export * from './declinePost';
13
13
  export * from './flagPost';
14
14
  export * from './unflagPost';
15
15
  export * from './isPostFlaggedByMe';
16
+
17
+ export * from './createClipPost';
@@ -43,7 +43,7 @@ export const queryPosts = async (
43
43
  // API-FIX: parameters should be querystring. (1)
44
44
  // API-FIX: backend should answer Amity.Response (2)
45
45
  // const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
46
- const { data } = await client.http.get<Amity.PostPayload & Amity.Pagination>(`/api/v4/posts`, {
46
+ const { data } = await client.http.get<Amity.PostPayload & Amity.Pagination>(`/api/v5/posts`, {
47
47
  params: {
48
48
  ...params,
49
49
  isDeleted: inferIsDeleted(includeDeleted),
@@ -23,7 +23,7 @@ export class PostPaginationController extends PaginationController<
23
23
  const options = token ? { ...baseOptions, token } : { ...baseOptions, limit };
24
24
 
25
25
  const { data: queryResponse } = await this.http.get<Amity.PostPayload & Amity.Pagination>(
26
- `/api/v4/posts`,
26
+ `/api/v5/posts`,
27
27
  {
28
28
  params: {
29
29
  ...params,
@@ -1,28 +1,8 @@
1
1
  import { addPostSetting } from '~/communityRepository/utils';
2
2
  import { updateMembershipStatus } from '~/communityRepository/utils/communityWithMembership';
3
- import { isAmityLivestreamPost } from '~/utils/postTypePredicate';
4
-
5
- const updateStreamReferences = (
6
- streams: Amity.RawStream[],
7
- streamId: string | undefined,
8
- postId: string,
9
- ) => {
10
- if (!streamId) return streams;
11
-
12
- return streams.map(stream =>
13
- stream.streamId === streamId
14
- ? {
15
- ...stream,
16
- referenceType: 'post',
17
- referenceId: postId,
18
- postId,
19
- }
20
- : stream,
21
- );
22
- };
23
3
 
24
4
  export const preparePostPayload = (payload: Amity.PostPayload): Amity.ProcessedPostPayload => {
25
- const { posts: postsData, postChildren, videoStreamings, ...postPayload } = payload;
5
+ const { posts: postsData, ...postPayload } = payload;
26
6
 
27
7
  // Unpack community payload by mapping payload field to postSetting value.
28
8
  const communitiesWithPostSetting = addPostSetting({ communities: postPayload.communities });
@@ -44,34 +24,18 @@ export const preparePostPayload = (payload: Amity.PostPayload): Amity.ProcessedP
44
24
  mappedCommunityUsers,
45
25
  );
46
26
 
47
- let mappedNewStream: Amity.RawStream[] = [];
48
-
49
27
  // feed type
50
28
  const posts = postsData.map(post => {
51
29
  const feedType = postPayload.feeds.find(feed => feed.feedId === post.feedId)?.feedType;
52
- const childPosts = payload.postChildren.filter(
53
- children => children.parentPostId === post.postId,
54
- );
55
-
56
- if (childPosts.length > 0 && isAmityLivestreamPost(childPosts[0])) {
57
- mappedNewStream = updateStreamReferences(
58
- videoStreamings,
59
- childPosts[0].data?.streamId,
60
- post.postId,
61
- );
62
- }
63
30
 
64
31
  return {
65
32
  ...post,
66
- childPosts,
67
33
  feedType,
68
34
  };
69
35
  });
70
36
 
71
37
  return {
72
38
  ...postPayload,
73
- postChildren,
74
- videoStreamings: mappedNewStream,
75
39
  posts,
76
40
  communities: communityWithMembershipStatus,
77
41
  communityUsers: mappedCommunityUsers,
@@ -21,10 +21,7 @@ import { LinkedObject } from '~/utils/linkedObject';
21
21
  * @async
22
22
  */
23
23
  export const createStream = async (
24
- bundle: Pick<
25
- Amity.InternalStream,
26
- 'title' | 'thumbnailFileId' | 'description' | 'channelEnabled'
27
- > & {
24
+ bundle: Pick<Amity.InternalStream, 'title' | 'thumbnailFileId' | 'description'> & {
28
25
  isSecure?: boolean;
29
26
  },
30
27
  ): Promise<Amity.Cached<Amity.Stream>> => {
@@ -2,4 +2,3 @@ export * from './createStream';
2
2
  export * from './updateStream';
3
3
  export * from './deleteStream';
4
4
  export * from './disposeStream';
5
- export * from './editStream';
@@ -7,9 +7,6 @@ import { LinkedObject } from '~/utils/linkedObject';
7
7
  id: stream.update
8
8
  */
9
9
  /**
10
- * @deprecated this function is deprecated,
11
- * please use {@link Amity.StreamRepository.editStream} instead.
12
- *
13
10
  * ```js
14
11
  * import { updateStream } from '@amityco/ts-sdk'
15
12
  * const updated = await updateStream(streamId, { title: 'foobar' })
@@ -24,13 +21,9 @@ import { LinkedObject } from '~/utils/linkedObject';
24
21
  * @category Stream API
25
22
  * @async
26
23
  */
27
-
28
24
  export const updateStream = async (
29
25
  streamId: Amity.Stream['streamId'],
30
- patch: Patch<
31
- Amity.Stream,
32
- 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'
33
- >,
26
+ patch: Patch<Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata'>,
34
27
  ): Promise<Amity.Cached<Amity.Stream>> => {
35
28
  const client = getActiveClient();
36
29
  client.log('stream/updateStream', streamId, patch);
@@ -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.InternalStream>> => {
25
+ ): Promise<Amity.Cached<Amity.Stream>> => {
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.InternalStream> | undefined => {
60
+ ): Amity.Cached<Amity.Stream> | 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.InternalStream>(['stream', 'get', streamId]);
66
+ const cached = pullFromCache<Amity.Stream>(['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.Stream[]): Amity.Stream[] => {
105
+ private applyFilter = (data: Amity.InternalStream[]): Amity.InternalStream[] => {
106
106
  let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
107
107
 
108
108
  streams = streams.sort(
@@ -3,22 +3,16 @@ 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,
6
7
  isAmityFilePost,
7
8
  isAmityImagePost,
8
- isAmityLivestreamPost,
9
- isAmityPollPost,
10
9
  isAmityVideoPost,
11
10
  } from '../postTypePredicate';
12
- import { streamLinkedObject } from './streamLinkedObject';
13
- import { isNonNullable } from '..';
14
11
 
15
12
  export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
16
13
  return {
17
14
  ...post,
18
- childrenPosts: post.children
19
- .map(childPost => pullFromCache<Amity.InternalPost>(['post', 'get', childPost])?.data)
20
- .filter(isNonNullable)
21
- .map(postLinkedObject),
15
+
22
16
  analytics: {
23
17
  markAsViewed: () => {
24
18
  const analyticsEngineInstance = AnalyticsEngine.getInstance();
@@ -76,23 +70,10 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
76
70
  : undefined;
77
71
  },
78
72
 
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;
73
+ getClipInfo(): Amity.File<'clip'> | undefined {
74
+ return isAmityClipPost(post)
75
+ ? pullFromCache<Amity.File<'clip'>>(['file', 'get', post?.data?.fileId])?.data
76
+ : undefined;
96
77
  },
97
78
  };
98
79
  };
@@ -1,5 +1,4 @@
1
1
  import { pullFromCache } from '~/cache/api';
2
- import { getLiveChat as _getLiveChat } from '~/streamRepository/internalApi/getLiveChat';
3
2
 
4
3
  export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream => {
5
4
  return {
@@ -19,6 +18,5 @@ export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream =
19
18
  get user() {
20
19
  return pullFromCache<Amity.User>(['user', 'get', stream.userId])?.data;
21
20
  },
22
- getLiveChat: () => _getLiveChat(stream),
23
21
  };
24
22
  };
@@ -1,6 +1,5 @@
1
- export function isAmityImagePost(post?: Amity.InternalPost): post is Amity.Post<'image'> {
1
+ export function isAmityImagePost(post: Amity.InternalPost): post is Amity.Post<'image'> {
2
2
  return !!(
3
- post &&
4
3
  post.data &&
5
4
  typeof post.data !== 'string' &&
6
5
  'fileId' in post.data &&
@@ -8,9 +7,8 @@ export function isAmityImagePost(post?: Amity.InternalPost): post is Amity.Post<
8
7
  );
9
8
  }
10
9
 
11
- export function isAmityFilePost(post?: Amity.InternalPost): post is Amity.Post<'file'> {
10
+ export function isAmityFilePost(post: Amity.InternalPost): post is Amity.Post<'file'> {
12
11
  return !!(
13
- post &&
14
12
  post.data &&
15
13
  typeof post.data !== 'string' &&
16
14
  'fileId' in post.data &&
@@ -18,9 +16,8 @@ export function isAmityFilePost(post?: Amity.InternalPost): post is Amity.Post<'
18
16
  );
19
17
  }
20
18
 
21
- export function isAmityVideoPost(post?: Amity.InternalPost): post is Amity.Post<'video'> {
19
+ export function isAmityVideoPost(post: Amity.InternalPost): post is Amity.Post<'video'> {
22
20
  return !!(
23
- post &&
24
21
  post.data &&
25
22
  typeof post.data !== 'string' &&
26
23
  'videoFileId' in post.data &&
@@ -29,22 +26,11 @@ export function isAmityVideoPost(post?: Amity.InternalPost): post is Amity.Post<
29
26
  );
30
27
  }
31
28
 
32
- export function isAmityLivestreamPost(post?: Amity.InternalPost): post is Amity.Post<'liveStream'> {
29
+ export function isAmityClipPost(post: Amity.InternalPost): post is Amity.Post<'clip'> {
33
30
  return !!(
34
- post &&
35
31
  post.data &&
36
32
  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'
33
+ 'fileId' in post.data &&
34
+ post.dataType === 'clip'
49
35
  );
50
36
  }
@@ -1,18 +0,0 @@
1
- /**
2
- *
3
- * ```js
4
- * import { StreamRepository } from '@amityco/ts-sdk'
5
- * const updated = await StreamRepository.editStream(streamId, { title: 'foobar' })
6
- * ```
7
- *
8
- * Updates an {@link Amity.Stream}
9
- *
10
- * @param streamId The ID of the {@link Amity.Stream} to edit
11
- * @param patch The patch data to apply
12
- * @returns the updated {@link Amity.Stream} object
13
- *
14
- * @category Stream API
15
- * @async
16
- */
17
- export declare const editStream: (streamId: Amity.Stream['streamId'], patch: Patch<Amity.Stream, 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'>) => Promise<Amity.Cached<Amity.Stream>>;
18
- //# sourceMappingURL=editStream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"editStream.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/api/editStream.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,UAAU,aACX,MAAM,MAAM,CAAC,UAAU,CAAC,SAC3B,MACL,MAAM,MAAM,EACZ,OAAO,GAAG,iBAAiB,GAAG,aAAa,GAAG,UAAU,GAAG,gBAAgB,CAC5E,KACA,QAAQ,MAAM,MAAM,CAAC,MAAM,MAAM,CAAC,CAkBpC,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * ```js
3
- * import { getStream } from '@amityco/ts-sdk'
4
- * const stream = await getStream('foobar')
5
- * ```
6
- *
7
- * Fetches a {@link Amity.Channel} object linked with a current stream
8
- *
9
- * @param stream {@link Amity.Stream} that has linked live channel
10
- * @returns the associated {@link Amity.Channel<'live'>} object
11
- *
12
- * @category Stream API
13
- * @async
14
- */
15
- export declare const getLiveChat: (stream: Amity.InternalStream) => Promise<Amity.Channel<'live'> | undefined>;
16
- //# sourceMappingURL=getLiveChat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getLiveChat.d.ts","sourceRoot":"","sources":["../../../src/streamRepository/internalApi/getLiveChat.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,WAAW,WACd,MAAM,cAAc,KAC3B,QAAQ,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,CAkC3C,CAAC"}
@@ -1,51 +0,0 @@
1
- import { getActiveClient } from '~/client/api';
2
-
3
- import { ingestInCache } from '~/cache/api/ingestInCache';
4
- import { LinkedObject } from '~/utils/linkedObject';
5
-
6
- /* begin_public_function
7
- id: stream.update
8
- */
9
- /**
10
- *
11
- * ```js
12
- * import { StreamRepository } from '@amityco/ts-sdk'
13
- * const updated = await StreamRepository.editStream(streamId, { title: 'foobar' })
14
- * ```
15
- *
16
- * Updates an {@link Amity.Stream}
17
- *
18
- * @param streamId The ID of the {@link Amity.Stream} to edit
19
- * @param patch The patch data to apply
20
- * @returns the updated {@link Amity.Stream} object
21
- *
22
- * @category Stream API
23
- * @async
24
- */
25
-
26
- export const editStream = async (
27
- streamId: Amity.Stream['streamId'],
28
- patch: Patch<
29
- Amity.Stream,
30
- 'title' | 'thumbnailFileId' | 'description' | 'metadata' | 'channelEnabled'
31
- >,
32
- ): Promise<Amity.Cached<Amity.Stream>> => {
33
- const client = getActiveClient();
34
- client.log('stream/updateStream', streamId, patch);
35
-
36
- const { data } = await client.http.put<Amity.StreamPayload>(
37
- `/api/v3/video-streaming/${streamId}`,
38
- patch,
39
- );
40
-
41
- const cachedAt = client.cache && Date.now();
42
- if (client.cache) ingestInCache(data, { cachedAt });
43
-
44
- const { videoStreamings } = data;
45
-
46
- return {
47
- data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)!),
48
- cachedAt,
49
- };
50
- };
51
- /* end_public_function */
@@ -1,59 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
- import { mergeInCache, pullFromCache } from '~/cache/api';
3
- import { createChannel } from '~/channelRepository/api/createChannel';
4
- import { channelLinkedObject } from '~/utils/linkedObject/channelLinkedObject';
5
- import { getChannel } from '~/channelRepository/internalApi/getChannel';
6
- import { constructChannelObject } from '~/channelRepository/utils/constructChannelObject';
7
-
8
- /**
9
- * ```js
10
- * import { getStream } from '@amityco/ts-sdk'
11
- * const stream = await getStream('foobar')
12
- * ```
13
- *
14
- * Fetches a {@link Amity.Channel} object linked with a current stream
15
- *
16
- * @param stream {@link Amity.Stream} that has linked live channel
17
- * @returns the associated {@link Amity.Channel<'live'>} object
18
- *
19
- * @category Stream API
20
- * @async
21
- */
22
-
23
- export const getLiveChat = async (
24
- stream: Amity.InternalStream,
25
- ): Promise<Amity.Channel<'live'> | undefined> => {
26
- const client = getActiveClient();
27
- client.log('stream/getLiveChat', stream.streamId);
28
-
29
- if (stream.channelId) {
30
- const channel = pullFromCache<Amity.StaticInternalChannel>([
31
- 'channel',
32
- 'get',
33
- stream.channelId,
34
- ])?.data;
35
-
36
- if (channel) return channelLinkedObject(constructChannelObject(channel));
37
-
38
- const { data } = await getChannel(stream.channelId);
39
- return channelLinkedObject(constructChannelObject(data));
40
- }
41
- // No Channel ID
42
- // streamer: create a new live channel
43
- if (stream.userId === client.userId) {
44
- const { data: channel } = await createChannel({
45
- type: 'live',
46
- postId: stream.postId,
47
- videoStreamId: stream.streamId,
48
- });
49
-
50
- // Update channelId to stream object in cache
51
- mergeInCache(['stream', 'get', stream.streamId], {
52
- channelId: channel.channelId,
53
- });
54
-
55
- return channel;
56
- }
57
- // watcher: return undefined
58
- return undefined;
59
- };