@amityco/ts-sdk 0.0.1-beta.15 → 0.0.1-beta.16

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 (142) hide show
  1. package/dist/@types/core/cache.d.ts +1 -1
  2. package/dist/@types/core/cache.d.ts.map +1 -1
  3. package/dist/@types/core/events.d.ts +10 -1
  4. package/dist/@types/core/events.d.ts.map +1 -1
  5. package/dist/@types/core/model.d.ts +4 -0
  6. package/dist/@types/core/model.d.ts.map +1 -1
  7. package/dist/@types/core/paging.d.ts +10 -10
  8. package/dist/@types/core/paging.d.ts.map +1 -1
  9. package/dist/@types/core/payload.d.ts +10 -0
  10. package/dist/@types/core/payload.d.ts.map +1 -1
  11. package/dist/@types/core/query.d.ts +5 -4
  12. package/dist/@types/core/query.d.ts.map +1 -1
  13. package/dist/@types/domains/client.d.ts +0 -1
  14. package/dist/@types/domains/client.d.ts.map +1 -1
  15. package/dist/@types/domains/follow.d.ts +20 -0
  16. package/dist/@types/domains/follow.d.ts.map +1 -0
  17. package/dist/@types/index.d.ts +1 -0
  18. package/dist/@types/index.d.ts.map +1 -1
  19. package/dist/category/api/queryCategories.d.ts +3 -3
  20. package/dist/channel/api/createChannel.d.ts +1 -1
  21. package/dist/channel/api/queryChannels.d.ts +1 -1
  22. package/dist/client/api/activeUser.d.ts +6 -0
  23. package/dist/client/api/activeUser.d.ts.map +1 -0
  24. package/dist/client/api/connectClient.d.ts.map +1 -1
  25. package/dist/community/api/getRecommendedCommunities.d.ts +32 -0
  26. package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -0
  27. package/dist/community/api/getTopTrendingCommunities.d.ts +32 -0
  28. package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -0
  29. package/dist/community/api/index.d.ts +2 -0
  30. package/dist/community/api/index.d.ts.map +1 -1
  31. package/dist/community/api/queryCommunities.d.ts +1 -1
  32. package/dist/core/events.d.ts +3 -3
  33. package/dist/core/events.d.ts.map +1 -1
  34. package/dist/core/model/idResolvers.d.ts.map +1 -1
  35. package/dist/core/model/identifyModel.d.ts.map +1 -1
  36. package/dist/core/model/index.d.ts.map +1 -1
  37. package/dist/core/query/paging.d.ts +3 -3
  38. package/dist/core/query/paging.d.ts.map +1 -1
  39. package/dist/core/subscription.d.ts +2 -0
  40. package/dist/core/subscription.d.ts.map +1 -1
  41. package/dist/feed/api/queryGlobalFeed.d.ts +1 -1
  42. package/dist/follow/api/acceptFollower.d.ts +16 -0
  43. package/dist/follow/api/acceptFollower.d.ts.map +1 -0
  44. package/dist/follow/api/declineFollower.d.ts +16 -0
  45. package/dist/follow/api/declineFollower.d.ts.map +1 -0
  46. package/dist/follow/api/follow.d.ts +16 -0
  47. package/dist/follow/api/follow.d.ts.map +1 -0
  48. package/dist/follow/api/getFollowInfo.d.ts +32 -0
  49. package/dist/follow/api/getFollowInfo.d.ts.map +1 -0
  50. package/dist/follow/api/index.d.ts +8 -0
  51. package/dist/follow/api/index.d.ts.map +1 -0
  52. package/dist/follow/api/queryFollowers.d.ts +36 -0
  53. package/dist/follow/api/queryFollowers.d.ts.map +1 -0
  54. package/dist/follow/api/queryFollowings.d.ts +36 -0
  55. package/dist/follow/api/queryFollowings.d.ts.map +1 -0
  56. package/dist/follow/api/unfollow.d.ts +16 -0
  57. package/dist/follow/api/unfollow.d.ts.map +1 -0
  58. package/dist/follow/api/utils.d.ts +9 -0
  59. package/dist/follow/api/utils.d.ts.map +1 -0
  60. package/dist/follow/events/index.d.ts +9 -0
  61. package/dist/follow/events/index.d.ts.map +1 -0
  62. package/dist/follow/events/onFollowInfoUpdated.d.ts +17 -0
  63. package/dist/follow/events/onFollowInfoUpdated.d.ts.map +1 -0
  64. package/dist/follow/events/onFollowRequestAccepted.d.ts +17 -0
  65. package/dist/follow/events/onFollowRequestAccepted.d.ts.map +1 -0
  66. package/dist/follow/events/onFollowRequestCanceled.d.ts +17 -0
  67. package/dist/follow/events/onFollowRequestCanceled.d.ts.map +1 -0
  68. package/dist/follow/events/onFollowRequestDeclined.d.ts +17 -0
  69. package/dist/follow/events/onFollowRequestDeclined.d.ts.map +1 -0
  70. package/dist/follow/events/onFollowerDeleted.d.ts +17 -0
  71. package/dist/follow/events/onFollowerDeleted.d.ts.map +1 -0
  72. package/dist/follow/events/onFollowerRequested.d.ts +17 -0
  73. package/dist/follow/events/onFollowerRequested.d.ts.map +1 -0
  74. package/dist/follow/events/onUserFollowed.d.ts +17 -0
  75. package/dist/follow/events/onUserFollowed.d.ts.map +1 -0
  76. package/dist/follow/events/onUserUnfollowed.d.ts +17 -0
  77. package/dist/follow/events/onUserUnfollowed.d.ts.map +1 -0
  78. package/dist/follow/events/utils.d.ts +2 -0
  79. package/dist/follow/events/utils.d.ts.map +1 -0
  80. package/dist/follow/observers/index.d.ts +4 -0
  81. package/dist/follow/observers/index.d.ts.map +1 -0
  82. package/dist/follow/observers/observeFollowInfo.d.ts +18 -0
  83. package/dist/follow/observers/observeFollowInfo.d.ts.map +1 -0
  84. package/dist/follow/observers/observeFollowers.d.ts +18 -0
  85. package/dist/follow/observers/observeFollowers.d.ts.map +1 -0
  86. package/dist/follow/observers/observeFollowings.d.ts +18 -0
  87. package/dist/follow/observers/observeFollowings.d.ts.map +1 -0
  88. package/dist/index.cjs.js +752 -8
  89. package/dist/index.d.ts +3 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.esm.js +731 -9
  92. package/dist/index.umd.js +5 -5
  93. package/dist/post/api/queryPosts.d.ts +2 -2
  94. package/dist/post/api/queryPosts.d.ts.map +1 -1
  95. package/dist/role/api/queryRoles.d.ts +1 -1
  96. package/dist/stream/api/queryStreams.d.ts +1 -1
  97. package/package.json +1 -1
  98. package/src/@types/core/cache.ts +1 -1
  99. package/src/@types/core/events.ts +11 -0
  100. package/src/@types/core/model.ts +6 -0
  101. package/src/@types/core/paging.ts +9 -9
  102. package/src/@types/core/payload.ts +14 -0
  103. package/src/@types/core/query.ts +8 -4
  104. package/src/@types/domains/client.ts +0 -1
  105. package/src/@types/domains/follow.ts +25 -0
  106. package/src/@types/index.ts +1 -0
  107. package/src/channel/api/createChannel.ts +1 -1
  108. package/src/client/api/activeUser.ts +26 -0
  109. package/src/client/api/connectClient.ts +3 -1
  110. package/src/community/api/getRecommendedCommunities.ts +86 -0
  111. package/src/community/api/getTopTrendingCommunities.ts +86 -0
  112. package/src/community/api/index.ts +3 -0
  113. package/src/core/model/idResolvers.ts +3 -0
  114. package/src/core/model/identifyModel.ts +2 -0
  115. package/src/core/model/index.ts +3 -0
  116. package/src/core/query/paging.ts +10 -10
  117. package/src/core/subscription.ts +21 -3
  118. package/src/follow/api/acceptFollower.ts +32 -0
  119. package/src/follow/api/declineFollower.ts +32 -0
  120. package/src/follow/api/follow.ts +40 -0
  121. package/src/follow/api/getFollowInfo.ts +75 -0
  122. package/src/follow/api/index.ts +8 -0
  123. package/src/follow/api/queryFollowers.ts +42 -0
  124. package/src/follow/api/queryFollowings.ts +42 -0
  125. package/src/follow/api/unfollow.ts +32 -0
  126. package/src/follow/api/utils.ts +77 -0
  127. package/src/follow/events/index.ts +10 -0
  128. package/src/follow/events/onFollowInfoUpdated.ts +43 -0
  129. package/src/follow/events/onFollowRequestAccepted.ts +19 -0
  130. package/src/follow/events/onFollowRequestCanceled.ts +19 -0
  131. package/src/follow/events/onFollowRequestDeclined.ts +19 -0
  132. package/src/follow/events/onFollowerDeleted.ts +19 -0
  133. package/src/follow/events/onFollowerRequested.ts +19 -0
  134. package/src/follow/events/onUserFollowed.ts +19 -0
  135. package/src/follow/events/onUserUnfollowed.ts +19 -0
  136. package/src/follow/events/utils.ts +38 -0
  137. package/src/follow/observers/index.ts +3 -0
  138. package/src/follow/observers/observeFollowInfo.ts +68 -0
  139. package/src/follow/observers/observeFollowers.ts +78 -0
  140. package/src/follow/observers/observeFollowings.ts +78 -0
  141. package/src/index.ts +4 -0
  142. package/src/post/api/queryPosts.ts +2 -2
