@amityco/ts-sdk 0.0.1-beta.12 → 0.0.1-beta.13
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/domains/client.d.ts +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +2 -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/partials.d.ts +10 -0
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +3 -2
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/updateComment.d.ts +1 -1
- package/dist/comment/api/updateComment.d.ts.map +1 -1
- package/dist/index.cjs.js +11 -11
- package/dist/index.esm.js +11 -11
- package/dist/index.umd.js +3 -3
- package/dist/post/api/createPost.d.ts +7 -3
- package/dist/post/api/createPost.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/package.json +1 -1
- package/rollup.config.js +3 -0
- package/src/@types/domains/client.ts +1 -1
- package/src/@types/domains/comment.ts +3 -0
- package/src/@types/domains/file.ts +2 -1
- package/src/@types/domains/partials.ts +8 -0
- package/src/@types/domains/post.ts +4 -1
- package/src/client/api/connectClient.ts +1 -1
- package/src/client/api/disconnectClient.ts +0 -1
- package/src/comment/api/createComment.ts +1 -2
- package/src/comment/api/updateComment.ts +1 -1
- package/src/core/debug.ts +1 -1
- package/src/core/subscription.ts +4 -4
- package/src/post/api/createPost.ts +6 -4
- package/src/post/api/updatePost.ts +2 -2
|
@@ -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"}
|
|
@@ -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"}
|
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(),
|
|
@@ -5,6 +5,8 @@ declare global {
|
|
|
5
5
|
type CommentContentType = ('text')
|
|
6
6
|
type CommentReferenceType = ('content' | 'post')
|
|
7
7
|
|
|
8
|
+
type CommentMentionType = keyof MentionTypes
|
|
9
|
+
|
|
8
10
|
type Comment<T extends CommentContentType = any> = {
|
|
9
11
|
commentId: string
|
|
10
12
|
userId: string
|
|
@@ -22,5 +24,6 @@ declare global {
|
|
|
22
24
|
& Amity.Timestamps
|
|
23
25
|
& Amity.SoftDelete
|
|
24
26
|
& Amity.Subscribable
|
|
27
|
+
& Amity.Mentionable<CommentMentionType>
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -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
|
|
|
@@ -52,5 +52,13 @@ 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
|
+
}
|
|
55
63
|
}
|
|
56
64
|
}
|
|
@@ -5,7 +5,9 @@ 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
|
+
|
|
10
|
+
type PostMentionType = keyof MentionTypes
|
|
9
11
|
|
|
10
12
|
type Post<T extends PostContentType = any> = {
|
|
11
13
|
postId: string
|
|
@@ -28,5 +30,6 @@ declare global {
|
|
|
28
30
|
& Amity.Timestamps
|
|
29
31
|
& Amity.SoftDelete
|
|
30
32
|
& Amity.Subscribable
|
|
33
|
+
& Amity.Mentionable<PostMentionType>
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -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)
|
package/src/core/debug.ts
CHANGED
|
@@ -12,7 +12,7 @@ import debug from 'debug'
|
|
|
12
12
|
export const createLogger = (session?: string) => {
|
|
13
13
|
const active = (
|
|
14
14
|
`${session?.trim()}`.length > 0
|
|
15
|
-
&& process
|
|
15
|
+
&& process?.env?.NODE_ENV !== 'production'
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
const logger = debug(session!)
|
package/src/core/subscription.ts
CHANGED
|
@@ -61,13 +61,13 @@ export function subscribeTopic(
|
|
|
61
61
|
topic: string,
|
|
62
62
|
callback?: Amity.Listener<ASCError | void>
|
|
63
63
|
): Amity.Unsubscriber {
|
|
64
|
-
const { mqtt, emitter, accessToken,
|
|
64
|
+
const { mqtt, emitter, accessToken, _internalUserId } = getActiveClient()
|
|
65
65
|
|
|
66
|
-
if (mqttAccessToken !== accessToken || mqttUserId !==
|
|
66
|
+
if (mqttAccessToken !== accessToken || mqttUserId !== _internalUserId) {
|
|
67
67
|
mqttAccessToken = accessToken!
|
|
68
|
-
mqttUserId =
|
|
68
|
+
mqttUserId = _internalUserId!
|
|
69
69
|
|
|
70
|
-
mqtt.connect({ accessToken:
|
|
70
|
+
mqtt.connect({ accessToken: mqttAccessToken, userId: mqttUserId })
|
|
71
71
|
proxyMqttEvents(mqtt, emitter)
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -22,19 +22,21 @@ import { fireEvent } from '~/core/events'
|
|
|
22
22
|
* @async
|
|
23
23
|
*/
|
|
24
24
|
export const createPost = async <T extends Amity.PostContentType | string>(
|
|
25
|
-
bundle: Pick<Amity.Post, 'targetType' | 'targetId' | 'metadata'> & {
|
|
26
|
-
dataType?: T,
|
|
25
|
+
bundle: Pick<Amity.Post, 'targetType' | 'targetId' | 'metadata' | 'mentionees'> & {
|
|
26
|
+
dataType?: T,
|
|
27
|
+
data?: { [k: string]: any },
|
|
28
|
+
attachments?: { type: T, fileId: Amity.File['fileId'] }[]
|
|
27
29
|
},
|
|
28
30
|
): Promise<Amity.Cached<Amity.Post>> => {
|
|
29
31
|
const client = getActiveClient()
|
|
30
32
|
client.log('post/createPost', bundle)
|
|
31
33
|
|
|
32
34
|
// API-FIX: backend rejects that we pass the dataType manually T_T
|
|
33
|
-
if (!bundle.dataType || ['text', 'image', 'file'].includes(bundle.dataType))
|
|
35
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType))
|
|
34
36
|
delete bundle.dataType
|
|
35
37
|
|
|
36
38
|
const { data } = await client.http.post<Amity.PostPayload>(
|
|
37
|
-
'/api/
|
|
39
|
+
'/api/v4/posts', bundle
|
|
38
40
|
)
|
|
39
41
|
|
|
40
42
|
const cachedAt = client.cache && Date.now()
|
|
@@ -22,13 +22,13 @@ import { fireEvent } from '~/core/events'
|
|
|
22
22
|
*/
|
|
23
23
|
export const updatePost = async (
|
|
24
24
|
postId: Amity.Post['postId'],
|
|
25
|
-
patch: Patch<Amity.Post, 'data' | 'metadata'>,
|
|
25
|
+
patch: Patch<Amity.Post, 'data' | 'metadata' | 'mentionees'>,
|
|
26
26
|
): Promise<Amity.Cached<Amity.Post>> => {
|
|
27
27
|
const client = getActiveClient()
|
|
28
28
|
client.log('user/updatePost', patch)
|
|
29
29
|
|
|
30
30
|
const { data } = await client.http.put<Amity.PostPayload>(
|
|
31
|
-
`/api/
|
|
31
|
+
`/api/v4/posts/${encodeURIComponent(postId)}`, patch,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
const cachedAt = client.cache && Date.now()
|