@amityco/ts-sdk 6.2.1-b60a2f4.0 → 6.2.1-b68e715.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/README.md +0 -4
- package/dist/@types/domains/channel.d.ts +5 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/channelRepsitory/api/createChannel.d.ts +1 -1
- package/dist/communityRepository/{communityModeration → communityMembership}/api/addMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/index.d.ts +3 -0
- package/dist/communityRepository/communityMembership/api/index.d.ts.map +1 -0
- package/dist/communityRepository/{communityModeration → communityMembership}/api/removeMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/api/tests/addMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/api/tests/removeMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityMembership/index.d.ts +1 -0
- package/dist/communityRepository/communityMembership/index.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/index.d.ts +0 -2
- package/dist/communityRepository/communityModeration/api/index.d.ts.map +1 -1
- package/dist/feedRepository/api/index.d.ts +1 -0
- package/dist/feedRepository/api/index.d.ts.map +1 -1
- package/dist/fileRepository/api/index.d.ts +3 -3
- package/dist/fileRepository/api/test/uploadFile.test.d.ts +2 -0
- package/dist/fileRepository/api/test/uploadFile.test.d.ts.map +1 -0
- package/dist/fileRepository/api/test/uploadImage.test.d.ts +2 -0
- package/dist/fileRepository/api/test/uploadImage.test.d.ts.map +1 -0
- package/dist/fileRepository/api/test/uploadVideo.test.d.ts +2 -0
- package/dist/fileRepository/api/test/uploadVideo.test.d.ts.map +1 -0
- package/dist/fileRepository/api/{createFile.d.ts → uploadFile.d.ts} +4 -4
- package/dist/fileRepository/api/uploadFile.d.ts.map +1 -0
- package/dist/fileRepository/api/{createImage.d.ts → uploadImage.d.ts} +4 -4
- package/dist/fileRepository/api/uploadImage.d.ts.map +1 -0
- package/dist/fileRepository/api/{createVideo.d.ts → uploadVideo.d.ts} +5 -5
- package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -0
- package/dist/index.cjs.js +657 -170
- package/dist/index.esm.js +657 -170
- package/dist/index.umd.js +4 -4
- package/dist/messageRepository/api/createMessage.d.ts +1 -1
- package/dist/messageRepository/api/editMessage.d.ts +38 -0
- package/dist/messageRepository/api/editMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/flagMessage.d.ts +14 -0
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/index.d.ts +5 -1
- package/dist/messageRepository/api/index.d.ts.map +1 -1
- package/dist/messageRepository/api/isMessageFlaggedByMe.d.ts +14 -0
- package/dist/messageRepository/api/isMessageFlaggedByMe.d.ts.map +1 -0
- package/dist/messageRepository/api/{deleteMessage.d.ts → softDeleteMessage.d.ts} +6 -6
- package/dist/messageRepository/api/softDeleteMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/editMessage.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/editMessage.test.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/flagMessage.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/flagMessage.test.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/unflagMessage.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/unflagMessage.test.d.ts.map +1 -0
- package/dist/messageRepository/api/unflagMessage.d.ts +14 -0
- package/dist/messageRepository/api/unflagMessage.d.ts.map +1 -0
- package/dist/messageRepository/api/updateMessage.d.ts.map +1 -1
- package/dist/postRepository/api/deletePost.d.ts +1 -1
- package/dist/postRepository/api/deletePost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts +24 -0
- package/dist/postRepository/api/editPost.d.ts.map +1 -0
- package/dist/postRepository/api/flagPost.d.ts +14 -0
- package/dist/postRepository/api/flagPost.d.ts.map +1 -0
- package/dist/postRepository/api/hardDeletePost.d.ts +16 -0
- package/dist/postRepository/api/hardDeletePost.d.ts.map +1 -0
- package/dist/postRepository/api/index.d.ts +6 -0
- package/dist/postRepository/api/index.d.ts.map +1 -1
- package/dist/postRepository/api/isPostFlaggedByMe.d.ts +14 -0
- package/dist/postRepository/api/isPostFlaggedByMe.d.ts.map +1 -0
- package/dist/postRepository/api/softDeletePost.d.ts +16 -0
- package/dist/postRepository/api/softDeletePost.d.ts.map +1 -0
- package/dist/postRepository/api/unflagPost.d.ts +14 -0
- package/dist/postRepository/api/unflagPost.d.ts.map +1 -0
- package/dist/postRepository/api/updatePost.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +14 -0
- package/dist/userRepository/api/flagUser.d.ts.map +1 -0
- package/dist/userRepository/api/index.d.ts +3 -0
- package/dist/userRepository/api/index.d.ts.map +1 -1
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts +14 -0
- package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -0
- package/dist/userRepository/api/tests/flagUser.test.d.ts +2 -0
- package/dist/userRepository/api/tests/flagUser.test.d.ts.map +1 -0
- package/dist/userRepository/api/tests/unflagUser.test.d.ts +2 -0
- package/dist/userRepository/api/tests/unflagUser.test.d.ts.map +1 -0
- package/dist/userRepository/api/unflagUser.d.ts +14 -0
- package/dist/userRepository/api/unflagUser.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/domains/channel.ts +7 -2
- package/src/categoryRepository/observers/getCategories.ts +1 -1
- package/src/channelRepsitory/channelMembership/observers/getMembers.ts +1 -1
- package/src/channelRepsitory/observers/getChannels.ts +1 -1
- package/src/channelRepsitory/observers/tests/getChannels.test.ts +3 -9
- package/src/commentRepository/observers/getComments.ts +4 -4
- package/src/communityRepository/communityMembership/api/index.ts +2 -0
- package/src/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/addMembers.test.ts +1 -1
- package/src/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/removeMembers.test.ts +1 -1
- package/src/communityRepository/communityMembership/index.ts +1 -0
- package/src/communityRepository/communityMembership/observers/getMembers.ts +1 -1
- package/src/communityRepository/communityModeration/api/index.ts +0 -3
- package/src/communityRepository/observers/getCommunities.ts +1 -1
- package/src/core/query/tests/runQuery.test.ts +3 -3
- package/src/feedRepository/api/index.ts +1 -0
- package/src/fileRepository/api/index.ts +3 -3
- package/src/fileRepository/api/test/uploadFile.test.ts +69 -0
- package/src/fileRepository/api/test/{createImage.test.ts → uploadImage.test.ts} +7 -7
- package/src/fileRepository/api/test/{createVideo.test.ts → uploadVideo.test.ts} +8 -8
- package/src/fileRepository/api/{createFile.ts → uploadFile.ts} +4 -6
- package/src/fileRepository/api/{createImage.ts → uploadImage.ts} +4 -6
- package/src/fileRepository/api/{createVideo.ts → uploadVideo.ts} +5 -7
- package/src/messageRepository/api/editMessage.ts +100 -0
- package/src/messageRepository/api/flagMessage.ts +40 -0
- package/src/messageRepository/api/index.ts +7 -1
- package/src/messageRepository/api/isMessageFlaggedByMe.ts +30 -0
- package/src/messageRepository/api/{deleteMessage.ts → softDeleteMessage.ts} +8 -8
- package/src/messageRepository/api/tests/deleteMessage.test.ts +11 -11
- package/src/messageRepository/api/tests/{updateMessage.test.ts → editMessage.test.ts} +10 -10
- package/src/messageRepository/api/tests/flagMessage.test.ts +87 -0
- package/src/messageRepository/api/tests/unflagMessage.test.ts +87 -0
- package/src/messageRepository/api/unflagMessage.ts +40 -0
- package/src/messageRepository/api/updateMessage.ts +4 -0
- package/src/messageRepository/observers/getMessages.ts +4 -4
- package/src/postRepository/api/deletePost.ts +1 -7
- package/src/postRepository/api/editPost.ts +58 -0
- package/src/postRepository/api/flagPost.ts +38 -0
- package/src/postRepository/api/hardDeletePost.ts +30 -0
- package/src/postRepository/api/index.ts +8 -0
- package/src/postRepository/api/isPostFlaggedByMe.ts +33 -0
- package/src/postRepository/api/softDeletePost.ts +30 -0
- package/src/postRepository/api/unflagPost.ts +39 -0
- package/src/postRepository/api/updatePost.ts +4 -0
- package/src/postRepository/observers/getPosts.ts +4 -4
- package/src/reactionRepository/observers/getReactions.ts +4 -4
- package/src/report/api/createReport.ts +1 -1
- package/src/report/api/tests/createReport.test.ts +2 -62
- package/src/report/api/tests/deleteReport.test.ts +2 -62
- package/src/userRepository/api/flagUser.ts +37 -0
- package/src/userRepository/api/index.ts +4 -0
- package/src/userRepository/api/isUserFlaggedByMe.ts +33 -0
- package/src/userRepository/api/tests/flagUser.test.ts +81 -0
- package/src/userRepository/api/tests/unflagUser.test.ts +80 -0
- package/src/userRepository/api/unflagUser.ts +37 -0
- package/src/userRepository/observers/getBlockedUsers.ts +4 -4
- package/src/userRepository/observers/getUsers.ts +1 -1
- package/src/userRepository/observers/tests/getUsers.test.ts +3 -9
- package/src/userRepository/relationship/follow/observers/getFollowers.ts +4 -4
- package/src/userRepository/relationship/follow/observers/getFollowings.ts +4 -4
- package/dist/communityRepository/communityModeration/api/test/addMembers.test.d.ts.map +0 -1
- package/dist/communityRepository/communityModeration/api/test/removeMembers.test.d.ts.map +0 -1
- package/dist/fileRepository/api/createFile.d.ts.map +0 -1
- package/dist/fileRepository/api/createImage.d.ts.map +0 -1
- package/dist/fileRepository/api/createVideo.d.ts.map +0 -1
- package/dist/fileRepository/api/test/createImage.test.d.ts +0 -2
- package/dist/fileRepository/api/test/createImage.test.d.ts.map +0 -1
- package/dist/fileRepository/api/test/createVideo.test.d.ts +0 -2
- package/dist/fileRepository/api/test/createVideo.test.d.ts.map +0 -1
- package/dist/messageRepository/api/deleteMessage.d.ts.map +0 -1
- package/dist/messageRepository/api/tests/updateMessage.test.d.ts +0 -2
- package/dist/messageRepository/api/tests/updateMessage.test.d.ts.map +0 -1
- /package/dist/communityRepository/{communityModeration → communityMembership}/api/addMembers.d.ts +0 -0
- /package/dist/communityRepository/{communityModeration → communityMembership}/api/removeMembers.d.ts +0 -0
- /package/dist/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/addMembers.test.d.ts +0 -0
- /package/dist/communityRepository/{communityModeration/api/test → communityMembership/api/tests}/removeMembers.test.d.ts +0 -0
- /package/src/communityRepository/{communityModeration → communityMembership}/api/addMembers.ts +0 -0
- /package/src/communityRepository/{communityModeration → communityMembership}/api/removeMembers.ts +0 -0
package/dist/index.esm.js
CHANGED
|
@@ -23130,15 +23130,15 @@ const getBlockedUsers$1 = (params, callback, config) => {
|
|
|
23130
23130
|
* observers
|
|
23131
23131
|
*};
|
|
23132
23132
|
*/
|
|
23133
|
-
const onFetch = () => {
|
|
23133
|
+
const onFetch = (initial = false) => {
|
|
23134
23134
|
var _a, _b;
|
|
23135
23135
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23136
23136
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23137
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
23137
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
23138
23138
|
return;
|
|
23139
23139
|
const query = createQuery(queryBlockedUsers, {
|
|
23140
23140
|
limit,
|
|
23141
|
-
token: toToken(collection === null || collection === void 0 ? void 0 : collection.params.page, 'afterbeforeraw'),
|
|
23141
|
+
token: toToken(!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined, 'afterbeforeraw'),
|
|
23142
23142
|
});
|
|
23143
23143
|
runQuery(query,
|
|
23144
23144
|
// @ts-ignore
|
|
@@ -23159,7 +23159,7 @@ const getBlockedUsers$1 = (params, callback, config) => {
|
|
|
23159
23159
|
disposers.push(() => {
|
|
23160
23160
|
// @TODO -> update once observers added
|
|
23161
23161
|
});
|
|
23162
|
-
onFetch();
|
|
23162
|
+
onFetch(true);
|
|
23163
23163
|
return () => {
|
|
23164
23164
|
log(`getCategories(tmpid: ${timestamp}) > dispose`);
|
|
23165
23165
|
disposers.forEach(fn => fn());
|
|
@@ -23800,13 +23800,13 @@ const getFollowers = (params, callback, config) => {
|
|
|
23800
23800
|
pushToCache(cacheKey, collection);
|
|
23801
23801
|
responder(collection);
|
|
23802
23802
|
};
|
|
23803
|
-
const onFetch = () => {
|
|
23804
|
-
var _a, _b, _c, _d
|
|
23803
|
+
const onFetch = (initial = false) => {
|
|
23804
|
+
var _a, _b, _c, _d;
|
|
23805
23805
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23806
23806
|
const followers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23807
|
-
if (followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23807
|
+
if (!initial && followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23808
23808
|
return;
|
|
23809
|
-
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (
|
|
23809
|
+
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
23810
23810
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
23811
23811
|
const data = {
|
|
23812
23812
|
loading,
|
|
@@ -23822,7 +23822,7 @@ const getFollowers = (params, callback, config) => {
|
|
|
23822
23822
|
}, queryOptions(policy));
|
|
23823
23823
|
};
|
|
23824
23824
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
23825
|
-
onFetch();
|
|
23825
|
+
onFetch(true);
|
|
23826
23826
|
return () => {
|
|
23827
23827
|
log(`getFollowers(tmpid: ${timestamp}) > dispose`);
|
|
23828
23828
|
disposers.forEach(fn => fn());
|
|
@@ -23924,13 +23924,13 @@ const getFollowings = (params, callback, config) => {
|
|
|
23924
23924
|
pushToCache(cacheKey, collection);
|
|
23925
23925
|
responder(collection);
|
|
23926
23926
|
};
|
|
23927
|
-
const onFetch = () => {
|
|
23928
|
-
var _a, _b, _c, _d
|
|
23927
|
+
const onFetch = (initial = false) => {
|
|
23928
|
+
var _a, _b, _c, _d;
|
|
23929
23929
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23930
23930
|
const followings = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23931
|
-
if (followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23931
|
+
if (!initial && followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23932
23932
|
return;
|
|
23933
|
-
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (
|
|
23933
|
+
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
23934
23934
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
23935
23935
|
const data = {
|
|
23936
23936
|
loading,
|
|
@@ -23946,7 +23946,7 @@ const getFollowings = (params, callback, config) => {
|
|
|
23946
23946
|
}, queryOptions(policy));
|
|
23947
23947
|
};
|
|
23948
23948
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
23949
|
-
onFetch();
|
|
23949
|
+
onFetch(true);
|
|
23950
23950
|
return () => {
|
|
23951
23951
|
log(`getFollowings(tmpid: ${timestamp}) > dispose`);
|
|
23952
23952
|
disposers.forEach(fn => fn());
|
|
@@ -24112,6 +24112,86 @@ const updateUser = async (userId, patch) => {
|
|
|
24112
24112
|
};
|
|
24113
24113
|
/* end_public_function */
|
|
24114
24114
|
|
|
24115
|
+
/* begin_public_function
|
|
24116
|
+
id: user.flag
|
|
24117
|
+
*/
|
|
24118
|
+
/**
|
|
24119
|
+
* ```js
|
|
24120
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24121
|
+
* const flagged = await UserRepository.flagUser('userId')
|
|
24122
|
+
* ```
|
|
24123
|
+
*
|
|
24124
|
+
* @param userId The ID of the user to add a be flagged
|
|
24125
|
+
* @returns the created report result
|
|
24126
|
+
*
|
|
24127
|
+
* @category User API
|
|
24128
|
+
* @async
|
|
24129
|
+
* */
|
|
24130
|
+
const flagUser = async (userId) => {
|
|
24131
|
+
const client = getActiveClient();
|
|
24132
|
+
client.log('user/flagUser', userId);
|
|
24133
|
+
const { data: payload } = await client.http.post(`api/v4/me/flags/${encodeURIComponent(userId)}`);
|
|
24134
|
+
if (client.cache) {
|
|
24135
|
+
ingestInCache(payload);
|
|
24136
|
+
}
|
|
24137
|
+
fireEvent('user.flagged', payload);
|
|
24138
|
+
return !!payload;
|
|
24139
|
+
};
|
|
24140
|
+
/* end_public_function */
|
|
24141
|
+
|
|
24142
|
+
/* begin_public_function
|
|
24143
|
+
id: user.unflag
|
|
24144
|
+
*/
|
|
24145
|
+
/**
|
|
24146
|
+
* ```js
|
|
24147
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24148
|
+
* const unflagged = await UserRepository.unflagUser('post', postId)
|
|
24149
|
+
* ```
|
|
24150
|
+
*
|
|
24151
|
+
* @param userId The ID of the user to unflag
|
|
24152
|
+
* @returns the deleted report result
|
|
24153
|
+
*
|
|
24154
|
+
* @category User API
|
|
24155
|
+
* @async
|
|
24156
|
+
* */
|
|
24157
|
+
const unflagUser = async (userId) => {
|
|
24158
|
+
const client = getActiveClient();
|
|
24159
|
+
client.log('user/unflag', userId);
|
|
24160
|
+
const { data: payload } = await client.http.delete(`/api/v4/me/flags/${encodeURIComponent(userId)}`);
|
|
24161
|
+
if (client.cache) {
|
|
24162
|
+
ingestInCache(payload);
|
|
24163
|
+
}
|
|
24164
|
+
fireEvent('user.unflagged', payload);
|
|
24165
|
+
return !!payload;
|
|
24166
|
+
};
|
|
24167
|
+
/* end_public_function */
|
|
24168
|
+
|
|
24169
|
+
/* begin_public_function
|
|
24170
|
+
id: user.check_flag_by_me
|
|
24171
|
+
*/
|
|
24172
|
+
/**
|
|
24173
|
+
* ```js
|
|
24174
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24175
|
+
* const isFlagged = await UserRepository.isUserFlaggedByMe('post', postId)
|
|
24176
|
+
* ```
|
|
24177
|
+
*
|
|
24178
|
+
* @param userId The ID of the thing to check a report to.
|
|
24179
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
24180
|
+
*
|
|
24181
|
+
* @category Report API
|
|
24182
|
+
* @async
|
|
24183
|
+
* */
|
|
24184
|
+
const isUserFlaggedByMe = async (userId) => {
|
|
24185
|
+
var _a, _b;
|
|
24186
|
+
const client = getActiveClient();
|
|
24187
|
+
client.log('user/isUserFlaggedByMe', userId);
|
|
24188
|
+
const { result, isFlagByMe } = (_a = (await synchronousWSCall(client, 'user.isFlagByMe', {
|
|
24189
|
+
userId,
|
|
24190
|
+
}))) !== null && _a !== void 0 ? _a : {};
|
|
24191
|
+
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
24192
|
+
};
|
|
24193
|
+
/* end_public_function */
|
|
24194
|
+
|
|
24115
24195
|
/**
|
|
24116
24196
|
* ```js
|
|
24117
24197
|
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
@@ -24442,7 +24522,7 @@ const getUsers = (params, callback, config) => {
|
|
|
24442
24522
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24443
24523
|
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24444
24524
|
return;
|
|
24445
|
-
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
24525
|
+
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
24446
24526
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
24447
24527
|
const data = {
|
|
24448
24528
|
loading,
|
|
@@ -24511,6 +24591,9 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
24511
24591
|
Relationship: index$h,
|
|
24512
24592
|
getUserByIds: getUserByIds,
|
|
24513
24593
|
updateUser: updateUser,
|
|
24594
|
+
flagUser: flagUser,
|
|
24595
|
+
unflagUser: unflagUser,
|
|
24596
|
+
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
24514
24597
|
onUserUpdated: onUserUpdated,
|
|
24515
24598
|
onUserDeleted: onUserDeleted,
|
|
24516
24599
|
onUserFlagged: onUserFlagged,
|
|
@@ -24586,8 +24669,8 @@ getFile.locally = (fileId) => {
|
|
|
24586
24669
|
*/
|
|
24587
24670
|
/**
|
|
24588
24671
|
* ```js
|
|
24589
|
-
* import {
|
|
24590
|
-
* const created = await
|
|
24672
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24673
|
+
* const created = await FileRepository.uploadFile(formData)
|
|
24591
24674
|
* ```
|
|
24592
24675
|
*
|
|
24593
24676
|
* Creates an {@link Amity.File}
|
|
@@ -24599,9 +24682,9 @@ getFile.locally = (fileId) => {
|
|
|
24599
24682
|
* @category File API
|
|
24600
24683
|
* @async
|
|
24601
24684
|
*/
|
|
24602
|
-
const
|
|
24685
|
+
const uploadFile = async (formData, onProgress) => {
|
|
24603
24686
|
const client = getActiveClient();
|
|
24604
|
-
client.log('file/
|
|
24687
|
+
client.log('file/uploadFile', formData);
|
|
24605
24688
|
if (!formData.getAll('files').length)
|
|
24606
24689
|
throw new Error('The formData object must have a `files` key.');
|
|
24607
24690
|
const headers = 'getHeaders' in formData
|
|
@@ -24623,8 +24706,7 @@ const createFile = async (formData, onProgress) => {
|
|
|
24623
24706
|
cachedAt,
|
|
24624
24707
|
};
|
|
24625
24708
|
};
|
|
24626
|
-
/* end_public_function */
|
|
24627
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24709
|
+
/* end_public_function */
|
|
24628
24710
|
|
|
24629
24711
|
/* begin_public_function
|
|
24630
24712
|
id: file.delete
|
|
@@ -24669,8 +24751,8 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
24669
24751
|
*/
|
|
24670
24752
|
/**
|
|
24671
24753
|
* ```js
|
|
24672
|
-
* import {
|
|
24673
|
-
* const created = await
|
|
24754
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24755
|
+
* const created = await FileRepository.uploadVideo(formData)
|
|
24674
24756
|
* ```
|
|
24675
24757
|
*
|
|
24676
24758
|
* Creates an {@link Amity.File<'video'>}
|
|
@@ -24678,14 +24760,14 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
24678
24760
|
* @param formData The data necessary to create a new {@link Amity.File<'video'>}
|
|
24679
24761
|
* @param feedType The {@link Amity.File<'video'>} feed type
|
|
24680
24762
|
* @param onProgress The callback to track the upload progress
|
|
24681
|
-
* @returns The newly
|
|
24763
|
+
* @returns The newly uploaded {@link Amity.File<'video'>}
|
|
24682
24764
|
*
|
|
24683
24765
|
* @category File API
|
|
24684
24766
|
* @async
|
|
24685
24767
|
*/
|
|
24686
|
-
const
|
|
24768
|
+
const uploadVideo = async (formData, feedType, onProgress) => {
|
|
24687
24769
|
const client = getActiveClient();
|
|
24688
|
-
client.log('file/
|
|
24770
|
+
client.log('file/uploadVideo', formData);
|
|
24689
24771
|
if (!formData.getAll('files').length)
|
|
24690
24772
|
throw new Error('The formData object must have a `files` key.');
|
|
24691
24773
|
if (feedType) {
|
|
@@ -24710,16 +24792,15 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
24710
24792
|
cachedAt,
|
|
24711
24793
|
};
|
|
24712
24794
|
};
|
|
24713
|
-
/* end_public_function */
|
|
24714
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24795
|
+
/* end_public_function */
|
|
24715
24796
|
|
|
24716
24797
|
/* begin_public_function
|
|
24717
24798
|
id: file.upload.image
|
|
24718
24799
|
*/
|
|
24719
24800
|
/**
|
|
24720
24801
|
* ```js
|
|
24721
|
-
* import {
|
|
24722
|
-
* const created = await
|
|
24802
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24803
|
+
* const created = await FileRepository.uploadImage(formData)
|
|
24723
24804
|
* ```
|
|
24724
24805
|
*
|
|
24725
24806
|
* Creates an {@link Amity.File<'image'>}
|
|
@@ -24731,9 +24812,9 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
24731
24812
|
* @category File API
|
|
24732
24813
|
* @async
|
|
24733
24814
|
*/
|
|
24734
|
-
const
|
|
24815
|
+
const uploadImage = async (formData, onProgress) => {
|
|
24735
24816
|
const client = getActiveClient();
|
|
24736
|
-
client.log('file/
|
|
24817
|
+
client.log('file/uploadImage', formData);
|
|
24737
24818
|
if (!formData.getAll('files').length)
|
|
24738
24819
|
throw new Error('The formData object must have a `files` key.');
|
|
24739
24820
|
const headers = 'getHeaders' in formData
|
|
@@ -24755,8 +24836,7 @@ const createImage = async (formData, onProgress) => {
|
|
|
24755
24836
|
cachedAt,
|
|
24756
24837
|
};
|
|
24757
24838
|
};
|
|
24758
|
-
/* end_public_function */
|
|
24759
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24839
|
+
/* end_public_function */
|
|
24760
24840
|
|
|
24761
24841
|
/**
|
|
24762
24842
|
* ```js
|
|
@@ -24799,11 +24879,11 @@ const observeFile = (fileId, callback) => {
|
|
|
24799
24879
|
var index$f = /*#__PURE__*/Object.freeze({
|
|
24800
24880
|
__proto__: null,
|
|
24801
24881
|
getFile: getFile,
|
|
24802
|
-
|
|
24882
|
+
uploadFile: uploadFile,
|
|
24803
24883
|
deleteFile: deleteFile,
|
|
24804
24884
|
fileUrlWithSize: fileUrlWithSize,
|
|
24805
|
-
|
|
24806
|
-
|
|
24885
|
+
uploadVideo: uploadVideo,
|
|
24886
|
+
uploadImage: uploadImage,
|
|
24807
24887
|
observeFile: observeFile
|
|
24808
24888
|
});
|
|
24809
24889
|
|
|
@@ -26068,13 +26148,13 @@ const getReactions = (params, callback, config) => {
|
|
|
26068
26148
|
pushToCache(cacheKey, collection);
|
|
26069
26149
|
responder(collection);
|
|
26070
26150
|
};
|
|
26071
|
-
const onFetch = () => {
|
|
26072
|
-
var _a, _b, _c, _d
|
|
26151
|
+
const onFetch = (initial = false) => {
|
|
26152
|
+
var _a, _b, _c, _d;
|
|
26073
26153
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26074
26154
|
const reactions = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26075
|
-
if (reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26155
|
+
if (!initial && reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26076
26156
|
return;
|
|
26077
|
-
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (
|
|
26157
|
+
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
26078
26158
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
26079
26159
|
const data = {
|
|
26080
26160
|
loading,
|
|
@@ -26092,7 +26172,7 @@ const getReactions = (params, callback, config) => {
|
|
|
26092
26172
|
}, queryOptions(policy));
|
|
26093
26173
|
};
|
|
26094
26174
|
disposers.push(onReactorAdded(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onAdded')), onReactorRemoved(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onRemoved')));
|
|
26095
|
-
onFetch();
|
|
26175
|
+
onFetch(true);
|
|
26096
26176
|
return () => {
|
|
26097
26177
|
log(`liveReactions(tmpid: ${timestamp}) > dispose`);
|
|
26098
26178
|
disposers.forEach(fn => fn());
|
|
@@ -26135,7 +26215,7 @@ var REFERENCE_TYPES = {
|
|
|
26135
26215
|
};
|
|
26136
26216
|
|
|
26137
26217
|
/* begin_public_function
|
|
26138
|
-
id:
|
|
26218
|
+
id: message.flag, post.flag, comment.flag
|
|
26139
26219
|
*/
|
|
26140
26220
|
/**
|
|
26141
26221
|
* ```js
|
|
@@ -27144,7 +27224,7 @@ const getChannels = (params, callback, config) => {
|
|
|
27144
27224
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27145
27225
|
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27146
27226
|
return;
|
|
27147
|
-
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27227
|
+
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27148
27228
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27149
27229
|
const data = {
|
|
27150
27230
|
loading,
|
|
@@ -27422,7 +27502,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27422
27502
|
const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27423
27503
|
if (!initial && channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27424
27504
|
return;
|
|
27425
|
-
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27505
|
+
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27426
27506
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27427
27507
|
const data = {
|
|
27428
27508
|
loading,
|
|
@@ -27817,6 +27897,7 @@ createMessage.optimistically = (_a) => {
|
|
|
27817
27897
|
const updateMessage = async (messageId, patch) => {
|
|
27818
27898
|
const client = getActiveClient();
|
|
27819
27899
|
client.log('message/updateMessage', patch);
|
|
27900
|
+
console.warn('MessageRepository.updateMessage will be replaced with MessageRepository.editMessage');
|
|
27820
27901
|
const { data: payload } = await client.http.put(`/api/v5/messages/${encodeURIComponent(messageId)}`, convertParams(patch));
|
|
27821
27902
|
const data = await prepareMessagePayload(payload);
|
|
27822
27903
|
const cachedAt = client.cache && Date.now();
|
|
@@ -27864,13 +27945,83 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
27864
27945
|
};
|
|
27865
27946
|
/* end_public_function */
|
|
27866
27947
|
|
|
27948
|
+
/* begin_public_function
|
|
27949
|
+
id: message.edit
|
|
27950
|
+
*/
|
|
27951
|
+
/**
|
|
27952
|
+
* ```js
|
|
27953
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
27954
|
+
* const updated = await MessageRepository.editMessage(messageId, {
|
|
27955
|
+
* data: { text: 'hello world' }
|
|
27956
|
+
* })
|
|
27957
|
+
* ```
|
|
27958
|
+
*
|
|
27959
|
+
* Updates an {@link Amity.Message}
|
|
27960
|
+
*
|
|
27961
|
+
* @param messageId The ID of the {@link Amity.Message} to edit
|
|
27962
|
+
* @param patch The patch data to apply
|
|
27963
|
+
* @returns the updated {@link Amity.Message} object
|
|
27964
|
+
*
|
|
27965
|
+
* @category Message API
|
|
27966
|
+
* @async
|
|
27967
|
+
*/
|
|
27968
|
+
const editMessage = async (messageId, patch) => {
|
|
27969
|
+
const client = getActiveClient();
|
|
27970
|
+
client.log('message/editMessage', patch);
|
|
27971
|
+
const { data: payload } = await client.http.put(`/api/v5/messages/${encodeURIComponent(messageId)}`, convertParams(patch));
|
|
27972
|
+
const data = await prepareMessagePayload(payload);
|
|
27973
|
+
const cachedAt = client.cache && Date.now();
|
|
27974
|
+
if (client.cache)
|
|
27975
|
+
ingestInCache(data, { cachedAt });
|
|
27976
|
+
const { messages } = data;
|
|
27977
|
+
fireEvent('local.message.updated', { messages });
|
|
27978
|
+
return {
|
|
27979
|
+
data: messages.find(message => message.messageId === messageId),
|
|
27980
|
+
cachedAt,
|
|
27981
|
+
};
|
|
27982
|
+
};
|
|
27983
|
+
/**
|
|
27984
|
+
* ```js
|
|
27985
|
+
* import { editMessage } from '@amityco/ts-sdk'
|
|
27986
|
+
* const updated = editMessage.optimistically('foobar', {
|
|
27987
|
+
* data: { text: 'hello world' }
|
|
27988
|
+
* })
|
|
27989
|
+
* ```
|
|
27990
|
+
*
|
|
27991
|
+
* Updates an {@link Amity.Message} in cache
|
|
27992
|
+
*
|
|
27993
|
+
* @param messageId The ID of the {@link Amity.Message} to edit
|
|
27994
|
+
* @param patch The patch data to apply
|
|
27995
|
+
* @returns the updated {@link Amity.Message} object
|
|
27996
|
+
*
|
|
27997
|
+
* @category Message API
|
|
27998
|
+
*/
|
|
27999
|
+
editMessage.optimistically = (messageId, patch) => {
|
|
28000
|
+
const client = getActiveClient();
|
|
28001
|
+
client.log('message/editMessage.optimistically', patch);
|
|
28002
|
+
if (!client.cache)
|
|
28003
|
+
return;
|
|
28004
|
+
const message = pullFromCache(['message', 'get', messageId]);
|
|
28005
|
+
if (!message)
|
|
28006
|
+
return;
|
|
28007
|
+
const cachedAt = -1;
|
|
28008
|
+
const edited = Object.assign(Object.assign(Object.assign({}, message.data), patch), { updatedAt: new Date().toISOString() });
|
|
28009
|
+
upsertInCache(['message', 'get', messageId], edited, { cachedAt });
|
|
28010
|
+
fireEvent('local.message.updated', { messages: [edited] });
|
|
28011
|
+
return {
|
|
28012
|
+
data: edited,
|
|
28013
|
+
cachedAt,
|
|
28014
|
+
};
|
|
28015
|
+
};
|
|
28016
|
+
/* end_public_function */
|
|
28017
|
+
|
|
27867
28018
|
/* begin_public_function
|
|
27868
28019
|
id: message.soft_delete
|
|
27869
28020
|
*/
|
|
27870
28021
|
/**
|
|
27871
28022
|
* ```js
|
|
27872
|
-
* import {
|
|
27873
|
-
* const success = await
|
|
28023
|
+
* import { softDeleteMessage } from '@amityco/ts-sdk'
|
|
28024
|
+
* const success = await softDeleteMessage('foobar')
|
|
27874
28025
|
* ```
|
|
27875
28026
|
*
|
|
27876
28027
|
* Delete a {@link Amity.Message}
|
|
@@ -27881,9 +28032,9 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
27881
28032
|
* @category Message API
|
|
27882
28033
|
* @async
|
|
27883
28034
|
*/
|
|
27884
|
-
const
|
|
28035
|
+
const softDeleteMessage = async (messageId) => {
|
|
27885
28036
|
const client = getActiveClient();
|
|
27886
|
-
client.log('message/
|
|
28037
|
+
client.log('message/softDeleteMessage', messageId);
|
|
27887
28038
|
// API-FIX: This endpoint has not been implemented yet.
|
|
27888
28039
|
await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}`);
|
|
27889
28040
|
const deleted = await getMessage$1(messageId);
|
|
@@ -27892,8 +28043,8 @@ const deleteMessage = async (messageId) => {
|
|
|
27892
28043
|
};
|
|
27893
28044
|
/**
|
|
27894
28045
|
* ```js
|
|
27895
|
-
* import {
|
|
27896
|
-
* const success =
|
|
28046
|
+
* import { softDeleteMessage } from '@amityco/ts-sdk'
|
|
28047
|
+
* const success = softDeleteMessage.optimistically('foobar')
|
|
27897
28048
|
* ```
|
|
27898
28049
|
*
|
|
27899
28050
|
* Deletes a {@link Amity.Message}
|
|
@@ -27903,9 +28054,9 @@ const deleteMessage = async (messageId) => {
|
|
|
27903
28054
|
*
|
|
27904
28055
|
* @category Message API
|
|
27905
28056
|
*/
|
|
27906
|
-
|
|
28057
|
+
softDeleteMessage.optimistically = (messageId) => {
|
|
27907
28058
|
const client = getActiveClient();
|
|
27908
|
-
client.log('message/
|
|
28059
|
+
client.log('message/softDeleteMessage.optimistically', messageId);
|
|
27909
28060
|
const message = pullFromCache(['message', 'get', messageId]);
|
|
27910
28061
|
if (!message)
|
|
27911
28062
|
return;
|
|
@@ -28107,6 +28258,85 @@ getDeliveredUsers.locally = (query) => {
|
|
|
28107
28258
|
return { data: users, cachedAt, prevPage, nextPage };
|
|
28108
28259
|
};
|
|
28109
28260
|
|
|
28261
|
+
/* begin_public_function
|
|
28262
|
+
id: message.flag
|
|
28263
|
+
*/
|
|
28264
|
+
/**
|
|
28265
|
+
* ```js
|
|
28266
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28267
|
+
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
28268
|
+
* ```
|
|
28269
|
+
*
|
|
28270
|
+
* @param messageId of the message to flag
|
|
28271
|
+
* @returns the created report result
|
|
28272
|
+
*
|
|
28273
|
+
* @category Message API
|
|
28274
|
+
* @async
|
|
28275
|
+
* */
|
|
28276
|
+
const flagMessage = async (messageId) => {
|
|
28277
|
+
const client = getActiveClient();
|
|
28278
|
+
client.log('message/flag', messageId);
|
|
28279
|
+
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28280
|
+
if (client.cache) {
|
|
28281
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
28282
|
+
ingestInCache(messagePayload);
|
|
28283
|
+
}
|
|
28284
|
+
fireEvent('message.flagged', payload);
|
|
28285
|
+
return !!payload;
|
|
28286
|
+
};
|
|
28287
|
+
/* end_public_function */
|
|
28288
|
+
|
|
28289
|
+
/* begin_public_function
|
|
28290
|
+
id: message.unflag
|
|
28291
|
+
*/
|
|
28292
|
+
/**
|
|
28293
|
+
* ```js
|
|
28294
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28295
|
+
* const unflagged = await MessageRepository.unflag(messageId)
|
|
28296
|
+
* ```
|
|
28297
|
+
*
|
|
28298
|
+
* @param messageId of the message to unflag
|
|
28299
|
+
* @returns boolean to indicate success
|
|
28300
|
+
*
|
|
28301
|
+
* @category Report API
|
|
28302
|
+
* @async
|
|
28303
|
+
* */
|
|
28304
|
+
const unflagMessage = async (messageId) => {
|
|
28305
|
+
const client = getActiveClient();
|
|
28306
|
+
client.log('message/unflag', messageId);
|
|
28307
|
+
const { data: payload } = await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28308
|
+
if (client.cache) {
|
|
28309
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
28310
|
+
ingestInCache(messagePayload);
|
|
28311
|
+
}
|
|
28312
|
+
fireEvent('message.unflagged', payload);
|
|
28313
|
+
return !!payload;
|
|
28314
|
+
};
|
|
28315
|
+
/* end_public_function */
|
|
28316
|
+
|
|
28317
|
+
/* begin_public_function
|
|
28318
|
+
id: message.check_flag_by_me
|
|
28319
|
+
*/
|
|
28320
|
+
/**
|
|
28321
|
+
* ```js
|
|
28322
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28323
|
+
* const isReportedByMe = await MessageRepository.isMessageFlaggedByMe(messageId)
|
|
28324
|
+
* ```
|
|
28325
|
+
*
|
|
28326
|
+
* @param messageId of the message to check a report of.
|
|
28327
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
28328
|
+
*
|
|
28329
|
+
* @category Report API
|
|
28330
|
+
* @async
|
|
28331
|
+
* */
|
|
28332
|
+
const isMessageFlaggedByMe = async (messageId) => {
|
|
28333
|
+
const client = getActiveClient();
|
|
28334
|
+
client.log('message/isMessageFlaggedByMe', messageId);
|
|
28335
|
+
const { data } = await client.http.get(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28336
|
+
return data.result;
|
|
28337
|
+
};
|
|
28338
|
+
/* end_public_function */
|
|
28339
|
+
|
|
28110
28340
|
/* begin_public_function
|
|
28111
28341
|
id: message.get
|
|
28112
28342
|
*/
|
|
@@ -28254,13 +28484,13 @@ const getMessages = (params, callback, config) => {
|
|
|
28254
28484
|
pushToCache(cacheKey, collection);
|
|
28255
28485
|
responder(collection);
|
|
28256
28486
|
};
|
|
28257
|
-
const onFetch = () => {
|
|
28258
|
-
var _a, _b, _c, _d
|
|
28487
|
+
const onFetch = (initial = false) => {
|
|
28488
|
+
var _a, _b, _c, _d;
|
|
28259
28489
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28260
28490
|
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28261
|
-
if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28491
|
+
if (!initial && messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28262
28492
|
return;
|
|
28263
|
-
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (
|
|
28493
|
+
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
28264
28494
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
28265
28495
|
const data = {
|
|
28266
28496
|
loading,
|
|
@@ -28276,7 +28506,7 @@ const getMessages = (params, callback, config) => {
|
|
|
28276
28506
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
28277
28507
|
};
|
|
28278
28508
|
disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()));
|
|
28279
|
-
onFetch();
|
|
28509
|
+
onFetch(true);
|
|
28280
28510
|
disposers.push(() => dropFromCache(cacheKey));
|
|
28281
28511
|
return () => {
|
|
28282
28512
|
log(`getMessages(tmpid: ${timestamp}) > dispose`);
|
|
@@ -28375,10 +28605,14 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
28375
28605
|
getMessageByIds: getMessages$1,
|
|
28376
28606
|
createMessage: createMessage,
|
|
28377
28607
|
updateMessage: updateMessage,
|
|
28378
|
-
|
|
28608
|
+
editMessage: editMessage,
|
|
28609
|
+
softDeleteMessage: softDeleteMessage,
|
|
28379
28610
|
markAsDelivered: markAsDelivered,
|
|
28380
28611
|
getReadUsers: getReadUsers,
|
|
28381
28612
|
getDeliveredUsers: getDeliveredUsers,
|
|
28613
|
+
flagMessage: flagMessage,
|
|
28614
|
+
unflagMessage: unflagMessage,
|
|
28615
|
+
isMessageFlaggedByMe: isMessageFlaggedByMe,
|
|
28382
28616
|
onMessageCreated: onMessageCreated,
|
|
28383
28617
|
onMessageUpdated: onMessageUpdated,
|
|
28384
28618
|
onMessageDeleted: onMessageDeleted,
|
|
@@ -29764,7 +29998,7 @@ const getCommunities = (params, callback, config) => {
|
|
|
29764
29998
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29765
29999
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29766
30000
|
return;
|
|
29767
|
-
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30001
|
+
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29768
30002
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29769
30003
|
const data = {
|
|
29770
30004
|
loading,
|
|
@@ -29825,144 +30059,82 @@ const getCommunity = (communityId, callback) => {
|
|
|
29825
30059
|
/* end_public_function */
|
|
29826
30060
|
|
|
29827
30061
|
/* begin_public_function
|
|
29828
|
-
id: community.
|
|
30062
|
+
id: community.moderation.add_roles
|
|
29829
30063
|
*/
|
|
29830
30064
|
/**
|
|
29831
30065
|
* ```js
|
|
29832
30066
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29833
|
-
* const updated = await CommunityRepository.moderation.
|
|
30067
|
+
* const updated = await CommunityRepository.moderation.addRoles(communityId, ['foo', 'bar'])
|
|
29834
30068
|
* ```
|
|
29835
30069
|
*
|
|
29836
|
-
* Adds a list of {@link Amity.
|
|
30070
|
+
* Adds a list of {@link Amity.Role} to a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29837
30071
|
*
|
|
29838
30072
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
29839
|
-
* @param
|
|
29840
|
-
* @
|
|
30073
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
30074
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
30075
|
+
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
29841
30076
|
*
|
|
29842
30077
|
* @category Community API
|
|
29843
30078
|
* @async
|
|
29844
30079
|
*/
|
|
29845
|
-
const
|
|
30080
|
+
const addRoles = async (communityId, roleIds, userIds) => {
|
|
29846
30081
|
const client = getActiveClient();
|
|
29847
|
-
client.log('community/moderation/
|
|
29848
|
-
const { data: payload } = await client.http.post(`/api/
|
|
29849
|
-
fireEvent('community.userAdded', payload);
|
|
30082
|
+
client.log('community/moderation/addRoles', communityId, roleIds, userIds);
|
|
30083
|
+
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
29850
30084
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29851
30085
|
if (client.cache)
|
|
29852
30086
|
ingestInCache(data);
|
|
29853
30087
|
const { communityUsers } = data;
|
|
29854
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30088
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30089
|
+
roleIds.some(role => communityUser.roles.includes(role)));
|
|
29855
30090
|
};
|
|
29856
30091
|
/* end_public_function */
|
|
29857
30092
|
|
|
29858
30093
|
/* begin_public_function
|
|
29859
|
-
id: community.
|
|
30094
|
+
id: community.moderation.remove_roles
|
|
29860
30095
|
*/
|
|
29861
30096
|
/**
|
|
29862
30097
|
* ```js
|
|
29863
30098
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29864
|
-
* const updated = await CommunityRepository.moderation.
|
|
30099
|
+
* const updated = await CommunityRepository.moderation.removeRoles(communityId, ['foo', 'bar'])
|
|
29865
30100
|
* ```
|
|
29866
30101
|
*
|
|
29867
|
-
* Removes a list of {@link Amity.
|
|
30102
|
+
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29868
30103
|
*
|
|
29869
|
-
* @param communityId The ID of the {@link Amity.Community} to
|
|
29870
|
-
* @param
|
|
29871
|
-
* @
|
|
30104
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
30105
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
30106
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
30107
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
29872
30108
|
*
|
|
29873
30109
|
* @category Community API
|
|
29874
30110
|
* @async
|
|
29875
30111
|
*/
|
|
29876
|
-
const
|
|
30112
|
+
const removeRoles = async (communityId, roleIds, userIds) => {
|
|
29877
30113
|
const client = getActiveClient();
|
|
29878
|
-
client.log('community/moderation/
|
|
29879
|
-
const { data: payload } = await client.http.delete(`/api/
|
|
29880
|
-
fireEvent('community.userRemoved', payload);
|
|
30114
|
+
client.log('community/moderation/removeRoles', communityId, roleIds, userIds);
|
|
30115
|
+
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
29881
30116
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29882
30117
|
if (client.cache)
|
|
29883
30118
|
ingestInCache(data);
|
|
29884
30119
|
const { communityUsers } = data;
|
|
29885
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30120
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30121
|
+
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
29886
30122
|
};
|
|
29887
30123
|
/* end_public_function */
|
|
29888
30124
|
|
|
29889
30125
|
/* begin_public_function
|
|
29890
|
-
id: community.moderation.
|
|
30126
|
+
id: community.moderation.ban_members
|
|
29891
30127
|
*/
|
|
29892
30128
|
/**
|
|
29893
30129
|
* ```js
|
|
29894
30130
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29895
|
-
*
|
|
30131
|
+
*
|
|
30132
|
+
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
29896
30133
|
* ```
|
|
29897
30134
|
*
|
|
29898
|
-
*
|
|
29899
|
-
*
|
|
29900
|
-
* @
|
|
29901
|
-
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
29902
|
-
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
29903
|
-
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
29904
|
-
*
|
|
29905
|
-
* @category Community API
|
|
29906
|
-
* @async
|
|
29907
|
-
*/
|
|
29908
|
-
const addRoles = async (communityId, roleIds, userIds) => {
|
|
29909
|
-
const client = getActiveClient();
|
|
29910
|
-
client.log('community/moderation/addRoles', communityId, roleIds, userIds);
|
|
29911
|
-
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
29912
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29913
|
-
if (client.cache)
|
|
29914
|
-
ingestInCache(data);
|
|
29915
|
-
const { communityUsers } = data;
|
|
29916
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
29917
|
-
roleIds.some(role => communityUser.roles.includes(role)));
|
|
29918
|
-
};
|
|
29919
|
-
/* end_public_function */
|
|
29920
|
-
|
|
29921
|
-
/* begin_public_function
|
|
29922
|
-
id: community.moderation.remove_roles
|
|
29923
|
-
*/
|
|
29924
|
-
/**
|
|
29925
|
-
* ```js
|
|
29926
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29927
|
-
* const updated = await CommunityRepository.moderation.removeRoles(communityId, ['foo', 'bar'])
|
|
29928
|
-
* ```
|
|
29929
|
-
*
|
|
29930
|
-
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29931
|
-
*
|
|
29932
|
-
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
29933
|
-
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
29934
|
-
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
29935
|
-
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
29936
|
-
*
|
|
29937
|
-
* @category Community API
|
|
29938
|
-
* @async
|
|
29939
|
-
*/
|
|
29940
|
-
const removeRoles = async (communityId, roleIds, userIds) => {
|
|
29941
|
-
const client = getActiveClient();
|
|
29942
|
-
client.log('community/moderation/removeRoles', communityId, roleIds, userIds);
|
|
29943
|
-
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
29944
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29945
|
-
if (client.cache)
|
|
29946
|
-
ingestInCache(data);
|
|
29947
|
-
const { communityUsers } = data;
|
|
29948
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
29949
|
-
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
29950
|
-
};
|
|
29951
|
-
/* end_public_function */
|
|
29952
|
-
|
|
29953
|
-
/* begin_public_function
|
|
29954
|
-
id: community.moderation.ban_members
|
|
29955
|
-
*/
|
|
29956
|
-
/**
|
|
29957
|
-
* ```js
|
|
29958
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29959
|
-
*
|
|
29960
|
-
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
29961
|
-
* ```
|
|
29962
|
-
*
|
|
29963
|
-
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
29964
|
-
* @param userIds of the {@link Amity.User}'s to be banned
|
|
29965
|
-
* @returns the updated {@link Amity.Membership}'s object
|
|
30135
|
+
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
30136
|
+
* @param userIds of the {@link Amity.User}'s to be banned
|
|
30137
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
29966
30138
|
*
|
|
29967
30139
|
* @category Community API
|
|
29968
30140
|
* @async
|
|
@@ -30022,14 +30194,74 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
30022
30194
|
|
|
30023
30195
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
30024
30196
|
__proto__: null,
|
|
30025
|
-
addMembers: addMembers,
|
|
30026
|
-
removeMembers: removeMembers,
|
|
30027
30197
|
addRoles: addRoles,
|
|
30028
30198
|
removeRoles: removeRoles,
|
|
30029
30199
|
banMembers: banMembers,
|
|
30030
30200
|
unbanMembers: unbanMembers
|
|
30031
30201
|
});
|
|
30032
30202
|
|
|
30203
|
+
/* begin_public_function
|
|
30204
|
+
id: community.membership.add_members
|
|
30205
|
+
*/
|
|
30206
|
+
/**
|
|
30207
|
+
* ```js
|
|
30208
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30209
|
+
* const updated = await CommunityRepository.moderation.addMembers(communityId, ['foo', 'bar'])
|
|
30210
|
+
* ```
|
|
30211
|
+
*
|
|
30212
|
+
* Adds a list of {@link Amity.User} to a {@link Amity.Community} to add users to
|
|
30213
|
+
*
|
|
30214
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
30215
|
+
* @param userIds The list of IDs {@link Amity.User} to add
|
|
30216
|
+
* @returns A success boolean if the {@link Amity.User} were added to the {@link Amity.Community}
|
|
30217
|
+
*
|
|
30218
|
+
* @category Community API
|
|
30219
|
+
* @async
|
|
30220
|
+
*/
|
|
30221
|
+
const addMembers = async (communityId, userIds) => {
|
|
30222
|
+
const client = getActiveClient();
|
|
30223
|
+
client.log('community/moderation/addMembers', communityId, userIds);
|
|
30224
|
+
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
30225
|
+
fireEvent('community.userAdded', payload);
|
|
30226
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30227
|
+
if (client.cache)
|
|
30228
|
+
ingestInCache(data);
|
|
30229
|
+
const { communityUsers } = data;
|
|
30230
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
30231
|
+
};
|
|
30232
|
+
/* end_public_function */
|
|
30233
|
+
|
|
30234
|
+
/* begin_public_function
|
|
30235
|
+
id: community.membership.remove_member
|
|
30236
|
+
*/
|
|
30237
|
+
/**
|
|
30238
|
+
* ```js
|
|
30239
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30240
|
+
* const updated = await CommunityRepository.moderation.removeMembers(communityId, ['foo', 'bar'])
|
|
30241
|
+
* ```
|
|
30242
|
+
*
|
|
30243
|
+
* Removes a list of {@link Amity.User} from a {@link Amity.Community}
|
|
30244
|
+
*
|
|
30245
|
+
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
30246
|
+
* @param userIds The list of IDs {@link Amity.User} to remove
|
|
30247
|
+
* @returns A success boolean if the list of {@link Amity.User} were removed from the {@link Amity.Community}
|
|
30248
|
+
*
|
|
30249
|
+
* @category Community API
|
|
30250
|
+
* @async
|
|
30251
|
+
*/
|
|
30252
|
+
const removeMembers = async (communityId, userIds) => {
|
|
30253
|
+
const client = getActiveClient();
|
|
30254
|
+
client.log('community/moderation/removeMembers', communityId, userIds);
|
|
30255
|
+
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
30256
|
+
fireEvent('community.userRemoved', payload);
|
|
30257
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30258
|
+
if (client.cache)
|
|
30259
|
+
ingestInCache(data);
|
|
30260
|
+
const { communityUsers } = data;
|
|
30261
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
30262
|
+
};
|
|
30263
|
+
/* end_public_function */
|
|
30264
|
+
|
|
30033
30265
|
/**
|
|
30034
30266
|
* ```js
|
|
30035
30267
|
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -30192,7 +30424,7 @@ const getMembers = (params, callback, config) => {
|
|
|
30192
30424
|
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30193
30425
|
if (!initial && communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30194
30426
|
return;
|
|
30195
|
-
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30427
|
+
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30196
30428
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30197
30429
|
const data = {
|
|
30198
30430
|
loading,
|
|
@@ -30220,6 +30452,8 @@ const getMembers = (params, callback, config) => {
|
|
|
30220
30452
|
|
|
30221
30453
|
var index$7 = /*#__PURE__*/Object.freeze({
|
|
30222
30454
|
__proto__: null,
|
|
30455
|
+
addMembers: addMembers,
|
|
30456
|
+
removeMembers: removeMembers,
|
|
30223
30457
|
getMembers: getMembers,
|
|
30224
30458
|
onCommunityUserAdded: onCommunityUserAdded,
|
|
30225
30459
|
onCommunityUserRemoved: onCommunityUserRemoved,
|
|
@@ -30450,7 +30684,7 @@ const getCategories = (params, callback, config) => {
|
|
|
30450
30684
|
const categories = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30451
30685
|
if (!initial && categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30452
30686
|
return;
|
|
30453
|
-
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30687
|
+
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30454
30688
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30455
30689
|
const data = {
|
|
30456
30690
|
loading,
|
|
@@ -30571,9 +30805,94 @@ queryGlobalFeed.locally = (query) => {
|
|
|
30571
30805
|
: undefined;
|
|
30572
30806
|
};
|
|
30573
30807
|
|
|
30808
|
+
/* begin_public_function
|
|
30809
|
+
id: feed.query.custom_ranking_feed
|
|
30810
|
+
*/
|
|
30811
|
+
/**
|
|
30812
|
+
* ```js
|
|
30813
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
30814
|
+
* const posts = await FeedRepository.getCustomRankingGlobalFeed()
|
|
30815
|
+
* ```
|
|
30816
|
+
*
|
|
30817
|
+
* Queries a paginable list of {@link Amity.Post} objects
|
|
30818
|
+
*
|
|
30819
|
+
* @param query The query parameters
|
|
30820
|
+
* @returns A page of {@link Amity.Post} objects
|
|
30821
|
+
*
|
|
30822
|
+
* @category Feed API
|
|
30823
|
+
* @async
|
|
30824
|
+
* */
|
|
30825
|
+
const getCustomRankingGlobalFeed = async (query) => {
|
|
30826
|
+
const client = getActiveClient();
|
|
30827
|
+
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
30828
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
30829
|
+
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
30830
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
30831
|
+
token: toToken(page, 'skiplimit'),
|
|
30832
|
+
} }),
|
|
30833
|
+
});
|
|
30834
|
+
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
30835
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30836
|
+
const { posts } = data;
|
|
30837
|
+
const cachedAt = client.cache && Date.now();
|
|
30838
|
+
if (client.cache) {
|
|
30839
|
+
ingestInCache(data);
|
|
30840
|
+
const cacheKey = [
|
|
30841
|
+
'customGlobalFeed',
|
|
30842
|
+
'query',
|
|
30843
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30844
|
+
];
|
|
30845
|
+
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
30846
|
+
}
|
|
30847
|
+
const nextPage = toPage(paging.next);
|
|
30848
|
+
const prevPage = toPage(paging.previous);
|
|
30849
|
+
return { data: posts, cachedAt, prevPage, nextPage };
|
|
30850
|
+
};
|
|
30851
|
+
/* end_public_function */
|
|
30852
|
+
/**
|
|
30853
|
+
* ```js
|
|
30854
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
30855
|
+
* const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
|
|
30856
|
+
* ```
|
|
30857
|
+
*
|
|
30858
|
+
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
30859
|
+
*
|
|
30860
|
+
* @param query The query parameters
|
|
30861
|
+
* @returns A page of {@link Amity.Post} objects
|
|
30862
|
+
*
|
|
30863
|
+
* @category Feed API
|
|
30864
|
+
* @async
|
|
30865
|
+
* */
|
|
30866
|
+
getCustomRankingGlobalFeed.locally = (query) => {
|
|
30867
|
+
var _a, _b;
|
|
30868
|
+
const client = getActiveClient();
|
|
30869
|
+
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
30870
|
+
if (!client.cache)
|
|
30871
|
+
return;
|
|
30872
|
+
const _c = query !== null && query !== void 0 ? query : {}, { page } = _c, params = __rest(_c, ["page"]);
|
|
30873
|
+
const queryKey = [
|
|
30874
|
+
'customGlobalFeed',
|
|
30875
|
+
'query',
|
|
30876
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30877
|
+
];
|
|
30878
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
30879
|
+
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
30880
|
+
return;
|
|
30881
|
+
const posts = data.posts
|
|
30882
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30883
|
+
.filter(Boolean)
|
|
30884
|
+
.map(({ data }) => data);
|
|
30885
|
+
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
30886
|
+
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
30887
|
+
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
30888
|
+
? { data: posts, cachedAt, prevPage, nextPage }
|
|
30889
|
+
: undefined;
|
|
30890
|
+
};
|
|
30891
|
+
|
|
30574
30892
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
30575
30893
|
__proto__: null,
|
|
30576
|
-
queryGlobalFeed: queryGlobalFeed
|
|
30894
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
30895
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
30577
30896
|
});
|
|
30578
30897
|
|
|
30579
30898
|
/* begin_public_function
|
|
@@ -30720,6 +31039,7 @@ const createPost = async (bundle) => {
|
|
|
30720
31039
|
const updatePost = async (postId, patch) => {
|
|
30721
31040
|
const client = getActiveClient();
|
|
30722
31041
|
client.log('user/updatePost', patch);
|
|
31042
|
+
console.warn('Deprecation: updatePost has been renamed to editPost. Update post API will be deprecated soon.');
|
|
30723
31043
|
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
30724
31044
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30725
31045
|
const cachedAt = client.cache && Date.now();
|
|
@@ -30735,8 +31055,42 @@ const updatePost = async (postId, patch) => {
|
|
|
30735
31055
|
/* end_public_function */
|
|
30736
31056
|
|
|
30737
31057
|
/* begin_public_function
|
|
30738
|
-
id: post.
|
|
31058
|
+
id: post.edit
|
|
30739
31059
|
*/
|
|
31060
|
+
/**
|
|
31061
|
+
* ```js
|
|
31062
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31063
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
31064
|
+
* data: { text: 'hello world' }
|
|
31065
|
+
* })
|
|
31066
|
+
* ```
|
|
31067
|
+
*
|
|
31068
|
+
* Updates an {@link Amity.Post}
|
|
31069
|
+
*
|
|
31070
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
31071
|
+
* @param patch The patch data to apply
|
|
31072
|
+
* @returns the updated {@link Amity.Post} object
|
|
31073
|
+
*
|
|
31074
|
+
* @category Post API
|
|
31075
|
+
* @async
|
|
31076
|
+
*/
|
|
31077
|
+
const editPost = async (postId, patch) => {
|
|
31078
|
+
const client = getActiveClient();
|
|
31079
|
+
client.log('user/editPost', patch);
|
|
31080
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
31081
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
31082
|
+
const cachedAt = client.cache && Date.now();
|
|
31083
|
+
if (client.cache)
|
|
31084
|
+
ingestInCache(data, { cachedAt });
|
|
31085
|
+
fireEvent('post.updated', data);
|
|
31086
|
+
const { posts } = data;
|
|
31087
|
+
return {
|
|
31088
|
+
data: posts.find(post => post.postId === postId),
|
|
31089
|
+
cachedAt,
|
|
31090
|
+
};
|
|
31091
|
+
};
|
|
31092
|
+
/* end_public_function */
|
|
31093
|
+
|
|
30740
31094
|
/**
|
|
30741
31095
|
* ```js
|
|
30742
31096
|
* import { deletePost } from '@amityco/ts-sdk'
|
|
@@ -30748,14 +31102,12 @@ const updatePost = async (postId, patch) => {
|
|
|
30748
31102
|
* @param postId The {@link Amity.Post} ID to delete
|
|
30749
31103
|
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
30750
31104
|
*
|
|
30751
|
-
* @
|
|
31105
|
+
* @private
|
|
30752
31106
|
* @async
|
|
30753
31107
|
*/
|
|
30754
31108
|
const deletePost = async (postId, permanent = false) => {
|
|
30755
31109
|
const client = getActiveClient();
|
|
30756
|
-
client.log('post/deletePost', postId);
|
|
30757
31110
|
const post = await getPost$1(postId);
|
|
30758
|
-
// API-FIX: This endpoint has not been implemented yet.
|
|
30759
31111
|
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
30760
31112
|
params: {
|
|
30761
31113
|
postId,
|
|
@@ -30799,6 +31151,55 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
30799
31151
|
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
30800
31152
|
}
|
|
30801
31153
|
return deleted;
|
|
31154
|
+
};
|
|
31155
|
+
|
|
31156
|
+
/* begin_public_function
|
|
31157
|
+
id: post.soft_delete
|
|
31158
|
+
*/
|
|
31159
|
+
/**
|
|
31160
|
+
* ```js
|
|
31161
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31162
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
31163
|
+
* ```
|
|
31164
|
+
*
|
|
31165
|
+
* Soft deletes a {@link Amity.Post}
|
|
31166
|
+
*
|
|
31167
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
31168
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
31169
|
+
*
|
|
31170
|
+
* @category Post API
|
|
31171
|
+
* @async
|
|
31172
|
+
*/
|
|
31173
|
+
const softDeletePost = async (postId) => {
|
|
31174
|
+
const client = getActiveClient();
|
|
31175
|
+
client.log('post/softDeletePost', postId);
|
|
31176
|
+
const softDeleted = await deletePost(postId, false);
|
|
31177
|
+
return softDeleted;
|
|
31178
|
+
};
|
|
31179
|
+
/* end_public_function */
|
|
31180
|
+
|
|
31181
|
+
/* begin_public_function
|
|
31182
|
+
id: post.hard_delete
|
|
31183
|
+
*/
|
|
31184
|
+
/**
|
|
31185
|
+
* ```js
|
|
31186
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
31187
|
+
* const success = await hardDeletePost('foobar')
|
|
31188
|
+
* ```
|
|
31189
|
+
*
|
|
31190
|
+
* Hard deletes a {@link Amity.Post}
|
|
31191
|
+
*
|
|
31192
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
31193
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
31194
|
+
*
|
|
31195
|
+
* @category Post API
|
|
31196
|
+
* @async
|
|
31197
|
+
*/
|
|
31198
|
+
const hardDeletePost = async (postId) => {
|
|
31199
|
+
const client = getActiveClient();
|
|
31200
|
+
client.log('post/hardDeletePost', postId);
|
|
31201
|
+
const hardDeleted = await deletePost(postId, true);
|
|
31202
|
+
return hardDeleted;
|
|
30802
31203
|
};
|
|
30803
31204
|
/* end_public_function */
|
|
30804
31205
|
|
|
@@ -30878,6 +31279,86 @@ const declinePost = async (postId) => {
|
|
|
30878
31279
|
};
|
|
30879
31280
|
/* end_public_function */
|
|
30880
31281
|
|
|
31282
|
+
/* begin_public_function
|
|
31283
|
+
id: post.flag
|
|
31284
|
+
*/
|
|
31285
|
+
/**
|
|
31286
|
+
* ```js
|
|
31287
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31288
|
+
* const flagged = await PostRepository.flagPost(postId)
|
|
31289
|
+
* ```
|
|
31290
|
+
*
|
|
31291
|
+
* @param postId of the post to flag
|
|
31292
|
+
* @returns a boolean
|
|
31293
|
+
*
|
|
31294
|
+
* @category Post API
|
|
31295
|
+
* @async
|
|
31296
|
+
* */
|
|
31297
|
+
const flagPost = async (postId) => {
|
|
31298
|
+
const client = getActiveClient();
|
|
31299
|
+
client.log('post/flagPost', postId);
|
|
31300
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
|
|
31301
|
+
if (client.cache) {
|
|
31302
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31303
|
+
}
|
|
31304
|
+
fireEvent('post.flagged', payload);
|
|
31305
|
+
return !!payload;
|
|
31306
|
+
};
|
|
31307
|
+
/* end_public_function */
|
|
31308
|
+
|
|
31309
|
+
/* begin_public_function
|
|
31310
|
+
id: post.unflag
|
|
31311
|
+
*/
|
|
31312
|
+
/**
|
|
31313
|
+
* ```js
|
|
31314
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31315
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
31316
|
+
* ```
|
|
31317
|
+
*
|
|
31318
|
+
* @param postId of the post to unflag
|
|
31319
|
+
* @returns the unflag post result
|
|
31320
|
+
*
|
|
31321
|
+
* @category Post API
|
|
31322
|
+
* @async
|
|
31323
|
+
* */
|
|
31324
|
+
const unflagPost = async (postId) => {
|
|
31325
|
+
const client = getActiveClient();
|
|
31326
|
+
client.log('post/unflagPost', postId);
|
|
31327
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
31328
|
+
if (client.cache) {
|
|
31329
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31330
|
+
}
|
|
31331
|
+
fireEvent('post.unflagged', payload);
|
|
31332
|
+
return !!payload;
|
|
31333
|
+
};
|
|
31334
|
+
/* end_public_function */
|
|
31335
|
+
|
|
31336
|
+
/* begin_public_function
|
|
31337
|
+
id: post.check_flag_by_me
|
|
31338
|
+
*/
|
|
31339
|
+
/**
|
|
31340
|
+
* ```js
|
|
31341
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31342
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
31343
|
+
* ```
|
|
31344
|
+
*
|
|
31345
|
+
* @param postId of the post to check if flagged by current user
|
|
31346
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
31347
|
+
*
|
|
31348
|
+
* @category Post API
|
|
31349
|
+
* @async
|
|
31350
|
+
* */
|
|
31351
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
31352
|
+
var _a, _b;
|
|
31353
|
+
const client = getActiveClient();
|
|
31354
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
31355
|
+
const { result, isFlagByMe } = (_a = (await synchronousWSCall(client, 'v3/post.isflagbyme', {
|
|
31356
|
+
postId,
|
|
31357
|
+
}))) !== null && _a !== void 0 ? _a : {};
|
|
31358
|
+
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
31359
|
+
};
|
|
31360
|
+
/* end_public_function */
|
|
31361
|
+
|
|
30881
31362
|
/**
|
|
30882
31363
|
* ```js
|
|
30883
31364
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
@@ -31171,13 +31652,13 @@ const getPosts = (params, callback, config) => {
|
|
|
31171
31652
|
disposers.push(() => dropFromCache(cacheKey));
|
|
31172
31653
|
responder(collection);
|
|
31173
31654
|
};
|
|
31174
|
-
const onFetch = () => {
|
|
31175
|
-
var _a, _b, _c, _d
|
|
31655
|
+
const onFetch = (initial = false) => {
|
|
31656
|
+
var _a, _b, _c, _d;
|
|
31176
31657
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31177
31658
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31178
|
-
if (posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31659
|
+
if (!initial && posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31179
31660
|
return;
|
|
31180
|
-
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (
|
|
31661
|
+
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
31181
31662
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
31182
31663
|
const data = {
|
|
31183
31664
|
loading,
|
|
@@ -31193,7 +31674,7 @@ const getPosts = (params, callback, config) => {
|
|
|
31193
31674
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
31194
31675
|
};
|
|
31195
31676
|
disposers.push(onPostCreated(realtimeRouter('onCreate')), onPostApproved(realtimeRouter('onApproved')), onPostDeclined(realtimeRouter('onDeclined')), onPostDeleted(realtimeRouter('onDelete')), onPostUpdated(realtimeRouter('onUpdate')), onPostFlagged(realtimeRouter('onFlagged')), onPostUnflagged(realtimeRouter('onUnflagged')), onPostReactionAdded(realtimeRouter('onReactionAdded')), onPostReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
31196
|
-
onFetch();
|
|
31677
|
+
onFetch(true);
|
|
31197
31678
|
return () => {
|
|
31198
31679
|
log(`getPosts(tmpid: ${timestamp}) > dispose`);
|
|
31199
31680
|
disposers.forEach(fn => fn());
|
|
@@ -31206,9 +31687,15 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
31206
31687
|
getPostByIds: getPostByIds,
|
|
31207
31688
|
createPost: createPost,
|
|
31208
31689
|
updatePost: updatePost,
|
|
31690
|
+
editPost: editPost,
|
|
31209
31691
|
deletePost: deletePost,
|
|
31692
|
+
softDeletePost: softDeletePost,
|
|
31693
|
+
hardDeletePost: hardDeletePost,
|
|
31210
31694
|
approvePost: approvePost,
|
|
31211
31695
|
declinePost: declinePost,
|
|
31696
|
+
flagPost: flagPost,
|
|
31697
|
+
unflagPost: unflagPost,
|
|
31698
|
+
isPostFlaggedByMe: isPostFlaggedByMe,
|
|
31212
31699
|
onPostCreated: onPostCreated,
|
|
31213
31700
|
onPostUpdated: onPostUpdated,
|
|
31214
31701
|
onPostDeleted: onPostDeleted,
|
|
@@ -31714,13 +32201,13 @@ const getComments = (params, callback, config) => {
|
|
|
31714
32201
|
pushToCache(cacheKey, collection);
|
|
31715
32202
|
responder(collection);
|
|
31716
32203
|
};
|
|
31717
|
-
const onFetch = () => {
|
|
31718
|
-
var _a, _b, _c, _d
|
|
32204
|
+
const onFetch = (initial = false) => {
|
|
32205
|
+
var _a, _b, _c, _d;
|
|
31719
32206
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31720
32207
|
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31721
|
-
if (comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
32208
|
+
if (!initial && comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31722
32209
|
return;
|
|
31723
|
-
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (
|
|
32210
|
+
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (_d = (!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined)) !== null && _d !== void 0 ? _d : { limit } }));
|
|
31724
32211
|
runQuery(query, ({ data: result, error, loading, prevPage, nextPage }) => {
|
|
31725
32212
|
// depend on sortBy value we have two different pagination type
|
|
31726
32213
|
const page = queryParams.sortBy ? nextPage : prevPage;
|
|
@@ -31738,7 +32225,7 @@ const getComments = (params, callback, config) => {
|
|
|
31738
32225
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
31739
32226
|
};
|
|
31740
32227
|
disposers.push(onCommentCreated(realtimeRouter('onCreate')), onCommentUpdated(realtimeRouter('onUpdate')), onCommentDeleted(realtimeRouter('onDelete')), onCommentFlagged(realtimeRouter('onFlagged')), onCommentUnflagged(realtimeRouter('onUnflagged')), onCommentReactionAdded(realtimeRouter('onReactionAdded')), onCommentReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
31741
|
-
onFetch();
|
|
32228
|
+
onFetch(true);
|
|
31742
32229
|
return () => {
|
|
31743
32230
|
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
31744
32231
|
disposers.forEach(fn => fn());
|