@amityco/ts-sdk 0.0.1-beta.43.1 → 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.
Files changed (45) hide show
  1. package/dist/category/api/queryCategories.d.ts.map +1 -1
  2. package/dist/comment/api/queryComments.d.ts.map +1 -1
  3. package/dist/community/api/queryCommunities.d.ts.map +1 -1
  4. package/dist/core/query/filtering.d.ts +10 -0
  5. package/dist/core/query/filtering.d.ts.map +1 -1
  6. package/dist/index.cjs.js +82 -60
  7. package/dist/index.esm.js +82 -61
  8. package/dist/index.umd.js +4 -4
  9. package/dist/message/api/queryMessages.d.ts +1 -17
  10. package/dist/message/api/queryMessages.d.ts.map +1 -1
  11. package/dist/message/utils/prepareMessagePayload.d.ts.map +1 -1
  12. package/dist/post/api/queryPosts.d.ts.map +1 -1
  13. package/dist/post/observers/livePosts.d.ts.map +1 -1
  14. package/dist/subChannel/api/querySubChannels.d.ts.map +1 -1
  15. package/dist/utils/inferIsDeleted.d.ts +2 -0
  16. package/dist/utils/inferIsDeleted.d.ts.map +1 -0
  17. package/dist/utils/tests/inferIsDeleted.test.d.ts +2 -0
  18. package/dist/utils/tests/inferIsDeleted.test.d.ts.map +1 -0
  19. package/package.json +1 -1
  20. package/src/category/api/queryCategories.ts +3 -1
  21. package/src/category/observers/liveCategories.ts +1 -1
  22. package/src/category/observers/tests/liveCategories.test.ts +7 -5
  23. package/src/channel/api/tests/removeChannelMembers.test.ts +3 -4
  24. package/src/channel/observers/tests/liveChannels.test.ts +6 -6
  25. package/src/client/api/connectClient.ts +1 -1
  26. package/src/comment/api/queryComments.ts +3 -1
  27. package/src/comment/observers/liveComments.ts +1 -1
  28. package/src/community/api/queryCommunities.ts +2 -1
  29. package/src/community/api/test/queryCommunity.test.ts +2 -2
  30. package/src/community/observers/liveCommunities.ts +1 -1
  31. package/src/community/observers/tests/liveCommunities.test.ts +7 -7
  32. package/src/core/query/filtering.ts +38 -0
  33. package/src/message/api/queryMessages.ts +15 -50
  34. package/src/message/api/tests/queryMessages.test.ts +2 -37
  35. package/src/message/observers/liveMessages.ts +2 -2
  36. package/src/message/tests/observers/liveMessage.test.ts +1 -1
  37. package/src/message/tests/observers/liveMessages.test.ts +1 -1
  38. package/src/message/utils/prepareMessagePayload.ts +3 -1
  39. package/src/post/api/queryPosts.ts +3 -1
  40. package/src/post/observers/livePosts.ts +7 -2
  41. package/src/post/observers/tests/livePosts.test.ts +10 -4
  42. package/src/subChannel/api/querySubChannels.ts +3 -1
  43. package/src/subChannel/observers/liveSubChannels.ts +1 -1
  44. package/src/utils/inferIsDeleted.ts +16 -0
  45. 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":"AAWA;;;;;;;;;;;;;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
