@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.cjs.js
CHANGED
|
@@ -23144,15 +23144,15 @@ const getBlockedUsers$1 = (params, callback, config) => {
|
|
|
23144
23144
|
* observers
|
|
23145
23145
|
*};
|
|
23146
23146
|
*/
|
|
23147
|
-
const onFetch = () => {
|
|
23147
|
+
const onFetch = (initial = false) => {
|
|
23148
23148
|
var _a, _b;
|
|
23149
23149
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23150
23150
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23151
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
23151
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
23152
23152
|
return;
|
|
23153
23153
|
const query = createQuery(queryBlockedUsers, {
|
|
23154
23154
|
limit,
|
|
23155
|
-
token: toToken(collection === null || collection === void 0 ? void 0 : collection.params.page, 'afterbeforeraw'),
|
|
23155
|
+
token: toToken(!initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined, 'afterbeforeraw'),
|
|
23156
23156
|
});
|
|
23157
23157
|
runQuery(query,
|
|
23158
23158
|
// @ts-ignore
|
|
@@ -23173,7 +23173,7 @@ const getBlockedUsers$1 = (params, callback, config) => {
|
|
|
23173
23173
|
disposers.push(() => {
|
|
23174
23174
|
// @TODO -> update once observers added
|
|
23175
23175
|
});
|
|
23176
|
-
onFetch();
|
|
23176
|
+
onFetch(true);
|
|
23177
23177
|
return () => {
|
|
23178
23178
|
log(`getCategories(tmpid: ${timestamp}) > dispose`);
|
|
23179
23179
|
disposers.forEach(fn => fn());
|
|
@@ -23814,13 +23814,13 @@ const getFollowers = (params, callback, config) => {
|
|
|
23814
23814
|
pushToCache(cacheKey, collection);
|
|
23815
23815
|
responder(collection);
|
|
23816
23816
|
};
|
|
23817
|
-
const onFetch = () => {
|
|
23818
|
-
var _a, _b, _c, _d
|
|
23817
|
+
const onFetch = (initial = false) => {
|
|
23818
|
+
var _a, _b, _c, _d;
|
|
23819
23819
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23820
23820
|
const followers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23821
|
-
if (followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23821
|
+
if (!initial && followers.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23822
23822
|
return;
|
|
23823
|
-
const query = createQuery(queryFollowers, Object.assign(Object.assign({}, queryParams), { page: (
|
|
23823
|
+
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 } }));
|
|
23824
23824
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
23825
23825
|
const data = {
|
|
23826
23826
|
loading,
|
|
@@ -23836,7 +23836,7 @@ const getFollowers = (params, callback, config) => {
|
|
|
23836
23836
|
}, queryOptions(policy));
|
|
23837
23837
|
};
|
|
23838
23838
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
23839
|
-
onFetch();
|
|
23839
|
+
onFetch(true);
|
|
23840
23840
|
return () => {
|
|
23841
23841
|
log(`getFollowers(tmpid: ${timestamp}) > dispose`);
|
|
23842
23842
|
disposers.forEach(fn => fn());
|
|
@@ -23938,13 +23938,13 @@ const getFollowings = (params, callback, config) => {
|
|
|
23938
23938
|
pushToCache(cacheKey, collection);
|
|
23939
23939
|
responder(collection);
|
|
23940
23940
|
};
|
|
23941
|
-
const onFetch = () => {
|
|
23942
|
-
var _a, _b, _c, _d
|
|
23941
|
+
const onFetch = (initial = false) => {
|
|
23942
|
+
var _a, _b, _c, _d;
|
|
23943
23943
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
23944
23944
|
const followings = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
23945
|
-
if (followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23945
|
+
if (!initial && followings.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
23946
23946
|
return;
|
|
23947
|
-
const query = createQuery(queryFollowings, Object.assign(Object.assign({}, queryParams), { page: (
|
|
23947
|
+
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 } }));
|
|
23948
23948
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
23949
23949
|
const data = {
|
|
23950
23950
|
loading,
|
|
@@ -23960,7 +23960,7 @@ const getFollowings = (params, callback, config) => {
|
|
|
23960
23960
|
}, queryOptions(policy));
|
|
23961
23961
|
};
|
|
23962
23962
|
disposers.push(onFollowerRequested(realtimeRouter('onRequested')), onFollowRequestAccepted(realtimeRouter('onAccepted')), onFollowRequestDeclined(realtimeRouter('onDeclined')), onFollowRequestCanceled(realtimeRouter('onCanceled')), onUserFollowed(realtimeRouter('onFollowed')), onUserUnfollowed(realtimeRouter('onUnfollowed')), onFollowerDeleted(realtimeRouter('onDeleted')));
|
|
23963
|
-
onFetch();
|
|
23963
|
+
onFetch(true);
|
|
23964
23964
|
return () => {
|
|
23965
23965
|
log(`getFollowings(tmpid: ${timestamp}) > dispose`);
|
|
23966
23966
|
disposers.forEach(fn => fn());
|
|
@@ -24126,6 +24126,86 @@ const updateUser = async (userId, patch) => {
|
|
|
24126
24126
|
};
|
|
24127
24127
|
/* end_public_function */
|
|
24128
24128
|
|
|
24129
|
+
/* begin_public_function
|
|
24130
|
+
id: user.flag
|
|
24131
|
+
*/
|
|
24132
|
+
/**
|
|
24133
|
+
* ```js
|
|
24134
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24135
|
+
* const flagged = await UserRepository.flagUser('userId')
|
|
24136
|
+
* ```
|
|
24137
|
+
*
|
|
24138
|
+
* @param userId The ID of the user to add a be flagged
|
|
24139
|
+
* @returns the created report result
|
|
24140
|
+
*
|
|
24141
|
+
* @category User API
|
|
24142
|
+
* @async
|
|
24143
|
+
* */
|
|
24144
|
+
const flagUser = async (userId) => {
|
|
24145
|
+
const client = getActiveClient();
|
|
24146
|
+
client.log('user/flagUser', userId);
|
|
24147
|
+
const { data: payload } = await client.http.post(`api/v4/me/flags/${encodeURIComponent(userId)}`);
|
|
24148
|
+
if (client.cache) {
|
|
24149
|
+
ingestInCache(payload);
|
|
24150
|
+
}
|
|
24151
|
+
fireEvent('user.flagged', payload);
|
|
24152
|
+
return !!payload;
|
|
24153
|
+
};
|
|
24154
|
+
/* end_public_function */
|
|
24155
|
+
|
|
24156
|
+
/* begin_public_function
|
|
24157
|
+
id: user.unflag
|
|
24158
|
+
*/
|
|
24159
|
+
/**
|
|
24160
|
+
* ```js
|
|
24161
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24162
|
+
* const unflagged = await UserRepository.unflagUser('post', postId)
|
|
24163
|
+
* ```
|
|
24164
|
+
*
|
|
24165
|
+
* @param userId The ID of the user to unflag
|
|
24166
|
+
* @returns the deleted report result
|
|
24167
|
+
*
|
|
24168
|
+
* @category User API
|
|
24169
|
+
* @async
|
|
24170
|
+
* */
|
|
24171
|
+
const unflagUser = async (userId) => {
|
|
24172
|
+
const client = getActiveClient();
|
|
24173
|
+
client.log('user/unflag', userId);
|
|
24174
|
+
const { data: payload } = await client.http.delete(`/api/v4/me/flags/${encodeURIComponent(userId)}`);
|
|
24175
|
+
if (client.cache) {
|
|
24176
|
+
ingestInCache(payload);
|
|
24177
|
+
}
|
|
24178
|
+
fireEvent('user.unflagged', payload);
|
|
24179
|
+
return !!payload;
|
|
24180
|
+
};
|
|
24181
|
+
/* end_public_function */
|
|
24182
|
+
|
|
24183
|
+
/* begin_public_function
|
|
24184
|
+
id: user.check_flag_by_me
|
|
24185
|
+
*/
|
|
24186
|
+
/**
|
|
24187
|
+
* ```js
|
|
24188
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
24189
|
+
* const isFlagged = await UserRepository.isUserFlaggedByMe('post', postId)
|
|
24190
|
+
* ```
|
|
24191
|
+
*
|
|
24192
|
+
* @param userId The ID of the thing to check a report to.
|
|
24193
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
24194
|
+
*
|
|
24195
|
+
* @category Report API
|
|
24196
|
+
* @async
|
|
24197
|
+
* */
|
|
24198
|
+
const isUserFlaggedByMe = async (userId) => {
|
|
24199
|
+
var _a, _b;
|
|
24200
|
+
const client = getActiveClient();
|
|
24201
|
+
client.log('user/isUserFlaggedByMe', userId);
|
|
24202
|
+
const { result, isFlagByMe } = (_a = (await synchronousWSCall(client, 'user.isFlagByMe', {
|
|
24203
|
+
userId,
|
|
24204
|
+
}))) !== null && _a !== void 0 ? _a : {};
|
|
24205
|
+
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
24206
|
+
};
|
|
24207
|
+
/* end_public_function */
|
|
24208
|
+
|
|
24129
24209
|
/**
|
|
24130
24210
|
* ```js
|
|
24131
24211
|
* import { onUserUpdated } from '@amityco/ts-sdk'
|
|
@@ -24456,7 +24536,7 @@ const getUsers = (params, callback, config) => {
|
|
|
24456
24536
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24457
24537
|
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24458
24538
|
return;
|
|
24459
|
-
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 } }));
|
|
24539
|
+
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 } }));
|
|
24460
24540
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
24461
24541
|
const data = {
|
|
24462
24542
|
loading,
|
|
@@ -24525,6 +24605,9 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
24525
24605
|
Relationship: index$h,
|
|
24526
24606
|
getUserByIds: getUserByIds,
|
|
24527
24607
|
updateUser: updateUser,
|
|
24608
|
+
flagUser: flagUser,
|
|
24609
|
+
unflagUser: unflagUser,
|
|
24610
|
+
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
24528
24611
|
onUserUpdated: onUserUpdated,
|
|
24529
24612
|
onUserDeleted: onUserDeleted,
|
|
24530
24613
|
onUserFlagged: onUserFlagged,
|
|
@@ -24600,8 +24683,8 @@ getFile.locally = (fileId) => {
|
|
|
24600
24683
|
*/
|
|
24601
24684
|
/**
|
|
24602
24685
|
* ```js
|
|
24603
|
-
* import {
|
|
24604
|
-
* const created = await
|
|
24686
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24687
|
+
* const created = await FileRepository.uploadFile(formData)
|
|
24605
24688
|
* ```
|
|
24606
24689
|
*
|
|
24607
24690
|
* Creates an {@link Amity.File}
|
|
@@ -24613,9 +24696,9 @@ getFile.locally = (fileId) => {
|
|
|
24613
24696
|
* @category File API
|
|
24614
24697
|
* @async
|
|
24615
24698
|
*/
|
|
24616
|
-
const
|
|
24699
|
+
const uploadFile = async (formData, onProgress) => {
|
|
24617
24700
|
const client = getActiveClient();
|
|
24618
|
-
client.log('file/
|
|
24701
|
+
client.log('file/uploadFile', formData);
|
|
24619
24702
|
if (!formData.getAll('files').length)
|
|
24620
24703
|
throw new Error('The formData object must have a `files` key.');
|
|
24621
24704
|
const headers = 'getHeaders' in formData
|
|
@@ -24637,8 +24720,7 @@ const createFile = async (formData, onProgress) => {
|
|
|
24637
24720
|
cachedAt,
|
|
24638
24721
|
};
|
|
24639
24722
|
};
|
|
24640
|
-
/* end_public_function */
|
|
24641
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24723
|
+
/* end_public_function */
|
|
24642
24724
|
|
|
24643
24725
|
/* begin_public_function
|
|
24644
24726
|
id: file.delete
|
|
@@ -24683,8 +24765,8 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
24683
24765
|
*/
|
|
24684
24766
|
/**
|
|
24685
24767
|
* ```js
|
|
24686
|
-
* import {
|
|
24687
|
-
* const created = await
|
|
24768
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24769
|
+
* const created = await FileRepository.uploadVideo(formData)
|
|
24688
24770
|
* ```
|
|
24689
24771
|
*
|
|
24690
24772
|
* Creates an {@link Amity.File<'video'>}
|
|
@@ -24692,14 +24774,14 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
24692
24774
|
* @param formData The data necessary to create a new {@link Amity.File<'video'>}
|
|
24693
24775
|
* @param feedType The {@link Amity.File<'video'>} feed type
|
|
24694
24776
|
* @param onProgress The callback to track the upload progress
|
|
24695
|
-
* @returns The newly
|
|
24777
|
+
* @returns The newly uploaded {@link Amity.File<'video'>}
|
|
24696
24778
|
*
|
|
24697
24779
|
* @category File API
|
|
24698
24780
|
* @async
|
|
24699
24781
|
*/
|
|
24700
|
-
const
|
|
24782
|
+
const uploadVideo = async (formData, feedType, onProgress) => {
|
|
24701
24783
|
const client = getActiveClient();
|
|
24702
|
-
client.log('file/
|
|
24784
|
+
client.log('file/uploadVideo', formData);
|
|
24703
24785
|
if (!formData.getAll('files').length)
|
|
24704
24786
|
throw new Error('The formData object must have a `files` key.');
|
|
24705
24787
|
if (feedType) {
|
|
@@ -24724,16 +24806,15 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
24724
24806
|
cachedAt,
|
|
24725
24807
|
};
|
|
24726
24808
|
};
|
|
24727
|
-
/* end_public_function */
|
|
24728
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24809
|
+
/* end_public_function */
|
|
24729
24810
|
|
|
24730
24811
|
/* begin_public_function
|
|
24731
24812
|
id: file.upload.image
|
|
24732
24813
|
*/
|
|
24733
24814
|
/**
|
|
24734
24815
|
* ```js
|
|
24735
|
-
* import {
|
|
24736
|
-
* const created = await
|
|
24816
|
+
* import { FileRepository } from '@amityco/ts-sdk'
|
|
24817
|
+
* const created = await FileRepository.uploadImage(formData)
|
|
24737
24818
|
* ```
|
|
24738
24819
|
*
|
|
24739
24820
|
* Creates an {@link Amity.File<'image'>}
|
|
@@ -24745,9 +24826,9 @@ const createVideo = async (formData, feedType, onProgress) => {
|
|
|
24745
24826
|
* @category File API
|
|
24746
24827
|
* @async
|
|
24747
24828
|
*/
|
|
24748
|
-
const
|
|
24829
|
+
const uploadImage = async (formData, onProgress) => {
|
|
24749
24830
|
const client = getActiveClient();
|
|
24750
|
-
client.log('file/
|
|
24831
|
+
client.log('file/uploadImage', formData);
|
|
24751
24832
|
if (!formData.getAll('files').length)
|
|
24752
24833
|
throw new Error('The formData object must have a `files` key.');
|
|
24753
24834
|
const headers = 'getHeaders' in formData
|
|
@@ -24769,8 +24850,7 @@ const createImage = async (formData, onProgress) => {
|
|
|
24769
24850
|
cachedAt,
|
|
24770
24851
|
};
|
|
24771
24852
|
};
|
|
24772
|
-
/* end_public_function */
|
|
24773
|
-
// TODO: consider doing local creation with URL.createObjectURL()
|
|
24853
|
+
/* end_public_function */
|
|
24774
24854
|
|
|
24775
24855
|
/**
|
|
24776
24856
|
* ```js
|
|
@@ -24813,11 +24893,11 @@ const observeFile = (fileId, callback) => {
|
|
|
24813
24893
|
var index$f = /*#__PURE__*/Object.freeze({
|
|
24814
24894
|
__proto__: null,
|
|
24815
24895
|
getFile: getFile,
|
|
24816
|
-
|
|
24896
|
+
uploadFile: uploadFile,
|
|
24817
24897
|
deleteFile: deleteFile,
|
|
24818
24898
|
fileUrlWithSize: fileUrlWithSize,
|
|
24819
|
-
|
|
24820
|
-
|
|
24899
|
+
uploadVideo: uploadVideo,
|
|
24900
|
+
uploadImage: uploadImage,
|
|
24821
24901
|
observeFile: observeFile
|
|
24822
24902
|
});
|
|
24823
24903
|
|
|
@@ -26082,13 +26162,13 @@ const getReactions = (params, callback, config) => {
|
|
|
26082
26162
|
pushToCache(cacheKey, collection);
|
|
26083
26163
|
responder(collection);
|
|
26084
26164
|
};
|
|
26085
|
-
const onFetch = () => {
|
|
26086
|
-
var _a, _b, _c, _d
|
|
26165
|
+
const onFetch = (initial = false) => {
|
|
26166
|
+
var _a, _b, _c, _d;
|
|
26087
26167
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
26088
26168
|
const reactions = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
26089
|
-
if (reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26169
|
+
if (!initial && reactions.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
26090
26170
|
return;
|
|
26091
|
-
const query = createQuery(queryReactions, Object.assign(Object.assign({}, queryParams), { page: (
|
|
26171
|
+
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 } }));
|
|
26092
26172
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
26093
26173
|
const data = {
|
|
26094
26174
|
loading,
|
|
@@ -26106,7 +26186,7 @@ const getReactions = (params, callback, config) => {
|
|
|
26106
26186
|
}, queryOptions(policy));
|
|
26107
26187
|
};
|
|
26108
26188
|
disposers.push(onReactorAdded(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onAdded')), onReactorRemoved(queryParams.referenceType, queryParams.referenceId, realtimeRouter('onRemoved')));
|
|
26109
|
-
onFetch();
|
|
26189
|
+
onFetch(true);
|
|
26110
26190
|
return () => {
|
|
26111
26191
|
log(`liveReactions(tmpid: ${timestamp}) > dispose`);
|
|
26112
26192
|
disposers.forEach(fn => fn());
|
|
@@ -26149,7 +26229,7 @@ var REFERENCE_TYPES = {
|
|
|
26149
26229
|
};
|
|
26150
26230
|
|
|
26151
26231
|
/* begin_public_function
|
|
26152
|
-
id:
|
|
26232
|
+
id: message.flag, post.flag, comment.flag
|
|
26153
26233
|
*/
|
|
26154
26234
|
/**
|
|
26155
26235
|
* ```js
|
|
@@ -27158,7 +27238,7 @@ const getChannels = (params, callback, config) => {
|
|
|
27158
27238
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27159
27239
|
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27160
27240
|
return;
|
|
27161
|
-
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 } }));
|
|
27241
|
+
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 } }));
|
|
27162
27242
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27163
27243
|
const data = {
|
|
27164
27244
|
loading,
|
|
@@ -27436,7 +27516,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27436
27516
|
const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27437
27517
|
if (!initial && channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27438
27518
|
return;
|
|
27439
|
-
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 } }));
|
|
27519
|
+
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 } }));
|
|
27440
27520
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
27441
27521
|
const data = {
|
|
27442
27522
|
loading,
|
|
@@ -27831,6 +27911,7 @@ createMessage.optimistically = (_a) => {
|
|
|
27831
27911
|
const updateMessage = async (messageId, patch) => {
|
|
27832
27912
|
const client = getActiveClient();
|
|
27833
27913
|
client.log('message/updateMessage', patch);
|
|
27914
|
+
console.warn('MessageRepository.updateMessage will be replaced with MessageRepository.editMessage');
|
|
27834
27915
|
const { data: payload } = await client.http.put(`/api/v5/messages/${encodeURIComponent(messageId)}`, convertParams(patch));
|
|
27835
27916
|
const data = await prepareMessagePayload(payload);
|
|
27836
27917
|
const cachedAt = client.cache && Date.now();
|
|
@@ -27878,13 +27959,83 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
27878
27959
|
};
|
|
27879
27960
|
/* end_public_function */
|
|
27880
27961
|
|
|
27962
|
+
/* begin_public_function
|
|
27963
|
+
id: message.edit
|
|
27964
|
+
*/
|
|
27965
|
+
/**
|
|
27966
|
+
* ```js
|
|
27967
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
27968
|
+
* const updated = await MessageRepository.editMessage(messageId, {
|
|
27969
|
+
* data: { text: 'hello world' }
|
|
27970
|
+
* })
|
|
27971
|
+
* ```
|
|
27972
|
+
*
|
|
27973
|
+
* Updates an {@link Amity.Message}
|
|
27974
|
+
*
|
|
27975
|
+
* @param messageId The ID of the {@link Amity.Message} to edit
|
|
27976
|
+
* @param patch The patch data to apply
|
|
27977
|
+
* @returns the updated {@link Amity.Message} object
|
|
27978
|
+
*
|
|
27979
|
+
* @category Message API
|
|
27980
|
+
* @async
|
|
27981
|
+
*/
|
|
27982
|
+
const editMessage = async (messageId, patch) => {
|
|
27983
|
+
const client = getActiveClient();
|
|
27984
|
+
client.log('message/editMessage', patch);
|
|
27985
|
+
const { data: payload } = await client.http.put(`/api/v5/messages/${encodeURIComponent(messageId)}`, convertParams(patch));
|
|
27986
|
+
const data = await prepareMessagePayload(payload);
|
|
27987
|
+
const cachedAt = client.cache && Date.now();
|
|
27988
|
+
if (client.cache)
|
|
27989
|
+
ingestInCache(data, { cachedAt });
|
|
27990
|
+
const { messages } = data;
|
|
27991
|
+
fireEvent('local.message.updated', { messages });
|
|
27992
|
+
return {
|
|
27993
|
+
data: messages.find(message => message.messageId === messageId),
|
|
27994
|
+
cachedAt,
|
|
27995
|
+
};
|
|
27996
|
+
};
|
|
27997
|
+
/**
|
|
27998
|
+
* ```js
|
|
27999
|
+
* import { editMessage } from '@amityco/ts-sdk'
|
|
28000
|
+
* const updated = editMessage.optimistically('foobar', {
|
|
28001
|
+
* data: { text: 'hello world' }
|
|
28002
|
+
* })
|
|
28003
|
+
* ```
|
|
28004
|
+
*
|
|
28005
|
+
* Updates an {@link Amity.Message} in cache
|
|
28006
|
+
*
|
|
28007
|
+
* @param messageId The ID of the {@link Amity.Message} to edit
|
|
28008
|
+
* @param patch The patch data to apply
|
|
28009
|
+
* @returns the updated {@link Amity.Message} object
|
|
28010
|
+
*
|
|
28011
|
+
* @category Message API
|
|
28012
|
+
*/
|
|
28013
|
+
editMessage.optimistically = (messageId, patch) => {
|
|
28014
|
+
const client = getActiveClient();
|
|
28015
|
+
client.log('message/editMessage.optimistically', patch);
|
|
28016
|
+
if (!client.cache)
|
|
28017
|
+
return;
|
|
28018
|
+
const message = pullFromCache(['message', 'get', messageId]);
|
|
28019
|
+
if (!message)
|
|
28020
|
+
return;
|
|
28021
|
+
const cachedAt = -1;
|
|
28022
|
+
const edited = Object.assign(Object.assign(Object.assign({}, message.data), patch), { updatedAt: new Date().toISOString() });
|
|
28023
|
+
upsertInCache(['message', 'get', messageId], edited, { cachedAt });
|
|
28024
|
+
fireEvent('local.message.updated', { messages: [edited] });
|
|
28025
|
+
return {
|
|
28026
|
+
data: edited,
|
|
28027
|
+
cachedAt,
|
|
28028
|
+
};
|
|
28029
|
+
};
|
|
28030
|
+
/* end_public_function */
|
|
28031
|
+
|
|
27881
28032
|
/* begin_public_function
|
|
27882
28033
|
id: message.soft_delete
|
|
27883
28034
|
*/
|
|
27884
28035
|
/**
|
|
27885
28036
|
* ```js
|
|
27886
|
-
* import {
|
|
27887
|
-
* const success = await
|
|
28037
|
+
* import { softDeleteMessage } from '@amityco/ts-sdk'
|
|
28038
|
+
* const success = await softDeleteMessage('foobar')
|
|
27888
28039
|
* ```
|
|
27889
28040
|
*
|
|
27890
28041
|
* Delete a {@link Amity.Message}
|
|
@@ -27895,9 +28046,9 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
27895
28046
|
* @category Message API
|
|
27896
28047
|
* @async
|
|
27897
28048
|
*/
|
|
27898
|
-
const
|
|
28049
|
+
const softDeleteMessage = async (messageId) => {
|
|
27899
28050
|
const client = getActiveClient();
|
|
27900
|
-
client.log('message/
|
|
28051
|
+
client.log('message/softDeleteMessage', messageId);
|
|
27901
28052
|
// API-FIX: This endpoint has not been implemented yet.
|
|
27902
28053
|
await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}`);
|
|
27903
28054
|
const deleted = await getMessage$1(messageId);
|
|
@@ -27906,8 +28057,8 @@ const deleteMessage = async (messageId) => {
|
|
|
27906
28057
|
};
|
|
27907
28058
|
/**
|
|
27908
28059
|
* ```js
|
|
27909
|
-
* import {
|
|
27910
|
-
* const success =
|
|
28060
|
+
* import { softDeleteMessage } from '@amityco/ts-sdk'
|
|
28061
|
+
* const success = softDeleteMessage.optimistically('foobar')
|
|
27911
28062
|
* ```
|
|
27912
28063
|
*
|
|
27913
28064
|
* Deletes a {@link Amity.Message}
|
|
@@ -27917,9 +28068,9 @@ const deleteMessage = async (messageId) => {
|
|
|
27917
28068
|
*
|
|
27918
28069
|
* @category Message API
|
|
27919
28070
|
*/
|
|
27920
|
-
|
|
28071
|
+
softDeleteMessage.optimistically = (messageId) => {
|
|
27921
28072
|
const client = getActiveClient();
|
|
27922
|
-
client.log('message/
|
|
28073
|
+
client.log('message/softDeleteMessage.optimistically', messageId);
|
|
27923
28074
|
const message = pullFromCache(['message', 'get', messageId]);
|
|
27924
28075
|
if (!message)
|
|
27925
28076
|
return;
|
|
@@ -28121,6 +28272,85 @@ getDeliveredUsers.locally = (query) => {
|
|
|
28121
28272
|
return { data: users, cachedAt, prevPage, nextPage };
|
|
28122
28273
|
};
|
|
28123
28274
|
|
|
28275
|
+
/* begin_public_function
|
|
28276
|
+
id: message.flag
|
|
28277
|
+
*/
|
|
28278
|
+
/**
|
|
28279
|
+
* ```js
|
|
28280
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28281
|
+
* const flagged = await MessageRepository.flagMessage(messageId)
|
|
28282
|
+
* ```
|
|
28283
|
+
*
|
|
28284
|
+
* @param messageId of the message to flag
|
|
28285
|
+
* @returns the created report result
|
|
28286
|
+
*
|
|
28287
|
+
* @category Message API
|
|
28288
|
+
* @async
|
|
28289
|
+
* */
|
|
28290
|
+
const flagMessage = async (messageId) => {
|
|
28291
|
+
const client = getActiveClient();
|
|
28292
|
+
client.log('message/flag', messageId);
|
|
28293
|
+
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28294
|
+
if (client.cache) {
|
|
28295
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
28296
|
+
ingestInCache(messagePayload);
|
|
28297
|
+
}
|
|
28298
|
+
fireEvent('message.flagged', payload);
|
|
28299
|
+
return !!payload;
|
|
28300
|
+
};
|
|
28301
|
+
/* end_public_function */
|
|
28302
|
+
|
|
28303
|
+
/* begin_public_function
|
|
28304
|
+
id: message.unflag
|
|
28305
|
+
*/
|
|
28306
|
+
/**
|
|
28307
|
+
* ```js
|
|
28308
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28309
|
+
* const unflagged = await MessageRepository.unflag(messageId)
|
|
28310
|
+
* ```
|
|
28311
|
+
*
|
|
28312
|
+
* @param messageId of the message to unflag
|
|
28313
|
+
* @returns boolean to indicate success
|
|
28314
|
+
*
|
|
28315
|
+
* @category Report API
|
|
28316
|
+
* @async
|
|
28317
|
+
* */
|
|
28318
|
+
const unflagMessage = async (messageId) => {
|
|
28319
|
+
const client = getActiveClient();
|
|
28320
|
+
client.log('message/unflag', messageId);
|
|
28321
|
+
const { data: payload } = await client.http.delete(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28322
|
+
if (client.cache) {
|
|
28323
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
28324
|
+
ingestInCache(messagePayload);
|
|
28325
|
+
}
|
|
28326
|
+
fireEvent('message.unflagged', payload);
|
|
28327
|
+
return !!payload;
|
|
28328
|
+
};
|
|
28329
|
+
/* end_public_function */
|
|
28330
|
+
|
|
28331
|
+
/* begin_public_function
|
|
28332
|
+
id: message.check_flag_by_me
|
|
28333
|
+
*/
|
|
28334
|
+
/**
|
|
28335
|
+
* ```js
|
|
28336
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
28337
|
+
* const isReportedByMe = await MessageRepository.isMessageFlaggedByMe(messageId)
|
|
28338
|
+
* ```
|
|
28339
|
+
*
|
|
28340
|
+
* @param messageId of the message to check a report of.
|
|
28341
|
+
* @returns `true` if the report is created by me, `false` if doesn't.
|
|
28342
|
+
*
|
|
28343
|
+
* @category Report API
|
|
28344
|
+
* @async
|
|
28345
|
+
* */
|
|
28346
|
+
const isMessageFlaggedByMe = async (messageId) => {
|
|
28347
|
+
const client = getActiveClient();
|
|
28348
|
+
client.log('message/isMessageFlaggedByMe', messageId);
|
|
28349
|
+
const { data } = await client.http.get(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
|
|
28350
|
+
return data.result;
|
|
28351
|
+
};
|
|
28352
|
+
/* end_public_function */
|
|
28353
|
+
|
|
28124
28354
|
/* begin_public_function
|
|
28125
28355
|
id: message.get
|
|
28126
28356
|
*/
|
|
@@ -28268,13 +28498,13 @@ const getMessages = (params, callback, config) => {
|
|
|
28268
28498
|
pushToCache(cacheKey, collection);
|
|
28269
28499
|
responder(collection);
|
|
28270
28500
|
};
|
|
28271
|
-
const onFetch = () => {
|
|
28272
|
-
var _a, _b, _c, _d
|
|
28501
|
+
const onFetch = (initial = false) => {
|
|
28502
|
+
var _a, _b, _c, _d;
|
|
28273
28503
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28274
28504
|
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28275
|
-
if (messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28505
|
+
if (!initial && messages.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
28276
28506
|
return;
|
|
28277
|
-
const query = createQuery(queryMessages, Object.assign(Object.assign({}, queryParams), { page: (
|
|
28507
|
+
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 } }));
|
|
28278
28508
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
28279
28509
|
const data = {
|
|
28280
28510
|
loading,
|
|
@@ -28290,7 +28520,7 @@ const getMessages = (params, callback, config) => {
|
|
|
28290
28520
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
28291
28521
|
};
|
|
28292
28522
|
disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()));
|
|
28293
|
-
onFetch();
|
|
28523
|
+
onFetch(true);
|
|
28294
28524
|
disposers.push(() => dropFromCache(cacheKey));
|
|
28295
28525
|
return () => {
|
|
28296
28526
|
log(`getMessages(tmpid: ${timestamp}) > dispose`);
|
|
@@ -28389,10 +28619,14 @@ var index$a = /*#__PURE__*/Object.freeze({
|
|
|
28389
28619
|
getMessageByIds: getMessages$1,
|
|
28390
28620
|
createMessage: createMessage,
|
|
28391
28621
|
updateMessage: updateMessage,
|
|
28392
|
-
|
|
28622
|
+
editMessage: editMessage,
|
|
28623
|
+
softDeleteMessage: softDeleteMessage,
|
|
28393
28624
|
markAsDelivered: markAsDelivered,
|
|
28394
28625
|
getReadUsers: getReadUsers,
|
|
28395
28626
|
getDeliveredUsers: getDeliveredUsers,
|
|
28627
|
+
flagMessage: flagMessage,
|
|
28628
|
+
unflagMessage: unflagMessage,
|
|
28629
|
+
isMessageFlaggedByMe: isMessageFlaggedByMe,
|
|
28396
28630
|
onMessageCreated: onMessageCreated,
|
|
28397
28631
|
onMessageUpdated: onMessageUpdated,
|
|
28398
28632
|
onMessageDeleted: onMessageDeleted,
|
|
@@ -29778,7 +30012,7 @@ const getCommunities = (params, callback, config) => {
|
|
|
29778
30012
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29779
30013
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29780
30014
|
return;
|
|
29781
|
-
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 } }));
|
|
30015
|
+
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 } }));
|
|
29782
30016
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
29783
30017
|
const data = {
|
|
29784
30018
|
loading,
|
|
@@ -29839,144 +30073,82 @@ const getCommunity = (communityId, callback) => {
|
|
|
29839
30073
|
/* end_public_function */
|
|
29840
30074
|
|
|
29841
30075
|
/* begin_public_function
|
|
29842
|
-
id: community.
|
|
30076
|
+
id: community.moderation.add_roles
|
|
29843
30077
|
*/
|
|
29844
30078
|
/**
|
|
29845
30079
|
* ```js
|
|
29846
30080
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29847
|
-
* const updated = await CommunityRepository.moderation.
|
|
30081
|
+
* const updated = await CommunityRepository.moderation.addRoles(communityId, ['foo', 'bar'])
|
|
29848
30082
|
* ```
|
|
29849
30083
|
*
|
|
29850
|
-
* Adds a list of {@link Amity.
|
|
30084
|
+
* Adds a list of {@link Amity.Role} to a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29851
30085
|
*
|
|
29852
30086
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
29853
|
-
* @param
|
|
29854
|
-
* @
|
|
30087
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
30088
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
30089
|
+
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
29855
30090
|
*
|
|
29856
30091
|
* @category Community API
|
|
29857
30092
|
* @async
|
|
29858
30093
|
*/
|
|
29859
|
-
const
|
|
30094
|
+
const addRoles = async (communityId, roleIds, userIds) => {
|
|
29860
30095
|
const client = getActiveClient();
|
|
29861
|
-
client.log('community/moderation/
|
|
29862
|
-
const { data: payload } = await client.http.post(`/api/
|
|
29863
|
-
fireEvent('community.userAdded', payload);
|
|
30096
|
+
client.log('community/moderation/addRoles', communityId, roleIds, userIds);
|
|
30097
|
+
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
29864
30098
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29865
30099
|
if (client.cache)
|
|
29866
30100
|
ingestInCache(data);
|
|
29867
30101
|
const { communityUsers } = data;
|
|
29868
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30102
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30103
|
+
roleIds.some(role => communityUser.roles.includes(role)));
|
|
29869
30104
|
};
|
|
29870
30105
|
/* end_public_function */
|
|
29871
30106
|
|
|
29872
30107
|
/* begin_public_function
|
|
29873
|
-
id: community.
|
|
30108
|
+
id: community.moderation.remove_roles
|
|
29874
30109
|
*/
|
|
29875
30110
|
/**
|
|
29876
30111
|
* ```js
|
|
29877
30112
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29878
|
-
* const updated = await CommunityRepository.moderation.
|
|
30113
|
+
* const updated = await CommunityRepository.moderation.removeRoles(communityId, ['foo', 'bar'])
|
|
29879
30114
|
* ```
|
|
29880
30115
|
*
|
|
29881
|
-
* Removes a list of {@link Amity.
|
|
30116
|
+
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29882
30117
|
*
|
|
29883
|
-
* @param communityId The ID of the {@link Amity.Community} to
|
|
29884
|
-
* @param
|
|
29885
|
-
* @
|
|
30118
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
30119
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
30120
|
+
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
30121
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
29886
30122
|
*
|
|
29887
30123
|
* @category Community API
|
|
29888
30124
|
* @async
|
|
29889
30125
|
*/
|
|
29890
|
-
const
|
|
30126
|
+
const removeRoles = async (communityId, roleIds, userIds) => {
|
|
29891
30127
|
const client = getActiveClient();
|
|
29892
|
-
client.log('community/moderation/
|
|
29893
|
-
const { data: payload } = await client.http.delete(`/api/
|
|
29894
|
-
fireEvent('community.userRemoved', payload);
|
|
30128
|
+
client.log('community/moderation/removeRoles', communityId, roleIds, userIds);
|
|
30129
|
+
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
29895
30130
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29896
30131
|
if (client.cache)
|
|
29897
30132
|
ingestInCache(data);
|
|
29898
30133
|
const { communityUsers } = data;
|
|
29899
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30134
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
30135
|
+
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
29900
30136
|
};
|
|
29901
30137
|
/* end_public_function */
|
|
29902
30138
|
|
|
29903
30139
|
/* begin_public_function
|
|
29904
|
-
id: community.moderation.
|
|
30140
|
+
id: community.moderation.ban_members
|
|
29905
30141
|
*/
|
|
29906
30142
|
/**
|
|
29907
30143
|
* ```js
|
|
29908
30144
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29909
|
-
*
|
|
30145
|
+
*
|
|
30146
|
+
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
29910
30147
|
* ```
|
|
29911
30148
|
*
|
|
29912
|
-
*
|
|
29913
|
-
*
|
|
29914
|
-
* @
|
|
29915
|
-
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
29916
|
-
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
29917
|
-
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
29918
|
-
*
|
|
29919
|
-
* @category Community API
|
|
29920
|
-
* @async
|
|
29921
|
-
*/
|
|
29922
|
-
const addRoles = async (communityId, roleIds, userIds) => {
|
|
29923
|
-
const client = getActiveClient();
|
|
29924
|
-
client.log('community/moderation/addRoles', communityId, roleIds, userIds);
|
|
29925
|
-
const { data: payload } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
29926
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29927
|
-
if (client.cache)
|
|
29928
|
-
ingestInCache(data);
|
|
29929
|
-
const { communityUsers } = data;
|
|
29930
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
29931
|
-
roleIds.some(role => communityUser.roles.includes(role)));
|
|
29932
|
-
};
|
|
29933
|
-
/* end_public_function */
|
|
29934
|
-
|
|
29935
|
-
/* begin_public_function
|
|
29936
|
-
id: community.moderation.remove_roles
|
|
29937
|
-
*/
|
|
29938
|
-
/**
|
|
29939
|
-
* ```js
|
|
29940
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29941
|
-
* const updated = await CommunityRepository.moderation.removeRoles(communityId, ['foo', 'bar'])
|
|
29942
|
-
* ```
|
|
29943
|
-
*
|
|
29944
|
-
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
29945
|
-
*
|
|
29946
|
-
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
29947
|
-
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
29948
|
-
* @param userIds Array of IDs of the {@link Amity.User} to perform
|
|
29949
|
-
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
29950
|
-
*
|
|
29951
|
-
* @category Community API
|
|
29952
|
-
* @async
|
|
29953
|
-
*/
|
|
29954
|
-
const removeRoles = async (communityId, roleIds, userIds) => {
|
|
29955
|
-
const client = getActiveClient();
|
|
29956
|
-
client.log('community/moderation/removeRoles', communityId, roleIds, userIds);
|
|
29957
|
-
const { data: payload } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
29958
|
-
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29959
|
-
if (client.cache)
|
|
29960
|
-
ingestInCache(data);
|
|
29961
|
-
const { communityUsers } = data;
|
|
29962
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
29963
|
-
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
29964
|
-
};
|
|
29965
|
-
/* end_public_function */
|
|
29966
|
-
|
|
29967
|
-
/* begin_public_function
|
|
29968
|
-
id: community.moderation.ban_members
|
|
29969
|
-
*/
|
|
29970
|
-
/**
|
|
29971
|
-
* ```js
|
|
29972
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29973
|
-
*
|
|
29974
|
-
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
29975
|
-
* ```
|
|
29976
|
-
*
|
|
29977
|
-
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
29978
|
-
* @param userIds of the {@link Amity.User}'s to be banned
|
|
29979
|
-
* @returns the updated {@link Amity.Membership}'s object
|
|
30149
|
+
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
30150
|
+
* @param userIds of the {@link Amity.User}'s to be banned
|
|
30151
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
29980
30152
|
*
|
|
29981
30153
|
* @category Community API
|
|
29982
30154
|
* @async
|
|
@@ -30036,14 +30208,74 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
30036
30208
|
|
|
30037
30209
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
30038
30210
|
__proto__: null,
|
|
30039
|
-
addMembers: addMembers,
|
|
30040
|
-
removeMembers: removeMembers,
|
|
30041
30211
|
addRoles: addRoles,
|
|
30042
30212
|
removeRoles: removeRoles,
|
|
30043
30213
|
banMembers: banMembers,
|
|
30044
30214
|
unbanMembers: unbanMembers
|
|
30045
30215
|
});
|
|
30046
30216
|
|
|
30217
|
+
/* begin_public_function
|
|
30218
|
+
id: community.membership.add_members
|
|
30219
|
+
*/
|
|
30220
|
+
/**
|
|
30221
|
+
* ```js
|
|
30222
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30223
|
+
* const updated = await CommunityRepository.moderation.addMembers(communityId, ['foo', 'bar'])
|
|
30224
|
+
* ```
|
|
30225
|
+
*
|
|
30226
|
+
* Adds a list of {@link Amity.User} to a {@link Amity.Community} to add users to
|
|
30227
|
+
*
|
|
30228
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
30229
|
+
* @param userIds The list of IDs {@link Amity.User} to add
|
|
30230
|
+
* @returns A success boolean if the {@link Amity.User} were added to the {@link Amity.Community}
|
|
30231
|
+
*
|
|
30232
|
+
* @category Community API
|
|
30233
|
+
* @async
|
|
30234
|
+
*/
|
|
30235
|
+
const addMembers = async (communityId, userIds) => {
|
|
30236
|
+
const client = getActiveClient();
|
|
30237
|
+
client.log('community/moderation/addMembers', communityId, userIds);
|
|
30238
|
+
const { data: payload } = await client.http.post(`/api/v3/communities/${communityId}/users`, { communityId, userIds });
|
|
30239
|
+
fireEvent('community.userAdded', payload);
|
|
30240
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30241
|
+
if (client.cache)
|
|
30242
|
+
ingestInCache(data);
|
|
30243
|
+
const { communityUsers } = data;
|
|
30244
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
30245
|
+
};
|
|
30246
|
+
/* end_public_function */
|
|
30247
|
+
|
|
30248
|
+
/* begin_public_function
|
|
30249
|
+
id: community.membership.remove_member
|
|
30250
|
+
*/
|
|
30251
|
+
/**
|
|
30252
|
+
* ```js
|
|
30253
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30254
|
+
* const updated = await CommunityRepository.moderation.removeMembers(communityId, ['foo', 'bar'])
|
|
30255
|
+
* ```
|
|
30256
|
+
*
|
|
30257
|
+
* Removes a list of {@link Amity.User} from a {@link Amity.Community}
|
|
30258
|
+
*
|
|
30259
|
+
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
30260
|
+
* @param userIds The list of IDs {@link Amity.User} to remove
|
|
30261
|
+
* @returns A success boolean if the list of {@link Amity.User} were removed from the {@link Amity.Community}
|
|
30262
|
+
*
|
|
30263
|
+
* @category Community API
|
|
30264
|
+
* @async
|
|
30265
|
+
*/
|
|
30266
|
+
const removeMembers = async (communityId, userIds) => {
|
|
30267
|
+
const client = getActiveClient();
|
|
30268
|
+
client.log('community/moderation/removeMembers', communityId, userIds);
|
|
30269
|
+
const { data: payload } = await client.http.delete(`/api/v3/communities/${communityId}/users`, { data: { communityId, userIds } });
|
|
30270
|
+
fireEvent('community.userRemoved', payload);
|
|
30271
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30272
|
+
if (client.cache)
|
|
30273
|
+
ingestInCache(data);
|
|
30274
|
+
const { communityUsers } = data;
|
|
30275
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
30276
|
+
};
|
|
30277
|
+
/* end_public_function */
|
|
30278
|
+
|
|
30047
30279
|
/**
|
|
30048
30280
|
* ```js
|
|
30049
30281
|
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -30206,7 +30438,7 @@ const getMembers = (params, callback, config) => {
|
|
|
30206
30438
|
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30207
30439
|
if (!initial && communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30208
30440
|
return;
|
|
30209
|
-
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 } }));
|
|
30441
|
+
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 } }));
|
|
30210
30442
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30211
30443
|
const data = {
|
|
30212
30444
|
loading,
|
|
@@ -30234,6 +30466,8 @@ const getMembers = (params, callback, config) => {
|
|
|
30234
30466
|
|
|
30235
30467
|
var index$7 = /*#__PURE__*/Object.freeze({
|
|
30236
30468
|
__proto__: null,
|
|
30469
|
+
addMembers: addMembers,
|
|
30470
|
+
removeMembers: removeMembers,
|
|
30237
30471
|
getMembers: getMembers,
|
|
30238
30472
|
onCommunityUserAdded: onCommunityUserAdded,
|
|
30239
30473
|
onCommunityUserRemoved: onCommunityUserRemoved,
|
|
@@ -30464,7 +30698,7 @@ const getCategories = (params, callback, config) => {
|
|
|
30464
30698
|
const categories = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30465
30699
|
if (!initial && categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30466
30700
|
return;
|
|
30467
|
-
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 } }));
|
|
30701
|
+
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 } }));
|
|
30468
30702
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
30469
30703
|
const data = {
|
|
30470
30704
|
loading,
|
|
@@ -30585,9 +30819,94 @@ queryGlobalFeed.locally = (query) => {
|
|
|
30585
30819
|
: undefined;
|
|
30586
30820
|
};
|
|
30587
30821
|
|
|
30822
|
+
/* begin_public_function
|
|
30823
|
+
id: feed.query.custom_ranking_feed
|
|
30824
|
+
*/
|
|
30825
|
+
/**
|
|
30826
|
+
* ```js
|
|
30827
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
30828
|
+
* const posts = await FeedRepository.getCustomRankingGlobalFeed()
|
|
30829
|
+
* ```
|
|
30830
|
+
*
|
|
30831
|
+
* Queries a paginable list of {@link Amity.Post} objects
|
|
30832
|
+
*
|
|
30833
|
+
* @param query The query parameters
|
|
30834
|
+
* @returns A page of {@link Amity.Post} objects
|
|
30835
|
+
*
|
|
30836
|
+
* @category Feed API
|
|
30837
|
+
* @async
|
|
30838
|
+
* */
|
|
30839
|
+
const getCustomRankingGlobalFeed = async (query) => {
|
|
30840
|
+
const client = getActiveClient();
|
|
30841
|
+
client.log('feed/getCustomRankingGlobalFeed', query);
|
|
30842
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
30843
|
+
const { data: queryPayload } = await client.http.get(`/api/v5/me/global-feeds`, {
|
|
30844
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
30845
|
+
token: toToken(page, 'skiplimit'),
|
|
30846
|
+
} }),
|
|
30847
|
+
});
|
|
30848
|
+
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
30849
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30850
|
+
const { posts } = data;
|
|
30851
|
+
const cachedAt = client.cache && Date.now();
|
|
30852
|
+
if (client.cache) {
|
|
30853
|
+
ingestInCache(data);
|
|
30854
|
+
const cacheKey = [
|
|
30855
|
+
'customGlobalFeed',
|
|
30856
|
+
'query',
|
|
30857
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30858
|
+
];
|
|
30859
|
+
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
30860
|
+
}
|
|
30861
|
+
const nextPage = toPage(paging.next);
|
|
30862
|
+
const prevPage = toPage(paging.previous);
|
|
30863
|
+
return { data: posts, cachedAt, prevPage, nextPage };
|
|
30864
|
+
};
|
|
30865
|
+
/* end_public_function */
|
|
30866
|
+
/**
|
|
30867
|
+
* ```js
|
|
30868
|
+
* import { FeedRepository } from '@amityco/ts-sdk'
|
|
30869
|
+
* const posts = await FeedRepository.getCustomRankingGlobalFeed.locally()
|
|
30870
|
+
* ```
|
|
30871
|
+
*
|
|
30872
|
+
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
30873
|
+
*
|
|
30874
|
+
* @param query The query parameters
|
|
30875
|
+
* @returns A page of {@link Amity.Post} objects
|
|
30876
|
+
*
|
|
30877
|
+
* @category Feed API
|
|
30878
|
+
* @async
|
|
30879
|
+
* */
|
|
30880
|
+
getCustomRankingGlobalFeed.locally = (query) => {
|
|
30881
|
+
var _a, _b;
|
|
30882
|
+
const client = getActiveClient();
|
|
30883
|
+
client.log('post/getCustomRankingGlobalFeed.locally', query);
|
|
30884
|
+
if (!client.cache)
|
|
30885
|
+
return;
|
|
30886
|
+
const _c = query !== null && query !== void 0 ? query : {}, { page } = _c, params = __rest(_c, ["page"]);
|
|
30887
|
+
const queryKey = [
|
|
30888
|
+
'customGlobalFeed',
|
|
30889
|
+
'query',
|
|
30890
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
30891
|
+
];
|
|
30892
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
30893
|
+
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
30894
|
+
return;
|
|
30895
|
+
const posts = data.posts
|
|
30896
|
+
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30897
|
+
.filter(Boolean)
|
|
30898
|
+
.map(({ data }) => data);
|
|
30899
|
+
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
30900
|
+
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
30901
|
+
return posts.length === ((_b = data === null || data === void 0 ? void 0 : data.posts) === null || _b === void 0 ? void 0 : _b.length)
|
|
30902
|
+
? { data: posts, cachedAt, prevPage, nextPage }
|
|
30903
|
+
: undefined;
|
|
30904
|
+
};
|
|
30905
|
+
|
|
30588
30906
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
30589
30907
|
__proto__: null,
|
|
30590
|
-
queryGlobalFeed: queryGlobalFeed
|
|
30908
|
+
queryGlobalFeed: queryGlobalFeed,
|
|
30909
|
+
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed
|
|
30591
30910
|
});
|
|
30592
30911
|
|
|
30593
30912
|
/* begin_public_function
|
|
@@ -30734,6 +31053,7 @@ const createPost = async (bundle) => {
|
|
|
30734
31053
|
const updatePost = async (postId, patch) => {
|
|
30735
31054
|
const client = getActiveClient();
|
|
30736
31055
|
client.log('user/updatePost', patch);
|
|
31056
|
+
console.warn('Deprecation: updatePost has been renamed to editPost. Update post API will be deprecated soon.');
|
|
30737
31057
|
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
30738
31058
|
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30739
31059
|
const cachedAt = client.cache && Date.now();
|
|
@@ -30749,8 +31069,42 @@ const updatePost = async (postId, patch) => {
|
|
|
30749
31069
|
/* end_public_function */
|
|
30750
31070
|
|
|
30751
31071
|
/* begin_public_function
|
|
30752
|
-
id: post.
|
|
31072
|
+
id: post.edit
|
|
30753
31073
|
*/
|
|
31074
|
+
/**
|
|
31075
|
+
* ```js
|
|
31076
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31077
|
+
* const updated = await PostRepository.editPost(postId, {
|
|
31078
|
+
* data: { text: 'hello world' }
|
|
31079
|
+
* })
|
|
31080
|
+
* ```
|
|
31081
|
+
*
|
|
31082
|
+
* Updates an {@link Amity.Post}
|
|
31083
|
+
*
|
|
31084
|
+
* @param postId The ID of the {@link Amity.Post} to edit
|
|
31085
|
+
* @param patch The patch data to apply
|
|
31086
|
+
* @returns the updated {@link Amity.Post} object
|
|
31087
|
+
*
|
|
31088
|
+
* @category Post API
|
|
31089
|
+
* @async
|
|
31090
|
+
*/
|
|
31091
|
+
const editPost = async (postId, patch) => {
|
|
31092
|
+
const client = getActiveClient();
|
|
31093
|
+
client.log('user/editPost', patch);
|
|
31094
|
+
const { data: payload } = await client.http.put(`/api/v4/posts/${encodeURIComponent(postId)}`, patch);
|
|
31095
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
31096
|
+
const cachedAt = client.cache && Date.now();
|
|
31097
|
+
if (client.cache)
|
|
31098
|
+
ingestInCache(data, { cachedAt });
|
|
31099
|
+
fireEvent('post.updated', data);
|
|
31100
|
+
const { posts } = data;
|
|
31101
|
+
return {
|
|
31102
|
+
data: posts.find(post => post.postId === postId),
|
|
31103
|
+
cachedAt,
|
|
31104
|
+
};
|
|
31105
|
+
};
|
|
31106
|
+
/* end_public_function */
|
|
31107
|
+
|
|
30754
31108
|
/**
|
|
30755
31109
|
* ```js
|
|
30756
31110
|
* import { deletePost } from '@amityco/ts-sdk'
|
|
@@ -30762,14 +31116,12 @@ const updatePost = async (postId, patch) => {
|
|
|
30762
31116
|
* @param postId The {@link Amity.Post} ID to delete
|
|
30763
31117
|
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
30764
31118
|
*
|
|
30765
|
-
* @
|
|
31119
|
+
* @private
|
|
30766
31120
|
* @async
|
|
30767
31121
|
*/
|
|
30768
31122
|
const deletePost = async (postId, permanent = false) => {
|
|
30769
31123
|
const client = getActiveClient();
|
|
30770
|
-
client.log('post/deletePost', postId);
|
|
30771
31124
|
const post = await getPost$1(postId);
|
|
30772
|
-
// API-FIX: This endpoint has not been implemented yet.
|
|
30773
31125
|
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
30774
31126
|
params: {
|
|
30775
31127
|
postId,
|
|
@@ -30813,6 +31165,55 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
30813
31165
|
upsertInCache(['post', 'get', postId], { isDeleted: true });
|
|
30814
31166
|
}
|
|
30815
31167
|
return deleted;
|
|
31168
|
+
};
|
|
31169
|
+
|
|
31170
|
+
/* begin_public_function
|
|
31171
|
+
id: post.soft_delete
|
|
31172
|
+
*/
|
|
31173
|
+
/**
|
|
31174
|
+
* ```js
|
|
31175
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31176
|
+
* const success = await PostRepository.softDeletePost('foobar')
|
|
31177
|
+
* ```
|
|
31178
|
+
*
|
|
31179
|
+
* Soft deletes a {@link Amity.Post}
|
|
31180
|
+
*
|
|
31181
|
+
* @param postId The {@link Amity.Post} ID to soft delete
|
|
31182
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
31183
|
+
*
|
|
31184
|
+
* @category Post API
|
|
31185
|
+
* @async
|
|
31186
|
+
*/
|
|
31187
|
+
const softDeletePost = async (postId) => {
|
|
31188
|
+
const client = getActiveClient();
|
|
31189
|
+
client.log('post/softDeletePost', postId);
|
|
31190
|
+
const softDeleted = await deletePost(postId, false);
|
|
31191
|
+
return softDeleted;
|
|
31192
|
+
};
|
|
31193
|
+
/* end_public_function */
|
|
31194
|
+
|
|
31195
|
+
/* begin_public_function
|
|
31196
|
+
id: post.hard_delete
|
|
31197
|
+
*/
|
|
31198
|
+
/**
|
|
31199
|
+
* ```js
|
|
31200
|
+
* import { hardDeletePost } from '@amityco/ts-sdk'
|
|
31201
|
+
* const success = await hardDeletePost('foobar')
|
|
31202
|
+
* ```
|
|
31203
|
+
*
|
|
31204
|
+
* Hard deletes a {@link Amity.Post}
|
|
31205
|
+
*
|
|
31206
|
+
* @param postId The {@link Amity.Post} ID to be hard delete
|
|
31207
|
+
* @return A success boolean if the {@link Amity.Post} was deleted
|
|
31208
|
+
*
|
|
31209
|
+
* @category Post API
|
|
31210
|
+
* @async
|
|
31211
|
+
*/
|
|
31212
|
+
const hardDeletePost = async (postId) => {
|
|
31213
|
+
const client = getActiveClient();
|
|
31214
|
+
client.log('post/hardDeletePost', postId);
|
|
31215
|
+
const hardDeleted = await deletePost(postId, true);
|
|
31216
|
+
return hardDeleted;
|
|
30816
31217
|
};
|
|
30817
31218
|
/* end_public_function */
|
|
30818
31219
|
|
|
@@ -30892,6 +31293,86 @@ const declinePost = async (postId) => {
|
|
|
30892
31293
|
};
|
|
30893
31294
|
/* end_public_function */
|
|
30894
31295
|
|
|
31296
|
+
/* begin_public_function
|
|
31297
|
+
id: post.flag
|
|
31298
|
+
*/
|
|
31299
|
+
/**
|
|
31300
|
+
* ```js
|
|
31301
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31302
|
+
* const flagged = await PostRepository.flagPost(postId)
|
|
31303
|
+
* ```
|
|
31304
|
+
*
|
|
31305
|
+
* @param postId of the post to flag
|
|
31306
|
+
* @returns a boolean
|
|
31307
|
+
*
|
|
31308
|
+
* @category Post API
|
|
31309
|
+
* @async
|
|
31310
|
+
* */
|
|
31311
|
+
const flagPost = async (postId) => {
|
|
31312
|
+
const client = getActiveClient();
|
|
31313
|
+
client.log('post/flagPost', postId);
|
|
31314
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
|
|
31315
|
+
if (client.cache) {
|
|
31316
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31317
|
+
}
|
|
31318
|
+
fireEvent('post.flagged', payload);
|
|
31319
|
+
return !!payload;
|
|
31320
|
+
};
|
|
31321
|
+
/* end_public_function */
|
|
31322
|
+
|
|
31323
|
+
/* begin_public_function
|
|
31324
|
+
id: post.unflag
|
|
31325
|
+
*/
|
|
31326
|
+
/**
|
|
31327
|
+
* ```js
|
|
31328
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31329
|
+
* const unflagged = await PostRepository.unflagPost(postId)
|
|
31330
|
+
* ```
|
|
31331
|
+
*
|
|
31332
|
+
* @param postId of the post to unflag
|
|
31333
|
+
* @returns the unflag post result
|
|
31334
|
+
*
|
|
31335
|
+
* @category Post API
|
|
31336
|
+
* @async
|
|
31337
|
+
* */
|
|
31338
|
+
const unflagPost = async (postId) => {
|
|
31339
|
+
const client = getActiveClient();
|
|
31340
|
+
client.log('post/unflagPost', postId);
|
|
31341
|
+
const { data: payload } = await client.http.delete(`/api/v3/posts/${encodeURIComponent(postId)}/unflag`);
|
|
31342
|
+
if (client.cache) {
|
|
31343
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
31344
|
+
}
|
|
31345
|
+
fireEvent('post.unflagged', payload);
|
|
31346
|
+
return !!payload;
|
|
31347
|
+
};
|
|
31348
|
+
/* end_public_function */
|
|
31349
|
+
|
|
31350
|
+
/* begin_public_function
|
|
31351
|
+
id: post.check_flag_by_me
|
|
31352
|
+
*/
|
|
31353
|
+
/**
|
|
31354
|
+
* ```js
|
|
31355
|
+
* import { PostRepository } from '@amityco/ts-sdk'
|
|
31356
|
+
* const isReported = await PostRepository.isPostFlaggedByMe('post', postId)
|
|
31357
|
+
* ```
|
|
31358
|
+
*
|
|
31359
|
+
* @param postId of the post to check if flagged by current user
|
|
31360
|
+
* @returns `true` if the post is flagged by me, `false` if doesn't.
|
|
31361
|
+
*
|
|
31362
|
+
* @category Post API
|
|
31363
|
+
* @async
|
|
31364
|
+
* */
|
|
31365
|
+
const isPostFlaggedByMe = async (postId) => {
|
|
31366
|
+
var _a, _b;
|
|
31367
|
+
const client = getActiveClient();
|
|
31368
|
+
client.log('post/isPostFlaggedByMe', postId);
|
|
31369
|
+
const { result, isFlagByMe } = (_a = (await synchronousWSCall(client, 'v3/post.isflagbyme', {
|
|
31370
|
+
postId,
|
|
31371
|
+
}))) !== null && _a !== void 0 ? _a : {};
|
|
31372
|
+
return (_b = result !== null && result !== void 0 ? result : isFlagByMe) !== null && _b !== void 0 ? _b : false;
|
|
31373
|
+
};
|
|
31374
|
+
/* end_public_function */
|
|
31375
|
+
|
|
30895
31376
|
/**
|
|
30896
31377
|
* ```js
|
|
30897
31378
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
@@ -31185,13 +31666,13 @@ const getPosts = (params, callback, config) => {
|
|
|
31185
31666
|
disposers.push(() => dropFromCache(cacheKey));
|
|
31186
31667
|
responder(collection);
|
|
31187
31668
|
};
|
|
31188
|
-
const onFetch = () => {
|
|
31189
|
-
var _a, _b, _c, _d
|
|
31669
|
+
const onFetch = (initial = false) => {
|
|
31670
|
+
var _a, _b, _c, _d;
|
|
31190
31671
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31191
31672
|
const posts = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31192
|
-
if (posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31673
|
+
if (!initial && posts.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31193
31674
|
return;
|
|
31194
|
-
const query = createQuery(queryPosts, Object.assign(Object.assign({}, queryParams), { page: (
|
|
31675
|
+
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 } }));
|
|
31195
31676
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
31196
31677
|
const data = {
|
|
31197
31678
|
loading,
|
|
@@ -31207,7 +31688,7 @@ const getPosts = (params, callback, config) => {
|
|
|
31207
31688
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
31208
31689
|
};
|
|
31209
31690
|
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')));
|
|
31210
|
-
onFetch();
|
|
31691
|
+
onFetch(true);
|
|
31211
31692
|
return () => {
|
|
31212
31693
|
log(`getPosts(tmpid: ${timestamp}) > dispose`);
|
|
31213
31694
|
disposers.forEach(fn => fn());
|
|
@@ -31220,9 +31701,15 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
31220
31701
|
getPostByIds: getPostByIds,
|
|
31221
31702
|
createPost: createPost,
|
|
31222
31703
|
updatePost: updatePost,
|
|
31704
|
+
editPost: editPost,
|
|
31223
31705
|
deletePost: deletePost,
|
|
31706
|
+
softDeletePost: softDeletePost,
|
|
31707
|
+
hardDeletePost: hardDeletePost,
|
|
31224
31708
|
approvePost: approvePost,
|
|
31225
31709
|
declinePost: declinePost,
|
|
31710
|
+
flagPost: flagPost,
|
|
31711
|
+
unflagPost: unflagPost,
|
|
31712
|
+
isPostFlaggedByMe: isPostFlaggedByMe,
|
|
31226
31713
|
onPostCreated: onPostCreated,
|
|
31227
31714
|
onPostUpdated: onPostUpdated,
|
|
31228
31715
|
onPostDeleted: onPostDeleted,
|
|
@@ -31728,13 +32215,13 @@ const getComments = (params, callback, config) => {
|
|
|
31728
32215
|
pushToCache(cacheKey, collection);
|
|
31729
32216
|
responder(collection);
|
|
31730
32217
|
};
|
|
31731
|
-
const onFetch = () => {
|
|
31732
|
-
var _a, _b, _c, _d
|
|
32218
|
+
const onFetch = (initial = false) => {
|
|
32219
|
+
var _a, _b, _c, _d;
|
|
31733
32220
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31734
32221
|
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31735
|
-
if (comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
32222
|
+
if (!initial && comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
31736
32223
|
return;
|
|
31737
|
-
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { page: (
|
|
32224
|
+
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 } }));
|
|
31738
32225
|
runQuery(query, ({ data: result, error, loading, prevPage, nextPage }) => {
|
|
31739
32226
|
// depend on sortBy value we have two different pagination type
|
|
31740
32227
|
const page = queryParams.sortBy ? nextPage : prevPage;
|
|
@@ -31752,7 +32239,7 @@ const getComments = (params, callback, config) => {
|
|
|
31752
32239
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
31753
32240
|
};
|
|
31754
32241
|
disposers.push(onCommentCreated(realtimeRouter('onCreate')), onCommentUpdated(realtimeRouter('onUpdate')), onCommentDeleted(realtimeRouter('onDelete')), onCommentFlagged(realtimeRouter('onFlagged')), onCommentUnflagged(realtimeRouter('onUnflagged')), onCommentReactionAdded(realtimeRouter('onReactionAdded')), onCommentReactionRemoved(realtimeRouter('onReactionRemoved')));
|
|
31755
|
-
onFetch();
|
|
32242
|
+
onFetch(true);
|
|
31756
32243
|
return () => {
|
|
31757
32244
|
log(`getComments(tmpid: ${timestamp}) > dispose`);
|
|
31758
32245
|
disposers.forEach(fn => fn());
|