@amityco/ts-sdk 7.3.1-e2dead4.0 → 7.4.1-97f8f862.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.
@@ -11,5 +11,5 @@
11
11
  * @category Message API
12
12
  * @async
13
13
  * */
14
- export declare const flagMessage: (messageId: Amity.Message['messageId'], reason: Amity.ContentFlagReason) => Promise<boolean>;
14
+ export declare const flagMessage: (messageId: Amity.Message['messageId'], reason?: Amity.ContentFlagReason) => Promise<boolean>;
15
15
  //# sourceMappingURL=flagMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flagMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/api/flagMessage.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,WAAW,cACX,MAAM,OAAO,CAAC,WAAW,CAAC,UAC7B,MAAM,iBAAiB,KAC9B,QAAQ,OAAO,CA0BjB,CAAC"}
1
+ {"version":3,"file":"flagMessage.d.ts","sourceRoot":"","sources":["../../../src/messageRepository/api/flagMessage.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,WAAW,cACX,MAAM,OAAO,CAAC,WAAW,CAAC,WAC5B,MAAM,iBAAiB,KAC/B,QAAQ,OAAO,CA4BjB,CAAC"}
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * ```js
3
3
  * import { PostRepository } from '@amityco/ts-sdk'
4
- * const flagged = await PostRepository.flagPost(postId)
4
+ * const flagged = await PostRepository.flagPost(postId, reason)
5
5
  * ```
6
6
  *
7
7
  * @param postId of the post to flag
8
+ * @param reason the reason to flag the post
8
9
  * @returns a boolean
9
10
  *
10
11
  * @category Post API
11
12
  * @async
12
13
  * */
13
- export declare const flagPost: (postId: Amity.Post['postId']) => Promise<boolean>;
14
+ export declare const flagPost: (postId: Amity.Post['postId'], reason?: Amity.ContentFlagReason) => Promise<boolean>;
14
15
  //# sourceMappingURL=flagPost.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flagPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/flagPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,QAAQ,WAAkB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAG,QAAQ,OAAO,CAe5E,CAAC"}
1
+ {"version":3,"file":"flagPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/flagPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,QAAQ,WACX,MAAM,IAAI,CAAC,QAAQ,CAAC,WACnB,MAAM,iBAAiB,KAC/B,QAAQ,OAAO,CA2BjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.3.1-e2dead4.0",
3
+ "version": "7.4.1-97f8f862.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -1,7 +1,8 @@
1
1
  import { getActiveClient } from '~/client/api/activeClient';
2
-
3
2
  import { ingestInCache } from '~/cache/api/ingestInCache';
4
3
  import { fireEvent } from '~/core/events';
4
+ import { prepareMembershipPayload } from '~/group/utils';
5
+ import { ContentFlagReasonEnum } from '~/@types';
5
6
 
6
7
  /* begin_public_function
7
8
  id: comment.flag
@@ -9,21 +10,37 @@ import { fireEvent } from '~/core/events';
9
10
  /**
10
11
  * ```js
11
12
  * import { CommentRepository } from '@amityco/ts-sdk'
12
- * const flagged = await CommentRepository.flagComment('commentId')
13
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
13
14
  * ```
14
15
  *
15
16
  * @param commentId The ID of the comment to flag
17
+ * @param reason the reason to flag the comment
16
18
  * @returns the created report result
17
19
  *
18
20
  * @category Comment API
19
21
  * @async
20
22
  * */
21
- export const flagComment = async (commentId: Amity.Comment['commentId']): Promise<boolean> => {
23
+ export const flagComment = async (
24
+ commentId: Amity.Comment['commentId'],
25
+ reason?: Amity.ContentFlagReason,
26
+ ): Promise<boolean> => {
22
27
  const client = getActiveClient();
23
28
  client.log('comment/flagComment', commentId);
24
29
 
30
+ const isPredefinedReason =
31
+ reason &&
32
+ Object.entries(ContentFlagReasonEnum).some(
33
+ ([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
34
+ );
35
+
36
+ const body = {
37
+ reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
38
+ detail: reason && !isPredefinedReason ? reason : '',
39
+ };
40
+
25
41
  const { data: payload } = await client.http.post<Amity.CommentPayload>(
26
42
  `/api/v3/comments/${encodeURIComponent(commentId)}/flag`,
43
+ body,
27
44
  );
28
45
 
29
46
  if (client.cache) {
@@ -22,18 +22,20 @@ import { prepareMessagePayload } from '~/messageRepository/utils';
22
22
  * */
23
23
  export const flagMessage = async (
24
24
  messageId: Amity.Message['messageId'],
25
- reason: Amity.ContentFlagReason,
25
+ reason?: Amity.ContentFlagReason,
26
26
  ): Promise<boolean> => {
27
27
  const client = getActiveClient();
28
28
  client.log('message/flag', messageId);
29
29
 
30
- const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(
31
- ([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
32
- );
30
+ const isPredefinedReason =
31
+ reason &&
32
+ Object.entries(ContentFlagReasonEnum).some(
33
+ ([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
34
+ );
33
35
 
34
36
  const body = {
35
37
  reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
36
- detail: isPredefinedReason ? '' : reason,
38
+ detail: !isPredefinedReason ? reason : '',
37
39
  };
38
40
 
39
41
  const { data: payload } = await client.http.post<Amity.MessagePayload>(
@@ -1,8 +1,8 @@
1
1
  import { getActiveClient } from '~/client/api/activeClient';
2
-
3
2
  import { ingestInCache } from '~/cache/api/ingestInCache';
4
3
  import { fireEvent } from '~/core/events';
5
4
  import { prepareMembershipPayload } from '~/group/utils';
5
+ import { ContentFlagReasonEnum } from '~/@types';
6
6
 
7
7
  /* begin_public_function
8
8
  id: post.flag
@@ -10,21 +10,37 @@ import { prepareMembershipPayload } from '~/group/utils';
10
10
  /**
11
11
  * ```js
12
12
  * import { PostRepository } from '@amityco/ts-sdk'
13
- * const flagged = await PostRepository.flagPost(postId)
13
+ * const flagged = await PostRepository.flagPost(postId, reason)
14
14
  * ```
15
15
  *
16
16
  * @param postId of the post to flag
17
+ * @param reason the reason to flag the post
17
18
  * @returns a boolean
18
19
  *
19
20
  * @category Post API
20
21
  * @async
21
22
  * */
22
- export const flagPost = async (postId: Amity.Post['postId']): Promise<boolean> => {
23
+ export const flagPost = async (
24
+ postId: Amity.Post['postId'],
25
+ reason?: Amity.ContentFlagReason,
26
+ ): Promise<boolean> => {
23
27
  const client = getActiveClient();
24
28
  client.log('post/flagPost', postId);
25
29
 
30
+ const isPredefinedReason =
31
+ reason &&
32
+ Object.entries(ContentFlagReasonEnum).some(
33
+ ([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
34
+ );
35
+
36
+ const body = {
37
+ reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
38
+ detail: reason && !isPredefinedReason ? reason : '',
39
+ };
40
+
26
41
  const { data: payload } = await client.http.post<Amity.PostPayload>(
27
42
  `/api/v3/posts/${encodeURIComponent(postId)}/flag`,
43
+ body,
28
44
  );
29
45
 
30
46
  if (client.cache) {