@amityco/ts-sdk 0.0.1-beta.36 → 0.0.1-beta.38
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 +3 -5
- package/dist/@types/core/errors.d.ts +1 -0
- package/dist/@types/core/errors.d.ts.map +1 -1
- package/dist/@types/core/events.d.ts +5 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts +7 -0
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +21 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +12 -0
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/global.d.ts +12 -0
- package/dist/@types/global.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts +1 -5
- package/dist/category/api/queryCategories.d.ts.map +1 -1
- package/dist/category/observers/index.d.ts +2 -0
- package/dist/category/observers/index.d.ts.map +1 -0
- package/dist/category/observers/liveCategories.d.ts +18 -0
- package/dist/category/observers/liveCategories.d.ts.map +1 -0
- package/dist/category/observers/tests/liveCategories.test.d.ts +2 -0
- package/dist/category/observers/tests/liveCategories.test.d.ts.map +1 -0
- package/dist/channel/api/tests/getChannels.test.d.ts +2 -0
- package/dist/channel/api/tests/getChannels.test.d.ts.map +1 -0
- package/dist/channel/api/tests/leaveChannel.test.d.ts +2 -0
- package/dist/channel/api/tests/leaveChannel.test.d.ts.map +1 -0
- package/dist/channel/observers/liveChannel.d.ts.map +1 -1
- package/dist/client/api/accessTokenExpiryWatcher.d.ts +7 -0
- package/dist/client/api/accessTokenExpiryWatcher.d.ts.map +1 -0
- package/dist/client/api/activeUser.d.ts +1 -1
- package/dist/client/api/activeUser.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts +1 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +1 -1
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.d.ts +0 -1
- package/dist/client/api/disconnectClient.d.ts.map +1 -1
- package/dist/client/api/getToken.d.ts +7 -5
- package/dist/client/api/getToken.d.ts.map +1 -1
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/renewal.d.ts +2 -0
- package/dist/client/api/renewal.d.ts.map +1 -0
- package/dist/client/api/setSessionState.d.ts +12 -0
- package/dist/client/api/setSessionState.d.ts.map +1 -0
- package/dist/client/api/terminateClient.d.ts +9 -0
- package/dist/client/api/terminateClient.d.ts.map +1 -0
- package/dist/client/api/tests/accessTokenExpiryWatcher.test.d.ts +2 -0
- package/dist/client/api/tests/accessTokenExpiryWatcher.test.d.ts.map +1 -0
- package/dist/client/api/tests/connectClient.test.d.ts +2 -0
- package/dist/client/api/tests/connectClient.test.d.ts.map +1 -0
- package/dist/client/api/tests/disconnectClient.test.d.ts +2 -0
- package/dist/client/api/tests/disconnectClient.test.d.ts.map +1 -0
- package/dist/client/api/tests/getToken.test.d.ts +2 -0
- package/dist/client/api/tests/getToken.test.d.ts.map +1 -0
- package/dist/client/api/tests/renewal.test.d.ts +2 -0
- package/dist/client/api/tests/renewal.test.d.ts.map +1 -0
- package/dist/client/api/tests/setSessionState.test.d.ts +2 -0
- package/dist/client/api/tests/setSessionState.test.d.ts.map +1 -0
- package/dist/client/api/tests/terminateClient.test.d.ts +2 -0
- package/dist/client/api/tests/terminateClient.test.d.ts.map +1 -0
- package/dist/client/events/index.d.ts +1 -0
- package/dist/client/events/index.d.ts.map +1 -1
- package/dist/client/events/onClientBanned.d.ts +1 -1
- package/dist/client/events/onClientBanned.d.ts.map +1 -1
- package/dist/client/events/onSessionStateChange.d.ts +17 -0
- package/dist/client/events/onSessionStateChange.d.ts.map +1 -0
- package/dist/client/events/onTokenExpired.d.ts +17 -0
- package/dist/client/events/onTokenExpired.d.ts.map +1 -0
- package/dist/client/events/onTokenTerminated.d.ts +11 -0
- package/dist/client/events/onTokenTerminated.d.ts.map +1 -0
- package/dist/client/events/tests/onSessionStateChange.test.d.ts +2 -0
- package/dist/client/events/tests/onSessionStateChange.test.d.ts.map +1 -0
- package/dist/client/events/tests/onTokenTerminated.test.d.ts +2 -0
- package/dist/client/events/tests/onTokenTerminated.test.d.ts.map +1 -0
- package/dist/client/utils/setClientToken.d.ts +19 -0
- package/dist/client/utils/setClientToken.d.ts.map +1 -0
- package/dist/comment/api/deleteComment.d.ts.map +1 -1
- package/dist/comment/api/getComment.d.ts.map +1 -1
- package/dist/comment/events/tests/onCommentDeleted.test.d.ts +2 -0
- package/dist/comment/events/tests/onCommentDeleted.test.d.ts.map +1 -0
- package/dist/comment/observers/index.d.ts +1 -0
- package/dist/comment/observers/index.d.ts.map +1 -1
- package/dist/comment/observers/liveComment.d.ts +21 -0
- package/dist/comment/observers/liveComment.d.ts.map +1 -0
- package/dist/comment/observers/tests/liveComment.test.d.ts +2 -0
- package/dist/comment/observers/tests/liveComment.test.d.ts.map +1 -0
- package/dist/community/api/queryCommunities.d.ts +1 -10
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/events/index.d.ts +1 -0
- package/dist/community/events/index.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserChanged.d.ts +17 -0
- package/dist/community/events/onCommunityUserChanged.d.ts.map +1 -0
- package/dist/community/events/utils.d.ts +1 -0
- package/dist/community/events/utils.d.ts.map +1 -1
- package/dist/community/observers/index.d.ts +1 -0
- package/dist/community/observers/index.d.ts.map +1 -1
- package/dist/community/observers/liveCommunities.d.ts +20 -0
- package/dist/community/observers/liveCommunities.d.ts.map +1 -0
- package/dist/community/observers/tests/liveCommunities.test.d.ts +2 -0
- package/dist/community/observers/tests/liveCommunities.test.d.ts.map +1 -0
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/query/sorting.d.ts +6 -0
- package/dist/core/query/sorting.d.ts.map +1 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/core/transports/http.d.ts +0 -5
- package/dist/core/transports/http.d.ts.map +1 -1
- package/dist/file/api/test/createImage.test.d.ts +2 -0
- package/dist/file/api/test/createImage.test.d.ts.map +1 -0
- package/dist/file/api/test/createVideo.test.d.ts +2 -0
- package/dist/file/api/test/createVideo.test.d.ts.map +1 -0
- package/dist/index.cjs.js +944 -332
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +937 -332
- package/dist/index.umd.js +4 -4
- package/dist/message/observers/liveMessage.d.ts.map +1 -1
- package/dist/post/observers/index.d.ts +1 -0
- package/dist/post/observers/index.d.ts.map +1 -1
- package/dist/post/observers/livePost.d.ts +21 -0
- package/dist/post/observers/livePost.d.ts.map +1 -0
- package/dist/post/observers/tests/livePost.test.d.ts +2 -0
- package/dist/post/observers/tests/livePost.test.d.ts.map +1 -0
- package/dist/stream/api/tests/createStream.test.d.ts +2 -0
- package/dist/stream/api/tests/createStream.test.d.ts.map +1 -0
- package/dist/stream/api/tests/deleteStream.test.d.ts +2 -0
- package/dist/stream/api/tests/deleteStream.test.d.ts.map +1 -0
- package/dist/stream/api/tests/getStream.test.d.ts +2 -0
- package/dist/stream/api/tests/getStream.test.d.ts.map +1 -0
- package/dist/subChannel/api/tests/createSubChannel.test.d.ts +2 -0
- package/dist/subChannel/api/tests/createSubChannel.test.d.ts.map +1 -0
- package/dist/subChannel/api/tests/deleteSubChannel.test.d.ts +2 -0
- package/dist/subChannel/api/tests/deleteSubChannel.test.d.ts.map +1 -0
- package/dist/subChannel/api/tests/getSubChannel.test.d.ts +2 -0
- package/dist/subChannel/api/tests/getSubChannel.test.d.ts.map +1 -0
- package/dist/subChannel/api/tests/getSubChannels.test.d.ts +2 -0
- package/dist/subChannel/api/tests/getSubChannels.test.d.ts.map +1 -0
- package/dist/subChannel/api/tests/updateSubChannel.test.d.ts +2 -0
- package/dist/subChannel/api/tests/updateSubChannel.test.d.ts.map +1 -0
- package/dist/subChannel/observers/liveSubChannel.d.ts.map +1 -1
- package/dist/user/api/tests/updateUser.test.d.ts +2 -0
- package/dist/user/api/tests/updateUser.test.d.ts.map +1 -0
- package/dist/user/observers/liveUser.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +2 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/liveObject.d.ts +2 -0
- package/dist/utils/liveObject.d.ts.map +1 -0
- package/dist/utils/tests/client.d.ts.map +1 -1
- package/dist/utils/tests/dummy/category.d.ts +64 -0
- package/dist/utils/tests/dummy/category.d.ts.map +1 -0
- package/dist/utils/tests/dummy/channel.d.ts +50 -0
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/community.d.ts +132 -0
- package/dist/utils/tests/dummy/community.d.ts.map +1 -1
- package/dist/utils/tests/dummy/file.d.ts +3 -0
- package/dist/utils/tests/dummy/file.d.ts.map +1 -1
- package/dist/utils/tests/dummy/index.d.ts +3 -0
- package/dist/utils/tests/dummy/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/post.d.ts +2 -0
- package/dist/utils/tests/dummy/post.d.ts.map +1 -1
- package/dist/utils/tests/dummy/stream.d.ts +83 -0
- package/dist/utils/tests/dummy/stream.d.ts.map +1 -0
- package/dist/utils/tests/dummy/token.d.ts +11 -0
- package/dist/utils/tests/dummy/token.d.ts.map +1 -0
- package/dist/utils/tests/dummy/user.d.ts +18 -0
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/dist/utils/tests/liveObject.test.d.ts +2 -0
- package/dist/utils/tests/liveObject.test.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/@types/core/errors.ts +1 -0
- package/src/@types/core/events.ts +7 -0
- package/src/@types/domains/category.ts +13 -0
- package/src/@types/domains/client.ts +45 -1
- package/src/@types/domains/community.ts +25 -0
- package/src/@types/global.ts +19 -0
- package/src/category/api/queryCategories.ts +3 -5
- package/src/category/observers/index.ts +1 -0
- package/src/category/observers/liveCategories.ts +141 -0
- package/src/category/observers/tests/liveCategories.test.ts +147 -0
- package/src/channel/api/tests/createChannel.test.ts +30 -6
- package/src/channel/api/tests/getChannel.test.ts +3 -1
- package/src/channel/api/tests/getChannels.test.ts +97 -0
- package/src/channel/api/tests/joinChannel.test.ts +62 -3
- package/src/channel/api/tests/leaveChannel.test.ts +90 -0
- package/src/channel/api/tests/queryChannels.test.ts +38 -1
- package/src/channel/observers/liveChannel.ts +8 -80
- package/src/client/api/accessTokenExpiryWatcher.ts +85 -0
- package/src/client/api/activeUser.ts +1 -1
- package/src/client/api/connectClient.ts +105 -24
- package/src/client/api/createClient.ts +9 -1
- package/src/client/api/disconnectClient.ts +26 -2
- package/src/client/api/getToken.ts +6 -6
- package/src/client/api/index.ts +2 -0
- package/src/client/api/renewal.ts +74 -0
- package/src/client/api/setSessionState.ts +75 -0
- package/src/client/api/terminateClient.ts +20 -0
- package/src/client/api/tests/accessTokenExpiryWatcher.test.ts +132 -0
- package/src/client/api/tests/connectClient.test.ts +84 -0
- package/src/client/api/tests/createClient.test.ts +8 -0
- package/src/client/api/tests/disconnectClient.test.ts +78 -0
- package/src/client/api/tests/getToken.test.ts +36 -0
- package/src/client/api/tests/renewal.test.ts +67 -0
- package/src/client/api/tests/setSessionState.test.ts +62 -0
- package/src/client/api/tests/terminateClient.test.ts +29 -0
- package/src/client/events/index.ts +2 -0
- package/src/client/events/onClientBanned.ts +12 -5
- package/src/client/events/onSessionStateChange.ts +31 -0
- package/src/client/events/onTokenExpired.ts +26 -0
- package/src/client/events/onTokenTerminated.ts +20 -0
- package/src/client/events/tests/onSessionStateChange.test.ts +37 -0
- package/src/client/events/tests/onTokenTerminated.test.ts +37 -0
- package/src/client/tests/connectClient.test.ts +6 -1
- package/src/client/utils/setClientToken.ts +39 -0
- package/src/comment/api/deleteComment.ts +5 -5
- package/src/comment/api/getComment.ts +8 -3
- package/src/comment/events/tests/onCommentDeleted.test.ts +27 -0
- package/src/comment/observers/index.ts +1 -0
- package/src/comment/observers/liveComment.ts +43 -0
- package/src/comment/observers/tests/liveComment.test.ts +95 -0
- package/src/community/api/queryCommunities.ts +3 -10
- package/src/community/api/test/addCommunityMember.test.ts +14 -2
- package/src/community/api/test/joinCommunity.test.ts +14 -2
- package/src/community/api/test/leaveCommunity.test.ts +11 -1
- package/src/community/api/test/removeCommunityMembers.test.ts +11 -1
- package/src/community/events/index.ts +1 -0
- package/src/community/events/onCommunityUserChanged.ts +20 -0
- package/src/community/events/test/onCommunityJoined.test.ts +1 -1
- package/src/community/events/test/onCommunityUserAdded.test.ts +1 -1
- package/src/community/events/test/onCommunityUserBanned.test.ts +1 -1
- package/src/community/events/test/onCommunityUserUnbaned.test.ts +1 -1
- package/src/community/events/test/utils.test.ts +52 -3
- package/src/community/events/utils.ts +49 -0
- package/src/community/observers/index.ts +1 -0
- package/src/community/observers/liveCommunities.ts +188 -0
- package/src/community/observers/tests/liveCommunities.test.ts +284 -0
- package/src/core/events.ts +5 -3
- package/src/core/query/sorting.ts +8 -0
- package/src/core/subscription.ts +3 -1
- package/src/core/transports/http.ts +52 -13
- package/src/core/transports/mqtt.ts +1 -1
- package/src/core/transports/test/http.test.ts +49 -60
- package/src/external/api/createUserToken.ts +2 -2
- package/src/file/api/createFile.ts +1 -1
- package/src/file/api/createImage.ts +1 -1
- package/src/file/api/createVideo.ts +1 -1
- package/src/file/api/test/createImage.test.ts +69 -0
- package/src/file/api/test/createVideo.test.ts +81 -0
- package/src/index.ts +1 -0
- package/src/message/observers/liveMessage.ts +11 -83
- package/src/message/tests/observers/liveMessage.test.ts +1 -143
- package/src/post/observers/index.ts +1 -0
- package/src/post/observers/livePost.ts +47 -0
- package/src/post/observers/tests/livePost.test.ts +97 -0
- package/src/stream/api/tests/createStream.test.ts +22 -0
- package/src/stream/api/tests/deleteStream.test.ts +50 -0
- package/src/stream/api/tests/getStream.test.ts +23 -0
- package/src/subChannel/api/tests/createSubChannel.test.ts +110 -0
- package/src/subChannel/api/tests/deleteSubChannel.test.ts +112 -0
- package/src/subChannel/api/tests/getSubChannel.test.ts +97 -0
- package/src/subChannel/api/tests/getSubChannels.test.ts +97 -0
- package/src/subChannel/api/tests/updateSubChannel.test.ts +86 -0
- package/src/subChannel/observers/liveSubChannel.ts +6 -56
- package/src/subChannel/observers/tests/liveSubChannel.test.ts +0 -82
- package/src/user/api/tests/updateUser.test.ts +60 -0
- package/src/user/observers/liveUser.ts +9 -61
- package/src/user/tests/observers/liveUser.test.ts +1 -154
- package/src/utils/constants.ts +2 -0
- package/src/utils/liveObject.ts +86 -0
- package/src/utils/tests/client.ts +18 -2
- package/src/utils/tests/dummy/category.ts +57 -0
- package/src/utils/tests/dummy/channel.ts +51 -1
- package/src/utils/tests/dummy/community.ts +94 -0
- package/src/utils/tests/dummy/file.ts +32 -0
- package/src/utils/tests/dummy/index.ts +4 -0
- package/src/utils/tests/dummy/post.ts +56 -45
- package/src/utils/tests/dummy/stream.ts +86 -0
- package/src/utils/tests/dummy/token.ts +12 -0
- package/src/utils/tests/dummy/user.ts +21 -0
- package/src/utils/tests/liveObject.test.ts +172 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amityco/ts-sdk",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.38",
|
|
4
4
|
"license": "CC-BY-ND-4.0",
|
|
5
5
|
"author": "amity.co <developers@amity.co> (https://amity.co)",
|
|
6
6
|
"description": "Amity Social Cloud Typescript SDK",
|
|
@@ -36,14 +36,15 @@
|
|
|
36
36
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
37
37
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
38
38
|
"@rollup/plugin-replace": "^4.0.0",
|
|
39
|
-
"@types/axios": "^0.14.0",
|
|
40
39
|
"@types/debug": "^4.1.7",
|
|
41
40
|
"@types/jest": "^27.5.1",
|
|
42
41
|
"@types/node": "^18.6.4",
|
|
43
42
|
"@types/socket.io-client": "^1.4.34",
|
|
44
43
|
"chalk": "^4.1.2",
|
|
45
44
|
"concurrently": "^6.1.0",
|
|
45
|
+
"form-data": "^4.0.0",
|
|
46
46
|
"jest": "^28.1.0",
|
|
47
|
+
"nock": "^13.3.0",
|
|
47
48
|
"rimraf": "^3.0.2",
|
|
48
49
|
"rollup": "^2.77.2",
|
|
49
50
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -54,12 +55,11 @@
|
|
|
54
55
|
"dependencies": {
|
|
55
56
|
"@react-native-async-storage/async-storage": "^1.17.7",
|
|
56
57
|
"agentkeepalive": "^4.2.1",
|
|
57
|
-
"axios": "^
|
|
58
|
+
"axios": "^1.2.3",
|
|
58
59
|
"debug": "^4.3.4",
|
|
59
60
|
"js-base64": "^3.7.2",
|
|
60
61
|
"mitt": "^3.0.0",
|
|
61
62
|
"mqtt": "^4.3.7",
|
|
62
|
-
"qs": "^6.11.0",
|
|
63
63
|
"react-native-uuid": "^2.0.1",
|
|
64
64
|
"socket.io-client": "2.2.0",
|
|
65
65
|
"ts-jest": "^28.0.3"
|
|
@@ -39,6 +39,7 @@ declare global {
|
|
|
39
39
|
close: Error;
|
|
40
40
|
end: undefined;
|
|
41
41
|
reconnect: undefined;
|
|
42
|
+
'user.didGlobalBan': Amity.UserPayload;
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
type MqttChannelUserEvents = {
|
|
@@ -79,6 +80,7 @@ declare global {
|
|
|
79
80
|
'community.left': Amity.CommunityMembershipPayload;
|
|
80
81
|
'community.userAdded': Amity.CommunityMembershipPayload;
|
|
81
82
|
'community.userRemoved': Amity.CommunityMembershipPayload;
|
|
83
|
+
'community.userChanged': Amity.CommunityMembershipPayload;
|
|
82
84
|
'community.userBanned': Amity.CommunityMembershipPayload;
|
|
83
85
|
'community.userUnbanned': Amity.CommunityMembershipPayload;
|
|
84
86
|
};
|
|
@@ -149,6 +151,11 @@ declare global {
|
|
|
149
151
|
'local.message-feed.deleted': Amity.SubChannelPayload;
|
|
150
152
|
'poll.updated': Amity.PollPayload;
|
|
151
153
|
'poll.deleted': Amity.PollPayload;
|
|
154
|
+
|
|
155
|
+
sessionStateChange: Amity.SessionStates;
|
|
156
|
+
// used by accessTokenExpiryWatcher
|
|
157
|
+
tokenExpired: Amity.SessionStates.TOKEN_EXPIRED;
|
|
158
|
+
tokenTerminated: Amity.SessionStates.TERMINATED;
|
|
152
159
|
};
|
|
153
160
|
|
|
154
161
|
type Events = WsEvents & MqttEvents & MqttRTE & LocalEvents;
|
|
@@ -9,5 +9,18 @@ declare global {
|
|
|
9
9
|
} & Amity.Metadata &
|
|
10
10
|
Amity.Timestamps &
|
|
11
11
|
Amity.SoftDelete;
|
|
12
|
+
|
|
13
|
+
type QueryCategories = {
|
|
14
|
+
isDeleted?: Amity.Category['isDeleted'];
|
|
15
|
+
sortBy?: 'name' | 'firstCreated' | 'lastCreated';
|
|
16
|
+
page?: Amity.Page;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type CategoryLiveCollection = Amity.LiveCollectionParams<Omit<QueryCategories, 'page'>>;
|
|
20
|
+
|
|
21
|
+
type CategoryLiveCollectionCache = Amity.LiveCollectionCache<
|
|
22
|
+
Amity.Category['categoryId'],
|
|
23
|
+
Pick<QueryCategories, 'page'>
|
|
24
|
+
>;
|
|
12
25
|
}
|
|
13
26
|
}
|
|
@@ -5,6 +5,27 @@ declare global {
|
|
|
5
5
|
namespace Amity {
|
|
6
6
|
type Logger = (topic: string, ...args: any[]) => void;
|
|
7
7
|
|
|
8
|
+
const enum SessionStates {
|
|
9
|
+
NOT_LOGGED_IN = 'notLoggedIn',
|
|
10
|
+
|
|
11
|
+
ESTABLISHING = 'establishing',
|
|
12
|
+
ESTABLISHED = 'established',
|
|
13
|
+
|
|
14
|
+
TOKEN_EXPIRED = 'tokenExpired',
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Terminated is slightly different from NOT_LOGGED_IN:
|
|
18
|
+
*
|
|
19
|
+
* After established, upon receiving the termination code, the SDK will move to terminated.
|
|
20
|
+
* Unlike tokenExpired that users can regain SDK usability by giving an auth token.
|
|
21
|
+
* This state represents unrecoverable failures. The app must manually re-login with a valid user.
|
|
22
|
+
*
|
|
23
|
+
* For more details, please check tech spec:
|
|
24
|
+
* https://ekoapp.atlassian.net/wiki/spaces/UP/pages/2082537485/ASC+Core+-+Session+Management+3.0#terminated
|
|
25
|
+
*/
|
|
26
|
+
TERMINATED = 'terminated',
|
|
27
|
+
}
|
|
28
|
+
|
|
8
29
|
type Client = {
|
|
9
30
|
version: string;
|
|
10
31
|
|
|
@@ -14,14 +35,24 @@ declare global {
|
|
|
14
35
|
ws: SocketIOClient.Socket;
|
|
15
36
|
emitter: Emitter<Amity.Events>;
|
|
16
37
|
|
|
38
|
+
sessionState: Amity.SessionStates;
|
|
39
|
+
sessionHandler?: Amity.SessionHandler;
|
|
40
|
+
|
|
17
41
|
cache?: Amity.Cache;
|
|
18
42
|
|
|
19
43
|
apiKey?: string;
|
|
20
44
|
userId?: string;
|
|
21
|
-
|
|
45
|
+
|
|
46
|
+
token?: Omit<Amity.Tokens, 'refreshToken'>;
|
|
22
47
|
|
|
23
48
|
use: () => void;
|
|
24
49
|
|
|
50
|
+
accessTokenExpiryWatcher: (
|
|
51
|
+
expiresAt: Amity.Tokens['expiresAt'],
|
|
52
|
+
issuedAt: Amity.Tokens['issuedAt'],
|
|
53
|
+
sessionHandler: Amity.SessionHandler,
|
|
54
|
+
) => Amity.Unsubscriber;
|
|
55
|
+
|
|
25
56
|
getFeedSettings: () => Promise<Amity.FeedSettings>;
|
|
26
57
|
};
|
|
27
58
|
|
|
@@ -37,8 +68,21 @@ declare global {
|
|
|
37
68
|
type Tokens = {
|
|
38
69
|
accessToken: string;
|
|
39
70
|
refreshToken: string;
|
|
71
|
+
// issuedAt, expiresAt is in iso Date format
|
|
72
|
+
issuedAt: string;
|
|
73
|
+
expiresAt: string;
|
|
40
74
|
};
|
|
41
75
|
|
|
76
|
+
type AccessTokenRenewal = {
|
|
77
|
+
renew: () => void;
|
|
78
|
+
renewWithAuthToken: (authToken: string) => void;
|
|
79
|
+
unableToRetrieveAuthToken: () => void;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
interface SessionHandler {
|
|
83
|
+
sessionWillRenewAccessToken(renewal: AccessTokenRenewal): void;
|
|
84
|
+
}
|
|
85
|
+
|
|
42
86
|
type ChatSettings = {
|
|
43
87
|
enabled: boolean;
|
|
44
88
|
mention: {
|
|
@@ -23,6 +23,14 @@ export const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
|
|
|
23
23
|
|
|
24
24
|
declare global {
|
|
25
25
|
namespace Amity {
|
|
26
|
+
type CommunityActionType =
|
|
27
|
+
| 'onCreate'
|
|
28
|
+
| 'onUpdate'
|
|
29
|
+
| 'onDelete'
|
|
30
|
+
| 'onJoin'
|
|
31
|
+
| 'onLeft'
|
|
32
|
+
| 'onMemberCountChanged';
|
|
33
|
+
|
|
26
34
|
type RawCommunity = {
|
|
27
35
|
communityId: string;
|
|
28
36
|
|
|
@@ -55,5 +63,22 @@ declare global {
|
|
|
55
63
|
type Community = Omit<Amity.RawCommunity, 'onlyAdminCanPost' | 'needApprovalOnPostCreation'> & {
|
|
56
64
|
postSetting?: ValueOf<typeof CommunityPostSettings>;
|
|
57
65
|
};
|
|
66
|
+
|
|
67
|
+
type QueryCommunities = {
|
|
68
|
+
displayName?: string;
|
|
69
|
+
membership?: 'all' | 'member' | 'notMember';
|
|
70
|
+
categoryId?: Amity.Category['categoryId'];
|
|
71
|
+
isDeleted?: Amity.Community['isDeleted'];
|
|
72
|
+
tags?: Amity.Taggable['tags'];
|
|
73
|
+
sortBy?: 'displayName' | 'firstCreated' | 'lastCreated';
|
|
74
|
+
page?: Amity.Page;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type CommunityLiveCollection = Amity.LiveCollectionParams<Omit<QueryCommunities, 'page'>>;
|
|
78
|
+
|
|
79
|
+
type CommunityLiveCollectionCache = Amity.LiveCollectionCache<
|
|
80
|
+
Amity.Community['communityId'],
|
|
81
|
+
Pick<QueryCommunities, 'page'>
|
|
82
|
+
>;
|
|
58
83
|
}
|
|
59
84
|
}
|
package/src/@types/global.ts
CHANGED
|
@@ -28,3 +28,22 @@ declare global {
|
|
|
28
28
|
|
|
29
29
|
type ValueOf<T extends Record<any, any>> = T[keyof T];
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
/*
|
|
33
|
+
* Extented to pass token expiry into request config, for internal use only.
|
|
34
|
+
* Since it's in the request config, it does not get sent for the server, and
|
|
35
|
+
* allows us to intercept the tokenExpiry value to check if the token has not
|
|
36
|
+
* expired & cancel the request if yes.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
declare module 'axios' {
|
|
40
|
+
export interface AxiosDefaults {
|
|
41
|
+
// expires at iso string for access token
|
|
42
|
+
metadata?: { tokenExpiry: string };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface AxiosRequestConfig {
|
|
46
|
+
// expires at iso string for access token
|
|
47
|
+
metadata?: { tokenExpiry: string };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -20,11 +20,9 @@ import { getResolver } from '~/core/model';
|
|
|
20
20
|
* @category Category API
|
|
21
21
|
* @async
|
|
22
22
|
* */
|
|
23
|
-
export const queryCategories = async (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
page?: Amity.Page;
|
|
27
|
-
}): Promise<Amity.Cached<Amity.Paged<Amity.Category, Amity.Page>>> => {
|
|
23
|
+
export const queryCategories = async (
|
|
24
|
+
query?: Amity.QueryCategories,
|
|
25
|
+
): Promise<Amity.Cached<Amity.Paged<Amity.Category, Amity.Page>>> => {
|
|
28
26
|
const client = getActiveClient();
|
|
29
27
|
client.log('category/queryCategories', query);
|
|
30
28
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './liveCategories';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/* eslint-disable no-use-before-define */
|
|
2
|
+
import { getResolver } from '~/core/model';
|
|
3
|
+
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
4
|
+
import { getActiveClient } from '~/client/api';
|
|
5
|
+
import {
|
|
6
|
+
createQuery,
|
|
7
|
+
runQuery,
|
|
8
|
+
queryOptions,
|
|
9
|
+
filterByPropEquality,
|
|
10
|
+
sortByLastCreated,
|
|
11
|
+
sortByName,
|
|
12
|
+
sortByFirstCreated,
|
|
13
|
+
} from '~/core/query';
|
|
14
|
+
import {
|
|
15
|
+
COLLECTION_DEFAULT_CACHING_POLICY,
|
|
16
|
+
COLLECTION_DEFAULT_PAGINATION_LIMIT,
|
|
17
|
+
ENABLE_CACHE_MESSAGE,
|
|
18
|
+
} from '~/utils/constants';
|
|
19
|
+
import { queryCategories } from '../api';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* ```js
|
|
23
|
+
* import { liveCategories } from '@amityco/ts-sdk'
|
|
24
|
+
*
|
|
25
|
+
* let categories = []
|
|
26
|
+
* const unsub = liveCategories({}, response => merge(categories, response.data))
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* Observe all mutations on a list of {@link Amity.Category}s
|
|
30
|
+
*
|
|
31
|
+
* @param params for querying categories
|
|
32
|
+
* @param callback the function to call when new data are available
|
|
33
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the categories
|
|
34
|
+
*
|
|
35
|
+
* @category Category Live Collection
|
|
36
|
+
*/
|
|
37
|
+
export const liveCategories = (
|
|
38
|
+
params: Amity.CategoryLiveCollection,
|
|
39
|
+
callback: Amity.LiveCollectionCallback<Amity.Category>,
|
|
40
|
+
config?: Amity.LiveCollectionConfig,
|
|
41
|
+
) => {
|
|
42
|
+
const { log, cache } = getActiveClient();
|
|
43
|
+
|
|
44
|
+
if (!cache) {
|
|
45
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const timestamp = Date.now();
|
|
49
|
+
log(`liveCategories(tmpid: ${timestamp}) > listen`);
|
|
50
|
+
|
|
51
|
+
const { limit: queryLimit, ...queryParams } = params;
|
|
52
|
+
|
|
53
|
+
const limit = queryLimit ?? COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
54
|
+
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config ?? {};
|
|
55
|
+
|
|
56
|
+
const disposers: Amity.Unsubscriber[] = [];
|
|
57
|
+
const cacheKey = ['category', 'collection', {}];
|
|
58
|
+
|
|
59
|
+
const responder = (data: Amity.CategoryLiveCollectionCache) => {
|
|
60
|
+
let categories: Amity.Category[] =
|
|
61
|
+
data.data
|
|
62
|
+
.map(categoryId => pullFromCache<Amity.Category>(['category', 'get', categoryId])!)
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.map(({ data }) => data) ?? [];
|
|
65
|
+
|
|
66
|
+
categories = filterByPropEquality(categories, 'isDeleted', params.isDeleted);
|
|
67
|
+
|
|
68
|
+
switch (params.sortBy) {
|
|
69
|
+
case 'firstCreated':
|
|
70
|
+
categories = categories.sort(sortByFirstCreated);
|
|
71
|
+
break;
|
|
72
|
+
|
|
73
|
+
case 'lastCreated':
|
|
74
|
+
categories = categories.sort(sortByLastCreated);
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
default:
|
|
78
|
+
categories = categories.sort(sortByName);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
callback({
|
|
82
|
+
onNextPage: onFetch,
|
|
83
|
+
data: categories,
|
|
84
|
+
hasNextPage: !!data.params?.page,
|
|
85
|
+
loading: data.loading,
|
|
86
|
+
error: data.error,
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* const realtimeRouter = () => {
|
|
92
|
+
* @TODO: At the time of creating this method category does not have any
|
|
93
|
+
* observers
|
|
94
|
+
*};
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
const onFetch = () => {
|
|
98
|
+
const collection = pullFromCache<Amity.CategoryLiveCollectionCache>(cacheKey)?.data;
|
|
99
|
+
|
|
100
|
+
const categories = collection?.data ?? [];
|
|
101
|
+
|
|
102
|
+
if (categories.length > 0 && !collection?.params.page) return;
|
|
103
|
+
|
|
104
|
+
const query = createQuery(queryCategories, {
|
|
105
|
+
...queryParams,
|
|
106
|
+
page: collection?.params.page ?? { limit },
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
runQuery(
|
|
110
|
+
query,
|
|
111
|
+
({ data: result, error, loading, nextPage: page }) => {
|
|
112
|
+
const data = {
|
|
113
|
+
loading,
|
|
114
|
+
error,
|
|
115
|
+
params: { page },
|
|
116
|
+
data: categories,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
if (result) {
|
|
120
|
+
data.data = [...new Set([...categories, ...result.map(getResolver('category'))])];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
pushToCache(cacheKey, data);
|
|
124
|
+
|
|
125
|
+
responder(data);
|
|
126
|
+
},
|
|
127
|
+
queryOptions(policy),
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
disposers.push(() => {
|
|
132
|
+
// @TODO -> update once observers added
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
onFetch();
|
|
136
|
+
|
|
137
|
+
return () => {
|
|
138
|
+
log(`liveCategories(tmpid: ${timestamp}) > dispose`);
|
|
139
|
+
disposers.forEach(fn => fn());
|
|
140
|
+
};
|
|
141
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { disableCache, enableCache } from '~/cache/api';
|
|
2
|
+
import {
|
|
3
|
+
client,
|
|
4
|
+
connectClient,
|
|
5
|
+
disconnectClient,
|
|
6
|
+
pause,
|
|
7
|
+
categoryQueryResponse,
|
|
8
|
+
categoryQueryResponsePage2,
|
|
9
|
+
category11,
|
|
10
|
+
category12,
|
|
11
|
+
category13,
|
|
12
|
+
} from '~/utils/tests';
|
|
13
|
+
import { sortByName } from '~/core/query';
|
|
14
|
+
|
|
15
|
+
import { liveCategories } from '../liveCategories';
|
|
16
|
+
|
|
17
|
+
const getSnapshot = (params?: Record<string, any>) => {
|
|
18
|
+
return {
|
|
19
|
+
data: [] as Amity.Category[],
|
|
20
|
+
loading: true,
|
|
21
|
+
error: undefined as any,
|
|
22
|
+
...params,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
describe('live Caategories', () => {
|
|
27
|
+
beforeAll(connectClient);
|
|
28
|
+
afterAll(disconnectClient);
|
|
29
|
+
|
|
30
|
+
beforeEach(enableCache);
|
|
31
|
+
|
|
32
|
+
afterEach(disableCache);
|
|
33
|
+
|
|
34
|
+
const payload = categoryQueryResponse.data;
|
|
35
|
+
const payloadPage2 = categoryQueryResponsePage2.data;
|
|
36
|
+
|
|
37
|
+
test('it should return category collection', async () => {
|
|
38
|
+
const callback = jest.fn();
|
|
39
|
+
client.http.get = jest.fn().mockResolvedValue(categoryQueryResponse);
|
|
40
|
+
|
|
41
|
+
liveCategories({}, callback);
|
|
42
|
+
await pause();
|
|
43
|
+
|
|
44
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
45
|
+
expect(callback).toHaveBeenNthCalledWith(1, expect.objectContaining(getSnapshot()));
|
|
46
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
47
|
+
2,
|
|
48
|
+
expect.objectContaining(
|
|
49
|
+
getSnapshot({
|
|
50
|
+
data: payload.categories,
|
|
51
|
+
loading: false,
|
|
52
|
+
}),
|
|
53
|
+
),
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('it should return data from cache', async () => {
|
|
58
|
+
const callback = jest.fn();
|
|
59
|
+
client.http.get = jest.fn().mockResolvedValue(categoryQueryResponse);
|
|
60
|
+
|
|
61
|
+
liveCategories({}, () => undefined);
|
|
62
|
+
await pause();
|
|
63
|
+
liveCategories({}, callback);
|
|
64
|
+
await pause();
|
|
65
|
+
|
|
66
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
67
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
68
|
+
1,
|
|
69
|
+
expect.objectContaining(
|
|
70
|
+
getSnapshot({
|
|
71
|
+
data: payload.categories,
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
76
|
+
2,
|
|
77
|
+
expect.objectContaining(
|
|
78
|
+
getSnapshot({
|
|
79
|
+
data: payload.categories,
|
|
80
|
+
loading: false,
|
|
81
|
+
}),
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const filters: [string, Amity.CategoryLiveCollection, Amity.Category[]][] = [
|
|
87
|
+
['deleted', { isDeleted: true }, [category13]],
|
|
88
|
+
['not deleted', { isDeleted: false }, [category11, category12]],
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
test.each(filters)('it should filter by %s categories', async (filter, params, expected) => {
|
|
92
|
+
const callback = jest.fn();
|
|
93
|
+
client.http.get = jest.fn().mockResolvedValue(categoryQueryResponse);
|
|
94
|
+
|
|
95
|
+
liveCategories(params, callback);
|
|
96
|
+
|
|
97
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
98
|
+
// check if cache data returned (should be empty)
|
|
99
|
+
expect(callback).toHaveBeenCalledWith(expect.objectContaining(getSnapshot()));
|
|
100
|
+
|
|
101
|
+
await pause();
|
|
102
|
+
|
|
103
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
104
|
+
expect(callback).toHaveBeenCalledWith(
|
|
105
|
+
expect.objectContaining(
|
|
106
|
+
getSnapshot({
|
|
107
|
+
loading: false,
|
|
108
|
+
data: expected,
|
|
109
|
+
}),
|
|
110
|
+
),
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('it should return method to fetch next page', async () => {
|
|
115
|
+
const callback = jest.fn();
|
|
116
|
+
client.http.get = jest
|
|
117
|
+
.fn()
|
|
118
|
+
.mockResolvedValue(categoryQueryResponse)
|
|
119
|
+
.mockResolvedValueOnce(categoryQueryResponsePage2);
|
|
120
|
+
|
|
121
|
+
liveCategories({}, callback);
|
|
122
|
+
await pause();
|
|
123
|
+
|
|
124
|
+
expect(callback).toHaveBeenCalled();
|
|
125
|
+
expect(callback.mock.lastCall).toHaveLength(1);
|
|
126
|
+
|
|
127
|
+
const { onNextPage, hasNextPage } = callback.mock.lastCall[0];
|
|
128
|
+
|
|
129
|
+
expect(hasNextPage).toBe(true);
|
|
130
|
+
expect(onNextPage).toBeTruthy();
|
|
131
|
+
|
|
132
|
+
onNextPage();
|
|
133
|
+
await pause();
|
|
134
|
+
|
|
135
|
+
// 4 -> because 1 local & server call each per call (2)
|
|
136
|
+
expect(callback).toHaveBeenCalledTimes(4);
|
|
137
|
+
expect(callback).toHaveBeenNthCalledWith(
|
|
138
|
+
4,
|
|
139
|
+
expect.objectContaining(
|
|
140
|
+
getSnapshot({
|
|
141
|
+
loading: false,
|
|
142
|
+
data: [...payloadPage2.categories, ...payload.categories].sort(sortByName),
|
|
143
|
+
}),
|
|
144
|
+
),
|
|
145
|
+
);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -1,20 +1,44 @@
|
|
|
1
1
|
import { disableCache, enableCache, pullFromCache } from '~/cache/api';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
channelPayload,
|
|
4
|
+
client,
|
|
5
|
+
conversationChannelPayload,
|
|
6
|
+
liveChannelPayload,
|
|
7
|
+
} from '~/utils/tests';
|
|
3
8
|
import { prepareChannelPayload } from '~/channel/utils';
|
|
4
9
|
import { createChannel } from '../createChannel';
|
|
5
10
|
|
|
6
11
|
const resPayload = { data: channelPayload };
|
|
7
12
|
|
|
8
13
|
describe('createChannel', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
test('it should create a channel', async () => {
|
|
14
|
+
// integration_test_id: 9d80fd54-9e6d-454d-8344-6f9436b8e495
|
|
15
|
+
test('it should create a channel for community', async () => {
|
|
12
16
|
client.http.post = jest.fn().mockResolvedValueOnce(resPayload);
|
|
13
17
|
|
|
14
18
|
const res = await createChannel({ type: 'community' });
|
|
15
19
|
|
|
16
20
|
expect(res).toBeDefined();
|
|
17
|
-
expect(res.data).toStrictEqual(
|
|
21
|
+
expect(res.data).toStrictEqual(prepareChannelPayload(channelPayload).channels[0]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// integration_test_id: cef520ab-027d-4c5b-836c-a7f63ddc5146
|
|
25
|
+
test('it should create a channel for live', async () => {
|
|
26
|
+
client.http.post = jest.fn().mockResolvedValueOnce({ data: liveChannelPayload });
|
|
27
|
+
|
|
28
|
+
const res = await createChannel({ type: 'live' });
|
|
29
|
+
|
|
30
|
+
expect(res).toBeDefined();
|
|
31
|
+
expect(res.data).toStrictEqual(prepareChannelPayload(liveChannelPayload).channels[0]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// integration_test_id: 11a43612-ff6f-4262-874c-4419d342cff1
|
|
35
|
+
test('it should create a channel for conversation', async () => {
|
|
36
|
+
client.http.post = jest.fn().mockResolvedValueOnce({ data: conversationChannelPayload });
|
|
37
|
+
|
|
38
|
+
const res = await createChannel({ type: 'conversation' });
|
|
39
|
+
|
|
40
|
+
expect(res).toBeDefined();
|
|
41
|
+
expect(res.data).toStrictEqual(prepareChannelPayload(conversationChannelPayload).channels[0]);
|
|
18
42
|
});
|
|
19
43
|
|
|
20
44
|
test('it should add channel to cache', async () => {
|
|
@@ -27,7 +51,7 @@ describe('createChannel', () => {
|
|
|
27
51
|
const data = pullFromCache(['channel', 'get', channelId]);
|
|
28
52
|
|
|
29
53
|
expect(data).toBeDefined();
|
|
30
|
-
expect(data?.data).toStrictEqual(
|
|
54
|
+
expect(data?.data).toStrictEqual(prepareChannelPayload(channelPayload).channels[0]);
|
|
31
55
|
|
|
32
56
|
disableCache();
|
|
33
57
|
});
|
|
@@ -12,7 +12,8 @@ const { channelId } = channelQueryResponse.data.channels[0];
|
|
|
12
12
|
const channel = prepareChannelPayload(channelQueryResponse.data).channels[0];
|
|
13
13
|
|
|
14
14
|
describe('getChannel', () => {
|
|
15
|
-
|
|
15
|
+
// integration_test_id: b331e01c-20db-4f17-979b-b280d8818792
|
|
16
|
+
test('it should return a valid channel', async () => {
|
|
16
17
|
client.http.get = jest.fn().mockResolvedValueOnce(channelQueryResponse);
|
|
17
18
|
|
|
18
19
|
const expected = channel;
|
|
@@ -31,6 +32,7 @@ describe('getChannel', () => {
|
|
|
31
32
|
disableCache();
|
|
32
33
|
});
|
|
33
34
|
|
|
35
|
+
// integration_test_id: da9dc3e8-01fd-4e76-a26b-ac8333a69b23
|
|
34
36
|
test('it should return an error', async () => {
|
|
35
37
|
client.http.get = jest.fn().mockRejectedValueOnce(new Error('error'));
|
|
36
38
|
|