@amityco/ts-sdk 7.3.1-e2dead4.0 → 7.4.1-9b7bc08.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.
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * ```js
3
3
  * import { MessageRepository } from '@amityco/ts-sdk'
4
- * const flagged = await MessageRepository.flagMessage(messageId, reason)
4
+ * const flagged = await MessageRepository.flagMessage(messageId)
5
5
  * ```
6
6
  *
7
7
  * @param messageId of the message to flag
8
- * @param reason the reason to flag the message
9
8
  * @returns the created report result
10
9
  *
11
10
  * @category Message API
12
11
  * @async
13
12
  * */
14
- export declare const flagMessage: (messageId: Amity.Message['messageId'], reason: Amity.ContentFlagReason) => Promise<boolean>;
13
+ export declare const flagMessage: (messageId: Amity.Message['messageId']) => Promise<boolean>;
15
14
  //# 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":"AAQA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,WAAW,cAAqB,MAAM,OAAO,CAAC,WAAW,CAAC,KAAG,QAAQ,OAAO,CAgBxF,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-9b7bc08.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) {
@@ -1,5 +1,4 @@
1
1
  import { fireEvent } from '~/core/events';
2
- import { ContentFlagReasonEnum } from '~/@types';
3
2
  import { ingestInCache } from '~/cache/api/ingestInCache';
4
3
  import { getActiveClient } from '~/client/api/activeClient';
5
4
  import { prepareMessagePayload } from '~/messageRepository/utils';
@@ -10,35 +9,21 @@ import { prepareMessagePayload } from '~/messageRepository/utils';
10
9
  /**
11
10
  * ```js
12
11
  * import { MessageRepository } from '@amityco/ts-sdk'
13
- * const flagged = await MessageRepository.flagMessage(messageId, reason)
12
+ * const flagged = await MessageRepository.flagMessage(messageId)
14
13
  * ```
15
14
  *
16
15
  * @param messageId of the message to flag
17
- * @param reason the reason to flag the message
18
16
  * @returns the created report result
19
17
  *
20
18
  * @category Message API
21
19
  * @async
22
20
  * */
23
- export const flagMessage = async (
24
- messageId: Amity.Message['messageId'],
25
- reason: Amity.ContentFlagReason,
26
- ): Promise<boolean> => {
21
+ export const flagMessage = async (messageId: Amity.Message['messageId']): Promise<boolean> => {
27
22
  const client = getActiveClient();
28
23
  client.log('message/flag', messageId);
29
24
 
30
- const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(
31
- ([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason,
32
- );
33
-
34
- const body = {
35
- reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
36
- detail: isPredefinedReason ? '' : reason,
37
- };
38
-
39
25
  const { data: payload } = await client.http.post<Amity.MessagePayload>(
40
26
  `/api/v5/messages/${encodeURIComponent(messageId)}/flags`,
41
- body,
42
27
  );
43
28
 
44
29
  if (client.cache) {
@@ -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) {