@amityco/ts-sdk 0.0.1-beta.40 → 0.0.1-beta.42.1
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 +3 -1
- package/dist/@types/core/model.d.ts +3 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts +1 -1
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +1 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +1 -1
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -1
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/subChannel.d.ts +1 -1
- package/dist/@types/domains/subChannel.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts.map +1 -1
- package/dist/category/observers/liveCategories.d.ts.map +1 -1
- package/dist/channel/api/addChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/addChannelMembersRole.d.ts.map +1 -1
- package/dist/channel/api/banChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/createChannel.d.ts.map +1 -1
- package/dist/channel/api/getChannel.d.ts.map +1 -1
- package/dist/channel/api/joinChannel.d.ts.map +1 -1
- package/dist/channel/api/leaveChannel.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/channel/api/removeChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/removeChannelMembersRole.d.ts +1 -1
- package/dist/channel/api/removeChannelMembersRole.d.ts.map +1 -1
- package/dist/channel/api/startReading.d.ts +3 -3
- package/dist/channel/api/startReading.d.ts.map +1 -1
- package/dist/channel/api/stopReading.d.ts +2 -2
- package/dist/channel/api/stopReading.d.ts.map +1 -1
- package/dist/channel/api/unbanChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/updateChannel.d.ts.map +1 -1
- package/dist/channel/observers/liveChannel.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.d.ts.map +1 -1
- package/dist/client/api/renewal.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/deleteComment.d.ts.map +1 -1
- package/dist/comment/api/getComment.d.ts.map +1 -1
- package/dist/comment/api/getComments.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/comment/api/tests/queryComments.test.d.ts +2 -0
- package/dist/comment/api/tests/queryComments.test.d.ts.map +1 -0
- package/dist/comment/api/updateComment.d.ts.map +1 -1
- package/dist/comment/observers/liveComments.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/api/createCommunity.d.ts.map +1 -1
- package/dist/community/api/deleteCommunity.d.ts.map +1 -1
- package/dist/community/api/getCommunity.d.ts.map +1 -1
- package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -1
- package/dist/community/api/joinCommunity.d.ts.map +1 -1
- package/dist/community/api/leaveCommunity.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/api/queryCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/api/updateCommunity.d.ts.map +1 -1
- package/dist/community/observers/liveCommunities.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/transports/http.d.ts.map +1 -1
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/file/api/createFile.d.ts.map +1 -1
- package/dist/file/api/createImage.d.ts.map +1 -1
- package/dist/file/api/createVideo.d.ts.map +1 -1
- package/dist/file/api/deleteFile.d.ts.map +1 -1
- package/dist/file/api/getFile.d.ts.map +1 -1
- package/dist/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/follow/api/follow.d.ts.map +1 -1
- package/dist/follow/api/getFollowInfo.d.ts.map +1 -1
- package/dist/follow/api/queryFollowers.d.ts.map +1 -1
- package/dist/follow/api/queryFollowings.d.ts.map +1 -1
- package/dist/follow/api/unfollow.d.ts.map +1 -1
- package/dist/follow/observers/index.d.ts +1 -0
- package/dist/follow/observers/index.d.ts.map +1 -1
- package/dist/follow/observers/liveFollowInfo.d.ts +21 -0
- package/dist/follow/observers/liveFollowInfo.d.ts.map +1 -0
- package/dist/follow/observers/tests/liveFollowInfo.test.d.ts +2 -0
- package/dist/follow/observers/tests/liveFollowInfo.test.d.ts.map +1 -0
- package/dist/index.cjs.js +511 -109
- package/dist/index.esm.js +511 -110
- package/dist/index.umd.js +2 -2
- package/dist/message/api/createMessage.d.ts +2 -1
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/api/deleteMessage.d.ts.map +1 -1
- package/dist/message/api/getMessage.d.ts.map +1 -1
- package/dist/message/api/queryMessages.d.ts.map +1 -1
- package/dist/message/api/updateMessage.d.ts.map +1 -1
- package/dist/message/observers/liveMessages.d.ts.map +1 -1
- package/dist/message/utils/index.d.ts +3 -2
- package/dist/message/utils/index.d.ts.map +1 -1
- package/dist/poll/api/closePoll.d.ts.map +1 -1
- package/dist/poll/api/createPoll.d.ts.map +1 -1
- package/dist/poll/api/deletePoll.d.ts.map +1 -1
- package/dist/poll/api/getPoll.d.ts.map +1 -1
- package/dist/poll/api/votePoll.d.ts.map +1 -1
- package/dist/post/api/approvePost.d.ts.map +1 -1
- package/dist/post/api/createPost.d.ts.map +1 -1
- package/dist/post/api/declinePost.d.ts.map +1 -1
- package/dist/post/api/deletePost.d.ts.map +1 -1
- package/dist/post/api/getPost.d.ts.map +1 -1
- package/dist/post/api/getPosts.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/post/api/updatePost.d.ts.map +1 -1
- package/dist/post/observers/livePosts.d.ts.map +1 -1
- package/dist/reaction/api/addReaction.d.ts.map +1 -1
- package/dist/reaction/api/queryReactions.d.ts.map +1 -1
- package/dist/reaction/api/removeReaction.d.ts.map +1 -1
- package/dist/report/api/createReport.d.ts.map +1 -1
- package/dist/report/api/deleteReport.d.ts.map +1 -1
- package/dist/report/api/isReportedByMe.d.ts.map +1 -1
- package/dist/stream/api/createStream.d.ts.map +1 -1
- package/dist/stream/api/deleteStream.d.ts.map +1 -1
- package/dist/stream/api/getStream.d.ts.map +1 -1
- package/dist/stream/api/queryStreams.d.ts.map +1 -1
- package/dist/stream/api/updateStream.d.ts.map +1 -1
- package/dist/subChannel/api/createSubChannel.d.ts.map +1 -1
- package/dist/subChannel/api/deleteSubChannel.d.ts.map +1 -1
- package/dist/subChannel/api/getSubChannel.d.ts.map +1 -1
- package/dist/subChannel/api/querySubChannels.d.ts.map +1 -1
- package/dist/subChannel/api/updateSubChannel.d.ts.map +1 -1
- package/dist/user/api/getUser.d.ts.map +1 -1
- package/dist/user/api/getUsers.d.ts.map +1 -1
- package/dist/user/api/queryUsers.d.ts.map +1 -1
- package/dist/user/api/updateUser.d.ts.map +1 -1
- package/dist/utils/liveObject.d.ts +1 -1
- package/dist/utils/liveObject.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +77 -0
- package/dist/utils/tests/dummy/comment.d.ts.map +1 -0
- package/dist/utils/tests/dummy/community.d.ts +1 -1
- package/dist/utils/tests/dummy/index.d.ts +1 -0
- package/dist/utils/tests/dummy/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/post.d.ts +0 -12
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/model.ts +3 -1
- package/src/@types/domains/category.ts +1 -1
- package/src/@types/domains/comment.ts +1 -1
- package/src/@types/domains/community.ts +1 -1
- package/src/@types/domains/message.ts +1 -1
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/domains/subChannel.ts +1 -1
- package/src/category/api/queryCategories.ts +5 -1
- package/src/category/observers/liveCategories.ts +3 -1
- package/src/category/observers/tests/liveCategories.test.ts +1 -3
- package/src/channel/api/addChannelMembers.ts +4 -0
- package/src/channel/api/addChannelMembersRole.ts +4 -0
- package/src/channel/api/banChannelMembers.ts +4 -0
- package/src/channel/api/createChannel.ts +4 -0
- package/src/channel/api/getChannel.ts +4 -0
- package/src/channel/api/joinChannel.ts +4 -0
- package/src/channel/api/leaveChannel.ts +4 -0
- package/src/channel/api/queryChannelMembers.ts +4 -0
- package/src/channel/api/queryChannels.ts +4 -0
- package/src/channel/api/removeChannelMembers.ts +4 -0
- package/src/channel/api/removeChannelMembersRole.ts +5 -1
- package/src/channel/api/startReading.ts +7 -3
- package/src/channel/api/stopReading.ts +6 -2
- package/src/channel/api/unbanChannelMembers.ts +4 -0
- package/src/channel/api/updateChannel.ts +4 -0
- package/src/channel/observers/liveChannel.ts +16 -1
- package/src/client/api/connectClient.ts +4 -0
- package/src/client/api/disconnectClient.ts +4 -0
- package/src/client/api/getToken.ts +1 -1
- package/src/client/api/renewal.ts +4 -0
- package/src/client/api/tests/getToken.test.ts +2 -2
- package/src/comment/api/createComment.ts +4 -0
- package/src/comment/api/deleteComment.ts +4 -0
- package/src/comment/api/getComment.ts +4 -0
- package/src/comment/api/getComments.ts +4 -0
- package/src/comment/api/queryComments.ts +6 -1
- package/src/comment/api/tests/createComment.test.ts +17 -112
- package/src/comment/api/tests/queryComments.test.ts +147 -0
- package/src/comment/api/tests/updateComment.test.ts +14 -85
- package/src/comment/api/updateComment.ts +4 -0
- package/src/comment/observers/liveComments.ts +3 -1
- package/src/community/api/addCommunityMembers.ts +4 -0
- package/src/community/api/addCommunityMembersRoles.ts +4 -0
- package/src/community/api/createCommunity.ts +4 -0
- package/src/community/api/deleteCommunity.ts +4 -0
- package/src/community/api/getCommunity.ts +4 -0
- package/src/community/api/getRecommendedCommunities.ts +4 -0
- package/src/community/api/getTopTrendingCommunities.ts +4 -0
- package/src/community/api/joinCommunity.ts +4 -0
- package/src/community/api/leaveCommunity.ts +4 -0
- package/src/community/api/queryCommunities.ts +6 -1
- package/src/community/api/queryCommunityMembers.ts +4 -0
- package/src/community/api/removeCommunityMembers.ts +4 -0
- package/src/community/api/removeCommunityMembersRoles.ts +4 -0
- package/src/community/api/test/queryCommunity.test.ts +30 -0
- package/src/community/api/updateCommunity.ts +4 -0
- package/src/community/observers/liveCommunities.ts +4 -1
- package/src/community/observers/tests/liveCommunities.test.ts +2 -2
- package/src/core/model/idResolvers.ts +1 -0
- package/src/core/model/identifyModel.ts +2 -1
- package/src/core/model/index.ts +11 -2
- package/src/core/transports/http.ts +5 -0
- package/src/core/transports/test/http.test.ts +12 -0
- package/src/feed/api/queryGlobalFeed.ts +4 -0
- package/src/file/api/createFile.ts +4 -0
- package/src/file/api/createImage.ts +4 -0
- package/src/file/api/createVideo.ts +4 -0
- package/src/file/api/deleteFile.ts +4 -0
- package/src/file/api/getFile.ts +4 -0
- package/src/follow/api/acceptFollower.ts +4 -0
- package/src/follow/api/declineFollower.ts +4 -0
- package/src/follow/api/follow.ts +4 -0
- package/src/follow/api/getFollowInfo.ts +8 -8
- package/src/follow/api/queryFollowers.ts +4 -0
- package/src/follow/api/queryFollowings.ts +4 -0
- package/src/follow/api/unfollow.ts +4 -0
- package/src/follow/observers/index.ts +1 -0
- package/src/follow/observers/liveFollowInfo.ts +29 -0
- package/src/follow/observers/tests/liveFollowInfo.test.ts +198 -0
- package/src/message/api/createMessage.ts +24 -7
- package/src/message/api/deleteMessage.ts +4 -0
- package/src/message/api/getMessage.ts +4 -0
- package/src/message/api/queryMessages.ts +4 -0
- package/src/message/api/tests/createMessage.test.ts +42 -2
- package/src/message/api/tests/queryMessages.test.ts +30 -0
- package/src/message/api/updateMessage.ts +4 -0
- package/src/message/observers/liveMessages.ts +14 -15
- package/src/message/tests/observers/liveMessages.test.ts +2 -2
- package/src/message/utils/index.ts +10 -1
- package/src/poll/api/closePoll.ts +4 -0
- package/src/poll/api/createPoll.ts +4 -0
- package/src/poll/api/deletePoll.ts +4 -0
- package/src/poll/api/getPoll.ts +4 -0
- package/src/poll/api/votePoll.ts +4 -0
- package/src/post/api/approvePost.ts +4 -0
- package/src/post/api/createPost.ts +4 -0
- package/src/post/api/declinePost.ts +4 -0
- package/src/post/api/deletePost.ts +4 -0
- package/src/post/api/getPost.ts +4 -0
- package/src/post/api/getPosts.ts +3 -0
- package/src/post/api/queryPosts.ts +6 -1
- package/src/post/api/tests/queryPosts.test.ts +30 -0
- package/src/post/api/updatePost.ts +4 -0
- package/src/post/observers/livePosts.ts +4 -2
- package/src/post/observers/tests/livePosts.test.ts +4 -5
- package/src/reaction/api/addReaction.ts +4 -0
- package/src/reaction/api/queryReactions.ts +4 -0
- package/src/reaction/api/removeReaction.ts +4 -0
- package/src/reaction/api/tests/addReaction.test.ts +13 -0
- package/src/reaction/api/tests/removeReaction.test.ts +13 -0
- package/src/report/api/createReport.ts +4 -0
- package/src/report/api/deleteReport.ts +4 -0
- package/src/report/api/isReportedByMe.ts +4 -0
- package/src/stream/api/createStream.ts +4 -0
- package/src/stream/api/deleteStream.ts +3 -0
- package/src/stream/api/getStream.ts +4 -0
- package/src/stream/api/queryStreams.ts +4 -0
- package/src/stream/api/updateStream.ts +3 -0
- package/src/subChannel/api/createSubChannel.ts +4 -0
- package/src/subChannel/api/deleteSubChannel.ts +4 -0
- package/src/subChannel/api/getSubChannel.ts +4 -0
- package/src/subChannel/api/querySubChannels.ts +6 -1
- package/src/subChannel/api/updateSubChannel.ts +4 -0
- package/src/subChannel/observers/liveSubChannels.ts +2 -2
- package/src/subChannel/observers/tests/liveSubChannels.test.ts +5 -2
- package/src/user/api/getUser.ts +4 -0
- package/src/user/api/getUsers.ts +3 -0
- package/src/user/api/queryUsers.ts +4 -0
- package/src/user/api/updateUser.ts +4 -0
- package/src/utils/liveObject.ts +1 -4
- package/src/utils/tests/dummy/comment.ts +268 -0
- package/src/utils/tests/dummy/index.ts +1 -0
- package/src/utils/tests/dummy/post.ts +0 -114
- package/dist/post/tests/api/getPost.test.d.ts +0 -2
- package/dist/post/tests/api/getPost.test.d.ts.map +0 -1
- package/dist/post/tests/api/queryPosts.test.d.ts +0 -2
- package/dist/post/tests/api/queryPosts.test.d.ts.map +0 -1
- package/src/post/tests/api/getPost.test.ts +0 -98
- package/src/post/tests/api/queryPosts.test.ts +0 -123
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { queryComments } from '../queryComments';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
client,
|
|
5
|
+
connectClient,
|
|
6
|
+
disconnectClient,
|
|
7
|
+
textCommentPayload,
|
|
8
|
+
imageCommentPayload,
|
|
9
|
+
post11,
|
|
10
|
+
textCommentResponse,
|
|
11
|
+
imageCommentResponse,
|
|
12
|
+
textAndImageCommentMixedPayload,
|
|
13
|
+
textCommentRequestPayload,
|
|
14
|
+
comment12,
|
|
15
|
+
comment12Payload,
|
|
16
|
+
deletedCommentPayload,
|
|
17
|
+
deletedCommentResponse,
|
|
18
|
+
} from '~/utils/tests';
|
|
19
|
+
import { ASCApiError } from '~/core/errors';
|
|
20
|
+
|
|
21
|
+
type mockParamAndResponse = {
|
|
22
|
+
query: Amity.QueryComments;
|
|
23
|
+
response: Amity.Comment[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const queryParams: mockParamAndResponse = {
|
|
27
|
+
query: {
|
|
28
|
+
referenceType: 'post',
|
|
29
|
+
referenceId: post11.postId,
|
|
30
|
+
},
|
|
31
|
+
response: textCommentPayload.comments,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const queryImageOnly: mockParamAndResponse = {
|
|
35
|
+
query: {
|
|
36
|
+
...queryParams.query,
|
|
37
|
+
dataTypes: {
|
|
38
|
+
values: ['image'],
|
|
39
|
+
matchType: 'exact',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
response: imageCommentPayload.comments,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const queryImageAny: mockParamAndResponse = {
|
|
46
|
+
query: {
|
|
47
|
+
...queryParams.query,
|
|
48
|
+
dataTypes: {
|
|
49
|
+
values: ['image'],
|
|
50
|
+
matchType: 'any',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
response: textAndImageCommentMixedPayload.comments,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const queryWithParentId: mockParamAndResponse = {
|
|
57
|
+
query: {
|
|
58
|
+
...queryParams.query,
|
|
59
|
+
parentId: comment12.parentId,
|
|
60
|
+
},
|
|
61
|
+
response: comment12Payload.comments,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const deletedComment: mockParamAndResponse = {
|
|
65
|
+
query: {
|
|
66
|
+
...queryParams.query,
|
|
67
|
+
includeDeleted: true,
|
|
68
|
+
},
|
|
69
|
+
response: deletedCommentPayload.comments,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
describe('queryComments', () => {
|
|
73
|
+
beforeAll(connectClient);
|
|
74
|
+
afterAll(disconnectClient);
|
|
75
|
+
|
|
76
|
+
const testCase: [string, object, Amity.QueryComments, Amity.Comment[]][] = [
|
|
77
|
+
[
|
|
78
|
+
// integration_test_id: 0be48975-be6d-4199-bec0-af186af444d3
|
|
79
|
+
'Should return valid comment when user query with valid query',
|
|
80
|
+
textCommentResponse,
|
|
81
|
+
queryParams.query,
|
|
82
|
+
queryParams.response,
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
// integration_test_id: 4550e036-53d0-4f35-b83f-9edc10f1c974
|
|
86
|
+
|
|
87
|
+
'Should return only valid image comment types when user query with dataType exact image',
|
|
88
|
+
imageCommentResponse,
|
|
89
|
+
queryImageOnly.query,
|
|
90
|
+
queryImageOnly.response,
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
// integration_test_id: 03056892-251f-4a85-a9bf-f9978c1912e5
|
|
94
|
+
'Should return only valid deleted comment list when user query with isDeleted=true',
|
|
95
|
+
deletedCommentResponse,
|
|
96
|
+
deletedComment.query,
|
|
97
|
+
deletedComment.response,
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
// integration_test_id: 2f68da78-7738-4371-ae72-b6a4ff043404
|
|
101
|
+
|
|
102
|
+
'Should return only valid mixed types comment list when user query with dataType any image',
|
|
103
|
+
{
|
|
104
|
+
data: {
|
|
105
|
+
...textAndImageCommentMixedPayload,
|
|
106
|
+
paging: {},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
queryImageAny.query,
|
|
110
|
+
queryImageAny.response,
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
// integration_test_id: 8207d436-a800-4224-8fb0-a46c05f7d11e
|
|
114
|
+
'Should return only valid mixed types comment list when user query with parent_id',
|
|
115
|
+
{
|
|
116
|
+
data: {
|
|
117
|
+
...comment12Payload,
|
|
118
|
+
paging: {},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
queryWithParentId.query,
|
|
122
|
+
queryWithParentId.response,
|
|
123
|
+
],
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
test.each(testCase)('%s', async (title, mockResponse, query, expectResult) => {
|
|
127
|
+
client.http.get = jest.fn().mockResolvedValueOnce(mockResponse);
|
|
128
|
+
const result = await queryComments(query);
|
|
129
|
+
expect(result.data).toEqual(expectResult);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const errorCase: [string, number, Amity.QueryComments][] = [
|
|
133
|
+
[
|
|
134
|
+
// integration_test_id: 2719d77f-177a-401f-864f-ef0f0804cc24
|
|
135
|
+
'Should return error 400400 when query with wrong post_id', // title
|
|
136
|
+
Amity.ServerError.ITEM_NOT_FOUND, // errorCode
|
|
137
|
+
textCommentRequestPayload, // payload
|
|
138
|
+
],
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
test.each(errorCase)('%s', async (title, errorCode, payload) => {
|
|
142
|
+
client.http.get = jest
|
|
143
|
+
.fn()
|
|
144
|
+
.mockRejectedValueOnce(new ASCApiError('not found!', errorCode, Amity.ErrorLevel.ERROR));
|
|
145
|
+
await expect(queryComments(payload)).rejects.toThrow();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -9,88 +9,17 @@ import {
|
|
|
9
9
|
imageComment11,
|
|
10
10
|
textImageComment11,
|
|
11
11
|
textMentionComment11,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
imageCommentResponse,
|
|
13
|
+
textCommentResponse,
|
|
14
|
+
textImageCommentResponse,
|
|
15
|
+
textMentionCommentResponse,
|
|
16
|
+
imageCommentRequestPayload,
|
|
17
|
+
textCommentRequestPayload,
|
|
18
|
+
textCommentWithMentionRequestPayload,
|
|
19
|
+
textImageCommentRequestPayload,
|
|
20
20
|
} from '~/utils/tests';
|
|
21
21
|
import { ASCApiError } from '~/core/errors';
|
|
22
22
|
|
|
23
|
-
const updateTextCommentResponse = {
|
|
24
|
-
data: {
|
|
25
|
-
...textCommentPayload,
|
|
26
|
-
files: [],
|
|
27
|
-
commentChildren: [],
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const updateImageCommentResponse = {
|
|
32
|
-
data: {
|
|
33
|
-
...imageCommentPayload,
|
|
34
|
-
files: [],
|
|
35
|
-
commentChildren: [],
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const updateTextMentionCommentResponse = {
|
|
40
|
-
data: {
|
|
41
|
-
...textCommentMentionPayload,
|
|
42
|
-
files: [],
|
|
43
|
-
commentChildren: [],
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const updateTextImageCommentResponse = {
|
|
48
|
-
data: {
|
|
49
|
-
...textImageCommentPayload,
|
|
50
|
-
files: [],
|
|
51
|
-
commentChildren: [],
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const textCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
56
|
-
referenceId: post11.postId,
|
|
57
|
-
referenceType: 'post',
|
|
58
|
-
data: {
|
|
59
|
-
text: 'test',
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const textCommentWithMentionRequestPayload: Parameters<typeof createComment>[0] = {
|
|
64
|
-
...textCommentRequestPayload,
|
|
65
|
-
mentionees: [
|
|
66
|
-
{
|
|
67
|
-
type: 'user',
|
|
68
|
-
userIds: [user11._id, user12._id],
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const textImageCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
74
|
-
...textCommentRequestPayload,
|
|
75
|
-
attachments: [
|
|
76
|
-
{
|
|
77
|
-
type: 'image',
|
|
78
|
-
fileId: file11.fileId,
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const imageCommentRequestPayload: Parameters<typeof createComment>[0] = {
|
|
84
|
-
referenceId: post11.postId,
|
|
85
|
-
referenceType: 'post',
|
|
86
|
-
attachments: [
|
|
87
|
-
{
|
|
88
|
-
type: 'image',
|
|
89
|
-
fileId: file11.fileId,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
};
|
|
93
|
-
|
|
94
23
|
describe('updateComment', () => {
|
|
95
24
|
beforeAll(connectClient);
|
|
96
25
|
afterAll(disconnectClient);
|
|
@@ -100,7 +29,7 @@ describe('updateComment', () => {
|
|
|
100
29
|
{
|
|
101
30
|
// integration_test_id: 1f0c74da-863e-44eb-acf1-3de57b1a0e79
|
|
102
31
|
title: 'update comment with valid data and return a new data',
|
|
103
|
-
mockRequest:
|
|
32
|
+
mockRequest: textCommentResponse,
|
|
104
33
|
mockFunction: textCommentRequestPayload,
|
|
105
34
|
expectResult: comment11,
|
|
106
35
|
extraCase: [],
|
|
@@ -108,7 +37,7 @@ describe('updateComment', () => {
|
|
|
108
37
|
{
|
|
109
38
|
// integration_test_id: 72550ea2-2943-4708-bc36-dd2b4fcf44b7
|
|
110
39
|
title: 'update text comment with mention and returns the new valid comment',
|
|
111
|
-
mockRequest:
|
|
40
|
+
mockRequest: textMentionCommentResponse,
|
|
112
41
|
mockFunction: textCommentWithMentionRequestPayload,
|
|
113
42
|
expectResult: textMentionComment11,
|
|
114
43
|
extraCase: [],
|
|
@@ -116,7 +45,7 @@ describe('updateComment', () => {
|
|
|
116
45
|
{
|
|
117
46
|
// integration_test_id: 9df2ff6c-81b7-4bdd-bcd2-33d9752735ed
|
|
118
47
|
title: 'update an image + text comment and returns the new valid comment',
|
|
119
|
-
mockRequest:
|
|
48
|
+
mockRequest: textImageCommentResponse,
|
|
120
49
|
mockFunction: textImageCommentRequestPayload,
|
|
121
50
|
expectResult: textImageComment11,
|
|
122
51
|
extraCase: [],
|
|
@@ -124,7 +53,7 @@ describe('updateComment', () => {
|
|
|
124
53
|
{
|
|
125
54
|
// integration_test_id: 75c77684-09f3-442e-8089-6d37e2182a65
|
|
126
55
|
title: 'add image to existing comment and returns the new valid comment',
|
|
127
|
-
mockRequest:
|
|
56
|
+
mockRequest: textImageCommentResponse,
|
|
128
57
|
mockFunction: textImageCommentRequestPayload,
|
|
129
58
|
expectResult: textImageComment11,
|
|
130
59
|
extraCase: [],
|
|
@@ -132,7 +61,7 @@ describe('updateComment', () => {
|
|
|
132
61
|
{
|
|
133
62
|
// integration_test_id: b50d7783-ab5e-4473-be3b-08ffe8b5142a
|
|
134
63
|
title: 'remove image from existing comment and returns the new valid comment',
|
|
135
|
-
mockRequest:
|
|
64
|
+
mockRequest: textCommentResponse,
|
|
136
65
|
mockFunction: textCommentRequestPayload,
|
|
137
66
|
expectResult: comment11,
|
|
138
67
|
extraCase: [{ attachments: [] }],
|
|
@@ -140,7 +69,7 @@ describe('updateComment', () => {
|
|
|
140
69
|
{
|
|
141
70
|
// integration_test_id: f31daa63-7214-400a-a7a1-d9b00d37137e
|
|
142
71
|
title: 'remove text from existing media comment and returns the new valid comment',
|
|
143
|
-
mockRequest:
|
|
72
|
+
mockRequest: imageCommentResponse,
|
|
144
73
|
mockFunction: imageCommentRequestPayload,
|
|
145
74
|
expectResult: imageComment11,
|
|
146
75
|
extraCase: [{ data: { text: '' } }],
|
|
@@ -3,6 +3,9 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
5
|
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: comment.update_comment
|
|
8
|
+
*/
|
|
6
9
|
/**
|
|
7
10
|
* ```js
|
|
8
11
|
* import { updateComment } from '@amityco/ts-sdk'
|
|
@@ -43,3 +46,4 @@ export const updateComment = async (
|
|
|
43
46
|
cachedAt,
|
|
44
47
|
};
|
|
45
48
|
};
|
|
49
|
+
/* end_public_function */
|
|
@@ -80,7 +80,9 @@ export const liveComments = (
|
|
|
80
80
|
.filter(Boolean)
|
|
81
81
|
.map(({ data }) => data) ?? [];
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
if (params.includeDeleted === false) {
|
|
84
|
+
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
85
|
+
}
|
|
84
86
|
|
|
85
87
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
86
88
|
|
|
@@ -4,6 +4,9 @@ import { fireEvent } from '~/core/events';
|
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
import { prepareMembershipPayload } from '~/group/utils';
|
|
6
6
|
|
|
7
|
+
/* begin_public_function
|
|
8
|
+
id: community.membership.add_members
|
|
9
|
+
*/
|
|
7
10
|
/**
|
|
8
11
|
* ```js
|
|
9
12
|
* import { addCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -43,3 +46,4 @@ export const addCommunityMembers = async (
|
|
|
43
46
|
communityUser.communityId === communityId && communityUser.communityMembership === 'member',
|
|
44
47
|
);
|
|
45
48
|
};
|
|
49
|
+
/* end_public_function */
|
|
@@ -3,6 +3,9 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { prepareMembershipPayload } from '~/group/utils';
|
|
5
5
|
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: community.moderation.add_roles
|
|
8
|
+
*/
|
|
6
9
|
/**
|
|
7
10
|
* ```js
|
|
8
11
|
* import { addCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
@@ -43,3 +46,4 @@ export const addCommunityMembersRoles = async (
|
|
|
43
46
|
roleIds.some(role => communityUser.roles.includes(role)),
|
|
44
47
|
);
|
|
45
48
|
};
|
|
49
|
+
/* end_public_function */
|
|
@@ -5,6 +5,9 @@ import { fireEvent } from '~/core/events';
|
|
|
5
5
|
|
|
6
6
|
import { prepareCommunityRequest, prepareCommunityPayload } from '../utils';
|
|
7
7
|
|
|
8
|
+
/* begin_public_function
|
|
9
|
+
id: community.create
|
|
10
|
+
*/
|
|
8
11
|
/**
|
|
9
12
|
* ```js
|
|
10
13
|
* import { createCommunity } from '@amityco/ts-sdk'
|
|
@@ -57,3 +60,4 @@ export const createCommunity = async (
|
|
|
57
60
|
cachedAt,
|
|
58
61
|
};
|
|
59
62
|
};
|
|
63
|
+
/* end_public_function */
|
|
@@ -3,6 +3,9 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { fireEvent } from '~/core/events';
|
|
4
4
|
import { getCommunity } from './getCommunity';
|
|
5
5
|
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: community.delete
|
|
8
|
+
*/
|
|
6
9
|
/**
|
|
7
10
|
* ```js
|
|
8
11
|
* import { deleteCommunity } from '@amityco/ts-sdk'
|
|
@@ -39,3 +42,4 @@ export const deleteCommunity = async (
|
|
|
39
42
|
|
|
40
43
|
return deleted.data;
|
|
41
44
|
};
|
|
45
|
+
/* end_public_function */
|
|
@@ -5,6 +5,9 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
5
5
|
|
|
6
6
|
import { prepareCommunityPayload } from '../utils';
|
|
7
7
|
|
|
8
|
+
/* begin_public_function
|
|
9
|
+
id: community.get
|
|
10
|
+
*/
|
|
8
11
|
/**
|
|
9
12
|
* ```js
|
|
10
13
|
* import { getCommunity } from '@amityco/ts-sdk'
|
|
@@ -42,6 +45,7 @@ export const getCommunity = async (
|
|
|
42
45
|
cachedAt,
|
|
43
46
|
};
|
|
44
47
|
};
|
|
48
|
+
/* end_public_function */
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* ```js
|
|
@@ -6,6 +6,9 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
6
6
|
|
|
7
7
|
import { prepareCommunityPayload } from '../utils';
|
|
8
8
|
|
|
9
|
+
/* begin_public_function
|
|
10
|
+
id: community.query.recommended_communities
|
|
11
|
+
*/
|
|
9
12
|
/**
|
|
10
13
|
* ```js
|
|
11
14
|
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
@@ -49,6 +52,7 @@ export const getRecommendedCommunities = async (
|
|
|
49
52
|
|
|
50
53
|
return { data: communities, cachedAt };
|
|
51
54
|
};
|
|
55
|
+
/* end_public_function */
|
|
52
56
|
|
|
53
57
|
/**
|
|
54
58
|
* ```js
|
|
@@ -6,6 +6,9 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
6
6
|
|
|
7
7
|
import { prepareCommunityPayload } from '../utils';
|
|
8
8
|
|
|
9
|
+
/* begin_public_function
|
|
10
|
+
id: community.query.trending_communities
|
|
11
|
+
*/
|
|
9
12
|
/**
|
|
10
13
|
* ```js
|
|
11
14
|
* import { getTopTrendingCommunities } from '@amityco/ts-sdk'
|
|
@@ -49,6 +52,7 @@ export const getTopTrendingCommunities = async (
|
|
|
49
52
|
|
|
50
53
|
return { data: communities, cachedAt };
|
|
51
54
|
};
|
|
55
|
+
/* end_public_function */
|
|
52
56
|
|
|
53
57
|
/**
|
|
54
58
|
* ```js
|
|
@@ -4,6 +4,9 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
import { prepareCommunityPayload } from '~/community/utils';
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
6
|
|
|
7
|
+
/* begin_public_function
|
|
8
|
+
id: community.join
|
|
9
|
+
*/
|
|
7
10
|
/**
|
|
8
11
|
* ```js
|
|
9
12
|
* import { joinCommunity } from '@amityco/ts-sdk'
|
|
@@ -42,3 +45,4 @@ export const joinCommunity = async (
|
|
|
42
45
|
communityUser.communityId === communityId && communityUser.communityMembership === 'member',
|
|
43
46
|
);
|
|
44
47
|
};
|
|
48
|
+
/* end_public_function */
|
|
@@ -4,6 +4,9 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
import { prepareCommunityPayload } from '~/community/utils';
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
6
|
|
|
7
|
+
/* begin_public_function
|
|
8
|
+
id: community.leave
|
|
9
|
+
*/
|
|
7
10
|
/**
|
|
8
11
|
* ```js
|
|
9
12
|
* import { leaveCommunity } from '@amityco/ts-sdk'
|
|
@@ -42,3 +45,4 @@ export const leaveCommunity = async (
|
|
|
42
45
|
communityUser.communityId === communityId && communityUser.communityMembership !== 'member',
|
|
43
46
|
);
|
|
44
47
|
};
|
|
48
|
+
/* end_public_function */
|
|
@@ -7,6 +7,9 @@ import { getResolver } from '~/core/model';
|
|
|
7
7
|
|
|
8
8
|
import { prepareCommunityPayload } from '../utils';
|
|
9
9
|
|
|
10
|
+
/* begin_public_function
|
|
11
|
+
id: community.query
|
|
12
|
+
*/
|
|
10
13
|
/**
|
|
11
14
|
* ```js
|
|
12
15
|
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
@@ -30,7 +33,7 @@ export const queryCommunities = async (
|
|
|
30
33
|
|
|
31
34
|
// safe decapsulation
|
|
32
35
|
const { page, ...params } = query ?? {};
|
|
33
|
-
const { displayName, membership, ...restParams } = params ?? {};
|
|
36
|
+
const { displayName, membership, includeDeleted, ...restParams } = params ?? {};
|
|
34
37
|
|
|
35
38
|
// API-FIX: parameters should be querystring.
|
|
36
39
|
// API-FIX: backend doesnt answer Amity.Response
|
|
@@ -40,6 +43,7 @@ export const queryCommunities = async (
|
|
|
40
43
|
{
|
|
41
44
|
params: {
|
|
42
45
|
...restParams,
|
|
46
|
+
isDeleted: includeDeleted === false ? false : undefined,
|
|
43
47
|
keyword: displayName,
|
|
44
48
|
filter: membership,
|
|
45
49
|
options: {
|
|
@@ -71,6 +75,7 @@ export const queryCommunities = async (
|
|
|
71
75
|
|
|
72
76
|
return { data: communities, cachedAt, prevPage, nextPage };
|
|
73
77
|
};
|
|
78
|
+
/* end_public_function */
|
|
74
79
|
|
|
75
80
|
/**
|
|
76
81
|
* ```js
|
|
@@ -6,6 +6,9 @@ import { toPage, toToken } from '~/core/query';
|
|
|
6
6
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
7
7
|
import { prepareMembershipPayload } from '~/group/utils';
|
|
8
8
|
|
|
9
|
+
/* begin_public_function
|
|
10
|
+
id: community.membership.query
|
|
11
|
+
*/
|
|
9
12
|
/**
|
|
10
13
|
* ```js
|
|
11
14
|
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -66,6 +69,7 @@ export const queryCommunityMembers = async (
|
|
|
66
69
|
|
|
67
70
|
return { data: communityUsers, cachedAt, nextPage, prevPage };
|
|
68
71
|
};
|
|
72
|
+
/* end_public_function */
|
|
69
73
|
|
|
70
74
|
/**
|
|
71
75
|
* ```js
|
|
@@ -4,6 +4,9 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
|
4
4
|
import { fireEvent } from '~/core/events';
|
|
5
5
|
import { prepareMembershipPayload } from '~/group/utils';
|
|
6
6
|
|
|
7
|
+
/* begin_public_function
|
|
8
|
+
id: community.membership.remove_member
|
|
9
|
+
*/
|
|
7
10
|
/**
|
|
8
11
|
* ```js
|
|
9
12
|
* import { removeCommunityMembers } from '@amityco/ts-sdk'
|
|
@@ -44,3 +47,4 @@ export const removeCommunityMembers = async (
|
|
|
44
47
|
communityUser.communityId === communityId && communityUser.communityMembership !== 'member',
|
|
45
48
|
);
|
|
46
49
|
};
|
|
50
|
+
/* end_public_function */
|
|
@@ -3,6 +3,9 @@ import { getActiveClient } from '~/client/api';
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { prepareMembershipPayload } from '~/group/utils';
|
|
5
5
|
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: community.moderation.remove_roles
|
|
8
|
+
*/
|
|
6
9
|
/**
|
|
7
10
|
* ```js
|
|
8
11
|
* import { removeCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
@@ -43,3 +46,4 @@ export const removeCommunityMembersRoles = async (
|
|
|
43
46
|
!roleIds.some(role => communityUser.roles.includes(role)),
|
|
44
47
|
);
|
|
45
48
|
};
|
|
49
|
+
/* end_public_function */
|
|
@@ -68,6 +68,36 @@ describe('queryCommunities', () => {
|
|
|
68
68
|
|
|
69
69
|
await expect(queryCommunities(queryCriteria)).rejects.toThrow('error');
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
test('it should set isDeleted to undefined if includeDeleted is true', async () => {
|
|
73
|
+
const mockFn = jest.fn();
|
|
74
|
+
client.http.get = mockFn.mockResolvedValue(resolvedGetValue);
|
|
75
|
+
|
|
76
|
+
await queryCommunities({ ...queryCriteriaWithoutPage, includeDeleted: true });
|
|
77
|
+
|
|
78
|
+
expect(mockFn.mock.lastCall).toHaveLength(2);
|
|
79
|
+
expect(mockFn.mock.lastCall[1].params.isDeleted).toBeUndefined();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('it should set isDeleted to false if includeDeleted is false', async () => {
|
|
83
|
+
const mockFn = jest.fn();
|
|
84
|
+
client.http.get = mockFn.mockResolvedValue(resolvedGetValue);
|
|
85
|
+
|
|
86
|
+
await queryCommunities({ ...queryCriteriaWithoutPage, includeDeleted: false });
|
|
87
|
+
|
|
88
|
+
expect(mockFn.mock.lastCall).toHaveLength(2);
|
|
89
|
+
expect(mockFn.mock.lastCall[1].params.isDeleted).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('it should set isDeleted to undefined if includeDeleted is undefined', async () => {
|
|
93
|
+
const mockFn = jest.fn();
|
|
94
|
+
client.http.get = mockFn.mockResolvedValue(resolvedGetValue);
|
|
95
|
+
|
|
96
|
+
await queryCommunities(queryCriteriaWithoutPage);
|
|
97
|
+
|
|
98
|
+
expect(mockFn.mock.lastCall).toHaveLength(2);
|
|
99
|
+
expect(mockFn.mock.lastCall[1].params.isDeleted).toBeUndefined();
|
|
100
|
+
});
|
|
71
101
|
});
|
|
72
102
|
|
|
73
103
|
describe.skip('queryCommunities.locally', () => {
|
|
@@ -5,6 +5,9 @@ import { fireEvent } from '~/core/events';
|
|
|
5
5
|
|
|
6
6
|
import { prepareCommunityRequest, prepareCommunityPayload } from '../utils';
|
|
7
7
|
|
|
8
|
+
/* begin_public_function
|
|
9
|
+
id: community.update
|
|
10
|
+
*/
|
|
8
11
|
/**
|
|
9
12
|
* ```js
|
|
10
13
|
* import { updateCommunity } from '@amityco/ts-sdk'
|
|
@@ -49,3 +52,4 @@ export const updateCommunity = async (
|
|
|
49
52
|
cachedAt,
|
|
50
53
|
};
|
|
51
54
|
};
|
|
55
|
+
/* end_public_function */
|
|
@@ -73,9 +73,12 @@ export const liveCommunities = (
|
|
|
73
73
|
.filter(Boolean)
|
|
74
74
|
.map(({ data }) => data) ?? [];
|
|
75
75
|
|
|
76
|
-
communities = filterByPropEquality(communities, 'isDeleted', params.isDeleted);
|
|
77
76
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
78
77
|
|
|
78
|
+
if (params.includeDeleted === false) {
|
|
79
|
+
communities = filterByPropEquality(communities, 'isDeleted', false);
|
|
80
|
+
}
|
|
81
|
+
|
|
79
82
|
if (params.categoryId) {
|
|
80
83
|
communities = communities.filter(c => c.categoryIds?.includes(params.categoryId!));
|
|
81
84
|
}
|
|
@@ -85,7 +85,7 @@ describe('liveCommunities', () => {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
const filters: [string, Amity.CommunityLiveCollection, Amity.Community[]][] = [
|
|
88
|
-
['deleted', {
|
|
88
|
+
['not deleted', { includeDeleted: false }, [community2]],
|
|
89
89
|
['categoryId', { categoryId: 'test-category-id' }, [community1]],
|
|
90
90
|
['displayName', { displayName: 'community 1' }, [community1]],
|
|
91
91
|
['tagged', { tags: ['test-community-tag'] }, [community1]],
|
|
@@ -200,7 +200,7 @@ describe('liveCommunities', () => {
|
|
|
200
200
|
const callback = jest.fn();
|
|
201
201
|
client.http.get = jest.fn().mockResolvedValue(communityQueryResponse);
|
|
202
202
|
|
|
203
|
-
liveCommunities({
|
|
203
|
+
liveCommunities({ includeDeleted: false }, callback);
|
|
204
204
|
await pause();
|
|
205
205
|
|
|
206
206
|
client.emitter.emit(event, communityPayload);
|
|
@@ -31,6 +31,7 @@ const idResolvers: Resolvers = {
|
|
|
31
31
|
stream: ({ streamId }) => streamId,
|
|
32
32
|
|
|
33
33
|
follow: ({ from, to }) => `${from}#${to}`,
|
|
34
|
+
followInfo: ({ userId }) => userId,
|
|
34
35
|
followCount: ({ userId }) => userId,
|
|
35
36
|
|
|
36
37
|
feed: ({ targetId, feedId }) => `${targetId}#${feedId}`,
|
|
@@ -36,8 +36,9 @@ const CRITERIAS: Criterias = {
|
|
|
36
36
|
reaction: ['reactionId'],
|
|
37
37
|
stream: ['streamId'],
|
|
38
38
|
follow: ['from', 'to'],
|
|
39
|
-
followCount: ['userId', 'followerCount'],
|
|
40
39
|
feed: ['feedId', 'feedType'],
|
|
40
|
+
followInfo: ['userId', 'status'],
|
|
41
|
+
followCount: ['userId', 'followerCount'],
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
/** @hidden */
|