package/dist/index.esm.js CHANGED
@@ -119,7 +119,7 @@ const toToken = (paging, style) => {
119
119
  */
120
120
  const toPage = (token) => {
121
121
  if (!token)
122
- return null;
122
+ return undefined;
123
123
  // don't try catch, let it throw
124
124
  const json = JSON.parse(decode(token));
125
125
  if (isSkipLimit(json)) {
@@ -142,7 +142,7 @@ const toPage = (token) => {
142
142
  };
143
143
  }
144
144
  }
145
- return null;
145
+ return undefined;
146
146
  };
147
147
  /**
148
148
  * Converts a b64 string token into a paging object
@@ -154,13 +154,13 @@ const toPage = (token) => {
154
154
  */
155
155
  const toPageRaw = (token) => {
156
156
  if (!token)
157
- return null;
157
+ return undefined;
158
158
  // don't try catch, let it throw
159
159
  const json = JSON.parse(decode(token));
160
160
  if (isAfterBeforeRaw(json)) {
161
161
  return json;
162
162
  }
163
- return null;
163
+ return undefined;
164
164
  };
165
165
 
166
166
  /**
@@ -14916,6 +14916,24 @@ const getDeviceInfo = () => {
14916
14916
  };
14917
14917
  };
14918
14918
 
14919
+ let activeUser = null;
14920
+ /**
14921
+ * for internal use
14922
+ */
14923
+ const getActiveUser = () => {
14924
+ if (!activeUser) {
14925
+ throw new ASCError('Connect client first', 800000 /* UNKNOWN_ERROR */, "fatal" /* FATAL */);
14926
+ }
14927
+ return activeUser;
14928
+ };
14929
+ const setActiveUser = (user) => {
14930
+ activeUser = {
14931
+ _id: user._id,
14932
+ userId: user.userId,
14933
+ path: user.path,
14934
+ };
14935
+ };
14936
+
14919
14937
  /**
14920
14938
  * Retrieves a pair of {@link Amity.Tokens} necessary for connection
14921
14939
  *
@@ -15063,8 +15081,8 @@ const connectClient = async (params) => {
15063
15081
  unsubscribe();
15064
15082
  });
15065
15083
  client.userId = params.userId;
15066
- client._internalUserId = users[0]._id;
15067
15084
  client.accessToken = accessToken;
15085
+ setActiveUser(users[0]);
15068
15086
  return client.ws.connected;
15069
15087
  };
15070
15088
 
@@ -15122,13 +15140,24 @@ const getPostTopic = ({ path }, level = SubscriptionLevels.POST) => {
15122
15140
  const getCommentTopic = ({ path }) => {
15123
15141
  return path;
15124
15142
  };
15143
+ const getMyFollowersTopic = () => {
15144
+ const user = getActiveUser();
15145
+ const [networkId] = user.path.split('/user/');
15146
+ return `${networkId}/membership/${user._id}/+/+`;
15147
+ };
15148
+ const getMyFollowingsTopic = () => {
15149
+ const user = getActiveUser();
15150
+ const [networkId] = user.path.split('/user/');
15151
+ return `${networkId}/membership/+/${user._id}/+`;
15152
+ };
15125
15153
  let mqttAccessToken;
15126
15154
  let mqttUserId;
15127
15155
  function subscribeTopic(topic, callback) {
15128
- const { mqtt, emitter, accessToken, _internalUserId } = getActiveClient();
15129
- if (mqttAccessToken !== accessToken || mqttUserId !== _internalUserId) {
15156
+ const { mqtt, emitter, accessToken } = getActiveClient();
15157
+ const user = getActiveUser();
15158
+ if (mqttAccessToken !== accessToken || mqttUserId !== user._id) {
15130
15159
  mqttAccessToken = accessToken;
15131
- mqttUserId = _internalUserId;
15160
+ mqttUserId = user._id;
15132
15161
  mqtt.connect({ accessToken: mqttAccessToken, userId: mqttUserId });
15133
15162
  proxyMqttEvents(mqtt, emitter);
15134
15163
  }
@@ -15534,6 +15563,8 @@ const idResolvers = {
15534
15563
  post: ({ postId }) => postId,
15535
15564
  comment: ({ commentId }) => commentId,
15536
15565
  stream: ({ streamId }) => streamId,
15566
+ follow: ({ from, to }) => `${from}#${to}`,
15567
+ followCount: ({ userId }) => userId,
15537
15568
  };
15538
15569
  /**
15539
15570
  * Retrieve the id resolver matching a domain name
@@ -15560,6 +15591,8 @@ const PAYLOAD2MODEL = {
15560
15591
  postChildren: 'post',
15561
15592
  comments: 'comment',
15562
15593
  videoStreamings: 'stream',
15594
+ follows: 'follow',
15595
+ followCounts: 'followCount'
15563
15596
  };
15564
15597
 
15565
15598
  /**
@@ -17341,6 +17374,132 @@ const removeCommunityMembersRole = async (communityId, roleId, userIds) => {
17341
17374
  return !!communityUsers.find(communityUser => communityUser.communityId === communityId && !communityUser.roles.includes(roleId));
17342
17375
  };
17343
17376
 
17377
+ /**
17378
+ * ```js
17379
+ * import { getTopTrendingCommunities } from '@amityco/ts-sdk'
17380
+ * const trendingCommunities = await getTopTrendingCommunities()
17381
+ * ```
17382
+ *
17383
+ * Gets a list of top trending {@link Amity.Community} objects
17384
+ *
17385
+ * @param query The query parameters
17386
+ * @returns A list of {@link Amity.Community} objects
17387
+ *
17388
+ * @category Community API
17389
+ * @async
17390
+ */
17391
+ const getTopTrendingCommunities = async (query) => {
17392
+ const client = getActiveClient();
17393
+ client.log('channel/getTopTrendingCommunities', query);
17394
+ const { limit = 5 } = query !== null && query !== void 0 ? query : {};
17395
+ // API-FIX: backend doesnt answer Amity.Response
17396
+ // const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
17397
+ const { data } = await client.http.get(`/api/v3/communities/top-trending`, { params: { options: { limit } } });
17398
+ const { communities } = data;
17399
+ const cachedAt = client.cache && Date.now();
17400
+ if (client.cache) {
17401
+ ingestInCache(data, { cachedAt });
17402
+ const cacheKey = ['community', 'top-trending', { params: { options: { limit } } }];
17403
+ pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
17404
+ }
17405
+ return { data: communities, cachedAt };
17406
+ };
17407
+ /**
17408
+ * ```js
17409
+ * import { getTopTrendingCommunities } from '@amityco/ts-sdk'
17410
+ * const communities = getTopTrendingCommunities.locally()
17411
+ * ```
17412
+ *
17413
+ * Gets a list of top trending {@link Amity.Community} objects from cache
17414
+ *
17415
+ * @param query The query parameters
17416
+ * @returns communities
17417
+ *
17418
+ * @category Community API
17419
+ */
17420
+ getTopTrendingCommunities.locally = (query) => {
17421
+ var _a, _b;
17422
+ const client = getActiveClient();
17423
+ client.log('community/getTopTrendingCommunities.locally', query);
17424
+ if (!client.cache)
17425
+ return;
17426
+ const { limit = 5 } = query !== null && query !== void 0 ? query : {};
17427
+ const queryKey = ['community', 'top-trending', { params: { options: { limit } } }];
17428
+ const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
17429
+ if (!(data === null || data === void 0 ? void 0 : data.communities.length))
17430
+ return;
17431
+ const communities = data.communities
17432
+ .map(communityId => pullFromCache(['community', 'get', communityId]))
17433
+ .filter(Boolean)
17434
+ .map(({ data }) => data);
17435
+ return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
17436
+ ? { data: communities, cachedAt }
17437
+ : undefined;
17438
+ };
17439
+
17440
+ /**
17441
+ * ```js
17442
+ * import { getRecommendedCommunities } from '@amityco/ts-sdk'
17443
+ * const communities = await getRecommendedCommunities()
17444
+ * ```
17445
+ *
17446
+ * Gets a list of recommended {@link Amity.Community} objects
17447
+ *
17448
+ * @param query The query parameters
17449
+ * @returns A list of {@link Amity.Community} objects
17450
+ *
17451
+ * @category Community API
17452
+ * @async
17453
+ */
17454
+ const getRecommendedCommunities = async (query) => {
17455
+ const client = getActiveClient();
17456
+ client.log('channel/getRecommendedCommunities', query);
17457
+ const { limit = 5 } = query !== null && query !== void 0 ? query : {};
17458
+ // API-FIX: backend doesnt answer Amity.Response
17459
+ // const { data } = await client.http.get<Amity.Response<CommunityPayload>>(
17460
+ const { data } = await client.http.get(`/api/v3/communities/recommended`, { params: { options: { limit } } });
17461
+ const { communities } = data;
17462
+ const cachedAt = client.cache && Date.now();
17463
+ if (client.cache) {
17464
+ ingestInCache(data, { cachedAt });
17465
+ const cacheKey = ['community', 'recommended', { params: { options: { limit } } }];
17466
+ pushToCache(cacheKey, { communities: communities.map(getResolver('community')) });
17467
+ }
17468
+ return { data: communities, cachedAt };
17469
+ };
17470
+ /**
17471
+ * ```js
17472
+ * import { getRecommendedCommunities } from '@amityco/ts-sdk'
17473
+ * const communities = getRecommendedCommunities.locally()
17474
+ * ```
17475
+ *
17476
+ * Gets a list of recommended {@link Amity.Community} objects from cache
17477
+ *
17478
+ * @param query The query parameters
17479
+ * @returns communities
17480
+ *
17481
+ * @category Community API
17482
+ */
17483
+ getRecommendedCommunities.locally = (query) => {
17484
+ var _a, _b;
17485
+ const client = getActiveClient();
17486
+ client.log('community/getRecommendedCommunities.locally', query);
17487
+ if (!client.cache)
17488
+ return;
17489
+ const { limit = 5 } = query !== null && query !== void 0 ? query : {};
17490
+ const queryKey = ['community', 'recommended', { params: { options: { limit } } }];
17491
+ const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
17492
+ if (!(data === null || data === void 0 ? void 0 : data.communities.length))
17493
+ return;
17494
+ const communities = data.communities
17495
+ .map(communityId => pullFromCache(['community', 'get', communityId]))
17496
+ .filter(Boolean)
17497
+ .map(({ data }) => data);
17498
+ return communities.length === ((_b = data === null || data === void 0 ? void 0 : data.communities) === null || _b === void 0 ? void 0 : _b.length)
17499
+ ? { data: communities, cachedAt }
17500
+ : undefined;
17501
+ };
17502
+
17344
17503
  /**
17345
17504
  * ```js
17346
17505
  * import { deletePost } from '@amityco/ts-sdk'
@@ -19535,6 +19694,569 @@ queryGlobalFeed.locally = (query) => {
19535
19694
  : undefined;
19536
19695
  };
19537
19696
 
19697
+ const queryFollows = async (key, query) => {
19698
+ const client = getActiveClient();
19699
+ client.log(`follow/queryF${key.substring(1)}`, query);
19700
+ const { userId, page } = query, params = __rest(query, ["userId", "page"]);
19701
+ const { data } = await client.http.get(client.userId === userId ? `/api/v4/me/${key}` : `/api/v4/users/${userId}/${key}`, {
19702
+ params: Object.assign(Object.assign({}, params), { token: toToken(page, 'skiplimit') }),
19703
+ });
19704
+ const { paging } = data, payload = __rest(data, ["paging"]);
19705
+ const { follows } = payload;
19706
+ const cachedAt = client.cache && Date.now();
19707
+ if (client.cache) {
19708
+ ingestInCache(payload, { cachedAt });
19709
+ const cacheKey = [key, 'query', Object.assign(Object.assign({}, params), { userId, options: Object.assign({}, page) })];
19710
+ pushToCache(cacheKey, { follows: follows.map(getResolver('follow')), paging });
19711
+ }
19712
+ const nextPage = toPage(paging.next);
19713
+ const prevPage = toPage(paging.previous);
19714
+ return { data: follows, cachedAt, prevPage, nextPage };
19715
+ };
19716
+ queryFollows.locally = (key, query) => {
19717
+ var _a, _b;
19718
+ const client = getActiveClient();
19719
+ client.log(`follow/queryF${key.substring(1)}.locally`, query);
19720
+ if (!client.cache)
19721
+ return;
19722
+ const { page } = query, params = __rest(query, ["page"]);
19723
+ const queryKey = [key, 'query', Object.assign(Object.assign({}, params), { options: Object.assign({}, page) })];
19724
+ const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
19725
+ if (!(data === null || data === void 0 ? void 0 : data.follows.length)) {
19726
+ return;
19727
+ }
19728
+ const follows = data.follows
19729
+ .map(key => pullFromCache(['follow', 'get', key]))
19730
+ .filter(Boolean)
19731
+ .map(({ data }) => data);
19732
+ const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
19733
+ const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
19734
+ return follows.length === ((_b = data === null || data === void 0 ? void 0 : data.follows) === null || _b === void 0 ? void 0 : _b.length)
19735
+ ? { data: follows, cachedAt, prevPage, nextPage }
19736
+ : undefined;
19737
+ };
19738
+
19739
+ /**
19740
+ * ```js
19741
+ * import { queryFollowers } from '@amityco/ts-sdk'
19742
+ * const { data: followers, prevPage, nextPage } = await queryFollowers({ userId })
19743
+ * ```
19744
+ *
19745
+ * Queries a paginable list of {@link Amity.FollowStatus}
19746
+ *
19747
+ * @param query The query parameters
19748
+ * @returns followers
19749
+ *
19750
+ * @category Follow API
19751
+ * @async
19752
+ */
19753
+ const queryFollowers = async (query) => queryFollows('followers', query);
19754
+ /**
19755
+ * ```js
19756
+ * import { queryFollowers } from '@amityco/ts-sdk'
19757
+ * const { data: followers, prevPage, nextPage } = queryFollowers.locally({ userId })
19758
+ * ```
19759
+ *
19760
+ * Queries a paginable list of {@link Amity.FollowStatus} objects from cache
19761
+ *
19762
+ * @param query The query parameters
19763
+ * @returns followers
19764
+ *
19765
+ * @category Post API
19766
+ */
19767
+ queryFollowers.locally = (query) => queryFollows.locally('followers', query);
19768
+
19769
+ /**
19770
+ * ```js
19771
+ * import { queryFollowings } from '@amityco/ts-sdk'
19772
+ * const { data: followings, prevPage, nextPage } = await queryFollowings({ userId })
19773
+ * ```
19774
+ *
19775
+ * Queries a paginable list of {@link Amity.FollowStatus}
19776
+ *
19777
+ * @param query The query parameters
19778
+ * @returns followings
19779
+ *
19780
+ * @category Follow API
19781
+ * @async
19782
+ */
19783
+ const queryFollowings = async (query) => queryFollows('following', query);
19784
+ /**
19785
+ * ```js
19786
+ * import { queryFollowings } from '@amityco/ts-sdk'
19787
+ * const { data: followings, prevPage, nextPage } = queryFollowings.locally({ userId })
19788
+ * ```
19789
+ *
19790
+ * Queries a paginable list of {@link Amity.FollowStatus} objects from cache
19791
+ *
19792
+ * @param query The query parameters
19793
+ * @returns followings
19794
+ *
19795
+ * @category Post API
19796
+ */
19797
+ queryFollowings.locally = (query) => queryFollows.locally('following', query);
19798
+
19799
+ const getCacheKey = (userId) => ['followInfo', 'get', `${getActiveClient().userId}#${userId}`];
19800
+ /**
19801
+ * ```js
19802
+ * import { getFollowInfo } from '@amityco/ts-sdk'
19803
+ * const { data: followInfo } = await getFollowInfo('foobar')
19804
+ * ```
19805
+ *
19806
+ * Fetches the number of followers, followings, pending requests and the follow status for current user
19807
+ *
19808
+ * @param userId the ID of the {@link Amity.User}
19809
+ * @returns the associated {@link Amity.FollowInfo} object
19810
+ *
19811
+ * @category Follow API
19812
+ * @async
19813
+ */
19814
+ const getFollowInfo = async (userId) => {
19815
+ var _a, _b;
19816
+ const client = getActiveClient();
19817
+ client.log('follow/getFollowInfo', userId);
19818
+ const { data } = await client.http.get(client.userId === userId ? `/api/v4/me/followInfo` : `/api/v4/users/${userId}/followInfo`);
19819
+ const cachedAt = client.cache && Date.now();
19820
+ const followInfo = Object.assign(Object.assign({}, data.followCounts[0]), { status: (_b = (_a = data.follows) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.status });
19821
+ if (client.cache) {
19822
+ pushToCache(getCacheKey(userId), followInfo, { cachedAt });
19823
+ }
19824
+ return {
19825
+ data: followInfo,
19826
+ cachedAt,
19827
+ };
19828
+ };
19829
+ /**
19830
+ * ```js
19831
+ * import { getFollowInfo } from '@amityco/ts-sdk'
19832
+ * const { data: followInfo } = getFollowInfo.locally('foobar')
19833
+ * ```
19834
+ *
19835
+ * Fetches the number of followers, followings, pending requests and the follow status for current user from cache
19836
+ *
19837
+ * @param userId the ID of the {@link Amity.User}
19838
+ * @returns the associated {@link Amity.FollowInfo} object
19839
+ *
19840
+ * @category Follow API
19841
+ */
19842
+ getFollowInfo.locally = (userId) => {
19843
+ const client = getActiveClient();
19844
+ client.log('follow/getFollowInfo.locally', userId);
19845
+ if (!client.cache) {
19846
+ return;
19847
+ }
19848
+ const cached = pullFromCache(getCacheKey(userId));
19849
+ if (!cached) {
19850
+ return;
19851
+ }
19852
+ return {
19853
+ data: cached.data,
19854
+ cachedAt: cached.cachedAt,
19855
+ };
19856
+ };
19857
+
19858
+ /**
19859
+ * ```js
19860
+ * import { follow } from '@amityco/ts-sdk'
19861
+ * const status = await follow('foobar')
19862
+ * ```
19863
+ *
19864
+ * Follow the user
19865
+ *
19866
+ * @param userId the ID of the {@link Amity.User}
19867
+ * @returns the status {@link Amity.FollowStatus}
19868
+ *
19869
+ * @category Follow API
19870
+ * @async
19871
+ */
19872
+ const follow = async (userId) => {
19873
+ const client = getActiveClient();
19874
+ client.log('follow/follow', userId);
19875
+ const { data } = await client.http.post(`/api/v4/me/following/${userId}`);
19876
+ const cachedAt = client.cache && Date.now();
19877
+ if (client.cache) {
19878
+ ingestInCache(data, { cachedAt });
19879
+ }
19880
+ fireEvent(data.follows[0].status === 'accepted' ? 'follow.created' : 'follow.requested', data.follows[0]);
19881
+ return {
19882
+ data: data.follows[0],
19883
+ cachedAt,
19884
+ };
19885
+ };
19886
+
19887
+ /**
19888
+ * ```js
19889
+ * import { unfollow } from '@amityco/ts-sdk'
19890
+ * await unfollow('foobar')
19891
+ * ```
19892
+ *
19893
+ * Cancel the follow request or unfollow the user
19894
+ *
19895
+ * @param userId the ID of the {@link Amity.User}
19896
+ * @returns A success boolean if the user {@link Amity.User} was unfollowed
19897
+ *
19898
+ * @category Follow API
19899
+ * @async
19900
+ */
19901
+ const unfollow = async (userId) => {
19902
+ const client = getActiveClient();
19903
+ client.log('follow/unfollow', userId);
19904
+ const { data } = await client.http.delete(`/api/v4/me/following/${userId}`);
19905
+ if (client.cache) {
19906
+ ingestInCache(data);
19907
+ }
19908
+ fireEvent('follow.unfollowed', data.follows[0]);
19909
+ return true;
19910
+ };
19911
+
19912
+ /**
19913
+ * ```js
19914
+ * import { acceptFollower } from '@amityco/ts-sdk'
19915
+ * await acceptFollower('foobar')
19916
+ * ```
19917
+ *
19918
+ * Accept the follow request
19919
+ *
19920
+ * @param userId the ID of the {@link Amity.User} follower
19921
+ * @returns A success boolean if the follow request was accepted
19922
+ *
19923
+ * @category Follow API
19924
+ * @async
19925
+ */
19926
+ const acceptFollower = async (userId) => {
19927
+ const client = getActiveClient();
19928
+ client.log('follow/acceptFollower', userId);
19929
+ const { data } = await client.http.post(`/api/v4/me/followers/${userId}`);
19930
+ if (client.cache) {
19931
+ ingestInCache(data);
19932
+ }
19933
+ fireEvent('follow.accepted', data.follows[0]);
19934
+ return true;
19935
+ };
19936
+
19937
+ /**
19938
+ * ```js
19939
+ * import { declineFollower } from '@amityco/ts-sdk'
19940
+ * await declineFollower('foobar')
19941
+ * ```
19942
+ *
19943
+ * Decline the follow request or delete the follower
19944
+ *
19945
+ * @param userId the ID of the {@link Amity.User} follower
19946
+ * @returns A success boolean if the follow request was decline
19947
+ *
19948
+ * @category Follow API
19949
+ * @async
19950
+ */
19951
+ const declineFollower = async (userId) => {
19952
+ const client = getActiveClient();
19953
+ client.log('follow/declineFollower', userId);
19954
+ const { data } = await client.http.delete(`/api/v4/me/followers/${userId}`);
19955
+ if (client.cache) {
19956
+ ingestInCache(data);
19957
+ }
19958
+ fireEvent('follow.requestDeclined', data.follows[0]);
19959
+ return true;
19960
+ };
19961
+
19962
+ const createFollowEventSubscriber = (event, callback) => {
19963
+ const client = getActiveClient();
19964
+ const filter = (payload) => {
19965
+ var _a, _b;
19966
+ if (!client.cache) {
19967
+ callback(payload);
19968
+ }
19969
+ else {
19970
+ ingestInCache({ follows: [payload] });
19971
+ const queries = [
19972
+ ...(_a = queryCache(['followers', 'query'])) !== null && _a !== void 0 ? _a : [],
19973
+ ...(_b = queryCache(['followings', 'query'])) !== null && _b !== void 0 ? _b : [],
19974
+ ];
19975
+ queries
19976
+ // @ts-ignore
19977
+ .filter(({ key }) => key[2].userId === payload.from || key[2].userId === payload.to)
19978
+ .forEach(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
19979
+ callback(payload);
19980
+ }
19981
+ };
19982
+ return createEventSubscriber(client, event, event, filter);
19983
+ };
19984
+
19985
+ /**
19986
+ * ```js
19987
+ * import { onUserFollowed } from '@amityco/ts-sdk'
19988
+ * const dispose = onUserFollowed(status => {
19989
+ * // ...
19990
+ * })
19991
+ * ```
19992
+ *
19993
+ * Fired when a user follows another users and confirmation is not required
19994
+ *
19995
+ * @param callback The function to call when the event was fired
19996
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
19997
+ *
19998
+ * @category Follow Events
19999
+ */
20000
+ const onUserFollowed = (callback) => createFollowEventSubscriber('follow.created', callback);
20001
+
20002
+ /**
20003
+ * ```js
20004
+ * import { onUserUnfollowed } from '@amityco/ts-sdk'
20005
+ * const dispose = onUserFollowed(status => {
20006
+ * // ...
20007
+ * })
20008
+ * ```
20009
+ *
20010
+ * Fired when a user unfollows
20011
+ *
20012
+ * @param callback The function to call when the event was fired
20013
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20014
+ *
20015
+ * @category Follow Events
20016
+ */
20017
+ const onUserUnfollowed = (callback) => createFollowEventSubscriber('follow.unfollowed', callback);
20018
+
20019
+ /**
20020
+ * ```js
20021
+ * import { onFollowerDeleted } from '@amityco/ts-sdk'
20022
+ * const dispose = onFollowerDeleted(status => {
20023
+ * // ...
20024
+ * })
20025
+ * ```
20026
+ *
20027
+ * Fired when a follower has been deleted
20028
+ *
20029
+ * @param callback The function to call when the event was fired
20030
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20031
+ *
20032
+ * @category Follow Events
20033
+ */
20034
+ const onFollowerDeleted = (callback) => createFollowEventSubscriber('follow.followerDeleted', callback);
20035
+
20036
+ /**
20037
+ * ```js
20038
+ * import { onFollowerRequested } from '@amityco/ts-sdk'
20039
+ * const dispose = onFollowerRequested(status => {
20040
+ * // ...
20041
+ * })
20042
+ * ```
20043
+ *
20044
+ * Fired when a user follows another users and confirmation is required
20045
+ *
20046
+ * @param callback The function to call when the event was fired
20047
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20048
+ *
20049
+ * @category Follow Events
20050
+ */
20051
+ const onFollowerRequested = (callback) => createFollowEventSubscriber('follow.requested', callback);
20052
+
20053
+ /**
20054
+ * ```js
20055
+ * import { onFollowRequestCanceled } from '@amityco/ts-sdk'
20056
+ * const dispose = onFollowRequestCanceled(status => {
20057
+ * // ...
20058
+ * })
20059
+ * ```
20060
+ *
20061
+ * Fired when a follow request has been canceled
20062
+ *
20063
+ * @param callback The function to call when the event was fired
20064
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20065
+ *
20066
+ * @category Follow Events
20067
+ */
20068
+ const onFollowRequestCanceled = (callback) => createFollowEventSubscriber('follow.requestCanceled', callback);
20069
+
20070
+ /**
20071
+ * ```js
20072
+ * import { onFollowRequestAccepted } from '@amityco/ts-sdk'
20073
+ * const dispose = onFollowRequestAccepted(status => {
20074
+ * // ...
20075
+ * })
20076
+ * ```
20077
+ *
20078
+ * Fired when a follow request has been accepted
20079
+ *
20080
+ * @param callback The function to call when the event was fired
20081
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20082
+ *
20083
+ * @category Follow Events
20084
+ */
20085
+ const onFollowRequestAccepted = (callback) => createFollowEventSubscriber('follow.accepted', callback);
20086
+
20087
+ /**
20088
+ * ```js
20089
+ * import { onFollowRequestDeclined } from '@amityco/ts-sdk'
20090
+ * const dispose = onFollowRequestDeclined(status => {
20091
+ * // ...
20092
+ * })
20093
+ * ```
20094
+ *
20095
+ * Fired when a follow request has been declined
20096
+ *
20097
+ * @param callback The function to call when the event was fired
20098
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20099
+ *
20100
+ * @category Follow Events
20101
+ */
20102
+ const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follow.requestDeclined', callback);
20103
+
20104
+ /**
20105
+ * ```js
20106
+ * import { onFollowInfoUpdated } from '@amityco/ts-sdk'
20107
+ * const dispose = onFollowInfoUpdated(followInfo => {
20108
+ * // ...
20109
+ * })
20110
+ * ```
20111
+ *
20112
+ * Fired when a {@link Amity.FollowInfo} has been updated
20113
+ *
20114
+ * @param callback The function to call when the event was fired
20115
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
20116
+ *
20117
+ * @category Follow Events
20118
+ */
20119
+ const onFollowInfoUpdated = (callback) => {
20120
+ const handler = async (payload) => {
20121
+ const [{ data: followInfoFrom }, { data: followInfoTo },] = await Promise.all([getFollowInfo(payload.from), getFollowInfo(payload.to)]);
20122
+ callback(followInfoFrom);
20123
+ callback(followInfoTo);
20124
+ };
20125
+ const disposers = [
20126
+ createFollowEventSubscriber('follow.created', handler),
20127
+ createFollowEventSubscriber('follow.requested', handler),
20128
+ createFollowEventSubscriber('follow.accepted', handler),
20129
+ createFollowEventSubscriber('follow.unfollowed', handler),
20130
+ createFollowEventSubscriber('follow.requestCanceled', handler),
20131
+ createFollowEventSubscriber('follow.requestDeclined', handler),
20132
+ createFollowEventSubscriber('follow.followerDeleted', handler),
20133
+ ];
20134
+ return () => {
20135
+ disposers.forEach(fn => fn());
20136
+ };
20137
+ };
20138
+
20139
+ /**
20140
+ * ```js
20141
+ * import { observeFollowInfo } from '@amityco/ts-sdk'
20142
+ *
20143
+ * let followInfo = {}
20144
+ * const dispose = observeFollowInfo(userId, updated => followInfo = updated)
20145
+ * ```
20146
+ *
20147
+ * Observe all mutation on a given {@link Amity.FollowInfo}
20148
+ *
20149
+ * @param userId the ID of the user to observe
20150
+ * @param callback the function to call when new data are available
20151
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the post
20152
+ *
20153
+ * @category Follow Observer
20154
+ */
20155
+ const observeFollowInfo = (userId, callback, policy = 'cache_then_server') => {
20156
+ const { log } = getActiveClient();
20157
+ const timestamp = Date.now();
20158
+ log(`observeFollowInfo(tmpid: ${timestamp}) > listen`);
20159
+ const router = (result, action) => {
20160
+ var _a, _b;
20161
+ if (callback instanceof Function)
20162
+ return callback(result);
20163
+ if (action !== 'onFetch')
20164
+ (_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, result);
20165
+ (_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, result);
20166
+ };
20167
+ const realtimeRouter = (result, action) => {
20168
+ var _a;
20169
+ if (((_a = result.data) === null || _a === void 0 ? void 0 : _a.userId) !== userId)
20170
+ return;
20171
+ router(result, action);
20172
+ };
20173
+ const disposers = [];
20174
+ disposers.push(onFollowInfoUpdated(data => realtimeRouter({ data, loading: false, origin: 'event' }, 'onUpdate')));
20175
+ runQuery(createQuery(getFollowInfo, userId), result => (result.data || result.error) && router(result, 'onFetch'), queryOptions(policy));
20176
+ return () => {
20177
+ log(`observeFollowInfo(tmpid: ${timestamp}) > dispose`);
20178
+ disposers.forEach(fn => fn());
20179
+ };
20180
+ };
20181
+
20182
+ /**
20183
+ * ```js
20184
+ * import { observeFollowers } from '@amityco/ts-sdk'
20185
+ *
20186
+ * let followers = []
20187
+ * const unsub = observeFollowers('userId', follower => merge(followers, follower))
20188
+ * ```
20189
+ *
20190
+ * Observe all mutations on a list of followers {@link Amity.FollowStatus} for a given user
20191
+ *
20192
+ * @param userId the ID of the {@link Amity.User}
20193
+ * @param callback the function to call when new data are available
20194
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
20195
+ *
20196
+ * @category Follow Observer
20197
+ */
20198
+ const observeFollowers = (userId, callback) => {
20199
+ const { log } = getActiveClient();
20200
+ const timestamp = Date.now();
20201
+ log(`observeFollowers(tmpid: ${timestamp}) > listen`);
20202
+ const disposers = [];
20203
+ const router = (status, action) => {
20204
+ var _a, _b;
20205
+ if (status.from !== userId) {
20206
+ return;
20207
+ }
20208
+ if (callback instanceof Function) {
20209
+ return callback(status);
20210
+ }
20211
+ (_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, status);
20212
+ (_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, status);
20213
+ };
20214
+ disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')));
20215
+ return () => {
20216
+ log(`observeFollowers(tmpid: ${timestamp}) > dispose`);
20217
+ disposers.forEach(fn => fn());
20218
+ };
20219
+ };
20220
+
20221
+ /**
20222
+ * ```js
20223
+ * import { observeFollowings } from '@amityco/ts-sdk'
20224
+ *
20225
+ * let followings = []
20226
+ * const unsub = observeFollowers('userId', follower => merge(followings, following))
20227
+ * ```
20228
+ *
20229
+ * Observe all mutations on a list of followings {@link Amity.FollowStatus} for a given user
20230
+ *
20231
+ * @param userId the ID of the {@link Amity.User}
20232
+ * @param callback the function to call when new data are available
20233
+ * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
20234
+ *
20235
+ * @category Follow Observer
20236
+ */
20237
+ const observeFollowings = (userId, callback) => {
20238
+ const { log } = getActiveClient();
20239
+ const timestamp = Date.now();
20240
+ log(`observeFollowings(tmpid: ${timestamp}) > listen`);
20241
+ const disposers = [];
20242
+ const router = (status, action) => {
20243
+ var _a, _b;
20244
+ if (status.to !== userId) {
20245
+ return;
20246
+ }
20247
+ if (callback instanceof Function) {
20248
+ return callback(status);
20249
+ }
20250
+ (_a = callback.onEvent) === null || _a === void 0 ? void 0 : _a.call(callback, action, status);
20251
+ (_b = callback[action]) === null || _b === void 0 ? void 0 : _b.call(callback, status);
20252
+ };
20253
+ disposers.push(onFollowerRequested(x => router(x, 'onRequested')), onFollowRequestAccepted(x => router(x, 'onAccepted')), onFollowRequestDeclined(x => router(x, 'onDeclined')), onFollowRequestCanceled(x => router(x, 'onCanceled')), onUserFollowed(x => router(x, 'onFollowed')), onUserUnfollowed(x => router(x, 'onUnfollowed')), onFollowerDeleted(x => router(x, 'onDeleted')));
20254
+ return () => {
20255
+ log(`observeFollowings(tmpid: ${timestamp}) > dispose`);
20256
+ disposers.forEach(fn => fn());
20257
+ };
20258
+ };
20259
+
19538
20260
  /**
19539
20261
  * ```js
19540
20262
  * import { observePosts } from '@amityco/ts-sdk'
@@ -19993,4 +20715,4 @@ const onStreamRecorded = (callback) => {
19993
20715
  return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
19994
20716
  };
19995
20717
 
19996
- export { API_REGIONS, SubscriptionLevels, VERSION$1 as VERSION, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRole, addReaction, backupCache, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createMessage, createPost, createQuery, createReport, createStream, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, getActiveClient, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFile, getMessage, getMessages, getPost, getPostTopic, getPosts, getRole, getStream, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, mergeInCache, observeChannel, observeComment, observeComments, observeCommunity, observeFile, observeMessage, observeMessages, observePost, observePosts, observeUser, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onMemberAdded, onMemberRemoved, onMessageCreated, onMessageDeleted, onMessageUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserFlagCleared, onUserFlagged, onUserUnflagged, onUserUpdated, pullFromCache, pushToCache, queryCache, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRole, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, wipeCache };
20718
+ export { API_REGIONS, SubscriptionLevels, VERSION$1 as VERSION, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRole, addReaction, backupCache, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createMessage, createPost, createQuery, createReport, createStream, declineFollower, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getStream, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, mergeInCache, observeChannel, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePost, observePosts, observeUser, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMemberAdded, onMemberRemoved, onMessageCreated, onMessageDeleted, onMessageUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRole, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, wipeCache };