+ {"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":"AAUA;;;;;;;;;;;;;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
+ {"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":"AAYA;;;;;;;;;;;;;;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
+ {"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"}
@@ -42,4 +42,14 @@ export declare const filterByFeedType: <T extends Amity.Post<any>>(collection: T
42
42
  * @hidden
43
43
  */
44
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[];
45
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;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,2DAE1B,MAAM,uBAAuB,CAAC,YAAY,CAAC,UAC/C,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QA0BhD,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.43.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
99
- return 'v0.0.1-beta.43.1-cjs';
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__';
@@ -1174,6 +1174,37 @@ const filterByCommunityMembership = (collection, membership, userId) => {
1174
1174
  // only membership value remainging is 'notMember'
1175
1175
  return !communityUser || communityUser.communityMembership !== 'none';
1176
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;
1177
1208
  };
1178
1209
 
1179
1210
  // Note:
@@ -20884,7 +20915,7 @@ const connectClient = async (params, sessionHandler, config) => {
20884
20915
  * Cannot push to subscriptions as watcher needs to continue working even if
20885
20916
  * token expires
20886
20917
  */
20887
- unsubWatcher = client.accessTokenExpiryWatcher((_b = client.token) === null || _b === void 0 ? void 0 : _b.issuedAt, (_c = client.token) === null || _c === void 0 ? void 0 : _c.expiresAt, sessionHandler);
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);
20888
20919
  setActiveUser(users[0]);
20889
20920
  }
20890
20921
  catch (error) {
@@ -21595,6 +21626,22 @@ const prepareMessagePayloadForCache = (payload) => {
21595
21626
  }
21596
21627
  };
21597
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
+
21598
21645
  const getCachedMarker$1 = (message) => {
21599
21646
  var _a, _b;
21600
21647
  const key = {
@@ -21673,7 +21720,7 @@ function convertParams(_a) {
21673
21720
  }
21674
21721
  function convertQueryParams$1(_a) {
21675
21722
  var { page, sortBy, subChannelId, tags, includeDeleted } = _a, rest = __rest(_a, ["page", "sortBy", "subChannelId", "tags", "includeDeleted"]);
21676
- const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: includeDeleted === false ? false : undefined, options: { token: toToken(page || { limit: 10 }, 'afterbeforeraw') } });
21723
+ const out = Object.assign(Object.assign({}, rest), { messageFeedId: subChannelId, isDeleted: inferIsDeleted(includeDeleted), options: { token: toToken(page || { limit: 10 }, 'afterbeforeraw') } });
21677
21724
  if (sortBy !== undefined) {
21678
21725
  out.options.sortBy = sortBy;
21679
21726
  }
@@ -23515,52 +23562,23 @@ const queryMessages = async (query) => {
23515
23562
  const data = await prepareMessagePayload(payload);
23516
23563
  const { messages } = data;
23517
23564
  const cachedAt = client.cache && Date.now();
23518
- // if (client.cache) {
23519
- // ingestInCache(data, { cachedAt });
23520
- //
23521
- // const cacheKey = ['message', 'query', params as Amity.Serializable];
23522
- // pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
23523
- // }
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
+ */
23572
+ ingestInCache(data, { cachedAt });
23573
+ const cacheKey = ['message', 'query', params];
23574
+ pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
23575
+ }
23524
23576
  fireEvent('local.message.fetched', { messages });
23525
23577
  const nextPage = toPageRaw(paging.next);
23526
23578
  const prevPage = toPageRaw(paging.previous);
23527
23579
  return { data: messages, cachedAt, prevPage, nextPage };
23528
23580
  };
23529
- /* end_public_function */
23530
- /**
23531
- * ```js
23532
- * import { queryMessages } from '@amityco/ts-sdk'
23533
- * const messages = queryMessages.locally!({ channelId })
23534
- * ```
23535
- *
23536
- * Queries a paginable list of {@link Amity.Message} objects from cache
23537
- *
23538
- * @param query The query parameters
23539
- * @returns A page of {@link Amity.Message} objects
23540
- *
23541
- * @category Message API
23542
- */
23543
- queryMessages.locally = (query) => {
23544
- var _a, _b;
23545
- const client = getActiveClient();
23546
- client.log('message/queryMessages.locally', query);
23547
- if (!client.cache)
23548
- return;
23549
- const params = convertQueryParams$1(query);
23550
- const queryKey = ['message', 'query', params];
23551
- const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
23552
- if (!(data === null || data === void 0 ? void 0 : data.messages.length))
23553
- return;
23554
- const messages = data.messages
23555
- .map(messageId => pullFromCache(['message', 'get', messageId]))
23556
- .filter(Boolean)
23557
- .map(({ data }) => data);
23558
- const prevPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.previous);
23559
- const nextPage = toPageRaw(data === null || data === void 0 ? void 0 : data.paging.next);
23560
- return messages.length === ((_b = data === null || data === void 0 ? void 0 : data.messages) === null || _b === void 0 ? void 0 : _b.length)
23561
- ? { data: messages, cachedAt, prevPage, nextPage }
23562
- : undefined;
23563
- };
23581
+ /* end_public_function */
23564
23582
 
23565
23583
  const uuid = () => nativeIdGenerator__default["default"].v4().toString();
23566
23584
 
@@ -23904,7 +23922,7 @@ const queryPosts = async (query) => {
23904
23922
  // API-FIX: backend should answer Amity.Response (2)
23905
23923
  // const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
23906
23924
  const { data } = await client.http.get(`/api/v4/posts`, {
23907
- params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted === false ? false : undefined,
23925
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
23908
23926
  /*
23909
23927
  * when creating post like image, file, video BE will create 2 posts
23910
23928
  * 1. parent post to store text with dataType=text
@@ -24249,7 +24267,7 @@ const queryCommunities = async (query) => {
24249
24267
  // API-FIX: backend doesnt answer Amity.Response
24250
24268
  // const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
24251
24269
  const { data } = await client.http.get(`/api/v3/communities`, {
24252
- params: Object.assign(Object.assign({}, restParams), { isDeleted: includeDeleted === false ? false : undefined, keyword: displayName, filter: membership, options: {
24270
+ params: Object.assign(Object.assign({}, restParams), { isDeleted: inferIsDeleted(includeDeleted), keyword: displayName, filter: membership, options: {
24253
24271
  token: toToken(page, 'skiplimit'),
24254
24272
  } }),
24255
24273
  });
@@ -25100,7 +25118,7 @@ const queryComments = async (query) => {
25100
25118
  // API-FIX: backend should answer Amity.Response (2)
25101
25119
  // const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
25102
25120
  const { data } = await client.http.get(`/api/v3/comments`, {
25103
- params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted === false ? false : undefined,
25121
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
25104
25122
  // filterByParentId, API-FIX: backend does not support this boolean LOL. what the hell seriously.
25105
25123
  options }),
25106
25124
  });
@@ -27939,7 +27957,7 @@ const querySubChannels = async (query) => {
27939
27957
  client.log('channel/querySubChannels', query);
27940
27958
  const _a = convertQueryParams(query), { page = { limit: 10 }, channelId, includeDeleted } = _a, params = __rest(_a, ["page", "channelId", "includeDeleted"]);
27941
27959
  const response = await client.http.get(`/api/v5/message-feeds/channel/${channelId}`, {
27942
- params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted === false ? false : undefined, options: {
27960
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
27943
27961
  token: toToken(page, 'skiplimit'),
27944
27962
  } }),
27945
27963
  });
@@ -28322,7 +28340,7 @@ const liveSubChannels = (params, callback, config) => {
28322
28340
  const responder = (data) => {
28323
28341
  var _a;
28324
28342
  let subChannels = data.data;
28325
- if (params.includeDeleted === false) {
28343
+ if (!params.includeDeleted) {
28326
28344
  subChannels = filterByPropEquality(subChannels, 'isDeleted', false);
28327
28345
  }
28328
28346
  subChannels.sort(sortByLastActivity);
@@ -28446,7 +28464,7 @@ const liveMessages = (params, callback, config) => {
28446
28464
  * for cases when message is deleted via RTE, this flag is used to get
28447
28465
  * items from cache that are !deleted
28448
28466
  */
28449
- if (params.includeDeleted === false) {
28467
+ if (!params.includeDeleted) {
28450
28468
  messages = filterByPropEquality(messages, 'isDeleted', false);
28451
28469
  }
28452
28470
  callback({
@@ -28464,6 +28482,7 @@ const liveMessages = (params, callback, config) => {
28464
28482
  return;
28465
28483
  collection.data = [...new Set([message.messageId, ...collection.data])];
28466
28484
  pushToCache(cacheKey, collection);
28485
+ disposers.push(() => dropFromCache(cacheKey));
28467
28486
  responder(collection);
28468
28487
  };
28469
28488
  const onFetch = () => {
@@ -28492,7 +28511,6 @@ const liveMessages = (params, callback, config) => {
28492
28511
  return () => {
28493
28512
  log(`liveMessages(tmpid: ${timestamp}) > dispose`);
28494
28513
  disposers.forEach(fn => fn());
28495
- dropFromCache(cacheKey);
28496
28514
  };
28497
28515
  };
28498
28516
 
@@ -28969,7 +28987,7 @@ const liveCommunities = (params, callback, config) => {
28969
28987
  .filter(Boolean)
28970
28988
  .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
28971
28989
  communities = filterByPropEquality(communities, 'displayName', params.displayName);
28972
- if (params.includeDeleted === false) {
28990
+ if (!params.includeDeleted) {
28973
28991
  communities = filterByPropEquality(communities, 'isDeleted', false);
28974
28992
  }
28975
28993
  if (params.categoryId) {
@@ -29213,7 +29231,7 @@ const queryCategories = async (query) => {
29213
29231
  client.log('category/queryCategories', query);
29214
29232
  const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 }, includeDeleted } = _a, params = __rest(_a, ["page", "includeDeleted"]);
29215
29233
  const { data } = await client.http.get(`/api/v3/community-categories`, {
29216
- params: Object.assign(Object.assign({}, params), { isDeleted: includeDeleted === false ? false : undefined, options: {
29234
+ params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted), options: {
29217
29235
  token: toToken(page, 'skiplimit'),
29218
29236
  } }),
29219
29237
  });
@@ -29356,7 +29374,7 @@ const liveCategories = (params, callback, config) => {
29356
29374
  .map(categoryId => pullFromCache(['category', 'get', categoryId]))
29357
29375
  .filter(Boolean)
29358
29376
  .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
29359
- if (params.includeDeleted === false) {
29377
+ if (!params.includeDeleted) {
29360
29378
  categories = filterByPropEquality(categories, 'isDeleted', false);
29361
29379
  }
29362
29380
  switch (params.sortBy) {
@@ -30460,14 +30478,14 @@ const livePosts = (params, callback, config) => {
30460
30478
  { targetId: params.targetId, targetType: params.targetType },
30461
30479
  ];
30462
30480
  const responder = (data) => {
30463
- var _a, _b;
30481
+ var _a, _b, _c;
30464
30482
  let posts = (_a = data.data
30465
30483
  .map(postId => pullFromCache(['post', 'get', postId]))
30466
30484
  .filter(Boolean)
30467
30485
  .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
30468
30486
  const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
30469
30487
  posts = posts.sort(sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
30470
- if (params.includeDeleted === false) {
30488
+ if (!params.includeDeleted) {
30471
30489
  posts = filterByPropEquality(posts, 'isDeleted', false);
30472
30490
  }
30473
30491
  if (params.tags) {
@@ -30476,10 +30494,13 @@ const livePosts = (params, callback, config) => {
30476
30494
  if (params.targetType === 'community' && params.feedType) {
30477
30495
  posts = filterByFeedType(posts, params.feedType);
30478
30496
  }
30497
+ if ((_b = params.dataTypes) === null || _b === void 0 ? void 0 : _b.length) {
30498
+ posts = filterByPostDataTypes(posts, params.dataTypes);
30499
+ }
30479
30500
  callback({
30480
30501
  onNextPage: onFetch,
30481
30502
  data: posts,
30482
- hasNextPage: !!((_b = data.params) === null || _b === void 0 ? void 0 : _b.page),
30503
+ hasNextPage: !!((_c = data.params) === null || _c === void 0 ? void 0 : _c.page),
30483
30504
  loading: data.loading,
30484
30505
  error: data.error,
30485
30506
  });
@@ -30500,6 +30521,7 @@ const livePosts = (params, callback, config) => {
30500
30521
  collection.data = [...new Set([post.postId, ...collection.data])];
30501
30522
  }
30502
30523
  pushToCache(cacheKey, collection);
30524
+ disposers.push(() => dropFromCache(cacheKey));
30503
30525
  responder(collection);
30504
30526
  };
30505
30527
  const onFetch = () => {
@@ -30528,7 +30550,6 @@ const livePosts = (params, callback, config) => {
30528
30550
  return () => {
30529
30551
  log(`livePosts(tmpid: ${timestamp}) > dispose`);
30530
30552
  disposers.forEach(fn => fn());
30531
- dropFromCache(cacheKey);
30532
30553
  };
30533
30554
  };
30534
30555
 
@@ -30685,7 +30706,7 @@ const liveComments = (params, callback, config) => {
30685
30706
  .map(commentId => pullFromCache(['comment', 'get', commentId]))
30686
30707
  .filter(Boolean)
30687
30708
  .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
30688
- if (params.includeDeleted === false) {
30709
+ if (!params.includeDeleted) {
30689
30710
  comments = filterByPropEquality(comments, 'isDeleted', false);
30690
30711
  }
30691
30712
  const sortBy = params.sortBy ? params.sortBy : 'lastCreated';
@@ -31430,6 +31451,7 @@ exports.fileUrlWithSize = fileUrlWithSize;
31430
31451
  exports.filterByChannelMembership = filterByChannelMembership;
31431
31452
  exports.filterByCommunityMembership = filterByCommunityMembership;
31432
31453
  exports.filterByFeedType = filterByFeedType;
31454
+ exports.filterByPostDataTypes = filterByPostDataTypes;
31433
31455
  exports.filterByPropEquality = filterByPropEquality;
31434
31456
  exports.filterByPropInclusion = filterByPropInclusion;
31435
31457
  exports.follow = follow;