@amityco/ts-sdk 7.5.4-ec2fdd4.0 → 7.6.1-1a687cb5.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/core/payload.d.ts +1 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +8 -2
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +2 -1
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +3 -1
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -0
- package/dist/@types/domains/group.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/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts +2 -2
- package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.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/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
- package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
- package/dist/feedRepository/api/queryGlobalFeed.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/uploadClip.d.ts +17 -0
- package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
- package/dist/index.cjs.js +145 -14
- package/dist/index.esm.js +145 -14
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/postRepository/api/createClipPost.d.ts +32 -0
- package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
- package/dist/postRepository/api/index.d.ts +1 -0
- package/dist/postRepository/api/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/channelMemberLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/channelMemberLinkedObject.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/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +1 -0
- package/dist/utils/postTypePredicate.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/dist/utils/tests/dummy/community.d.ts +2 -0
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/payload.ts +1 -1
- package/src/@types/domains/channel.ts +1 -0
- package/src/@types/domains/content.ts +10 -0
- package/src/@types/domains/feed.ts +2 -1
- package/src/@types/domains/file.ts +5 -0
- package/src/@types/domains/group.ts +2 -0
- package/src/@types/domains/post.ts +4 -0
- package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +3 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +2 -1
- package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.ts +2 -2
- package/src/communityRepository/api/getCommunity.ts +0 -9
- package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
- package/src/feedRepository/api/queryGlobalFeed.ts +3 -1
- package/src/fileRepository/api/index.ts +1 -0
- package/src/fileRepository/api/uploadClip.ts +71 -0
- package/src/postRepository/api/createClipPost.ts +62 -0
- package/src/postRepository/api/index.ts +2 -0
- package/src/postRepository/api/queryPosts.ts +1 -1
- package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
- package/src/utils/linkedObject/channelLinkedObject.ts +19 -0
- package/src/utils/linkedObject/channelMemberLinkedObject.ts +20 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/postLinkedObject.ts +12 -1
- package/src/utils/postTypePredicate.ts +10 -0
package/dist/index.cjs.js
CHANGED
|
@@ -35,6 +35,7 @@ const FileType = Object.freeze({
|
|
|
35
35
|
FILE: 'file',
|
|
36
36
|
IMAGE: 'image',
|
|
37
37
|
VIDEO: 'video',
|
|
38
|
+
CLIP: 'clip',
|
|
38
39
|
});
|
|
39
40
|
const VideoResolution = Object.freeze({
|
|
40
41
|
'1080P': '1080p',
|
|
@@ -118,6 +119,7 @@ const PostContentType = Object.freeze({
|
|
|
118
119
|
VIDEO: 'video',
|
|
119
120
|
LIVESTREAM: 'liveStream',
|
|
120
121
|
POLL: 'poll',
|
|
122
|
+
CLIP: 'clip',
|
|
121
123
|
});
|
|
122
124
|
|
|
123
125
|
exports.InvitationTypeEnum = void 0;
|
|
@@ -153,8 +155,8 @@ exports.JoinResultStatusEnum = void 0;
|
|
|
153
155
|
|
|
154
156
|
function getVersion() {
|
|
155
157
|
try {
|
|
156
|
-
// the string ''v7.
|
|
157
|
-
return 'v7.
|
|
158
|
+
// the string ''v7.6.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
159
|
+
return 'v7.6.0-cjs';
|
|
158
160
|
}
|
|
159
161
|
catch (error) {
|
|
160
162
|
return '__dev__';
|
|
@@ -6693,6 +6695,13 @@ function isAmityVideoPost(post) {
|
|
|
6693
6695
|
'videoFileId' in post.data &&
|
|
6694
6696
|
'thumbnailFileId' in post.data &&
|
|
6695
6697
|
post.dataType === 'video');
|
|
6698
|
+
}
|
|
6699
|
+
function isAmityClipPost(post) {
|
|
6700
|
+
return !!(post.data &&
|
|
6701
|
+
typeof post.data !== 'string' &&
|
|
6702
|
+
'fileId' in post.data &&
|
|
6703
|
+
'thumbnailFileId' in post.data &&
|
|
6704
|
+
post.dataType === 'clip');
|
|
6696
6705
|
}
|
|
6697
6706
|
|
|
6698
6707
|
const postLinkedObject = (post) => {
|
|
@@ -6747,6 +6756,12 @@ const postLinkedObject = (post) => {
|
|
|
6747
6756
|
return isAmityFilePost(post)
|
|
6748
6757
|
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
6749
6758
|
: undefined;
|
|
6759
|
+
},
|
|
6760
|
+
getClipInfo() {
|
|
6761
|
+
var _a, _b;
|
|
6762
|
+
return isAmityClipPost(post)
|
|
6763
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
6764
|
+
: undefined;
|
|
6750
6765
|
} });
|
|
6751
6766
|
};
|
|
6752
6767
|
|
|
@@ -7296,9 +7311,35 @@ const markAsRead = async (channelId) => {
|
|
|
7296
7311
|
return true;
|
|
7297
7312
|
};
|
|
7298
7313
|
|
|
7314
|
+
const channelMemberLinkedObject = (channelMember) => {
|
|
7315
|
+
const getUser = () => {
|
|
7316
|
+
var _a;
|
|
7317
|
+
const cacheKey = ['user', 'get', channelMember.userId];
|
|
7318
|
+
const internalUser = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
7319
|
+
return internalUser ? userLinkedObject(internalUser) : undefined;
|
|
7320
|
+
};
|
|
7321
|
+
return Object.assign(Object.assign({}, channelMember), { get user() {
|
|
7322
|
+
return getUser();
|
|
7323
|
+
} });
|
|
7324
|
+
};
|
|
7325
|
+
|
|
7299
7326
|
const channelLinkedObject = (channel) => {
|
|
7327
|
+
var _a;
|
|
7328
|
+
let previewMembers = [];
|
|
7329
|
+
if (channel.type === 'conversation') {
|
|
7330
|
+
const channelUsers = queryCache(['channelUsers', 'get']);
|
|
7331
|
+
if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
|
|
7332
|
+
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.channelId === channel.channelId)) !== null && _a !== void 0 ? _a : [])
|
|
7333
|
+
// sort in ascending order by userInternalId
|
|
7334
|
+
.sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
|
|
7335
|
+
// Select only first 4 members
|
|
7336
|
+
.slice(0, 4)
|
|
7337
|
+
.map(({ data }) => channelMemberLinkedObject(data));
|
|
7338
|
+
}
|
|
7339
|
+
}
|
|
7300
7340
|
return shallowClone(channel, {
|
|
7301
7341
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
7342
|
+
previewMembers,
|
|
7302
7343
|
});
|
|
7303
7344
|
};
|
|
7304
7345
|
|
|
@@ -8621,6 +8662,7 @@ const LinkedObject = {
|
|
|
8621
8662
|
community: communityLinkedObject,
|
|
8622
8663
|
invitation: invitationLinkedObject,
|
|
8623
8664
|
joinRequest: joinRequestLinkedObject,
|
|
8665
|
+
channelMember: channelMemberLinkedObject,
|
|
8624
8666
|
};
|
|
8625
8667
|
|
|
8626
8668
|
const constructChannelObject = (channel) => {
|
|
@@ -13888,6 +13930,57 @@ const updateAltText = async (fileId, altText) => {
|
|
|
13888
13930
|
};
|
|
13889
13931
|
/* end_public_function */
|
|
13890
13932
|
|
|
13933
|
+
/* begin_public_function
|
|
13934
|
+
id: file.upload.clip
|
|
13935
|
+
*/
|
|
13936
|
+
/**
|
|
13937
|
+
* ```js
|
|
13938
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
13939
|
+
* const created = await FileRepository.uploadClip(formData)
|
|
13940
|
+
* ```
|
|
13941
|
+
*
|
|
13942
|
+
* Creates an {@link Amity.File}
|
|
13943
|
+
*
|
|
13944
|
+
* @param formData The data necessary to create a new {@link Amity.File}
|
|
13945
|
+
* @param onProgress The callback to track the upload progress
|
|
13946
|
+
* @returns The newly created {@link Amity.File}
|
|
13947
|
+
*
|
|
13948
|
+
* @category File API
|
|
13949
|
+
* @async
|
|
13950
|
+
*/
|
|
13951
|
+
const uploadClip = async (formData, feedType, onProgress) => {
|
|
13952
|
+
const client = getActiveClient();
|
|
13953
|
+
client.log('file/uploadClip', formData);
|
|
13954
|
+
const file = formData.get('files');
|
|
13955
|
+
if (!file)
|
|
13956
|
+
throw new Error('The formData object must have a `files` key.');
|
|
13957
|
+
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
13958
|
+
formData.append('accessType', accessType);
|
|
13959
|
+
formData.append('preferredFilename', file.name);
|
|
13960
|
+
if (feedType) {
|
|
13961
|
+
formData.append('feedType', feedType);
|
|
13962
|
+
}
|
|
13963
|
+
const headers = 'getHeaders' in formData
|
|
13964
|
+
? formData.getHeaders()
|
|
13965
|
+
: { 'content-type': 'multipart/form-data' };
|
|
13966
|
+
const { data } = await client.upload.post('/api/v4/clips', formData, {
|
|
13967
|
+
headers,
|
|
13968
|
+
onUploadProgress({ loaded, total = 100 }) {
|
|
13969
|
+
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
13970
|
+
},
|
|
13971
|
+
});
|
|
13972
|
+
// API-FIX: payload should be serialized properly
|
|
13973
|
+
// const { files } = data
|
|
13974
|
+
const cachedAt = client.cache && Date.now();
|
|
13975
|
+
if (client.cache)
|
|
13976
|
+
ingestInCache({ files: data }, { cachedAt });
|
|
13977
|
+
return {
|
|
13978
|
+
data,
|
|
13979
|
+
cachedAt,
|
|
13980
|
+
};
|
|
13981
|
+
};
|
|
13982
|
+
/* end_public_function */
|
|
13983
|
+
|
|
13891
13984
|
var index$k = /*#__PURE__*/Object.freeze({
|
|
13892
13985
|
__proto__: null,
|
|
13893
13986
|
getFile: getFile,
|
|
@@ -13896,7 +13989,8 @@ var index$k = /*#__PURE__*/Object.freeze({
|
|
|
13896
13989
|
fileUrlWithSize: fileUrlWithSize,
|
|
13897
13990
|
uploadVideo: uploadVideo,
|
|
13898
13991
|
uploadImage: uploadImage,
|
|
13899
|
-
updateAltText: updateAltText
|
|
13992
|
+
updateAltText: updateAltText,
|
|
13993
|
+
uploadClip: uploadClip
|
|
13900
13994
|
});
|
|
13901
13995
|
|
|
13902
13996
|
/**
|
|
@@ -19214,7 +19308,8 @@ class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
|
19214
19308
|
const data = this.applyFilter((_b = collection.data
|
|
19215
19309
|
.map(id => pullFromCache(['channelUsers', 'get', id]))
|
|
19216
19310
|
.filter(Boolean)
|
|
19217
|
-
.map(({ data }) => data)
|
|
19311
|
+
.map(({ data }) => data)
|
|
19312
|
+
.map(LinkedObject.channelMember)) !== null && _b !== void 0 ? _b : []);
|
|
19218
19313
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
19219
19314
|
return;
|
|
19220
19315
|
this.callback({
|
|
@@ -19763,16 +19858,11 @@ const updateCommunity = async (communityId, patch) => {
|
|
|
19763
19858
|
* @category Community API
|
|
19764
19859
|
* @async
|
|
19765
19860
|
*/
|
|
19766
|
-
const getCommunity$1 = async (communityId
|
|
19861
|
+
const getCommunity$1 = async (communityId) => {
|
|
19767
19862
|
const client = getActiveClient();
|
|
19768
19863
|
client.log('community/getCommunity', communityId);
|
|
19769
19864
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
19770
|
-
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}
|
|
19771
|
-
params: {
|
|
19772
|
-
type: 'communityJoinRequest',
|
|
19773
|
-
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity !== null && includeDiscoverablePrivateCommunity !== void 0 ? includeDiscoverablePrivateCommunity : true,
|
|
19774
|
-
},
|
|
19775
|
-
});
|
|
19865
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
19776
19866
|
const data = prepareCommunityPayload(payload);
|
|
19777
19867
|
const cachedAt = client.cache && Date.now();
|
|
19778
19868
|
if (client.cache) {
|
|
@@ -22496,14 +22586,14 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
22496
22586
|
const queryGlobalFeed = async (query) => {
|
|
22497
22587
|
const client = getActiveClient();
|
|
22498
22588
|
client.log('feed/queryGlobalFeed', query);
|
|
22499
|
-
const _a = query !== null && query !== void 0 ? query : {}, { queryToken } = _a, params = __rest(_a, ["queryToken"]);
|
|
22589
|
+
const _a = query !== null && query !== void 0 ? query : {}, { queryToken, dataTypes, resolveParent } = _a, params = __rest(_a, ["queryToken", "dataTypes", "resolveParent"]);
|
|
22500
22590
|
const options = (() => {
|
|
22501
22591
|
if (queryToken)
|
|
22502
22592
|
return { token: queryToken };
|
|
22503
22593
|
return undefined;
|
|
22504
22594
|
})();
|
|
22505
22595
|
const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
|
|
22506
|
-
params: Object.assign(Object.assign({}, params), { options }),
|
|
22596
|
+
params: Object.assign(Object.assign({}, params), { dataTypes, resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
|
|
22507
22597
|
});
|
|
22508
22598
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
22509
22599
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
@@ -23089,6 +23179,46 @@ const isPostFlaggedByMe = async (postId) => {
|
|
|
23089
23179
|
};
|
|
23090
23180
|
/* end_public_function */
|
|
23091
23181
|
|
|
23182
|
+
/* begin_public_function
|
|
23183
|
+
id: post.create.clip_post
|
|
23184
|
+
*/
|
|
23185
|
+
/**
|
|
23186
|
+
* ```js
|
|
23187
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
23188
|
+
* const created = await PostRepository.createClipPost({
|
|
23189
|
+
* targetType: 'user',
|
|
23190
|
+
* targetId: 'foobar',
|
|
23191
|
+
* dataType: 'clip',
|
|
23192
|
+
* data: { text: 'hello world' },
|
|
23193
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
23194
|
+
* }))
|
|
23195
|
+
* ```
|
|
23196
|
+
*
|
|
23197
|
+
* Creates an {@link Amity.Post}
|
|
23198
|
+
*
|
|
23199
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
23200
|
+
* @returns The newly created {@link Amity.Post}
|
|
23201
|
+
*
|
|
23202
|
+
* @category Post API
|
|
23203
|
+
* @async
|
|
23204
|
+
*/
|
|
23205
|
+
const createClipPost = async (bundle) => {
|
|
23206
|
+
const client = getActiveClient();
|
|
23207
|
+
client.log('post/createPost', bundle);
|
|
23208
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
23209
|
+
fireEvent('post.created', payload);
|
|
23210
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
23211
|
+
const cachedAt = client.cache && Date.now();
|
|
23212
|
+
if (client.cache)
|
|
23213
|
+
ingestInCache(data, { cachedAt });
|
|
23214
|
+
const { posts } = data;
|
|
23215
|
+
return {
|
|
23216
|
+
data: LinkedObject.post(posts[0]),
|
|
23217
|
+
cachedAt,
|
|
23218
|
+
};
|
|
23219
|
+
};
|
|
23220
|
+
/* end_public_function */
|
|
23221
|
+
|
|
23092
23222
|
/* begin_public_function
|
|
23093
23223
|
id: comment.get_by_ids
|
|
23094
23224
|
*/
|
|
@@ -24177,7 +24307,7 @@ class PostPaginationController extends PaginationController {
|
|
|
24177
24307
|
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
24178
24308
|
};
|
|
24179
24309
|
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
24180
|
-
const { data: queryResponse } = await this.http.get(`/api/
|
|
24310
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
|
|
24181
24311
|
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
24182
24312
|
/*
|
|
24183
24313
|
* when creating post like image, file, video BE will create 2 posts
|
|
@@ -24989,6 +25119,7 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
24989
25119
|
flagPost: flagPost,
|
|
24990
25120
|
unflagPost: unflagPost,
|
|
24991
25121
|
isPostFlaggedByMe: isPostFlaggedByMe,
|
|
25122
|
+
createClipPost: createClipPost,
|
|
24992
25123
|
onPostCreated: onPostCreated,
|
|
24993
25124
|
onPostUpdated: onPostUpdated,
|
|
24994
25125
|
onPostDeleted: onPostDeleted,
|
package/dist/index.esm.js
CHANGED
|
@@ -19,6 +19,7 @@ const FileType = Object.freeze({
|
|
|
19
19
|
FILE: 'file',
|
|
20
20
|
IMAGE: 'image',
|
|
21
21
|
VIDEO: 'video',
|
|
22
|
+
CLIP: 'clip',
|
|
22
23
|
});
|
|
23
24
|
const VideoResolution = Object.freeze({
|
|
24
25
|
'1080P': '1080p',
|
|
@@ -102,6 +103,7 @@ const PostContentType = Object.freeze({
|
|
|
102
103
|
VIDEO: 'video',
|
|
103
104
|
LIVESTREAM: 'liveStream',
|
|
104
105
|
POLL: 'poll',
|
|
106
|
+
CLIP: 'clip',
|
|
105
107
|
});
|
|
106
108
|
|
|
107
109
|
var InvitationTypeEnum;
|
|
@@ -137,8 +139,8 @@ var JoinResultStatusEnum;
|
|
|
137
139
|
|
|
138
140
|
function getVersion() {
|
|
139
141
|
try {
|
|
140
|
-
// the string ''v7.
|
|
141
|
-
return 'v7.
|
|
142
|
+
// the string ''v7.6.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
143
|
+
return 'v7.6.0-esm';
|
|
142
144
|
}
|
|
143
145
|
catch (error) {
|
|
144
146
|
return '__dev__';
|
|
@@ -22784,6 +22786,13 @@ function isAmityVideoPost(post) {
|
|
|
22784
22786
|
'videoFileId' in post.data &&
|
|
22785
22787
|
'thumbnailFileId' in post.data &&
|
|
22786
22788
|
post.dataType === 'video');
|
|
22789
|
+
}
|
|
22790
|
+
function isAmityClipPost(post) {
|
|
22791
|
+
return !!(post.data &&
|
|
22792
|
+
typeof post.data !== 'string' &&
|
|
22793
|
+
'fileId' in post.data &&
|
|
22794
|
+
'thumbnailFileId' in post.data &&
|
|
22795
|
+
post.dataType === 'clip');
|
|
22787
22796
|
}
|
|
22788
22797
|
|
|
22789
22798
|
const postLinkedObject = (post) => {
|
|
@@ -22838,6 +22847,12 @@ const postLinkedObject = (post) => {
|
|
|
22838
22847
|
return isAmityFilePost(post)
|
|
22839
22848
|
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
22840
22849
|
: undefined;
|
|
22850
|
+
},
|
|
22851
|
+
getClipInfo() {
|
|
22852
|
+
var _a, _b;
|
|
22853
|
+
return isAmityClipPost(post)
|
|
22854
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
22855
|
+
: undefined;
|
|
22841
22856
|
} });
|
|
22842
22857
|
};
|
|
22843
22858
|
|
|
@@ -23387,9 +23402,35 @@ const markAsRead = async (channelId) => {
|
|
|
23387
23402
|
return true;
|
|
23388
23403
|
};
|
|
23389
23404
|
|
|
23405
|
+
const channelMemberLinkedObject = (channelMember) => {
|
|
23406
|
+
const getUser = () => {
|
|
23407
|
+
var _a;
|
|
23408
|
+
const cacheKey = ['user', 'get', channelMember.userId];
|
|
23409
|
+
const internalUser = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23410
|
+
return internalUser ? userLinkedObject(internalUser) : undefined;
|
|
23411
|
+
};
|
|
23412
|
+
return Object.assign(Object.assign({}, channelMember), { get user() {
|
|
23413
|
+
return getUser();
|
|
23414
|
+
} });
|
|
23415
|
+
};
|
|
23416
|
+
|
|
23390
23417
|
const channelLinkedObject = (channel) => {
|
|
23418
|
+
var _a;
|
|
23419
|
+
let previewMembers = [];
|
|
23420
|
+
if (channel.type === 'conversation') {
|
|
23421
|
+
const channelUsers = queryCache(['channelUsers', 'get']);
|
|
23422
|
+
if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
|
|
23423
|
+
previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.channelId === channel.channelId)) !== null && _a !== void 0 ? _a : [])
|
|
23424
|
+
// sort in ascending order by userInternalId
|
|
23425
|
+
.sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
|
|
23426
|
+
// Select only first 4 members
|
|
23427
|
+
.slice(0, 4)
|
|
23428
|
+
.map(({ data }) => channelMemberLinkedObject(data));
|
|
23429
|
+
}
|
|
23430
|
+
}
|
|
23391
23431
|
return shallowClone(channel, {
|
|
23392
23432
|
markAsRead: () => markAsRead(channel.channelInternalId),
|
|
23433
|
+
previewMembers,
|
|
23393
23434
|
});
|
|
23394
23435
|
};
|
|
23395
23436
|
|
|
@@ -24712,6 +24753,7 @@ const LinkedObject = {
|
|
|
24712
24753
|
community: communityLinkedObject,
|
|
24713
24754
|
invitation: invitationLinkedObject,
|
|
24714
24755
|
joinRequest: joinRequestLinkedObject,
|
|
24756
|
+
channelMember: channelMemberLinkedObject,
|
|
24715
24757
|
};
|
|
24716
24758
|
|
|
24717
24759
|
const constructChannelObject = (channel) => {
|
|
@@ -29979,6 +30021,57 @@ const updateAltText = async (fileId, altText) => {
|
|
|
29979
30021
|
};
|
|
29980
30022
|
/* end_public_function */
|
|
29981
30023
|
|
|
30024
|
+
/* begin_public_function
|
|
30025
|
+
id: file.upload.clip
|
|
30026
|
+
*/
|
|
30027
|
+
/**
|
|
30028
|
+
* ```js
|
|
30029
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
30030
|
+
* const created = await FileRepository.uploadClip(formData)
|
|
30031
|
+
* ```
|
|
30032
|
+
*
|
|
30033
|
+
* Creates an {@link Amity.File}
|
|
30034
|
+
*
|
|
30035
|
+
* @param formData The data necessary to create a new {@link Amity.File}
|
|
30036
|
+
* @param onProgress The callback to track the upload progress
|
|
30037
|
+
* @returns The newly created {@link Amity.File}
|
|
30038
|
+
*
|
|
30039
|
+
* @category File API
|
|
30040
|
+
* @async
|
|
30041
|
+
*/
|
|
30042
|
+
const uploadClip = async (formData, feedType, onProgress) => {
|
|
30043
|
+
const client = getActiveClient();
|
|
30044
|
+
client.log('file/uploadClip', formData);
|
|
30045
|
+
const file = formData.get('files');
|
|
30046
|
+
if (!file)
|
|
30047
|
+
throw new Error('The formData object must have a `files` key.');
|
|
30048
|
+
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
30049
|
+
formData.append('accessType', accessType);
|
|
30050
|
+
formData.append('preferredFilename', file.name);
|
|
30051
|
+
if (feedType) {
|
|
30052
|
+
formData.append('feedType', feedType);
|
|
30053
|
+
}
|
|
30054
|
+
const headers = 'getHeaders' in formData
|
|
30055
|
+
? formData.getHeaders()
|
|
30056
|
+
: { 'content-type': 'multipart/form-data' };
|
|
30057
|
+
const { data } = await client.upload.post('/api/v4/clips', formData, {
|
|
30058
|
+
headers,
|
|
30059
|
+
onUploadProgress({ loaded, total = 100 }) {
|
|
30060
|
+
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
30061
|
+
},
|
|
30062
|
+
});
|
|
30063
|
+
// API-FIX: payload should be serialized properly
|
|
30064
|
+
// const { files } = data
|
|
30065
|
+
const cachedAt = client.cache && Date.now();
|
|
30066
|
+
if (client.cache)
|
|
30067
|
+
ingestInCache({ files: data }, { cachedAt });
|
|
30068
|
+
return {
|
|
30069
|
+
data,
|
|
30070
|
+
cachedAt,
|
|
30071
|
+
};
|
|
30072
|
+
};
|
|
30073
|
+
/* end_public_function */
|
|
30074
|
+
|
|
29982
30075
|
var index$k = /*#__PURE__*/Object.freeze({
|
|
29983
30076
|
__proto__: null,
|
|
29984
30077
|
getFile: getFile,
|
|
@@ -29987,7 +30080,8 @@ var index$k = /*#__PURE__*/Object.freeze({
|
|
|
29987
30080
|
fileUrlWithSize: fileUrlWithSize,
|
|
29988
30081
|
uploadVideo: uploadVideo,
|
|
29989
30082
|
uploadImage: uploadImage,
|
|
29990
|
-
updateAltText: updateAltText
|
|
30083
|
+
updateAltText: updateAltText,
|
|
30084
|
+
uploadClip: uploadClip
|
|
29991
30085
|
});
|
|
29992
30086
|
|
|
29993
30087
|
/**
|
|
@@ -35305,7 +35399,8 @@ class ChannelMemberLiveCollectionController extends LiveCollectionController {
|
|
|
35305
35399
|
const data = this.applyFilter((_b = collection.data
|
|
35306
35400
|
.map(id => pullFromCache(['channelUsers', 'get', id]))
|
|
35307
35401
|
.filter(Boolean)
|
|
35308
|
-
.map(({ data }) => data)
|
|
35402
|
+
.map(({ data }) => data)
|
|
35403
|
+
.map(LinkedObject.channelMember)) !== null && _b !== void 0 ? _b : []);
|
|
35309
35404
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
35310
35405
|
return;
|
|
35311
35406
|
this.callback({
|
|
@@ -35854,16 +35949,11 @@ const updateCommunity = async (communityId, patch) => {
|
|
|
35854
35949
|
* @category Community API
|
|
35855
35950
|
* @async
|
|
35856
35951
|
*/
|
|
35857
|
-
const getCommunity$1 = async (communityId
|
|
35952
|
+
const getCommunity$1 = async (communityId) => {
|
|
35858
35953
|
const client = getActiveClient();
|
|
35859
35954
|
client.log('community/getCommunity', communityId);
|
|
35860
35955
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
35861
|
-
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}
|
|
35862
|
-
params: {
|
|
35863
|
-
type: 'communityJoinRequest',
|
|
35864
|
-
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity !== null && includeDiscoverablePrivateCommunity !== void 0 ? includeDiscoverablePrivateCommunity : true,
|
|
35865
|
-
},
|
|
35866
|
-
});
|
|
35956
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
35867
35957
|
const data = prepareCommunityPayload(payload);
|
|
35868
35958
|
const cachedAt = client.cache && Date.now();
|
|
35869
35959
|
if (client.cache) {
|
|
@@ -38587,14 +38677,14 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
38587
38677
|
const queryGlobalFeed = async (query) => {
|
|
38588
38678
|
const client = getActiveClient();
|
|
38589
38679
|
client.log('feed/queryGlobalFeed', query);
|
|
38590
|
-
const _a = query !== null && query !== void 0 ? query : {}, { queryToken } = _a, params = __rest(_a, ["queryToken"]);
|
|
38680
|
+
const _a = query !== null && query !== void 0 ? query : {}, { queryToken, dataTypes, resolveParent } = _a, params = __rest(_a, ["queryToken", "dataTypes", "resolveParent"]);
|
|
38591
38681
|
const options = (() => {
|
|
38592
38682
|
if (queryToken)
|
|
38593
38683
|
return { token: queryToken };
|
|
38594
38684
|
return undefined;
|
|
38595
38685
|
})();
|
|
38596
38686
|
const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
|
|
38597
|
-
params: Object.assign(Object.assign({}, params), { options }),
|
|
38687
|
+
params: Object.assign(Object.assign({}, params), { dataTypes, resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
|
|
38598
38688
|
});
|
|
38599
38689
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
38600
38690
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
@@ -39180,6 +39270,46 @@ const isPostFlaggedByMe = async (postId) => {
|
|
|
39180
39270
|
};
|
|
39181
39271
|
/* end_public_function */
|
|
39182
39272
|
|
|
39273
|
+
/* begin_public_function
|
|
39274
|
+
id: post.create.clip_post
|
|
39275
|
+
*/
|
|
39276
|
+
/**
|
|
39277
|
+
* ```js
|
|
39278
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
39279
|
+
* const created = await PostRepository.createClipPost({
|
|
39280
|
+
* targetType: 'user',
|
|
39281
|
+
* targetId: 'foobar',
|
|
39282
|
+
* dataType: 'clip',
|
|
39283
|
+
* data: { text: 'hello world' },
|
|
39284
|
+
* attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
|
|
39285
|
+
* }))
|
|
39286
|
+
* ```
|
|
39287
|
+
*
|
|
39288
|
+
* Creates an {@link Amity.Post}
|
|
39289
|
+
*
|
|
39290
|
+
* @param bundle The data necessary to create a new {@link Amity.Post}
|
|
39291
|
+
* @returns The newly created {@link Amity.Post}
|
|
39292
|
+
*
|
|
39293
|
+
* @category Post API
|
|
39294
|
+
* @async
|
|
39295
|
+
*/
|
|
39296
|
+
const createClipPost = async (bundle) => {
|
|
39297
|
+
const client = getActiveClient();
|
|
39298
|
+
client.log('post/createPost', bundle);
|
|
39299
|
+
const { data: payload } = await client.http.post('/api/v4/posts', bundle);
|
|
39300
|
+
fireEvent('post.created', payload);
|
|
39301
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
39302
|
+
const cachedAt = client.cache && Date.now();
|
|
39303
|
+
if (client.cache)
|
|
39304
|
+
ingestInCache(data, { cachedAt });
|
|
39305
|
+
const { posts } = data;
|
|
39306
|
+
return {
|
|
39307
|
+
data: LinkedObject.post(posts[0]),
|
|
39308
|
+
cachedAt,
|
|
39309
|
+
};
|
|
39310
|
+
};
|
|
39311
|
+
/* end_public_function */
|
|
39312
|
+
|
|
39183
39313
|
/* begin_public_function
|
|
39184
39314
|
id: comment.get_by_ids
|
|
39185
39315
|
*/
|
|
@@ -40268,7 +40398,7 @@ class PostPaginationController extends PaginationController {
|
|
|
40268
40398
|
type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
|
|
40269
40399
|
};
|
|
40270
40400
|
const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
|
|
40271
|
-
const { data: queryResponse } = await this.http.get(`/api/
|
|
40401
|
+
const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
|
|
40272
40402
|
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
40273
40403
|
/*
|
|
40274
40404
|
* when creating post like image, file, video BE will create 2 posts
|
|
@@ -41080,6 +41210,7 @@ var index$7 = /*#__PURE__*/Object.freeze({
|
|
|
41080
41210
|
flagPost: flagPost,
|
|
41081
41211
|
unflagPost: unflagPost,
|
|
41082
41212
|
isPostFlaggedByMe: isPostFlaggedByMe,
|
|
41213
|
+
createClipPost: createClipPost,
|
|
41083
41214
|
onPostCreated: onPostCreated,
|
|
41084
41215
|
onPostUpdated: onPostUpdated,
|
|
41085
41216
|
onPostDeleted: onPostDeleted,
|