@amityco/ts-sdk 0.0.1-beta.28 → 0.0.1-beta.29
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/core/payload.d.ts +3 -3
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +12 -0
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +24 -2
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +2 -1
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts +1 -10
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/channel/observers/index.d.ts +1 -0
- package/dist/channel/observers/index.d.ts.map +1 -1
- package/dist/channel/observers/liveChannels.d.ts +20 -0
- package/dist/channel/observers/liveChannels.d.ts.map +1 -0
- package/dist/channel/observers/tests/liveChannels.test.d.ts +2 -0
- package/dist/channel/observers/tests/liveChannels.test.d.ts.map +1 -0
- package/dist/community/api/createCommunity.d.ts +1 -1
- package/dist/community/api/createCommunity.d.ts.map +1 -1
- package/dist/community/api/getCommunities.d.ts.map +1 -1
- package/dist/community/api/getCommunity.d.ts.map +1 -1
- package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/api/updateCommunity.d.ts +1 -1
- package/dist/community/api/updateCommunity.d.ts.map +1 -1
- package/dist/community/events/utils.d.ts.map +1 -1
- package/dist/community/utils/index.d.ts +2 -0
- package/dist/community/utils/index.d.ts.map +1 -0
- package/dist/community/utils/payload.d.ts +11 -0
- package/dist/community/utils/payload.d.ts.map +1 -0
- package/dist/follow/tests/observers/liveFollowers.test.d.ts +2 -0
- package/dist/follow/tests/observers/liveFollowers.test.d.ts.map +1 -0
- package/dist/follow/tests/observers/liveFollowings.test.d.ts +2 -0
- package/dist/follow/tests/observers/liveFollowings.test.d.ts.map +1 -0
- package/dist/index.cjs.js +201 -20
- package/dist/index.esm.js +198 -21
- package/dist/index.umd.js +4 -4
- package/dist/utils/tests/dummy/channel.d.ts +25 -2
- package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
- package/dist/utils/tests/dummy/follow.d.ts +12 -0
- package/dist/utils/tests/dummy/follow.d.ts.map +1 -0
- package/dist/utils/tests/dummy/index.d.ts +1 -0
- package/dist/utils/tests/dummy/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/user.d.ts +3 -0
- package/dist/utils/tests/dummy/user.d.ts.map +1 -1
- package/dist/utils/tests/index.d.ts +1 -0
- package/dist/utils/tests/index.d.ts.map +1 -1
- package/dist/utils/tests/utils.d.ts +2 -0
- package/dist/utils/tests/utils.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/core/payload.ts +3 -3
- package/src/@types/domains/channel.ts +18 -0
- package/src/@types/domains/community.ts +27 -2
- package/src/@types/domains/content.ts +2 -1
- package/src/@types/index.ts +1 -1
- package/src/channel/api/queryChannels.ts +3 -10
- package/src/channel/observers/index.ts +1 -0
- package/src/channel/observers/liveChannels.ts +178 -0
- package/src/channel/observers/tests/liveChannels.test.ts +173 -0
- package/src/community/api/createCommunity.ts +9 -3
- package/src/community/api/getCommunities.ts +10 -3
- package/src/community/api/getCommunity.ts +5 -1
- package/src/community/api/getRecommendedCommunities.ts +5 -2
- package/src/community/api/getTopTrendingCommunities.ts +4 -1
- package/src/community/api/queryCommunities.ts +5 -2
- package/src/community/api/updateCommunity.ts +7 -3
- package/src/community/events/utils.ts +13 -7
- package/src/community/utils/index.ts +1 -0
- package/src/community/utils/payload.ts +44 -0
- package/src/core/model/identifyModel.ts +1 -1
- package/src/follow/observers/liveFollowers.ts +1 -1
- package/src/follow/observers/liveFollowings.ts +1 -1
- package/src/follow/tests/observers/liveFollowers.test.ts +240 -0
- package/src/follow/tests/observers/liveFollowings.test.ts +239 -0
- package/src/message/observers/tests/liveMessages.test.ts +202 -22
- package/src/utils/tests/dummy/channel.ts +48 -4
- package/src/utils/tests/dummy/follow.ts +60 -0
- package/src/utils/tests/dummy/index.ts +1 -0
- package/src/utils/tests/dummy/user.ts +15 -0
- package/src/utils/tests/index.ts +1 -0
- package/src/utils/tests/utils.ts +3 -0
package/dist/index.esm.js
CHANGED
|
@@ -7,11 +7,33 @@ import HttpAgent, { HttpsAgent } from 'agentkeepalive';
|
|
|
7
7
|
import io from 'socket.io-client';
|
|
8
8
|
import nativeIdGenerator from 'react-native-uuid';
|
|
9
9
|
|
|
10
|
+
const CommunityPostSettings = Object.freeze({
|
|
11
|
+
ONLY_ADMIN_CAN_POST: 'ONLY_ADMIN_CAN_POST',
|
|
12
|
+
ADMIN_REVIEW_POST_REQUIRED: 'ADMIN_REVIEW_POST_REQUIRED',
|
|
13
|
+
ANYONE_CAN_POST: 'ANYONE_CAN_POST',
|
|
14
|
+
});
|
|
15
|
+
const CommunityPostSettingMaps = Object.freeze({
|
|
16
|
+
ONLY_ADMIN_CAN_POST: {
|
|
17
|
+
needApprovalOnPostCreation: false,
|
|
18
|
+
onlyAdminCanPost: true,
|
|
19
|
+
},
|
|
20
|
+
ADMIN_REVIEW_POST_REQUIRED: {
|
|
21
|
+
needApprovalOnPostCreation: true,
|
|
22
|
+
onlyAdminCanPost: false,
|
|
23
|
+
},
|
|
24
|
+
ANYONE_CAN_POST: {
|
|
25
|
+
needApprovalOnPostCreation: false,
|
|
26
|
+
onlyAdminCanPost: false,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
|
|
30
|
+
|
|
10
31
|
const ContentFeedType = Object.freeze({
|
|
11
32
|
STORY: 'story',
|
|
12
|
-
|
|
33
|
+
CLIP: 'clip',
|
|
13
34
|
CHAT: 'chat',
|
|
14
35
|
POST: 'post',
|
|
36
|
+
MESSAGE: 'message',
|
|
15
37
|
});
|
|
16
38
|
|
|
17
39
|
const FileType = Object.freeze({
|
|
@@ -243,7 +265,7 @@ const CRITERIAS = {
|
|
|
243
265
|
channel: ['channelId', 'rateLimit'],
|
|
244
266
|
channelUsers: ['channelId', 'userId', 'membership'],
|
|
245
267
|
message: ['messageId'],
|
|
246
|
-
community: ['communityId', '
|
|
268
|
+
community: ['communityId', 'postSetting'],
|
|
247
269
|
category: ['categoryId'],
|
|
248
270
|
communityUsers: ['userId', 'communityId', 'communityMembership'],
|
|
249
271
|
post: ['postId', 'feedId'],
|
|
@@ -21925,6 +21947,33 @@ const updatePost = async (postId, patch) => {
|
|
|
21925
21947
|
};
|
|
21926
21948
|
};
|
|
21927
21949
|
|
|
21950
|
+
const getMatchPostSetting = (value) => {
|
|
21951
|
+
var _a;
|
|
21952
|
+
return (_a = Object.keys(CommunityPostSettingMaps).find(key => value.needApprovalOnPostCreation ===
|
|
21953
|
+
CommunityPostSettingMaps[key].needApprovalOnPostCreation &&
|
|
21954
|
+
value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost)) !== null && _a !== void 0 ? _a : DefaultCommunityPostSetting;
|
|
21955
|
+
};
|
|
21956
|
+
/*
|
|
21957
|
+
* Unpack community payload by mapping payload field to postSetting value.
|
|
21958
|
+
*/
|
|
21959
|
+
const unpackCommunityPayload = (_a) => {
|
|
21960
|
+
var { communities } = _a, restPayload = __rest(_a, ["communities"]);
|
|
21961
|
+
return (Object.assign({ communities: communities.map((_a) => {
|
|
21962
|
+
var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
|
|
21963
|
+
return (Object.assign({ postSetting: getMatchPostSetting({
|
|
21964
|
+
needApprovalOnPostCreation,
|
|
21965
|
+
onlyAdminCanPost,
|
|
21966
|
+
}) }, restCommunityPayload));
|
|
21967
|
+
}) }, restPayload));
|
|
21968
|
+
};
|
|
21969
|
+
/*
|
|
21970
|
+
* Repack community payload by mapping postSetting to the actual value.
|
|
21971
|
+
*/
|
|
21972
|
+
const packCommunityPayload = (_a) => {
|
|
21973
|
+
var { postSetting = undefined } = _a, restParam = __rest(_a, ["postSetting"]);
|
|
21974
|
+
return (Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)));
|
|
21975
|
+
};
|
|
21976
|
+
|
|
21928
21977
|
/**
|
|
21929
21978
|
* ```js
|
|
21930
21979
|
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
@@ -21954,10 +22003,11 @@ const queryCommunities = async (query) => {
|
|
|
21954
22003
|
} }),
|
|
21955
22004
|
});
|
|
21956
22005
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
21957
|
-
const
|
|
22006
|
+
const unpackedPayload = unpackCommunityPayload(payload);
|
|
22007
|
+
const { communities } = unpackedPayload;
|
|
21958
22008
|
const cachedAt = client.cache && Date.now();
|
|
21959
22009
|
if (client.cache) {
|
|
21960
|
-
ingestInCache(
|
|
22010
|
+
ingestInCache(unpackedPayload, { cachedAt });
|
|
21961
22011
|
const cacheKey = [
|
|
21962
22012
|
'community',
|
|
21963
22013
|
'query',
|
|
@@ -22006,9 +22056,10 @@ const getCommunities = async (communityIds) => {
|
|
|
22006
22056
|
const client = getActiveClient();
|
|
22007
22057
|
client.log('community/getCommunities', communityIds);
|
|
22008
22058
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22009
|
-
const { data } = await client.http.get(`/api/v3/communities/list`, {
|
|
22059
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/list`, {
|
|
22010
22060
|
params: { communityIds },
|
|
22011
22061
|
});
|
|
22062
|
+
const data = unpackCommunityPayload(payload);
|
|
22012
22063
|
const cachedAt = client.cache && Date.now();
|
|
22013
22064
|
if (client.cache)
|
|
22014
22065
|
ingestInCache(data, { cachedAt });
|
|
@@ -22067,7 +22118,8 @@ const getCommunity = async (communityId) => {
|
|
|
22067
22118
|
const client = getActiveClient();
|
|
22068
22119
|
client.log('community/getCommunity', communityId);
|
|
22069
22120
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22070
|
-
const { data } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
22121
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
22122
|
+
const data = unpackCommunityPayload(payload);
|
|
22071
22123
|
const cachedAt = client.cache && Date.now();
|
|
22072
22124
|
if (client.cache)
|
|
22073
22125
|
ingestInCache(data, { cachedAt });
|
|
@@ -22121,7 +22173,8 @@ getCommunity.locally = (communityId) => {
|
|
|
22121
22173
|
const createCommunity = async (bundle) => {
|
|
22122
22174
|
const client = getActiveClient();
|
|
22123
22175
|
client.log('user/createCommunity', bundle);
|
|
22124
|
-
const { data } = await client.http.post('/api/v3/communities/', bundle);
|
|
22176
|
+
const { data: payload } = await client.http.post('/api/v3/communities/', packCommunityPayload(bundle));
|
|
22177
|
+
const data = unpackCommunityPayload(payload);
|
|
22125
22178
|
const cachedAt = client.cache && Date.now();
|
|
22126
22179
|
if (client.cache)
|
|
22127
22180
|
ingestInCache(data, { cachedAt });
|
|
@@ -22151,7 +22204,8 @@ const createCommunity = async (bundle) => {
|
|
|
22151
22204
|
const updateCommunity = async (communityId, patch) => {
|
|
22152
22205
|
const client = getActiveClient();
|
|
22153
22206
|
client.log('community/updateCommunity', communityId, patch);
|
|
22154
|
-
const { data } = await client.http.put(`/api/v3/communities/${communityId}`, patch);
|
|
22207
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}`, packCommunityPayload(patch));
|
|
22208
|
+
const data = unpackCommunityPayload(payload);
|
|
22155
22209
|
const cachedAt = client.cache && Date.now();
|
|
22156
22210
|
if (client.cache)
|
|
22157
22211
|
ingestInCache(data, { cachedAt });
|
|
@@ -22417,7 +22471,8 @@ const getTopTrendingCommunities = async (query) => {
|
|
|
22417
22471
|
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
22418
22472
|
// API-FIX: backend doesnt answer Amity.Response
|
|
22419
22473
|
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
22420
|
-
const { data } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
22474
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
22475
|
+
const data = unpackCommunityPayload(payload);
|
|
22421
22476
|
const { communities } = data;
|
|
22422
22477
|
const cachedAt = client.cache && Date.now();
|
|
22423
22478
|
if (client.cache) {
|
|
@@ -22479,8 +22534,9 @@ const getRecommendedCommunities = async (query) => {
|
|
|
22479
22534
|
client.log('channel/getRecommendedCommunities', query);
|
|
22480
22535
|
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
22481
22536
|
// API-FIX: backend doesnt answer Amity.Response
|
|
22482
|
-
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
22483
|
-
const { data } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
22537
|
+
// const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
22538
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
22539
|
+
const data = unpackCommunityPayload(payload);
|
|
22484
22540
|
const { communities } = data;
|
|
22485
22541
|
const cachedAt = client.cache && Date.now();
|
|
22486
22542
|
if (client.cache) {
|
|
@@ -24830,6 +24886,125 @@ const observeChannels = (callback) => {
|
|
|
24830
24886
|
};
|
|
24831
24887
|
};
|
|
24832
24888
|
|
|
24889
|
+
/**
|
|
24890
|
+
* ```js
|
|
24891
|
+
* import { liveChannels } from '@amityco/ts-sdk'
|
|
24892
|
+
*
|
|
24893
|
+
* let channels = []
|
|
24894
|
+
* const unsub = liveChannels({
|
|
24895
|
+
* displayName: Amity.Channel['displayName'],
|
|
24896
|
+
* }, response => merge(channels, response.data))
|
|
24897
|
+
* ```
|
|
24898
|
+
*
|
|
24899
|
+
* Observe all mutations on a list of {@link Amity.Channel}s
|
|
24900
|
+
*
|
|
24901
|
+
* @param params for querying channels
|
|
24902
|
+
* @param callback the function to call when new data are available
|
|
24903
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channels
|
|
24904
|
+
*
|
|
24905
|
+
* @category Channel Live Collection
|
|
24906
|
+
*/
|
|
24907
|
+
const liveChannels = (params, callback, config) => {
|
|
24908
|
+
const { log, cache } = getActiveClient();
|
|
24909
|
+
if (!cache) {
|
|
24910
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
24911
|
+
}
|
|
24912
|
+
const timestamp = Date.now();
|
|
24913
|
+
log(`liveChannels(tmpid: ${timestamp}) > listen`);
|
|
24914
|
+
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
24915
|
+
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
24916
|
+
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
24917
|
+
const disposers = [];
|
|
24918
|
+
const cacheKey = ['channel', 'collection', {}];
|
|
24919
|
+
const responder = (data) => {
|
|
24920
|
+
var _a, _b;
|
|
24921
|
+
let channels = (_a = data.data
|
|
24922
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
24923
|
+
.filter(Boolean)
|
|
24924
|
+
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
24925
|
+
channels = filterByPropEquality(channels, 'isDeleted', params.isDeleted);
|
|
24926
|
+
channels = filterByPropEquality(channels, 'displayName', params.displayName);
|
|
24927
|
+
if (params.types) {
|
|
24928
|
+
channels = channels.filter(c => { var _a; return (_a = params.types) === null || _a === void 0 ? void 0 : _a.includes(c.type); });
|
|
24929
|
+
}
|
|
24930
|
+
if (params.tags) {
|
|
24931
|
+
channels = channels.filter(c => { var _a; return (_a = c.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.tags) === null || _a === void 0 ? void 0 : _a.includes(t); }); });
|
|
24932
|
+
}
|
|
24933
|
+
if (params.excludeTags) {
|
|
24934
|
+
channels = channels.filter(c => { var _a; return !((_a = c.tags) === null || _a === void 0 ? void 0 : _a.some(t => { var _a; return (_a = params.excludeTags) === null || _a === void 0 ? void 0 : _a.includes(t); })); });
|
|
24935
|
+
}
|
|
24936
|
+
const sortBy = params.sortBy || 'lastCreated';
|
|
24937
|
+
if (sortBy === 'lastCreated' || sortBy === 'firstCreated') {
|
|
24938
|
+
channels = channels.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
24939
|
+
}
|
|
24940
|
+
/*
|
|
24941
|
+
* The server returns channels with empty | null displayName's first before
|
|
24942
|
+
* returning sorted list of channels with displayNames
|
|
24943
|
+
*
|
|
24944
|
+
* This section needs to be updated as displayNames can be null as well
|
|
24945
|
+
*/
|
|
24946
|
+
if (sortBy === 'displayName') {
|
|
24947
|
+
channels = channels
|
|
24948
|
+
// this needs to be aligned with the backend data type
|
|
24949
|
+
.map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
|
|
24950
|
+
// @ts-ignore
|
|
24951
|
+
.sort(sortByDisplayName);
|
|
24952
|
+
}
|
|
24953
|
+
callback({
|
|
24954
|
+
onNextPage: onFetch,
|
|
24955
|
+
data: channels,
|
|
24956
|
+
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
24957
|
+
loading: data.loading,
|
|
24958
|
+
error: data.error,
|
|
24959
|
+
});
|
|
24960
|
+
};
|
|
24961
|
+
const realtimeRouter = (channel, action) => {
|
|
24962
|
+
var _a;
|
|
24963
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24964
|
+
if (!collection)
|
|
24965
|
+
return;
|
|
24966
|
+
if (action === 'onCreate') {
|
|
24967
|
+
collection.data = [...new Set([channel.channelId, ...collection.data])];
|
|
24968
|
+
/*
|
|
24969
|
+
* if the filter isDeleted is set, only collection item must be updated and not
|
|
24970
|
+
* the collection
|
|
24971
|
+
*/
|
|
24972
|
+
}
|
|
24973
|
+
else if (action === 'onDelete' && !params.isDeleted) {
|
|
24974
|
+
collection.data = collection.data.filter(c => c !== channel.channelId);
|
|
24975
|
+
}
|
|
24976
|
+
pushToCache(cacheKey, collection);
|
|
24977
|
+
responder(collection);
|
|
24978
|
+
};
|
|
24979
|
+
const onFetch = () => {
|
|
24980
|
+
var _a, _b, _c;
|
|
24981
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24982
|
+
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24983
|
+
if (channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24984
|
+
return;
|
|
24985
|
+
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 } }));
|
|
24986
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
24987
|
+
const data = {
|
|
24988
|
+
loading,
|
|
24989
|
+
error,
|
|
24990
|
+
params: { page },
|
|
24991
|
+
data: channels,
|
|
24992
|
+
};
|
|
24993
|
+
if (result) {
|
|
24994
|
+
data.data = [...new Set([...channels, ...result.map(getResolver('channel'))])];
|
|
24995
|
+
}
|
|
24996
|
+
pushToCache(cacheKey, data);
|
|
24997
|
+
responder(data);
|
|
24998
|
+
}, queryOptions(policy));
|
|
24999
|
+
};
|
|
25000
|
+
disposers.push(onChannelCreated(channel => realtimeRouter(channel, 'onCreate')), onChannelDeleted(channel => realtimeRouter(channel, 'onDelete')), onChannelUpdated(channel => realtimeRouter(channel, 'onUpdate')));
|
|
25001
|
+
onFetch();
|
|
25002
|
+
return () => {
|
|
25003
|
+
log(`liveChannels(tmpid: ${timestamp}) > dispose`);
|
|
25004
|
+
disposers.forEach(fn => fn());
|
|
25005
|
+
};
|
|
25006
|
+
};
|
|
25007
|
+
|
|
24833
25008
|
/**
|
|
24834
25009
|
* ```js
|
|
24835
25010
|
* import { onMessageCreated } from '@amityco/ts-sdk'
|
|
@@ -25084,16 +25259,17 @@ const liveMessages = (params, callback, config) => {
|
|
|
25084
25259
|
const createCommunityEventSubscriber = (event, callback) => {
|
|
25085
25260
|
const client = getActiveClient();
|
|
25086
25261
|
const filter = (payload) => {
|
|
25262
|
+
const unpackedPayload = unpackCommunityPayload(payload);
|
|
25087
25263
|
if (!client.cache) {
|
|
25088
25264
|
// TODO: here we are missing specific properties here!
|
|
25089
|
-
callback(
|
|
25265
|
+
callback(unpackedPayload.communities[0]);
|
|
25090
25266
|
}
|
|
25091
25267
|
else {
|
|
25092
|
-
ingestInCache(
|
|
25268
|
+
ingestInCache(unpackedPayload);
|
|
25093
25269
|
const community = pullFromCache([
|
|
25094
25270
|
'community',
|
|
25095
25271
|
'get',
|
|
25096
|
-
|
|
25272
|
+
unpackedPayload.communities[0].communityId,
|
|
25097
25273
|
]);
|
|
25098
25274
|
callback(community.data);
|
|
25099
25275
|
}
|
|
@@ -25129,21 +25305,22 @@ function getEventRelatedMember(event, payload) {
|
|
|
25129
25305
|
const createCommunityMemberEventSubscriber = (event, callback) => {
|
|
25130
25306
|
const client = getActiveClient();
|
|
25131
25307
|
const filter = (payload) => {
|
|
25308
|
+
const unpackedPayload = unpackCommunityPayload(payload);
|
|
25132
25309
|
if (!client.cache) {
|
|
25133
25310
|
// TODO: here we are missing specific properties here!
|
|
25134
|
-
callback(
|
|
25311
|
+
callback(unpackedPayload.communities[0], getEventRelatedMember(event, unpackedPayload));
|
|
25135
25312
|
}
|
|
25136
25313
|
else {
|
|
25137
|
-
ingestInCache(
|
|
25314
|
+
ingestInCache(unpackedPayload);
|
|
25138
25315
|
const community = pullFromCache([
|
|
25139
25316
|
'community',
|
|
25140
25317
|
'get',
|
|
25141
|
-
|
|
25318
|
+
unpackedPayload.communities[0].communityId,
|
|
25142
25319
|
]);
|
|
25143
25320
|
const member = pullFromCache([
|
|
25144
25321
|
'communityUsers',
|
|
25145
25322
|
'get',
|
|
25146
|
-
getResolver('communityUsers')(getEventRelatedMember(event,
|
|
25323
|
+
getResolver('communityUsers')(getEventRelatedMember(event, unpackedPayload)),
|
|
25147
25324
|
]);
|
|
25148
25325
|
callback(community.data, member.data);
|
|
25149
25326
|
}
|
|
@@ -26171,7 +26348,7 @@ const liveFollowers = (params, callback, config) => {
|
|
|
26171
26348
|
.map(key => pullFromCache(['follow', 'get', key]))
|
|
26172
26349
|
.filter(Boolean)
|
|
26173
26350
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
26174
|
-
if (params.status) {
|
|
26351
|
+
if (params.status && params.status !== 'all') {
|
|
26175
26352
|
followers = filterByPropEquality(followers, 'status', params.status);
|
|
26176
26353
|
}
|
|
26177
26354
|
callback({
|
|
@@ -26261,7 +26438,7 @@ const liveFollowings = (params, callback, config) => {
|
|
|
26261
26438
|
.map(key => pullFromCache(['follow', 'get', key]))
|
|
26262
26439
|
.filter(Boolean)
|
|
26263
26440
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
26264
|
-
if (params.status) {
|
|
26441
|
+
if (params.status && params.status !== 'all') {
|
|
26265
26442
|
followings = filterByPropEquality(followings, 'status', params.status);
|
|
26266
26443
|
}
|
|
26267
26444
|
callback({
|
|
@@ -27261,4 +27438,4 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
27261
27438
|
return { accessToken: data.accessToken };
|
|
27262
27439
|
};
|
|
27263
27440
|
|
|
27264
|
-
export { API_REGIONS, ContentFeedType, FileType, SubscriptionLevels, VERSION$1 as VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getCategory, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getStream, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveComments, liveFollowers, liveFollowings, liveMessages, livePosts, liveReactions, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMemberAdded, onChannelMemberRemoved, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, votePoll, wipeCache };
|
|
27441
|
+
export { API_REGIONS, CommunityPostSettingMaps, CommunityPostSettings, ContentFeedType, DefaultCommunityPostSetting, FileType, SubscriptionLevels, VERSION$1 as VERSION, VideoResolution, VideoSize, VideoTranscodingStatus, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, approvePost, backupCache, banChannelMembers, closePoll, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createImage, createMessage, createPoll, createPost, createQuery, createReport, createStream, createUserToken, createVideo, declineFollower, declinePost, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePoll, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getCategory, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFeedSettings, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getNetworkTopic, getPoll, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getStream, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, liveChannels, liveComments, liveFollowers, liveFollowings, liveMessages, livePosts, liveReactions, mergeInCache, observeChannel, observeChannels, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePoll, observePost, observePosts, observeUser, onChannelCreated, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelMemberAdded, onChannelMemberRemoved, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMessageCreated, onMessageDeleted, onMessageUpdated, onPollDeleted, onPollUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionAdded, onReactionRemoved, onReactorAdded, onReactorRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserDeleted, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryReactions, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unbanChannelMembers, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, votePoll, wipeCache };
|