@amityco/ts-sdk 7.3.1-e2dead4.0 → 7.4.1-568463d.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__';
@@ -15934,10 +15934,11 @@ getDeliveredUsers.locally = (query) => {
15934
15934
  const flagMessage = async (messageId, reason) => {
15935
15935
  const client = getActiveClient();
15936
15936
  client.log('message/flag', messageId);
15937
- const isPredefinedReason = Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
15937
+ const isPredefinedReason = reason &&
15938
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
15938
15939
  const body = {
15939
15940
  reason: isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
15940
- detail: isPredefinedReason ? '' : reason,
15941
+ detail: !isPredefinedReason ? reason : '',
15941
15942
  };
15942
15943
  const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
15943
15944
  if (client.cache) {
@@ -21672,19 +21673,26 @@ const declinePost = async (postId) => {
21672
21673
  /**
21673
21674
  * ```js
21674
21675
  * import { PostRepository } from '@amityco/ts-sdk'
21675
- * const flagged = await PostRepository.flagPost(postId)
21676
+ * const flagged = await PostRepository.flagPost(postId, reason)
21676
21677
  * ```
21677
21678
  *
21678
21679
  * @param postId of the post to flag
21680
+ * @param reason the reason to flag the post
21679
21681
  * @returns a boolean
21680
21682
  *
21681
21683
  * @category Post API
21682
21684
  * @async
21683
21685
  * */
21684
- const flagPost = async (postId) => {
21686
+ const flagPost = async (postId, reason) => {
21685
21687
  const client = getActiveClient();
21686
21688
  client.log('post/flagPost', postId);
21687
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
21689
+ const isPredefinedReason = reason &&
21690
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
21691
+ const body = {
21692
+ reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
21693
+ detail: reason && !isPredefinedReason ? reason : '',
21694
+ };
21695
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
21688
21696
  if (client.cache) {
21689
21697
  ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
21690
21698
  }
@@ -22147,19 +22155,26 @@ const hardDeleteComment = async (commentId) => {
22147
22155
  /**
22148
22156
  * ```js
22149
22157
  * import { CommentRepository } from '@amityco/ts-sdk'
22150
- * const flagged = await CommentRepository.flagComment('commentId')
22158
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
22151
22159
  * ```
22152
22160
  *
22153
22161
  * @param commentId The ID of the comment to flag
22162
+ * @param reason the reason to flag the comment
22154
22163
  * @returns the created report result
22155
22164
  *
22156
22165
  * @category Comment API
22157
22166
  * @async
22158
22167
  * */
22159
- const flagComment = async (commentId) => {
22168
+ const flagComment = async (commentId, reason) => {
22160
22169
  const client = getActiveClient();
22161
22170
  client.log('comment/flagComment', commentId);
22162
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`);
22171
+ const isPredefinedReason = reason &&
22172
+ Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
22173
+ const body = {
22174
+ reason: reason && isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
22175
+ detail: reason && !isPredefinedReason ? reason : '',
22176
+ };
22177
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
22163
22178
  if (client.cache) {
22164
22179
  ingestInCache(payload);
22165
22180
  }
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__';
@@ -32026,10 +32026,11 @@ getDeliveredUsers.locally = (query) => {
32026
32026
  const flagMessage = async (messageId, reason) => {
32027
32027
  const client = getActiveClient();
32028
32028
  client.log('message/flag', messageId);
32029
- const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
32029
+ const isPredefinedReason = reason &&
32030
+ Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
32030
32031
  const body = {
32031
32032
  reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
32032
- detail: isPredefinedReason ? '' : reason,
32033
+ detail: !isPredefinedReason ? reason : '',
32033
32034
  };
32034
32035
  const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
32035
32036
  if (client.cache) {
@@ -37764,19 +37765,26 @@ const declinePost = async (postId) => {
37764
37765
  /**
37765
37766
  * ```js
37766
37767
  * import { PostRepository } from '@amityco/ts-sdk'
37767
- * const flagged = await PostRepository.flagPost(postId)
37768
+ * const flagged = await PostRepository.flagPost(postId, reason)
37768
37769
  * ```
37769
37770
  *
37770
37771
  * @param postId of the post to flag
37772
+ * @param reason the reason to flag the post
37771
37773
  * @returns a boolean
37772
37774
  *
37773
37775
  * @category Post API
37774
37776
  * @async
37775
37777
  * */
37776
- const flagPost = async (postId) => {
37778
+ const flagPost = async (postId, reason) => {
37777
37779
  const client = getActiveClient();
37778
37780
  client.log('post/flagPost', postId);
37779
- const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`);
37781
+ const isPredefinedReason = reason &&
37782
+ Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
37783
+ const body = {
37784
+ reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
37785
+ detail: reason && !isPredefinedReason ? reason : '',
37786
+ };
37787
+ const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
37780
37788
  if (client.cache) {
37781
37789
  ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
37782
37790
  }
@@ -38239,19 +38247,26 @@ const hardDeleteComment = async (commentId) => {
38239
38247
  /**
38240
38248
  * ```js
38241
38249
  * import { CommentRepository } from '@amityco/ts-sdk'
38242
- * const flagged = await CommentRepository.flagComment('commentId')
38250
+ * const flagged = await CommentRepository.flagComment(commentId, reason)
38243
38251
  * ```
38244
38252
  *
38245
38253
  * @param commentId The ID of the comment to flag
38254
+ * @param reason the reason to flag the comment
38246
38255
  * @returns the created report result
38247
38256
  *
38248
38257
  * @category Comment API
38249
38258
  * @async
38250
38259
  * */
38251
- const flagComment = async (commentId) => {
38260
+ const flagComment = async (commentId, reason) => {
38252
38261
  const client = getActiveClient();
38253
38262
  client.log('comment/flagComment', commentId);
38254
- const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`);
38263
+ const isPredefinedReason = reason &&
38264
+ Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
38265
+ const body = {
38266
+ reason: reason && isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
38267
+ detail: reason && !isPredefinedReason ? reason : '',
38268
+ };
38269
+ const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
38255
38270
  if (client.cache) {
38256
38271
  ingestInCache(payload);
38257
38272
  }