@amityco/ts-sdk-react-native 6.13.0 → 6.13.2
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/paging.d.ts +3 -0
- package/dist/@types/core/paging.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +2 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +6 -2
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +2 -1
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/channelRepsitory/api/queryChannels.d.ts +1 -1
- package/dist/channelRepsitory/api/queryChannels.d.ts.map +1 -1
- package/dist/channelRepsitory/observers/getChannels.d.ts.map +1 -1
- package/dist/commentRepository/api/queryComments.d.ts +1 -1
- package/dist/commentRepository/api/queryComments.d.ts.map +1 -1
- package/dist/commentRepository/observers/getComments.d.ts.map +1 -1
- package/dist/index.cjs.js +65 -58
- package/dist/index.esm.js +65 -58
- package/dist/index.umd.js +2 -2
- package/dist/streamRepository/observers/getStreams.d.ts +1 -0
- package/dist/streamRepository/observers/getStreams.d.ts.map +1 -1
- package/dist/userRepository/api/queryUsers.d.ts +2 -2
- package/dist/userRepository/api/queryUsers.d.ts.map +1 -1
- package/dist/userRepository/observers/getUsers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/core/paging.ts +2 -0
- package/src/@types/domains/channel.ts +2 -1
- package/src/@types/domains/comment.ts +3 -2
- package/src/@types/domains/user.ts +2 -1
- package/src/channelRepsitory/api/queryChannels.ts +6 -15
- package/src/channelRepsitory/observers/getChannels.ts +24 -21
- package/src/commentRepository/api/queryComments.ts +7 -15
- package/src/commentRepository/observers/getComments.ts +9 -5
- package/src/communityRepository/api/queryCommunities.ts +2 -2
- package/src/communityRepository/communityMembership/observers/tests/getMembers.test.ts +11 -11
- package/src/communityRepository/observers/getCommunities.ts +1 -1
- package/src/streamRepository/observers/getStreams.ts +6 -5
- package/src/userRepository/api/queryUsers.ts +27 -18
- package/src/userRepository/observers/getUsers.ts +9 -6
package/dist/index.esm.js
CHANGED
|
@@ -83,8 +83,8 @@ const PostContentType = Object.freeze({
|
|
|
83
83
|
|
|
84
84
|
function getVersion() {
|
|
85
85
|
try {
|
|
86
|
-
// the string ''v6.13.
|
|
87
|
-
return 'v6.13.
|
|
86
|
+
// the string ''v6.13.2-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
87
|
+
return 'v6.13.2-esm';
|
|
88
88
|
}
|
|
89
89
|
catch (error) {
|
|
90
90
|
return '__dev__';
|
|
@@ -24590,13 +24590,13 @@ const queryChannels = async (query) => {
|
|
|
24590
24590
|
const client = getActiveClient();
|
|
24591
24591
|
client.log('channel/queryChannels', query);
|
|
24592
24592
|
// safe decapsulation
|
|
24593
|
-
const _a = query !== null && query !== void 0 ? query : {}, { page =
|
|
24593
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page = undefined, limit = 10, displayName, membership } = _a, params = __rest(_a, ["page", "limit", "displayName", "membership"]);
|
|
24594
24594
|
// API-FIX: parameters should be querystring.
|
|
24595
24595
|
// API-FIX: backend doesn't answer Amity.Response
|
|
24596
24596
|
// const { data } = await client.http.get<Amity.Response<Amity.Paged<ChannelPayload>>>(
|
|
24597
24597
|
const { data: queryPayload } = await client.http.get(`/api/v3/channels`, {
|
|
24598
24598
|
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter: membership, options: {
|
|
24599
|
-
token:
|
|
24599
|
+
token: page,
|
|
24600
24600
|
} }),
|
|
24601
24601
|
});
|
|
24602
24602
|
const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
|
|
@@ -24605,16 +24605,10 @@ const queryChannels = async (query) => {
|
|
|
24605
24605
|
const cachedAt = client.cache && Date.now();
|
|
24606
24606
|
if (client.cache) {
|
|
24607
24607
|
ingestInCache(data, { cachedAt });
|
|
24608
|
-
const cacheKey = [
|
|
24609
|
-
'channel',
|
|
24610
|
-
'query',
|
|
24611
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
24612
|
-
];
|
|
24608
|
+
const cacheKey = ['channel', 'query', Object.assign(Object.assign({}, params), { options: { limit } })];
|
|
24613
24609
|
pushToCache(cacheKey, { channels: channels.map(getResolver('channel')), paging });
|
|
24614
24610
|
}
|
|
24615
|
-
|
|
24616
|
-
const prevPage = toPage(paging.previous);
|
|
24617
|
-
return { data: channels, cachedAt, prevPage, nextPage };
|
|
24611
|
+
return { data: channels, cachedAt, paging };
|
|
24618
24612
|
};
|
|
24619
24613
|
|
|
24620
24614
|
/* begin_public_function
|
|
@@ -24682,7 +24676,7 @@ const getChannels = (params, callback, config) => {
|
|
|
24682
24676
|
case 'displayName':
|
|
24683
24677
|
/*
|
|
24684
24678
|
* The server returns channels with empty | null displayName's first before
|
|
24685
|
-
* returning sorted list of channels with displayNames
|
|
24679
|
+
* returning a sorted list of channels with displayNames
|
|
24686
24680
|
*
|
|
24687
24681
|
* This section needs to be updated as displayNames can be null as well
|
|
24688
24682
|
*/
|
|
@@ -24714,21 +24708,23 @@ const getChannels = (params, callback, config) => {
|
|
|
24714
24708
|
responder(collection);
|
|
24715
24709
|
};
|
|
24716
24710
|
const onFetch = (initial = false) => {
|
|
24717
|
-
var _a, _b
|
|
24711
|
+
var _a, _b;
|
|
24718
24712
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
24719
24713
|
const channels = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
24720
24714
|
if (!initial && channels.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
24721
24715
|
return;
|
|
24722
|
-
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page:
|
|
24723
|
-
runQuery(query, ({ data: result, error, loading,
|
|
24716
|
+
const query = createQuery(queryChannels, Object.assign(Object.assign({}, queryParams), { page: !initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined, limit }));
|
|
24717
|
+
runQuery(query, ({ data: result, error, loading, paging }) => {
|
|
24724
24718
|
const data = {
|
|
24725
24719
|
loading,
|
|
24726
24720
|
error,
|
|
24727
|
-
params: { page },
|
|
24721
|
+
params: { page: paging === null || paging === void 0 ? void 0 : paging.next },
|
|
24728
24722
|
data: channels,
|
|
24729
24723
|
};
|
|
24730
24724
|
if (result) {
|
|
24731
|
-
data.data =
|
|
24725
|
+
data.data = initial
|
|
24726
|
+
? result.map(getResolver('channel')) // Replace all collection from BE when initial fetch
|
|
24727
|
+
: [...new Set([...channels, ...result.map(getResolver('channel'))])];
|
|
24732
24728
|
}
|
|
24733
24729
|
pushToCache(cacheKey, data);
|
|
24734
24730
|
responder(data);
|
|
@@ -27400,11 +27396,12 @@ const getUser = (userId, callback) => {
|
|
|
27400
27396
|
const queryUsers = async (query = {}) => {
|
|
27401
27397
|
const client = getActiveClient();
|
|
27402
27398
|
client.log('user/queryUsers', query);
|
|
27403
|
-
const { page =
|
|
27399
|
+
const { page, limit = 10, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "limit", "displayName", "filter", "sortBy"]);
|
|
27404
27400
|
const { data } = await client.http.get(`/api/v3/users`, {
|
|
27405
27401
|
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter,
|
|
27406
27402
|
sortBy, options: {
|
|
27407
|
-
token:
|
|
27403
|
+
token: page,
|
|
27404
|
+
limit,
|
|
27408
27405
|
} }),
|
|
27409
27406
|
});
|
|
27410
27407
|
// unpacking
|
|
@@ -27414,16 +27411,22 @@ const queryUsers = async (query = {}) => {
|
|
|
27414
27411
|
if (client.cache) {
|
|
27415
27412
|
ingestInCache(payload, { cachedAt });
|
|
27416
27413
|
/*
|
|
27417
|
-
* using query as cache key over params because if the keyword, filter, sort
|
|
27414
|
+
* using a query as a cache key over params because if the keyword, filter, sort
|
|
27418
27415
|
* change the API will NOT cache results, when it should
|
|
27419
27416
|
*/
|
|
27420
|
-
const cacheKey = [
|
|
27417
|
+
const cacheKey = [
|
|
27418
|
+
'user',
|
|
27419
|
+
'query',
|
|
27420
|
+
Object.assign(Object.assign({}, query), { options: { limit, token: page } }),
|
|
27421
|
+
];
|
|
27421
27422
|
pushToCache(cacheKey, { users: users.map(getResolver('user')), paging });
|
|
27422
27423
|
}
|
|
27423
27424
|
fireEvent('user.fetched', data);
|
|
27424
|
-
|
|
27425
|
-
|
|
27426
|
-
|
|
27425
|
+
return {
|
|
27426
|
+
data: users.map(user => LinkedObject.user(user)),
|
|
27427
|
+
cachedAt,
|
|
27428
|
+
paging,
|
|
27429
|
+
};
|
|
27427
27430
|
};
|
|
27428
27431
|
/**
|
|
27429
27432
|
* ```js
|
|
@@ -27445,18 +27448,23 @@ queryUsers.locally = (query = {}) => {
|
|
|
27445
27448
|
client.log('user/queryUsers.locally', query);
|
|
27446
27449
|
if (!client.cache)
|
|
27447
27450
|
return;
|
|
27448
|
-
const {
|
|
27451
|
+
const { limit = 10, page } = query !== null && query !== void 0 ? query : {};
|
|
27449
27452
|
const cacheKey = [
|
|
27450
27453
|
'user',
|
|
27451
27454
|
'query',
|
|
27452
|
-
Object.assign(Object.assign({}, query), { options:
|
|
27455
|
+
Object.assign(Object.assign({}, query), { options: {
|
|
27456
|
+
limit,
|
|
27457
|
+
token: page,
|
|
27458
|
+
} }),
|
|
27453
27459
|
];
|
|
27454
27460
|
const { data, cachedAt } = (_a = pullFromCache(cacheKey)) !== null && _a !== void 0 ? _a : {};
|
|
27455
27461
|
const users = (_b = data === null || data === void 0 ? void 0 : data.users.map(userId => pullFromCache(['user', 'get', userId])).filter(Boolean).map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
|
|
27456
|
-
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
27457
|
-
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
27458
27462
|
return users.length > 0 && users.length === ((_c = data === null || data === void 0 ? void 0 : data.users) === null || _c === void 0 ? void 0 : _c.length)
|
|
27459
|
-
? {
|
|
27463
|
+
? {
|
|
27464
|
+
data: users.map(LinkedObject.user),
|
|
27465
|
+
cachedAt,
|
|
27466
|
+
paging: data === null || data === void 0 ? void 0 : data.paging,
|
|
27467
|
+
}
|
|
27460
27468
|
: undefined;
|
|
27461
27469
|
};
|
|
27462
27470
|
|
|
@@ -27541,21 +27549,23 @@ const getUsers = (params, callback, config) => {
|
|
|
27541
27549
|
responder(collection, true);
|
|
27542
27550
|
};
|
|
27543
27551
|
const onFetch = (initial = false) => {
|
|
27544
|
-
var _a, _b
|
|
27552
|
+
var _a, _b;
|
|
27545
27553
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
27546
27554
|
const users = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
27547
27555
|
if (!initial && users.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
27548
27556
|
return;
|
|
27549
|
-
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { page:
|
|
27550
|
-
runQuery(query, ({ data: result, error, loading,
|
|
27557
|
+
const query = createQuery(queryUsers, Object.assign(Object.assign({}, queryParams), { limit, page: !initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined }));
|
|
27558
|
+
runQuery(query, ({ data: result, error, loading, paging }) => {
|
|
27551
27559
|
const data = {
|
|
27552
27560
|
loading,
|
|
27553
27561
|
error,
|
|
27554
|
-
params: { page },
|
|
27562
|
+
params: { page: paging === null || paging === void 0 ? void 0 : paging.next },
|
|
27555
27563
|
data: users,
|
|
27556
27564
|
};
|
|
27557
27565
|
if (result) {
|
|
27558
|
-
data.data =
|
|
27566
|
+
data.data = initial
|
|
27567
|
+
? result.map(getResolver('user'))
|
|
27568
|
+
: [...new Set([...users, ...result.map(getResolver('user'))])];
|
|
27559
27569
|
}
|
|
27560
27570
|
pushToCache(cacheKey, data);
|
|
27561
27571
|
responder(data);
|
|
@@ -32020,10 +32030,10 @@ const queryCommunities = async (query) => {
|
|
|
32020
32030
|
const client = getActiveClient();
|
|
32021
32031
|
client.log('channel/queryCommunities', query);
|
|
32022
32032
|
// safe decapsulation
|
|
32023
|
-
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
32033
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 } } = _a, params = __rest(_a, ["page"]);
|
|
32024
32034
|
const _b = params !== null && params !== void 0 ? params : {}, { displayName, membership, includeDeleted } = _b, restParams = __rest(_b, ["displayName", "membership", "includeDeleted"]);
|
|
32025
32035
|
// API-FIX: parameters should be querystring.
|
|
32026
|
-
// API-FIX: backend
|
|
32036
|
+
// API-FIX: backend doesn't answer Amity.Response
|
|
32027
32037
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
32028
32038
|
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
32029
32039
|
params: Object.assign(Object.assign({}, restParams), { isDeleted: inferIsDeleted(includeDeleted), keyword: displayName, filter: membership, options: {
|
|
@@ -32138,12 +32148,12 @@ const getCommunities = (params, callback, config) => {
|
|
|
32138
32148
|
responder(collection);
|
|
32139
32149
|
};
|
|
32140
32150
|
const onFetch = (initial = false) => {
|
|
32141
|
-
var _a, _b
|
|
32151
|
+
var _a, _b;
|
|
32142
32152
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32143
32153
|
const communities = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
32144
32154
|
if (!initial && communities.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
32145
32155
|
return;
|
|
32146
|
-
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page:
|
|
32156
|
+
const query = createQuery(queryCommunities, Object.assign(Object.assign({}, queryParams), { page: !initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : { limit } }));
|
|
32147
32157
|
runQuery(query, ({ data: result, error, loading, nextPage: page }) => {
|
|
32148
32158
|
const data = {
|
|
32149
32159
|
loading,
|
|
@@ -34603,13 +34613,13 @@ const getComment = (commentId, callback) => {
|
|
|
34603
34613
|
* @async
|
|
34604
34614
|
*/
|
|
34605
34615
|
const queryComments = async (query) => {
|
|
34606
|
-
var _a;
|
|
34607
34616
|
const client = getActiveClient();
|
|
34608
34617
|
client.log('comment/queryComments', query);
|
|
34609
|
-
const {
|
|
34618
|
+
const { limit = 10, includeDeleted } = query, params = __rest(query, ["limit", "includeDeleted"]);
|
|
34610
34619
|
const options = {
|
|
34611
|
-
type: params.sortBy ||
|
|
34612
|
-
|
|
34620
|
+
type: params.sortBy || query.limit ? 'pagination' : undefined,
|
|
34621
|
+
limit: query.limit,
|
|
34622
|
+
token: query.page,
|
|
34613
34623
|
};
|
|
34614
34624
|
// const filterByParentId = query.parentId !== undefined
|
|
34615
34625
|
// API-FIX: parameters should be querystring. (1)
|
|
@@ -34627,16 +34637,10 @@ const queryComments = async (query) => {
|
|
|
34627
34637
|
const cachedAt = client.cache && Date.now();
|
|
34628
34638
|
if (client.cache) {
|
|
34629
34639
|
ingestInCache(payload, { cachedAt });
|
|
34630
|
-
const cacheKey = [
|
|
34631
|
-
'comment',
|
|
34632
|
-
'query',
|
|
34633
|
-
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
34634
|
-
];
|
|
34640
|
+
const cacheKey = ['comment', 'query', Object.assign(Object.assign({}, params), { options: { limit } })];
|
|
34635
34641
|
pushToCache(cacheKey, { comments: comments.map(getResolver('comment')), paging });
|
|
34636
34642
|
}
|
|
34637
|
-
|
|
34638
|
-
const prevPage = toPage(paging.previous);
|
|
34639
|
-
return { data: comments, cachedAt, prevPage, nextPage };
|
|
34643
|
+
return { data: comments, cachedAt, paging };
|
|
34640
34644
|
};
|
|
34641
34645
|
|
|
34642
34646
|
/* begin_public_function
|
|
@@ -34670,7 +34674,6 @@ const getComments = (params, callback, config) => {
|
|
|
34670
34674
|
const timestamp = Date.now();
|
|
34671
34675
|
log(`getComments(tmpid: ${timestamp}) > listen`);
|
|
34672
34676
|
const { limit: queryLimit } = params, queryParams = __rest(params, ["limit"]);
|
|
34673
|
-
const limit = queryLimit !== null && queryLimit !== void 0 ? queryLimit : COLLECTION_DEFAULT_PAGINATION_LIMIT;
|
|
34674
34677
|
const { policy = COLLECTION_DEFAULT_CACHING_POLICY } = config !== null && config !== void 0 ? config : {};
|
|
34675
34678
|
const disposers = [];
|
|
34676
34679
|
const cacheKey = [
|
|
@@ -34720,15 +34723,16 @@ const getComments = (params, callback, config) => {
|
|
|
34720
34723
|
responder(collection);
|
|
34721
34724
|
};
|
|
34722
34725
|
const onFetch = (initial = false) => {
|
|
34723
|
-
var _a, _b, _c
|
|
34726
|
+
var _a, _b, _c;
|
|
34724
34727
|
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
34725
34728
|
const comments = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
34726
34729
|
if (!initial && comments.length > 0 && !((_c = collection === null || collection === void 0 ? void 0 : collection.params) === null || _c === void 0 ? void 0 : _c.page))
|
|
34727
34730
|
return;
|
|
34728
|
-
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), {
|
|
34729
|
-
runQuery(query, ({ data: result, error, loading,
|
|
34730
|
-
// depend on sortBy value we have two different pagination
|
|
34731
|
-
const
|
|
34731
|
+
const query = createQuery(queryComments, Object.assign(Object.assign({}, queryParams), { limit: queryLimit, page: !initial ? collection === null || collection === void 0 ? void 0 : collection.params.page : undefined }));
|
|
34732
|
+
runQuery(query, ({ data: result, error, loading, paging }) => {
|
|
34733
|
+
// depend on sortBy value we have two different pagination types
|
|
34734
|
+
const sorting = queryParams.sortBy || 'lastCreated';
|
|
34735
|
+
const page = sorting === 'lastCreated' ? paging === null || paging === void 0 ? void 0 : paging.next : paging === null || paging === void 0 ? void 0 : paging.previous;
|
|
34732
34736
|
const data = {
|
|
34733
34737
|
loading,
|
|
34734
34738
|
error,
|
|
@@ -34736,7 +34740,9 @@ const getComments = (params, callback, config) => {
|
|
|
34736
34740
|
data: comments,
|
|
34737
34741
|
};
|
|
34738
34742
|
if (result) {
|
|
34739
|
-
data.data =
|
|
34743
|
+
data.data = initial
|
|
34744
|
+
? result.map(getResolver('comment')) // Replace a collection list with new data from BE
|
|
34745
|
+
: [...new Set([...comments, ...result.map(getResolver('comment'))])];
|
|
34740
34746
|
}
|
|
34741
34747
|
pushToCache(cacheKey, data);
|
|
34742
34748
|
responder(data);
|
|
@@ -35138,6 +35144,7 @@ getStreamById.locally = (streamId) => {
|
|
|
35138
35144
|
*
|
|
35139
35145
|
* @param params for querying streams
|
|
35140
35146
|
* @param callback the function to call when new data are available
|
|
35147
|
+
* @param config
|
|
35141
35148
|
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the streams
|
|
35142
35149
|
*
|
|
35143
35150
|
* @category Stream Live Collection
|