@amityco/ts-sdk 0.0.1-beta.12 → 0.0.1-beta.15
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 +2 -2
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/paging.d.ts +19 -38
- package/dist/@types/core/paging.d.ts.map +1 -1
- package/dist/@types/core/query.d.ts +12 -4
- package/dist/@types/core/query.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +1 -1
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +2 -2
- package/dist/@types/domains/file.d.ts.map +1 -1
- 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/post.d.ts +2 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts +3 -3
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts +1 -1
- package/dist/client/api/createClient.d.ts +3 -3
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.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/comment/api/createComment.d.ts +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/updateComment.d.ts +1 -1
- package/dist/comment/api/updateComment.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts +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.map +1 -1
- package/dist/core/microtasks.d.ts +13 -0
- package/dist/core/microtasks.d.ts.map +1 -0
- package/dist/core/query/paging.d.ts +2 -13
- 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/feed/api/queryGlobalFeed.d.ts +22 -4
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/index.cjs.js +101 -74
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +101 -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/createPost.d.ts +7 -3
- package/dist/post/api/createPost.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/post/api/updatePost.d.ts +1 -1
- package/dist/post/api/updatePost.d.ts.map +1 -1
- package/dist/role/api/queryRoles.d.ts +1 -1
- package/dist/stream/api/queryStreams.d.ts +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/rollup.config.js +3 -0
- package/src/@types/core/cache.ts +2 -2
- package/src/@types/core/events.ts +1 -1
- package/src/@types/core/paging.ts +29 -44
- package/src/@types/core/query.ts +7 -3
- package/src/@types/domains/client.ts +1 -1
- package/src/@types/domains/comment.ts +1 -0
- package/src/@types/domains/file.ts +2 -1
- package/src/@types/domains/mention.ts +26 -0
- package/src/@types/domains/message.ts +1 -0
- package/src/@types/domains/post.ts +2 -1
- package/src/@types/index.ts +2 -0
- package/src/channel/api/queryChannelMembers.ts +2 -1
- package/src/client/api/connectClient.ts +1 -1
- package/src/client/api/createClient.ts +7 -7
- package/src/client/api/disconnectClient.ts +0 -1
- package/src/client/utils/endpoints.ts +14 -0
- package/src/comment/api/createComment.ts +1 -2
- package/src/comment/api/updateComment.ts +1 -1
- 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/query/paging.ts +6 -41
- package/src/core/query/query.ts +5 -5
- package/src/core/subscription.ts +4 -4
- package/src/feed/api/queryGlobalFeed.ts +58 -5
- package/src/index.ts +1 -0
- package/src/message/api/createMessage.ts +2 -2
- package/src/message/api/updateMessage.ts +2 -2
- package/src/post/api/createPost.ts +6 -4
- package/src/post/api/queryPosts.ts +5 -5
- package/src/post/api/updatePost.ts +2 -2
- 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"}
|
|
@@ -16,10 +16,14 @@
|
|
|
16
16
|
* @category Post API
|
|
17
17
|
* @async
|
|
18
18
|
*/
|
|
19
|
-
export declare const createPost: <T extends string>(bundle: Pick<Amity.Post<any>, "targetType" | "targetId" | "metadata"> & {
|
|
19
|
+
export declare const createPost: <T extends string>(bundle: Pick<Amity.Post<any>, "targetType" | "targetId" | "metadata" | "mentionees"> & {
|
|
20
20
|
dataType?: T | undefined;
|
|
21
|
-
data
|
|
21
|
+
data?: {
|
|
22
22
|
[k: string]: any;
|
|
23
|
-
};
|
|
23
|
+
} | undefined;
|
|
24
|
+
attachments?: {
|
|
25
|
+
type: T;
|
|
26
|
+
fileId: Amity.File['fileId'];
|
|
27
|
+
}[] | undefined;
|
|
24
28
|
}) => Promise<Amity.Cached<Amity.Post>>;
|
|
25
29
|
//# sourceMappingURL=createPost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPost.d.ts","sourceRoot":"","sources":["../../../src/post/api/createPost.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU
|
|
1
|
+
{"version":3,"file":"createPost.d.ts","sourceRoot":"","sources":["../../../src/post/api/createPost.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU;;;;;;;gBAIc,UAAU,CAAC,QAAQ,CAAC;;MAEtD,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAuBlC,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>>>;
|
|
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>> | 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,CAAC,CAAC,CAAC;IAuCjD;;;;;;;;;;;;OAYG;mBAEM,WAAW,iBAAiB,CAAC,CAAC,CAAC,CAAC,GACtC,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS;CAjBnD,CAAA"}
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* @category Post API
|
|
16
16
|
* @async
|
|
17
17
|
*/
|
|
18
|
-
export declare const updatePost: (postId: Amity.Post['postId'], patch: Patch<Amity.Post, 'data' | 'metadata'>) => Promise<Amity.Cached<Amity.Post>>;
|
|
18
|
+
export declare const updatePost: (postId: Amity.Post['postId'], patch: Patch<Amity.Post, 'data' | 'metadata' | 'mentionees'>) => Promise<Amity.Cached<Amity.Post>>;
|
|
19
19
|
//# sourceMappingURL=updatePost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updatePost.d.ts","sourceRoot":"","sources":["../../../src/post/api/updatePost.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,IAAI,CAAC,QAAQ,CAAC,SACrB,MAAM,MAAM,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"updatePost.d.ts","sourceRoot":"","sources":["../../../src/post/api/updatePost.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,IAAI,CAAC,QAAQ,CAAC,SACrB,MAAM,MAAM,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC,KAC3D,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAoBlC,CAAA"}
|
|
@@ -17,7 +17,7 @@ export declare const queryRoles: {
|
|
|
17
17
|
(query?: {
|
|
18
18
|
displayName?: string | undefined;
|
|
19
19
|
sortBy?: "displayName" | "firstCreated" | "lastCreated" | undefined;
|
|
20
|
-
page?: Amity.Page | undefined;
|
|
20
|
+
page?: Amity.Page<number> | undefined;
|
|
21
21
|
} | undefined): Promise<Amity.Cached<Amity.Paged<Amity.Role>>>;
|
|
22
22
|
/**
|
|
23
23
|
* ```js
|
|
@@ -19,7 +19,7 @@ export declare const queryStreams: {
|
|
|
19
19
|
userPublicIds?: string[] | undefined;
|
|
20
20
|
sortBy?: "lastCreated" | "firstCreated" | undefined;
|
|
21
21
|
isDeleted?: Amity.Stream['isDeleted'];
|
|
22
|
-
page?: Amity.Page | undefined;
|
|
22
|
+
page?: Amity.Page<number> | undefined;
|
|
23
23
|
} | undefined): Promise<Amity.Cached<Amity.Paged<Amity.Stream>>>;
|
|
24
24
|
/**
|
|
25
25
|
* ```js
|
|
@@ -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/rollup.config.js
CHANGED
|
@@ -43,6 +43,7 @@ export default [
|
|
|
43
43
|
plugins: [
|
|
44
44
|
...config.plugins,
|
|
45
45
|
replace({
|
|
46
|
+
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
|
|
46
47
|
'process.env.VERSION': `'v${pkg.version}-esm'`,
|
|
47
48
|
}),
|
|
48
49
|
],
|
|
@@ -59,6 +60,7 @@ export default [
|
|
|
59
60
|
plugins: [
|
|
60
61
|
...config.plugins,
|
|
61
62
|
replace({
|
|
63
|
+
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
|
|
62
64
|
'process.env.VERSION': `'v${pkg.version}-cjs'`,
|
|
63
65
|
}),
|
|
64
66
|
],
|
|
@@ -73,6 +75,7 @@ export default [
|
|
|
73
75
|
plugins: [
|
|
74
76
|
...config.plugins,
|
|
75
77
|
replace({
|
|
78
|
+
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
|
|
76
79
|
'process.env.VERSION': `'v${pkg.version}-umd'`,
|
|
77
80
|
}),
|
|
78
81
|
terser(),
|
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>
|
|
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>
|
|
@@ -2,6 +2,32 @@ export {}
|
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Amity {
|
|
5
|
+
type PaginationStyles = 'skiplimit' | 'afterbefore' | 'afterbeforeraw'
|
|
6
|
+
|
|
7
|
+
type Paging = {
|
|
8
|
+
limit: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type PrevPage<T extends number | string = number> = Paging & {
|
|
12
|
+
after?: never
|
|
13
|
+
before?: T
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type NextPage<T extends number | string = number> = Paging & {
|
|
17
|
+
after?: T
|
|
18
|
+
before?: never
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Page<T extends number | string = number> = (PrevPage<T> | NextPage<T>)
|
|
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 = Page<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)
|
|
51
|
+
type AfterBeforeRawPagination = PageRaw
|
|
38
52
|
|
|
39
53
|
type Pages = {
|
|
40
|
-
nextPage?: Page | null
|
|
41
|
-
prevPage?: Page | null
|
|
54
|
+
nextPage?: (Page | PageRaw) | null
|
|
55
|
+
prevPage?: (Page | PageRaw) | null
|
|
42
56
|
}
|
|
43
57
|
|
|
44
58
|
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)
|
|
67
|
-
|
|
68
|
-
type PagesRaw = {
|
|
69
|
-
nextPage?: PageRaw | null
|
|
70
|
-
prevPage?: PageRaw | null
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
type PagedRaw<T> = { data: T[] } & PagesRaw
|
|
74
59
|
}
|
|
75
60
|
}
|
package/src/@types/core/query.ts
CHANGED
|
@@ -46,9 +46,13 @@ 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>
|
|
51
|
+
? { data: T3[] | undefined } & Pages & { cachedAt?: CacheOptions['cachedAt'] }
|
|
52
|
+
: { data: T2 } & { cachedAt?: CacheOptions['cachedAt'] }
|
|
53
|
+
: T extends Amity.Paged<infer T3>
|
|
54
|
+
? { data: T3[] | undefined } & Pages
|
|
55
|
+
: { data: T | undefined }
|
|
52
56
|
) & SnapshotOptions
|
|
53
57
|
}
|
|
54
58
|
}
|
|
@@ -2,7 +2,7 @@ export {}
|
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
4
|
namespace Amity {
|
|
5
|
-
type FileType = 'file' | 'image'
|
|
5
|
+
type FileType = 'file' | 'image' | 'video'
|
|
6
6
|
|
|
7
7
|
type FileMetadata = {}
|
|
8
8
|
|
|
@@ -19,6 +19,7 @@ declare global {
|
|
|
19
19
|
type MetadataFor<T extends FileType> = (
|
|
20
20
|
T extends 'file' ? FileMetadata :
|
|
21
21
|
T extends 'image' ? ImageMetadata :
|
|
22
|
+
T extends 'video' ? VideoMetadata :
|
|
22
23
|
never
|
|
23
24
|
)
|
|
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
|
+
}
|
|
@@ -5,7 +5,7 @@ declare global {
|
|
|
5
5
|
// bad hack until we get proper feed objects in backend
|
|
6
6
|
type PostTargetType = Amity.FeedType | 'content'
|
|
7
7
|
|
|
8
|
-
type PostContentType = ('text' | 'image' | 'file')
|
|
8
|
+
type PostContentType = ('text' | 'image' | 'file' | 'video')
|
|
9
9
|
|
|
10
10
|
type Post<T extends PostContentType = any> = {
|
|
11
11
|
postId: string
|
|
@@ -28,5 +28,6 @@ declare global {
|
|
|
28
28
|
& Amity.Timestamps
|
|
29
29
|
& Amity.SoftDelete
|
|
30
30
|
& Amity.Subscribable
|
|
31
|
+
& Amity.Mentionable<'user'>
|
|
31
32
|
}
|
|
32
33
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -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
|
/**
|
|
@@ -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
|
+
}
|
|
@@ -20,7 +20,7 @@ import { getPost } from '~/post/api/getPost'
|
|
|
20
20
|
* @async
|
|
21
21
|
*/
|
|
22
22
|
export const createComment = async <T extends Amity.CommentContentType>(
|
|
23
|
-
bundle: Pick<Amity.Comment<T>, 'referenceType' | 'referenceId' | 'parentId' | 'data' | 'metadata'>,
|
|
23
|
+
bundle: Pick<Amity.Comment<T>, 'referenceType' | 'referenceId' | 'parentId' | 'data' | 'metadata' | 'mentionees'>,
|
|
24
24
|
): Promise<Amity.Cached<Amity.Comment>> => {
|
|
25
25
|
const client = getActiveClient()
|
|
26
26
|
client.log('comment/createComment', bundle)
|
|
@@ -29,7 +29,6 @@ export const createComment = async <T extends Amity.CommentContentType>(
|
|
|
29
29
|
'/api/v3/comments', bundle,
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
const cachedAt = client.cache && Date.now()
|
|
34
33
|
if (client.cache) ingestInCache(data, { cachedAt })
|
|
35
34
|
|
|
@@ -22,7 +22,7 @@ import { fireEvent } from '~/core/events'
|
|
|
22
22
|
*/
|
|
23
23
|
export const updateComment = async (
|
|
24
24
|
commentId: Amity.Comment['commentId'],
|
|
25
|
-
patch: Patch<Amity.Comment, 'data' | 'metadata'>,
|
|
25
|
+
patch: Patch<Amity.Comment, 'data' | 'metadata' | 'mentionees'>,
|
|
26
26
|
): Promise<Amity.Cached<Amity.Comment>> => {
|
|
27
27
|
const client = getActiveClient()
|
|
28
28
|
client.log('user/updateComment', patch)
|
|
@@ -51,7 +51,7 @@ export const queryCommunityMembers = async (query: {
|
|
|
51
51
|
const nextPage = toPage(paging.next)
|
|
52
52
|
const prevPage = toPage(paging.previous)
|
|
53
53
|
|
|
54
|
-
return { data: communityUsers, nextPage, prevPage }
|
|
54
|
+
return { data: communityUsers, cachedAt, nextPage, prevPage }
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
package/src/core/debug.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import debug from 'debug'
|
|
2
2
|
|
|
3
|
+
import { isProduction } from '~/utils/env'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Creates a pre-configured logger instance
|
|
5
7
|
*
|
|
@@ -12,7 +14,7 @@ import debug from 'debug'
|
|
|
12
14
|
export const createLogger = (session?: string) => {
|
|
13
15
|
const active = (
|
|
14
16
|
`${session?.trim()}`.length > 0
|
|
15
|
-
&&
|
|
17
|
+
&& !isProduction
|
|
16
18
|
)
|
|
17
19
|
|
|
18
20
|
const logger = debug(session!)
|
package/src/core/device.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// TODO: find a way to uniquely identify the device
|
|
2
2
|
// import { getStorage } from './storage'
|
|
3
|
+
import { safeProcess } from '~/utils/env'
|
|
3
4
|
|
|
4
5
|
/** @hidden */
|
|
5
6
|
const VERSION = '11.0.0'
|
|
@@ -16,8 +17,8 @@ export const getDeviceId = () => {
|
|
|
16
17
|
|
|
17
18
|
/** @hidden */
|
|
18
19
|
export const getDeviceModel = () => {
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
20
|
+
if (safeProcess.versions?.node)
|
|
21
|
+
return safeProcess.versions.node
|
|
21
22
|
|
|
22
23
|
if (navigator)
|
|
23
24
|
return `${navigator.product.toLowerCase()}#${navigator.userAgent ?? 'unknown_agent'}`
|
package/src/core/events.ts
CHANGED
|
@@ -2,6 +2,8 @@ import mitt from 'mitt'
|
|
|
2
2
|
|
|
3
3
|
import { getActiveClient } from '~/client/api/activeClient'
|
|
4
4
|
|
|
5
|
+
import { scheduleTask } from './microtasks'
|
|
6
|
+
|
|
5
7
|
// need to sync up the list
|
|
6
8
|
const WS_EVENTS = [
|
|
7
9
|
'disconnected',
|
|
@@ -134,5 +136,5 @@ export const fireEvent = <T extends keyof Amity.Events>(
|
|
|
134
136
|
payload: Amity.Events[T],
|
|
135
137
|
) => {
|
|
136
138
|
const { emitter } = getActiveClient()
|
|
137
|
-
|
|
139
|
+
scheduleTask(() => { emitter.emit(event, payload) })
|
|
138
140
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
let tasks: Function[] = []
|
|
2
|
+
let timer: NodeJS.Timeout
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Add a function to run just before the next tick
|
|
6
|
+
*
|
|
7
|
+
* @param task function to schedule for later execution
|
|
8
|
+
*/
|
|
9
|
+
export const scheduleTask = (task: Function) => {
|
|
10
|
+
clearTimeout(timer)
|
|
11
|
+
tasks.push(task)
|
|
12
|
+
|
|
13
|
+
timer = setTimeout(() => {
|
|
14
|
+
tasks.forEach(fn => fn())
|
|
15
|
+
tasks = []
|
|
16
|
+
}, 0)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Cancel the scheduling operation
|
|
21
|
+
*
|
|
22
|
+
* @param task function to be removed from later execution
|
|
23
|
+
*/
|
|
24
|
+
export const cancelTask = (task: Function) => {
|
|
25
|
+
tasks = tasks.filter(fn => fn !== task)
|
|
26
|
+
if (!tasks.length) clearTimeout(timer)
|
|
27
|
+
}
|