@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,14 +1,15 @@
1
1
  /**
2
2
  * ```js
3
3
  * import { CommentRepository } from '@amityco/ts-sdk'
4
- * const flagged = await CommentRepository.flagComment('commentId')
4
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
5
5
  * ```
6
6
  *
7
7
  * @param commentId The ID of the comment to flag
8
+ * @param reason the reason to flag the comment
8
9
  * @returns the created report result
9
10
  *
10
11
  * @category Comment API
11
12
  * @async
12
13
  * */
13
- export declare const flagComment: (commentId: Amity.Comment['commentId']) => Promise<boolean>;
14
+ export declare const flagComment: (commentId: Amity.Comment['commentId'], reason?: Amity.ContentFlagReason) => Promise<boolean>;
14
15
  //# sourceMappingURL=flagComment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"flagComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagComment.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;KAWK;AACL,eAAO,MAAM,WAAW,cAAqB,aAAa,CAAC,WAAW,CAAC,KAAG,QAAQ,OAAO,CAexF,CAAC"}
1
+ {"version":3,"file":"flagComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagComment.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,WAAW,cACX,aAAa,CAAC,WAAW,CAAC,WAC5B,MAAM,iBAAiB,KAC/B,QAAQ,OAAO,CA2BjB,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -114,8 +114,8 @@ const PostContentType = Object.freeze({
114
114
 
115
115
  function getVersion() {
116
116
  try {
117
- // the string ''v7.3.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
118
- return 'v7.3.0-cjs';
117
+ // the string ''v7.4.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
118
+ return 'v7.4.0-cjs';
119
119
  }
120
120
  catch (error) {
121
121
  return '__dev__';
@@ -15921,25 +15921,19 @@ getDeliveredUsers.locally = (query) => {
15921
15921
  /**
15922
15922
  * ```js
15923
15923
  * import { MessageRepository } from '@amityco/ts-sdk'
15924
- * const flagged = await MessageRepository.flagMessage(messageId, reason)
15924
+ * const flagged = await MessageRepository.flagMessage(messageId)
15925
15925
  * ```
15926
15926
  *
15927
15927
  * @param messageId of the message to flag
15928
- * @param reason the reason to flag the message
15929
15928
  * @returns the created report result
15930
15929
  *
15931
15930
  * @category Message API
15932
15931
  * @async
15933
15932
  * */
15934
- const flagMessage = async (messageId, reason) => {
15933
+ const flagMessage = async (messageId) => {
15935
15934
  const client = getActiveClient();
15936
15935
  client.log('message/flag', messageId);
15937
- const isPredefinedReason = Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
15938
- const body = {
15939
- reason: isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
15940
- detail: isPredefinedReason ? '' : reason,
15941
- };
15942
- const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
15936
+ const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
15943
15937
  if (client.cache) {
15944
15938
  const messagePayload = await prepareMessagePayload(payload);
15945
15939
  ingestInCache(messagePayload);
@@ -21672,19 +21666,26 @@ const declinePost = async (postId) => {
21672
21666
  /**
21673
21667
  * ```js
21674
21668
  * import { PostRepository } from '@amityco/ts-sdk'
21675
- * const flagged = await PostRepository.flagPost(postId)
21669
+ * const flagged = await PostRepository.flagPost(postId, reason)
21676
21670
  * ```
21677
21671
  *
21678
21672
  * @param postId of the post to flag
21673
+ * @param reason the reason to flag the post
21679
21674
  * @returns a boolean
21680
21675
  *
21681
21676
  * @category Post API
21682
21677
  * @async
21683
21678
  * */
21684
- const flagPost = async (postId) => {
21679
+ const flagPost = async (postId, reason) => {
21685
21680
  const client = getActiveClient();
21686
21681
  client.log('post/flagPost', postId);
21687
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
21682
+ const isPredefinedReason = reason &&
21683
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
21684
+ const body = {
21685
+ reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
21686
+ detail: reason && !isPredefinedReason ? reason : '',
21687
+ };
21688
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
21688
21689
  if (client.cache) {
21689
21690
  ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
21690
21691
  }
@@ -22147,19 +22148,26 @@ const hardDeleteComment = async (commentId) => {
22147
22148
  /**
22148
22149
  * ```js
22149
22150
  * import { CommentRepository } from '@amityco/ts-sdk'
22150
- * const flagged = await CommentRepository.flagComment('commentId')
22151
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
22151
22152
  * ```
22152
22153
  *
22153
22154
  * @param commentId The ID of the comment to flag
22155
+ * @param reason the reason to flag the comment
22154
22156
  * @returns the created report result
22155
22157
  *
22156
22158
  * @category Comment API
22157
22159
  * @async
22158
22160
  * */
22159
- const flagComment = async (commentId) => {
22161
+ const flagComment = async (commentId, reason) => {
22160
22162
  const client = getActiveClient();
22161
22163
  client.log('comment/flagComment', commentId);
22162
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`);
22164
+ const isPredefinedReason = reason &&
22165
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
22166
+ const body = {
22167
+ reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
22168
+ detail: reason && !isPredefinedReason ? reason : '',
22169
+ };
22170
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
22163
22171
  if (client.cache) {
22164
22172
  ingestInCache(payload);
22165
22173
  }
package/dist/index.esm.js CHANGED
@@ -99,8 +99,8 @@ const PostContentType = Object.freeze({
99
99
 
100
100
  function getVersion() {
101
101
  try {
102
- // the string ''v7.3.0-esm'' should be replaced by actual value by @rollup/plugin-replace
103
- return 'v7.3.0-esm';
102
+ // the string ''v7.4.0-esm'' should be replaced by actual value by @rollup/plugin-replace
103
+ return 'v7.4.0-esm';
104
104
  }
105
105
  catch (error) {
106
106
  return '__dev__';
@@ -32013,25 +32013,19 @@ getDeliveredUsers.locally = (query) => {
32013
32013
  /**
32014
32014
  * ```js
32015
32015
  * import { MessageRepository } from '@amityco/ts-sdk'
32016
- * const flagged = await MessageRepository.flagMessage(messageId, reason)
32016
+ * const flagged = await MessageRepository.flagMessage(messageId)
32017
32017
  * ```
32018
32018
  *
32019
32019
  * @param messageId of the message to flag
32020
- * @param reason the reason to flag the message
32021
32020
  * @returns the created report result
32022
32021
  *
32023
32022
  * @category Message API
32024
32023
  * @async
32025
32024
  * */
32026
- const flagMessage = async (messageId, reason) => {
32025
+ const flagMessage = async (messageId) => {
32027
32026
  const client = getActiveClient();
32028
32027
  client.log('message/flag', messageId);
32029
- const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
32030
- const body = {
32031
- reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
32032
- detail: isPredefinedReason ? '' : reason,
32033
- };
32034
- const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
32028
+ const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`);
32035
32029
  if (client.cache) {
32036
32030
  const messagePayload = await prepareMessagePayload(payload);
32037
32031
  ingestInCache(messagePayload);
@@ -37764,19 +37758,26 @@ const declinePost = async (postId) => {
37764
37758
  /**
37765
37759
  * ```js
37766
37760
  * import { PostRepository } from '@amityco/ts-sdk'
37767
- * const flagged = await PostRepository.flagPost(postId)
37761
+ * const flagged = await PostRepository.flagPost(postId, reason)
37768
37762
  * ```
37769
37763
  *
37770
37764
  * @param postId of the post to flag
37765
+ * @param reason the reason to flag the post
37771
37766
  * @returns a boolean
37772
37767
  *
37773
37768
  * @category Post API
37774
37769
  * @async
37775
37770
  * */
37776
- const flagPost = async (postId) => {
37771
+ const flagPost = async (postId, reason) => {
37777
37772
  const client = getActiveClient();
37778
37773
  client.log('post/flagPost', postId);
37779
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
37774
+ const isPredefinedReason = reason &&
37775
+ Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
37776
+ const body = {
37777
+ reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
37778
+ detail: reason && !isPredefinedReason ? reason : '',
37779
+ };
37780
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
37780
37781
  if (client.cache) {
37781
37782
  ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
37782
37783
  }
@@ -38239,19 +38240,26 @@ const hardDeleteComment = async (commentId) => {
38239
38240
  /**
38240
38241
  * ```js
38241
38242
  * import { CommentRepository } from '@amityco/ts-sdk'
38242
- * const flagged = await CommentRepository.flagComment('commentId')
38243
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
38243
38244
  * ```
38244
38245
  *
38245
38246
  * @param commentId The ID of the comment to flag
38247
+ * @param reason the reason to flag the comment
38246
38248
  * @returns the created report result
38247
38249
  *
38248
38250
  * @category Comment API
38249
38251
  * @async
38250
38252
  * */
38251
- const flagComment = async (commentId) => {
38253
+ const flagComment = async (commentId, reason) => {
38252
38254
  const client = getActiveClient();
38253
38255
  client.log('comment/flagComment', commentId);
38254
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`);
38256
+ const isPredefinedReason = reason &&
38257
+ Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
38258
+ const body = {
38259
+ reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
38260
+ detail: reason && !isPredefinedReason ? reason : '',
38261
+ };
38262
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
38255
38263
  if (client.cache) {
38256
38264
  ingestInCache(payload);
38257
38265
  }