@amityco/ts-sdk 7.27.2-c6896ad9.0 → 7.27.2-d978f145.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/user.d.ts +31 -0
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/commentRepository/api/flagCommentWithOptions.d.ts.map +1 -1
- package/dist/index.cjs.js +181 -11
- package/dist/index.esm.js +182 -12
- package/dist/index.umd.js +2 -2
- package/dist/messageRepository/api/flagMessageWithOptions.d.ts.map +1 -1
- package/dist/postRepository/api/flagPostWithOptions.d.ts.map +1 -1
- package/dist/userRepository/api/flagUser.d.ts +50 -9
- package/dist/userRepository/api/flagUser.d.ts.map +1 -1
- package/dist/userRepository/api/flagUserBehavior.d.ts +29 -0
- package/dist/userRepository/api/flagUserBehavior.d.ts.map +1 -0
- package/dist/userRepository/api/flagUserProfile.d.ts +29 -0
- package/dist/userRepository/api/flagUserProfile.d.ts.map +1 -0
- package/dist/userRepository/api/index.d.ts +2 -0
- package/dist/userRepository/api/index.d.ts.map +1 -1
- package/dist/userRepository/api/tests/integration/flagUser.overloads.integration.test.d.ts +2 -0
- package/dist/userRepository/api/tests/integration/flagUser.overloads.integration.test.d.ts.map +1 -0
- package/dist/userRepository/api/tests/integration/flagUserBehavior.integration.test.d.ts +2 -0
- package/dist/userRepository/api/tests/integration/flagUserBehavior.integration.test.d.ts.map +1 -0
- package/dist/userRepository/api/tests/integration/flagUserProfile.integration.test.d.ts +2 -0
- package/dist/userRepository/api/tests/integration/flagUserProfile.integration.test.d.ts.map +1 -0
- package/dist/userRepository/utils/submitUserReport.d.ts +10 -0
- package/dist/userRepository/utils/submitUserReport.d.ts.map +1 -0
- package/dist/userRepository/utils/userReport.d.ts +35 -0
- package/dist/userRepository/utils/userReport.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AmityUserSearchMatchType } from '~/userRepository';
|
|
2
|
+
import { ContentFlagReasonEnum } from './content';
|
|
2
3
|
export declare const enum UserTypeEnum {
|
|
3
4
|
SIGNED_IN = "signed-in",
|
|
4
5
|
VISITOR = "visitor",
|
|
@@ -15,6 +16,17 @@ export declare enum UserReportTypeEnum {
|
|
|
15
16
|
AVATAR = "avatarFileId",
|
|
16
17
|
BEHAVIOR = "behavior"
|
|
17
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The profile field a user is reported for in `UserRepository.flagUserProfile`.
|
|
21
|
+
* Each member is the backend `reportType` wire value. There is deliberately no
|
|
22
|
+
* behavior member: behavior reports need a reason and go through
|
|
23
|
+
* `UserRepository.flagUserBehavior`.
|
|
24
|
+
*/
|
|
25
|
+
export declare enum UserProfileFieldEnum {
|
|
26
|
+
DISPLAY_NAME = "displayName",
|
|
27
|
+
DESCRIPTION = "description",
|
|
28
|
+
AVATAR = "avatarFileId"
|
|
29
|
+
}
|
|
18
30
|
export {};
|
|
19
31
|
declare global {
|
|
20
32
|
namespace Amity {
|
|
@@ -39,6 +51,25 @@ declare global {
|
|
|
39
51
|
reason?: Amity.ContentFlagReason;
|
|
40
52
|
comment?: string;
|
|
41
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Input for `UserRepository.flagUserProfile`: the reported profile field plus
|
|
56
|
+
* optional reporter context. There is no `reason`; profile reports never carry one.
|
|
57
|
+
* `comment` is trimmed, omitted when blank, and rejected locally above 300 characters.
|
|
58
|
+
*/
|
|
59
|
+
type UserProfileReportOptions = {
|
|
60
|
+
field: UserProfileFieldEnum;
|
|
61
|
+
comment?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Input for `UserRepository.flagUserBehavior`: one payload-free category plus
|
|
65
|
+
* optional reporter context. Reporter text, including the explanation for
|
|
66
|
+
* `ContentFlagReasonEnum.Others`, always travels in `comment`. `comment` is
|
|
67
|
+
* trimmed, omitted when blank, and rejected locally above 300 characters.
|
|
68
|
+
*/
|
|
69
|
+
type UserBehaviorReportOptions = {
|
|
70
|
+
reason: ContentFlagReasonEnum;
|
|
71
|
+
comment?: string;
|
|
72
|
+
};
|
|
42
73
|
type RawUser = {
|
|
43
74
|
_id: string;
|
|
44
75
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/user.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +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,
|
|
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,CAoBjB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -58,6 +58,18 @@ exports.UserReportTypeEnum = void 0;
|
|
|
58
58
|
UserReportTypeEnum["AVATAR"] = "avatarFileId";
|
|
59
59
|
UserReportTypeEnum["BEHAVIOR"] = "behavior";
|
|
60
60
|
})(exports.UserReportTypeEnum || (exports.UserReportTypeEnum = {}));
|
|
61
|
+
/**
|
|
62
|
+
* The profile field a user is reported for in `UserRepository.flagUserProfile`.
|
|
63
|
+
* Each member is the backend `reportType` wire value. There is deliberately no
|
|
64
|
+
* behavior member: behavior reports need a reason and go through
|
|
65
|
+
* `UserRepository.flagUserBehavior`.
|
|
66
|
+
*/
|
|
67
|
+
exports.UserProfileFieldEnum = void 0;
|
|
68
|
+
(function (UserProfileFieldEnum) {
|
|
69
|
+
UserProfileFieldEnum["DISPLAY_NAME"] = "displayName";
|
|
70
|
+
UserProfileFieldEnum["DESCRIPTION"] = "description";
|
|
71
|
+
UserProfileFieldEnum["AVATAR"] = "avatarFileId";
|
|
72
|
+
})(exports.UserProfileFieldEnum || (exports.UserProfileFieldEnum = {}));
|
|
61
73
|
|
|
62
74
|
const FileType = Object.freeze({
|
|
63
75
|
FILE: 'file',
|
|
@@ -15262,18 +15274,18 @@ const buildFlagUserBody = (options) => {
|
|
|
15262
15274
|
/**
|
|
15263
15275
|
* ```js
|
|
15264
15276
|
* import { UserRepository } from '@amityco/ts-sdk'
|
|
15277
|
+
*
|
|
15278
|
+
* // Typeless report (supported).
|
|
15265
15279
|
* const flagged = await UserRepository.flagUser('userId')
|
|
15266
|
-
* const flaggedBehavior = await UserRepository.flagUser('userId', {
|
|
15267
|
-
* reportType: 'behavior',
|
|
15268
|
-
* reason: 'Harassment or bullying',
|
|
15269
|
-
* comment: 'optional free-text',
|
|
15270
|
-
* })
|
|
15271
15280
|
* ```
|
|
15272
15281
|
*
|
|
15282
|
+
* Flags a user. Two call shapes are accepted (see the overloads): id-only, which
|
|
15283
|
+
* sends no body and stays supported, and the deprecated structured options object,
|
|
15284
|
+
* whose request mapping is unchanged. New code reporting a profile field or behavior
|
|
15285
|
+
* should use `flagUserProfile` or `flagUserBehavior`.
|
|
15286
|
+
*
|
|
15273
15287
|
* @param userId The ID of the user to be flagged
|
|
15274
|
-
* @param options
|
|
15275
|
-
* body: `reportType`, `reason`, `comment`. Only non-null fields are included.
|
|
15276
|
-
* All validation is server-side; a bodyless call produces a typeless report.
|
|
15288
|
+
* @param options Deprecated report metadata; omit for a typeless report
|
|
15277
15289
|
* @returns the flagged {@link Amity.User}
|
|
15278
15290
|
*
|
|
15279
15291
|
* @category User API
|
|
@@ -15294,6 +15306,156 @@ const flagUser = async (userId, options) => {
|
|
|
15294
15306
|
};
|
|
15295
15307
|
/* end_public_function */
|
|
15296
15308
|
|
|
15309
|
+
/**
|
|
15310
|
+
* Sends a validated split user report (`flagUserProfile` / `flagUserBehavior`) to the
|
|
15311
|
+
* same endpoint as `flagUser`, then persists the returned user and fires `user.flagged`
|
|
15312
|
+
* exactly as `flagUser` does, so all three calls share return, cache and event behaviour.
|
|
15313
|
+
*
|
|
15314
|
+
* Not exported from the public API.
|
|
15315
|
+
*/
|
|
15316
|
+
const submitUserReport = async (apiName, userId, body) => {
|
|
15317
|
+
var _a;
|
|
15318
|
+
const client = getActiveClient();
|
|
15319
|
+
client.log(`user/${apiName}`, { userId, body });
|
|
15320
|
+
const { data } = await client.http.post(`/api/v4/me/flags/${encodeURIComponent(userId)}`, body);
|
|
15321
|
+
const payload = prepareUserPayload(data);
|
|
15322
|
+
if (client.cache) {
|
|
15323
|
+
ingestInCache(payload);
|
|
15324
|
+
}
|
|
15325
|
+
fireEvent('user.flagged', data);
|
|
15326
|
+
return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
|
|
15327
|
+
};
|
|
15328
|
+
|
|
15329
|
+
/** Maximum `comment` length, in string length units, after trimming. */
|
|
15330
|
+
const USER_REPORT_COMMENT_MAX_LENGTH = 300;
|
|
15331
|
+
const PROFILE_FIELDS = Object.values(exports.UserProfileFieldEnum);
|
|
15332
|
+
const BEHAVIOR_REASONS = Object.values(exports.ContentFlagReasonEnum);
|
|
15333
|
+
const assertOptionsObject = (apiName, options, shape) => {
|
|
15334
|
+
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
15335
|
+
throw new ASCInvalidParameterError(`${apiName}: expected an options object \`${shape}\``);
|
|
15336
|
+
}
|
|
15337
|
+
return options;
|
|
15338
|
+
};
|
|
15339
|
+
/**
|
|
15340
|
+
* Normalizes an optional reporter `comment`: it must be a string when supplied (`null`
|
|
15341
|
+
* is not a valid supplied comment); it is trimmed; a blank result is omitted (the
|
|
15342
|
+
* backend rejects `""`); a result longer than 300 characters is rejected before any
|
|
15343
|
+
* request. Otherwise the trimmed text is returned unchanged.
|
|
15344
|
+
*
|
|
15345
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` for a non-string or over-length comment
|
|
15346
|
+
*/
|
|
15347
|
+
const normalizeUserReportComment = (apiName, comment) => {
|
|
15348
|
+
if (comment === undefined)
|
|
15349
|
+
return undefined;
|
|
15350
|
+
if (typeof comment !== 'string') {
|
|
15351
|
+
throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be a string when supplied`);
|
|
15352
|
+
}
|
|
15353
|
+
const trimmed = comment.trim();
|
|
15354
|
+
if (trimmed.length === 0)
|
|
15355
|
+
return undefined;
|
|
15356
|
+
if (trimmed.length > USER_REPORT_COMMENT_MAX_LENGTH) {
|
|
15357
|
+
throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be at most ${USER_REPORT_COMMENT_MAX_LENGTH} characters after trimming`);
|
|
15358
|
+
}
|
|
15359
|
+
return trimmed;
|
|
15360
|
+
};
|
|
15361
|
+
const withComment = (body, comment) => comment === undefined ? body : Object.assign(Object.assign({}, body), { comment });
|
|
15362
|
+
/**
|
|
15363
|
+
* Validates `flagUserProfile` options and builds its request body. Untyped callers can
|
|
15364
|
+
* pass anything at runtime, so nothing is trusted from the declared type. Any `reason`
|
|
15365
|
+
* key is ignored and never sent.
|
|
15366
|
+
*
|
|
15367
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
15368
|
+
*/
|
|
15369
|
+
const toUserProfileReportBody = (options) => {
|
|
15370
|
+
const apiName = 'flagUserProfile';
|
|
15371
|
+
const { field, comment } = assertOptionsObject(apiName, options, '{ field, comment? }');
|
|
15372
|
+
if (typeof field !== 'string' || !PROFILE_FIELDS.includes(field)) {
|
|
15373
|
+
throw new ASCInvalidParameterError(`${apiName}: \`field\` must be a \`UserProfileFieldEnum\` value`);
|
|
15374
|
+
}
|
|
15375
|
+
return withComment({ reportType: field }, normalizeUserReportComment(apiName, comment));
|
|
15376
|
+
};
|
|
15377
|
+
/**
|
|
15378
|
+
* Validates `flagUserBehavior` options and builds its request body. `reason` must be one
|
|
15379
|
+
* of the nine `ContentFlagReasonEnum` values and is sent as that canonical label;
|
|
15380
|
+
* `reportType` is always `behavior`.
|
|
15381
|
+
*
|
|
15382
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
15383
|
+
*/
|
|
15384
|
+
const toUserBehaviorReportBody = (options) => {
|
|
15385
|
+
const apiName = 'flagUserBehavior';
|
|
15386
|
+
const { reason, comment } = assertOptionsObject(apiName, options, '{ reason, comment? }');
|
|
15387
|
+
if (typeof reason !== 'string' || !BEHAVIOR_REASONS.includes(reason)) {
|
|
15388
|
+
throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
|
|
15389
|
+
}
|
|
15390
|
+
return withComment({ reportType: 'behavior', reason }, normalizeUserReportComment(apiName, comment));
|
|
15391
|
+
};
|
|
15392
|
+
|
|
15393
|
+
/* begin_public_function
|
|
15394
|
+
id: user.flag_profile
|
|
15395
|
+
*/
|
|
15396
|
+
/**
|
|
15397
|
+
* ```js
|
|
15398
|
+
* import { UserRepository, UserProfileFieldEnum } from '@amityco/ts-sdk'
|
|
15399
|
+
* const flagged = await UserRepository.flagUserProfile('userId', {
|
|
15400
|
+
* field: UserProfileFieldEnum.AVATAR,
|
|
15401
|
+
* comment: 'Nudity in profile photo',
|
|
15402
|
+
* })
|
|
15403
|
+
* ```
|
|
15404
|
+
*
|
|
15405
|
+
* Reports one of a user's profile fields (display name, description or avatar). The
|
|
15406
|
+
* call has no reason: profile reports never carry one, so the backend's reason rules
|
|
15407
|
+
* cannot be violated from here. A `reason` key passed at runtime is ignored and never sent.
|
|
15408
|
+
*
|
|
15409
|
+
* `comment` is trimmed; a blank comment is omitted from the request; a comment longer
|
|
15410
|
+
* than 300 characters after trimming is rejected before any request. Otherwise the
|
|
15411
|
+
* trimmed text is sent unchanged.
|
|
15412
|
+
*
|
|
15413
|
+
* Sends `POST /api/v4/me/flags/:userId` with `{ reportType: <field>, comment? }`.
|
|
15414
|
+
*
|
|
15415
|
+
* @param userId The ID of the user to be reported
|
|
15416
|
+
* @param options `field` is a `UserProfileFieldEnum` value; `comment` is optional free text
|
|
15417
|
+
* @returns the flagged {@link Amity.User}
|
|
15418
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, or `comment` is over 300 characters, before any request is made
|
|
15419
|
+
*
|
|
15420
|
+
* @category User API
|
|
15421
|
+
* @async
|
|
15422
|
+
* */
|
|
15423
|
+
const flagUserProfile = async (userId, options) => submitUserReport('flagUserProfile', userId, toUserProfileReportBody(options));
|
|
15424
|
+
/* end_public_function */
|
|
15425
|
+
|
|
15426
|
+
/* begin_public_function
|
|
15427
|
+
id: user.flag_behavior
|
|
15428
|
+
*/
|
|
15429
|
+
/**
|
|
15430
|
+
* ```js
|
|
15431
|
+
* import { UserRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
15432
|
+
* const flagged = await UserRepository.flagUserBehavior('userId', {
|
|
15433
|
+
* reason: ContentFlagReasonEnum.Others,
|
|
15434
|
+
* comment: 'Impersonating our brand',
|
|
15435
|
+
* })
|
|
15436
|
+
* ```
|
|
15437
|
+
*
|
|
15438
|
+
* Reports a user's behavior. `reason` is required and is one of the nine
|
|
15439
|
+
* `ContentFlagReasonEnum` values, sent as its canonical label. Reporter text, including
|
|
15440
|
+
* the explanation for `Others`, always travels in `comment`; the reason never carries text.
|
|
15441
|
+
*
|
|
15442
|
+
* `comment` is trimmed; a blank comment is omitted from the request; a comment longer
|
|
15443
|
+
* than 300 characters after trimming is rejected before any request. Otherwise the
|
|
15444
|
+
* trimmed text is sent unchanged.
|
|
15445
|
+
*
|
|
15446
|
+
* Sends `POST /api/v4/me/flags/:userId` with `{ reportType: 'behavior', reason, comment? }`.
|
|
15447
|
+
*
|
|
15448
|
+
* @param userId The ID of the user to be reported
|
|
15449
|
+
* @param options `reason` is a `ContentFlagReasonEnum` value; `comment` is optional free text
|
|
15450
|
+
* @returns the flagged {@link Amity.User}
|
|
15451
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, `reason` is missing or unknown, or `comment` is over 300 characters, before any request is made
|
|
15452
|
+
*
|
|
15453
|
+
* @category User API
|
|
15454
|
+
* @async
|
|
15455
|
+
* */
|
|
15456
|
+
const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBehavior', userId, toUserBehaviorReportBody(options));
|
|
15457
|
+
/* end_public_function */
|
|
15458
|
+
|
|
15297
15459
|
/* begin_public_function
|
|
15298
15460
|
id: user.unflag
|
|
15299
15461
|
*/
|
|
@@ -16468,6 +16630,8 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
16468
16630
|
getUserByIds: getUserByIds,
|
|
16469
16631
|
updateUser: updateUser,
|
|
16470
16632
|
flagUser: flagUser,
|
|
16633
|
+
flagUserProfile: flagUserProfile,
|
|
16634
|
+
flagUserBehavior: flagUserBehavior,
|
|
16471
16635
|
unflagUser: unflagUser,
|
|
16472
16636
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
16473
16637
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
@@ -20220,9 +20384,11 @@ const toContentFlagBody = ({ reason, detail }) => detail === undefined ? { reaso
|
|
|
20220
20384
|
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
20221
20385
|
*/
|
|
20222
20386
|
const flagMessageWithOptions = async (messageId, options) => {
|
|
20387
|
+
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
20388
|
+
// whether a client is active, and validation needs nothing from the client.
|
|
20389
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
|
|
20223
20390
|
const client = getActiveClient();
|
|
20224
20391
|
client.log('message/flag', messageId);
|
|
20225
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
|
|
20226
20392
|
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
|
|
20227
20393
|
if (client.cache) {
|
|
20228
20394
|
const messagePayload = await prepareMessagePayload(payload);
|
|
@@ -27488,9 +27654,11 @@ const flagCommentWithReasonString = async (commentId, reason) => {
|
|
|
27488
27654
|
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
27489
27655
|
*/
|
|
27490
27656
|
const flagCommentWithOptions = async (commentId, options) => {
|
|
27657
|
+
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
27658
|
+
// whether a client is active, and validation needs nothing from the client.
|
|
27659
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
|
|
27491
27660
|
const client = getActiveClient();
|
|
27492
27661
|
client.log('comment/flagComment', commentId);
|
|
27493
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
|
|
27494
27662
|
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
27495
27663
|
if (client.cache) {
|
|
27496
27664
|
ingestInCache(payload);
|
|
@@ -29899,9 +30067,11 @@ const declinePost = async (postId) => {
|
|
|
29899
30067
|
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
29900
30068
|
*/
|
|
29901
30069
|
const flagPostWithOptions = async (postId, options) => {
|
|
30070
|
+
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
30071
|
+
// whether a client is active, and validation needs nothing from the client.
|
|
30072
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
|
|
29902
30073
|
const client = getActiveClient();
|
|
29903
30074
|
client.log('post/flagPost', postId);
|
|
29904
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
|
|
29905
30075
|
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
29906
30076
|
if (client.cache) {
|
|
29907
30077
|
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
package/dist/index.esm.js
CHANGED
|
@@ -42,6 +42,18 @@ var UserReportTypeEnum;
|
|
|
42
42
|
UserReportTypeEnum["AVATAR"] = "avatarFileId";
|
|
43
43
|
UserReportTypeEnum["BEHAVIOR"] = "behavior";
|
|
44
44
|
})(UserReportTypeEnum || (UserReportTypeEnum = {}));
|
|
45
|
+
/**
|
|
46
|
+
* The profile field a user is reported for in `UserRepository.flagUserProfile`.
|
|
47
|
+
* Each member is the backend `reportType` wire value. There is deliberately no
|
|
48
|
+
* behavior member: behavior reports need a reason and go through
|
|
49
|
+
* `UserRepository.flagUserBehavior`.
|
|
50
|
+
*/
|
|
51
|
+
var UserProfileFieldEnum;
|
|
52
|
+
(function (UserProfileFieldEnum) {
|
|
53
|
+
UserProfileFieldEnum["DISPLAY_NAME"] = "displayName";
|
|
54
|
+
UserProfileFieldEnum["DESCRIPTION"] = "description";
|
|
55
|
+
UserProfileFieldEnum["AVATAR"] = "avatarFileId";
|
|
56
|
+
})(UserProfileFieldEnum || (UserProfileFieldEnum = {}));
|
|
45
57
|
|
|
46
58
|
const FileType = Object.freeze({
|
|
47
59
|
FILE: 'file',
|
|
@@ -15262,18 +15274,18 @@ const buildFlagUserBody = (options) => {
|
|
|
15262
15274
|
/**
|
|
15263
15275
|
* ```js
|
|
15264
15276
|
* import { UserRepository } from '@amityco/ts-sdk'
|
|
15277
|
+
*
|
|
15278
|
+
* // Typeless report (supported).
|
|
15265
15279
|
* const flagged = await UserRepository.flagUser('userId')
|
|
15266
|
-
* const flaggedBehavior = await UserRepository.flagUser('userId', {
|
|
15267
|
-
* reportType: 'behavior',
|
|
15268
|
-
* reason: 'Harassment or bullying',
|
|
15269
|
-
* comment: 'optional free-text',
|
|
15270
|
-
* })
|
|
15271
15280
|
* ```
|
|
15272
15281
|
*
|
|
15282
|
+
* Flags a user. Two call shapes are accepted (see the overloads): id-only, which
|
|
15283
|
+
* sends no body and stays supported, and the deprecated structured options object,
|
|
15284
|
+
* whose request mapping is unchanged. New code reporting a profile field or behavior
|
|
15285
|
+
* should use `flagUserProfile` or `flagUserBehavior`.
|
|
15286
|
+
*
|
|
15273
15287
|
* @param userId The ID of the user to be flagged
|
|
15274
|
-
* @param options
|
|
15275
|
-
* body: `reportType`, `reason`, `comment`. Only non-null fields are included.
|
|
15276
|
-
* All validation is server-side; a bodyless call produces a typeless report.
|
|
15288
|
+
* @param options Deprecated report metadata; omit for a typeless report
|
|
15277
15289
|
* @returns the flagged {@link Amity.User}
|
|
15278
15290
|
*
|
|
15279
15291
|
* @category User API
|
|
@@ -15294,6 +15306,156 @@ const flagUser = async (userId, options) => {
|
|
|
15294
15306
|
};
|
|
15295
15307
|
/* end_public_function */
|
|
15296
15308
|
|
|
15309
|
+
/**
|
|
15310
|
+
* Sends a validated split user report (`flagUserProfile` / `flagUserBehavior`) to the
|
|
15311
|
+
* same endpoint as `flagUser`, then persists the returned user and fires `user.flagged`
|
|
15312
|
+
* exactly as `flagUser` does, so all three calls share return, cache and event behaviour.
|
|
15313
|
+
*
|
|
15314
|
+
* Not exported from the public API.
|
|
15315
|
+
*/
|
|
15316
|
+
const submitUserReport = async (apiName, userId, body) => {
|
|
15317
|
+
var _a;
|
|
15318
|
+
const client = getActiveClient();
|
|
15319
|
+
client.log(`user/${apiName}`, { userId, body });
|
|
15320
|
+
const { data } = await client.http.post(`/api/v4/me/flags/${encodeURIComponent(userId)}`, body);
|
|
15321
|
+
const payload = prepareUserPayload(data);
|
|
15322
|
+
if (client.cache) {
|
|
15323
|
+
ingestInCache(payload);
|
|
15324
|
+
}
|
|
15325
|
+
fireEvent('user.flagged', data);
|
|
15326
|
+
return (_a = payload.users.find(user => user.userId === userId)) !== null && _a !== void 0 ? _a : payload.users[0];
|
|
15327
|
+
};
|
|
15328
|
+
|
|
15329
|
+
/** Maximum `comment` length, in string length units, after trimming. */
|
|
15330
|
+
const USER_REPORT_COMMENT_MAX_LENGTH = 300;
|
|
15331
|
+
const PROFILE_FIELDS = Object.values(UserProfileFieldEnum);
|
|
15332
|
+
const BEHAVIOR_REASONS = Object.values(ContentFlagReasonEnum);
|
|
15333
|
+
const assertOptionsObject = (apiName, options, shape) => {
|
|
15334
|
+
if (typeof options !== 'object' || options === null || Array.isArray(options)) {
|
|
15335
|
+
throw new ASCInvalidParameterError(`${apiName}: expected an options object \`${shape}\``);
|
|
15336
|
+
}
|
|
15337
|
+
return options;
|
|
15338
|
+
};
|
|
15339
|
+
/**
|
|
15340
|
+
* Normalizes an optional reporter `comment`: it must be a string when supplied (`null`
|
|
15341
|
+
* is not a valid supplied comment); it is trimmed; a blank result is omitted (the
|
|
15342
|
+
* backend rejects `""`); a result longer than 300 characters is rejected before any
|
|
15343
|
+
* request. Otherwise the trimmed text is returned unchanged.
|
|
15344
|
+
*
|
|
15345
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` for a non-string or over-length comment
|
|
15346
|
+
*/
|
|
15347
|
+
const normalizeUserReportComment = (apiName, comment) => {
|
|
15348
|
+
if (comment === undefined)
|
|
15349
|
+
return undefined;
|
|
15350
|
+
if (typeof comment !== 'string') {
|
|
15351
|
+
throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be a string when supplied`);
|
|
15352
|
+
}
|
|
15353
|
+
const trimmed = comment.trim();
|
|
15354
|
+
if (trimmed.length === 0)
|
|
15355
|
+
return undefined;
|
|
15356
|
+
if (trimmed.length > USER_REPORT_COMMENT_MAX_LENGTH) {
|
|
15357
|
+
throw new ASCInvalidParameterError(`${apiName}: \`comment\` must be at most ${USER_REPORT_COMMENT_MAX_LENGTH} characters after trimming`);
|
|
15358
|
+
}
|
|
15359
|
+
return trimmed;
|
|
15360
|
+
};
|
|
15361
|
+
const withComment = (body, comment) => comment === undefined ? body : Object.assign(Object.assign({}, body), { comment });
|
|
15362
|
+
/**
|
|
15363
|
+
* Validates `flagUserProfile` options and builds its request body. Untyped callers can
|
|
15364
|
+
* pass anything at runtime, so nothing is trusted from the declared type. Any `reason`
|
|
15365
|
+
* key is ignored and never sent.
|
|
15366
|
+
*
|
|
15367
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
15368
|
+
*/
|
|
15369
|
+
const toUserProfileReportBody = (options) => {
|
|
15370
|
+
const apiName = 'flagUserProfile';
|
|
15371
|
+
const { field, comment } = assertOptionsObject(apiName, options, '{ field, comment? }');
|
|
15372
|
+
if (typeof field !== 'string' || !PROFILE_FIELDS.includes(field)) {
|
|
15373
|
+
throw new ASCInvalidParameterError(`${apiName}: \`field\` must be a \`UserProfileFieldEnum\` value`);
|
|
15374
|
+
}
|
|
15375
|
+
return withComment({ reportType: field }, normalizeUserReportComment(apiName, comment));
|
|
15376
|
+
};
|
|
15377
|
+
/**
|
|
15378
|
+
* Validates `flagUserBehavior` options and builds its request body. `reason` must be one
|
|
15379
|
+
* of the nine `ContentFlagReasonEnum` values and is sent as that canonical label;
|
|
15380
|
+
* `reportType` is always `behavior`.
|
|
15381
|
+
*
|
|
15382
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when the options are malformed
|
|
15383
|
+
*/
|
|
15384
|
+
const toUserBehaviorReportBody = (options) => {
|
|
15385
|
+
const apiName = 'flagUserBehavior';
|
|
15386
|
+
const { reason, comment } = assertOptionsObject(apiName, options, '{ reason, comment? }');
|
|
15387
|
+
if (typeof reason !== 'string' || !BEHAVIOR_REASONS.includes(reason)) {
|
|
15388
|
+
throw new ASCInvalidParameterError(`${apiName}: \`reason\` must be a \`ContentFlagReasonEnum\` value`);
|
|
15389
|
+
}
|
|
15390
|
+
return withComment({ reportType: 'behavior', reason }, normalizeUserReportComment(apiName, comment));
|
|
15391
|
+
};
|
|
15392
|
+
|
|
15393
|
+
/* begin_public_function
|
|
15394
|
+
id: user.flag_profile
|
|
15395
|
+
*/
|
|
15396
|
+
/**
|
|
15397
|
+
* ```js
|
|
15398
|
+
* import { UserRepository, UserProfileFieldEnum } from '@amityco/ts-sdk'
|
|
15399
|
+
* const flagged = await UserRepository.flagUserProfile('userId', {
|
|
15400
|
+
* field: UserProfileFieldEnum.AVATAR,
|
|
15401
|
+
* comment: 'Nudity in profile photo',
|
|
15402
|
+
* })
|
|
15403
|
+
* ```
|
|
15404
|
+
*
|
|
15405
|
+
* Reports one of a user's profile fields (display name, description or avatar). The
|
|
15406
|
+
* call has no reason: profile reports never carry one, so the backend's reason rules
|
|
15407
|
+
* cannot be violated from here. A `reason` key passed at runtime is ignored and never sent.
|
|
15408
|
+
*
|
|
15409
|
+
* `comment` is trimmed; a blank comment is omitted from the request; a comment longer
|
|
15410
|
+
* than 300 characters after trimming is rejected before any request. Otherwise the
|
|
15411
|
+
* trimmed text is sent unchanged.
|
|
15412
|
+
*
|
|
15413
|
+
* Sends `POST /api/v4/me/flags/:userId` with `{ reportType: <field>, comment? }`.
|
|
15414
|
+
*
|
|
15415
|
+
* @param userId The ID of the user to be reported
|
|
15416
|
+
* @param options `field` is a `UserProfileFieldEnum` value; `comment` is optional free text
|
|
15417
|
+
* @returns the flagged {@link Amity.User}
|
|
15418
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, or `comment` is over 300 characters, before any request is made
|
|
15419
|
+
*
|
|
15420
|
+
* @category User API
|
|
15421
|
+
* @async
|
|
15422
|
+
* */
|
|
15423
|
+
const flagUserProfile = async (userId, options) => submitUserReport('flagUserProfile', userId, toUserProfileReportBody(options));
|
|
15424
|
+
/* end_public_function */
|
|
15425
|
+
|
|
15426
|
+
/* begin_public_function
|
|
15427
|
+
id: user.flag_behavior
|
|
15428
|
+
*/
|
|
15429
|
+
/**
|
|
15430
|
+
* ```js
|
|
15431
|
+
* import { UserRepository, ContentFlagReasonEnum } from '@amityco/ts-sdk'
|
|
15432
|
+
* const flagged = await UserRepository.flagUserBehavior('userId', {
|
|
15433
|
+
* reason: ContentFlagReasonEnum.Others,
|
|
15434
|
+
* comment: 'Impersonating our brand',
|
|
15435
|
+
* })
|
|
15436
|
+
* ```
|
|
15437
|
+
*
|
|
15438
|
+
* Reports a user's behavior. `reason` is required and is one of the nine
|
|
15439
|
+
* `ContentFlagReasonEnum` values, sent as its canonical label. Reporter text, including
|
|
15440
|
+
* the explanation for `Others`, always travels in `comment`; the reason never carries text.
|
|
15441
|
+
*
|
|
15442
|
+
* `comment` is trimmed; a blank comment is omitted from the request; a comment longer
|
|
15443
|
+
* than 300 characters after trimming is rejected before any request. Otherwise the
|
|
15444
|
+
* trimmed text is sent unchanged.
|
|
15445
|
+
*
|
|
15446
|
+
* Sends `POST /api/v4/me/flags/:userId` with `{ reportType: 'behavior', reason, comment? }`.
|
|
15447
|
+
*
|
|
15448
|
+
* @param userId The ID of the user to be reported
|
|
15449
|
+
* @param options `reason` is a `ContentFlagReasonEnum` value; `comment` is optional free text
|
|
15450
|
+
* @returns the flagged {@link Amity.User}
|
|
15451
|
+
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is missing or malformed, `reason` is missing or unknown, or `comment` is over 300 characters, before any request is made
|
|
15452
|
+
*
|
|
15453
|
+
* @category User API
|
|
15454
|
+
* @async
|
|
15455
|
+
* */
|
|
15456
|
+
const flagUserBehavior = async (userId, options) => submitUserReport('flagUserBehavior', userId, toUserBehaviorReportBody(options));
|
|
15457
|
+
/* end_public_function */
|
|
15458
|
+
|
|
15297
15459
|
/* begin_public_function
|
|
15298
15460
|
id: user.unflag
|
|
15299
15461
|
*/
|
|
@@ -16468,6 +16630,8 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
16468
16630
|
getUserByIds: getUserByIds,
|
|
16469
16631
|
updateUser: updateUser,
|
|
16470
16632
|
flagUser: flagUser,
|
|
16633
|
+
flagUserProfile: flagUserProfile,
|
|
16634
|
+
flagUserBehavior: flagUserBehavior,
|
|
16471
16635
|
unflagUser: unflagUser,
|
|
16472
16636
|
isUserFlaggedByMe: isUserFlaggedByMe,
|
|
16473
16637
|
getAllBlockedUsers: getAllBlockedUsers,
|
|
@@ -20220,9 +20384,11 @@ const toContentFlagBody = ({ reason, detail }) => detail === undefined ? { reaso
|
|
|
20220
20384
|
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
20221
20385
|
*/
|
|
20222
20386
|
const flagMessageWithOptions = async (messageId, options) => {
|
|
20387
|
+
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
20388
|
+
// whether a client is active, and validation needs nothing from the client.
|
|
20389
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
|
|
20223
20390
|
const client = getActiveClient();
|
|
20224
20391
|
client.log('message/flag', messageId);
|
|
20225
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagMessage', options));
|
|
20226
20392
|
const { data: payload } = await client.http.post(`/api/v5/messages/${encodeURIComponent(messageId)}/flags`, body);
|
|
20227
20393
|
if (client.cache) {
|
|
20228
20394
|
const messagePayload = await prepareMessagePayload(payload);
|
|
@@ -27488,9 +27654,11 @@ const flagCommentWithReasonString = async (commentId, reason) => {
|
|
|
27488
27654
|
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
27489
27655
|
*/
|
|
27490
27656
|
const flagCommentWithOptions = async (commentId, options) => {
|
|
27657
|
+
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
27658
|
+
// whether a client is active, and validation needs nothing from the client.
|
|
27659
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
|
|
27491
27660
|
const client = getActiveClient();
|
|
27492
27661
|
client.log('comment/flagComment', commentId);
|
|
27493
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagComment', options));
|
|
27494
27662
|
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
27495
27663
|
if (client.cache) {
|
|
27496
27664
|
ingestInCache(payload);
|
|
@@ -29899,9 +30067,11 @@ const declinePost = async (postId) => {
|
|
|
29899
30067
|
* @throws {ASCInvalidParameterError} `INVALID_PARAMETERS` when `options` is malformed, before any request is made
|
|
29900
30068
|
*/
|
|
29901
30069
|
const flagPostWithOptions = async (postId, options) => {
|
|
30070
|
+
// Validate first: an input error must surface as INVALID_PARAMETERS regardless of
|
|
30071
|
+
// whether a client is active, and validation needs nothing from the client.
|
|
30072
|
+
const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
|
|
29902
30073
|
const client = getActiveClient();
|
|
29903
30074
|
client.log('post/flagPost', postId);
|
|
29904
|
-
const body = toContentFlagBody(validateContentFlagOptions('flagPost', options));
|
|
29905
30075
|
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
29906
30076
|
if (client.cache) {
|
|
29907
30077
|
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
@@ -37356,4 +37526,4 @@ class AmityAttachmentProductTags {
|
|
|
37356
37526
|
}
|
|
37357
37527
|
}
|
|
37358
37528
|
|
|
37359
|
-
export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserReportTypeEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
|
|
37529
|
+
export { API_REGIONS, index$6 as AdRepository, AmityAttachmentProductTags, AmityAutoSubscription, AmityChannelNotificationModeEnum, AmityCommunityType, AmityEventOrderOption, AmityEventOriginType, AmityEventResponseStatus, AmityEventSortOption, AmityEventStatus, AmityEventType, AmityLiveViewerCountMode, AmityModuleNotEntitledError, AmitySharableContentType, AnalyticsSourceTypeEnum, index$g as CategoryRepository, index$k as ChannelRepository, index$t as Client, index$f as CommentRepository, CommunityNotificationEventNameEnum, CommunityPostSettingMaps, CommunityPostSettings, index$h as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, index as CuratedContentRepository, DefaultCommunityPostSetting, index$2 as EventRepository, FeedDataTypeEnum, index$e as FeedRepository, FeedSortByEnum, FeedSourceEnum, FeedTypeEnum, FileAccessTypeEnum, index$q as FileRepository, FileType, GET_WATCHER_URLS, index$4 as InvitationRepository, InvitationSortByEnum, InvitationStatusEnum, InvitationTargetTypeEnum, InvitationTypeEnum, JoinRequestStatusEnum, JoinResultStatusEnum, index$3 as LiveReactionRepository, index$8 as LiveStreamPlayer, MembershipAcceptanceTypeEnum, MessageContentType, index$o as MessageRepository, NotificationRolesFilterTypeEnum, NotificationSettingsLevelEnum, index$9 as PollRepository, PostContentType, index$c as PostRepository, PostStructureType, index$1 as ProductRepository, index$p as ReactionRepository, index$a as RoomPresenceRepository, index$d as RoomRepository, SearchUsersByEnum, index$7 as StoryRepository, index$b as StreamRepository, index$n as SubChannelRepository, SubscriptionLevels, UserNotificationModuleNameEnum, UserProfileFieldEnum, UserReportTypeEnum, index$r as UserRepository, UserTypeEnum, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, exceedsUntilAtBoundary, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, filterByUntilAt, filterCommentsByBlockUsers, filterPostsByBlockUsers, getBlockUsersId, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveReactionTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkId, getNetworkTopic, getPostTopic, getRole, getRoomStreamerTopic, getRoomWatcherTopic, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index$5 as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, resolveModuleAvailability, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, validateUntilAt, wipeCache };
|