@amityco/ts-sdk 6.4.6-bdc04db.0 → 6.4.6-be7e4df.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/core/events.d.ts +4 -4
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -1
- package/dist/@types/core/payload.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/reaction.d.ts +4 -5
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/client/observers/getTotalUnreadCount.d.ts.map +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComment.d.ts +2 -2
- package/dist/communityRepository/api/getCommunity.d.ts +4 -4
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts +4 -4
- package/dist/communityRepository/api/getTopTrendingCommunities.d.ts +5 -2
- package/dist/communityRepository/api/getTopTrendingCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts +32 -0
- package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -0
- package/dist/communityRepository/api/index.d.ts +0 -1
- package/dist/communityRepository/api/index.d.ts.map +1 -1
- package/dist/communityRepository/api/test/getTrendingCommunities.test.d.ts +2 -0
- package/dist/communityRepository/api/test/getTrendingCommunities.test.d.ts.map +1 -0
- package/dist/communityRepository/observers/getCommunities.d.ts +2 -2
- package/dist/communityRepository/observers/getCommunity.d.ts +2 -2
- package/dist/communityRepository/observers/getRecommendedCommunities.d.ts +20 -0
- package/dist/communityRepository/observers/getRecommendedCommunities.d.ts.map +1 -0
- package/dist/communityRepository/observers/getTrendingCommunities.d.ts +20 -0
- package/dist/communityRepository/observers/getTrendingCommunities.d.ts.map +1 -0
- package/dist/communityRepository/observers/index.d.ts +2 -0
- package/dist/communityRepository/observers/index.d.ts.map +1 -1
- package/dist/communityRepository/utils/communityQueryFilter.d.ts +2 -0
- package/dist/communityRepository/utils/communityQueryFilter.d.ts.map +1 -0
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/index.cjs.js +371 -166
- package/dist/index.esm.js +371 -166
- package/dist/index.umd.js +4 -4
- package/dist/pollRepository/api/index.d.ts +0 -1
- package/dist/pollRepository/api/index.d.ts.map +1 -1
- package/dist/pollRepository/observers/getPoll.d.ts +21 -0
- package/dist/pollRepository/observers/getPoll.d.ts.map +1 -0
- package/dist/pollRepository/observers/index.d.ts +1 -0
- package/dist/pollRepository/observers/index.d.ts.map +1 -1
- package/dist/postRepository/observers/getPost.d.ts +2 -2
- package/dist/reactionRepository/api/addReaction.d.ts +2 -2
- package/dist/reactionRepository/api/addReaction.d.ts.map +1 -1
- package/dist/reactionRepository/api/queryReactions.d.ts +2 -2
- package/dist/reactionRepository/api/queryReactions.d.ts.map +1 -1
- package/dist/reactionRepository/api/queryReactor.d.ts +19 -0
- package/dist/reactionRepository/api/queryReactor.d.ts.map +1 -0
- package/dist/reactionRepository/api/removeReaction.d.ts +2 -2
- package/dist/reactionRepository/api/removeReaction.d.ts.map +1 -1
- package/dist/reactionRepository/observers/getReactions.d.ts +3 -3
- package/dist/reactionRepository/observers/getReactions.d.ts.map +1 -1
- package/dist/utils/tests/dummy/reaction.d.ts +1 -1
- package/dist/utils/tests/dummy/reaction.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +4 -4
- package/src/@types/core/model.ts +3 -1
- package/src/@types/core/payload.ts +1 -1
- package/src/@types/domains/post.ts +1 -1
- package/src/@types/domains/reaction.ts +8 -9
- package/src/categoryRepository/api/queryCategories.ts +1 -1
- package/src/client/observers/getTotalUnreadCount.ts +1 -7
- package/src/client/observers/tests/getTotalUnreadCount.test.ts +3 -10
- package/src/client/utils/markerSyncEngine.ts +13 -2
- package/src/commentRepository/events/onCommentReactionAdded.ts +1 -1
- package/src/commentRepository/events/onCommentReactionRemoved.ts +1 -1
- package/src/commentRepository/observers/getComment.ts +2 -2
- package/src/commentRepository/observers/tests/getComment.test.ts +1 -3
- package/src/communityRepository/api/getCommunity.ts +4 -4
- package/src/communityRepository/api/getRecommendedCommunities.ts +4 -4
- package/src/communityRepository/api/getTopTrendingCommunities.ts +5 -2
- package/src/communityRepository/api/getTrendingCommunities.ts +97 -0
- package/src/communityRepository/api/index.ts +1 -1
- package/src/communityRepository/api/test/getTrendingCommunities.test.ts +102 -0
- package/src/communityRepository/observers/getCommunities.ts +2 -2
- package/src/communityRepository/observers/getCommunity.ts +2 -2
- package/src/communityRepository/observers/getRecommendedCommunities.ts +133 -0
- package/src/communityRepository/observers/getTrendingCommunities.ts +133 -0
- package/src/communityRepository/observers/index.ts +2 -0
- package/src/communityRepository/utils/communityQueryFilter.ts +55 -0
- package/src/core/model/idResolvers.ts +2 -1
- package/src/core/model/identifyModel.ts +5 -4
- package/src/pollRepository/api/index.ts +0 -2
- package/src/pollRepository/observers/getPoll.ts +33 -0
- package/src/pollRepository/observers/index.ts +1 -0
- package/src/pollRepository/observers/observePoll.ts +2 -2
- package/src/postRepository/events/tests/onPostReactionAdded.test.ts +6 -5
- package/src/postRepository/events/tests/onPostReactionRemoved.test.ts +5 -4
- package/src/postRepository/observers/getPost.ts +2 -2
- package/src/postRepository/observers/getPosts.ts +1 -1
- package/src/postRepository/observers/tests/getPost.test.ts +1 -3
- package/src/postRepository/observers/tests/getPosts.test.ts +1 -5
- package/src/reactionRepository/api/addReaction.ts +2 -2
- package/src/reactionRepository/api/queryReactions.ts +2 -2
- package/src/reactionRepository/api/queryReactor.ts +31 -0
- package/src/reactionRepository/api/removeReaction.ts +2 -2
- package/src/reactionRepository/observers/getReactions.ts +6 -8
- package/src/utils/tests/dummy/reaction.ts +6 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pollRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pollRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAE7B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { PollRepository } from '@amityco/ts-sdk';
|
|
4
|
+
*
|
|
5
|
+
* let poll;
|
|
6
|
+
*
|
|
7
|
+
* const unsub = PollRepository.getPoll(commentId, response => {
|
|
8
|
+
* poll = response.data;
|
|
9
|
+
* });
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Observe all mutation on a given {@link Amity.Poll}
|
|
13
|
+
*
|
|
14
|
+
* @param pollId the ID of the poll to observe
|
|
15
|
+
* @param callback the function to call when new data are available
|
|
16
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the poll
|
|
17
|
+
*
|
|
18
|
+
* @category Poll Live Object
|
|
19
|
+
*/
|
|
20
|
+
export declare const getPoll: (pollId: Amity.Poll['pollId'], callback: Amity.LiveObjectCallback<Amity.Poll>) => Amity.Unsubscriber;
|
|
21
|
+
//# sourceMappingURL=getPoll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPoll.d.ts","sourceRoot":"","sources":["../../../src/pollRepository/observers/getPoll.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,WACV,MAAM,IAAI,CAAC,QAAQ,CAAC,YAClB,MAAM,kBAAkB,CAAC,MAAM,IAAI,CAAC,KAC7C,MAAM,YAER,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pollRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pollRepository/observers/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ```js
|
|
3
|
-
* import {
|
|
3
|
+
* import { PostRepository } from '@amityco/ts-sdk';
|
|
4
4
|
*
|
|
5
5
|
* let post;
|
|
6
6
|
*
|
|
7
|
-
* const
|
|
7
|
+
* const unsub = PostRepository.getPost(postId, response => {
|
|
8
8
|
* post = response.data;
|
|
9
9
|
* });
|
|
10
10
|
* ```
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @async
|
|
16
16
|
* */
|
|
17
17
|
export declare const addReaction: {
|
|
18
|
-
(referenceType: Amity.Reaction['referenceType'], referenceId: Amity.Reaction['referenceId'], reactionName: Amity.
|
|
18
|
+
(referenceType: Amity.Reaction['referenceType'], referenceId: Amity.Reaction['referenceId'], reactionName: Amity.Reactor['reactionName']): Promise<boolean>;
|
|
19
19
|
/**
|
|
20
20
|
* ```js
|
|
21
21
|
* import { addReaction } from '@amityco/ts-sdk'
|
|
@@ -31,6 +31,6 @@ export declare const addReaction: {
|
|
|
31
31
|
*
|
|
32
32
|
* @category Reaction API
|
|
33
33
|
* */
|
|
34
|
-
optimistically(referenceType: Amity.ReactableType, referenceId: Amity.Reaction['referenceId'], reactionName: Amity.
|
|
34
|
+
optimistically(referenceType: Amity.ReactableType, referenceId: Amity.Reaction['referenceId'], reactionName: Amity.Reactor['reactionName']): boolean | undefined;
|
|
35
35
|
};
|
|
36
36
|
//# sourceMappingURL=addReaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/addReaction.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,WAAW;oBACP,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"addReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/addReaction.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,WAAW;oBACP,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,OAAO,CAAC,cAAc,CAAC,GAC1C,QAAQ,OAAO,CAAC;IA8BnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,OAAO,CAAC,cAAc,CAAC,GAC1C,OAAO,GAAG,SAAS;CAtBrB,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* })
|
|
8
8
|
* ```
|
|
9
9
|
*
|
|
10
|
-
* Queries a paginable list of {@link Amity.
|
|
10
|
+
* Queries a paginable list of {@link Amity.Reaction} objects
|
|
11
11
|
*
|
|
12
12
|
* @param query The query parameters
|
|
13
13
|
* @returns A page of {@link Amity.Reaction} objects
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* @reaction Reaction API
|
|
16
16
|
* @async
|
|
17
17
|
* */
|
|
18
|
-
export declare const queryReactions: (query: Amity.QueryReactions) => Promise<Amity.Paged<Amity.
|
|
18
|
+
export declare const queryReactions: (query: Amity.QueryReactions) => Promise<Amity.Paged<Amity.Reaction, Amity.Page<string>>>;
|
|
19
19
|
//# sourceMappingURL=queryReactions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryReactions.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/queryReactions.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;KAgBK;AACL,eAAO,MAAM,cAAc,UAClB,MAAM,cAAc,KAC1B,QAAQ,MAAM,KAAK,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"queryReactions.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/queryReactions.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;KAgBK;AACL,eAAO,MAAM,cAAc,UAClB,MAAM,cAAc,KAC1B,QAAQ,MAAM,KAAK,CAAC,MAAM,QAAQ,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CA6BzD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { queryReactor } from '@amityco/ts-sdk'
|
|
4
|
+
* const { data: reactions, prevPage, nextPage } = await queryReactor({
|
|
5
|
+
* referenceId: 'postId',
|
|
6
|
+
* referenceType: 'post',
|
|
7
|
+
* })
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Queries a paginable list of {@link Amity.Reactor} objects
|
|
11
|
+
*
|
|
12
|
+
* @param query The query parameters
|
|
13
|
+
* @returns A page of {@link Amity.Reactor} objects
|
|
14
|
+
*
|
|
15
|
+
* @reaction Reaction API
|
|
16
|
+
* @async
|
|
17
|
+
* */
|
|
18
|
+
export declare const queryReactor: (query: Amity.QueryReactions) => Promise<Amity.Paged<Amity.Reactor, Amity.Page<string>>>;
|
|
19
|
+
//# sourceMappingURL=queryReactor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryReactor.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/queryReactor.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;KAgBK;AACL,eAAO,MAAM,YAAY,UAChB,MAAM,cAAc,KAC1B,QAAQ,MAAM,KAAK,CAAC,MAAM,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CAOxD,CAAC"}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @async
|
|
16
16
|
* */
|
|
17
17
|
export declare const removeReaction: {
|
|
18
|
-
(referenceType: Amity.Reaction['referenceType'], referenceId: Amity.Reaction['referenceId'], reactionName: Amity.
|
|
18
|
+
(referenceType: Amity.Reaction['referenceType'], referenceId: Amity.Reaction['referenceId'], reactionName: Amity.Reactor['reactionName']): Promise<boolean>;
|
|
19
19
|
/**
|
|
20
20
|
* ```js
|
|
21
21
|
* import { removeReaction } from '@amityco/ts-sdk'
|
|
@@ -31,6 +31,6 @@ export declare const removeReaction: {
|
|
|
31
31
|
*
|
|
32
32
|
* @category Reaction API
|
|
33
33
|
* */
|
|
34
|
-
optimistically(referenceType: Amity.ReactableType, referenceId: Amity.Reaction['referenceId'], reactionName: Amity.
|
|
34
|
+
optimistically(referenceType: Amity.ReactableType, referenceId: Amity.Reaction['referenceId'], reactionName: Amity.Reactor['reactionName']): boolean | undefined;
|
|
35
35
|
};
|
|
36
36
|
//# sourceMappingURL=removeReaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/removeReaction.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,cAAc;oBACV,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"removeReaction.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/api/removeReaction.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;KAeK;AACL,eAAO,MAAM,cAAc;oBACV,MAAM,QAAQ,CAAC,eAAe,CAAC,eACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,OAAO,CAAC,cAAc,CAAC,GAC1C,QAAQ,OAAO,CAAC;IAgCnB;;;;;;;;;;;;;;SAcK;kCAEY,MAAM,aAAa,eACrB,MAAM,QAAQ,CAAC,aAAa,CAAC,gBAC5B,MAAM,OAAO,CAAC,cAAc,CAAC,GAC1C,OAAO,GAAG,SAAS;CAtBrB,CAAC"}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* }, response => merge(reactions, response.data))
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
|
-
* Observe all mutations on a list of {@link Amity.
|
|
12
|
+
* Observe all mutations on a list of {@link Amity.Reactor} for a given target object
|
|
13
13
|
*
|
|
14
|
-
* @param params
|
|
15
|
-
* @param params.referenceId the ID of the target
|
|
14
|
+
* @param params for querying reactions
|
|
16
15
|
* @param callback the function to call when new data are available
|
|
16
|
+
* @param config the live collection configuration
|
|
17
17
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
|
|
18
18
|
*
|
|
19
19
|
* @category Reactions Live Collection
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReactions.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/observers/getReactions.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,sBAAsB,YAC1B,MAAM,sBAAsB,CAAC,MAAM,OAAO,CAAC,WAC5C,MAAM,oBAAoB,KAClC,MAAM,
|
|
1
|
+
{"version":3,"file":"getReactions.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/observers/getReactions.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,WACf,MAAM,sBAAsB,YAC1B,MAAM,sBAAsB,CAAC,MAAM,OAAO,CAAC,WAC5C,MAAM,oBAAoB,KAClC,MAAM,YAqGR,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/reaction.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/reaction.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,OAK7B,CAAC;AACF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,QAI9B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,eAGnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -101,8 +101,8 @@ declare global {
|
|
|
101
101
|
'post.declined': Amity.PostPayload;
|
|
102
102
|
'post.flagged': Amity.PostPayload;
|
|
103
103
|
'post.unflagged': Amity.PostPayload;
|
|
104
|
-
'post.addReaction': Amity.PostPayload & { reactor: Amity.
|
|
105
|
-
'post.removeReaction': Amity.PostPayload & { reactor: Amity.
|
|
104
|
+
'post.addReaction': Amity.PostPayload & { reactor: Amity.Reactor };
|
|
105
|
+
'post.removeReaction': Amity.PostPayload & { reactor: Amity.Reactor };
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
type MqttCommentEvents = {
|
|
@@ -111,8 +111,8 @@ declare global {
|
|
|
111
111
|
'comment.deleted': Amity.CommentPayload;
|
|
112
112
|
'comment.flagged': Amity.CommentPayload;
|
|
113
113
|
'comment.unflagged': Amity.CommentPayload;
|
|
114
|
-
'comment.addReaction': Amity.CommentPayload & { reactor: Amity.
|
|
115
|
-
'comment.removeReaction': Amity.CommentPayload & { reactor: Amity.
|
|
114
|
+
'comment.addReaction': Amity.CommentPayload & { reactor: Amity.Reactor };
|
|
115
|
+
'comment.removeReaction': Amity.CommentPayload & { reactor: Amity.Reactor };
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
type MqttUserEvents = {
|
package/src/@types/core/model.ts
CHANGED
|
@@ -29,6 +29,7 @@ declare global {
|
|
|
29
29
|
comment: Amity.Comment;
|
|
30
30
|
poll: Amity.Poll;
|
|
31
31
|
reaction: Amity.Reaction;
|
|
32
|
+
reactor: Amity.Reactor;
|
|
32
33
|
|
|
33
34
|
stream: Amity.Stream;
|
|
34
35
|
|
|
@@ -69,7 +70,8 @@ declare global {
|
|
|
69
70
|
post: Pick<Amity.Post, 'postId'>;
|
|
70
71
|
comment: Pick<Amity.Comment, 'commentId'>;
|
|
71
72
|
poll: Pick<Amity.Poll, 'pollId'>;
|
|
72
|
-
reaction: Pick<Amity.Reaction, '
|
|
73
|
+
reaction: Pick<Amity.Reaction, 'referenceType' | 'referenceId'>;
|
|
74
|
+
reactor: Pick<Amity.Reactor, 'reactionId'>;
|
|
73
75
|
|
|
74
76
|
stream: Pick<Amity.Stream, 'streamId'>;
|
|
75
77
|
|
|
@@ -53,7 +53,7 @@ declare global {
|
|
|
53
53
|
type QueryPosts = {
|
|
54
54
|
targetId: string;
|
|
55
55
|
targetType: Amity.Post['targetType'];
|
|
56
|
-
sortBy?: 'lastCreated' | 'firstCreated'
|
|
56
|
+
sortBy?: 'lastCreated' | 'firstCreated';
|
|
57
57
|
dataTypes?: Exclude<Amity.PostContentType, 'text'>[];
|
|
58
58
|
includeDeleted?: boolean;
|
|
59
59
|
hasFlag?: boolean;
|
|
@@ -10,29 +10,28 @@ declare global {
|
|
|
10
10
|
reactionId: string;
|
|
11
11
|
reactionName: string;
|
|
12
12
|
userId: Amity.User['userId'];
|
|
13
|
-
} & Amity.
|
|
14
|
-
|
|
15
|
-
type Reaction = Amity.Reactor & Amity.Relationship<ReactableType>;
|
|
13
|
+
} & Amity.Timestamps;
|
|
16
14
|
|
|
17
15
|
type Reactable = {
|
|
18
16
|
reactionsCount: number;
|
|
19
17
|
reactions: Record<string, number>;
|
|
20
18
|
myReactions?: string[];
|
|
21
19
|
|
|
22
|
-
latestReaction?: Amity.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
latestReaction?: Amity.Reactor &
|
|
21
|
+
Amity.Relationship<ReactableType> & {
|
|
22
|
+
eventName: 'add' | 'remove';
|
|
23
|
+
userDisplayName: string;
|
|
24
|
+
};
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
type
|
|
27
|
+
type Reaction = {
|
|
29
28
|
reactors: Reactor[];
|
|
30
29
|
} & Amity.Relationship<ReactableType>;
|
|
31
30
|
|
|
32
31
|
type QueryReactions = {
|
|
33
32
|
referenceId: Amity.Reaction['referenceId'];
|
|
34
33
|
referenceType: Amity.Reaction['referenceType'];
|
|
35
|
-
reactionName?: Amity.
|
|
34
|
+
reactionName?: Amity.Reactor['reactionName'];
|
|
36
35
|
page?: Amity.Page<string>;
|
|
37
36
|
};
|
|
38
37
|
|
|
@@ -54,7 +54,7 @@ export const queryCategories = async (
|
|
|
54
54
|
const cacheKey = [
|
|
55
55
|
'category',
|
|
56
56
|
'query',
|
|
57
|
-
{ ...params, options: { ...page } } as Amity.Serializable,
|
|
57
|
+
{ ...params, includeDeleted, options: { ...page } } as Amity.Serializable,
|
|
58
58
|
];
|
|
59
59
|
pushToCache(cacheKey, { categories: categories.map(getResolver('category')), paging });
|
|
60
60
|
}
|
|
@@ -33,15 +33,9 @@ export const getTotalUnreadCount = (
|
|
|
33
33
|
Amity.ErrorLevel.ERROR,
|
|
34
34
|
);
|
|
35
35
|
|
|
36
|
-
const callbackDataSelector = (data: Amity.UserMarker) => data?.unreadCount ?? 0;
|
|
37
|
-
|
|
38
|
-
// based on the mobile specs, unreadCount will not trigger observer when userMarker
|
|
39
|
-
// is re-fetched, so apply this filter to ensure the behavior is the same.
|
|
40
|
-
const callbackFilter = (newModel: Amity.UserMarker, oldModel: Amity.UserMarker) =>
|
|
41
|
-
newModel?.unreadCount !== oldModel?.unreadCount;
|
|
36
|
+
const callbackDataSelector = (data: Amity.UserMarker | undefined) => data?.unreadCount ?? 0;
|
|
42
37
|
|
|
43
38
|
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched], {
|
|
44
39
|
callbackDataSelector,
|
|
45
|
-
callbackFilter,
|
|
46
40
|
});
|
|
47
41
|
};
|
|
@@ -59,7 +59,7 @@ describe('getTotalUnreadCount', () => {
|
|
|
59
59
|
|
|
60
60
|
await pause();
|
|
61
61
|
|
|
62
|
-
expect(callback).toHaveBeenCalledTimes(
|
|
62
|
+
expect(callback).toHaveBeenCalledTimes(2);
|
|
63
63
|
// on initial, expect 0 unread count
|
|
64
64
|
expect(callback).toHaveBeenLastCalledWith({
|
|
65
65
|
origin: 'server',
|
|
@@ -72,7 +72,7 @@ describe('getTotalUnreadCount', () => {
|
|
|
72
72
|
|
|
73
73
|
await pause();
|
|
74
74
|
|
|
75
|
-
expect(callback).toHaveBeenCalledTimes(
|
|
75
|
+
expect(callback).toHaveBeenCalledTimes(3);
|
|
76
76
|
expect(callback).toHaveBeenLastCalledWith(expected);
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -89,12 +89,6 @@ describe('getTotalUnreadCount', () => {
|
|
|
89
89
|
await pause();
|
|
90
90
|
|
|
91
91
|
// initial callback
|
|
92
|
-
expect(callback).toHaveBeenCalledTimes(1);
|
|
93
|
-
|
|
94
|
-
client.emitter.emit('local.userMarker.fetched', refreshUpdateTime(eventPayload));
|
|
95
|
-
|
|
96
|
-
await pause();
|
|
97
|
-
|
|
98
92
|
expect(callback).toHaveBeenCalledTimes(2);
|
|
99
93
|
|
|
100
94
|
// emit duplicated event
|
|
@@ -102,7 +96,6 @@ describe('getTotalUnreadCount', () => {
|
|
|
102
96
|
|
|
103
97
|
await pause();
|
|
104
98
|
|
|
105
|
-
|
|
106
|
-
expect(callback).toHaveBeenCalledTimes(2);
|
|
99
|
+
expect(callback).toHaveBeenCalledTimes(3);
|
|
107
100
|
});
|
|
108
101
|
});
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
onChannelJoined,
|
|
5
5
|
onChannelLeft,
|
|
6
6
|
} from '~/channelRepsitory';
|
|
7
|
-
import { onUserMarkerSync } from '~/marker/events/onUserMarkerSync'
|
|
7
|
+
import { onUserMarkerSync } from '~/marker/events/onUserMarkerSync';
|
|
8
8
|
import { setIntervalTask } from '~/utils/timer';
|
|
9
9
|
import { getUserMarker } from '~/marker/api';
|
|
10
10
|
import { onFeedMarkerUpdated } from '~/marker/events';
|
|
@@ -15,6 +15,7 @@ import { isUnreadCountSupport } from '~/subChannelRepository/utils';
|
|
|
15
15
|
import { markerSync } from '../api';
|
|
16
16
|
|
|
17
17
|
const SYNC_TRIGGER_INTERVAL_TIME = 2000;
|
|
18
|
+
const ON_SUB_CHANNEL_DELETE_SYNC_TRIGGER_DELAY = 2000;
|
|
18
19
|
|
|
19
20
|
let clearSyncTrigger: Amity.Unsubscriber | undefined;
|
|
20
21
|
let disposers: (() => void)[] = [];
|
|
@@ -138,7 +139,17 @@ const registerEventListeners = () => {
|
|
|
138
139
|
onChannelJoined(() => events.push(Amity.MarkerSyncEvent.CHANNEL_JOINED)),
|
|
139
140
|
onChannelLeft(() => events.push(Amity.MarkerSyncEvent.CHANNEL_LEFT)),
|
|
140
141
|
onSubChannelCreated(() => events.push(Amity.MarkerSyncEvent.SUB_CHANNEL_CREATED)),
|
|
141
|
-
onSubChannelDeleted(() =>
|
|
142
|
+
onSubChannelDeleted(() =>
|
|
143
|
+
/*
|
|
144
|
+
workaround: when receiving the event for sub-channel deletion,
|
|
145
|
+
before triggering marker update, the SDK will have to add a 2-second delay.
|
|
146
|
+
so that the unread count is calculated correctly.
|
|
147
|
+
*/
|
|
148
|
+
setTimeout(
|
|
149
|
+
() => events.push(Amity.MarkerSyncEvent.SUBCHANNEL_IS_DELETED),
|
|
150
|
+
ON_SUB_CHANNEL_DELETE_SYNC_TRIGGER_DELAY,
|
|
151
|
+
),
|
|
152
|
+
),
|
|
142
153
|
onFeedMarkerUpdated(() => events.push(Amity.MarkerSyncEvent.MARKER_UPDATED)),
|
|
143
154
|
onUserMarkerSync(() => events.push(Amity.MarkerSyncEvent.MARKER_UPDATED)),
|
|
144
155
|
);
|
|
@@ -24,7 +24,7 @@ export const onCommentReactionAdded = (
|
|
|
24
24
|
): Amity.Unsubscriber => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
|
|
27
|
-
const filter = (payload: Amity.CommentPayload & { reactor: Amity.
|
|
27
|
+
const filter = (payload: Amity.CommentPayload & { reactor: Amity.Reactor }) => {
|
|
28
28
|
if (!client.cache) {
|
|
29
29
|
callback(payload.comments[0]);
|
|
30
30
|
} else {
|
|
@@ -24,7 +24,7 @@ export const onCommentReactionRemoved = (
|
|
|
24
24
|
): Amity.Unsubscriber => {
|
|
25
25
|
const client = getActiveClient();
|
|
26
26
|
|
|
27
|
-
const filter = (payload: Amity.CommentPayload & { reactor: Amity.
|
|
27
|
+
const filter = (payload: Amity.CommentPayload & { reactor: Amity.Reactor }) => {
|
|
28
28
|
if (!client.cache) {
|
|
29
29
|
callback(payload.comments[0]);
|
|
30
30
|
} else {
|
|
@@ -14,11 +14,11 @@ import {
|
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
16
|
* ```js
|
|
17
|
-
* import {
|
|
17
|
+
* import { CommentRepository } from '@amityco/ts-sdk';
|
|
18
18
|
*
|
|
19
19
|
* let comment;
|
|
20
20
|
*
|
|
21
|
-
* const
|
|
21
|
+
* const unsub = CommentRepository.getComment(commentId, response => {
|
|
22
22
|
* comment = response.data;
|
|
23
23
|
* });
|
|
24
24
|
* ```
|
|
@@ -75,12 +75,10 @@ describe('getComment', () => {
|
|
|
75
75
|
data: { text: 'new-text' },
|
|
76
76
|
updatedAt: getFutureDate(comment.updatedAt),
|
|
77
77
|
};
|
|
78
|
-
const reactor: Amity.
|
|
78
|
+
const reactor: Amity.Reactor = {
|
|
79
79
|
createdAt: getFutureDate(comment.updatedAt),
|
|
80
80
|
reactionId: 'like',
|
|
81
81
|
reactionName: 'like',
|
|
82
|
-
referenceId: comment.commentId,
|
|
83
|
-
referenceType: 'comment',
|
|
84
82
|
userId: user12.userId,
|
|
85
83
|
};
|
|
86
84
|
const callback = jest.fn();
|
|
@@ -7,8 +7,8 @@ import { prepareCommunityPayload } from '../utils';
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* ```js
|
|
10
|
-
* import {
|
|
11
|
-
* const community = await getCommunity('foobar')
|
|
10
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
11
|
+
* const community = await CommunityRepository.getCommunity('foobar')
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
14
|
* Fetches a {@link Amity.Community} object
|
|
@@ -45,8 +45,8 @@ export const getCommunity = async (
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* ```js
|
|
48
|
-
* import {
|
|
49
|
-
* const community = getCommunity.locally('foobar')
|
|
48
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
49
|
+
* const community = CommunityRepository.getCommunity.locally('foobar')
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
52
|
* Fetches a {@link Amity.Community} object from cache
|
|
@@ -11,8 +11,8 @@ import { prepareCommunityPayload } from '../utils';
|
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* ```js
|
|
14
|
-
* import {
|
|
15
|
-
* const communities = await getRecommendedCommunities()
|
|
14
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
15
|
+
* const communities = await CommunityRepository.getRecommendedCommunities()
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
18
|
* Gets a list of recommended {@link Amity.Community} objects
|
|
@@ -56,8 +56,8 @@ export const getRecommendedCommunities = async (
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* ```js
|
|
59
|
-
* import {
|
|
60
|
-
* const communities = getRecommendedCommunities.locally()
|
|
59
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
60
|
+
* const communities = CommunityRepository.getRecommendedCommunities.locally()
|
|
61
61
|
* ```
|
|
62
62
|
*
|
|
63
63
|
* Gets a list of recommended {@link Amity.Community} objects from cache
|
|
@@ -10,9 +10,12 @@ import { prepareCommunityPayload } from '../utils';
|
|
|
10
10
|
id: community.query.trending_communities
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
+
* @deprecated This API renamed to `getTrendingCommunities()`.
|
|
14
|
+
* Please use getTrendingCommunities() instead.
|
|
15
|
+
*
|
|
13
16
|
* ```js
|
|
14
|
-
* import {
|
|
15
|
-
* const trendingCommunities = await getTopTrendingCommunities()
|
|
17
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
18
|
+
* const trendingCommunities = await CommunityRepository.getTopTrendingCommunities()
|
|
16
19
|
* ```
|
|
17
20
|
*
|
|
18
21
|
* Gets a list of top trending {@link Amity.Community} objects
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api';
|
|
2
|
+
|
|
3
|
+
import { getResolver } from '~/core/model';
|
|
4
|
+
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
5
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
6
|
+
|
|
7
|
+
import { prepareCommunityPayload } from '../utils';
|
|
8
|
+
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
9
|
+
|
|
10
|
+
/* begin_public_function
|
|
11
|
+
id: community.query.trending_communities
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* ```js
|
|
15
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
16
|
+
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Gets a list of top trending {@link Amity.Community} objects
|
|
20
|
+
*
|
|
21
|
+
* @param query The query parameters
|
|
22
|
+
* @returns A list of {@link Amity.Community} objects
|
|
23
|
+
*
|
|
24
|
+
* @category Community API
|
|
25
|
+
* @async
|
|
26
|
+
*/
|
|
27
|
+
export const getTrendingCommunities = async (
|
|
28
|
+
query: Amity.PageLimit,
|
|
29
|
+
): Promise<Amity.Cached<Amity.Community[]>> => {
|
|
30
|
+
const client = getActiveClient();
|
|
31
|
+
client.log('channel/getTopTrendingCommunities', query);
|
|
32
|
+
|
|
33
|
+
const { limit = 5 } = query ?? {};
|
|
34
|
+
|
|
35
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
36
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
37
|
+
const { data: payload } = await client.http.get<Amity.CommunityPayload>(
|
|
38
|
+
`/api/v3/communities/top-trending`,
|
|
39
|
+
{ params: { options: { limit } } },
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const data = prepareCommunityPayload(payload);
|
|
43
|
+
const { communities } = data;
|
|
44
|
+
|
|
45
|
+
const cachedAt = client.cache && Date.now();
|
|
46
|
+
|
|
47
|
+
if (client.cache) {
|
|
48
|
+
ingestInCache(data, { cachedAt });
|
|
49
|
+
|
|
50
|
+
const cacheKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
51
|
+
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { data: communities, cachedAt };
|
|
55
|
+
};
|
|
56
|
+
/* end_public_function */
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* ```js
|
|
60
|
+
* import { getTrendingCommunities } from '@amityco/ts-sdk'
|
|
61
|
+
* const communities = getTrendingCommunities.locally()
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Gets a list of trending {@link Amity.Community} objects from cache
|
|
65
|
+
*
|
|
66
|
+
* @param query The query parameters
|
|
67
|
+
* @returns communities
|
|
68
|
+
*
|
|
69
|
+
* @category Community API
|
|
70
|
+
*/
|
|
71
|
+
getTrendingCommunities.locally = (
|
|
72
|
+
query: Parameters<typeof getTrendingCommunities>[0],
|
|
73
|
+
): Amity.Cached<Amity.Community[]> | undefined => {
|
|
74
|
+
const client = getActiveClient();
|
|
75
|
+
client.log('community/getTrendingCommunities.locally', query);
|
|
76
|
+
|
|
77
|
+
if (!client.cache) return;
|
|
78
|
+
|
|
79
|
+
const { limit: queryLimit } = query;
|
|
80
|
+
|
|
81
|
+
const limit = queryLimit ?? COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
82
|
+
|
|
83
|
+
const queryKey = ['community', 'top-trending', { params: { options: { limit } } }];
|
|
84
|
+
const { data, cachedAt } =
|
|
85
|
+
pullFromCache<{ communities: Pick<Amity.Community, 'communityId'>[] }>(queryKey) ?? {};
|
|
86
|
+
|
|
87
|
+
if (!data?.communities.length) return;
|
|
88
|
+
|
|
89
|
+
const communities: Amity.Community[] = data.communities
|
|
90
|
+
.map(communityId => pullFromCache<Amity.Community>(['community', 'get', communityId])!)
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.map(({ data }) => data);
|
|
93
|
+
|
|
94
|
+
return communities.length === data?.communities?.length
|
|
95
|
+
? { data: communities, cachedAt }
|
|
96
|
+
: undefined;
|
|
97
|
+
};
|