@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.cjs.js
CHANGED
|
@@ -21,11 +21,33 @@ var HttpAgent__default = /*#__PURE__*/_interopDefaultLegacy(HttpAgent);
|
|
|
21
21
|
var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
|
|
22
22
|
var nativeIdGenerator__default = /*#__PURE__*/_interopDefaultLegacy(nativeIdGenerator);
|
|
23
23
|
|
|
24
|
+
const CommunityPostSettings = Object.freeze({
|
|
25
|
+
ONLY_ADMIN_CAN_POST: 'ONLY_ADMIN_CAN_POST',
|
|
26
|
+
ADMIN_REVIEW_POST_REQUIRED: 'ADMIN_REVIEW_POST_REQUIRED',
|
|
27
|
+
ANYONE_CAN_POST: 'ANYONE_CAN_POST',
|
|
28
|
+
});
|
|
29
|
+
const CommunityPostSettingMaps = Object.freeze({
|
|
30
|
+
ONLY_ADMIN_CAN_POST: {
|
|
31
|
+
needApprovalOnPostCreation: false,
|
|
32
|
+
onlyAdminCanPost: true,
|
|
33
|
+
},
|
|
34
|
+
ADMIN_REVIEW_POST_REQUIRED: {
|
|
35
|
+
needApprovalOnPostCreation: true,
|
|
36
|
+
onlyAdminCanPost: false,
|
|
37
|
+
},
|
|
38
|
+
ANYONE_CAN_POST: {
|
|
39
|
+
needApprovalOnPostCreation: false,
|
|
40
|
+
onlyAdminCanPost: false,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const DefaultCommunityPostSetting = 'ONLY_ADMIN_CAN_POST';
|
|
44
|
+
|
|
24
45
|
const ContentFeedType = Object.freeze({
|
|
25
46
|
STORY: 'story',
|
|
26
|
-
|
|
47
|
+
CLIP: 'clip',
|
|
27
48
|
CHAT: 'chat',
|
|
28
49
|
POST: 'post',
|
|
50
|
+
MESSAGE: 'message',
|
|
29
51
|
});
|
|
30
52
|
|
|
31
53
|
const FileType = Object.freeze({
|
|
@@ -257,7 +279,7 @@ const CRITERIAS = {
|
|
|
257
279
|
channel: ['channelId', 'rateLimit'],
|
|
258
280
|
channelUsers: ['channelId', 'userId', 'membership'],
|
|
259
281
|
message: ['messageId'],
|
|
260
|
-
community: ['communityId', '
|
|
282
|
+
community: ['communityId', 'postSetting'],
|
|
261
283
|
category: ['categoryId'],
|
|
262
284
|
communityUsers: ['userId', 'communityId', 'communityMembership'],
|
|
263
285
|
post: ['postId', 'feedId'],
|
|
@@ -21939,6 +21961,33 @@ const updatePost = async (postId, patch) => {
|
|
|
21939
21961
|
};
|
|
21940
21962
|
};
|
|
21941
21963
|
|
|
21964
|
+
const getMatchPostSetting = (value) => {
|
|
21965
|
+
var _a;
|
|
21966
|
+
return (_a = Object.keys(CommunityPostSettingMaps).find(key => value.needApprovalOnPostCreation ===
|
|
21967
|
+
CommunityPostSettingMaps[key].needApprovalOnPostCreation &&
|
|
21968
|
+
value.onlyAdminCanPost === CommunityPostSettingMaps[key].onlyAdminCanPost)) !== null && _a !== void 0 ? _a : DefaultCommunityPostSetting;
|
|
21969
|
+
};
|
|
21970
|
+
/*
|
|
21971
|
+
* Unpack community payload by mapping payload field to postSetting value.
|
|
21972
|
+
*/
|
|
21973
|
+
const unpackCommunityPayload = (_a) => {
|
|
21974
|
+
var { communities } = _a, restPayload = __rest(_a, ["communities"]);
|
|
21975
|
+
return (Object.assign({ communities: communities.map((_a) => {
|
|
21976
|
+
var { needApprovalOnPostCreation, onlyAdminCanPost } = _a, restCommunityPayload = __rest(_a, ["needApprovalOnPostCreation", "onlyAdminCanPost"]);
|
|
21977
|
+
return (Object.assign({ postSetting: getMatchPostSetting({
|
|
21978
|
+
needApprovalOnPostCreation,
|
|
21979
|
+
onlyAdminCanPost,
|
|
21980
|
+
}) }, restCommunityPayload));
|
|
21981
|
+
}) }, restPayload));
|
|
21982
|
+
};
|
|
21983
|
+
/*
|
|
21984
|
+
* Repack community payload by mapping postSetting to the actual value.
|
|
21985
|
+
*/
|
|
21986
|
+
const packCommunityPayload = (_a) => {
|
|
21987
|
+
var { postSetting = undefined } = _a, restParam = __rest(_a, ["postSetting"]);
|
|
21988
|
+
return (Object.assign(Object.assign({}, restParam), (postSetting ? CommunityPostSettingMaps[postSetting] : undefined)));
|
|
21989
|
+
};
|
|
21990
|
+
|
|
21942
21991
|
/**
|
|
21943
21992
|
* ```js
|
|
21944
21993
|
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
@@ -21968,10 +22017,11 @@ const queryCommunities = async (query) => {
|
|
|
21968
22017
|
} }),
|
|
21969
22018
|
});
|
|
21970
22019
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
21971
|
-
const
|
|
22020
|
+
const unpackedPayload = unpackCommunityPayload(payload);
|
|
22021
|
+
const { communities } = unpackedPayload;
|
|
21972
22022
|
const cachedAt = client.cache && Date.now();
|
|
21973
22023
|
if (client.cache) {
|
|
21974
|
-
ingestInCache(
|
|
22024
|
+
ingestInCache(unpackedPayload, { cachedAt });
|
|
21975
22025
|
const cacheKey = [
|
|
21976
22026
|
'community',
|
|
21977
22027
|
'query',
|
|
@@ -22020,9 +22070,10 @@ const getCommunities = async (communityIds) => {
|
|
|
22020
22070
|
const client = getActiveClient();
|
|
22021
22071
|
client.log('community/getCommunities', communityIds);
|
|
22022
22072
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22023
|
-
const { data } = await client.http.get(`/api/v3/communities/list`, {
|
|
22073
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/list`, {
|
|
22024
22074
|
params: { communityIds },
|
|
22025
22075
|
});
|
|
22076
|
+
const data = unpackCommunityPayload(payload);
|
|
22026
22077
|
const cachedAt = client.cache && Date.now();
|
|
22027
22078
|
if (client.cache)
|
|
22028
22079
|
ingestInCache(data, { cachedAt });
|
|
@@ -22081,7 +22132,8 @@ const getCommunity = async (communityId) => {
|
|
|
22081
22132
|
const client = getActiveClient();
|
|
22082
22133
|
client.log('community/getCommunity', communityId);
|
|
22083
22134
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
22084
|
-
const { data } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
22135
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
|
|
22136
|
+
const data = unpackCommunityPayload(payload);
|
|
22085
22137
|
const cachedAt = client.cache && Date.now();
|
|
22086
22138
|
if (client.cache)
|
|
22087
22139
|
ingestInCache(data, { cachedAt });
|
|
@@ -22135,7 +22187,8 @@ getCommunity.locally = (communityId) => {
|
|
|
22135
22187
|
const createCommunity = async (bundle) => {
|
|
22136
22188
|
const client = getActiveClient();
|
|
22137
22189
|
client.log('user/createCommunity', bundle);
|
|
22138
|
-
const { data } = await client.http.post('/api/v3/communities/', bundle);
|
|
22190
|
+
const { data: payload } = await client.http.post('/api/v3/communities/', packCommunityPayload(bundle));
|
|
22191
|
+
const data = unpackCommunityPayload(payload);
|
|
22139
22192
|
const cachedAt = client.cache && Date.now();
|
|
22140
22193
|
if (client.cache)
|
|
22141
22194
|
ingestInCache(data, { cachedAt });
|
|
@@ -22165,7 +22218,8 @@ const createCommunity = async (bundle) => {
|
|
|
22165
22218
|
const updateCommunity = async (communityId, patch) => {
|
|
22166
22219
|
const client = getActiveClient();
|
|
22167
22220
|
client.log('community/updateCommunity', communityId, patch);
|
|
22168
|
-
const { data } = await client.http.put(`/api/v3/communities/${communityId}`, patch);
|
|
22221
|
+
const { data: payload } = await client.http.put(`/api/v3/communities/${communityId}`, packCommunityPayload(patch));
|
|
22222
|
+
const data = unpackCommunityPayload(payload);
|
|
22169
22223
|
const cachedAt = client.cache && Date.now();
|
|
22170
22224
|
if (client.cache)
|
|
22171
22225
|
ingestInCache(data, { cachedAt });
|
|
@@ -22431,7 +22485,8 @@ const getTopTrendingCommunities = async (query) => {
|
|
|
22431
22485
|
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
22432
22486
|
// API-FIX: backend doesnt answer Amity.Response
|
|
22433
22487
|
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
22434
|
-
const { data } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
22488
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
22489
|
+
const data = unpackCommunityPayload(payload);
|
|
22435
22490
|
const { communities } = data;
|
|
22436
22491
|
const cachedAt = client.cache && Date.now();
|
|
22437
22492
|
if (client.cache) {
|
|
@@ -22493,8 +22548,9 @@ const getRecommendedCommunities = async (query) => {
|
|
|
22493
22548
|
client.log('channel/getRecommendedCommunities', query);
|
|
22494
22549
|
const { limit = 5 } = query !== null && query !== void 0 ? query : {};
|
|
22495
22550
|
// API-FIX: backend doesnt answer Amity.Response
|
|
22496
|
-
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
22497
|
-
const { data } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
22551
|
+
// const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
22552
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
22553
|
+
const data = unpackCommunityPayload(payload);
|
|
22498
22554
|
const { communities } = data;
|
|
22499
22555
|
const cachedAt = client.cache && Date.now();
|
|
22500
22556
|
if (client.cache) {
|
|
@@ -24844,6 +24900,125 @@ const observeChannels = (callback) => {
|
|
|
24844
24900
|
};
|
|
24845
24901
|
};
|
|
24846
24902
|
|
|
24903
|
+
/**
|
|
24904
|
+
* ```js
|
|
24905
|
+
* import { liveChannels } from '@amityco/ts-sdk'
|
|
24906
|
+
*
|
|
24907
|
+
* let channels = []
|
|
24908
|
+
* const unsub = liveChannels({
|
|
24909
|
+
* displayName: Amity.Channel['displayName'],
|
|
24910
|
+
* }, response => merge(channels, response.data))
|
|
24911
|
+
* ```
|
|
24912
|
+
*
|
|
24913
|
+
* Observe all mutations on a list of {@link Amity.Channel}s
|
|
24914
|
+
*
|
|
24915
|
+
* @param params for querying channels
|
|
24916
|
+
* @param callback the function to call when new data are available
|
|
24917
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the channels
|
|
24918
|
+
*
|
|
24919
|
+
* @category Channel Live Collection
|
|
24920
|
+
*/
|
|
24921
|
+
const liveChannels = (params, callback, config) => {
|
|
24922
|
+
const { log, cache } = getActiveClient();
|
|
24923
|
+
if (!cache) {
|
|
24924
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
24925
|
+
}
|
|
24926
|
+
const timestamp = Date.now();
|
|
24927
|
+
log(`liveChannels(tmpid: ${timestamp}) > listen`);
|
|
24928
|
+
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
24929
|
+
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
24930
|
+
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
24931
|
+
const disposers = [];
|
|
24932
|
+
const cacheKey = ['channel', 'collection', {}];
|
|
24933
|
+
const responder = (data) => {
|
|
24934
|
+
var _a, _b;
|
|
24935
|
+
let channels = (_a = data.data
|
|
24936
|
+
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
24937
|
+
.filter(Boolean)
|
|
24938
|
+
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
24939
|
+
channels = filterByPropEquality(channels, 'isDeleted', params.isDeleted);
|
|
24940
|
+
channels = filterByPropEquality(channels, 'displayName', params.displayName);
|
|
24941
|
+
if (params.types) {
|
|
24942
|
+
channels = channels.filter(c => { var _a; return (_a = params.types) === null || _a === void 0 ? void 0 : _a.includes(c.type); });
|
|
24943
|
+
}
|
|
24944
|
+
if (params.tags) {
|
|
24945
|
+
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); }); });
|
|
24946
|
+
}
|
|
24947
|
+
if (params.excludeTags) {
|
|
24948
|
+
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); })); });
|
|
24949
|
+
}
|
|
24950
|
+
const sortBy = params.sortBy || 'lastCreated';
|
|
24951
|
+
if (sortBy === 'lastCreated' || sortBy === 'firstCreated') {
|
|
24952
|
+
channels = channels.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
24953
|
+
}
|
|
24954
|
+
/*
|
|
24955
|
+
* The server returns channels with empty | null displayName's first before
|
|
24956
|
+
* returning sorted list of channels with displayNames
|
|
24957
|
+
*
|
|
24958
|
+
* This section needs to be updated as displayNames can be null as well
|
|
24959
|
+
*/
|
|
24960
|
+
if (sortBy === 'displayName') {
|
|
24961
|
+
channels = channels
|
|
24962
|
+
// this needs to be aligned with the backend data type
|
|
24963
|
+
.map(c => (c.displayName ? c : Object.assign(Object.assign({}, c), { displayName: '' })))
|
|
24964
|
+
// @ts-ignore
|
|
24965
|
+
.sort(sortByDisplayName);
|
|
24966
|
+
}
|
|
24967
|
+
callback({
|
|
24968
|
+
onNextPage: onFetch,
|
|
24969
|
+
data: channels,
|
|
24970
|
+
hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
|
|
24971
|
+
loading: data.loading,
|
|
24972
|
+
error: data.error,
|
|
24973
|
+
});
|
|
24974
|
+
};
|
|
24975
|
+
const realtimeRouter = (channel, action) => {
|
|
24976
|
+
var _a;
|
|
24977
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24978
|
+
if (!collection)
|
|
24979
|
+
return;
|
|
24980
|
+
if (action === 'onCreate') {
|
|
24981
|
+
collection.data = [...new Set([channel.channelId, ...collection.data])];
|
|
24982
|
+
/*
|
|
24983
|
+
* if the filter isDeleted is set, only collection item must be updated and not
|
|
24984
|
+
* the collection
|
|
24985
|
+
*/
|
|
24986
|
+
}
|
|
24987
|
+
else if (action === 'onDelete' && !params.isDeleted) {
|
|
24988
|
+
collection.data = collection.data.filter(c => c !== channel.channelId);
|
|
24989
|
+
}
|
|
24990
|
+
pushToCache(cacheKey, collection);
|
|
24991
|
+
responder(collection);
|
|
24992
|
+
};
|
|
24993
|
+
const onFetch = () => {
|
|
24994
|
+
var _a, _b, _c;
|
|
24995
|
+
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24996
|
+
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24997
|
+
if (channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24998
|
+
return;
|
|
24999
|
+
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 } }));
|
|
25000
|
+
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
25001
|
+
const data = {
|
|
25002
|
+
loading,
|
|
25003
|
+
error,
|
|
25004
|
+
params: { page },
|
|
25005
|
+
data: channels,
|
|
25006
|
+
};
|
|
25007
|
+
if (result) {
|
|
25008
|
+
data.data = [...new Set([...channels, ...result.map(getResolver('channel'))])];
|
|
25009
|
+
}
|
|
25010
|
+
pushToCache(cacheKey, data);
|
|
25011
|
+
responder(data);
|
|
25012
|
+
}, queryOptions(policy));
|
|
25013
|
+
};
|
|
25014
|
+
disposers.push(onChannelCreated(channel => realtimeRouter(channel, 'onCreate')), onChannelDeleted(channel => realtimeRouter(channel, 'onDelete')), onChannelUpdated(channel => realtimeRouter(channel, 'onUpdate')));
|
|
25015
|
+
onFetch();
|
|
25016
|
+
return () => {
|
|
25017
|
+
log(`liveChannels(tmpid: ${timestamp}) > dispose`);
|
|
25018
|
+
disposers.forEach(fn => fn());
|
|
25019
|
+
};
|
|
25020
|
+
};
|
|
25021
|
+
|
|
24847
25022
|
/**
|
|
24848
25023
|
* ```js
|
|
24849
25024
|
* import { onMessageCreated } from '@amityco/ts-sdk'
|
|
@@ -25098,16 +25273,17 @@ const liveMessages = (params, callback, config) => {
|
|
|
25098
25273
|
const createCommunityEventSubscriber = (event, callback) => {
|
|
25099
25274
|
const client = getActiveClient();
|
|
25100
25275
|
const filter = (payload) => {
|
|
25276
|
+
const unpackedPayload = unpackCommunityPayload(payload);
|
|
25101
25277
|
if (!client.cache) {
|
|
25102
25278
|
// TODO: here we are missing specific properties here!
|
|
25103
|
-
callback(
|
|
25279
|
+
callback(unpackedPayload.communities[0]);
|
|
25104
25280
|
}
|
|
25105
25281
|
else {
|
|
25106
|
-
ingestInCache(
|
|
25282
|
+
ingestInCache(unpackedPayload);
|
|
25107
25283
|
const community = pullFromCache([
|
|
25108
25284
|
'community',
|
|
25109
25285
|
'get',
|
|
25110
|
-
|
|
25286
|
+
unpackedPayload.communities[0].communityId,
|
|
25111
25287
|
]);
|
|
25112
25288
|
callback(community.data);
|
|
25113
25289
|
}
|
|
@@ -25143,21 +25319,22 @@ function getEventRelatedMember(event, payload) {
|
|
|
25143
25319
|
const createCommunityMemberEventSubscriber = (event, callback) => {
|
|
25144
25320
|
const client = getActiveClient();
|
|
25145
25321
|
const filter = (payload) => {
|
|
25322
|
+
const unpackedPayload = unpackCommunityPayload(payload);
|
|
25146
25323
|
if (!client.cache) {
|
|
25147
25324
|
// TODO: here we are missing specific properties here!
|
|
25148
|
-
callback(
|
|
25325
|
+
callback(unpackedPayload.communities[0], getEventRelatedMember(event, unpackedPayload));
|
|
25149
25326
|
}
|
|
25150
25327
|
else {
|
|
25151
|
-
ingestInCache(
|
|
25328
|
+
ingestInCache(unpackedPayload);
|
|
25152
25329
|
const community = pullFromCache([
|
|
25153
25330
|
'community',
|
|
25154
25331
|
'get',
|
|
25155
|
-
|
|
25332
|
+
unpackedPayload.communities[0].communityId,
|
|
25156
25333
|
]);
|
|
25157
25334
|
const member = pullFromCache([
|
|
25158
25335
|
'communityUsers',
|
|
25159
25336
|
'get',
|
|
25160
|
-
getResolver('communityUsers')(getEventRelatedMember(event,
|
|
25337
|
+
getResolver('communityUsers')(getEventRelatedMember(event, unpackedPayload)),
|
|
25161
25338
|
]);
|
|
25162
25339
|
callback(community.data, member.data);
|
|
25163
25340
|
}
|
|
@@ -26185,7 +26362,7 @@ const liveFollowers = (params, callback, config) => {
|
|
|
26185
26362
|
.map(key => pullFromCache(['follow', 'get', key]))
|
|
26186
26363
|
.filter(Boolean)
|
|
26187
26364
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
26188
|
-
if (params.status) {
|
|
26365
|
+
if (params.status && params.status !== 'all') {
|
|
26189
26366
|
followers = filterByPropEquality(followers, 'status', params.status);
|
|
26190
26367
|
}
|
|
26191
26368
|
callback({
|
|
@@ -26275,7 +26452,7 @@ const liveFollowings = (params, callback, config) => {
|
|
|
26275
26452
|
.map(key => pullFromCache(['follow', 'get', key]))
|
|
26276
26453
|
.filter(Boolean)
|
|
26277
26454
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
26278
|
-
if (params.status) {
|
|
26455
|
+
if (params.status && params.status !== 'all') {
|
|
26279
26456
|
followings = filterByPropEquality(followings, 'status', params.status);
|
|
26280
26457
|
}
|
|
26281
26458
|
callback({
|
|
@@ -27276,7 +27453,10 @@ const createUserToken = async (apiKey, apiRegion, params) => {
|
|
|
27276
27453
|
};
|
|
27277
27454
|
|
|
27278
27455
|
exports.API_REGIONS = API_REGIONS;
|
|
27456
|
+
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
27457
|
+
exports.CommunityPostSettings = CommunityPostSettings;
|
|
27279
27458
|
exports.ContentFeedType = ContentFeedType;
|
|
27459
|
+
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
27280
27460
|
exports.FileType = FileType;
|
|
27281
27461
|
exports.VERSION = VERSION$1;
|
|
27282
27462
|
exports.VideoResolution = VideoResolution;
|
|
@@ -27371,6 +27551,7 @@ exports.joinChannel = joinChannel;
|
|
|
27371
27551
|
exports.joinCommunity = joinCommunity;
|
|
27372
27552
|
exports.leaveChannel = leaveChannel;
|
|
27373
27553
|
exports.leaveCommunity = leaveCommunity;
|
|
27554
|
+
exports.liveChannels = liveChannels;
|
|
27374
27555
|
exports.liveComments = liveComments;
|
|
27375
27556
|
exports.liveFollowers = liveFollowers;
|
|
27376
27557
|
exports.liveFollowings = liveFollowings;
|