@amityco/ts-sdk-react-native 7.3.1-1cd86e2.0 → 7.4.1-9a54e83.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/.eslintrc.json +2 -1
- package/dist/@types/core/payload.d.ts +21 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +12 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +1 -20
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +4 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/commentRepository/api/flagComment.d.ts +3 -2
- package/dist/commentRepository/api/flagComment.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/updateAltText.d.ts +17 -0
- package/dist/fileRepository/api/updateAltText.d.ts.map +1 -0
- package/dist/fileRepository/api/uploadImage.d.ts +2 -1
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
- package/dist/index.cjs.js +129 -14
- package/dist/index.esm.js +130 -15
- package/dist/index.umd.js +3 -3
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
- package/dist/postRepository/api/flagPost.d.ts +3 -2
- package/dist/postRepository/api/flagPost.d.ts.map +1 -1
- package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
- package/dist/utils/postTypePredicate.d.ts +4 -0
- package/dist/utils/postTypePredicate.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/core/payload.ts +23 -1
- package/src/@types/domains/content.ts +16 -0
- package/src/@types/domains/file.ts +1 -21
- package/src/@types/domains/post.ts +4 -0
- package/src/commentRepository/api/flagComment.ts +20 -3
- package/src/fileRepository/api/index.ts +1 -0
- package/src/fileRepository/api/updateAltText.ts +39 -0
- package/src/fileRepository/api/uploadImage.ts +22 -3
- package/src/messageRepository/api/flagMessage.ts +2 -4
- package/src/postRepository/api/flagPost.ts +19 -3
- package/src/utils/linkedObject/postLinkedObject.ts +29 -0
- package/src/utils/postTypePredicate.ts +27 -0
package/dist/index.esm.js
CHANGED
|
@@ -67,7 +67,19 @@ const ContentFeedType = Object.freeze({
|
|
|
67
67
|
CHAT: 'chat',
|
|
68
68
|
POST: 'post',
|
|
69
69
|
MESSAGE: 'message',
|
|
70
|
-
});
|
|
70
|
+
});
|
|
71
|
+
var ContentFlagReasonEnum;
|
|
72
|
+
(function (ContentFlagReasonEnum) {
|
|
73
|
+
ContentFlagReasonEnum["CommunityGuidelines"] = "Against community guidelines";
|
|
74
|
+
ContentFlagReasonEnum["HarassmentOrBullying"] = "Harassment or bullying";
|
|
75
|
+
ContentFlagReasonEnum["SelfHarmOrSuicide"] = "Self-harm or suicide";
|
|
76
|
+
ContentFlagReasonEnum["ViolenceOrThreateningContent"] = "Violence or threatening content";
|
|
77
|
+
ContentFlagReasonEnum["SellingRestrictedItems"] = "Selling and promoting restricted items";
|
|
78
|
+
ContentFlagReasonEnum["SexualContentOrNudity"] = "Sexual message or nudity";
|
|
79
|
+
ContentFlagReasonEnum["SpamOrScams"] = "Spam or scams";
|
|
80
|
+
ContentFlagReasonEnum["FalseInformation"] = "False information or misinformation";
|
|
81
|
+
ContentFlagReasonEnum["Others"] = "Others";
|
|
82
|
+
})(ContentFlagReasonEnum || (ContentFlagReasonEnum = {}));
|
|
71
83
|
|
|
72
84
|
const MessageContentType = Object.freeze({
|
|
73
85
|
TEXT: 'text',
|
|
@@ -89,8 +101,8 @@ const PostContentType = Object.freeze({
|
|
|
89
101
|
|
|
90
102
|
function getVersion() {
|
|
91
103
|
try {
|
|
92
|
-
// the string ''v7.
|
|
93
|
-
return 'v7.
|
|
104
|
+
// the string ''v7.4.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
105
|
+
return 'v7.4.0-esm';
|
|
94
106
|
}
|
|
95
107
|
catch (error) {
|
|
96
108
|
return '__dev__';
|
|
@@ -21683,6 +21695,26 @@ const commentLinkedObject = (comment) => {
|
|
|
21683
21695
|
} });
|
|
21684
21696
|
};
|
|
21685
21697
|
|
|
21698
|
+
function isAmityImagePost(post) {
|
|
21699
|
+
return !!(post.data &&
|
|
21700
|
+
typeof post.data !== 'string' &&
|
|
21701
|
+
'fileId' in post.data &&
|
|
21702
|
+
post.dataType === 'image');
|
|
21703
|
+
}
|
|
21704
|
+
function isAmityFilePost(post) {
|
|
21705
|
+
return !!(post.data &&
|
|
21706
|
+
typeof post.data !== 'string' &&
|
|
21707
|
+
'fileId' in post.data &&
|
|
21708
|
+
post.dataType === 'file');
|
|
21709
|
+
}
|
|
21710
|
+
function isAmityVideoPost(post) {
|
|
21711
|
+
return !!(post.data &&
|
|
21712
|
+
typeof post.data !== 'string' &&
|
|
21713
|
+
'videoFileId' in post.data &&
|
|
21714
|
+
'thumbnailFileId' in post.data &&
|
|
21715
|
+
post.dataType === 'video');
|
|
21716
|
+
}
|
|
21717
|
+
|
|
21686
21718
|
const postLinkedObject = (post) => {
|
|
21687
21719
|
return Object.assign(Object.assign({}, post), { analytics: {
|
|
21688
21720
|
markAsViewed: () => {
|
|
@@ -21711,6 +21743,30 @@ const postLinkedObject = (post) => {
|
|
|
21711
21743
|
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
21712
21744
|
return;
|
|
21713
21745
|
return userLinkedObject(cacheData.data);
|
|
21746
|
+
},
|
|
21747
|
+
getImageInfo() {
|
|
21748
|
+
var _a, _b;
|
|
21749
|
+
return isAmityImagePost(post)
|
|
21750
|
+
? (_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
|
|
21751
|
+
: undefined;
|
|
21752
|
+
},
|
|
21753
|
+
getVideoInfo() {
|
|
21754
|
+
var _a, _b, _c;
|
|
21755
|
+
return isAmityVideoPost(post)
|
|
21756
|
+
? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
|
|
21757
|
+
: undefined;
|
|
21758
|
+
},
|
|
21759
|
+
getVideoThumbnailInfo() {
|
|
21760
|
+
var _a, _b;
|
|
21761
|
+
return isAmityVideoPost(post)
|
|
21762
|
+
? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
|
|
21763
|
+
: undefined;
|
|
21764
|
+
},
|
|
21765
|
+
getFileInfo() {
|
|
21766
|
+
var _a, _b;
|
|
21767
|
+
return isAmityFilePost(post)
|
|
21768
|
+
? (_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
|
|
21769
|
+
: undefined;
|
|
21714
21770
|
} });
|
|
21715
21771
|
};
|
|
21716
21772
|
|
|
@@ -28841,20 +28897,33 @@ const uploadVideo = async (formData, feedType, onProgress) => {
|
|
|
28841
28897
|
*
|
|
28842
28898
|
* @param formData The data necessary to create a new {@link Amity.File<'image'>}
|
|
28843
28899
|
* @param onProgress The callback to track the upload progress
|
|
28900
|
+
* @param altText The alt text for the image
|
|
28844
28901
|
* @returns The newly created {@link Amity.File<'image'>}
|
|
28845
28902
|
*
|
|
28846
28903
|
* @category File API
|
|
28847
28904
|
* @async
|
|
28848
28905
|
*/
|
|
28849
|
-
const uploadImage = async (formData, onProgress) => {
|
|
28906
|
+
const uploadImage = async (formData, onProgress, altText) => {
|
|
28850
28907
|
const client = getActiveClient();
|
|
28851
28908
|
client.log('file/uploadImage', formData);
|
|
28852
28909
|
const files = formData.getAll('files');
|
|
28853
|
-
if (
|
|
28854
|
-
|
|
28910
|
+
if (files === null || files === void 0 ? void 0 : files.length) {
|
|
28911
|
+
console.warn('Deprecation Warning: `files` is deprecated, please use `file` instead.');
|
|
28912
|
+
formData.append('preferredFilename', files[0].name);
|
|
28913
|
+
}
|
|
28914
|
+
else {
|
|
28915
|
+
const file = formData.get('file');
|
|
28916
|
+
if (!file) {
|
|
28917
|
+
throw new Error('The formData object must have a `file` or `files` key');
|
|
28918
|
+
}
|
|
28919
|
+
formData.append('preferredFilename', file.name);
|
|
28920
|
+
// alt is for single image
|
|
28921
|
+
if (altText) {
|
|
28922
|
+
formData.append('altText', altText);
|
|
28923
|
+
}
|
|
28924
|
+
}
|
|
28855
28925
|
const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
|
|
28856
28926
|
formData.append('accessType', accessType);
|
|
28857
|
-
formData.append('preferredFilename', files[0].name);
|
|
28858
28927
|
const headers = 'getHeaders' in formData
|
|
28859
28928
|
? formData.getHeaders()
|
|
28860
28929
|
: { 'content-type': 'multipart/form-data' };
|
|
@@ -28876,6 +28945,37 @@ const uploadImage = async (formData, onProgress) => {
|
|
|
28876
28945
|
};
|
|
28877
28946
|
/* end_public_function */
|
|
28878
28947
|
|
|
28948
|
+
/* begin_public_function
|
|
28949
|
+
id: file.update.altText
|
|
28950
|
+
*/
|
|
28951
|
+
/**
|
|
28952
|
+
* ```js
|
|
28953
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
28954
|
+
* const updated = await FileRepository.updateAltText(fileId, altText)
|
|
28955
|
+
* ```
|
|
28956
|
+
*
|
|
28957
|
+
* Updates an {@link Amity.File<'image'>['altText']}.
|
|
28958
|
+
*
|
|
28959
|
+
* @param fileId The ID of the {@link Amity.File<'image'>} to edit
|
|
28960
|
+
* @param altText The new alt text for the {@link Amity.File<'image'>}
|
|
28961
|
+
* @returns the updated {@link Amity.File<'image'>} object
|
|
28962
|
+
*
|
|
28963
|
+
* @category File API
|
|
28964
|
+
* @async
|
|
28965
|
+
*/
|
|
28966
|
+
const updateAltText = async (fileId, altText) => {
|
|
28967
|
+
const client = getActiveClient();
|
|
28968
|
+
client.log('file/updateAltText', altText);
|
|
28969
|
+
const { data } = await client.http.put(`/api/v3/files/${fileId}`, {
|
|
28970
|
+
altText,
|
|
28971
|
+
});
|
|
28972
|
+
const cachedAt = client.cache && Date.now();
|
|
28973
|
+
if (client.cache)
|
|
28974
|
+
ingestInCache({ files: [data] }, { cachedAt });
|
|
28975
|
+
return true;
|
|
28976
|
+
};
|
|
28977
|
+
/* end_public_function */
|
|
28978
|
+
|
|
28879
28979
|
var index$j = /*#__PURE__*/Object.freeze({
|
|
28880
28980
|
__proto__: null,
|
|
28881
28981
|
getFile: getFile,
|
|
@@ -28883,7 +28983,8 @@ var index$j = /*#__PURE__*/Object.freeze({
|
|
|
28883
28983
|
deleteFile: deleteFile,
|
|
28884
28984
|
fileUrlWithSize: fileUrlWithSize,
|
|
28885
28985
|
uploadVideo: uploadVideo,
|
|
28886
|
-
uploadImage: uploadImage
|
|
28986
|
+
uploadImage: uploadImage,
|
|
28987
|
+
updateAltText: updateAltText
|
|
28887
28988
|
});
|
|
28888
28989
|
|
|
28889
28990
|
/**
|
|
@@ -37805,19 +37906,26 @@ const declinePost = async (postId) => {
|
|
|
37805
37906
|
/**
|
|
37806
37907
|
* ```js
|
|
37807
37908
|
* import { PostRepository } from '@amityco/ts-sdk-react-native'
|
|
37808
|
-
* const flagged = await PostRepository.flagPost(postId)
|
|
37909
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
37809
37910
|
* ```
|
|
37810
37911
|
*
|
|
37811
37912
|
* @param postId of the post to flag
|
|
37913
|
+
* @param reason the reason to flag the post
|
|
37812
37914
|
* @returns a boolean
|
|
37813
37915
|
*
|
|
37814
37916
|
* @category Post API
|
|
37815
37917
|
* @async
|
|
37816
37918
|
* */
|
|
37817
|
-
const flagPost = async (postId) => {
|
|
37919
|
+
const flagPost = async (postId, reason) => {
|
|
37818
37920
|
const client = getActiveClient();
|
|
37819
37921
|
client.log('post/flagPost', postId);
|
|
37820
|
-
const
|
|
37922
|
+
const isPredefinedReason = reason &&
|
|
37923
|
+
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
37924
|
+
const body = {
|
|
37925
|
+
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
37926
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
37927
|
+
};
|
|
37928
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
37821
37929
|
if (client.cache) {
|
|
37822
37930
|
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
37823
37931
|
}
|
|
@@ -38280,19 +38388,26 @@ const hardDeleteComment = async (commentId) => {
|
|
|
38280
38388
|
/**
|
|
38281
38389
|
* ```js
|
|
38282
38390
|
* import { CommentRepository } from '@amityco/ts-sdk-react-native'
|
|
38283
|
-
* const flagged = await CommentRepository.flagComment(
|
|
38391
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
38284
38392
|
* ```
|
|
38285
38393
|
*
|
|
38286
38394
|
* @param commentId The ID of the comment to flag
|
|
38395
|
+
* @param reason the reason to flag the comment
|
|
38287
38396
|
* @returns the created report result
|
|
38288
38397
|
*
|
|
38289
38398
|
* @category Comment API
|
|
38290
38399
|
* @async
|
|
38291
38400
|
* */
|
|
38292
|
-
const flagComment = async (commentId) => {
|
|
38401
|
+
const flagComment = async (commentId, reason) => {
|
|
38293
38402
|
const client = getActiveClient();
|
|
38294
38403
|
client.log('comment/flagComment', commentId);
|
|
38295
|
-
const
|
|
38404
|
+
const isPredefinedReason = reason &&
|
|
38405
|
+
Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
38406
|
+
const body = {
|
|
38407
|
+
reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
38408
|
+
detail: reason && !isPredefinedReason ? reason : '',
|
|
38409
|
+
};
|
|
38410
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
38296
38411
|
if (client.cache) {
|
|
38297
38412
|
ingestInCache(payload);
|
|
38298
38413
|
}
|
|
@@ -42550,4 +42665,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
42550
42665
|
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
42551
42666
|
});
|
|
42552
42667
|
|
|
42553
|
-
export { API_REGIONS, index$1 as AdRepository, index$9 as CategoryRepository, index$d as ChannelRepository, index$m as Client, index$7 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$a as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$8 as FeedRepository, FileAccessTypeEnum, index$j as FileRepository, FileType, index$3 as LiveStreamPlayer, MessageContentType, index$h as MessageRepository, index$4 as PollRepository, PostContentType, index$6 as PostRepository, index$i as ReactionRepository, index$2 as StoryRepository, index$5 as StreamRepository, index$g as SubChannelRepository, SubscriptionLevels, index$k as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|
|
42668
|
+
export { API_REGIONS, index$1 as AdRepository, index$9 as CategoryRepository, index$d as ChannelRepository, index$m as Client, index$7 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$a as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$8 as FeedRepository, FileAccessTypeEnum, index$j as FileRepository, FileType, index$3 as LiveStreamPlayer, MessageContentType, index$h as MessageRepository, index$4 as PollRepository, PostContentType, index$6 as PostRepository, index$i as ReactionRepository, index$2 as StoryRepository, index$5 as StreamRepository, index$g as SubChannelRepository, SubscriptionLevels, index$k as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|