@amityco/ts-sdk 0.0.1-beta.39 → 0.0.1-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -0
- package/dist/@types/core/events.d.ts +22 -22
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +87 -34
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -1
- package/dist/@types/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +5 -0
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -0
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +7 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +2 -2
- package/dist/@types/global.d.ts +8 -0
- package/dist/@types/global.d.ts.map +1 -1
- package/dist/cache/api/ingestInCache.d.ts +2 -1
- package/dist/cache/api/ingestInCache.d.ts.map +1 -1
- package/dist/channel/api/banChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/unbanChannelMembers.d.ts.map +1 -1
- package/dist/channel/events/onChannelJoined.d.ts.map +1 -1
- package/dist/channel/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberAdded.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberBanned.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberRemoved.d.ts.map +1 -1
- package/dist/channel/events/onChannelMemberUnbanned.d.ts.map +1 -1
- package/dist/channel/utils/index.d.ts +2 -2
- package/dist/channel/utils/index.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts +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/tests/updateComment.test.d.ts +2 -0
- package/dist/comment/api/tests/updateComment.test.d.ts.map +1 -0
- package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/api/deleteCommunity.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/queryCommunityMembers.d.ts +1 -7
- 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 +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts.map +1 -1
- package/dist/community/events/index.d.ts +2 -0
- package/dist/community/events/index.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserRoleAdded.d.ts +17 -0
- package/dist/community/events/onCommunityUserRoleAdded.d.ts.map +1 -0
- package/dist/community/events/onCommunityUserRoleRemoved.d.ts +17 -0
- package/dist/community/events/onCommunityUserRoleRemoved.d.ts.map +1 -0
- package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts +2 -0
- package/dist/community/events/test/onCommunityUserRoleAdded.test.d.ts.map +1 -0
- package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts +2 -0
- package/dist/community/events/test/onCommunityUserRoleRemoved.test.d.ts.map +1 -0
- package/dist/community/events/utils.d.ts.map +1 -1
- package/dist/community/observers/index.d.ts +2 -0
- package/dist/community/observers/index.d.ts.map +1 -1
- package/dist/community/observers/liveCommunity.d.ts +21 -0
- package/dist/community/observers/liveCommunity.d.ts.map +1 -0
- package/dist/community/observers/liveCommunityMembers.d.ts +20 -0
- package/dist/community/observers/liveCommunityMembers.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunity.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunity.test.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunityMembers.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunityMembers.test.d.ts.map +1 -0
- package/dist/community/utils/payload.d.ts +3 -5
- package/dist/community/utils/payload.d.ts.map +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts +2 -4
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts +2 -2
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/external/api/tests/createUserToken.test.d.ts +2 -0
- package/dist/external/api/tests/createUserToken.test.d.ts.map +1 -0
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/group/utils/withUser.d.ts.map +1 -1
- package/dist/index.cjs.js +481 -200
- package/dist/index.esm.js +477 -200
- package/dist/index.umd.js +4 -4
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/utils/index.d.ts +3 -3
- package/dist/message/utils/index.d.ts.map +1 -1
- package/dist/poll/api/tests/closePoll.test.d.ts +2 -0
- package/dist/poll/api/tests/closePoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/createPoll.test.d.ts +2 -0
- package/dist/poll/api/tests/createPoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/getPoll.test.d.ts +2 -0
- package/dist/poll/api/tests/getPoll.test.d.ts.map +1 -0
- package/dist/poll/api/tests/votePoll.test.d.ts +2 -0
- package/dist/poll/api/tests/votePoll.test.d.ts.map +1 -0
- 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/events/utils.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/reaction/events/onReactorAdded.d.ts.map +1 -1
- package/dist/reaction/events/onReactorRemoved.d.ts.map +1 -1
- package/dist/reaction/utils/dispatchReactable.d.ts +1 -1
- package/dist/reaction/utils/dispatchReactable.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/subChannel/utils/index.d.ts +1 -1
- package/dist/subChannel/utils/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/channel.d.ts +31 -35
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +35 -84
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/dist/utils/tests/dummy/feed.d.ts +2 -18
- package/dist/utils/tests/dummy/feed.d.ts.map +1 -1
- package/dist/utils/tests/dummy/member.d.ts +1 -1
- package/dist/utils/tests/dummy/post.d.ts +30 -29
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +22 -20
- package/src/@types/core/model.ts +3 -2
- package/src/@types/core/payload.ts +102 -38
- package/src/@types/domains/channel.ts +1 -1
- package/src/@types/domains/client.ts +1 -1
- package/src/@types/domains/comment.ts +7 -0
- package/src/@types/domains/community.ts +25 -0
- package/src/@types/domains/content.ts +9 -1
- package/src/@types/domains/group.ts +2 -2
- package/src/@types/global.ts +10 -0
- package/src/cache/api/ingestInCache.ts +3 -6
- package/src/cache/api/tests/ingestInCache.test.ts +12 -9
- package/src/channel/api/addChannelMembers.ts +5 -5
- package/src/channel/api/banChannelMembers.ts +1 -3
- package/src/channel/api/getChannel.ts +1 -1
- package/src/channel/api/queryChannelMembers.ts +1 -3
- package/src/channel/api/removeChannelMembers.ts +5 -5
- package/src/channel/api/tests/addChannelMembers.test.ts +4 -3
- package/src/channel/api/tests/createChannel.test.ts +5 -3
- package/src/channel/api/tests/getChannel.test.ts +2 -1
- package/src/channel/api/tests/joinChannel.test.ts +2 -2
- package/src/channel/api/tests/leaveChannel.test.ts +2 -2
- package/src/channel/api/tests/queryChannelMembers.test.ts +2 -5
- package/src/channel/api/tests/queryChannels.test.ts +4 -3
- package/src/channel/api/tests/removeChannelMembers.test.ts +16 -5
- package/src/channel/api/unbanChannelMembers.ts +1 -3
- package/src/channel/events/onChannelJoined.ts +1 -3
- package/src/channel/events/onChannelLeft.ts +1 -3
- package/src/channel/events/onChannelMemberAdded.ts +1 -3
- package/src/channel/events/onChannelMemberBanned.ts +1 -3
- package/src/channel/events/onChannelMemberRemoved.ts +1 -3
- package/src/channel/events/onChannelMemberUnbanned.ts +1 -3
- package/src/channel/observers/tests/liveChannelMembers.test.ts +5 -12
- package/src/channel/observers/tests/liveChannels.test.ts +3 -1
- package/src/channel/utils/index.ts +9 -6
- package/src/comment/api/createComment.ts +18 -2
- package/src/comment/api/deleteComment.ts +19 -2
- package/src/comment/api/tests/createComment.test.ts +169 -9
- package/src/comment/api/tests/updateComment.test.ts +189 -0
- package/src/comment/events/tests/onCommentCreated.test.ts +3 -3
- package/src/comment/events/tests/onCommentDeleted.test.ts +3 -3
- package/src/comment/observers/tests/liveComment.test.ts +18 -2
- package/src/community/api/addCommunityMembers.ts +6 -3
- package/src/community/api/addCommunityMembersRoles.ts +5 -2
- package/src/community/api/createCommunity.ts +5 -5
- package/src/community/api/deleteCommunity.ts +9 -1
- package/src/community/api/getCommunities.ts +2 -2
- package/src/community/api/getCommunity.ts +2 -2
- package/src/community/api/getRecommendedCommunities.ts +2 -2
- package/src/community/api/getTopTrendingCommunities.ts +2 -2
- package/src/community/api/joinCommunity.ts +6 -3
- package/src/community/api/leaveCommunity.ts +6 -3
- package/src/community/api/queryCommunities.ts +3 -3
- package/src/community/api/queryCommunityMembers.ts +3 -7
- package/src/community/api/removeCommunityMembers.ts +7 -3
- package/src/community/api/removeCommunityMembersRoles.ts +5 -2
- package/src/community/api/test/queryCommunityMembers.test.ts +2 -1
- package/src/community/api/test/removeCommunityMemberRole.test.ts +4 -1
- package/src/community/api/updateCommunity.ts +5 -5
- package/src/community/events/index.ts +2 -0
- package/src/community/events/onCommunityUserRoleAdded.ts +20 -0
- package/src/community/events/onCommunityUserRoleRemoved.ts +20 -0
- package/src/community/events/test/onCommunityDeleted.test.ts +8 -1
- package/src/community/events/test/onCommunityUserRoleAdded.test.ts +50 -0
- package/src/community/events/test/onCommunityUserRoleRemoved.test.ts +50 -0
- package/src/community/events/utils.ts +4 -8
- package/src/community/observers/index.ts +4 -0
- package/src/community/observers/liveCommunity.ts +45 -0
- package/src/community/observers/liveCommunityMembers.ts +187 -0
- package/src/community/observers/tests/liveCommunities.test.ts +38 -18
- package/src/community/observers/tests/liveCommunity.test.ts +147 -0
- package/src/community/observers/tests/liveCommunityMembers.test.ts +195 -0
- package/src/community/utils/payload.ts +28 -22
- package/src/core/device.ts +2 -4
- package/src/core/model/idResolvers.ts +4 -3
- package/src/core/model/identifyModel.ts +3 -3
- package/src/core/model/index.ts +1 -0
- package/src/core/query/query.ts +7 -0
- package/src/core/tests/query/query/runQuery.test.ts +8 -3
- package/src/core/tests/subscription.test.ts +80 -2
- package/src/external/api/tests/createUserToken.test.ts +29 -0
- package/src/feed/api/queryGlobalFeed.ts +8 -4
- package/src/group/utils/test/withUsers.test.ts +5 -5
- package/src/group/utils/withUser.ts +20 -14
- package/src/message/api/createMessage.ts +10 -9
- package/src/message/api/getMessage.ts +2 -2
- package/src/message/api/getMessages.ts +1 -1
- package/src/message/api/queryMessages.ts +2 -2
- package/src/message/api/tests/createMessage.test.ts +5 -1
- package/src/message/api/updateMessage.ts +1 -1
- package/src/message/events/onMessageCreated.ts +1 -1
- package/src/message/events/onMessageDeleted.ts +1 -1
- package/src/message/events/onMessageFetched.ts +1 -1
- package/src/message/events/onMessageFlagCleared.ts +1 -1
- package/src/message/events/onMessageFlagged.ts +1 -1
- package/src/message/events/onMessageReactionAdded.ts +1 -1
- package/src/message/events/onMessageReactionRemoved.ts +1 -1
- package/src/message/events/onMessageUnflagged.ts +1 -1
- package/src/message/events/onMessageUpdated.ts +1 -1
- package/src/message/tests/events.test.ts +10 -2
- package/src/message/tests/observers/liveMessage.test.ts +6 -1
- package/src/message/tests/observers/liveMessages.test.ts +16 -3
- package/src/message/utils/index.ts +5 -3
- package/src/poll/api/tests/closePoll.test.ts +50 -0
- package/src/poll/api/tests/createPoll.test.ts +70 -0
- package/src/poll/api/tests/getPoll.test.ts +31 -0
- package/src/poll/api/tests/votePoll.test.ts +41 -0
- package/src/poll/events/onPollDeleted.ts +1 -1
- package/src/poll/events/onPollUpdated.ts +1 -1
- package/src/post/api/approvePost.ts +10 -10
- package/src/post/api/createPost.ts +6 -3
- package/src/post/api/declinePost.ts +11 -11
- package/src/post/api/deletePost.ts +19 -2
- package/src/post/api/getPost.ts +5 -2
- package/src/post/api/getPosts.ts +4 -1
- package/src/post/api/queryPosts.ts +3 -1
- package/src/post/api/tests/queryPosts.test.ts +5 -4
- package/src/post/api/updatePost.ts +4 -1
- package/src/post/events/onPostReactionAdded.ts +1 -1
- package/src/post/events/onPostReactionRemoved.ts +1 -1
- package/src/post/events/utils.ts +12 -2
- package/src/post/observers/tests/livePost.test.ts +10 -3
- package/src/post/observers/tests/livePosts.test.ts +12 -4
- package/src/post/tests/api/getPost.test.ts +13 -3
- package/src/post/tests/api/queryPosts.test.ts +5 -4
- package/src/reaction/api/addReaction.ts +3 -3
- package/src/reaction/api/queryReactions.ts +2 -0
- package/src/reaction/api/removeReaction.ts +4 -3
- package/src/reaction/events/onReactionAdded.ts +3 -3
- package/src/reaction/events/onReactionRemoved.ts +3 -3
- package/src/reaction/events/onReactorAdded.ts +8 -2
- package/src/reaction/events/onReactorRemoved.ts +8 -2
- package/src/reaction/utils/dispatchReactable.ts +1 -1
- package/src/reaction/utils/fetchReference.ts +1 -1
- package/src/report/api/createReport.ts +14 -8
- package/src/report/api/deleteReport.ts +14 -8
- package/src/subChannel/api/createSubChannel.ts +1 -1
- package/src/subChannel/api/getSubChannel.ts +1 -1
- package/src/subChannel/api/getSubChannels.ts +1 -1
- package/src/subChannel/api/querySubChannels.ts +2 -2
- package/src/subChannel/api/updateSubChannel.ts +1 -1
- package/src/subChannel/events/onSubChannelCreated.ts +1 -1
- package/src/subChannel/events/onSubChannelDeleted.ts +1 -1
- package/src/subChannel/events/onSubChannelUpdated.ts +1 -1
- package/src/subChannel/utils/index.ts +2 -2
- package/src/user/observers/tests/liveUsers.test.ts +2 -0
- package/src/user/tests/api/getUser.test.ts +17 -3
- package/src/utils/index.ts +2 -2
- package/src/utils/liveObject.ts +1 -1
- package/src/utils/tests/dummy/channel.ts +18 -11
- package/src/utils/tests/dummy/community.ts +68 -6
- package/src/utils/tests/dummy/feed.ts +1 -1
- package/src/utils/tests/dummy/member.ts +1 -1
- package/src/utils/tests/dummy/post.ts +93 -9
- package/src/version.ts +9 -3
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
disconnectClient,
|
|
8
8
|
pause,
|
|
9
9
|
communityUser11,
|
|
10
|
+
emptyCommunityPayload,
|
|
10
11
|
} from '~/utils/tests';
|
|
11
12
|
|
|
12
13
|
import { liveCommunities } from '../liveCommunities';
|
|
13
|
-
|
|
14
|
-
import { unpackCommunityPayload } from '../../utils';
|
|
14
|
+
import { prepareCommunityPayload } from '../../utils';
|
|
15
15
|
|
|
16
16
|
const getSnapshot = (params?: Record<string, any>) => {
|
|
17
17
|
return {
|
|
@@ -23,10 +23,9 @@ const getSnapshot = (params?: Record<string, any>) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
const { paging, ...payload } = communityQueryResponse.data;
|
|
26
|
-
const { paging: paging2, ...payload2 } = communityQueryResponsePage2.data;
|
|
27
26
|
|
|
28
|
-
const community1 =
|
|
29
|
-
const community2 =
|
|
27
|
+
const community1 = prepareCommunityPayload(payload).communities[0];
|
|
28
|
+
const community2 = prepareCommunityPayload(payload).communities[1];
|
|
30
29
|
|
|
31
30
|
describe('liveCommunities', () => {
|
|
32
31
|
beforeAll(connectClient);
|
|
@@ -49,7 +48,7 @@ describe('liveCommunities', () => {
|
|
|
49
48
|
2,
|
|
50
49
|
expect.objectContaining(
|
|
51
50
|
getSnapshot({
|
|
52
|
-
data:
|
|
51
|
+
data: prepareCommunityPayload(payload).communities,
|
|
53
52
|
loading: false,
|
|
54
53
|
}),
|
|
55
54
|
),
|
|
@@ -70,7 +69,7 @@ describe('liveCommunities', () => {
|
|
|
70
69
|
1,
|
|
71
70
|
expect.objectContaining(
|
|
72
71
|
getSnapshot({
|
|
73
|
-
data:
|
|
72
|
+
data: prepareCommunityPayload(payload).communities,
|
|
74
73
|
}),
|
|
75
74
|
),
|
|
76
75
|
);
|
|
@@ -78,7 +77,7 @@ describe('liveCommunities', () => {
|
|
|
78
77
|
2,
|
|
79
78
|
expect.objectContaining(
|
|
80
79
|
getSnapshot({
|
|
81
|
-
data:
|
|
80
|
+
data: prepareCommunityPayload(payload).communities,
|
|
82
81
|
loading: false,
|
|
83
82
|
}),
|
|
84
83
|
),
|
|
@@ -146,7 +145,7 @@ describe('liveCommunities', () => {
|
|
|
146
145
|
expect.objectContaining(
|
|
147
146
|
getSnapshot({
|
|
148
147
|
loading: false,
|
|
149
|
-
data:
|
|
148
|
+
data: prepareCommunityPayload(payload).communities,
|
|
150
149
|
}),
|
|
151
150
|
),
|
|
152
151
|
);
|
|
@@ -158,10 +157,14 @@ describe('liveCommunities', () => {
|
|
|
158
157
|
communityId: 'new-community',
|
|
159
158
|
isDeleted: false,
|
|
160
159
|
};
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
|
|
161
|
+
const newCommunity = prepareCommunityPayload({
|
|
162
|
+
...emptyCommunityPayload,
|
|
163
|
+
communities: [newCommunityPayload],
|
|
164
|
+
}).communities[0];
|
|
163
165
|
|
|
164
166
|
const communityPayload = {
|
|
167
|
+
...emptyCommunityPayload,
|
|
165
168
|
communities: [communityQueryResponse.data.communities[0]],
|
|
166
169
|
communityUsers: [communityUser11],
|
|
167
170
|
};
|
|
@@ -170,13 +173,19 @@ describe('liveCommunities', () => {
|
|
|
170
173
|
[
|
|
171
174
|
'it should add new community to collection onCreate',
|
|
172
175
|
'community.created',
|
|
173
|
-
{
|
|
176
|
+
{
|
|
177
|
+
...emptyCommunityPayload,
|
|
178
|
+
communities: [newCommunityPayload],
|
|
179
|
+
},
|
|
174
180
|
[newCommunity, community2],
|
|
175
181
|
],
|
|
176
182
|
[
|
|
177
183
|
'it should update community in collection onUpdate',
|
|
178
184
|
'community.updated',
|
|
179
|
-
{
|
|
185
|
+
{
|
|
186
|
+
...emptyCommunityPayload,
|
|
187
|
+
communities: [{ ...newCommunityPayload, communityId: community1.communityId }],
|
|
188
|
+
},
|
|
180
189
|
[{ ...newCommunity, communityId: community1.communityId }, community2],
|
|
181
190
|
],
|
|
182
191
|
[
|
|
@@ -213,10 +222,13 @@ describe('liveCommunities', () => {
|
|
|
213
222
|
communityId: 'joining-community',
|
|
214
223
|
isDeleted: false,
|
|
215
224
|
};
|
|
216
|
-
const joinedCommunity = unpackCommunityPayload({ communities: [joinCommunityPayload] })
|
|
217
|
-
.communities[0];
|
|
218
225
|
|
|
219
|
-
const
|
|
226
|
+
const joinedCommunity = prepareCommunityPayload({
|
|
227
|
+
...emptyCommunityPayload,
|
|
228
|
+
communities: [joinCommunityPayload],
|
|
229
|
+
}).communities[0];
|
|
230
|
+
|
|
231
|
+
const joiningUser: Amity.RawMembership<'community'> = {
|
|
220
232
|
...communityUser11,
|
|
221
233
|
userId: 'test',
|
|
222
234
|
communityId: 'joining-community',
|
|
@@ -234,14 +246,22 @@ describe('liveCommunities', () => {
|
|
|
234
246
|
'it should add new community to collection onJoin',
|
|
235
247
|
{ membership: 'member' },
|
|
236
248
|
'community.joined',
|
|
237
|
-
{
|
|
249
|
+
{
|
|
250
|
+
...emptyCommunityPayload,
|
|
251
|
+
communities: [joinCommunityPayload],
|
|
252
|
+
communityUsers: [joiningUser],
|
|
253
|
+
},
|
|
238
254
|
[joinedCommunity, community1],
|
|
239
255
|
],
|
|
240
256
|
[
|
|
241
257
|
'it should not add new member to community collection onJoin if membership:not member',
|
|
242
258
|
{ membership: 'notMember' },
|
|
243
259
|
'community.joined',
|
|
244
|
-
{
|
|
260
|
+
{
|
|
261
|
+
...emptyCommunityPayload,
|
|
262
|
+
communities: [joinCommunityPayload],
|
|
263
|
+
communityUsers: [joiningUser],
|
|
264
|
+
},
|
|
245
265
|
[],
|
|
246
266
|
],
|
|
247
267
|
[
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { disableCache, enableCache } from '~/cache/api';
|
|
2
|
+
import {
|
|
3
|
+
pause,
|
|
4
|
+
client,
|
|
5
|
+
connectClient,
|
|
6
|
+
disconnectClient,
|
|
7
|
+
community11,
|
|
8
|
+
user11,
|
|
9
|
+
communityUser11,
|
|
10
|
+
communityUser12,
|
|
11
|
+
} from '~/utils/tests';
|
|
12
|
+
import { getFutureDate } from '~/core/model';
|
|
13
|
+
|
|
14
|
+
import { liveCommunity } from '../liveCommunity';
|
|
15
|
+
|
|
16
|
+
const { communityId } = community11;
|
|
17
|
+
const response = {
|
|
18
|
+
data: {
|
|
19
|
+
communities: [community11],
|
|
20
|
+
communityUsers: [communityUser11],
|
|
21
|
+
files: [],
|
|
22
|
+
users: [user11],
|
|
23
|
+
categories: [],
|
|
24
|
+
feeds: [],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe('liveCommunity events', () => {
|
|
29
|
+
beforeAll(connectClient);
|
|
30
|
+
afterAll(disconnectClient);
|
|
31
|
+
|
|
32
|
+
beforeEach(enableCache);
|
|
33
|
+
afterEach(disableCache);
|
|
34
|
+
|
|
35
|
+
const events: [string, keyof Amity.MqttCommunityEvents][] = [
|
|
36
|
+
['it should get update on community.updated event', 'community.updated'],
|
|
37
|
+
['it should get update on community.deleted event', 'community.deleted'],
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
test.each(events)('%s', async (test, event) => {
|
|
41
|
+
const update =
|
|
42
|
+
event === 'community.updated'
|
|
43
|
+
? {
|
|
44
|
+
...community11,
|
|
45
|
+
displayName: 'updated-name',
|
|
46
|
+
updatedAt: getFutureDate(community11.updatedAt),
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
...community11,
|
|
50
|
+
isDeleted: true,
|
|
51
|
+
updatedAt: getFutureDate(community11.updatedAt),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const callback = jest.fn();
|
|
55
|
+
client.http.get = jest.fn().mockResolvedValue(response);
|
|
56
|
+
|
|
57
|
+
const unsub = liveCommunity(communityId, callback);
|
|
58
|
+
await pause();
|
|
59
|
+
|
|
60
|
+
client.emitter.emit(event, {
|
|
61
|
+
communities: [update],
|
|
62
|
+
communityUsers: [],
|
|
63
|
+
categories: [],
|
|
64
|
+
feeds: [],
|
|
65
|
+
users: [user11],
|
|
66
|
+
files: [],
|
|
67
|
+
});
|
|
68
|
+
await pause();
|
|
69
|
+
|
|
70
|
+
expect(callback).toHaveBeenCalledTimes(3);
|
|
71
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
72
|
+
3,
|
|
73
|
+
expect.objectContaining({
|
|
74
|
+
data: update,
|
|
75
|
+
loading: false,
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
unsub();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const communityUserEvents: [string, keyof Amity.MqttCommunityUserEvents][] = [
|
|
83
|
+
['it should add user on community.joined event', 'community.joined'],
|
|
84
|
+
['should get update on community.left event', 'community.left'],
|
|
85
|
+
['should get update on community.userChanged event', 'community.userChanged'],
|
|
86
|
+
['should get update on community.userBanned event', 'community.userBanned'],
|
|
87
|
+
['should get update on community.userUnbanned event', 'community.userUnbanned'],
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
test.each(communityUserEvents)('%s', async (test, event) => {
|
|
91
|
+
const callback = jest.fn();
|
|
92
|
+
client.http.get = jest.fn().mockResolvedValue(response);
|
|
93
|
+
|
|
94
|
+
const community = {
|
|
95
|
+
...community11,
|
|
96
|
+
updatedAt: getFutureDate(community11.updatedAt),
|
|
97
|
+
};
|
|
98
|
+
let communityUsers: Amity.RawMembership<'community'>[];
|
|
99
|
+
let communities: Amity.RawCommunity[];
|
|
100
|
+
|
|
101
|
+
switch (event) {
|
|
102
|
+
case 'community.userChanged':
|
|
103
|
+
case 'community.left':
|
|
104
|
+
communityUsers = [communityUser11];
|
|
105
|
+
communities = [{ ...community, isJoined: true }];
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case 'community.userBanned':
|
|
109
|
+
communities = [{ ...community, isJoined: true }];
|
|
110
|
+
communityUsers = [{ ...communityUser11, communityMembership: 'banned' }];
|
|
111
|
+
break;
|
|
112
|
+
|
|
113
|
+
case 'community.userUnbanned':
|
|
114
|
+
communityUsers = [communityUser11];
|
|
115
|
+
communities = [{ ...community, isJoined: true }];
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
// community.joined
|
|
119
|
+
default:
|
|
120
|
+
communities = [community];
|
|
121
|
+
communityUsers = [communityUser12];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const unsub = liveCommunity(communityId, callback);
|
|
125
|
+
await pause();
|
|
126
|
+
|
|
127
|
+
client.emitter.emit(event, {
|
|
128
|
+
communities,
|
|
129
|
+
communityUsers,
|
|
130
|
+
categories: [],
|
|
131
|
+
feeds: [],
|
|
132
|
+
users: [user11],
|
|
133
|
+
files: [],
|
|
134
|
+
});
|
|
135
|
+
await pause();
|
|
136
|
+
|
|
137
|
+
expect(callback).toHaveBeenCalledTimes(3);
|
|
138
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
139
|
+
3,
|
|
140
|
+
expect.objectContaining({
|
|
141
|
+
data: communities[0],
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
unsub();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { disableCache, enableCache } from '~/cache/api';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
client,
|
|
5
|
+
connectClient,
|
|
6
|
+
disconnectClient,
|
|
7
|
+
pause,
|
|
8
|
+
user11,
|
|
9
|
+
user13,
|
|
10
|
+
community11,
|
|
11
|
+
communityUser11,
|
|
12
|
+
communityUser13,
|
|
13
|
+
withRoleCommunityUser,
|
|
14
|
+
bannedCommunityUser,
|
|
15
|
+
communityUserQueryResponse,
|
|
16
|
+
communityUserQueryResponsePage2,
|
|
17
|
+
convertedCommunityUser1,
|
|
18
|
+
convertedCommunityUser2,
|
|
19
|
+
convertedCommunityUser3,
|
|
20
|
+
} from '~/utils/tests';
|
|
21
|
+
|
|
22
|
+
import { liveCommunityMembers } from '../liveCommunityMembers';
|
|
23
|
+
|
|
24
|
+
const getSnapshot = (params?: Record<string, any>) => {
|
|
25
|
+
return {
|
|
26
|
+
data: [] as Amity.Membership<'community'>[],
|
|
27
|
+
loading: true,
|
|
28
|
+
error: undefined as any,
|
|
29
|
+
...params,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe('liveCommunityMembers', () => {
|
|
34
|
+
beforeAll(connectClient);
|
|
35
|
+
afterAll(disconnectClient);
|
|
36
|
+
|
|
37
|
+
beforeEach(enableCache);
|
|
38
|
+
afterEach(disableCache);
|
|
39
|
+
|
|
40
|
+
const { communityId } = community11;
|
|
41
|
+
|
|
42
|
+
test('it should return community members collection', async () => {
|
|
43
|
+
const callback = jest.fn();
|
|
44
|
+
client.http.get = jest.fn().mockResolvedValue(communityUserQueryResponse);
|
|
45
|
+
|
|
46
|
+
liveCommunityMembers({ communityId }, callback);
|
|
47
|
+
await pause();
|
|
48
|
+
|
|
49
|
+
expect(callback).toHaveBeenNthCalledWith(1, expect.objectContaining(getSnapshot()));
|
|
50
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
51
|
+
2,
|
|
52
|
+
expect.objectContaining(
|
|
53
|
+
getSnapshot({ data: [convertedCommunityUser2, convertedCommunityUser1], loading: false }),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const filters: [string, Amity.CommunityMemberLiveCollection, Amity.Membership<'community'>[]][] =
|
|
59
|
+
[
|
|
60
|
+
['roles', { communityId, roles: ['test-role'] }, [withRoleCommunityUser]],
|
|
61
|
+
[
|
|
62
|
+
'searched term',
|
|
63
|
+
{ communityId, search: 'use' },
|
|
64
|
+
[withRoleCommunityUser, bannedCommunityUser],
|
|
65
|
+
],
|
|
66
|
+
['member', { communityId, membership: ['member'] }, [withRoleCommunityUser]],
|
|
67
|
+
['banned members', { communityId, membership: ['banned'] }, [bannedCommunityUser]],
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
test.each(filters)('it should filter channelUsers by %s', async (filter, params, expected) => {
|
|
71
|
+
const callback = jest.fn();
|
|
72
|
+
client.http.get = jest.fn().mockResolvedValue(communityUserQueryResponsePage2);
|
|
73
|
+
|
|
74
|
+
liveCommunityMembers(params, callback);
|
|
75
|
+
await pause();
|
|
76
|
+
|
|
77
|
+
expect(callback).toHaveBeenNthCalledWith(1, expect.objectContaining(getSnapshot()));
|
|
78
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
79
|
+
2,
|
|
80
|
+
expect.objectContaining({ data: expected, loading: false }),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('it should return method to fetch next page', async () => {
|
|
85
|
+
const callback = jest.fn();
|
|
86
|
+
client.http.get = jest
|
|
87
|
+
.fn()
|
|
88
|
+
.mockResolvedValue(communityUserQueryResponse)
|
|
89
|
+
.mockResolvedValueOnce(communityUserQueryResponsePage2);
|
|
90
|
+
|
|
91
|
+
liveCommunityMembers({ communityId, sortBy: 'firstCreated' }, callback);
|
|
92
|
+
await pause();
|
|
93
|
+
|
|
94
|
+
expect(callback).toHaveBeenCalled();
|
|
95
|
+
expect(callback.mock.lastCall).toHaveLength(1);
|
|
96
|
+
|
|
97
|
+
const { onNextPage, hasNextPage } = callback.mock.lastCall[0];
|
|
98
|
+
|
|
99
|
+
expect(hasNextPage).toBe(true);
|
|
100
|
+
expect(onNextPage).toBeTruthy();
|
|
101
|
+
|
|
102
|
+
onNextPage();
|
|
103
|
+
await pause();
|
|
104
|
+
|
|
105
|
+
const payload = [convertedCommunityUser1, convertedCommunityUser2];
|
|
106
|
+
const payload2 = [withRoleCommunityUser, bannedCommunityUser];
|
|
107
|
+
|
|
108
|
+
const snapshot = getSnapshot();
|
|
109
|
+
snapshot.loading = false;
|
|
110
|
+
snapshot.data = [...payload2, ...payload];
|
|
111
|
+
|
|
112
|
+
expect(callback).toHaveBeenNthCalledWith(4, expect.objectContaining(snapshot));
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const events: [
|
|
116
|
+
string,
|
|
117
|
+
keyof Amity.Events,
|
|
118
|
+
Amity.RawMembership<'community'>,
|
|
119
|
+
Amity.User,
|
|
120
|
+
Amity.Membership<'community'>[],
|
|
121
|
+
][] = [
|
|
122
|
+
[
|
|
123
|
+
'it should add new member to collection onJoined',
|
|
124
|
+
'community.joined',
|
|
125
|
+
communityUser13,
|
|
126
|
+
user13,
|
|
127
|
+
[convertedCommunityUser1, convertedCommunityUser3, convertedCommunityUser2],
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
'it should remove member from collection onLeft',
|
|
131
|
+
'community.left',
|
|
132
|
+
{ ...communityUser11, communityMembership: 'none' },
|
|
133
|
+
user11,
|
|
134
|
+
[{ ...convertedCommunityUser1, communityMembership: 'none' }, convertedCommunityUser2],
|
|
135
|
+
],
|
|
136
|
+
[
|
|
137
|
+
'it should add new member to collection onMemberCountChanged',
|
|
138
|
+
'community.userChanged',
|
|
139
|
+
communityUser13,
|
|
140
|
+
user13,
|
|
141
|
+
[convertedCommunityUser1, convertedCommunityUser3, convertedCommunityUser2],
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
'it should update member in collection onMemberCountChanged',
|
|
145
|
+
'community.userChanged',
|
|
146
|
+
{ ...communityUser13, communityMembership: 'none' },
|
|
147
|
+
user13,
|
|
148
|
+
[
|
|
149
|
+
convertedCommunityUser1,
|
|
150
|
+
{ ...convertedCommunityUser3, communityMembership: 'none' },
|
|
151
|
+
convertedCommunityUser2,
|
|
152
|
+
],
|
|
153
|
+
],
|
|
154
|
+
[
|
|
155
|
+
'it should update member membership on ban',
|
|
156
|
+
'community.userBanned',
|
|
157
|
+
{ ...communityUser11, communityMembership: 'banned' },
|
|
158
|
+
user11,
|
|
159
|
+
[{ ...convertedCommunityUser1, communityMembership: 'banned' }, convertedCommunityUser2],
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
'it should update membership on Unban',
|
|
163
|
+
'community.userUnbanned',
|
|
164
|
+
communityUser13,
|
|
165
|
+
user13,
|
|
166
|
+
[convertedCommunityUser1, convertedCommunityUser3, convertedCommunityUser2],
|
|
167
|
+
],
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
test.each(events)('%s', async (test, event, communityUserRaw, user, expected) => {
|
|
171
|
+
const callback = jest.fn();
|
|
172
|
+
client.http.get = jest.fn().mockResolvedValue(communityUserQueryResponse);
|
|
173
|
+
|
|
174
|
+
liveCommunityMembers({ communityId, sortBy: 'firstCreated' }, callback);
|
|
175
|
+
await pause();
|
|
176
|
+
|
|
177
|
+
client.emitter.emit(event, {
|
|
178
|
+
communities: [community11],
|
|
179
|
+
communityUsers: [communityUserRaw],
|
|
180
|
+
users: [user],
|
|
181
|
+
files: [],
|
|
182
|
+
});
|
|
183
|
+
await pause();
|
|
184
|
+
|
|
185
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
186
|
+
3,
|
|
187
|
+
expect.objectContaining(
|
|
188
|
+
getSnapshot({
|
|
189
|
+
data: expected,
|
|
190
|
+
loading: false,
|
|
191
|
+
}),
|
|
192
|
+
),
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommunityPostSettingMaps, DefaultCommunityPostSetting } from '~/@types';
|
|
2
|
+
import { withUsers } from '~/group/utils';
|
|
2
3
|
|
|
3
4
|
const getMatchPostSetting = (value: {
|
|
4
5
|
needApprovalOnPostCreation: Amity.RawCommunity['needApprovalOnPostCreation'];
|
|
@@ -11,14 +12,11 @@ const getMatchPostSetting = (value: {
|
|
|
11
12
|
value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost,
|
|
12
13
|
) ?? DefaultCommunityPostSetting;
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
communities
|
|
19
|
-
...restPayload
|
|
20
|
-
}: T) => ({
|
|
21
|
-
communities: communities.map<Amity.Community>(
|
|
15
|
+
export const prepareCommunityPayload = (
|
|
16
|
+
rawPayload: Amity.CommunityPayload,
|
|
17
|
+
): Amity.ProcessedCommunityPayload => {
|
|
18
|
+
// Unpack community payload by mapping payload field to postSetting value.
|
|
19
|
+
const communities = rawPayload.communities.map<Amity.Community>(
|
|
22
20
|
({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
|
|
23
21
|
postSetting: getMatchPostSetting({
|
|
24
22
|
needApprovalOnPostCreation,
|
|
@@ -26,19 +24,27 @@ export const unpackCommunityPayload = <T extends Amity.CommunityPayload>({
|
|
|
26
24
|
}),
|
|
27
25
|
...restCommunityPayload,
|
|
28
26
|
}),
|
|
29
|
-
)
|
|
30
|
-
...restPayload,
|
|
31
|
-
});
|
|
27
|
+
);
|
|
32
28
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
const communityUsers = withUsers(rawPayload.communityUsers);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
...rawPayload,
|
|
33
|
+
communities,
|
|
34
|
+
communityUsers,
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const prepareCommunityRequest = <
|
|
37
39
|
T extends { postSetting?: Amity.Community['postSetting']; [k: string]: any },
|
|
38
|
-
>(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
>(
|
|
41
|
+
params: T,
|
|
42
|
+
) => {
|
|
43
|
+
const { postSetting = undefined, ...restParam } = params;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...restParam,
|
|
47
|
+
// Repack community payload by mapping postSetting to the actual value.
|
|
48
|
+
...(postSetting ? CommunityPostSettingMaps[postSetting] : undefined),
|
|
49
|
+
};
|
|
50
|
+
};
|
package/src/core/device.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
// TODO: find a way to uniquely identify the device
|
|
2
2
|
// import { getStorage } from './storage'
|
|
3
3
|
import { safeProcess } from '~/utils/env';
|
|
4
|
-
|
|
5
|
-
/** @hidden */
|
|
6
|
-
const VERSION = '11.0.0';
|
|
4
|
+
import { VERSION } from '~/version';
|
|
7
5
|
|
|
8
6
|
/** @hidden */
|
|
9
7
|
export const getDeviceId = () => {
|
|
@@ -30,9 +28,9 @@ export const getDeviceInfo = (): Amity.Device['deviceInfo'] => {
|
|
|
30
28
|
const model = getDeviceModel();
|
|
31
29
|
|
|
32
30
|
return {
|
|
33
|
-
version: VERSION,
|
|
34
31
|
// TODO: replace with: kind: process.versions ? 'node' : 'web', when backend has fixed this
|
|
35
32
|
kind: 'web',
|
|
36
33
|
model,
|
|
34
|
+
sdkVersion: VERSION,
|
|
37
35
|
};
|
|
38
36
|
};
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* to avoid using any and give some typing security at the
|
|
5
5
|
* resolver's level.
|
|
6
6
|
*/
|
|
7
|
-
type
|
|
8
|
-
|
|
7
|
+
type Resolver<T extends Amity.Domain> = (model: Amity.Minimal[T]) => string;
|
|
8
|
+
type Resolvers<T extends Amity.Domain = Amity.Domain> = {
|
|
9
|
+
[K in T]: Resolver<K>;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
/** @hidden */
|
|
@@ -41,4 +42,4 @@ const idResolvers: Resolvers = {
|
|
|
41
42
|
* @param name the domain name for the resolve
|
|
42
43
|
* @returns an idResolver function for the given domain name
|
|
43
44
|
*/
|
|
44
|
-
export const getResolver = <T extends Amity.Domain>(name: T):
|
|
45
|
+
export const getResolver = <T extends Amity.Domain>(name: T): Resolver<T> => idResolvers[name];
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* adding new models.
|
|
6
6
|
* @hidden
|
|
7
7
|
*/
|
|
8
|
-
type Criterias<T extends Amity.Domain
|
|
9
|
-
[K in T
|
|
8
|
+
type Criterias<T extends Amity.Domain = Amity.Domain> = {
|
|
9
|
+
[K in T]: (keyof Amity.Models[K])[];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -49,7 +49,7 @@ const hasKeys = (object: Record<string, unknown>, needles: string[]) => {
|
|
|
49
49
|
/**
|
|
50
50
|
* Finds the name of the store for a given unknown model
|
|
51
51
|
*
|
|
52
|
-
* @param model one of the {@link Amity.
|
|
52
|
+
* @param model one of the {@link Amity.Models} to identify
|
|
53
53
|
* @returns the name of the corresponding store
|
|
54
54
|
*/
|
|
55
55
|
export const identifyModel = (model: Record<string, unknown>) => {
|
package/src/core/model/index.ts
CHANGED
package/src/core/query/query.ts
CHANGED
|
@@ -165,6 +165,13 @@ export const runQuery = <Args extends any[], Returned extends any>(
|
|
|
165
165
|
callback?: (args: Amity.Snapshot<Returned>) => void,
|
|
166
166
|
options: Amity.QueryOptions = queryOptions('cache_then_server'),
|
|
167
167
|
) => {
|
|
168
|
+
console.warn(
|
|
169
|
+
'Deprecation Notice: After 1 April 2023, CreateQuery/RunQuery will no longer be supported. You will be able to use the API without either methods. Check https://docs.amity.co/ for details',
|
|
170
|
+
);
|
|
171
|
+
console.warn(
|
|
172
|
+
'Deprecation Notice: After 1 March 2023, individual module imoprts will no longer be supported. All public APIs will need to be imported from their respective repositories. Ex: CommunityRepository, UserRepository, etc. Check https://docs.amity.co/ for detailed info.',
|
|
173
|
+
);
|
|
174
|
+
|
|
168
175
|
let local: Returned | undefined;
|
|
169
176
|
|
|
170
177
|
const { lifeSpan } = queryOptions('cache_then_server', options.lifeSpan);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ASCApiError
|
|
1
|
+
import { ASCApiError } from '~/core/errors';
|
|
2
2
|
import { disableCache, enableCache, pushToCache } from '~/cache/api';
|
|
3
3
|
import { runQuery, createQuery } from '~/core/query';
|
|
4
4
|
import { createPost, getPost } from '~/post/api';
|
|
5
5
|
import { deleteMessage } from '~/message/api';
|
|
6
6
|
|
|
7
|
-
import { posts, client, pause } from '~/utils/tests';
|
|
7
|
+
import { posts, client, pause, emptyPostPayload } from '~/utils/tests';
|
|
8
8
|
|
|
9
9
|
const createPostArgs: Parameters<typeof createPost> = [
|
|
10
10
|
{
|
|
@@ -54,7 +54,12 @@ describe('Core/Query/runQuery', () => {
|
|
|
54
54
|
|
|
55
55
|
test('should call callback with server data for invalid cache', async () => {
|
|
56
56
|
const callback = jest.fn();
|
|
57
|
-
client.http.get = jest.fn().mockResolvedValue({
|
|
57
|
+
client.http.get = jest.fn().mockResolvedValue({
|
|
58
|
+
data: {
|
|
59
|
+
...emptyPostPayload,
|
|
60
|
+
posts: [post],
|
|
61
|
+
},
|
|
62
|
+
});
|
|
58
63
|
|
|
59
64
|
// at the time of writing this test, cache is valid for 2 minutes
|
|
60
65
|
const expiredDate = Date.parse('04 Dec 1995 00:12:00 GMT');
|