@amityco/ts-sdk 0.0.1-beta.43 → 0.0.1-beta.44.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/category/api/queryCategories.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/observers/liveCommunities.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +21 -0
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/index.cjs.js +116 -62
- package/dist/index.esm.js +115 -63
- package/dist/index.umd.js +4 -4
- package/dist/message/api/queryMessages.d.ts +1 -17
- package/dist/message/api/queryMessages.d.ts.map +1 -1
- package/dist/message/utils/prepareMessagePayload.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/post/observers/livePosts.d.ts.map +1 -1
- package/dist/subChannel/api/querySubChannels.d.ts.map +1 -1
- package/dist/utils/inferIsDeleted.d.ts +2 -0
- package/dist/utils/inferIsDeleted.d.ts.map +1 -0
- package/dist/utils/tests/inferIsDeleted.test.d.ts +2 -0
- package/dist/utils/tests/inferIsDeleted.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/category/api/queryCategories.ts +3 -1
- package/src/category/observers/liveCategories.ts +1 -1
- package/src/category/observers/tests/liveCategories.test.ts +7 -5
- package/src/channel/api/tests/removeChannelMembers.test.ts +3 -4
- package/src/channel/observers/tests/liveChannels.test.ts +6 -6
- package/src/client/api/connectClient.ts +1 -1
- package/src/comment/api/queryComments.ts +3 -1
- package/src/comment/observers/liveComments.ts +1 -1
- package/src/community/api/queryCommunities.ts +2 -1
- package/src/community/api/test/queryCommunity.test.ts +2 -2
- package/src/community/observers/liveCommunities.ts +5 -8
- package/src/community/observers/tests/liveCommunities.test.ts +7 -94
- package/src/community/observers/tests/liveCommunity.test.ts +4 -4
- package/src/core/query/filtering.ts +79 -0
- package/src/core/query/query.ts +4 -4
- package/src/message/api/queryMessages.ts +7 -44
- package/src/message/api/tests/queryMessages.test.ts +2 -37
- package/src/message/observers/liveMessages.ts +2 -2
- package/src/message/tests/observers/liveMessage.test.ts +1 -1
- package/src/message/tests/observers/liveMessages.test.ts +1 -1
- package/src/message/utils/prepareMessagePayload.ts +3 -1
- package/src/post/api/queryPosts.ts +3 -1
- package/src/post/observers/livePosts.ts +7 -2
- package/src/post/observers/tests/livePosts.test.ts +10 -4
- package/src/subChannel/api/querySubChannels.ts +3 -1
- package/src/subChannel/observers/liveSubChannels.ts +1 -1
- package/src/utils/inferIsDeleted.ts +16 -0
- package/src/utils/tests/inferIsDeleted.test.ts +15 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryCategories.d.ts","sourceRoot":"","sources":["../../../src/category/api/queryCategories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queryCategories.d.ts","sourceRoot":"","sources":["../../../src/category/api/queryCategories.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;KAaK;AACL,eAAO,MAAM,eAAe;aAClB,MAAM,eAAe,GAC5B,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;IAyCjE;;;;;;;;;;;;OAYG;mBAEM,WAAW,sBAAsB,CAAC,CAAC,CAAC,CAAC,GAC3C,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,SAAS;CAjBnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryComments.d.ts","sourceRoot":"","sources":["../../../src/comment/api/queryComments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queryComments.d.ts","sourceRoot":"","sources":["../../../src/comment/api/queryComments.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;YACjB,MAAM,aAAa,GACzB,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAoDpD;;;;;;;;;;;;OAYG;mBAEM,WAAW,oBAAoB,CAAC,CAAC,CAAC,CAAC,GACzC,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC,GAAG,SAAS;CAlBtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryCommunities.d.ts","sourceRoot":"","sources":["../../../src/community/api/queryCommunities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queryCommunities.d.ts","sourceRoot":"","sources":["../../../src/community/api/queryCommunities.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;aACnB,MAAM,gBAAgB,GAC7B,QAAQ,MAAM,MAAM,CAAC,MAAM,KAAK,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC;IAkDtD;;;;;;;;;;;;OAYG;mBACgC,WAAW,uBAAuB,CAAC,CAAC,CAAC,CAAC;CAhBxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveCommunities.d.ts","sourceRoot":"","sources":["../../../src/community/observers/liveCommunities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"liveCommunities.d.ts","sourceRoot":"","sources":["../../../src/community/observers/liveCommunities.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,uBAAuB,YAC3B,MAAM,sBAAsB,CAAC,MAAM,SAAS,CAAC,WAC9C,MAAM,oBAAoB,eA0IpC,CAAC"}
|
|
@@ -31,4 +31,25 @@ export declare const filterByChannelMembership: (collection: Amity.Channel[], me
|
|
|
31
31
|
* @hidden
|
|
32
32
|
*/
|
|
33
33
|
export declare const filterByFeedType: <T extends Amity.Post<any>>(collection: T[], feedType: Amity.Feed['feedType']) => T[];
|
|
34
|
+
/**
|
|
35
|
+
* Filter a community collection by membership of the userId
|
|
36
|
+
*
|
|
37
|
+
* @param collection the community to filter
|
|
38
|
+
* @param membership the membership to be filtered by
|
|
39
|
+
* @param userId user id to be filtered by
|
|
40
|
+
* @returns a filtered collection with items only matching the criteria
|
|
41
|
+
*
|
|
42
|
+
* @hidden
|
|
43
|
+
*/
|
|
44
|
+
export declare const filterByCommunityMembership: <T extends Amity.Community>(collection: T[], membership: Amity.CommunityLiveCollection['membership'], userId: Amity.Membership<'community'>['userId']) => T[];
|
|
45
|
+
/**
|
|
46
|
+
* Filter a post collection by dataType
|
|
47
|
+
*
|
|
48
|
+
* @param collection the post to filter
|
|
49
|
+
* @param dataTypes of the post to be filtered by
|
|
50
|
+
* @returns a filtered collection with items only matching the criteria
|
|
51
|
+
*
|
|
52
|
+
* @hidden
|
|
53
|
+
*/
|
|
54
|
+
export declare const filterByPostDataTypes: <T extends Amity.Post<any>>(collection: T[], dataTypes: Amity.PostLiveCollection['dataTypes']) => T[];
|
|
34
55
|
//# sourceMappingURL=filtering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAC4E,CAAC;AAEzF,eAAO,MAAM,qBAAqB,sEAGzB,GAAG,EAAE,GAAG,SAAS,QACoE,CAAC;AAE/F;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,eACxB,MAAM,OAAO,EAAE,cACf,MAAM,qBAAqB,CAAC,YAAY,CAAC,UAC7C,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAC5C,MAAM,OAAO,EAyBf,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,yDAEjB,MAAM,IAAI,CAAC,UAAU,CAAC,QAgBjC,CAAC"}
|
|
1
|
+
{"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/core/query/filtering.ts"],"names":[],"mappings":"AAMA;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,sEAGxB,GAAG,QAC4E,CAAC;AAEzF,eAAO,MAAM,qBAAqB,sEAGzB,GAAG,EAAE,GAAG,SAAS,QACoE,CAAC;AAE/F;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,eACxB,MAAM,OAAO,EAAE,cACf,MAAM,qBAAqB,CAAC,YAAY,CAAC,UAC7C,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAC5C,MAAM,OAAO,EAyBf,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,yDAEjB,MAAM,IAAI,CAAC,UAAU,CAAC,QAgBjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,2DAE1B,MAAM,uBAAuB,CAAC,YAAY,CAAC,UAC/C,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QA0BhD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,0DAErB,MAAM,kBAAkB,CAAC,WAAW,CAAC,QAyBjD,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -95,8 +95,8 @@ const PostContentType = Object.freeze({
|
|
|
95
95
|
|
|
96
96
|
function getVersion() {
|
|
97
97
|
try {
|
|
98
|
-
// the string ''v0.0.1-beta.
|
|
99
|
-
return 'v0.0.1-beta.
|
|
98
|
+
// the string ''v0.0.1-beta.44.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
99
|
+
return 'v0.0.1-beta.44.0-cjs';
|
|
100
100
|
}
|
|
101
101
|
catch (error) {
|
|
102
102
|
return '__dev__';
|
|
@@ -451,8 +451,8 @@ const queryOptions = (policy, lifeSpan = CACHE_LIFESPAN) => {
|
|
|
451
451
|
* @category Query
|
|
452
452
|
*/
|
|
453
453
|
const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_server')) => {
|
|
454
|
-
console.
|
|
455
|
-
console.
|
|
454
|
+
console.info('Deprecation Notice: By Q3, CreateQuery/RunQuery will no longer be exported from the SDK. You will be able to use the API without either methods.');
|
|
455
|
+
console.info('Deprecation Notice: From v6.0.0, individual module imports will no longer be supported. All public APIs will need to be imported from their respective repositories. Ex: CommunityRepository, UserRepository, etc.');
|
|
456
456
|
let local;
|
|
457
457
|
const { lifeSpan } = queryOptions('cache_then_server', options.lifeSpan);
|
|
458
458
|
// offline first
|
|
@@ -1141,6 +1141,70 @@ const filterByFeedType = (collection, feedType) => {
|
|
|
1141
1141
|
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1142
1142
|
return feed && feed.feedType === feedType;
|
|
1143
1143
|
});
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* Filter a community collection by membership of the userId
|
|
1147
|
+
*
|
|
1148
|
+
* @param collection the community to filter
|
|
1149
|
+
* @param membership the membership to be filtered by
|
|
1150
|
+
* @param userId user id to be filtered by
|
|
1151
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1152
|
+
*
|
|
1153
|
+
* @hidden
|
|
1154
|
+
*/
|
|
1155
|
+
const filterByCommunityMembership = (collection, membership, userId) => {
|
|
1156
|
+
if (membership === 'all') {
|
|
1157
|
+
return collection;
|
|
1158
|
+
}
|
|
1159
|
+
return collection.filter(c => {
|
|
1160
|
+
var _a;
|
|
1161
|
+
// get resolver for the community by user
|
|
1162
|
+
const communityUserCacheKey = getResolver('communityUsers')({
|
|
1163
|
+
communityId: c.communityId,
|
|
1164
|
+
userId,
|
|
1165
|
+
});
|
|
1166
|
+
const communityUser = (_a = pullFromCache([
|
|
1167
|
+
'communityUsers',
|
|
1168
|
+
'get',
|
|
1169
|
+
communityUserCacheKey,
|
|
1170
|
+
])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1171
|
+
if (membership === 'member') {
|
|
1172
|
+
return communityUser && communityUser.communityMembership === 'member';
|
|
1173
|
+
}
|
|
1174
|
+
// only membership value remainging is 'notMember'
|
|
1175
|
+
return !communityUser || communityUser.communityMembership !== 'none';
|
|
1176
|
+
});
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Filter a post collection by dataType
|
|
1180
|
+
*
|
|
1181
|
+
* @param collection the post to filter
|
|
1182
|
+
* @param dataTypes of the post to be filtered by
|
|
1183
|
+
* @returns a filtered collection with items only matching the criteria
|
|
1184
|
+
*
|
|
1185
|
+
* @hidden
|
|
1186
|
+
*/
|
|
1187
|
+
const filterByPostDataTypes = (collection, dataTypes) => {
|
|
1188
|
+
const filteredPosts = [];
|
|
1189
|
+
collection.forEach(c => {
|
|
1190
|
+
var _a;
|
|
1191
|
+
/*
|
|
1192
|
+
* A text post with no children is just a text post
|
|
1193
|
+
*/
|
|
1194
|
+
if (c.dataType === 'text' && !c.children.length)
|
|
1195
|
+
return;
|
|
1196
|
+
if (c.children.length) {
|
|
1197
|
+
const childPost = (_a = pullFromCache(['post', 'get', c.children[0]])) === null || _a === void 0 ? void 0 : _a.data;
|
|
1198
|
+
if (childPost && (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(childPost === null || childPost === void 0 ? void 0 : childPost.dataType))) {
|
|
1199
|
+
// @ts-ignore
|
|
1200
|
+
filteredPosts.push(childPost);
|
|
1201
|
+
}
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.includes(c.dataType))
|
|
1205
|
+
filteredPosts.push(c);
|
|
1206
|
+
});
|
|
1207
|
+
return filteredPosts;
|
|
1144
1208
|
};
|
|
1145
1209
|
|
|
1146
1210
|
// Note:
|
|
@@ -20851,7 +20915,7 @@ const connectClient = async (params, sessionHandler, config) => {
|
|
|
20851
20915
|
* Cannot push to subscriptions as watcher needs to continue working even if
|
|
20852
20916
|
* token expires
|
|
20853
20917
|
*/
|
|
20854
|
-
unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.
|
|
20918
|
+
unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.expiresAt, (_c = client.token) === null || _c === void 0 ? void 0 : _c.issuedAt, sessionHandler);
|
|
20855
20919
|
setActiveUser(users[0]);
|
|
20856
20920
|
}
|
|
20857
20921
|
catch (error) {
|
|
@@ -21562,6 +21626,22 @@ const prepareMessagePayloadForCache = (payload) => {
|
|
|
21562
21626
|
}
|
|
21563
21627
|
};
|
|
21564
21628
|
|
|
21629
|
+
/*
|
|
21630
|
+
* This is a simple utility that infers the value of isDeleted based on the
|
|
21631
|
+
* value of includeDeleted
|
|
21632
|
+
*
|
|
21633
|
+
* There are two important things to note here:
|
|
21634
|
+
* 1. `includeDeleted` is purely client side query param and not recognized by
|
|
21635
|
+
* the server
|
|
21636
|
+
* 2. The only values we wish to expose with regards to `isDeleted` (the server
|
|
21637
|
+
* param for queries) is false | undefined and want to disallow users to query
|
|
21638
|
+
* for deleted entities
|
|
21639
|
+
*
|
|
21640
|
+
* Although this is a very simple utility, it's only purpose is to keep things
|
|
21641
|
+
* DRY
|
|
21642
|
+
*/
|
|
21643
|
+
const inferIsDeleted = (includeDeleted) => includeDeleted === true ? undefined : false;
|
|
21644
|
+
|
|
21565
21645
|
const getCachedMarker$1 = (message) => {
|
|
21566
21646
|
var _a, _b;
|
|
21567
21647
|
const key = {
|
|
@@ -21640,7 +21720,7 @@ function convertParams(_a) {
|
|
|
21640
21720
|
}
|
|
21641
21721
|
function convertQueryParams$1(_a) {
|
|
21642
21722
|
var { page, sortBy, subChannelId, tags, includeDeleted } = _a, rest = __rest(_a, ["page", "sortBy", "subChannelId", "tags", "includeDeleted"]);
|
|
21643
|
-
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: includeDeleted
|
|
21723
|
+
const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: inferIsDeleted(includeDeleted), options: { token: toToken(page || { limit: 10 }, 'afterbeforeraw') } });
|
|
21644
21724
|
if (sortBy !== undefined) {
|
|
21645
21725
|
out.options.sortBy = sortBy;
|
|
21646
21726
|
}
|
|
@@ -23483,6 +23563,12 @@ const queryMessages = async (query) => {
|
|
|
23483
23563
|
const { messages } = data;
|
|
23484
23564
|
const cachedAt = client.cache && Date.now();
|
|
23485
23565
|
if (client.cache) {
|
|
23566
|
+
/*
|
|
23567
|
+
* queryMessages.locally is unsupported for messages as message list updates
|
|
23568
|
+
* frequently and leads to bugs when user switches between channels, i.e. when
|
|
23569
|
+
* the public function (live messages) calls unmount. The list fetched on
|
|
23570
|
+
* after from the cache is stale.
|
|
23571
|
+
*/
|
|
23486
23572
|
ingestInCache(data, { cachedAt });
|
|
23487
23573
|
const cacheKey = ['message', 'query', params];
|
|
23488
23574
|
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
@@ -23492,41 +23578,7 @@ const queryMessages = async (query) => {
|
|
|
23492
23578
|
const prevPage = toPageRaw(paging.previous);
|
|
23493
23579
|
return { data: messages, cachedAt, prevPage, nextPage };
|
|
23494
23580
|
};
|
|
23495
|
-
/* end_public_function */
|
|
23496
|
-
/**
|
|
23497
|
-
* ```js
|
|
23498
|
-
* import { queryMessages } from '@amityco/ts-sdk'
|
|
23499
|
-
* const messages = queryMessages.locally!({ channelId })
|
|
23500
|
-
* ```
|
|
23501
|
-
*
|
|
23502
|
-
* Queries a paginable list of {@link Amity.Message} objects from cache
|
|
23503
|
-
*
|
|
23504
|
-
* @param query The query parameters
|
|
23505
|
-
* @returns A page of {@link Amity.Message} objects
|
|
23506
|
-
*
|
|
23507
|
-
* @category Message API
|
|
23508
|
-
*/
|
|
23509
|
-
queryMessages.locally = (query) => {
|
|
23510
|
-
var _a, _b;
|
|
23511
|
-
const client = getActiveClient();
|
|
23512
|
-
client.log('message/queryMessages.locally', query);
|
|
23513
|
-
if (!client.cache)
|
|
23514
|
-
return;
|
|
23515
|
-
const params = convertQueryParams$1(query);
|
|
23516
|
-
const queryKey = ['message', 'query', params];
|
|
23517
|
-
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
23518
|
-
if (!(data === null || data === void 0 ? void 0 : data.messages.length))
|
|
23519
|
-
return;
|
|
23520
|
-
const messages = data.messages
|
|
23521
|
-
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
23522
|
-
.filter(Boolean)
|
|
23523
|
-
.map(({ data }) => data);
|
|
23524
|
-
const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
23525
|
-
const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
23526
|
-
return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
|
|
23527
|
-
? { data: messages, cachedAt, prevPage, nextPage }
|
|
23528
|
-
: undefined;
|
|
23529
|
-
};
|
|
23581
|
+
/* end_public_function */
|
|
23530
23582
|
|
|
23531
23583
|
const uuid = () => nativeIdGenerator__default["default"].v4().toString();
|
|
23532
23584
|
|
|
@@ -23870,7 +23922,7 @@ const queryPosts = async (query) => {
|
|
|
23870
23922
|
// API-FIX: backend should answer Amity.Response (2)
|
|
23871
23923
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
23872
23924
|
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
23873
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
23925
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
23874
23926
|
/*
|
|
23875
23927
|
* when creating post like image, file, video BE will create 2 posts
|
|
23876
23928
|
* 1. parent post to store text with dataType=text
|
|
@@ -24215,7 +24267,7 @@ const queryCommunities = async (query) => {
|
|
|
24215
24267
|
// API-FIX: backend doesnt answer Amity.Response
|
|
24216
24268
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
24217
24269
|
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
24218
|
-
params: Object.assign(Object.assign({}, restParams), { isDeleted: includeDeleted
|
|
24270
|
+
params: Object.assign(Object.assign({}, restParams), { isDeleted: inferIsDeleted(includeDeleted), keyword: displayName, filter: membership, options: {
|
|
24219
24271
|
token: toToken(page, 'skiplimit'),
|
|
24220
24272
|
} }),
|
|
24221
24273
|
});
|
|
@@ -25066,7 +25118,7 @@ const queryComments = async (query) => {
|
|
|
25066
25118
|
// API-FIX: backend should answer Amity.Response (2)
|
|
25067
25119
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
|
|
25068
25120
|
const { data } = await client.http.get(`/api/v3/comments`, {
|
|
25069
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
25121
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
|
|
25070
25122
|
// filterByParentId, API-FIX: backend does not support this boolean LOL. what the hell seriously.
|
|
25071
25123
|
options }),
|
|
25072
25124
|
});
|
|
@@ -27905,7 +27957,7 @@ const querySubChannels = async (query) => {
|
|
|
27905
27957
|
client.log('channel/querySubChannels', query);
|
|
27906
27958
|
const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted"]);
|
|
27907
27959
|
const response = await client.http.get(`/api/v5/message-feeds/channel/${channelId}`, {
|
|
27908
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
27960
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
27909
27961
|
token: toToken(page, 'skiplimit'),
|
|
27910
27962
|
} }),
|
|
27911
27963
|
});
|
|
@@ -28288,7 +28340,7 @@ const liveSubChannels = (params, callback, config) => {
|
|
|
28288
28340
|
const responder = (data) => {
|
|
28289
28341
|
var _a;
|
|
28290
28342
|
let subChannels = data.data;
|
|
28291
|
-
if (params.includeDeleted
|
|
28343
|
+
if (!params.includeDeleted) {
|
|
28292
28344
|
subChannels = filterByPropEquality(subChannels, 'isDeleted', false);
|
|
28293
28345
|
}
|
|
28294
28346
|
subChannels.sort(sortByLastActivity);
|
|
@@ -28412,7 +28464,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
28412
28464
|
* for cases when message is deleted via RTE, this flag is used to get
|
|
28413
28465
|
* items from cache that are !deleted
|
|
28414
28466
|
*/
|
|
28415
|
-
if (params.includeDeleted
|
|
28467
|
+
if (!params.includeDeleted) {
|
|
28416
28468
|
messages = filterByPropEquality(messages, 'isDeleted', false);
|
|
28417
28469
|
}
|
|
28418
28470
|
callback({
|
|
@@ -28430,6 +28482,7 @@ const liveMessages = (params, callback, config) => {
|
|
|
28430
28482
|
return;
|
|
28431
28483
|
collection.data = [...new Set([message.messageId, ...collection.data])];
|
|
28432
28484
|
pushToCache(cacheKey, collection);
|
|
28485
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
28433
28486
|
responder(collection);
|
|
28434
28487
|
};
|
|
28435
28488
|
const onFetch = () => {
|
|
@@ -28458,7 +28511,6 @@ const liveMessages = (params, callback, config) => {
|
|
|
28458
28511
|
return () => {
|
|
28459
28512
|
log(`liveMessages(tmpid: ${timestamp}) > dispose`);
|
|
28460
28513
|
disposers.forEach(fn => fn());
|
|
28461
|
-
dropFromCache(cacheKey);
|
|
28462
28514
|
};
|
|
28463
28515
|
};
|
|
28464
28516
|
|
|
@@ -28917,7 +28969,7 @@ const observeCommunity = (communityId, callback) => {
|
|
|
28917
28969
|
* @category Community Live Collection
|
|
28918
28970
|
*/
|
|
28919
28971
|
const liveCommunities = (params, callback, config) => {
|
|
28920
|
-
const { log, cache } = getActiveClient();
|
|
28972
|
+
const { log, cache, userId } = getActiveClient();
|
|
28921
28973
|
if (!cache) {
|
|
28922
28974
|
console.log(ENABLE_CACHE_MESSAGE);
|
|
28923
28975
|
}
|
|
@@ -28935,7 +28987,7 @@ const liveCommunities = (params, callback, config) => {
|
|
|
28935
28987
|
.filter(Boolean)
|
|
28936
28988
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
28937
28989
|
communities = filterByPropEquality(communities, 'displayName', params.displayName);
|
|
28938
|
-
if (params.includeDeleted
|
|
28990
|
+
if (!params.includeDeleted) {
|
|
28939
28991
|
communities = filterByPropEquality(communities, 'isDeleted', false);
|
|
28940
28992
|
}
|
|
28941
28993
|
if (params.categoryId) {
|
|
@@ -28944,11 +28996,8 @@ const liveCommunities = (params, callback, config) => {
|
|
|
28944
28996
|
if (params.tags) {
|
|
28945
28997
|
communities = communities.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); }); });
|
|
28946
28998
|
}
|
|
28947
|
-
if (params.membership
|
|
28948
|
-
communities =
|
|
28949
|
-
}
|
|
28950
|
-
if (params.membership === 'notMember') {
|
|
28951
|
-
communities = filterByPropEquality(communities, 'isJoined', false);
|
|
28999
|
+
if (params.membership && userId) {
|
|
29000
|
+
communities = filterByCommunityMembership(communities, params.membership, userId);
|
|
28952
29001
|
}
|
|
28953
29002
|
const sortBy = params.sortBy || 'lastCreated';
|
|
28954
29003
|
if (sortBy === 'lastCreated' || sortBy === 'firstCreated') {
|
|
@@ -29182,7 +29231,7 @@ const queryCategories = async (query) => {
|
|
|
29182
29231
|
client.log('category/queryCategories', query);
|
|
29183
29232
|
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 }, includeDeleted } = _a, params = __rest(_a, ["page", "includeDeleted"]);
|
|
29184
29233
|
const { data } = await client.http.get(`/api/v3/community-categories`, {
|
|
29185
|
-
params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted
|
|
29234
|
+
params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
|
|
29186
29235
|
token: toToken(page, 'skiplimit'),
|
|
29187
29236
|
} }),
|
|
29188
29237
|
});
|
|
@@ -29325,7 +29374,7 @@ const liveCategories = (params, callback, config) => {
|
|
|
29325
29374
|
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
29326
29375
|
.filter(Boolean)
|
|
29327
29376
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
29328
|
-
if (params.includeDeleted
|
|
29377
|
+
if (!params.includeDeleted) {
|
|
29329
29378
|
categories = filterByPropEquality(categories, 'isDeleted', false);
|
|
29330
29379
|
}
|
|
29331
29380
|
switch (params.sortBy) {
|
|
@@ -30429,14 +30478,14 @@ const livePosts = (params, callback, config) => {
|
|
|
30429
30478
|
{ targetId: params.targetId, targetType: params.targetType },
|
|
30430
30479
|
];
|
|
30431
30480
|
const responder = (data) => {
|
|
30432
|
-
var _a, _b;
|
|
30481
|
+
var _a, _b, _c;
|
|
30433
30482
|
let posts = (_a = data.data
|
|
30434
30483
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
30435
30484
|
.filter(Boolean)
|
|
30436
30485
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30437
30486
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
30438
30487
|
posts = posts.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
30439
|
-
if (params.includeDeleted
|
|
30488
|
+
if (!params.includeDeleted) {
|
|
30440
30489
|
posts = filterByPropEquality(posts, 'isDeleted', false);
|
|
30441
30490
|
}
|
|
30442
30491
|
if (params.tags) {
|
|
@@ -30445,10 +30494,13 @@ const livePosts = (params, callback, config) => {
|
|
|
30445
30494
|
if (params.targetType === 'community' && params.feedType) {
|
|
30446
30495
|
posts = filterByFeedType(posts, params.feedType);
|
|
30447
30496
|
}
|
|
30497
|
+
if ((_b = params.dataTypes) === null || _b === void 0 ? void 0 : _b.length) {
|
|
30498
|
+
posts = filterByPostDataTypes(posts, params.dataTypes);
|
|
30499
|
+
}
|
|
30448
30500
|
callback({
|
|
30449
30501
|
onNextPage: onFetch,
|
|
30450
30502
|
data: posts,
|
|
30451
|
-
hasNextPage: !!((
|
|
30503
|
+
hasNextPage: !!((_c = data.params) === null || _c === void 0 ? void 0 : _c.page),
|
|
30452
30504
|
loading: data.loading,
|
|
30453
30505
|
error: data.error,
|
|
30454
30506
|
});
|
|
@@ -30469,6 +30521,7 @@ const livePosts = (params, callback, config) => {
|
|
|
30469
30521
|
collection.data = [...new Set([post.postId, ...collection.data])];
|
|
30470
30522
|
}
|
|
30471
30523
|
pushToCache(cacheKey, collection);
|
|
30524
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
30472
30525
|
responder(collection);
|
|
30473
30526
|
};
|
|
30474
30527
|
const onFetch = () => {
|
|
@@ -30497,7 +30550,6 @@ const livePosts = (params, callback, config) => {
|
|
|
30497
30550
|
return () => {
|
|
30498
30551
|
log(`livePosts(tmpid: ${timestamp}) > dispose`);
|
|
30499
30552
|
disposers.forEach(fn => fn());
|
|
30500
|
-
dropFromCache(cacheKey);
|
|
30501
30553
|
};
|
|
30502
30554
|
};
|
|
30503
30555
|
|
|
@@ -30654,7 +30706,7 @@ const liveComments = (params, callback, config) => {
|
|
|
30654
30706
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
30655
30707
|
.filter(Boolean)
|
|
30656
30708
|
.map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
|
|
30657
|
-
if (params.includeDeleted
|
|
30709
|
+
if (!params.includeDeleted) {
|
|
30658
30710
|
comments = filterByPropEquality(comments, 'isDeleted', false);
|
|
30659
30711
|
}
|
|
30660
30712
|
const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
|
|
@@ -31397,7 +31449,9 @@ exports.dropFromCache = dropFromCache;
|
|
|
31397
31449
|
exports.enableCache = enableCache;
|
|
31398
31450
|
exports.fileUrlWithSize = fileUrlWithSize;
|
|
31399
31451
|
exports.filterByChannelMembership = filterByChannelMembership;
|
|
31452
|
+
exports.filterByCommunityMembership = filterByCommunityMembership;
|
|
31400
31453
|
exports.filterByFeedType = filterByFeedType;
|
|
31454
|
+
exports.filterByPostDataTypes = filterByPostDataTypes;
|
|
31401
31455
|
exports.filterByPropEquality = filterByPropEquality;
|
|
31402
31456
|
exports.filterByPropInclusion = filterByPropInclusion;
|
|
31403
31457
|
exports.follow = follow;
|