@amityco/ts-sdk 7.2.1-eeeca9c0.0 → 7.3.1-56cdb841.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/.eslintrc.json +2 -1
- package/dist/@types/domains/content.d.ts +12 -0
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/commentRepository/api/flagComment.d.ts +3 -2
- package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
- package/dist/index.cjs.js +35 -11
- package/dist/index.esm.js +36 -12
- package/dist/index.umd.js +4 -4
- package/dist/postRepository/api/flagPost.d.ts +3 -2
- package/dist/postRepository/api/flagPost.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/content.ts +16 -0
- package/src/commentRepository/api/flagComment.ts +18 -3
- package/src/notificationTray/api/markItemsSeen.ts +2 -2
- package/src/postRepository/api/flagPost.ts +17 -3
package/.eslintrc.json
CHANGED
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"import/no-unresolved": "off",
|
|
30
30
|
"no-shadow": "off",
|
|
31
31
|
"no-unused-vars": "off",
|
|
32
|
-
"no-console": ["warn", { "allow": ["warn", "error"] }]
|
|
32
|
+
"no-console": ["warn", { "allow": ["warn", "error"] }],
|
|
33
|
+
"@typescript-eslint/ban-types": "off"
|
|
33
34
|
},
|
|
34
35
|
"settings": {
|
|
35
36
|
"import/resolver": {
|
|
@@ -5,8 +5,20 @@ export declare const ContentFeedType: Readonly<{
|
|
|
5
5
|
POST: "post";
|
|
6
6
|
MESSAGE: "message";
|
|
7
7
|
}>;
|
|
8
|
+
export declare enum ContentFlagReasonEnum {
|
|
9
|
+
CommunityGuidelines = "Against community guidelines",
|
|
10
|
+
HarassmentOrBullying = "Harassment or bullying",
|
|
11
|
+
SelfHarmOrSuicide = "Self-harm or suicide",
|
|
12
|
+
ViolenceOrThreateningContent = "Violence or threatening content",
|
|
13
|
+
SellingRestrictedItems = "Selling and promoting restricted items",
|
|
14
|
+
SexualContentOrNudity = "Sexual message or nudity",
|
|
15
|
+
SpamOrScams = "Spam or scams",
|
|
16
|
+
FalseInformation = "False information or misinformation",
|
|
17
|
+
Others = "Others"
|
|
18
|
+
}
|
|
8
19
|
declare global {
|
|
9
20
|
namespace Amity {
|
|
21
|
+
type ContentFlagReason = Exclude<`${ContentFlagReasonEnum}`, `${ContentFlagReasonEnum.Others}`> | (string & {});
|
|
10
22
|
type ContentType = 'text' | 'image' | 'file' | 'video' | 'poll' | 'json' | string;
|
|
11
23
|
type ContentFeedType = ValueOf<typeof ContentFeedType>;
|
|
12
24
|
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,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;QAElF,KAAK,eAAe,GAAG,OAAO,CAAC,OAAO,eAAe,CAAC,CAAC;QAEvD,KAAK,eAAe,GAAG;YACrB,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,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;YACtC,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QAEF,KAAK,UAAU,GAAG;YAChB,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;YACvB,GAAG,CAAC,EAAE,MAAM,CAAC;YACb,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,OAA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F,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,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ```js
|
|
3
3
|
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
4
|
-
* const flagged = await CommentRepository.flagComment(
|
|
4
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
5
5
|
* ```
|
|
6
6
|
*
|
|
7
7
|
* @param commentId The ID of the comment to flag
|
|
8
|
+
* @param reason the reason to flag the comment
|
|
8
9
|
* @returns the created report result
|
|
9
10
|
*
|
|
10
11
|
* @category Comment API
|
|
11
12
|
* @async
|
|
12
13
|
* */
|
|
13
|
-
export declare const flagComment: (commentId: Amity.Comment['commentId']) => Promise<boolean>;
|
|
14
|
+
export declare const flagComment: (commentId: Amity.Comment['commentId'], reason: Amity.ContentFlagReason) => Promise<boolean>;
|
|
14
15
|
//# sourceMappingURL=flagComment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flagComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagComment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flagComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/api/flagComment.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;KAYK;AACL,eAAO,MAAM,WAAW,cACX,aAAa,CAAC,WAAW,CAAC,UAC7B,MAAM,iBAAiB,KAC9B,QAAQ,OAAO,CAyBjB,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -80,7 +80,19 @@ const ContentFeedType = Object.freeze({
|
|
|
80
80
|
CHAT: 'chat',
|
|
81
81
|
POST: 'post',
|
|
82
82
|
MESSAGE: 'message',
|
|
83
|
-
});
|
|
83
|
+
});
|
|
84
|
+
exports.ContentFlagReasonEnum = void 0;
|
|
85
|
+
(function (ContentFlagReasonEnum) {
|
|
86
|
+
ContentFlagReasonEnum["CommunityGuidelines"] = "Against community guidelines";
|
|
87
|
+
ContentFlagReasonEnum["HarassmentOrBullying"] = "Harassment or bullying";
|
|
88
|
+
ContentFlagReasonEnum["SelfHarmOrSuicide"] = "Self-harm or suicide";
|
|
89
|
+
ContentFlagReasonEnum["ViolenceOrThreateningContent"] = "Violence or threatening content";
|
|
90
|
+
ContentFlagReasonEnum["SellingRestrictedItems"] = "Selling and promoting restricted items";
|
|
91
|
+
ContentFlagReasonEnum["SexualContentOrNudity"] = "Sexual message or nudity";
|
|
92
|
+
ContentFlagReasonEnum["SpamOrScams"] = "Spam or scams";
|
|
93
|
+
ContentFlagReasonEnum["FalseInformation"] = "False information or misinformation";
|
|
94
|
+
ContentFlagReasonEnum["Others"] = "Others";
|
|
95
|
+
})(exports.ContentFlagReasonEnum || (exports.ContentFlagReasonEnum = {}));
|
|
84
96
|
|
|
85
97
|
const MessageContentType = Object.freeze({
|
|
86
98
|
TEXT: 'text',
|
|
@@ -102,8 +114,8 @@ const PostContentType = Object.freeze({
|
|
|
102
114
|
|
|
103
115
|
function getVersion() {
|
|
104
116
|
try {
|
|
105
|
-
// the string ''v7.
|
|
106
|
-
return 'v7.
|
|
117
|
+
// the string ''v7.3.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
118
|
+
return 'v7.3.0-cjs';
|
|
107
119
|
}
|
|
108
120
|
catch (error) {
|
|
109
121
|
return '__dev__';
|
|
@@ -21565,19 +21577,25 @@ const declinePost = async (postId) => {
|
|
|
21565
21577
|
/**
|
|
21566
21578
|
* ```js
|
|
21567
21579
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
21568
|
-
* const flagged = await PostRepository.flagPost(postId)
|
|
21580
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
21569
21581
|
* ```
|
|
21570
21582
|
*
|
|
21571
21583
|
* @param postId of the post to flag
|
|
21584
|
+
* @param reason the reason to flag the post
|
|
21572
21585
|
* @returns a boolean
|
|
21573
21586
|
*
|
|
21574
21587
|
* @category Post API
|
|
21575
21588
|
* @async
|
|
21576
21589
|
* */
|
|
21577
|
-
const flagPost = async (postId) => {
|
|
21590
|
+
const flagPost = async (postId, reason) => {
|
|
21578
21591
|
const client = getActiveClient();
|
|
21579
21592
|
client.log('post/flagPost', postId);
|
|
21580
|
-
const
|
|
21593
|
+
const isPredefinedReason = Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
21594
|
+
const body = {
|
|
21595
|
+
reason: isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
21596
|
+
detail: isPredefinedReason ? '' : reason,
|
|
21597
|
+
};
|
|
21598
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
21581
21599
|
if (client.cache) {
|
|
21582
21600
|
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
21583
21601
|
}
|
|
@@ -22040,19 +22058,25 @@ const hardDeleteComment = async (commentId) => {
|
|
|
22040
22058
|
/**
|
|
22041
22059
|
* ```js
|
|
22042
22060
|
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
22043
|
-
* const flagged = await CommentRepository.flagComment(
|
|
22061
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
22044
22062
|
* ```
|
|
22045
22063
|
*
|
|
22046
22064
|
* @param commentId The ID of the comment to flag
|
|
22065
|
+
* @param reason the reason to flag the comment
|
|
22047
22066
|
* @returns the created report result
|
|
22048
22067
|
*
|
|
22049
22068
|
* @category Comment API
|
|
22050
22069
|
* @async
|
|
22051
22070
|
* */
|
|
22052
|
-
const flagComment = async (commentId) => {
|
|
22071
|
+
const flagComment = async (commentId, reason) => {
|
|
22053
22072
|
const client = getActiveClient();
|
|
22054
22073
|
client.log('comment/flagComment', commentId);
|
|
22055
|
-
const
|
|
22074
|
+
const isPredefinedReason = Object.entries(exports.ContentFlagReasonEnum).some(([key, value]) => key !== exports.ContentFlagReasonEnum.Others && value === reason);
|
|
22075
|
+
const body = {
|
|
22076
|
+
reason: isPredefinedReason ? reason : exports.ContentFlagReasonEnum.Others,
|
|
22077
|
+
detail: isPredefinedReason ? '' : reason,
|
|
22078
|
+
};
|
|
22079
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
22056
22080
|
if (client.cache) {
|
|
22057
22081
|
ingestInCache(payload);
|
|
22058
22082
|
}
|
|
@@ -26238,7 +26262,7 @@ const markItemsSeen = async (trayItems) => {
|
|
|
26238
26262
|
lastSeenAt: item.lastSeenAt,
|
|
26239
26263
|
})),
|
|
26240
26264
|
});
|
|
26241
|
-
const updatedData = trayItems
|
|
26265
|
+
const updatedData = payload.trayItems
|
|
26242
26266
|
.map(patchItem => {
|
|
26243
26267
|
var _a;
|
|
26244
26268
|
const cacheData = (_a = pullFromCache([
|
|
@@ -26248,7 +26272,7 @@ const markItemsSeen = async (trayItems) => {
|
|
|
26248
26272
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
26249
26273
|
if (!cacheData)
|
|
26250
26274
|
return;
|
|
26251
|
-
const data = Object.assign(Object.assign({}, cacheData),
|
|
26275
|
+
const data = Object.assign(Object.assign({}, cacheData), { lastSeenAt: patchItem.lastSeenAt });
|
|
26252
26276
|
if (client.cache) {
|
|
26253
26277
|
const cachedAt = Date.now();
|
|
26254
26278
|
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
package/dist/index.esm.js
CHANGED
|
@@ -65,7 +65,19 @@ const ContentFeedType = Object.freeze({
|
|
|
65
65
|
CHAT: 'chat',
|
|
66
66
|
POST: 'post',
|
|
67
67
|
MESSAGE: 'message',
|
|
68
|
-
});
|
|
68
|
+
});
|
|
69
|
+
var ContentFlagReasonEnum;
|
|
70
|
+
(function (ContentFlagReasonEnum) {
|
|
71
|
+
ContentFlagReasonEnum["CommunityGuidelines"] = "Against community guidelines";
|
|
72
|
+
ContentFlagReasonEnum["HarassmentOrBullying"] = "Harassment or bullying";
|
|
73
|
+
ContentFlagReasonEnum["SelfHarmOrSuicide"] = "Self-harm or suicide";
|
|
74
|
+
ContentFlagReasonEnum["ViolenceOrThreateningContent"] = "Violence or threatening content";
|
|
75
|
+
ContentFlagReasonEnum["SellingRestrictedItems"] = "Selling and promoting restricted items";
|
|
76
|
+
ContentFlagReasonEnum["SexualContentOrNudity"] = "Sexual message or nudity";
|
|
77
|
+
ContentFlagReasonEnum["SpamOrScams"] = "Spam or scams";
|
|
78
|
+
ContentFlagReasonEnum["FalseInformation"] = "False information or misinformation";
|
|
79
|
+
ContentFlagReasonEnum["Others"] = "Others";
|
|
80
|
+
})(ContentFlagReasonEnum || (ContentFlagReasonEnum = {}));
|
|
69
81
|
|
|
70
82
|
const MessageContentType = Object.freeze({
|
|
71
83
|
TEXT: 'text',
|
|
@@ -87,8 +99,8 @@ const PostContentType = Object.freeze({
|
|
|
87
99
|
|
|
88
100
|
function getVersion() {
|
|
89
101
|
try {
|
|
90
|
-
// the string ''v7.
|
|
91
|
-
return 'v7.
|
|
102
|
+
// the string ''v7.3.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
103
|
+
return 'v7.3.0-esm';
|
|
92
104
|
}
|
|
93
105
|
catch (error) {
|
|
94
106
|
return '__dev__';
|
|
@@ -37657,19 +37669,25 @@ const declinePost = async (postId) => {
|
|
|
37657
37669
|
/**
|
|
37658
37670
|
* ```js
|
|
37659
37671
|
* import { PostRepository } from '@amityco/ts-sdk'
|
|
37660
|
-
* const flagged = await PostRepository.flagPost(postId)
|
|
37672
|
+
* const flagged = await PostRepository.flagPost(postId, reason)
|
|
37661
37673
|
* ```
|
|
37662
37674
|
*
|
|
37663
37675
|
* @param postId of the post to flag
|
|
37676
|
+
* @param reason the reason to flag the post
|
|
37664
37677
|
* @returns a boolean
|
|
37665
37678
|
*
|
|
37666
37679
|
* @category Post API
|
|
37667
37680
|
* @async
|
|
37668
37681
|
* */
|
|
37669
|
-
const flagPost = async (postId) => {
|
|
37682
|
+
const flagPost = async (postId, reason) => {
|
|
37670
37683
|
const client = getActiveClient();
|
|
37671
37684
|
client.log('post/flagPost', postId);
|
|
37672
|
-
const
|
|
37685
|
+
const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
37686
|
+
const body = {
|
|
37687
|
+
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
37688
|
+
detail: isPredefinedReason ? '' : reason,
|
|
37689
|
+
};
|
|
37690
|
+
const { data: payload } = await client.http.post(`/api/v3/posts/${encodeURIComponent(postId)}/flag`, body);
|
|
37673
37691
|
if (client.cache) {
|
|
37674
37692
|
ingestInCache(prepareMembershipPayload(payload, 'communityUsers'));
|
|
37675
37693
|
}
|
|
@@ -38132,19 +38150,25 @@ const hardDeleteComment = async (commentId) => {
|
|
|
38132
38150
|
/**
|
|
38133
38151
|
* ```js
|
|
38134
38152
|
* import { CommentRepository } from '@amityco/ts-sdk'
|
|
38135
|
-
* const flagged = await CommentRepository.flagComment(
|
|
38153
|
+
* const flagged = await CommentRepository.flagComment(commentId, reason)
|
|
38136
38154
|
* ```
|
|
38137
38155
|
*
|
|
38138
38156
|
* @param commentId The ID of the comment to flag
|
|
38157
|
+
* @param reason the reason to flag the comment
|
|
38139
38158
|
* @returns the created report result
|
|
38140
38159
|
*
|
|
38141
38160
|
* @category Comment API
|
|
38142
38161
|
* @async
|
|
38143
38162
|
* */
|
|
38144
|
-
const flagComment = async (commentId) => {
|
|
38163
|
+
const flagComment = async (commentId, reason) => {
|
|
38145
38164
|
const client = getActiveClient();
|
|
38146
38165
|
client.log('comment/flagComment', commentId);
|
|
38147
|
-
const
|
|
38166
|
+
const isPredefinedReason = Object.entries(ContentFlagReasonEnum).some(([key, value]) => key !== ContentFlagReasonEnum.Others && value === reason);
|
|
38167
|
+
const body = {
|
|
38168
|
+
reason: isPredefinedReason ? reason : ContentFlagReasonEnum.Others,
|
|
38169
|
+
detail: isPredefinedReason ? '' : reason,
|
|
38170
|
+
};
|
|
38171
|
+
const { data: payload } = await client.http.post(`/api/v3/comments/${encodeURIComponent(commentId)}/flag`, body);
|
|
38148
38172
|
if (client.cache) {
|
|
38149
38173
|
ingestInCache(payload);
|
|
38150
38174
|
}
|
|
@@ -42330,7 +42354,7 @@ const markItemsSeen = async (trayItems) => {
|
|
|
42330
42354
|
lastSeenAt: item.lastSeenAt,
|
|
42331
42355
|
})),
|
|
42332
42356
|
});
|
|
42333
|
-
const updatedData = trayItems
|
|
42357
|
+
const updatedData = payload.trayItems
|
|
42334
42358
|
.map(patchItem => {
|
|
42335
42359
|
var _a;
|
|
42336
42360
|
const cacheData = (_a = pullFromCache([
|
|
@@ -42340,7 +42364,7 @@ const markItemsSeen = async (trayItems) => {
|
|
|
42340
42364
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
42341
42365
|
if (!cacheData)
|
|
42342
42366
|
return;
|
|
42343
|
-
const data = Object.assign(Object.assign({}, cacheData),
|
|
42367
|
+
const data = Object.assign(Object.assign({}, cacheData), { lastSeenAt: patchItem.lastSeenAt });
|
|
42344
42368
|
if (client.cache) {
|
|
42345
42369
|
const cachedAt = Date.now();
|
|
42346
42370
|
pushToCache(['notificationTrayItem', 'get'], data, { cachedAt });
|
|
@@ -42408,4 +42432,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
42408
42432
|
onNotificationTraySeenUpdated: onNotificationTraySeenUpdated
|
|
42409
42433
|
});
|
|
42410
42434
|
|
|
42411
|
-
export { API_REGIONS, index$1 as AdRepository, index$9 as CategoryRepository, index$d as ChannelRepository, index$m as Client, index$7 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$a as CommunityRepository, ContentFeedType, DefaultCommunityPostSetting, index$8 as FeedRepository, FileAccessTypeEnum, index$j as FileRepository, FileType, index$3 as LiveStreamPlayer, MessageContentType, index$h as MessageRepository, index$4 as PollRepository, PostContentType, index$6 as PostRepository, index$i as ReactionRepository, index$2 as StoryRepository, index$5 as StreamRepository, index$g as SubChannelRepository, SubscriptionLevels, index$k as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|
|
42435
|
+
export { API_REGIONS, index$1 as AdRepository, index$9 as CategoryRepository, index$d as ChannelRepository, index$m as Client, index$7 as CommentRepository, CommunityPostSettingMaps, CommunityPostSettings, index$a as CommunityRepository, ContentFeedType, ContentFlagReasonEnum, DefaultCommunityPostSetting, index$8 as FeedRepository, FileAccessTypeEnum, index$j as FileRepository, FileType, index$3 as LiveStreamPlayer, MessageContentType, index$h as MessageRepository, index$4 as PollRepository, PostContentType, index$6 as PostRepository, index$i as ReactionRepository, index$2 as StoryRepository, index$5 as StreamRepository, index$g as SubChannelRepository, SubscriptionLevels, index$k as UserRepository, VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, backupCache, createQuery, createReport, createUserToken, deleteReport, disableCache, dropFromCache, enableCache, filterByChannelMembership, filterByCommunityMembership, filterByFeedType, filterByPostDataTypes, filterByPropEquality, filterByPropInclusion, filterByPropIntersection, filterBySearchTerm, filterByStringComparePartially, getChannelTopic, getCommentTopic, getCommunityStoriesTopic, getCommunityTopic, getLiveStreamTopic, getMarkedMessageTopic, getMarkerUserFeedTopic, getMessageTopic, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPostTopic, getRole, getSmartFeedChannelTopic, getSmartFeedMessageTopic, getSmartFeedSubChannelTopic, getStoryTopic, getSubChannelTopic, getUserTopic, isAfterBefore, isAfterBeforeRaw, isCachable, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkip, mergeInCache, index as notificationTray, onChannelMarkerFetched, onFeedMarkerFetched, onFeedMarkerUpdated, onMessageMarked, onMessageMarkerFetched, onSubChannelMarkerFetched, onSubChannelMarkerUpdated, onUserMarkerFetched, onUserMarkerFetchedLegacy, pullFromCache, pushToCache, queryCache, queryOptions, queryRoles, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByFirstUpdated, sortByLastActivity, sortByLastCreated, sortByLastUpdated, sortByLocalSortingDate, sortByName, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, upsertInCache, wipeCache };
|