@amityco/ts-sdk 7.27.1-23f628a8.0 → 7.27.1-2f09d30a.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/flagCommentLegacy.d.ts +16 -0
- package/dist/commentRepository/api/flagCommentLegacy.d.ts.map +1 -0
- package/dist/commentRepository/api/flagCommentWithOptions.d.ts +13 -0
- package/dist/commentRepository/api/flagCommentWithOptions.d.ts.map +1 -0
- package/dist/commentRepository/api/tests/integration/flagCommentLegacy.integration.test.d.ts +2 -0
- package/dist/commentRepository/api/tests/integration/flagCommentLegacy.integration.test.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/index.cjs.js +93 -14
- package/dist/index.esm.js +93 -14
- package/dist/index.umd.js +1 -1
- 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 `CommentRepository.flagComment` overload: one
|
|
24
|
+
* payload-free category plus optional reporter context. Arbitrary custom
|
|
25
|
+
* strings are not accepted here; use `ContentFlagReasonEnum.Others` and put
|
|
26
|
+
* the text in `detail`. `detail` is forwarded unchanged (the backend enforces
|
|
27
|
+
* the 300-character limit) and is omitted from the request when `undefined`.
|
|
28
|
+
*/
|
|
29
|
+
type CommentFlagOptions = {
|
|
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 {ASCError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
31
|
+
*/
|
|
32
|
+
(commentId: Amity.Comment['commentId'], options: Amity.CommentFlagOptions): 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 → `flagCommentLegacy` (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":"AAGA,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,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 flagCommentLegacy: (commentId: Amity.Comment['commentId'], reason?: Amity.ContentFlagReason) => Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=flagCommentLegacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagCommentLegacy.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagCommentLegacy.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,cACjB,aAAa,CAAC,WAAW,CAAC,WAC5B,MAAM,iBAAiB,KAC/B,QAAQ,OAAO,CA2BjB,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 {ASCError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
11
|
+
*/
|
|
12
|
+
export declare const flagCommentWithOptions: (commentId: Amity.Comment['commentId'], options: Amity.CommentFlagOptions) => 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":"AAuCA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,cACtB,aAAa,CAAC,WAAW,CAAC,WAC5B,MAAM,kBAAkB,KAChC,QAAQ,OAAO,CAmBjB,CAAC"}
|
package/dist/commentRepository/api/tests/integration/flagCommentLegacy.integration.test.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flagCommentLegacy.integration.test.d.ts","sourceRoot":"","sources":["../../../../../src/commentRepository/api/tests/integration/flagCommentLegacy.integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -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":""}
|
package/dist/index.cjs.js
CHANGED
|
@@ -27110,23 +27110,21 @@ const declineComment = async (commentId, reason) => {
|
|
|
27110
27110
|
};
|
|
27111
27111
|
/* end_public_function */
|
|
27112
27112
|
|
|
27113
|
-
/* begin_public_function
|
|
27114
|
-
id: comment.flag
|
|
27115
|
-
*/
|
|
27116
27113
|
/**
|
|
27117
|
-
*
|
|
27118
|
-
*
|
|
27119
|
-
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
27120
|
-
* ```
|
|
27114
|
+
* Legacy `flagComment(commentId, reason?)` implementation, kept verbatim so existing
|
|
27115
|
+
* callers keep the exact request body they had before the options contract existed:
|
|
27121
27116
|
*
|
|
27122
|
-
*
|
|
27123
|
-
*
|
|
27124
|
-
*
|
|
27117
|
+
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
27118
|
+
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
27119
|
+
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
27125
27120
|
*
|
|
27126
|
-
*
|
|
27127
|
-
*
|
|
27128
|
-
*
|
|
27129
|
-
|
|
27121
|
+
* Not exported from the public API. It is reached through the deprecated
|
|
27122
|
+
* `CommentRepository.flagComment(commentId, reason)` overload; see `flagComment.ts`.
|
|
27123
|
+
*
|
|
27124
|
+
* @deprecated Use `flagCommentWithOptions` (the `{ reason, detail? }` contract) for new code.
|
|
27125
|
+
* This path stays available throughout the current major version.
|
|
27126
|
+
*/
|
|
27127
|
+
const flagCommentLegacy = async (commentId, reason) => {
|
|
27130
27128
|
const client = getActiveClient();
|
|
27131
27129
|
client.log('comment/flagComment', commentId);
|
|
27132
27130
|
const isPredefinedReason = reason &&
|
|
@@ -27142,6 +27140,87 @@ const flagComment = async (commentId, reason) => {
|
|
|
27142
27140
|
fireEvent('comment.flagged', payload);
|
|
27143
27141
|
return !!payload;
|
|
27144
27142
|
};
|
|
27143
|
+
|
|
27144
|
+
const FLAG_REASONS = Object.values(exports.ContentFlagReasonEnum);
|
|
27145
|
+
const invalidOptions = (message) => new ASCError(`flagComment: ${message}`, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
27146
|
+
/**
|
|
27147
|
+
* Validates the options object before any request is made. Untyped (plain JS) callers
|
|
27148
|
+
* can pass anything at runtime, so the checks do not trust the declared type:
|
|
27149
|
+
* the argument must be a plain object, `reason` must be one of the nine
|
|
27150
|
+
* `ContentFlagReasonEnum` values and `detail`, when supplied, must be a string.
|
|
27151
|
+
*/
|
|
27152
|
+
const validateFlagCommentOptions = (options) => {
|
|
27153
|
+
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
27154
|
+
throw invalidOptions('expected an options object `{ reason, detail? }`');
|
|
27155
|
+
}
|
|
27156
|
+
const { reason, detail } = options;
|
|
27157
|
+
if (typeof reason !== 'string' || !FLAG_REASONS.includes(reason)) {
|
|
27158
|
+
throw invalidOptions('`reason` must be a `ContentFlagReasonEnum` value');
|
|
27159
|
+
}
|
|
27160
|
+
if (detail !== undefined && typeof detail !== 'string') {
|
|
27161
|
+
throw invalidOptions('`detail` must be a string when supplied');
|
|
27162
|
+
}
|
|
27163
|
+
return { reason: reason, detail };
|
|
27164
|
+
};
|
|
27165
|
+
/**
|
|
27166
|
+
* New `flagComment(commentId, { reason, detail? })` implementation. Any category,
|
|
27167
|
+
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
27168
|
+
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
27169
|
+
* the backend enforces the 300-character limit.
|
|
27170
|
+
*
|
|
27171
|
+
* Not exported from the public API. It is reached through the
|
|
27172
|
+
* `CommentRepository.flagComment(commentId, options)` overload; see `flagComment.ts`.
|
|
27173
|
+
*
|
|
27174
|
+
* @throws {ASCError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
27175
|
+
*/
|
|
27176
|
+
const flagCommentWithOptions = async (commentId, options) => {
|
|
27177
|
+
const client = getActiveClient();
|
|
27178
|
+
client.log('comment/flagComment', commentId);
|
|
27179
|
+
const { reason, detail } = validateFlagCommentOptions(options);
|
|
27180
|
+
const body = detail === undefined ? { reason } : { reason, detail };
|
|
27181
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
27182
|
+
if (client.cache) {
|
|
27183
|
+
ingestInCache(payload);
|
|
27184
|
+
}
|
|
27185
|
+
fireEvent('comment.flagged', payload);
|
|
27186
|
+
return !!payload;
|
|
27187
|
+
};
|
|
27188
|
+
|
|
27189
|
+
/* begin_public_function
|
|
27190
|
+
id: comment.flag
|
|
27191
|
+
*/
|
|
27192
|
+
/**
|
|
27193
|
+
* ```js
|
|
27194
|
+
* import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
27195
|
+
*
|
|
27196
|
+
* // No reason: sent as Others with an empty detail.
|
|
27197
|
+
* await CommentRepository.flagComment(commentId)
|
|
27198
|
+
*
|
|
27199
|
+
* // Category plus optional reporter context (any category, including Others).
|
|
27200
|
+
* await CommentRepository.flagComment(commentId, {
|
|
27201
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
27202
|
+
* detail: 'Repeated promotional links',
|
|
27203
|
+
* })
|
|
27204
|
+
* ```
|
|
27205
|
+
*
|
|
27206
|
+
* Reports a comment to moderation. Three call shapes are accepted (see the overloads):
|
|
27207
|
+
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
27208
|
+
* name only dispatches on the input shape; the two implementations are kept separate
|
|
27209
|
+
* so the legacy path is untouched by the new contract:
|
|
27210
|
+
*
|
|
27211
|
+
* - `undefined` or a string → `flagCommentLegacy` (unchanged legacy mapping)
|
|
27212
|
+
* - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
|
|
27213
|
+
*
|
|
27214
|
+
* @param commentId The ID of the comment to flag
|
|
27215
|
+
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
27216
|
+
* @returns `true` when the report was created
|
|
27217
|
+
*
|
|
27218
|
+
* @category Comment API
|
|
27219
|
+
* @async
|
|
27220
|
+
* */
|
|
27221
|
+
const flagComment = (commentId, input) => input === undefined || typeof input === 'string'
|
|
27222
|
+
? flagCommentLegacy(commentId, input)
|
|
27223
|
+
: flagCommentWithOptions(commentId, input);
|
|
27145
27224
|
/* end_public_function */
|
|
27146
27225
|
|
|
27147
27226
|
/* begin_public_function
|
package/dist/index.esm.js
CHANGED
|
@@ -27110,23 +27110,21 @@ const declineComment = async (commentId, reason) => {
|
|
|
27110
27110
|
};
|
|
27111
27111
|
/* end_public_function */
|
|
27112
27112
|
|
|
27113
|
-
/* begin_public_function
|
|
27114
|
-
id: comment.flag
|
|
27115
|
-
*/
|
|
27116
27113
|
/**
|
|
27117
|
-
*
|
|
27118
|
-
*
|
|
27119
|
-
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
27120
|
-
* ```
|
|
27114
|
+
* Legacy `flagComment(commentId, reason?)` implementation, kept verbatim so existing
|
|
27115
|
+
* callers keep the exact request body they had before the options contract existed:
|
|
27121
27116
|
*
|
|
27122
|
-
*
|
|
27123
|
-
*
|
|
27124
|
-
*
|
|
27117
|
+
* - predefined `ContentFlagReasonEnum` value → `{ reason: <value>, detail: '' }`
|
|
27118
|
+
* - any other non-empty string (including the literal `'Others'`) → `{ reason: 'Others', detail: <string> }`
|
|
27119
|
+
* - `undefined` or `''` → `{ reason: 'Others', detail: '' }`
|
|
27125
27120
|
*
|
|
27126
|
-
*
|
|
27127
|
-
*
|
|
27128
|
-
*
|
|
27129
|
-
|
|
27121
|
+
* Not exported from the public API. It is reached through the deprecated
|
|
27122
|
+
* `CommentRepository.flagComment(commentId, reason)` overload; see `flagComment.ts`.
|
|
27123
|
+
*
|
|
27124
|
+
* @deprecated Use `flagCommentWithOptions` (the `{ reason, detail? }` contract) for new code.
|
|
27125
|
+
* This path stays available throughout the current major version.
|
|
27126
|
+
*/
|
|
27127
|
+
const flagCommentLegacy = async (commentId, reason) => {
|
|
27130
27128
|
const client = getActiveClient();
|
|
27131
27129
|
client.log('comment/flagComment', commentId);
|
|
27132
27130
|
const isPredefinedReason = reason &&
|
|
@@ -27142,6 +27140,87 @@ const flagComment = async (commentId, reason) => {
|
|
|
27142
27140
|
fireEvent('comment.flagged', payload);
|
|
27143
27141
|
return !!payload;
|
|
27144
27142
|
};
|
|
27143
|
+
|
|
27144
|
+
const FLAG_REASONS = Object.values(ContentFlagReasonEnum);
|
|
27145
|
+
const invalidOptions = (message) => new ASCError(`flagComment: ${message}`, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
27146
|
+
/**
|
|
27147
|
+
* Validates the options object before any request is made. Untyped (plain JS) callers
|
|
27148
|
+
* can pass anything at runtime, so the checks do not trust the declared type:
|
|
27149
|
+
* the argument must be a plain object, `reason` must be one of the nine
|
|
27150
|
+
* `ContentFlagReasonEnum` values and `detail`, when supplied, must be a string.
|
|
27151
|
+
*/
|
|
27152
|
+
const validateFlagCommentOptions = (options) => {
|
|
27153
|
+
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
27154
|
+
throw invalidOptions('expected an options object `{ reason, detail? }`');
|
|
27155
|
+
}
|
|
27156
|
+
const { reason, detail } = options;
|
|
27157
|
+
if (typeof reason !== 'string' || !FLAG_REASONS.includes(reason)) {
|
|
27158
|
+
throw invalidOptions('`reason` must be a `ContentFlagReasonEnum` value');
|
|
27159
|
+
}
|
|
27160
|
+
if (detail !== undefined && typeof detail !== 'string') {
|
|
27161
|
+
throw invalidOptions('`detail` must be a string when supplied');
|
|
27162
|
+
}
|
|
27163
|
+
return { reason: reason, detail };
|
|
27164
|
+
};
|
|
27165
|
+
/**
|
|
27166
|
+
* New `flagComment(commentId, { reason, detail? })` implementation. Any category,
|
|
27167
|
+
* including `Others`, may carry a `detail`. `detail` is forwarded unchanged (empty and
|
|
27168
|
+
* whitespace-only strings included) and omitted from the request body when `undefined`;
|
|
27169
|
+
* the backend enforces the 300-character limit.
|
|
27170
|
+
*
|
|
27171
|
+
* Not exported from the public API. It is reached through the
|
|
27172
|
+
* `CommentRepository.flagComment(commentId, options)` overload; see `flagComment.ts`.
|
|
27173
|
+
*
|
|
27174
|
+
* @throws {ASCError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
27175
|
+
*/
|
|
27176
|
+
const flagCommentWithOptions = async (commentId, options) => {
|
|
27177
|
+
const client = getActiveClient();
|
|
27178
|
+
client.log('comment/flagComment', commentId);
|
|
27179
|
+
const { reason, detail } = validateFlagCommentOptions(options);
|
|
27180
|
+
const body = detail === undefined ? { reason } : { reason, detail };
|
|
27181
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
27182
|
+
if (client.cache) {
|
|
27183
|
+
ingestInCache(payload);
|
|
27184
|
+
}
|
|
27185
|
+
fireEvent('comment.flagged', payload);
|
|
27186
|
+
return !!payload;
|
|
27187
|
+
};
|
|
27188
|
+
|
|
27189
|
+
/* begin_public_function
|
|
27190
|
+
id: comment.flag
|
|
27191
|
+
*/
|
|
27192
|
+
/**
|
|
27193
|
+
* ```js
|
|
27194
|
+
* import { CommentRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
27195
|
+
*
|
|
27196
|
+
* // No reason: sent as Others with an empty detail.
|
|
27197
|
+
* await CommentRepository.flagComment(commentId)
|
|
27198
|
+
*
|
|
27199
|
+
* // Category plus optional reporter context (any category, including Others).
|
|
27200
|
+
* await CommentRepository.flagComment(commentId, {
|
|
27201
|
+
* reason: ContentFlagReasonEnum.SpamOrScams,
|
|
27202
|
+
* detail: 'Repeated promotional links',
|
|
27203
|
+
* })
|
|
27204
|
+
* ```
|
|
27205
|
+
*
|
|
27206
|
+
* Reports a comment to moderation. Three call shapes are accepted (see the overloads):
|
|
27207
|
+
* id-only, an options object, and the deprecated legacy reason string. The public
|
|
27208
|
+
* name only dispatches on the input shape; the two implementations are kept separate
|
|
27209
|
+
* so the legacy path is untouched by the new contract:
|
|
27210
|
+
*
|
|
27211
|
+
* - `undefined` or a string → `flagCommentLegacy` (unchanged legacy mapping)
|
|
27212
|
+
* - anything else → `flagCommentWithOptions` (validated `{ reason, detail? }`)
|
|
27213
|
+
*
|
|
27214
|
+
* @param commentId The ID of the comment to flag
|
|
27215
|
+
* @param input an options object `{ reason, detail? }`, a legacy reason string, or nothing
|
|
27216
|
+
* @returns `true` when the report was created
|
|
27217
|
+
*
|
|
27218
|
+
* @category Comment API
|
|
27219
|
+
* @async
|
|
27220
|
+
* */
|
|
27221
|
+
const flagComment = (commentId, input) => input === undefined || typeof input === 'string'
|
|
27222
|
+
? flagCommentLegacy(commentId, input)
|
|
27223
|
+
: flagCommentWithOptions(commentId, input);
|
|
27145
27224
|
/* end_public_function */
|
|
27146
27225
|
|
|
27147
27226
|
/* begin_public_function
|