@amityco/ts-sdk 0.0.1-beta.13 → 0.0.1-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/@types/core/cache.d.ts +2 -2
- package/dist/@types/core/cache.d.ts.map +1 -1
- package/dist/@types/core/events.d.ts +12 -3
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/paging.d.ts +22 -41
- package/dist/@types/core/paging.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +10 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/query.d.ts +13 -4
- package/dist/@types/core/query.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +0 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -2
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts +20 -0
- package/dist/@types/domains/follow.d.ts.map +1 -0
- package/dist/@types/domains/mention.d.ts +23 -0
- package/dist/@types/domains/mention.d.ts.map +1 -0
- package/dist/@types/domains/message.d.ts +1 -1
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts +0 -10
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +1 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts +2 -2
- package/dist/channel/api/createChannel.d.ts +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/client/api/activeUser.d.ts +6 -0
- package/dist/client/api/activeUser.d.ts.map +1 -0
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +3 -3
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts +12 -0
- package/dist/client/utils/endpoints.d.ts.map +1 -0
- package/dist/community/api/getRecommendedCommunities.d.ts +32 -0
- package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -0
- package/dist/community/api/getTopTrendingCommunities.d.ts +32 -0
- package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -0
- package/dist/community/api/index.d.ts +2 -0
- package/dist/community/api/index.d.ts.map +1 -1
- package/dist/core/debug.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/microtasks.d.ts +13 -0
- package/dist/core/microtasks.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/core/model/index.d.ts.map +1 -1
- package/dist/core/query/paging.d.ts +5 -16
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/core/query/query.d.ts +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/core/subscription.d.ts +2 -0
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/feed/api/queryGlobalFeed.d.ts +22 -4
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/follow/api/acceptFollower.d.ts +16 -0
- package/dist/follow/api/acceptFollower.d.ts.map +1 -0
- package/dist/follow/api/declineFollower.d.ts +16 -0
- package/dist/follow/api/declineFollower.d.ts.map +1 -0
- package/dist/follow/api/follow.d.ts +16 -0
- package/dist/follow/api/follow.d.ts.map +1 -0
- package/dist/follow/api/getFollowInfo.d.ts +32 -0
- package/dist/follow/api/getFollowInfo.d.ts.map +1 -0
- package/dist/follow/api/index.d.ts +8 -0
- package/dist/follow/api/index.d.ts.map +1 -0
- package/dist/follow/api/queryFollowers.d.ts +36 -0
- package/dist/follow/api/queryFollowers.d.ts.map +1 -0
- package/dist/follow/api/queryFollowings.d.ts +36 -0
- package/dist/follow/api/queryFollowings.d.ts.map +1 -0
- package/dist/follow/api/unfollow.d.ts +16 -0
- package/dist/follow/api/unfollow.d.ts.map +1 -0
- package/dist/follow/api/utils.d.ts +9 -0
- package/dist/follow/api/utils.d.ts.map +1 -0
- package/dist/follow/events/index.d.ts +9 -0
- package/dist/follow/events/index.d.ts.map +1 -0
- package/dist/follow/events/onFollowInfoUpdated.d.ts +17 -0
- package/dist/follow/events/onFollowInfoUpdated.d.ts.map +1 -0
- package/dist/follow/events/onFollowRequestAccepted.d.ts +17 -0
- package/dist/follow/events/onFollowRequestAccepted.d.ts.map +1 -0
- package/dist/follow/events/onFollowRequestCanceled.d.ts +17 -0
- package/dist/follow/events/onFollowRequestCanceled.d.ts.map +1 -0
- package/dist/follow/events/onFollowRequestDeclined.d.ts +17 -0
- package/dist/follow/events/onFollowRequestDeclined.d.ts.map +1 -0
- package/dist/follow/events/onFollowerDeleted.d.ts +17 -0
- package/dist/follow/events/onFollowerDeleted.d.ts.map +1 -0
- package/dist/follow/events/onFollowerRequested.d.ts +17 -0
- package/dist/follow/events/onFollowerRequested.d.ts.map +1 -0
- package/dist/follow/events/onUserFollowed.d.ts +17 -0
- package/dist/follow/events/onUserFollowed.d.ts.map +1 -0
- package/dist/follow/events/onUserUnfollowed.d.ts +17 -0
- package/dist/follow/events/onUserUnfollowed.d.ts.map +1 -0
- package/dist/follow/events/utils.d.ts +2 -0
- package/dist/follow/events/utils.d.ts.map +1 -0
- package/dist/follow/observers/index.d.ts +4 -0
- package/dist/follow/observers/index.d.ts.map +1 -0
- package/dist/follow/observers/observeFollowInfo.d.ts +18 -0
- package/dist/follow/observers/observeFollowInfo.d.ts.map +1 -0
- package/dist/follow/observers/observeFollowers.d.ts +18 -0
- package/dist/follow/observers/observeFollowers.d.ts.map +1 -0
- package/dist/follow/observers/observeFollowings.d.ts +18 -0
- package/dist/follow/observers/observeFollowings.d.ts.map +1 -0
- package/dist/index.cjs.js +845 -74
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +823 -74
- package/dist/index.umd.js +5 -5
- package/dist/message/api/createMessage.d.ts +2 -2
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/api/updateMessage.d.ts +2 -2
- package/dist/message/api/updateMessage.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts +3 -3
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/utils/env.d.ts +5 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/cache.ts +2 -2
- package/src/@types/core/events.ts +12 -1
- package/src/@types/core/model.ts +6 -0
- package/src/@types/core/paging.ts +31 -46
- package/src/@types/core/payload.ts +14 -0
- package/src/@types/core/query.ts +11 -3
- package/src/@types/domains/client.ts +0 -1
- package/src/@types/domains/comment.ts +1 -3
- package/src/@types/domains/follow.ts +25 -0
- package/src/@types/domains/mention.ts +26 -0
- package/src/@types/domains/message.ts +1 -0
- package/src/@types/domains/partials.ts +0 -8
- package/src/@types/domains/post.ts +1 -3
- package/src/@types/index.ts +3 -0
- package/src/channel/api/createChannel.ts +1 -1
- package/src/channel/api/queryChannelMembers.ts +2 -1
- package/src/client/api/activeUser.ts +26 -0
- package/src/client/api/connectClient.ts +3 -1
- package/src/client/api/createClient.ts +7 -7
- package/src/client/utils/endpoints.ts +14 -0
- package/src/community/api/getRecommendedCommunities.ts +86 -0
- package/src/community/api/getTopTrendingCommunities.ts +86 -0
- package/src/community/api/index.ts +3 -0
- package/src/community/api/queryCommunityMembers.ts +1 -1
- package/src/core/debug.ts +3 -1
- package/src/core/device.ts +3 -2
- package/src/core/events.ts +3 -1
- package/src/core/microtasks.ts +27 -0
- package/src/core/model/idResolvers.ts +3 -0
- package/src/core/model/identifyModel.ts +2 -0
- package/src/core/model/index.ts +3 -0
- package/src/core/query/paging.ts +16 -51
- package/src/core/query/query.ts +5 -5
- package/src/core/subscription.ts +21 -3
- package/src/feed/api/queryGlobalFeed.ts +58 -5
- package/src/follow/api/acceptFollower.ts +32 -0
- package/src/follow/api/declineFollower.ts +32 -0
- package/src/follow/api/follow.ts +40 -0
- package/src/follow/api/getFollowInfo.ts +75 -0
- package/src/follow/api/index.ts +8 -0
- package/src/follow/api/queryFollowers.ts +42 -0
- package/src/follow/api/queryFollowings.ts +42 -0
- package/src/follow/api/unfollow.ts +32 -0
- package/src/follow/api/utils.ts +77 -0
- package/src/follow/events/index.ts +10 -0
- package/src/follow/events/onFollowInfoUpdated.ts +43 -0
- package/src/follow/events/onFollowRequestAccepted.ts +19 -0
- package/src/follow/events/onFollowRequestCanceled.ts +19 -0
- package/src/follow/events/onFollowRequestDeclined.ts +19 -0
- package/src/follow/events/onFollowerDeleted.ts +19 -0
- package/src/follow/events/onFollowerRequested.ts +19 -0
- package/src/follow/events/onUserFollowed.ts +19 -0
- package/src/follow/events/onUserUnfollowed.ts +19 -0
- package/src/follow/events/utils.ts +38 -0
- package/src/follow/observers/index.ts +3 -0
- package/src/follow/observers/observeFollowInfo.ts +68 -0
- package/src/follow/observers/observeFollowers.ts +78 -0
- package/src/follow/observers/observeFollowings.ts +78 -0
- package/src/index.ts +5 -0
- package/src/message/api/createMessage.ts +2 -2
- package/src/message/api/updateMessage.ts +2 -2
- package/src/post/api/queryPosts.ts +5 -5
- package/src/utils/env.ts +7 -0
- package/src/version.ts +3 -1
- package/dist/core/network.d.ts +0 -11
- package/dist/core/network.d.ts.map +0 -1
- package/src/core/network.ts +0 -14
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @async
|
|
17
17
|
*/
|
|
18
18
|
export declare const createMessage: {
|
|
19
|
-
<T extends Amity.MessageContentType>(bundle: Pick<Amity.Message<T>, "type" | "channelId" | "data" | "metadata">): Promise<Amity.Cached<Amity.Message>>;
|
|
19
|
+
<T extends Amity.MessageContentType>(bundle: Pick<Amity.Message<T>, "type" | "channelId" | "data" | "metadata" | "mentionees">): Promise<Amity.Cached<Amity.Message>>;
|
|
20
20
|
/**
|
|
21
21
|
* ```js
|
|
22
22
|
* import { createMessage } from '@amityco/ts-sdk'
|
|
@@ -33,6 +33,6 @@ export declare const createMessage: {
|
|
|
33
33
|
*
|
|
34
34
|
* @category Message API
|
|
35
35
|
*/
|
|
36
|
-
optimistically(bundle: Pick<Amity.Message, 'channelId' | 'type' | 'data' | 'metadata'>): Amity.Cached<Amity.Message> | undefined;
|
|
36
|
+
optimistically(bundle: Pick<Amity.Message, 'channelId' | 'type' | 'data' | 'metadata' | 'mentionees'>): Amity.Cached<Amity.Message> | undefined;
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=createMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMessage.d.ts","sourceRoot":"","sources":["../../../src/message/api/createMessage.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"createMessage.d.ts","sourceRoot":"","sources":["../../../src/message/api/createMessage.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;qIAEvB,QAAQ,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC;IAoBvC;;;;;;;;;;;;;;;OAeG;2BAEO,KAAK,MAAM,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC,GACrF,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS;CApBzC,CAAA"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* @async
|
|
17
17
|
*/
|
|
18
18
|
export declare const updateMessage: {
|
|
19
|
-
(messageId: Amity.Message['messageId'], patch: Patch<Amity.Message, 'data' | 'metadata'>): Promise<Amity.Cached<Amity.Message>>;
|
|
19
|
+
(messageId: Amity.Message['messageId'], patch: Patch<Amity.Message, 'data' | 'metadata' | 'mentionees'>): Promise<Amity.Cached<Amity.Message>>;
|
|
20
20
|
/**
|
|
21
21
|
* ```js
|
|
22
22
|
* import { updateMessage } from '@amityco/ts-sdk'
|
|
@@ -33,6 +33,6 @@ export declare const updateMessage: {
|
|
|
33
33
|
*
|
|
34
34
|
* @category Message API
|
|
35
35
|
*/
|
|
36
|
-
optimistically(messageId: Amity.Message['messageId'], patch: Patch<Amity.Message, 'data' | 'metadata'>): Amity.Cached<Amity.Message> | undefined;
|
|
36
|
+
optimistically(messageId: Amity.Message['messageId'], patch: Patch<Amity.Message, 'data' | 'metadata' | 'mentionees'>): Amity.Cached<Amity.Message> | undefined;
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=updateMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateMessage.d.ts","sourceRoot":"","sources":["../../../src/message/api/updateMessage.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;gBACb,MAAM,OAAO,CAAC,WAAW,CAAC,SAC9B,MAAM,MAAM,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"updateMessage.d.ts","sourceRoot":"","sources":["../../../src/message/api/updateMessage.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;gBACb,MAAM,OAAO,CAAC,WAAW,CAAC,SAC9B,MAAM,MAAM,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC,GAC9D,QAAQ,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC;IAmBvC;;;;;;;;;;;;;;;OAeG;8BAEU,MAAM,OAAO,CAAC,WAAW,CAAC,SAC9B,MAAM,MAAM,OAAO,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC,GAC9D,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS;CArBzC,CAAA"}
|
|
@@ -23,8 +23,8 @@ export declare const queryPosts: {
|
|
|
23
23
|
feedType?: 'reviewing' | 'published';
|
|
24
24
|
tags?: Amity.Taggable['tags'];
|
|
25
25
|
matchingOnlyParentPost?: boolean;
|
|
26
|
-
page?: Amity.
|
|
27
|
-
}): Promise<Amity.Cached<Amity.
|
|
26
|
+
page?: Amity.PageRaw;
|
|
27
|
+
}): Promise<Amity.Cached<Amity.Paged<Amity.Post, Amity.PageRaw>>>;
|
|
28
28
|
/**
|
|
29
29
|
* ```js
|
|
30
30
|
* import { queryPosts } from '@amityco/ts-sdk'
|
|
@@ -38,6 +38,6 @@ export declare const queryPosts: {
|
|
|
38
38
|
*
|
|
39
39
|
* @category Post API
|
|
40
40
|
*/
|
|
41
|
-
locally(query: Parameters<typeof queryPosts>[0]): Amity.Cached<Amity.
|
|
41
|
+
locally(query: Parameters<typeof queryPosts>[0]): Amity.Cached<Amity.Paged<Amity.Post, Amity.PageRaw>> | undefined;
|
|
42
42
|
};
|
|
43
43
|
//# sourceMappingURL=queryPosts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryPosts.d.ts","sourceRoot":"","sources":["../../../src/post/api/queryPosts.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU;YACd;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,cAAc,CAAA;QACxE,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC,WAAW,CAAC,CAAA;QACnC,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,CAAA;QACpC,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAA;QAChC,IAAI,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"queryPosts.d.ts","sourceRoot":"","sources":["../../../src/post/api/queryPosts.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU;YACd;QACL,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;QACrC,MAAM,CAAC,EAAE,aAAa,GAAG,cAAc,GAAG,aAAa,GAAG,cAAc,CAAA;QACxE,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC,WAAW,CAAC,CAAA;QACnC,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,QAAQ,CAAC,EAAE,WAAW,GAAG,WAAW,CAAA;QACpC,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAA;QAChC,IAAI,CAAC,EAAE,MAAM,OAAO,CAAA;KACrB,GACA,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;IAuChE;;;;;;;;;;;;OAYG;mBAEM,WAAW,iBAAiB,CAAC,CAAC,CAAC,CAAC,GACtC,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,GAAG,SAAS;CAjBlE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":";AAEA,eAAO,MAAiB,WAAW,yBAAyD,CAAA;AAE5F,wBAAgB,MAAM,sBAAmC;AAEzD,eAAO,MAAM,YAAY,SAA6C,CAAA"}
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,QAAwC,CAAA"}
|
package/package.json
CHANGED
package/src/@types/core/cache.ts
CHANGED
|
@@ -49,11 +49,11 @@ declare global {
|
|
|
49
49
|
* Minimal CacheEntry alias, used mostly
|
|
50
50
|
*/
|
|
51
51
|
type Cached<T extends unknown = unknown> = (
|
|
52
|
-
T extends
|
|
52
|
+
T extends Amity.Paged<any, infer K>
|
|
53
53
|
? T
|
|
54
54
|
: { data: T }
|
|
55
55
|
) & {
|
|
56
|
-
cachedAt
|
|
56
|
+
cachedAt: CacheOptions['cachedAt']
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -6,7 +6,7 @@ declare global {
|
|
|
6
6
|
namespace Amity {
|
|
7
7
|
type Listener<T = any> = (params: T) => void
|
|
8
8
|
|
|
9
|
-
type ObjectListener<T, K extends string[]> = {
|
|
9
|
+
type ObjectListener<T, K extends string[]> = Listener<T> | {
|
|
10
10
|
onEvent?: (event: K[number], params: T) => void
|
|
11
11
|
} & {
|
|
12
12
|
[P in K[number]]?: Listener<T>
|
|
@@ -96,10 +96,21 @@ declare global {
|
|
|
96
96
|
'user.flagCleared': Amity.UserPayload
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
type MqttFollowMessageEvents = {
|
|
100
|
+
'follow.created': Amity.FollowStatus
|
|
101
|
+
'follow.requested': Amity.FollowStatus
|
|
102
|
+
'follow.accepted': Amity.FollowStatus
|
|
103
|
+
'follow.unfollowed': Amity.FollowStatus
|
|
104
|
+
'follow.requestCanceled': Amity.FollowStatus
|
|
105
|
+
'follow.requestDeclined': Amity.FollowStatus
|
|
106
|
+
'follow.followerDeleted': Amity.FollowStatus
|
|
107
|
+
}
|
|
108
|
+
|
|
99
109
|
type MqttMessageEvents = MqttCommunityMessageEvents
|
|
100
110
|
& MqttPostMessageEvents
|
|
101
111
|
& MqttCommentMessageEvents
|
|
102
112
|
& MqttUserMessageEvents
|
|
113
|
+
& MqttFollowMessageEvents
|
|
103
114
|
|
|
104
115
|
type Events = WsEvents & MqttEvents & MqttMessageEvents
|
|
105
116
|
}
|
package/src/@types/core/model.ts
CHANGED
|
@@ -23,6 +23,9 @@ declare global {
|
|
|
23
23
|
'comment': Amity.Comment
|
|
24
24
|
|
|
25
25
|
'stream': Amity.Stream
|
|
26
|
+
|
|
27
|
+
'follow': Amity.FollowStatus
|
|
28
|
+
'followCount': Amity.FollowCount
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
/**
|
|
@@ -48,6 +51,9 @@ declare global {
|
|
|
48
51
|
'comment': Pick<Amity.Comment, 'commentId'>
|
|
49
52
|
|
|
50
53
|
'stream': Pick<Amity.Stream, 'streamId'>
|
|
54
|
+
|
|
55
|
+
'follow': Pick<Amity.FollowStatus, 'from' | 'to'>
|
|
56
|
+
'followCount': Pick<Amity.FollowCount, 'userId'>
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
}
|
|
@@ -2,6 +2,32 @@ export {}
|
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Amity {
|
|
5
|
+
type PaginationStyles = 'skiplimit' | 'afterbefore' | 'afterbeforeraw'
|
|
6
|
+
|
|
7
|
+
type PageLimit = {
|
|
8
|
+
limit: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type PrevPage<T extends number | string> = PageLimit & {
|
|
12
|
+
after?: never
|
|
13
|
+
before?: T
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type NextPage<T extends number | string> = PageLimit & {
|
|
17
|
+
after?: T
|
|
18
|
+
before?: never
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Page = PrevPage<number> | NextPage<number>
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
updatedAt is here because if you need sort by updatedAt you
|
|
25
|
+
need to include this data in query also
|
|
26
|
+
*/
|
|
27
|
+
type PageRaw = (PrevPage<string> | NextPage<string>) & {
|
|
28
|
+
updatedAt?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
5
31
|
type SkipLimitPagination = {
|
|
6
32
|
skip?: number
|
|
7
33
|
limit?: number
|
|
@@ -22,54 +48,13 @@ declare global {
|
|
|
22
48
|
last?: number
|
|
23
49
|
}
|
|
24
50
|
|
|
25
|
-
type
|
|
26
|
-
after?: never
|
|
27
|
-
before?: number
|
|
28
|
-
limit: number
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type NextPage = {
|
|
32
|
-
after?: number
|
|
33
|
-
before?: never
|
|
34
|
-
limit: number
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type Page = (PrevPage | NextPage)
|
|
38
|
-
|
|
39
|
-
type Pages = {
|
|
40
|
-
nextPage?: Page | null
|
|
41
|
-
prevPage?: Page | null
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
type Paged<T> = { data: T[] } & Pages
|
|
45
|
-
|
|
46
|
-
type AfterBeforeRawPagination = {
|
|
47
|
-
before?: string
|
|
48
|
-
after?: string
|
|
49
|
-
updatedAt?: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
type PrevPageRaw = {
|
|
53
|
-
after?: never
|
|
54
|
-
before?: string
|
|
55
|
-
limit: number
|
|
56
|
-
updatedAt?: string
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type NextPageRaw = {
|
|
60
|
-
after?: string
|
|
61
|
-
before?: never
|
|
62
|
-
limit: number
|
|
63
|
-
updatedAt?: string
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
type PageRaw = (PrevPageRaw | NextPageRaw)
|
|
51
|
+
type AfterBeforeRawPagination = PageRaw
|
|
67
52
|
|
|
68
|
-
type
|
|
69
|
-
nextPage?:
|
|
70
|
-
prevPage?:
|
|
53
|
+
type Pages<T extends (Page | PageRaw)> = {
|
|
54
|
+
nextPage?: T
|
|
55
|
+
prevPage?: T
|
|
71
56
|
}
|
|
72
57
|
|
|
73
|
-
type
|
|
58
|
+
type Paged<T, K extends (Page | PageRaw) = Page> = { data: T[] } & Pages<K>
|
|
74
59
|
}
|
|
75
60
|
}
|
|
@@ -98,5 +98,19 @@ declare global {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
type GlobalFeedPayload = Amity.PostPayload
|
|
101
|
+
|
|
102
|
+
type FollowersPayload = {
|
|
103
|
+
follows: Amity.FollowStatus[]
|
|
104
|
+
}
|
|
105
|
+
& UserPayload
|
|
106
|
+
|
|
107
|
+
type FollowStatusPayload = {
|
|
108
|
+
follows: Amity.FollowStatus[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type FollowInfoPayload = {
|
|
112
|
+
follows: Amity.FollowStatus[]
|
|
113
|
+
followCounts: Amity.FollowCount[]
|
|
114
|
+
}
|
|
101
115
|
}
|
|
102
116
|
}
|
package/src/@types/core/query.ts
CHANGED
|
@@ -46,9 +46,17 @@ declare global {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
type Snapshot<T> = (
|
|
49
|
-
T extends Amity.Cached<infer
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
T extends Amity.Cached<infer T2>
|
|
50
|
+
? T2 extends Amity.Paged<infer T3, infer T4>
|
|
51
|
+
? { data: T3[] | undefined } & Pages<T4> & { cachedAt?: CacheOptions['cachedAt'] }
|
|
52
|
+
: { data: T2 } & { cachedAt?: CacheOptions['cachedAt'] }
|
|
53
|
+
: T extends Amity.Paged<infer T3, infer T4>
|
|
54
|
+
? { data: T3[] | undefined } & Pages<T4>
|
|
55
|
+
: { data: T | undefined }
|
|
52
56
|
) & SnapshotOptions
|
|
57
|
+
|
|
58
|
+
type RunQueryOptions<T> = T extends Amity.AsyncFunc<infer Args, infer Returned>
|
|
59
|
+
? Omit<Amity.Snapshot<Returned>, 'data'>
|
|
60
|
+
: never
|
|
53
61
|
}
|
|
54
62
|
}
|
|
@@ -5,8 +5,6 @@ declare global {
|
|
|
5
5
|
type CommentContentType = ('text')
|
|
6
6
|
type CommentReferenceType = ('content' | 'post')
|
|
7
7
|
|
|
8
|
-
type CommentMentionType = keyof MentionTypes
|
|
9
|
-
|
|
10
8
|
type Comment<T extends CommentContentType = any> = {
|
|
11
9
|
commentId: string
|
|
12
10
|
userId: string
|
|
@@ -24,6 +22,6 @@ declare global {
|
|
|
24
22
|
& Amity.Timestamps
|
|
25
23
|
& Amity.SoftDelete
|
|
26
24
|
& Amity.Subscribable
|
|
27
|
-
& Amity.Mentionable<
|
|
25
|
+
& Amity.Mentionable<'user'>
|
|
28
26
|
}
|
|
29
27
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Amity {
|
|
5
|
+
type FollowStatus = {
|
|
6
|
+
from: Amity.User['userId']
|
|
7
|
+
to: Amity.User['userId']
|
|
8
|
+
status: 'pending' | 'accepted' | 'none'
|
|
9
|
+
}
|
|
10
|
+
& Amity.CreatedAt
|
|
11
|
+
& Amity.UpdatedAt
|
|
12
|
+
|
|
13
|
+
type FollowCount = {
|
|
14
|
+
userId: Amity.User['userId']
|
|
15
|
+
followerCount: number
|
|
16
|
+
followingCount: number
|
|
17
|
+
pendingCount: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type FollowInfo = {
|
|
21
|
+
status?: FollowStatus['status']
|
|
22
|
+
}
|
|
23
|
+
& FollowCount
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export {}
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace Amity {
|
|
5
|
+
type Mention = {
|
|
6
|
+
type: "user" | "channel"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type ChannelMention = Mention & {
|
|
10
|
+
type: "channel"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type UserMention = Mention & {
|
|
14
|
+
type: "user", userIds: string[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type MentionType = {
|
|
18
|
+
"channel": ChannelMention
|
|
19
|
+
"user": UserMention
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type Mentionable<T extends keyof MentionType = 'channel' | 'user'> = {
|
|
23
|
+
mentionees?: (MentionType[T])[]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -52,13 +52,5 @@ declare global {
|
|
|
52
52
|
type Subscribable = {
|
|
53
53
|
path: string
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
type MentionTypes = {
|
|
57
|
-
user: { userIds: Amity.User['userId'][] }
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
type Mentionable<T extends keyof MentionTypes> = {
|
|
61
|
-
mentionees?: {type: T & MentionTypes}[]
|
|
62
|
-
}
|
|
63
55
|
}
|
|
64
56
|
}
|
|
@@ -7,8 +7,6 @@ declare global {
|
|
|
7
7
|
|
|
8
8
|
type PostContentType = ('text' | 'image' | 'file' | 'video')
|
|
9
9
|
|
|
10
|
-
type PostMentionType = keyof MentionTypes
|
|
11
|
-
|
|
12
10
|
type Post<T extends PostContentType = any> = {
|
|
13
11
|
postId: string
|
|
14
12
|
postedUserId: User['userId'] // API-FIX: it should be "userId"
|
|
@@ -30,6 +28,6 @@ declare global {
|
|
|
30
28
|
& Amity.Timestamps
|
|
31
29
|
& Amity.SoftDelete
|
|
32
30
|
& Amity.Subscribable
|
|
33
|
-
& Amity.Mentionable<
|
|
31
|
+
& Amity.Mentionable<'user'>
|
|
34
32
|
}
|
|
35
33
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import './core/cache' // cache.pull('user', ...)
|
|
|
13
13
|
import './domains/client' // client definition
|
|
14
14
|
|
|
15
15
|
import './domains/user'
|
|
16
|
+
import './domains/follow'
|
|
16
17
|
import './domains/file'
|
|
17
18
|
|
|
18
19
|
import './domains/partials' // small model partials (CreatedAt, etc...)
|
|
@@ -29,3 +30,5 @@ import './domains/post'
|
|
|
29
30
|
import './domains/comment'
|
|
30
31
|
|
|
31
32
|
import './domains/stream'
|
|
33
|
+
|
|
34
|
+
import './domains/mention'
|
|
@@ -17,7 +17,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache'
|
|
|
17
17
|
* @async
|
|
18
18
|
*/
|
|
19
19
|
export const createChannel = async <T extends Amity.ChannelType>(
|
|
20
|
-
bundle: { type: T, userIds?: Amity.User['userId'] }
|
|
20
|
+
bundle: { type: T, userIds?: Amity.User['userId'][] }
|
|
21
21
|
& Pick<Amity.Channel<T>, 'displayName' | 'avatarFileId' | 'tags' | 'metadata'>
|
|
22
22
|
): Promise<Amity.Cached<Amity.Channel>> => {
|
|
23
23
|
const client = getActiveClient()
|
|
@@ -44,6 +44,7 @@ export const queryChannelMembers = async (query: {
|
|
|
44
44
|
const { paging, ...payload } = data
|
|
45
45
|
const { channelUsers } = payload
|
|
46
46
|
|
|
47
|
+
const cachedAt = client.cache && Date.now()
|
|
47
48
|
if (client.cache) {
|
|
48
49
|
ingestInCache(payload as Amity.ChannelMembershipPayload)
|
|
49
50
|
}
|
|
@@ -51,7 +52,7 @@ export const queryChannelMembers = async (query: {
|
|
|
51
52
|
const nextPage = toPage(paging.next)
|
|
52
53
|
const prevPage = toPage(paging.previous)
|
|
53
54
|
|
|
54
|
-
return { data: channelUsers, nextPage, prevPage }
|
|
55
|
+
return { data: channelUsers, cachedAt, nextPage, prevPage }
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ASCError } from '~/core/errors'
|
|
2
|
+
|
|
3
|
+
let activeUser: Pick<Amity.User, '_id' | 'userId' | 'path'> | null = null
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* for internal use
|
|
7
|
+
*/
|
|
8
|
+
export const getActiveUser = () => {
|
|
9
|
+
if (!activeUser) {
|
|
10
|
+
throw new ASCError(
|
|
11
|
+
'Connect client first',
|
|
12
|
+
Amity.ClientError.UNKNOWN_ERROR,
|
|
13
|
+
Amity.ErrorLevel.FATAL,
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return activeUser!
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const setActiveUser = (user: Amity.User) => {
|
|
21
|
+
activeUser = {
|
|
22
|
+
_id: user._id,
|
|
23
|
+
userId: user.userId,
|
|
24
|
+
path: user.path,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -3,6 +3,7 @@ import { getDeviceId } from '~/core/device'
|
|
|
3
3
|
import { proxyMqttEvents, proxyWebsocketEvents } from '~/core/events'
|
|
4
4
|
|
|
5
5
|
import { getActiveClient } from './activeClient'
|
|
6
|
+
import { setActiveUser } from './activeUser'
|
|
6
7
|
|
|
7
8
|
import { getToken } from './getToken'
|
|
8
9
|
import { onClientBanned } from '../events'
|
|
@@ -66,8 +67,9 @@ export const connectClient = async (params: {
|
|
|
66
67
|
})
|
|
67
68
|
|
|
68
69
|
client.userId = params.userId
|
|
69
|
-
client._internalUserId = users[0]._id
|
|
70
70
|
client.accessToken = accessToken
|
|
71
71
|
|
|
72
|
+
setActiveUser(users[0])
|
|
73
|
+
|
|
72
74
|
return client.ws.connected
|
|
73
75
|
}
|
|
@@ -2,7 +2,7 @@ import { VERSION } from '~/version'
|
|
|
2
2
|
|
|
3
3
|
import { createLogger } from '~/core/debug'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { API_REGIONS, computeUrl } from '~/client/utils/endpoints'
|
|
6
6
|
import { createHttpTransport, createMqttTransport, createWebsocketTransport } from '~/core/transports'
|
|
7
7
|
|
|
8
8
|
import { createEventEmitter } from '~/core/events'
|
|
@@ -18,7 +18,7 @@ import { getActiveClient, setActiveClient } from './activeClient'
|
|
|
18
18
|
* Creates a new {@link Amity.Client} instance
|
|
19
19
|
*
|
|
20
20
|
* @param apiKey for the {@link Amity.Client} instance
|
|
21
|
-
* @param
|
|
21
|
+
* @param apiRegion endpoint to connect to
|
|
22
22
|
* @param debugSession session's identifier for the client's logger instance
|
|
23
23
|
* @returns A {@link Amity.Client} instance
|
|
24
24
|
*
|
|
@@ -26,19 +26,19 @@ import { getActiveClient, setActiveClient } from './activeClient'
|
|
|
26
26
|
**/
|
|
27
27
|
export const createClient = (
|
|
28
28
|
apiKey: string,
|
|
29
|
-
|
|
29
|
+
apiRegion: typeof API_REGIONS[keyof typeof API_REGIONS] = API_REGIONS.SG,
|
|
30
30
|
debugSession: string = 'amity'
|
|
31
31
|
): Amity.Client => {
|
|
32
32
|
const log = createLogger(debugSession)
|
|
33
33
|
|
|
34
34
|
log('client/api/createClient', {
|
|
35
35
|
apiKey: apiKey.replace(/.{5}$/g, 'xxxxx'),
|
|
36
|
-
|
|
36
|
+
apiRegion,
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
const http = createHttpTransport(
|
|
40
|
-
const ws = createWebsocketTransport(
|
|
41
|
-
const mqtt = createMqttTransport(
|
|
39
|
+
const http = createHttpTransport(computeUrl('http', apiRegion))
|
|
40
|
+
const ws = createWebsocketTransport(computeUrl('http', apiRegion))
|
|
41
|
+
const mqtt = createMqttTransport(computeUrl('mqtt', apiRegion));
|
|
42
42
|
|
|
43
43
|
const emitter = createEventEmitter()
|
|
44
44
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const API_REGIONS = {
|
|
2
|
+
EU: 'eu',
|
|
3
|
+
SG: 'sg',
|
|
4
|
+
US: 'us',
|
|
5
|
+
} as const
|
|
6
|
+
|
|
7
|
+
const URLS = {
|
|
8
|
+
http: 'https://api.{region}.amity.co',
|
|
9
|
+
mqtt: 'wss://sse.{region}.amity.co:443/mqtt',
|
|
10
|
+
} as const
|
|
11
|
+
|
|
12
|
+
export function computeUrl(type: keyof typeof URLS, region: string) {
|
|
13
|
+
return URLS[type].replace('{region}', region)
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
10
|
+
* const communities = await getRecommendedCommunities()
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Gets a list of recommended {@link Amity.Community} objects
|
|
14
|
+
*
|
|
15
|
+
* @param query The query parameters
|
|
16
|
+
* @returns A list of {@link Amity.Community} objects
|
|
17
|
+
*
|
|
18
|
+
* @category Community API
|
|
19
|
+
* @async
|
|
20
|
+
*/
|
|
21
|
+
export const getRecommendedCommunities = async (
|
|
22
|
+
query?: Partial<Amity.PageLimit>
|
|
23
|
+
): Promise<Amity.Cached<Amity.Community[]>> => {
|
|
24
|
+
const client = getActiveClient()
|
|
25
|
+
client.log('channel/getRecommendedCommunities', query)
|
|
26
|
+
|
|
27
|
+
const { limit = 5 } = query ?? {}
|
|
28
|
+
|
|
29
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
30
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
31
|
+
const { data } = await client.http.get<Amity.CommunityPayload>(
|
|
32
|
+
`/api/v3/communities/recommended`, { params: { options: { limit }}}
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const { communities } = data
|
|
36
|
+
|
|
37
|
+
const cachedAt = client.cache && Date.now()
|
|
38
|
+
|
|
39
|
+
if (client.cache) {
|
|
40
|
+
ingestInCache(data, { cachedAt })
|
|
41
|
+
|
|
42
|
+
const cacheKey = ['community', 'recommended', { params: { options: { limit }} }]
|
|
43
|
+
pushToCache(cacheKey, { communities: communities.map(getResolver('community')) })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { data: communities, cachedAt }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* ```js
|
|
51
|
+
* import { getRecommendedCommunities } from '@amityco/ts-sdk'
|
|
52
|
+
* const communities = getRecommendedCommunities.locally()
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Gets a list of recommended {@link Amity.Community} objects from cache
|
|
56
|
+
*
|
|
57
|
+
* @param query The query parameters
|
|
58
|
+
* @returns communities
|
|
59
|
+
*
|
|
60
|
+
* @category Community API
|
|
61
|
+
*/
|
|
62
|
+
getRecommendedCommunities.locally = (
|
|
63
|
+
query: Parameters<typeof getRecommendedCommunities>[0],
|
|
64
|
+
): Amity.Cached<Amity.Community[]> | undefined => {
|
|
65
|
+
const client = getActiveClient()
|
|
66
|
+
client.log('community/getRecommendedCommunities.locally', query)
|
|
67
|
+
|
|
68
|
+
if (!client.cache) return
|
|
69
|
+
|
|
70
|
+
const { limit = 5 } = query ?? {}
|
|
71
|
+
|
|
72
|
+
const queryKey = ['community', 'recommended', { params: { options: { limit }} }];
|
|
73
|
+
const { data, cachedAt } = pullFromCache<{communities: Pick<Amity.Community, 'communityId'>[]}>(queryKey) ?? {}
|
|
74
|
+
|
|
75
|
+
if (!data?.communities.length)
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
const communities: Amity.Community[] = data.communities
|
|
79
|
+
.map(communityId => pullFromCache<Amity.Community>(['community', 'get', communityId])!)
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.map(({ data }) => data)
|
|
82
|
+
|
|
83
|
+
return communities.length === data?.communities?.length
|
|
84
|
+
? { data: communities, cachedAt }
|
|
85
|
+
: undefined
|
|
86
|
+
}
|