@amityco/ts-sdk 6.2.0 → 6.2.1-25dfe5d.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/channelRepsitory/api/markAsRead.d.ts +1 -1
- package/dist/channelRepsitory/api/muteChannel.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts +16 -0
- package/dist/communityRepository/communityModeration/api/banMembers.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/api/index.d.ts +2 -0
- package/dist/communityRepository/communityModeration/api/index.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/api/test/banMembers.test.d.ts +2 -0
- package/dist/communityRepository/communityModeration/api/test/banMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/api/test/unbanMembers.test.d.ts +2 -0
- package/dist/communityRepository/communityModeration/api/test/unbanMembers.test.d.ts.map +1 -0
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts +16 -0
- package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts.map +1 -0
- package/dist/core/query/filtering.d.ts +1 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/core/query/sorting.d.ts.map +1 -1
- package/dist/index.cjs.js +129 -41
- package/dist/index.esm.js +129 -42
- package/dist/index.umd.js +4 -4
- package/dist/messageRepository/api/markAsDelivered.d.ts +2 -2
- package/dist/userRepository/{relationship/block/api → api}/queryBlockedUsers.d.ts +2 -2
- package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -0
- package/dist/userRepository/api/tests/queryBlockedUsers.test.d.ts.map +1 -0
- package/dist/userRepository/observers/getBlockedUsers.d.ts +2 -0
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -0
- package/dist/userRepository/observers/index.d.ts +1 -0
- package/dist/userRepository/observers/index.d.ts.map +1 -1
- package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/categoryRepository/observers/getCategories.ts +3 -3
- package/src/channelRepsitory/api/markAsRead.ts +1 -1
- package/src/channelRepsitory/api/muteChannel.ts +8 -0
- package/src/channelRepsitory/api/tests/muteChannel.test.ts +12 -0
- package/src/channelRepsitory/channelMembership/observers/getMembers.ts +5 -5
- package/src/channelRepsitory/observers/getChannels.ts +3 -3
- package/src/communityRepository/communityMembership/observers/getMembers.ts +5 -7
- package/src/communityRepository/communityModeration/api/banMembers.ts +50 -0
- package/src/communityRepository/communityModeration/api/index.ts +4 -0
- package/src/communityRepository/communityModeration/api/test/banMembers.test.ts +70 -0
- package/src/communityRepository/communityModeration/api/test/unbanMembers.test.ts +70 -0
- package/src/communityRepository/communityModeration/api/unbanMembers.ts +50 -0
- package/src/communityRepository/observers/getCommunities.ts +3 -3
- package/src/core/query/filtering.ts +22 -2
- package/src/core/query/sorting.ts +2 -4
- package/src/core/query/tests/filtering.test.ts +6 -0
- package/src/messageRepository/api/markAsDelivered.ts +2 -2
- package/src/messageRepository/observers/getMessages.ts +1 -1
- package/src/userRepository/{relationship/block/api → api}/queryBlockedUsers.ts +3 -2
- package/src/userRepository/{relationship/block/api → api}/tests/queryBlockedUsers.test.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers.ts +104 -0
- package/src/userRepository/observers/getUsers.ts +3 -3
- package/src/userRepository/observers/index.ts +1 -0
- package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +5 -96
- package/dist/userRepository/relationship/block/api/queryBlockedUsers.d.ts.map +0 -1
- package/dist/userRepository/relationship/block/api/tests/queryBlockedUsers.test.d.ts.map +0 -1
- /package/dist/userRepository/{relationship/block/api → api}/tests/queryBlockedUsers.test.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"muteChannel.d.ts","sourceRoot":"","sources":["../../../src/channelRepsitory/api/muteChannel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"muteChannel.d.ts","sourceRoot":"","sources":["../../../src/channelRepsitory/api/muteChannel.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,cACX,MAAM,OAAO,CAAC,WAAW,CAAC,0BAEpC,QAAQ,OAAO,CAmBjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMembers.d.ts","sourceRoot":"","sources":["../../../../src/communityRepository/communityMembership/observers/getMembers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMembers.d.ts","sourceRoot":"","sources":["../../../../src/communityRepository/communityMembership/observers/getMembers.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,WACb,MAAM,6BAA6B,YACjC,MAAM,sBAAsB,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,WAC5D,MAAM,oBAAoB,eA8HpC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
4
|
+
*
|
|
5
|
+
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
9
|
+
* @param userIds of the {@link Amity.User}'s to be banned
|
|
10
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
11
|
+
*
|
|
12
|
+
* @category Community API
|
|
13
|
+
* @async
|
|
14
|
+
* */
|
|
15
|
+
export declare const banMembers: (communityId: Amity.Community['communityId'], userIds: Amity.User['userId'][]) => Promise<Amity.Cached<Amity.Membership<'community'>[]>>;
|
|
16
|
+
//# sourceMappingURL=banMembers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banMembers.d.ts","sourceRoot":"","sources":["../../../../src/communityRepository/communityModeration/api/banMembers.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;KAaK;AACL,eAAO,MAAM,UAAU,gBACR,MAAM,SAAS,CAAC,aAAa,CAAC,WAClC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,KAC9B,QAAQ,MAAM,MAAM,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAsBvD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/communityRepository/communityModeration/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/communityRepository/communityModeration/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"banMembers.test.d.ts","sourceRoot":"","sources":["../../../../../src/communityRepository/communityModeration/api/test/banMembers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unbanMembers.test.d.ts","sourceRoot":"","sources":["../../../../../src/communityRepository/communityModeration/api/test/unbanMembers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ```js
|
|
3
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
4
|
+
*
|
|
5
|
+
* await CommunityRepository.Moderation.unbanMembers('communityId', ['userId1', 'userId2'])
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* @param communityId of {@link Amity.Community} from which the users should be unbanned
|
|
9
|
+
* @param userIds of the {@link Amity.User}'s to be unbanned
|
|
10
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
11
|
+
*
|
|
12
|
+
* @category Community API
|
|
13
|
+
* @async
|
|
14
|
+
* */
|
|
15
|
+
export declare const unbanMembers: (communityId: Amity.Community['communityId'], userIds: Amity.User['userId'][]) => Promise<Amity.Cached<Amity.Membership<'community'>[]>>;
|
|
16
|
+
//# sourceMappingURL=unbanMembers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unbanMembers.d.ts","sourceRoot":"","sources":["../../../../src/communityRepository/communityModeration/api/unbanMembers.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;KAaK;AACL,eAAO,MAAM,YAAY,gBACV,MAAM,SAAS,CAAC,aAAa,CAAC,WAClC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,KAC9B,QAAQ,MAAM,MAAM,CAAC,MAAM,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC,CAsBvD,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const filterByPropEquality: <T = Record<string, unknown>>(collection: T[], key: keyof T, value: any) => T[];
|
|
12
12
|
export declare const filterByPropInclusion: <T = Record<string, unknown>>(collection: T[], key: keyof T, value: any[] | undefined) => T[];
|
|
13
|
+
export declare const filterByPropIntersection: <T extends Record<string, unknown>>(collection: T[], key: keyof T, values: any[] | undefined) => T[];
|
|
13
14
|
/**
|
|
14
15
|
* Filter a channel collection by membership of the userId
|
|
15
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,
|
|
1
|
+
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAII,CAAC;AAEjB,eAAO,MAAM,qBAAqB,sEAGzB,GAAG,EAAE,GAAG,SAAS,QACoE,CAAC;AAE/F,eAAO,MAAM,wBAAwB,6EAG3B,GAAG,EAAE,GAAG,SAAS,QAQ1B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,eACxB,MAAM,OAAO,EAAE,cACf,MAAM,qBAAqB,CAAC,YAAY,CAAC,UAC7C,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAC5C,MAAM,OAAO,EAyBf,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,yDAEjB,MAAM,IAAI,CAAC,UAAU,CAAC,QAgBjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,2DAE1B,MAAM,uBAAuB,CAAC,YAAY,CAAC,UAC/C,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QA0BhD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,0DAErB,MAAM,kBAAkB,CAAC,WAAW,CAAC,QAyBjD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB;YAAwB,MAAM,IAAI,CAAC,QAAQ,CAAC;;gCAE7D,MAAM,QAanB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../../../src/core/query/sorting.ts"],"names":[],"mappings":"AAIA,aAAK,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAMlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"sorting.d.ts","sourceRoot":"","sources":["../../../src/core/query/sorting.ts"],"names":[],"mappings":"AAIA,aAAK,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC;AAEvE;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAMlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CACjC,CAAC;AAErB;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAG/D,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAG7D,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC;IAAE,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,CAGhC,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC;IAAE,SAAS,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,CAG/B,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC;IAAE,YAAY,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;CAAE,CAGnC,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1081,8 +1081,15 @@ const dropFromCache = (key, exact = false) => {
|
|
|
1081
1081
|
*
|
|
1082
1082
|
* @hidden
|
|
1083
1083
|
*/
|
|
1084
|
-
const filterByPropEquality = (collection, key, value) =>
|
|
1084
|
+
const filterByPropEquality = (collection, key, value) => value !== undefined
|
|
1085
|
+
? collection.filter(item => JSON.stringify(item[key]) === JSON.stringify(value))
|
|
1086
|
+
: collection;
|
|
1085
1087
|
const filterByPropInclusion = (collection, key, value) => (value !== undefined ? collection.filter(item => value.includes(item[key])) : collection);
|
|
1088
|
+
const filterByPropIntersection = (collection, key, values) => {
|
|
1089
|
+
if (!(values === null || values === void 0 ? void 0 : values.length))
|
|
1090
|
+
return collection;
|
|
1091
|
+
return collection.filter(item => Array.isArray(item[key]) && values.some(value => item[key].includes(value)));
|
|
1092
|
+
};
|
|
1086
1093
|
/**
|
|
1087
1094
|
* Filter a channel collection by membership of the userId
|
|
1088
1095
|
*
|
|
@@ -1216,7 +1223,11 @@ const filterByPostDataTypes = (collection, dataTypes) => {
|
|
|
1216
1223
|
* @hidden
|
|
1217
1224
|
*/
|
|
1218
1225
|
const filterBySearchTerm = (collection, searchTerm) => {
|
|
1219
|
-
|
|
1226
|
+
/*
|
|
1227
|
+
* Search term should match regardless of the case.
|
|
1228
|
+
* Hence, the flag "i", is passed to the created regex
|
|
1229
|
+
*/
|
|
1230
|
+
const containsMatcher = new RegExp(searchTerm, 'i');
|
|
1220
1231
|
return collection.filter(m => {
|
|
1221
1232
|
var _a;
|
|
1222
1233
|
if (m.userId.match(containsMatcher))
|
|
@@ -1239,11 +1250,7 @@ const sortByDisplayName = ({ displayName: a }, { displayName: b }) => {
|
|
|
1239
1250
|
/**
|
|
1240
1251
|
* Alphabetic sorting of objects having a name
|
|
1241
1252
|
*/
|
|
1242
|
-
const sortByName = ({ name: a }, { name: b }) =>
|
|
1243
|
-
if (a === b)
|
|
1244
|
-
return 0;
|
|
1245
|
-
return a < b ? -1 : 1;
|
|
1246
|
-
};
|
|
1253
|
+
const sortByName = ({ name: a }, { name: b }) => a.localeCompare(b);
|
|
1247
1254
|
/**
|
|
1248
1255
|
* Sorting a collection by their apparition order (oldest first)
|
|
1249
1256
|
*/
|
|
@@ -23008,8 +23015,8 @@ const unBlockUser = async (userId) => {
|
|
|
23008
23015
|
|
|
23009
23016
|
/**
|
|
23010
23017
|
* ```js
|
|
23011
|
-
* import {
|
|
23012
|
-
* const { data: users, prevPage, nextPage, total } = await queryBlockedUsers({ page: Amity.PageRaw, limit: number })
|
|
23018
|
+
* import { UserRepository } from '@amityco/ts-sdk'
|
|
23019
|
+
* const { data: users, prevPage, nextPage, total } = await UserRepository.queryBlockedUsers({ page: Amity.PageRaw, limit: number })
|
|
23013
23020
|
* ```
|
|
23014
23021
|
*
|
|
23015
23022
|
* @param query The query parameters
|
|
@@ -23084,7 +23091,7 @@ queryBlockedUsers.locally = (query = {}) => {
|
|
|
23084
23091
|
};
|
|
23085
23092
|
|
|
23086
23093
|
/* eslint-disable no-use-before-define */
|
|
23087
|
-
const getBlockedUsers = (params, callback, config) => {
|
|
23094
|
+
const getBlockedUsers$1 = (params, callback, config) => {
|
|
23088
23095
|
const { log, cache } = getActiveClient();
|
|
23089
23096
|
if (!cache) {
|
|
23090
23097
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
@@ -23153,6 +23160,12 @@ const getBlockedUsers = (params, callback, config) => {
|
|
|
23153
23160
|
};
|
|
23154
23161
|
};
|
|
23155
23162
|
|
|
23163
|
+
/* eslint-disable no-use-before-define */
|
|
23164
|
+
const getBlockedUsers = (params, callback, config) => {
|
|
23165
|
+
console.log('Deprecation Notice: UserRepository.Relationship.getBlockedUsers will be deprecated on 9th June 2023, please use UserRepository.getBlockedUsers instead.');
|
|
23166
|
+
return getBlockedUsers$1(params, callback, config);
|
|
23167
|
+
};
|
|
23168
|
+
|
|
23156
23169
|
/* begin_public_function
|
|
23157
23170
|
id: user.relationship.follow
|
|
23158
23171
|
*/
|
|
@@ -24416,11 +24429,11 @@ const getUsers = (params, callback, config) => {
|
|
|
24416
24429
|
pushToCache(cacheKey, collection);
|
|
24417
24430
|
responder(collection);
|
|
24418
24431
|
};
|
|
24419
|
-
const onFetch = () => {
|
|
24432
|
+
const onFetch = (initial = false) => {
|
|
24420
24433
|
var _a, _b, _c;
|
|
24421
24434
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24422
24435
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24423
|
-
if (users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24436
|
+
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24424
24437
|
return;
|
|
24425
24438
|
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
24426
24439
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
@@ -24438,7 +24451,7 @@ const getUsers = (params, callback, config) => {
|
|
|
24438
24451
|
}, queryOptions(policy));
|
|
24439
24452
|
};
|
|
24440
24453
|
disposers.push(onUserUpdated(realtimeRouter()), onUserDeleted(realtimeRouter()), onUserFlagged(realtimeRouter()), onUserUnflagged(realtimeRouter()), onUserFlagCleared(realtimeRouter()));
|
|
24441
|
-
onFetch();
|
|
24454
|
+
onFetch(true);
|
|
24442
24455
|
return () => {
|
|
24443
24456
|
log(`liveUsers(tmpid: ${timestamp}) > dispose`);
|
|
24444
24457
|
disposers.forEach(fn => fn());
|
|
@@ -24498,7 +24511,8 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
24498
24511
|
onUserFlagCleared: onUserFlagCleared,
|
|
24499
24512
|
getUser: getUser,
|
|
24500
24513
|
getUsers: getUsers,
|
|
24501
|
-
observeUser: observeUser
|
|
24514
|
+
observeUser: observeUser,
|
|
24515
|
+
getBlockedUsers: getBlockedUsers$1
|
|
24502
24516
|
});
|
|
24503
24517
|
|
|
24504
24518
|
/* begin_public_function
|
|
@@ -26556,6 +26570,8 @@ const MUTE_FOREVER = -1;
|
|
|
26556
26570
|
const muteChannel = async (channelId, mutePeriod = MUTE_FOREVER) => {
|
|
26557
26571
|
const client = getActiveClient();
|
|
26558
26572
|
client.log('channel/muteChannel', channelId);
|
|
26573
|
+
if (mutePeriod !== MUTE_FOREVER && mutePeriod < 0)
|
|
26574
|
+
throw new ASCError(`Mute Period can only be positive numbers or ${MUTE_FOREVER}(mute forever)`, 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
26559
26575
|
const { data } = await client.http.put(`/api/v2/channel/${encodeURIComponent(channelId)}/mute`, { mutePeriod });
|
|
26560
26576
|
const { success } = data;
|
|
26561
26577
|
return success;
|
|
@@ -26595,7 +26611,7 @@ const unmuteChannel = async (channelId) => {
|
|
|
26595
26611
|
|
|
26596
26612
|
/**
|
|
26597
26613
|
* ```js
|
|
26598
|
-
* import {
|
|
26614
|
+
* import { ChannelRepository } from '@amityco/ts-sdk'
|
|
26599
26615
|
* const success = await ChannelRepository.markAsRead('channelId')
|
|
26600
26616
|
* ```
|
|
26601
26617
|
*
|
|
@@ -27115,11 +27131,11 @@ const getChannels = (params, callback, config) => {
|
|
|
27115
27131
|
pushToCache(cacheKey, collection);
|
|
27116
27132
|
responder(collection);
|
|
27117
27133
|
};
|
|
27118
|
-
const onFetch = () => {
|
|
27134
|
+
const onFetch = (initial = false) => {
|
|
27119
27135
|
var _a, _b, _c;
|
|
27120
27136
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27121
27137
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27122
|
-
if (channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27138
|
+
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27123
27139
|
return;
|
|
27124
27140
|
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27125
27141
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
@@ -27137,7 +27153,7 @@ const getChannels = (params, callback, config) => {
|
|
|
27137
27153
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
27138
27154
|
};
|
|
27139
27155
|
disposers.push(onChannelCreated(realtimeRouter()), onChannelDeleted(realtimeRouter()), onChannelUpdated(realtimeRouter()), onChannelMuted(realtimeRouter()), onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onMessageCreated(() => null));
|
|
27140
|
-
onFetch();
|
|
27156
|
+
onFetch(true);
|
|
27141
27157
|
return () => {
|
|
27142
27158
|
log(`getChannels(tmpid: ${timestamp}) > dispose`);
|
|
27143
27159
|
disposers.forEach(fn => fn());
|
|
@@ -27341,7 +27357,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27341
27357
|
.map(id => pullFromCache(['channelUsers', 'get', id]))
|
|
27342
27358
|
.filter(Boolean)
|
|
27343
27359
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
27344
|
-
channelMembers =
|
|
27360
|
+
channelMembers = filterByPropIntersection(channelMembers, 'roles', params.roles);
|
|
27345
27361
|
if (params.memberships) {
|
|
27346
27362
|
/*
|
|
27347
27363
|
* even though membership includes muted as a possible value
|
|
@@ -27393,11 +27409,11 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27393
27409
|
pushToCache(cacheKey, collection);
|
|
27394
27410
|
responder(collection);
|
|
27395
27411
|
};
|
|
27396
|
-
const onFetch = () => {
|
|
27412
|
+
const onFetch = (initial = false) => {
|
|
27397
27413
|
var _a, _b, _c;
|
|
27398
27414
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27399
27415
|
const channelMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27400
|
-
if (channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27416
|
+
if (!initial && channelMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27401
27417
|
return;
|
|
27402
27418
|
const query = createQuery(queryChannelMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
27403
27419
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
@@ -27415,7 +27431,7 @@ const getMembers$1 = (params, callback, config) => {
|
|
|
27415
27431
|
}, queryOptions(policy));
|
|
27416
27432
|
};
|
|
27417
27433
|
disposers.push(onChannelJoined(realtimeRouter()), onChannelLeft(realtimeRouter()), onChannelMemberAdded(realtimeRouter()), onChannelMemberRemoved(realtimeRouter()), onChannelMemberBanned(realtimeRouter()), onChannelMemberUnbanned(realtimeRouter()));
|
|
27418
|
-
onFetch();
|
|
27434
|
+
onFetch(true);
|
|
27419
27435
|
return () => {
|
|
27420
27436
|
log(`getMembers(tmpid: ${timestamp}) > dispose`);
|
|
27421
27437
|
disposers.forEach(fn => fn());
|
|
@@ -27509,7 +27525,7 @@ const removeRole = async (channelId, roleId, userIds) => {
|
|
|
27509
27525
|
* @category Channel API
|
|
27510
27526
|
* @async
|
|
27511
27527
|
* */
|
|
27512
|
-
const banMembers = async (channelId, userIds) => {
|
|
27528
|
+
const banMembers$1 = async (channelId, userIds) => {
|
|
27513
27529
|
const client = getActiveClient();
|
|
27514
27530
|
client.log('channel/banMembers', { userIds, channelId });
|
|
27515
27531
|
const { data: payload } = await client.http.put(`/api/v3/channels/${channelId}/users/ban`, {
|
|
@@ -27544,7 +27560,7 @@ const banMembers = async (channelId, userIds) => {
|
|
|
27544
27560
|
* @category Channel API
|
|
27545
27561
|
* @async
|
|
27546
27562
|
* */
|
|
27547
|
-
const unbanMembers = async (channelId, userIds) => {
|
|
27563
|
+
const unbanMembers$1 = async (channelId, userIds) => {
|
|
27548
27564
|
const client = getActiveClient();
|
|
27549
27565
|
client.log('channel/unbanMembers', { userIds, channelId });
|
|
27550
27566
|
const { data: payload } = await client.http.put(`/api/v3/channels/${encodeURIComponent(channelId)}/users/unban`, {
|
|
@@ -27566,8 +27582,8 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
27566
27582
|
__proto__: null,
|
|
27567
27583
|
addRole: addRole,
|
|
27568
27584
|
removeRole: removeRole,
|
|
27569
|
-
banMembers: banMembers,
|
|
27570
|
-
unbanMembers: unbanMembers
|
|
27585
|
+
banMembers: banMembers$1,
|
|
27586
|
+
unbanMembers: unbanMembers$1
|
|
27571
27587
|
});
|
|
27572
27588
|
|
|
27573
27589
|
var index$b = /*#__PURE__*/Object.freeze({
|
|
@@ -27899,8 +27915,8 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
27899
27915
|
|
|
27900
27916
|
/**
|
|
27901
27917
|
* ```js
|
|
27902
|
-
* import {
|
|
27903
|
-
* const success = await markAsDelivered('subChannelId', 'messageId')
|
|
27918
|
+
* import { MessageRepository } from '@amityco/ts-sdk'
|
|
27919
|
+
* const success = await MessageRepository.markAsDelivered('subChannelId', 'messageId')
|
|
27904
27920
|
* ```
|
|
27905
27921
|
*
|
|
27906
27922
|
* Update `deliveredToSegment` in {@link Amity.SubChannelMarker}
|
|
@@ -28229,7 +28245,6 @@ const getMessages = (params, callback, config) => {
|
|
|
28229
28245
|
return;
|
|
28230
28246
|
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
28231
28247
|
pushToCache(cacheKey, collection);
|
|
28232
|
-
disposers.push(() => dropFromCache(cacheKey));
|
|
28233
28248
|
responder(collection);
|
|
28234
28249
|
};
|
|
28235
28250
|
const onFetch = () => {
|
|
@@ -28255,6 +28270,7 @@ const getMessages = (params, callback, config) => {
|
|
|
28255
28270
|
};
|
|
28256
28271
|
disposers.push(onMessageFetched(realtimeRouter()), onMessageCreated(realtimeRouter()), onMessageUpdated(realtimeRouter()), onMessageDeleted(realtimeRouter()), onMessageFlagged(realtimeRouter()), onMessageUnflagged(realtimeRouter()), onMessageFlagCleared(realtimeRouter()), onMessageReactionAdded(realtimeRouter()), onMessageReactionRemoved(realtimeRouter()));
|
|
28257
28272
|
onFetch();
|
|
28273
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28258
28274
|
return () => {
|
|
28259
28275
|
log(`getMessages(tmpid: ${timestamp}) > dispose`);
|
|
28260
28276
|
disposers.forEach(fn => fn());
|
|
@@ -29735,11 +29751,11 @@ const getCommunities = (params, callback, config) => {
|
|
|
29735
29751
|
pushToCache(cacheKey, collection);
|
|
29736
29752
|
responder(collection);
|
|
29737
29753
|
};
|
|
29738
|
-
const onFetch = () => {
|
|
29754
|
+
const onFetch = (initial = false) => {
|
|
29739
29755
|
var _a, _b, _c;
|
|
29740
29756
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29741
29757
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29742
|
-
if (communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29758
|
+
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
29743
29759
|
return;
|
|
29744
29760
|
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
29745
29761
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
@@ -29757,7 +29773,7 @@ const getCommunities = (params, callback, config) => {
|
|
|
29757
29773
|
}, queryOptions(policy, CACHE_SHORTEN_LIFESPAN));
|
|
29758
29774
|
};
|
|
29759
29775
|
disposers.push(onCommunityCreated(realtimeRouter()), onCommunityDeleted(realtimeRouter()), onCommunityUpdated(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityLeft(realtimeRouter()), onCommunityUserChanged(realtimeRouter()));
|
|
29760
|
-
onFetch();
|
|
29776
|
+
onFetch(true);
|
|
29761
29777
|
return () => {
|
|
29762
29778
|
log(`getCommunities(tmpid: ${timestamp}) > dispose`);
|
|
29763
29779
|
disposers.forEach(fn => fn());
|
|
@@ -29927,12 +29943,84 @@ const removeRoles = async (communityId, roleIds, userIds) => {
|
|
|
29927
29943
|
};
|
|
29928
29944
|
/* end_public_function */
|
|
29929
29945
|
|
|
29946
|
+
/* begin_public_function
|
|
29947
|
+
id: community.moderation.ban_members
|
|
29948
|
+
*/
|
|
29949
|
+
/**
|
|
29950
|
+
* ```js
|
|
29951
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29952
|
+
*
|
|
29953
|
+
* await CommunityRepository.Moderation.banMembers('communityId', ['userId1', 'userId2'])
|
|
29954
|
+
* ```
|
|
29955
|
+
*
|
|
29956
|
+
* @param communityId of {@link Amity.Community} from which the users should be banned
|
|
29957
|
+
* @param userIds of the {@link Amity.User}'s to be banned
|
|
29958
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
29959
|
+
*
|
|
29960
|
+
* @category Community API
|
|
29961
|
+
* @async
|
|
29962
|
+
* */
|
|
29963
|
+
const banMembers = async (communityId, userIds) => {
|
|
29964
|
+
const client = getActiveClient();
|
|
29965
|
+
client.log('community/banMembers', { userIds, communityId });
|
|
29966
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}/users/ban`, {
|
|
29967
|
+
userIds,
|
|
29968
|
+
});
|
|
29969
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
29970
|
+
const cachedAt = client.cache && Date.now();
|
|
29971
|
+
if (client.cache)
|
|
29972
|
+
ingestInCache(data, { cachedAt });
|
|
29973
|
+
const { communityUsers } = data;
|
|
29974
|
+
return {
|
|
29975
|
+
data: communityUsers.filter(u => userIds.includes(u.userId)),
|
|
29976
|
+
cachedAt,
|
|
29977
|
+
};
|
|
29978
|
+
};
|
|
29979
|
+
/* end_public_function */
|
|
29980
|
+
|
|
29981
|
+
/* begin_public_function
|
|
29982
|
+
id: community.moderation.unban_members
|
|
29983
|
+
*/
|
|
29984
|
+
/**
|
|
29985
|
+
* ```js
|
|
29986
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29987
|
+
*
|
|
29988
|
+
* await CommunityRepository.Moderation.unbanMembers('communityId', ['userId1', 'userId2'])
|
|
29989
|
+
* ```
|
|
29990
|
+
*
|
|
29991
|
+
* @param communityId of {@link Amity.Community} from which the users should be unbanned
|
|
29992
|
+
* @param userIds of the {@link Amity.User}'s to be unbanned
|
|
29993
|
+
* @returns the updated {@link Amity.Membership}'s object
|
|
29994
|
+
*
|
|
29995
|
+
* @category Community API
|
|
29996
|
+
* @async
|
|
29997
|
+
* */
|
|
29998
|
+
const unbanMembers = async (communityId, userIds) => {
|
|
29999
|
+
const client = getActiveClient();
|
|
30000
|
+
client.log('community/unbanMembers', { userIds, communityId });
|
|
30001
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}/users/unban`, {
|
|
30002
|
+
userIds,
|
|
30003
|
+
});
|
|
30004
|
+
const data = prepareMembershipPayload(payload, 'communityUsers');
|
|
30005
|
+
const cachedAt = client.cache && Date.now();
|
|
30006
|
+
if (client.cache)
|
|
30007
|
+
ingestInCache(data, { cachedAt });
|
|
30008
|
+
const { communityUsers } = data;
|
|
30009
|
+
return {
|
|
30010
|
+
data: communityUsers.filter(u => userIds.includes(u.userId)),
|
|
30011
|
+
cachedAt,
|
|
30012
|
+
};
|
|
30013
|
+
};
|
|
30014
|
+
/* end_public_function */
|
|
30015
|
+
|
|
29930
30016
|
var index$8 = /*#__PURE__*/Object.freeze({
|
|
29931
30017
|
__proto__: null,
|
|
29932
30018
|
addMembers: addMembers,
|
|
29933
30019
|
removeMembers: removeMembers,
|
|
29934
30020
|
addRoles: addRoles,
|
|
29935
|
-
removeRoles: removeRoles
|
|
30021
|
+
removeRoles: removeRoles,
|
|
30022
|
+
banMembers: banMembers,
|
|
30023
|
+
unbanMembers: unbanMembers
|
|
29936
30024
|
});
|
|
29937
30025
|
|
|
29938
30026
|
/**
|
|
@@ -30056,8 +30144,7 @@ const getMembers = (params, callback, config) => {
|
|
|
30056
30144
|
.map(id => pullFromCache(['communityUsers', 'get', id]))
|
|
30057
30145
|
.filter(Boolean)
|
|
30058
30146
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30059
|
-
|
|
30060
|
-
communityMembers = communityMembers.filter(c => { var _a; return (_a = c.roles) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.roles) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
30147
|
+
communityMembers = filterByPropIntersection(communityMembers, 'roles', params.roles);
|
|
30061
30148
|
if (params.membership) {
|
|
30062
30149
|
communityMembers = communityMembers.filter(({ communityMembership }) =>
|
|
30063
30150
|
// @ts-ignore
|
|
@@ -30092,11 +30179,11 @@ const getMembers = (params, callback, config) => {
|
|
|
30092
30179
|
pushToCache(cacheKey, collection);
|
|
30093
30180
|
responder(collection);
|
|
30094
30181
|
};
|
|
30095
|
-
const onFetch = () => {
|
|
30182
|
+
const onFetch = (initial = false) => {
|
|
30096
30183
|
var _a, _b, _c;
|
|
30097
30184
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30098
30185
|
const communityMembers = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30099
|
-
if (communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30186
|
+
if (!initial && communityMembers.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30100
30187
|
return;
|
|
30101
30188
|
const query = createQuery(queryCommunityMembers, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30102
30189
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
@@ -30116,7 +30203,7 @@ const getMembers = (params, callback, config) => {
|
|
|
30116
30203
|
}, queryOptions(policy));
|
|
30117
30204
|
};
|
|
30118
30205
|
disposers.push(onCommunityLeft(realtimeRouter()), onCommunityJoined(realtimeRouter()), onCommunityUserBanned(realtimeRouter()), onCommunityUserUnbanned(realtimeRouter()), onCommunityUserChanged(realtimeRouter()), onCommunityUserRoleAdded(realtimeRouter()), onCommunityUserRoleRemoved(realtimeRouter()));
|
|
30119
|
-
onFetch();
|
|
30206
|
+
onFetch(true);
|
|
30120
30207
|
return () => {
|
|
30121
30208
|
log(`getMembers(tmpid: ${timestamp}) > dispose`);
|
|
30122
30209
|
disposers.forEach(fn => fn());
|
|
@@ -30350,11 +30437,11 @@ const getCategories = (params, callback, config) => {
|
|
|
30350
30437
|
* observers
|
|
30351
30438
|
*};
|
|
30352
30439
|
*/
|
|
30353
|
-
const onFetch = () => {
|
|
30440
|
+
const onFetch = (initial = false) => {
|
|
30354
30441
|
var _a, _b, _c;
|
|
30355
30442
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30356
30443
|
const categories = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30357
|
-
if (categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30444
|
+
if (!initial && categories.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30358
30445
|
return;
|
|
30359
30446
|
const query = createQuery(queryCategories, Object.assign(Object.assign({}, queryParams), { page: (_c = collection === null || collection === void 0 ? void 0 : collection.params.page) !== null && _c !== void 0 ? _c : { limit } }));
|
|
30360
30447
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
@@ -30374,7 +30461,7 @@ const getCategories = (params, callback, config) => {
|
|
|
30374
30461
|
disposers.push(() => {
|
|
30375
30462
|
// @TODO -> update once observers added
|
|
30376
30463
|
});
|
|
30377
|
-
onFetch();
|
|
30464
|
+
onFetch(true);
|
|
30378
30465
|
return () => {
|
|
30379
30466
|
log(`getCategories(tmpid: ${timestamp}) > dispose`);
|
|
30380
30467
|
disposers.forEach(fn => fn());
|
|
@@ -32357,6 +32444,7 @@ exports.filterByFeedType = filterByFeedType;
|
|
|
32357
32444
|
exports.filterByPostDataTypes = filterByPostDataTypes;
|
|
32358
32445
|
exports.filterByPropEquality = filterByPropEquality;
|
|
32359
32446
|
exports.filterByPropInclusion = filterByPropInclusion;
|
|
32447
|
+
exports.filterByPropIntersection = filterByPropIntersection;
|
|
32360
32448
|
exports.filterBySearchTerm = filterBySearchTerm;
|
|
32361
32449
|
exports.getChannelMarkers = getChannelMarkers;
|
|
32362
32450
|
exports.getChannelTopic = getChannelTopic;
|