@amityco/ts-sdk 6.4.6-fcf3ec9.0 → 6.5.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/client/observers/getTotalUnreadCount.d.ts.map +1 -1
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts +2 -17
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getTopTrendingCommunities.d.ts +1 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts +2 -17
- package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities.d.ts +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities.d.ts +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities.d.ts.map +1 -1
- package/dist/index.cjs.js +116 -25
- package/dist/index.esm.js +116 -25
- package/dist/index.umd.js +4 -4
- package/dist/streamRepository/observers/getStreamById.d.ts +19 -2
- package/dist/streamRepository/observers/getStreamById.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreams.d.ts.map +1 -1
- package/dist/streamRepository/observers/tests/getStreamById.test.d.ts +2 -0
- package/dist/streamRepository/observers/tests/getStreamById.test.d.ts.map +1 -0
- package/dist/utils/tests/dummy/stream.d.ts +22 -0
- package/dist/utils/tests/dummy/stream.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/client/observers/getTotalUnreadCount.ts +1 -7
- package/src/client/observers/tests/getTotalUnreadCount.test.ts +3 -10
- package/src/communityRepository/api/getRecommendedCommunities.ts +5 -46
- package/src/communityRepository/api/getTopTrendingCommunities.ts +1 -1
- package/src/communityRepository/api/getTrendingCommunities.ts +4 -51
- package/src/communityRepository/observers/getRecommendedCommunities.ts +6 -9
- package/src/communityRepository/observers/getTrendingCommunities.ts +7 -10
- package/src/streamRepository/observers/getStreamById.ts +35 -1
- package/src/streamRepository/observers/getStreams.ts +6 -5
- package/src/streamRepository/observers/tests/getStreamById.test.ts +44 -0
- package/src/utils/tests/dummy/stream.ts +47 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTotalUnreadCount.d.ts","sourceRoot":"","sources":["../../../src/client/observers/getTotalUnreadCount.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM,kBAAkB,CAAC,MAAM,CAAC,KACzC,MAAM,
|
|
1
|
+
{"version":3,"file":"getTotalUnreadCount.d.ts","sourceRoot":"","sources":["../../../src/client/observers/getTotalUnreadCount.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM,kBAAkB,CAAC,MAAM,CAAC,KACzC,MAAM,YAeR,CAAC"}
|
|
@@ -11,22 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @category Community API
|
|
13
13
|
* @async
|
|
14
|
+
* @private
|
|
14
15
|
*/
|
|
15
|
-
export declare const getRecommendedCommunities:
|
|
16
|
-
(query?: Partial<Amity.PageLimit>): Promise<Amity.Cached<Amity.Community[]>>;
|
|
17
|
-
/**
|
|
18
|
-
* ```js
|
|
19
|
-
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
20
|
-
* const communities = CommunityRepository.getRecommendedCommunities.locally()
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Gets a list of recommended {@link Amity.Community} objects from cache
|
|
24
|
-
*
|
|
25
|
-
* @param query The query parameters
|
|
26
|
-
* @returns communities
|
|
27
|
-
*
|
|
28
|
-
* @category Community API
|
|
29
|
-
*/
|
|
30
|
-
locally(query: Parameters<typeof getRecommendedCommunities>[0]): Amity.Cached<Amity.Community[]> | undefined;
|
|
31
|
-
};
|
|
16
|
+
export declare const getRecommendedCommunities: (query?: Amity.PageLimit) => Promise<Amity.Cached<Amity.Community[]>>;
|
|
32
17
|
//# sourceMappingURL=getRecommendedCommunities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRecommendedCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/api/getRecommendedCommunities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getRecommendedCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/api/getRecommendedCommunities.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,WAC5B,MAAM,SAAS,KACtB,QAAQ,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,CAAC,CAuBzC,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* ```js
|
|
6
6
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
7
|
-
* const trendingCommunities = await CommunityRepository.
|
|
7
|
+
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
8
8
|
* ```
|
|
9
9
|
*
|
|
10
10
|
* Gets a list of top trending {@link Amity.Community} objects
|
|
@@ -11,22 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @category Community API
|
|
13
13
|
* @async
|
|
14
|
+
* @private
|
|
14
15
|
*/
|
|
15
|
-
export declare const getTrendingCommunities:
|
|
16
|
-
(query: Amity.PageLimit): Promise<Amity.Cached<Amity.Community[]>>;
|
|
17
|
-
/**
|
|
18
|
-
* ```js
|
|
19
|
-
* import { getTrendingCommunities } from '@amityco/ts-sdk'
|
|
20
|
-
* const communities = getTrendingCommunities.locally()
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* Gets a list of trending {@link Amity.Community} objects from cache
|
|
24
|
-
*
|
|
25
|
-
* @param query The query parameters
|
|
26
|
-
* @returns communities
|
|
27
|
-
*
|
|
28
|
-
* @category Community API
|
|
29
|
-
*/
|
|
30
|
-
locally(query: Parameters<typeof getTrendingCommunities>[0]): Amity.Cached<Amity.Community[]> | undefined;
|
|
31
|
-
};
|
|
16
|
+
export declare const getTrendingCommunities: (query?: Amity.PageLimit) => Promise<Amity.Cached<Amity.Community[]>>;
|
|
32
17
|
//# sourceMappingURL=getTrendingCommunities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTrendingCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/api/getTrendingCommunities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTrendingCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/api/getTrendingCommunities.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,WACzB,MAAM,SAAS,KACtB,QAAQ,MAAM,MAAM,CAAC,MAAM,SAAS,EAAE,CAAC,CAuBzC,CAAC"}
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @category Community Live Collection
|
|
18
18
|
*/
|
|
19
|
-
export declare const getRecommendedCommunities: (params: Amity.
|
|
19
|
+
export declare const getRecommendedCommunities: (params: Amity.PageLimit, callback: Amity.LiveCollectionCallback<Amity.Community>, config?: Amity.LiveCollectionConfig) => () => void;
|
|
20
20
|
//# sourceMappingURL=getRecommendedCommunities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRecommendedCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/observers/getRecommendedCommunities.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,WAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"getRecommendedCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/observers/getRecommendedCommunities.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,yBAAyB,WAC5B,MAAM,SAAS,YACb,MAAM,sBAAsB,CAAC,MAAM,SAAS,CAAC,WAC9C,MAAM,oBAAoB,eAwFpC,CAAC"}
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @category Community Live Collection
|
|
18
18
|
*/
|
|
19
|
-
export declare const getTrendingCommunities: (params: Amity.
|
|
19
|
+
export declare const getTrendingCommunities: (params: Amity.PageLimit, callback: Amity.LiveCollectionCallback<Amity.Community>, config?: Amity.LiveCollectionConfig) => () => void;
|
|
20
20
|
//# sourceMappingURL=getTrendingCommunities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTrendingCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/observers/getTrendingCommunities.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,WACzB,MAAM,
|
|
1
|
+
{"version":3,"file":"getTrendingCommunities.d.ts","sourceRoot":"","sources":["../../../src/communityRepository/observers/getTrendingCommunities.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,WACzB,MAAM,SAAS,YACb,MAAM,sBAAsB,CAAC,MAAM,SAAS,CAAC,WAC9C,MAAM,oBAAoB,eAwFpC,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -96,8 +96,8 @@ const PostContentType = Object.freeze({
|
|
|
96
96
|
|
|
97
97
|
function getVersion() {
|
|
98
98
|
try {
|
|
99
|
-
// the string ''v6.
|
|
100
|
-
return 'v6.
|
|
99
|
+
// the string ''v6.5.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
100
|
+
return 'v6.5.0-cjs';
|
|
101
101
|
}
|
|
102
102
|
catch (error) {
|
|
103
103
|
return '__dev__';
|
|
@@ -22566,12 +22566,8 @@ const getTotalUnreadCount = (callback) => {
|
|
|
22566
22566
|
if (!userId)
|
|
22567
22567
|
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22568
22568
|
const callbackDataSelector = (data) => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : 0; };
|
|
22569
|
-
// based on the mobile specs, unreadCount will not trigger observer when userMarker
|
|
22570
|
-
// is re-fetched, so apply this filter to ensure the behavior is the same.
|
|
22571
|
-
const callbackFilter = (newModel, oldModel) => (newModel === null || newModel === void 0 ? void 0 : newModel.unreadCount) !== (oldModel === null || oldModel === void 0 ? void 0 : oldModel.unreadCount);
|
|
22572
22569
|
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched], {
|
|
22573
22570
|
callbackDataSelector,
|
|
22574
|
-
callbackFilter,
|
|
22575
22571
|
});
|
|
22576
22572
|
};
|
|
22577
22573
|
|
|
@@ -29929,7 +29925,7 @@ const leaveCommunity = async (communityId) => {
|
|
|
29929
29925
|
*
|
|
29930
29926
|
* ```js
|
|
29931
29927
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29932
|
-
* const trendingCommunities = await CommunityRepository.
|
|
29928
|
+
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
29933
29929
|
* ```
|
|
29934
29930
|
*
|
|
29935
29931
|
* Gets a list of top trending {@link Amity.Community} objects
|
|
@@ -30545,6 +30541,37 @@ const getCommunity = (communityId, callback) => {
|
|
|
30545
30541
|
};
|
|
30546
30542
|
/* end_public_function */
|
|
30547
30543
|
|
|
30544
|
+
/**
|
|
30545
|
+
* ```js
|
|
30546
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30547
|
+
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
30548
|
+
* ```
|
|
30549
|
+
*
|
|
30550
|
+
* Gets a list of top trending {@link Amity.Community} objects
|
|
30551
|
+
*
|
|
30552
|
+
* @param query The query parameters
|
|
30553
|
+
* @returns A list of {@link Amity.Community} objects
|
|
30554
|
+
*
|
|
30555
|
+
* @category Community API
|
|
30556
|
+
* @async
|
|
30557
|
+
* @private
|
|
30558
|
+
*/
|
|
30559
|
+
const getTrendingCommunities$1 = async (query) => {
|
|
30560
|
+
const client = getActiveClient();
|
|
30561
|
+
client.log('community/getTrendingCommunities', query);
|
|
30562
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = query !== null && query !== void 0 ? query : {};
|
|
30563
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
30564
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
30565
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
30566
|
+
const data = prepareCommunityPayload(payload);
|
|
30567
|
+
const { communities } = data;
|
|
30568
|
+
const cachedAt = client.cache && Date.now();
|
|
30569
|
+
if (client.cache) {
|
|
30570
|
+
ingestInCache(data, { cachedAt });
|
|
30571
|
+
}
|
|
30572
|
+
return { data: communities, cachedAt };
|
|
30573
|
+
};
|
|
30574
|
+
|
|
30548
30575
|
const communityQueryFilter = (data, params, userId) => {
|
|
30549
30576
|
let communities = data;
|
|
30550
30577
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
@@ -30580,8 +30607,9 @@ const communityQueryFilter = (data, params, userId) => {
|
|
|
30580
30607
|
return communities;
|
|
30581
30608
|
};
|
|
30582
30609
|
|
|
30610
|
+
/* eslint-disable no-use-before-define */
|
|
30583
30611
|
/* begin_public_function
|
|
30584
|
-
id: community.query
|
|
30612
|
+
id: community.query.trending_communities
|
|
30585
30613
|
*/
|
|
30586
30614
|
/**
|
|
30587
30615
|
* ```js
|
|
@@ -30608,7 +30636,7 @@ const getTrendingCommunities = (params, callback, config) => {
|
|
|
30608
30636
|
}
|
|
30609
30637
|
const timestamp = Date.now();
|
|
30610
30638
|
log(`getTrendingCommunities(tmpid: ${timestamp}) > listen`);
|
|
30611
|
-
const { limit: queryLimit } = params
|
|
30639
|
+
const { limit: queryLimit } = params;
|
|
30612
30640
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
30613
30641
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
30614
30642
|
const disposers = [];
|
|
@@ -30640,17 +30668,17 @@ const getTrendingCommunities = (params, callback, config) => {
|
|
|
30640
30668
|
responder(collection);
|
|
30641
30669
|
};
|
|
30642
30670
|
const onFetch = (initial = false) => {
|
|
30643
|
-
var _a, _b
|
|
30671
|
+
var _a, _b;
|
|
30644
30672
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30645
30673
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30646
30674
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30647
30675
|
return;
|
|
30648
|
-
const query = createQuery(
|
|
30649
|
-
runQuery(query, ({ data: result, error, loading
|
|
30676
|
+
const query = createQuery(getTrendingCommunities$1, params);
|
|
30677
|
+
runQuery(query, ({ data: result, error, loading }) => {
|
|
30650
30678
|
const data = {
|
|
30651
30679
|
loading,
|
|
30652
30680
|
error,
|
|
30653
|
-
params
|
|
30681
|
+
params,
|
|
30654
30682
|
data: communities,
|
|
30655
30683
|
};
|
|
30656
30684
|
if (result) {
|
|
@@ -30671,7 +30699,41 @@ const getTrendingCommunities = (params, callback, config) => {
|
|
|
30671
30699
|
/* end_public_function */
|
|
30672
30700
|
|
|
30673
30701
|
/* begin_public_function
|
|
30674
|
-
id: community.query
|
|
30702
|
+
id: community.query.recommended_communities
|
|
30703
|
+
*/
|
|
30704
|
+
/**
|
|
30705
|
+
* ```js
|
|
30706
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30707
|
+
* const communities = await CommunityRepository.getRecommendedCommunities()
|
|
30708
|
+
* ```
|
|
30709
|
+
*
|
|
30710
|
+
* Gets a list of recommended {@link Amity.Community} objects
|
|
30711
|
+
*
|
|
30712
|
+
* @param query The query parameters
|
|
30713
|
+
* @returns A list of {@link Amity.Community} objects
|
|
30714
|
+
*
|
|
30715
|
+
* @category Community API
|
|
30716
|
+
* @async
|
|
30717
|
+
* @private
|
|
30718
|
+
*/
|
|
30719
|
+
const getRecommendedCommunities$1 = async (query) => {
|
|
30720
|
+
const client = getActiveClient();
|
|
30721
|
+
client.log('community/getRecommendedCommunities', query);
|
|
30722
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = query !== null && query !== void 0 ? query : {};
|
|
30723
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
30724
|
+
// const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
30725
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
30726
|
+
const data = prepareCommunityPayload(payload);
|
|
30727
|
+
const { communities } = data;
|
|
30728
|
+
const cachedAt = client.cache && Date.now();
|
|
30729
|
+
if (client.cache) {
|
|
30730
|
+
ingestInCache(data, { cachedAt });
|
|
30731
|
+
}
|
|
30732
|
+
return { data: communities, cachedAt };
|
|
30733
|
+
};
|
|
30734
|
+
|
|
30735
|
+
/* begin_public_function
|
|
30736
|
+
id: community.query.recommended_communities
|
|
30675
30737
|
*/
|
|
30676
30738
|
/**
|
|
30677
30739
|
* ```js
|
|
@@ -30698,7 +30760,7 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
30698
30760
|
}
|
|
30699
30761
|
const timestamp = Date.now();
|
|
30700
30762
|
log(`getRecommendedCommunities(tmpid: ${timestamp}) > listen`);
|
|
30701
|
-
const { limit: queryLimit } = params
|
|
30763
|
+
const { limit: queryLimit } = params; __rest(params, ["limit"]);
|
|
30702
30764
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
30703
30765
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
30704
30766
|
const disposers = [];
|
|
@@ -30730,17 +30792,17 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
30730
30792
|
responder(collection);
|
|
30731
30793
|
};
|
|
30732
30794
|
const onFetch = (initial = false) => {
|
|
30733
|
-
var _a, _b
|
|
30795
|
+
var _a, _b;
|
|
30734
30796
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30735
30797
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30736
30798
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30737
30799
|
return;
|
|
30738
|
-
const query = createQuery(
|
|
30739
|
-
runQuery(query, ({ data: result, error, loading
|
|
30800
|
+
const query = createQuery(getRecommendedCommunities$1, params);
|
|
30801
|
+
runQuery(query, ({ data: result, error, loading }) => {
|
|
30740
30802
|
const data = {
|
|
30741
30803
|
loading,
|
|
30742
30804
|
error,
|
|
30743
|
-
params
|
|
30805
|
+
params,
|
|
30744
30806
|
data: communities,
|
|
30745
30807
|
};
|
|
30746
30808
|
if (result) {
|
|
@@ -33339,7 +33401,8 @@ const onStreamRecorded = (callback) => {
|
|
|
33339
33401
|
/**
|
|
33340
33402
|
* ```js
|
|
33341
33403
|
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
33342
|
-
* const
|
|
33404
|
+
* const unsub = StreamRepository.getStreamById('foobar')
|
|
33405
|
+
* unsub()
|
|
33343
33406
|
* ```
|
|
33344
33407
|
*
|
|
33345
33408
|
* Fetches a {@link Amity.Stream} object
|
|
@@ -33356,7 +33419,33 @@ const getStreamById = (streamId, callback) => {
|
|
|
33356
33419
|
onStreamStopped,
|
|
33357
33420
|
]);
|
|
33358
33421
|
};
|
|
33359
|
-
/* end_public_function */
|
|
33422
|
+
/* end_public_function */
|
|
33423
|
+
/**
|
|
33424
|
+
* ```js
|
|
33425
|
+
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
33426
|
+
* const stream = StreamRepository.getStreamById.locally('foobar')
|
|
33427
|
+
* ```
|
|
33428
|
+
*
|
|
33429
|
+
* Fetches a {@link Amity.Stream} live object
|
|
33430
|
+
*
|
|
33431
|
+
* @param streamId the ID of the {@link Amity.Stream} to fetch
|
|
33432
|
+
* @returns the associated {@link Amity.Stream} live object
|
|
33433
|
+
*
|
|
33434
|
+
* @category Stream API
|
|
33435
|
+
*/
|
|
33436
|
+
getStreamById.locally = (streamId) => {
|
|
33437
|
+
const client = getActiveClient();
|
|
33438
|
+
client.log('stream/getStreamById', streamId);
|
|
33439
|
+
if (!client.cache)
|
|
33440
|
+
return;
|
|
33441
|
+
const cached = pullFromCache(['stream', 'get', streamId]);
|
|
33442
|
+
if (!cached)
|
|
33443
|
+
return;
|
|
33444
|
+
return {
|
|
33445
|
+
data: cached.data,
|
|
33446
|
+
cachedAt: cached.cachedAt,
|
|
33447
|
+
};
|
|
33448
|
+
};
|
|
33360
33449
|
|
|
33361
33450
|
/* begin_public_function
|
|
33362
33451
|
id: stream.query
|
|
@@ -33381,12 +33470,12 @@ const getStreams = (params, callback, config) => {
|
|
|
33381
33470
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
33382
33471
|
}
|
|
33383
33472
|
const timestamp = Date.now();
|
|
33384
|
-
log(`
|
|
33473
|
+
log(`getStreams(tmpid: ${timestamp}) > listen`);
|
|
33385
33474
|
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
33386
33475
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
33387
33476
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
33388
33477
|
const disposers = [];
|
|
33389
|
-
const cacheKey = ['streams', 'collection',
|
|
33478
|
+
const cacheKey = ['streams', 'collection', params];
|
|
33390
33479
|
const applyFilter = (data) => {
|
|
33391
33480
|
let streams = filterByPropEquality(data, 'isDeleted', params.isDeleted);
|
|
33392
33481
|
streams = streams.sort(params.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
@@ -33395,7 +33484,9 @@ const getStreams = (params, callback, config) => {
|
|
|
33395
33484
|
const responder = (data, isEventModel = false) => {
|
|
33396
33485
|
var _a, _b;
|
|
33397
33486
|
const streams = (_a = data.data
|
|
33398
|
-
.map(streamId =>
|
|
33487
|
+
.map(streamId => {
|
|
33488
|
+
return pullFromCache(['stream', 'get', streamId]);
|
|
33489
|
+
})
|
|
33399
33490
|
.filter(Boolean)
|
|
33400
33491
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
33401
33492
|
callback({
|
|
@@ -33442,7 +33533,7 @@ const getStreams = (params, callback, config) => {
|
|
|
33442
33533
|
disposers.push(onStreamRecorded(realtimeRouter()), onStreamStarted(realtimeRouter()), onStreamStopped(realtimeRouter()));
|
|
33443
33534
|
onFetch(true);
|
|
33444
33535
|
return () => {
|
|
33445
|
-
log(`
|
|
33536
|
+
log(`getStreams(tmpid: ${timestamp}) > dispose`);
|
|
33446
33537
|
disposers.forEach(fn => fn());
|
|
33447
33538
|
};
|
|
33448
33539
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -82,8 +82,8 @@ const PostContentType = Object.freeze({
|
|
|
82
82
|
|
|
83
83
|
function getVersion() {
|
|
84
84
|
try {
|
|
85
|
-
// the string ''v6.
|
|
86
|
-
return 'v6.
|
|
85
|
+
// the string ''v6.5.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
86
|
+
return 'v6.5.0-esm';
|
|
87
87
|
}
|
|
88
88
|
catch (error) {
|
|
89
89
|
return '__dev__';
|
|
@@ -22552,12 +22552,8 @@ const getTotalUnreadCount = (callback) => {
|
|
|
22552
22552
|
if (!userId)
|
|
22553
22553
|
throw new ASCError('The _id has not been defined in ActiveUser', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
22554
22554
|
const callbackDataSelector = (data) => { var _a; return (_a = data === null || data === void 0 ? void 0 : data.unreadCount) !== null && _a !== void 0 ? _a : 0; };
|
|
22555
|
-
// based on the mobile specs, unreadCount will not trigger observer when userMarker
|
|
22556
|
-
// is re-fetched, so apply this filter to ensure the behavior is the same.
|
|
22557
|
-
const callbackFilter = (newModel, oldModel) => (newModel === null || newModel === void 0 ? void 0 : newModel.unreadCount) !== (oldModel === null || oldModel === void 0 ? void 0 : oldModel.unreadCount);
|
|
22558
22555
|
return liveObject(userId, callback, 'userId', getUserMarker, [onUserMarkerFetched], {
|
|
22559
22556
|
callbackDataSelector,
|
|
22560
|
-
callbackFilter,
|
|
22561
22557
|
});
|
|
22562
22558
|
};
|
|
22563
22559
|
|
|
@@ -29915,7 +29911,7 @@ const leaveCommunity = async (communityId) => {
|
|
|
29915
29911
|
*
|
|
29916
29912
|
* ```js
|
|
29917
29913
|
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
29918
|
-
* const trendingCommunities = await CommunityRepository.
|
|
29914
|
+
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
29919
29915
|
* ```
|
|
29920
29916
|
*
|
|
29921
29917
|
* Gets a list of top trending {@link Amity.Community} objects
|
|
@@ -30531,6 +30527,37 @@ const getCommunity = (communityId, callback) => {
|
|
|
30531
30527
|
};
|
|
30532
30528
|
/* end_public_function */
|
|
30533
30529
|
|
|
30530
|
+
/**
|
|
30531
|
+
* ```js
|
|
30532
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30533
|
+
* const trendingCommunities = await CommunityRepository.getTrendingCommunities()
|
|
30534
|
+
* ```
|
|
30535
|
+
*
|
|
30536
|
+
* Gets a list of top trending {@link Amity.Community} objects
|
|
30537
|
+
*
|
|
30538
|
+
* @param query The query parameters
|
|
30539
|
+
* @returns A list of {@link Amity.Community} objects
|
|
30540
|
+
*
|
|
30541
|
+
* @category Community API
|
|
30542
|
+
* @async
|
|
30543
|
+
* @private
|
|
30544
|
+
*/
|
|
30545
|
+
const getTrendingCommunities$1 = async (query) => {
|
|
30546
|
+
const client = getActiveClient();
|
|
30547
|
+
client.log('community/getTrendingCommunities', query);
|
|
30548
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = query !== null && query !== void 0 ? query : {};
|
|
30549
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
30550
|
+
// const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
30551
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
|
|
30552
|
+
const data = prepareCommunityPayload(payload);
|
|
30553
|
+
const { communities } = data;
|
|
30554
|
+
const cachedAt = client.cache && Date.now();
|
|
30555
|
+
if (client.cache) {
|
|
30556
|
+
ingestInCache(data, { cachedAt });
|
|
30557
|
+
}
|
|
30558
|
+
return { data: communities, cachedAt };
|
|
30559
|
+
};
|
|
30560
|
+
|
|
30534
30561
|
const communityQueryFilter = (data, params, userId) => {
|
|
30535
30562
|
let communities = data;
|
|
30536
30563
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
@@ -30566,8 +30593,9 @@ const communityQueryFilter = (data, params, userId) => {
|
|
|
30566
30593
|
return communities;
|
|
30567
30594
|
};
|
|
30568
30595
|
|
|
30596
|
+
/* eslint-disable no-use-before-define */
|
|
30569
30597
|
/* begin_public_function
|
|
30570
|
-
id: community.query
|
|
30598
|
+
id: community.query.trending_communities
|
|
30571
30599
|
*/
|
|
30572
30600
|
/**
|
|
30573
30601
|
* ```js
|
|
@@ -30594,7 +30622,7 @@ const getTrendingCommunities = (params, callback, config) => {
|
|
|
30594
30622
|
}
|
|
30595
30623
|
const timestamp = Date.now();
|
|
30596
30624
|
log(`getTrendingCommunities(tmpid: ${timestamp}) > listen`);
|
|
30597
|
-
const { limit: queryLimit } = params
|
|
30625
|
+
const { limit: queryLimit } = params;
|
|
30598
30626
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
30599
30627
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
30600
30628
|
const disposers = [];
|
|
@@ -30626,17 +30654,17 @@ const getTrendingCommunities = (params, callback, config) => {
|
|
|
30626
30654
|
responder(collection);
|
|
30627
30655
|
};
|
|
30628
30656
|
const onFetch = (initial = false) => {
|
|
30629
|
-
var _a, _b
|
|
30657
|
+
var _a, _b;
|
|
30630
30658
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30631
30659
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30632
30660
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30633
30661
|
return;
|
|
30634
|
-
const query = createQuery(
|
|
30635
|
-
runQuery(query, ({ data: result, error, loading
|
|
30662
|
+
const query = createQuery(getTrendingCommunities$1, params);
|
|
30663
|
+
runQuery(query, ({ data: result, error, loading }) => {
|
|
30636
30664
|
const data = {
|
|
30637
30665
|
loading,
|
|
30638
30666
|
error,
|
|
30639
|
-
params
|
|
30667
|
+
params,
|
|
30640
30668
|
data: communities,
|
|
30641
30669
|
};
|
|
30642
30670
|
if (result) {
|
|
@@ -30657,7 +30685,41 @@ const getTrendingCommunities = (params, callback, config) => {
|
|
|
30657
30685
|
/* end_public_function */
|
|
30658
30686
|
|
|
30659
30687
|
/* begin_public_function
|
|
30660
|
-
id: community.query
|
|
30688
|
+
id: community.query.recommended_communities
|
|
30689
|
+
*/
|
|
30690
|
+
/**
|
|
30691
|
+
* ```js
|
|
30692
|
+
* import { CommunityRepository } from '@amityco/ts-sdk'
|
|
30693
|
+
* const communities = await CommunityRepository.getRecommendedCommunities()
|
|
30694
|
+
* ```
|
|
30695
|
+
*
|
|
30696
|
+
* Gets a list of recommended {@link Amity.Community} objects
|
|
30697
|
+
*
|
|
30698
|
+
* @param query The query parameters
|
|
30699
|
+
* @returns A list of {@link Amity.Community} objects
|
|
30700
|
+
*
|
|
30701
|
+
* @category Community API
|
|
30702
|
+
* @async
|
|
30703
|
+
* @private
|
|
30704
|
+
*/
|
|
30705
|
+
const getRecommendedCommunities$1 = async (query) => {
|
|
30706
|
+
const client = getActiveClient();
|
|
30707
|
+
client.log('community/getRecommendedCommunities', query);
|
|
30708
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = query !== null && query !== void 0 ? query : {};
|
|
30709
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
30710
|
+
// const { data: payload } = await client.http.get<Amity.Response<CommunityPayload>>(
|
|
30711
|
+
const { data: payload } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
|
|
30712
|
+
const data = prepareCommunityPayload(payload);
|
|
30713
|
+
const { communities } = data;
|
|
30714
|
+
const cachedAt = client.cache && Date.now();
|
|
30715
|
+
if (client.cache) {
|
|
30716
|
+
ingestInCache(data, { cachedAt });
|
|
30717
|
+
}
|
|
30718
|
+
return { data: communities, cachedAt };
|
|
30719
|
+
};
|
|
30720
|
+
|
|
30721
|
+
/* begin_public_function
|
|
30722
|
+
id: community.query.recommended_communities
|
|
30661
30723
|
*/
|
|
30662
30724
|
/**
|
|
30663
30725
|
* ```js
|
|
@@ -30684,7 +30746,7 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
30684
30746
|
}
|
|
30685
30747
|
const timestamp = Date.now();
|
|
30686
30748
|
log(`getRecommendedCommunities(tmpid: ${timestamp}) > listen`);
|
|
30687
|
-
const { limit: queryLimit } = params
|
|
30749
|
+
const { limit: queryLimit } = params; __rest(params, ["limit"]);
|
|
30688
30750
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
30689
30751
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
30690
30752
|
const disposers = [];
|
|
@@ -30716,17 +30778,17 @@ const getRecommendedCommunities = (params, callback, config) => {
|
|
|
30716
30778
|
responder(collection);
|
|
30717
30779
|
};
|
|
30718
30780
|
const onFetch = (initial = false) => {
|
|
30719
|
-
var _a, _b
|
|
30781
|
+
var _a, _b;
|
|
30720
30782
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
30721
30783
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
30722
30784
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
30723
30785
|
return;
|
|
30724
|
-
const query = createQuery(
|
|
30725
|
-
runQuery(query, ({ data: result, error, loading
|
|
30786
|
+
const query = createQuery(getRecommendedCommunities$1, params);
|
|
30787
|
+
runQuery(query, ({ data: result, error, loading }) => {
|
|
30726
30788
|
const data = {
|
|
30727
30789
|
loading,
|
|
30728
30790
|
error,
|
|
30729
|
-
params
|
|
30791
|
+
params,
|
|
30730
30792
|
data: communities,
|
|
30731
30793
|
};
|
|
30732
30794
|
if (result) {
|
|
@@ -33325,7 +33387,8 @@ const onStreamRecorded = (callback) => {
|
|
|
33325
33387
|
/**
|
|
33326
33388
|
* ```js
|
|
33327
33389
|
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
33328
|
-
* const
|
|
33390
|
+
* const unsub = StreamRepository.getStreamById('foobar')
|
|
33391
|
+
* unsub()
|
|
33329
33392
|
* ```
|
|
33330
33393
|
*
|
|
33331
33394
|
* Fetches a {@link Amity.Stream} object
|
|
@@ -33342,7 +33405,33 @@ const getStreamById = (streamId, callback) => {
|
|
|
33342
33405
|
onStreamStopped,
|
|
33343
33406
|
]);
|
|
33344
33407
|
};
|
|
33345
|
-
/* end_public_function */
|
|
33408
|
+
/* end_public_function */
|
|
33409
|
+
/**
|
|
33410
|
+
* ```js
|
|
33411
|
+
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
33412
|
+
* const stream = StreamRepository.getStreamById.locally('foobar')
|
|
33413
|
+
* ```
|
|
33414
|
+
*
|
|
33415
|
+
* Fetches a {@link Amity.Stream} live object
|
|
33416
|
+
*
|
|
33417
|
+
* @param streamId the ID of the {@link Amity.Stream} to fetch
|
|
33418
|
+
* @returns the associated {@link Amity.Stream} live object
|
|
33419
|
+
*
|
|
33420
|
+
* @category Stream API
|
|
33421
|
+
*/
|
|
33422
|
+
getStreamById.locally = (streamId) => {
|
|
33423
|
+
const client = getActiveClient();
|
|
33424
|
+
client.log('stream/getStreamById', streamId);
|
|
33425
|
+
if (!client.cache)
|
|
33426
|
+
return;
|
|
33427
|
+
const cached = pullFromCache(['stream', 'get', streamId]);
|
|
33428
|
+
if (!cached)
|
|
33429
|
+
return;
|
|
33430
|
+
return {
|
|
33431
|
+
data: cached.data,
|
|
33432
|
+
cachedAt: cached.cachedAt,
|
|
33433
|
+
};
|
|
33434
|
+
};
|
|
33346
33435
|
|
|
33347
33436
|
/* begin_public_function
|
|
33348
33437
|
id: stream.query
|
|
@@ -33367,12 +33456,12 @@ const getStreams = (params, callback, config) => {
|
|
|
33367
33456
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
33368
33457
|
}
|
|
33369
33458
|
const timestamp = Date.now();
|
|
33370
|
-
log(`
|
|
33459
|
+
log(`getStreams(tmpid: ${timestamp}) > listen`);
|
|
33371
33460
|
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
33372
33461
|
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
33373
33462
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
33374
33463
|
const disposers = [];
|
|
33375
|
-
const cacheKey = ['streams', 'collection',
|
|
33464
|
+
const cacheKey = ['streams', 'collection', params];
|
|
33376
33465
|
const applyFilter = (data) => {
|
|
33377
33466
|
let streams = filterByPropEquality(data, 'isDeleted', params.isDeleted);
|
|
33378
33467
|
streams = streams.sort(params.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
@@ -33381,7 +33470,9 @@ const getStreams = (params, callback, config) => {
|
|
|
33381
33470
|
const responder = (data, isEventModel = false) => {
|
|
33382
33471
|
var _a, _b;
|
|
33383
33472
|
const streams = (_a = data.data
|
|
33384
|
-
.map(streamId =>
|
|
33473
|
+
.map(streamId => {
|
|
33474
|
+
return pullFromCache(['stream', 'get', streamId]);
|
|
33475
|
+
})
|
|
33385
33476
|
.filter(Boolean)
|
|
33386
33477
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
33387
33478
|
callback({
|
|
@@ -33428,7 +33519,7 @@ const getStreams = (params, callback, config) => {
|
|
|
33428
33519
|
disposers.push(onStreamRecorded(realtimeRouter()), onStreamStarted(realtimeRouter()), onStreamStopped(realtimeRouter()));
|
|
33429
33520
|
onFetch(true);
|
|
33430
33521
|
return () => {
|
|
33431
|
-
log(`
|
|
33522
|
+
log(`getStreams(tmpid: ${timestamp}) > dispose`);
|
|
33432
33523
|
disposers.forEach(fn => fn());
|
|
33433
33524
|
};
|
|
33434
33525
|
};
|