@amityco/ts-sdk 7.27.2-9bed893.0 → 7.27.2-c6896ad9.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.
- package/dist/@types/domains/content.d.ts +11 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/commentRepository/api/flagComment.d.ts +72 -5
- package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
- package/dist/commentRepository/api/flagCommentWithOptions.d.ts +13 -0
- package/dist/commentRepository/api/flagCommentWithOptions.d.ts.map +1 -0
- package/dist/commentRepository/api/flagCommentWithReasonString.d.ts +16 -0
- package/dist/commentRepository/api/flagCommentWithReasonString.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/integration/flagCommentWithOptions.integration.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/integration/flagCommentWithOptions.integration.test.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/integration/flagCommentWithReasonString.integration.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/integration/flagCommentWithReasonString.integration.test.d.ts.map +1 -0
- package/dist/index.cjs.js +263 -42
- package/dist/index.esm.js +263 -42
- package/dist/index.umd.js +2 -2
- package/dist/messageRepository/api/flagMessage.d.ts +73 -6
- package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
- package/dist/messageRepository/api/flagMessageWithOptions.d.ts +13 -0
- package/dist/messageRepository/api/flagMessageWithOptions.d.ts.map +1 -0
- package/dist/messageRepository/api/flagMessageWithReasonString.d.ts +17 -0
- package/dist/messageRepository/api/flagMessageWithReasonString.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/integration/flagMessage.overloads.integration.test.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/integration/flagMessageWithOptions.integration.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/integration/flagMessageWithOptions.integration.test.d.ts.map +1 -0
- package/dist/messageRepository/api/tests/integration/flagMessageWithReasonString.integration.test.d.ts +2 -0
- package/dist/messageRepository/api/tests/integration/flagMessageWithReasonString.integration.test.d.ts.map +1 -0
- package/dist/postRepository/api/flagPost.d.ts +73 -6
- package/dist/postRepository/api/flagPost.d.ts.map +1 -1
- package/dist/postRepository/api/flagPostWithOptions.d.ts +13 -0
- package/dist/postRepository/api/flagPostWithOptions.d.ts.map +1 -0
- package/dist/postRepository/api/flagPostWithReasonString.d.ts +16 -0
- package/dist/postRepository/api/flagPostWithReasonString.d.ts.map +1 -0
- package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts +2 -0
- package/dist/postRepository/api/tests/integration/flagPost.overloads.integration.test.d.ts.map +1 -0
- package/dist/postRepository/api/tests/integration/flagPostWithOptions.integration.test.d.ts +2 -0
- package/dist/postRepository/api/tests/integration/flagPostWithOptions.integration.test.d.ts.map +1 -0
- package/dist/postRepository/api/tests/integration/flagPostWithReasonString.integration.test.d.ts +2 -0
- package/dist/postRepository/api/tests/integration/flagPostWithReasonString.integration.test.d.ts.map +1 -0
- package/dist/utils/contentFlag.d.ts +28 -0
- package/dist/utils/contentFlag.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -19,6 +19,17 @@ export declare enum ContentFlagReasonEnum {
|
|
|
19
19
|
declare global {
|
|
20
20
|
namespace Amity {
|
|
21
21
|
type ContentFlagReason = Exclude<`${ContentFlagReasonEnum}`, `${ContentFlagReasonEnum.Others}`> | (string & {});
|
|
22
|
+
/**
|
|
23
|
+
* Input for the reason-bearing `flagPost` / `flagComment` / `flagMessage` overloads:
|
|
24
|
+
* one payload-free category plus optional reporter context. Arbitrary custom
|
|
25
|
+
* strings are not accepted here; use `ContentFlagReasonEnum.Others` and put the
|
|
26
|
+
* text in `detail`. `detail` is forwarded unchanged (the backend enforces the
|
|
27
|
+
* 300-character limit) and is omitted from the request when `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
type ContentFlagOptions = {
|
|
30
|
+
reason: ContentFlagReasonEnum;
|
|
31
|
+
detail?: string;
|
|
32
|
+
};
|
|
22
33
|
type ContentType = 'text' | 'image' | 'file' | 'video' | 'poll' | 'json' | 'liveStream' | 'clip' | 'audio' | string;
|
|
23
34
|
type ContentFeedType = ValueOf<typeof ContentFeedType>;
|
|
24
35
|
type ContentDataText = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,oBAAY,qBAAqB;IAC/B,mBAAmB,iCAAiC;IACpD,oBAAoB,2BAA2B;IAC/C,iBAAiB,yBAAyB;IAC1C,4BAA4B,oCAAoC;IAChE,sBAAsB,2CAA2C;IACjE,qBAAqB,6BAA6B;IAClD,WAAW,kBAAkB;IAC7B,gBAAgB,wCAAwC;IACxD,MAAM,WAAW;CAClB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,iBAAiB,GAClB,OAAO,CAAC,GAAG,qBAAqB,EAAE,EAAE,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC,GACtE,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QAElB,KAAK,WAAW,GACZ,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY,GACZ,MAAM,GACN,OAAO,GACP,MAAM,CAAC;QAEX,KAAK,eAAe,GAAG,OAAO,CAAC,OAAO,eAAe,CAAC,CAAC;QAEvD,KAAK,eAAe,GAAG;YACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QAEF,KAAK,eAAe,GAAG;YACrB,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;SACtC,CAAC;QAEF,KAAK,gBAAgB,GAAG;YACtB,MAAM,EAAE,K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pB,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,WAAW,EAAE,OAAO,CAAC;YACrB,OAAO,EAAE,OAAO,CAAC;YACjB,kBAAkB,EAAE,MAAM,CAAC;YAC3B,eAAe,EAAE;gBACf,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;gBACrC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;aACtC,CAAC;SACH,CAAC;QAEF,KAAK,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,GAAG,OAAO,IAAI,CAAC,SAAS,MAAM,GAC5E,kBAAkB,GAClB,CAAC,SAAS,OAAO,GACjB,mBAAmB,GACnB,KAAK,CAAC;KACX;CACF"}
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/content.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;EAM1B,CAAC;AAEH,oBAAY,qBAAqB;IAC/B,mBAAmB,iCAAiC;IACpD,oBAAoB,2BAA2B;IAC/C,iBAAiB,yBAAyB;IAC1C,4BAA4B,oCAAoC;IAChE,sBAAsB,2CAA2C;IACjE,qBAAqB,6BAA6B;IAClD,WAAW,kBAAkB;IAC7B,gBAAgB,wCAAwC;IACxD,MAAM,WAAW;CAClB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,iBAAiB,GAClB,OAAO,CAAC,GAAG,qBAAqB,EAAE,EAAE,GAAG,qBAAqB,CAAC,MAAM,EAAE,CAAC,GACtE,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QAElB;;;;;;WAMG;QACH,KAAK,kBAAkB,GAAG;YACxB,MAAM,EAAE,qBAAqB,CAAC;YAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;SACjB,CAAC;QAEF,KAAK,WAAW,GACZ,MAAM,GACN,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,YAAY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AC,MAAM,EAAE,OAAO,CAAC,GACvB,CAAC,SAAS,MAAM,GAChB,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAAC;QAEV,KAAK,OAAO,CAAC,CAAC,SAAS,WAAW,IAAI;YAEpC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACb,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;YAChB,IAAI,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;SACvB,CAAC;QAEF,KAAK,kBAAkB,GAAG;YACxB,WAAW,EAAE,MAAM,CAAC;YACpB,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;QAEF,KAAK,mBAAmB,GAAG;YACzB,WAAW,EAAE,OAAO,CAAC;YACrB,OAAO,EAAE,OAAO,CAAC;YACjB,kBAAkB,EAAE,MAAM,CAAC;YAC3B,eAAe,EAAE;gBACf,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;gBACrC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC;aACtC,CAAC;SACH,CAAC;QAEF,KAAK,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,MAAM,GAAG,OAAO,IAAI,CAAC,SAAS,MAAM,GAC5E,kBAAkB,GAClB,CAAC,SAAS,OAAO,GACjB,mBAAmB,GACnB,KAAK,CAAC;KACX;CACF"}
|
|
@@ -1,15 +1,82 @@
|
|
|
1
|
+
declare type FlagComment = {
|
|
2
|
+
/**
|
|
3
|
+
* ```js
|
|
4
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
5
|
+
* const flagged = await CommentRepository.flagComment(commentId)
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Flags a comment without a reason. The report is sent as `Others` with an empty detail.
|
|
9
|
+
*
|
|
10
|
+
* @param commentId The ID of the comment to flag
|
|
11
|
+
* @returns `true` when the report was created
|
|
12
|
+
*/
|
|
13
|
+
(commentId: Amity.Comment['commentId'], reason?: undefined): Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* ```js
|
|
16
|
+
* import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
17
|
+
* const flagged = await CommentRepository.flagComment(commentId, {
|
|
18
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
19
|
+
* detail: 'Repeated promotional links',
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Flags a comment with a category and optional reporter context. Any category,
|
|
24
|
+
* including `Others`, may carry a `detail`. `detail` is sent unchanged and omitted
|
|
25
|
+
* when not supplied; the backend enforces its 300-character limit.
|
|
26
|
+
*
|
|
27
|
+
* @param commentId The ID of the comment to flag
|
|
28
|
+
* @param options `reason` is a `ContentFlagReasonEnum` value; `detail` is optional free text
|
|
29
|
+
* @returns `true` when the report was created
|
|
30
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
31
|
+
*/
|
|
32
|
+
(commentId: Amity.Comment['commentId'], options: Amity.ContentFlagOptions): Promise<boolean>;
|
|
33
|
+
/**
|
|
34
|
+
* ```js
|
|
35
|
+
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
36
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @deprecated Pass an options object instead: `flagComment(commentId, { reason, detail })`.
|
|
40
|
+
* A predefined string maps to `{ reason: <value>, detail: '' }`; a custom string maps to
|
|
41
|
+
* `{ reason: 'Others', detail: <string> }`. Migrate a custom string to
|
|
42
|
+
* `{ reason: ContentFlagReasonEnum.Others, detail: customString }`. This mapping is
|
|
43
|
+
* unchanged and stays available throughout the current major version.
|
|
44
|
+
*
|
|
45
|
+
* @param commentId The ID of the comment to flag
|
|
46
|
+
* @param reason a predefined `ContentFlagReasonEnum` value or a custom string
|
|
47
|
+
* @returns `true` when the report was created
|
|
48
|
+
*/
|
|
49
|
+
(commentId: Amity.Comment['commentId'], reason?: Amity.ContentFlagReason): Promise<boolean>;
|
|
50
|
+
};
|
|
1
51
|
/**
|
|
2
52
|
* ```js
|
|
3
|
-
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
4
|
-
*
|
|
53
|
+
* import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
54
|
+
*
|
|
55
|
+
* // No reason: sent as Others with an empty detail.
|
|
56
|
+
* await CommentRepository.flagComment(commentId)
|
|
57
|
+
*
|
|
58
|
+
* // Category plus optional reporter context (any category, including Others).
|
|
59
|
+
* await CommentRepository.flagComment(commentId, {
|
|
60
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
61
|
+
* detail: 'Repeated promotional links',
|
|
62
|
+
* })
|
|
5
63
|
* ```
|
|
6
64
|
*
|
|
65
|
+
* Reports a comment to moderation. Three call shapes are accepted (see the overloads):
|
|
66
|
+
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
67
|
+
* name only dispatches on the input shape; the two implementations are kept separate
|
|
68
|
+
* so the legacy path is untouched by the new contract:
|
|
69
|
+
*
|
|
70
|
+
* - `undefined` or a string → `flagCommentWithReasonString` (unchanged legacy mapping)
|
|
71
|
+
* - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
|
|
72
|
+
*
|
|
7
73
|
* @param commentId The ID of the comment to flag
|
|
8
|
-
* @param reason
|
|
9
|
-
* @returns the
|
|
74
|
+
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
75
|
+
* @returns `true` when the report was created
|
|
10
76
|
*
|
|
11
77
|
* @category Comment API
|
|
12
78
|
* @async
|
|
13
79
|
* */
|
|
14
|
-
export declare const flagComment:
|
|
80
|
+
export declare const flagComment: FlagComment;
|
|
81
|
+
export {};
|
|
15
82
|
//# sourceMappingURL=flagComment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flagComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flagComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagComment.ts"],"names":[],"mappings":"AAIA,aAAK,WAAW,GAAG;IACjB;;;;;;;;;;OAUG;IACH,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9E;;;;;;;;;;;;;;;;;OAiBG;IACH,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7F;;;;;;;;;;;;;;;OAeG;IACH,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7F,CAAC;AAKF;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BK;AACL,eAAO,MAAM,WAAW,EAAE,WAMoB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New `flagComment(commentId, { reason, detail? })` implementation. Any category,
|
|
3
|
+
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
4
|
+
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
5
|
+
* the backend enforces the 300-character limit.
|
|
6
|
+
*
|
|
7
|
+
* Not exported from the public API. It is reached through the
|
|
8
|
+
* `CommentRepository.flagComment(commentId, options)` overload; see `flagComment.ts`.
|
|
9
|
+
*
|
|
10
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
11
|
+
*/
|
|
12
|
+
export declare const flagCommentWithOptions: (commentId: Amity.Comment['commentId'], options: Amity.ContentFlagOptions) => Promise<boolean>;
|
|
13
|
+
//# sourceMappingURL=flagCommentWithOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagCommentWithOptions.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagCommentWithOptions.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,cACtB,aAAa,CAAC,WAAW,CAAC,WAC5B,MAAM,kBAAkB,KAChC,QAAQ,OAAO,CAkBjB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy `flagComment(commentId, reason?)` implementation, kept verbatim so existing
|
|
3
|
+
* callers keep the exact request body they had before the options contract existed:
|
|
4
|
+
*
|
|
5
|
+
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
6
|
+
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
7
|
+
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
8
|
+
*
|
|
9
|
+
* Not exported from the public API. It is reached through the deprecated
|
|
10
|
+
* `CommentRepository.flagComment(commentId, reason)` overload; see `flagComment.ts`.
|
|
11
|
+
*
|
|
12
|
+
* @deprecated Use `flagCommentWithOptions` (the `{ reason, detail? }` contract) for new code.
|
|
13
|
+
* This path stays available throughout the current major version.
|
|
14
|
+
*/
|
|
15
|
+
export declare const flagCommentWithReasonString: (commentId: Amity.Comment['commentId'], reason?: Amity.ContentFlagReason) => Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=flagCommentWithReasonString.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagCommentWithReasonString.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagCommentWithReasonString.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,2BAA2B,cAC3B,aAAa,CAAC,WAAW,CAAC,WAC5B,MAAM,iBAAiB,KAC/B,QAAQ,OAAO,CA2BjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagCommentWithOptions.integration.test.d.ts","sourceRoot":"","sources":["../../../../../src/commentRepository/api/tests/integration/flagCommentWithOptions.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagCommentWithReasonString.integration.test.d.ts","sourceRoot":"","sources":["../../../../../src/commentRepository/api/tests/integration/flagCommentWithReasonString.integration.test.ts"],"names":[],"mappings":""}
|
package/dist/index.cjs.js
CHANGED
|
@@ -834,6 +834,18 @@ class AmityModuleNotEntitledError extends ASCApiError {
|
|
|
834
834
|
this.type = 'AmityModuleNotEntitledError';
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
+
/**
|
|
838
|
+
* Input sanitization related error
|
|
839
|
+
* @category Errors
|
|
840
|
+
*/
|
|
841
|
+
class ASCInvalidParameterError extends ASCError {
|
|
842
|
+
/**
|
|
843
|
+
* @param message A custom error message
|
|
844
|
+
*/
|
|
845
|
+
constructor(message) {
|
|
846
|
+
super(message, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
837
849
|
|
|
838
850
|
let activeClient = null;
|
|
839
851
|
/**
|
|
@@ -20160,23 +20172,82 @@ getDeliveredUsers.locally = (query) => {
|
|
|
20160
20172
|
return { data: users, cachedAt, prevPage, nextPage };
|
|
20161
20173
|
};
|
|
20162
20174
|
|
|
20163
|
-
|
|
20164
|
-
id: message.flag
|
|
20165
|
-
*/
|
|
20175
|
+
const CONTENT_FLAG_REASONS = Object.values(exports.ContentFlagReasonEnum);
|
|
20166
20176
|
/**
|
|
20167
|
-
*
|
|
20168
|
-
*
|
|
20169
|
-
*
|
|
20170
|
-
|
|
20177
|
+
* True when a public `flagX(id, input)` argument is the legacy shape (a reason string
|
|
20178
|
+
* or nothing). Anything else is routed to the `Amity.ContentFlagOptions` path, whose
|
|
20179
|
+
* validation rejects malformed values before any request is made.
|
|
20180
|
+
*/
|
|
20181
|
+
const isLegacyContentFlagReason = (input) => input === undefined || typeof input === 'string';
|
|
20182
|
+
/**
|
|
20183
|
+
* Validates an `Amity.ContentFlagOptions` argument. Untyped (plain JS) callers can pass
|
|
20184
|
+
* anything at runtime, so the checks do not trust the declared type: the value must be a
|
|
20185
|
+
* plain object, `reason` must be one of the nine `ContentFlagReasonEnum` values and
|
|
20186
|
+
* `detail`, when supplied, must be a string (`null` is not a valid supplied detail).
|
|
20171
20187
|
*
|
|
20172
|
-
* @param
|
|
20173
|
-
* @
|
|
20174
|
-
|
|
20188
|
+
* @param apiName used in the error message, e.g. `flagPost`
|
|
20189
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
20190
|
+
*/
|
|
20191
|
+
const validateContentFlagOptions = (apiName, options) => {
|
|
20192
|
+
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
20193
|
+
throw new ASCInvalidParameterError(`${apiName}: expected an options object \`{ reason, detail? }\``);
|
|
20194
|
+
}
|
|
20195
|
+
const { reason, detail } = options;
|
|
20196
|
+
if (typeof reason !== 'string' || !CONTENT_FLAG_REASONS.includes(reason)) {
|
|
20197
|
+
throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
|
|
20198
|
+
}
|
|
20199
|
+
if (detail !== undefined && typeof detail !== 'string') {
|
|
20200
|
+
throw new ASCInvalidParameterError(`${apiName}: \`detail\` must be a string when supplied`);
|
|
20201
|
+
}
|
|
20202
|
+
return { reason: reason, detail };
|
|
20203
|
+
};
|
|
20204
|
+
/**
|
|
20205
|
+
* Builds the request body for validated options. `detail` is forwarded unchanged (empty
|
|
20206
|
+
* and whitespace-only strings included) and omitted from the body when `undefined`; the
|
|
20207
|
+
* backend enforces the 300-character limit.
|
|
20208
|
+
*/
|
|
20209
|
+
const toContentFlagBody = ({ reason, detail }) => detail === undefined ? { reason } : { reason, detail };
|
|
20210
|
+
|
|
20211
|
+
/**
|
|
20212
|
+
* New `flagMessage(messageId, { reason, detail? })` implementation. Any category,
|
|
20213
|
+
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
20214
|
+
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
20215
|
+
* the backend enforces the 300-character limit.
|
|
20175
20216
|
*
|
|
20176
|
-
*
|
|
20177
|
-
*
|
|
20178
|
-
*
|
|
20179
|
-
|
|
20217
|
+
* Not exported from the public API. It is reached through the
|
|
20218
|
+
* `MessageRepository.flagMessage(messageId, options)` overload; see `flagMessage.ts`.
|
|
20219
|
+
*
|
|
20220
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
20221
|
+
*/
|
|
20222
|
+
const flagMessageWithOptions = async (messageId, options) => {
|
|
20223
|
+
const client = getActiveClient();
|
|
20224
|
+
client.log('message/flag', messageId);
|
|
20225
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
|
|
20226
|
+
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
|
|
20227
|
+
if (client.cache) {
|
|
20228
|
+
const messagePayload = await prepareMessagePayload(payload);
|
|
20229
|
+
ingestInCache(messagePayload);
|
|
20230
|
+
}
|
|
20231
|
+
fireEvent('message.flagged', payload);
|
|
20232
|
+
return !!payload;
|
|
20233
|
+
};
|
|
20234
|
+
|
|
20235
|
+
/**
|
|
20236
|
+
* Legacy `flagMessage(messageId, reason?)` implementation, kept verbatim so existing
|
|
20237
|
+
* callers keep the exact request body they had before the options contract existed:
|
|
20238
|
+
*
|
|
20239
|
+
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
20240
|
+
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
20241
|
+
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
20242
|
+
* (for `undefined` the message body carries `detail: undefined`, which JSON serialization omits)
|
|
20243
|
+
*
|
|
20244
|
+
* Not exported from the public API. It is reached through the deprecated
|
|
20245
|
+
* `MessageRepository.flagMessage(messageId, reason)` overload; see `flagMessage.ts`.
|
|
20246
|
+
*
|
|
20247
|
+
* @deprecated Use `flagMessageWithOptions` (the `{ reason, detail? }` contract) for new code.
|
|
20248
|
+
* This path stays available throughout the current major version.
|
|
20249
|
+
*/
|
|
20250
|
+
const flagMessageWithReasonString = async (messageId, reason) => {
|
|
20180
20251
|
const client = getActiveClient();
|
|
20181
20252
|
client.log('message/flag', messageId);
|
|
20182
20253
|
const isPredefinedReason = reason &&
|
|
@@ -20193,6 +20264,42 @@ const flagMessage = async (messageId, reason) => {
|
|
|
20193
20264
|
fireEvent('message.flagged', payload);
|
|
20194
20265
|
return !!payload;
|
|
20195
20266
|
};
|
|
20267
|
+
|
|
20268
|
+
/* begin_public_function
|
|
20269
|
+
id: message.flag
|
|
20270
|
+
*/
|
|
20271
|
+
/**
|
|
20272
|
+
* ```js
|
|
20273
|
+
* import { MessageRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
20274
|
+
*
|
|
20275
|
+
* // No reason.
|
|
20276
|
+
* await MessageRepository.flagMessage(messageId)
|
|
20277
|
+
*
|
|
20278
|
+
* // Category plus optional reporter context (any category, including Others).
|
|
20279
|
+
* await MessageRepository.flagMessage(messageId, {
|
|
20280
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
20281
|
+
* detail: 'Repeated promotional links',
|
|
20282
|
+
* })
|
|
20283
|
+
* ```
|
|
20284
|
+
*
|
|
20285
|
+
* Reports a message to moderation. Three call shapes are accepted (see the overloads):
|
|
20286
|
+
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
20287
|
+
* name only dispatches on the input shape; the two implementations are kept separate
|
|
20288
|
+
* so the legacy path is untouched by the new contract:
|
|
20289
|
+
*
|
|
20290
|
+
* - `undefined` or a string → `flagMessageWithReasonString` (unchanged legacy mapping)
|
|
20291
|
+
* - anything else → `flagMessageWithOptions` (validated `{ reason, detail? }`)
|
|
20292
|
+
*
|
|
20293
|
+
* @param messageId The ID of the message to flag
|
|
20294
|
+
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
20295
|
+
* @returns `true` when the report was created
|
|
20296
|
+
*
|
|
20297
|
+
* @category Message API
|
|
20298
|
+
* @async
|
|
20299
|
+
* */
|
|
20300
|
+
const flagMessage = (messageId, input) => isLegacyContentFlagReason(input)
|
|
20301
|
+
? flagMessageWithReasonString(messageId, input)
|
|
20302
|
+
: flagMessageWithOptions(messageId, input);
|
|
20196
20303
|
/* end_public_function */
|
|
20197
20304
|
|
|
20198
20305
|
/* begin_public_function
|
|
@@ -27338,23 +27445,21 @@ const declineComment = async (commentId, reason) => {
|
|
|
27338
27445
|
};
|
|
27339
27446
|
/* end_public_function */
|
|
27340
27447
|
|
|
27341
|
-
/* begin_public_function
|
|
27342
|
-
id: comment.flag
|
|
27343
|
-
*/
|
|
27344
27448
|
/**
|
|
27345
|
-
*
|
|
27346
|
-
*
|
|
27347
|
-
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
27348
|
-
* ```
|
|
27449
|
+
* Legacy `flagComment(commentId, reason?)` implementation, kept verbatim so existing
|
|
27450
|
+
* callers keep the exact request body they had before the options contract existed:
|
|
27349
27451
|
*
|
|
27350
|
-
*
|
|
27351
|
-
*
|
|
27352
|
-
*
|
|
27452
|
+
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
27453
|
+
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
27454
|
+
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
27353
27455
|
*
|
|
27354
|
-
*
|
|
27355
|
-
*
|
|
27356
|
-
*
|
|
27357
|
-
|
|
27456
|
+
* Not exported from the public API. It is reached through the deprecated
|
|
27457
|
+
* `CommentRepository.flagComment(commentId, reason)` overload; see `flagComment.ts`.
|
|
27458
|
+
*
|
|
27459
|
+
* @deprecated Use `flagCommentWithOptions` (the `{ reason, detail? }` contract) for new code.
|
|
27460
|
+
* This path stays available throughout the current major version.
|
|
27461
|
+
*/
|
|
27462
|
+
const flagCommentWithReasonString = async (commentId, reason) => {
|
|
27358
27463
|
const client = getActiveClient();
|
|
27359
27464
|
client.log('comment/flagComment', commentId);
|
|
27360
27465
|
const isPredefinedReason = reason &&
|
|
@@ -27370,6 +27475,65 @@ const flagComment = async (commentId, reason) => {
|
|
|
27370
27475
|
fireEvent('comment.flagged', payload);
|
|
27371
27476
|
return !!payload;
|
|
27372
27477
|
};
|
|
27478
|
+
|
|
27479
|
+
/**
|
|
27480
|
+
* New `flagComment(commentId, { reason, detail? })` implementation. Any category,
|
|
27481
|
+
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
27482
|
+
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
27483
|
+
* the backend enforces the 300-character limit.
|
|
27484
|
+
*
|
|
27485
|
+
* Not exported from the public API. It is reached through the
|
|
27486
|
+
* `CommentRepository.flagComment(commentId, options)` overload; see `flagComment.ts`.
|
|
27487
|
+
*
|
|
27488
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
27489
|
+
*/
|
|
27490
|
+
const flagCommentWithOptions = async (commentId, options) => {
|
|
27491
|
+
const client = getActiveClient();
|
|
27492
|
+
client.log('comment/flagComment', commentId);
|
|
27493
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
|
|
27494
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
27495
|
+
if (client.cache) {
|
|
27496
|
+
ingestInCache(payload);
|
|
27497
|
+
}
|
|
27498
|
+
fireEvent('comment.flagged', payload);
|
|
27499
|
+
return !!payload;
|
|
27500
|
+
};
|
|
27501
|
+
|
|
27502
|
+
/* begin_public_function
|
|
27503
|
+
id: comment.flag
|
|
27504
|
+
*/
|
|
27505
|
+
/**
|
|
27506
|
+
* ```js
|
|
27507
|
+
* import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
27508
|
+
*
|
|
27509
|
+
* // No reason: sent as Others with an empty detail.
|
|
27510
|
+
* await CommentRepository.flagComment(commentId)
|
|
27511
|
+
*
|
|
27512
|
+
* // Category plus optional reporter context (any category, including Others).
|
|
27513
|
+
* await CommentRepository.flagComment(commentId, {
|
|
27514
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
27515
|
+
* detail: 'Repeated promotional links',
|
|
27516
|
+
* })
|
|
27517
|
+
* ```
|
|
27518
|
+
*
|
|
27519
|
+
* Reports a comment to moderation. Three call shapes are accepted (see the overloads):
|
|
27520
|
+
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
27521
|
+
* name only dispatches on the input shape; the two implementations are kept separate
|
|
27522
|
+
* so the legacy path is untouched by the new contract:
|
|
27523
|
+
*
|
|
27524
|
+
* - `undefined` or a string → `flagCommentWithReasonString` (unchanged legacy mapping)
|
|
27525
|
+
* - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
|
|
27526
|
+
*
|
|
27527
|
+
* @param commentId The ID of the comment to flag
|
|
27528
|
+
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
27529
|
+
* @returns `true` when the report was created
|
|
27530
|
+
*
|
|
27531
|
+
* @category Comment API
|
|
27532
|
+
* @async
|
|
27533
|
+
* */
|
|
27534
|
+
const flagComment = (commentId, input) => isLegacyContentFlagReason(input)
|
|
27535
|
+
? flagCommentWithReasonString(commentId, input)
|
|
27536
|
+
: flagCommentWithOptions(commentId, input);
|
|
27373
27537
|
/* end_public_function */
|
|
27374
27538
|
|
|
27375
27539
|
/* begin_public_function
|
|
@@ -29723,23 +29887,44 @@ const declinePost = async (postId) => {
|
|
|
29723
29887
|
};
|
|
29724
29888
|
/* end_public_function */
|
|
29725
29889
|
|
|
29726
|
-
/* begin_public_function
|
|
29727
|
-
id: post.flag
|
|
29728
|
-
*/
|
|
29729
29890
|
/**
|
|
29730
|
-
*
|
|
29731
|
-
*
|
|
29732
|
-
*
|
|
29733
|
-
*
|
|
29891
|
+
* New `flagPost(postId, { reason, detail? })` implementation. Any category, including
|
|
29892
|
+
* `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
29893
|
+
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
29894
|
+
* the backend enforces the 300-character limit.
|
|
29734
29895
|
*
|
|
29735
|
-
*
|
|
29736
|
-
*
|
|
29737
|
-
* @returns a boolean
|
|
29896
|
+
* Not exported from the public API. It is reached through the
|
|
29897
|
+
* `PostRepository.flagPost(postId, options)` overload; see `flagPost.ts`.
|
|
29738
29898
|
*
|
|
29739
|
-
* @
|
|
29740
|
-
|
|
29741
|
-
|
|
29742
|
-
const
|
|
29899
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
29900
|
+
*/
|
|
29901
|
+
const flagPostWithOptions = async (postId, options) => {
|
|
29902
|
+
const client = getActiveClient();
|
|
29903
|
+
client.log('post/flagPost', postId);
|
|
29904
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
|
|
29905
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
29906
|
+
if (client.cache) {
|
|
29907
|
+
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
29908
|
+
}
|
|
29909
|
+
fireEvent('post.flagged', payload);
|
|
29910
|
+
return !!payload;
|
|
29911
|
+
};
|
|
29912
|
+
|
|
29913
|
+
/**
|
|
29914
|
+
* Legacy `flagPost(postId, reason?)` implementation, kept verbatim so existing
|
|
29915
|
+
* callers keep the exact request body they had before the options contract existed:
|
|
29916
|
+
*
|
|
29917
|
+
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
29918
|
+
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
29919
|
+
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
29920
|
+
*
|
|
29921
|
+
* Not exported from the public API. It is reached through the deprecated
|
|
29922
|
+
* `PostRepository.flagPost(postId, reason)` overload; see `flagPost.ts`.
|
|
29923
|
+
*
|
|
29924
|
+
* @deprecated Use `flagPostWithOptions` (the `{ reason, detail? }` contract) for new code.
|
|
29925
|
+
* This path stays available throughout the current major version.
|
|
29926
|
+
*/
|
|
29927
|
+
const flagPostWithReasonString = async (postId, reason) => {
|
|
29743
29928
|
const client = getActiveClient();
|
|
29744
29929
|
client.log('post/flagPost', postId);
|
|
29745
29930
|
const isPredefinedReason = reason &&
|
|
@@ -29755,6 +29940,42 @@ const flagPost = async (postId, reason) => {
|
|
|
29755
29940
|
fireEvent('post.flagged', payload);
|
|
29756
29941
|
return !!payload;
|
|
29757
29942
|
};
|
|
29943
|
+
|
|
29944
|
+
/* begin_public_function
|
|
29945
|
+
id: post.flag
|
|
29946
|
+
*/
|
|
29947
|
+
/**
|
|
29948
|
+
* ```js
|
|
29949
|
+
* import { PostRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
29950
|
+
*
|
|
29951
|
+
* // No reason.
|
|
29952
|
+
* await PostRepository.flagPost(postId)
|
|
29953
|
+
*
|
|
29954
|
+
* // Category plus optional reporter context (any category, including Others).
|
|
29955
|
+
* await PostRepository.flagPost(postId, {
|
|
29956
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
29957
|
+
* detail: 'Repeated promotional links',
|
|
29958
|
+
* })
|
|
29959
|
+
* ```
|
|
29960
|
+
*
|
|
29961
|
+
* Reports a post to moderation. Three call shapes are accepted (see the overloads):
|
|
29962
|
+
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
29963
|
+
* name only dispatches on the input shape; the two implementations are kept separate
|
|
29964
|
+
* so the legacy path is untouched by the new contract:
|
|
29965
|
+
*
|
|
29966
|
+
* - `undefined` or a string → `flagPostWithReasonString` (unchanged legacy mapping)
|
|
29967
|
+
* - anything else → `flagPostWithOptions` (validated `{ reason, detail? }`)
|
|
29968
|
+
*
|
|
29969
|
+
* @param postId The ID of the post to flag
|
|
29970
|
+
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
29971
|
+
* @returns `true` when the report was created
|
|
29972
|
+
*
|
|
29973
|
+
* @category Post API
|
|
29974
|
+
* @async
|
|
29975
|
+
* */
|
|
29976
|
+
const flagPost = (postId, input) => isLegacyContentFlagReason(input)
|
|
29977
|
+
? flagPostWithReasonString(postId, input)
|
|
29978
|
+
: flagPostWithOptions(postId, input);
|
|
29758
29979
|
/* end_public_function */
|
|
29759
29980
|
|
|
29760
29981
|
/* begin_public_function
|