@amityco/ts-sdk 6.12.2-d74459e.0 → 6.12.2-e855934.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 (290) hide show
  1. package/README.md +8 -9
  2. package/dist/@types/core/marker.d.ts +4 -4
  3. package/dist/@types/core/marker.d.ts.map +1 -1
  4. package/dist/@types/core/model.d.ts +4 -4
  5. package/dist/@types/core/model.d.ts.map +1 -1
  6. package/dist/@types/core/payload.d.ts +17 -17
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/block.d.ts +1 -1
  9. package/dist/@types/domains/block.d.ts.map +1 -1
  10. package/dist/@types/domains/category.d.ts +5 -2
  11. package/dist/@types/domains/category.d.ts.map +1 -1
  12. package/dist/@types/domains/client.d.ts +3 -3
  13. package/dist/@types/domains/client.d.ts.map +1 -1
  14. package/dist/@types/domains/comment.d.ts +1 -1
  15. package/dist/@types/domains/comment.d.ts.map +1 -1
  16. package/dist/@types/domains/community.d.ts +4 -4
  17. package/dist/@types/domains/community.d.ts.map +1 -1
  18. package/dist/@types/domains/follow.d.ts +4 -4
  19. package/dist/@types/domains/follow.d.ts.map +1 -1
  20. package/dist/@types/domains/group.d.ts +2 -2
  21. package/dist/@types/domains/group.d.ts.map +1 -1
  22. package/dist/@types/domains/messagePreview.d.ts +2 -2
  23. package/dist/@types/domains/messagePreview.d.ts.map +1 -1
  24. package/dist/@types/domains/poll.d.ts +1 -1
  25. package/dist/@types/domains/poll.d.ts.map +1 -1
  26. package/dist/@types/domains/post.d.ts +1 -1
  27. package/dist/@types/domains/post.d.ts.map +1 -1
  28. package/dist/@types/domains/reaction.d.ts +1 -1
  29. package/dist/@types/domains/reaction.d.ts.map +1 -1
  30. package/dist/@types/domains/stream.d.ts +2 -2
  31. package/dist/@types/domains/stream.d.ts.map +1 -1
  32. package/dist/@types/domains/user.d.ts +7 -3
  33. package/dist/@types/domains/user.d.ts.map +1 -1
  34. package/dist/cache/api/pushToCache.d.ts +1 -1
  35. package/dist/cache/api/upsertInCache.d.ts +1 -1
  36. package/dist/categoryRepository/api/getCategory.d.ts.map +1 -1
  37. package/dist/categoryRepository/api/queryCategories.d.ts.map +1 -1
  38. package/dist/categoryRepository/observers/getCategories.d.ts.map +1 -1
  39. package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts +4 -4
  40. package/dist/channelRepsitory/channelMembership/api/addMembers.d.ts.map +1 -1
  41. package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts +4 -4
  42. package/dist/channelRepsitory/channelMembership/api/removeMembers.d.ts.map +1 -1
  43. package/dist/channelRepsitory/channelModeration/api/addRole.d.ts +4 -4
  44. package/dist/channelRepsitory/channelModeration/api/addRole.d.ts.map +1 -1
  45. package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts +2 -2
  46. package/dist/channelRepsitory/channelModeration/api/banMembers.d.ts.map +1 -1
  47. package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts +4 -4
  48. package/dist/channelRepsitory/channelModeration/api/removeRole.d.ts.map +1 -1
  49. package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts +2 -2
  50. package/dist/channelRepsitory/channelModeration/api/unbanMembers.d.ts.map +1 -1
  51. package/dist/channelRepsitory/events/onChannelMemberAdded.d.ts +1 -1
  52. package/dist/channelRepsitory/events/onChannelMemberBanned.d.ts +1 -1
  53. package/dist/channelRepsitory/events/onChannelMemberRemoved.d.ts +1 -1
  54. package/dist/channelRepsitory/events/onChannelMemberUnbanned.d.ts +1 -1
  55. package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts +2 -0
  56. package/dist/channelRepsitory/observers/tests/getChannel.test.d.ts.map +1 -0
  57. package/dist/client/api/getToken.d.ts +3 -3
  58. package/dist/client/api/getToken.d.ts.map +1 -1
  59. package/dist/client/utils/setClientToken.d.ts +1 -1
  60. package/dist/communityRepository/communityMembership/api/addMembers.d.ts +4 -4
  61. package/dist/communityRepository/communityMembership/api/addMembers.d.ts.map +1 -1
  62. package/dist/communityRepository/communityMembership/api/removeMembers.d.ts +4 -4
  63. package/dist/communityRepository/communityMembership/api/removeMembers.d.ts.map +1 -1
  64. package/dist/communityRepository/communityModeration/api/addRoles.d.ts +4 -4
  65. package/dist/communityRepository/communityModeration/api/addRoles.d.ts.map +1 -1
  66. package/dist/communityRepository/communityModeration/api/banMembers.d.ts +2 -2
  67. package/dist/communityRepository/communityModeration/api/banMembers.d.ts.map +1 -1
  68. package/dist/communityRepository/communityModeration/api/removeRoles.d.ts +4 -4
  69. package/dist/communityRepository/communityModeration/api/removeRoles.d.ts.map +1 -1
  70. package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts +2 -2
  71. package/dist/communityRepository/communityModeration/api/unbanMembers.d.ts.map +1 -1
  72. package/dist/core/device.d.ts +1 -1
  73. package/dist/core/device.d.ts.map +1 -1
  74. package/dist/core/query/filtering.d.ts +2 -2
  75. package/dist/core/query/filtering.d.ts.map +1 -1
  76. package/dist/external/api/createUserToken.d.ts +2 -2
  77. package/dist/external/api/createUserToken.d.ts.map +1 -1
  78. package/dist/group/utils/withUser.d.ts +3 -3
  79. package/dist/group/utils/withUser.d.ts.map +1 -1
  80. package/dist/index.cjs.js +206 -126
  81. package/dist/index.esm.js +206 -126
  82. package/dist/index.umd.js +4 -4
  83. package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
  84. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  85. package/dist/messageRepository/api/getDeliveredUsers.d.ts +6 -6
  86. package/dist/messageRepository/api/getDeliveredUsers.d.ts.map +1 -1
  87. package/dist/messageRepository/api/getReadUsers.d.ts +6 -6
  88. package/dist/messageRepository/api/getReadUsers.d.ts.map +1 -1
  89. package/dist/streamRepository/api/getStreams.d.ts +1 -1
  90. package/dist/streamRepository/api/getStreams.d.ts.map +1 -1
  91. package/dist/streamRepository/api/queryStreams.d.ts +1 -1
  92. package/dist/streamRepository/api/queryStreams.d.ts.map +1 -1
  93. package/dist/userRepository/api/flagUser.d.ts +1 -1
  94. package/dist/userRepository/api/flagUser.d.ts.map +1 -1
  95. package/dist/userRepository/api/getUser.d.ts.map +1 -1
  96. package/dist/userRepository/api/getUserByIds.d.ts +1 -1
  97. package/dist/userRepository/api/getUserByIds.d.ts.map +1 -1
  98. package/dist/userRepository/api/isUserFlaggedByMe.d.ts +1 -1
  99. package/dist/userRepository/api/isUserFlaggedByMe.d.ts.map +1 -1
  100. package/dist/userRepository/api/queryBlockedUsers.d.ts +5 -5
  101. package/dist/userRepository/api/queryBlockedUsers.d.ts.map +1 -1
  102. package/dist/userRepository/api/queryUsers.d.ts +6 -6
  103. package/dist/userRepository/api/queryUsers.d.ts.map +1 -1
  104. package/dist/userRepository/api/unflagUser.d.ts +1 -1
  105. package/dist/userRepository/api/unflagUser.d.ts.map +1 -1
  106. package/dist/userRepository/api/updateUser.d.ts +4 -4
  107. package/dist/userRepository/api/updateUser.d.ts.map +1 -1
  108. package/dist/userRepository/events/onUserDeleted.d.ts +2 -2
  109. package/dist/userRepository/events/onUserDeleted.d.ts.map +1 -1
  110. package/dist/userRepository/events/onUserFetched.d.ts +2 -2
  111. package/dist/userRepository/events/onUserFetched.d.ts.map +1 -1
  112. package/dist/userRepository/events/onUserFlagCleared.d.ts +2 -2
  113. package/dist/userRepository/events/onUserFlagCleared.d.ts.map +1 -1
  114. package/dist/userRepository/events/onUserFlagged.d.ts +2 -2
  115. package/dist/userRepository/events/onUserFlagged.d.ts.map +1 -1
  116. package/dist/userRepository/events/onUserUnflagged.d.ts +2 -2
  117. package/dist/userRepository/events/onUserUnflagged.d.ts.map +1 -1
  118. package/dist/userRepository/events/onUserUpdated.d.ts +2 -2
  119. package/dist/userRepository/events/onUserUpdated.d.ts.map +1 -1
  120. package/dist/userRepository/events/utils.d.ts +1 -1
  121. package/dist/userRepository/events/utils.d.ts.map +1 -1
  122. package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
  123. package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
  124. package/dist/userRepository/observers/getUser.d.ts +2 -2
  125. package/dist/userRepository/observers/getUser.d.ts.map +1 -1
  126. package/dist/userRepository/observers/getUsers.d.ts.map +1 -1
  127. package/dist/userRepository/observers/observeUser.d.ts +2 -2
  128. package/dist/userRepository/observers/observeUser.d.ts.map +1 -1
  129. package/dist/userRepository/observers/searchUserByDisplayName.d.ts +2 -2
  130. package/dist/userRepository/observers/searchUserByDisplayName.d.ts.map +1 -1
  131. package/dist/userRepository/relationship/block/api/blockUser.d.ts +4 -4
  132. package/dist/userRepository/relationship/block/api/blockUser.d.ts.map +1 -1
  133. package/dist/userRepository/relationship/block/api/unBlockUser.d.ts +4 -4
  134. package/dist/userRepository/relationship/block/api/unBlockUser.d.ts.map +1 -1
  135. package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts +1 -1
  136. package/dist/userRepository/relationship/block/observers/getBlockedUsers.d.ts.map +1 -1
  137. package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts +2 -2
  138. package/dist/userRepository/relationship/follow/api/acceptFollower.d.ts.map +1 -1
  139. package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts +2 -2
  140. package/dist/userRepository/relationship/follow/api/acceptMyFollower.d.ts.map +1 -1
  141. package/dist/userRepository/relationship/follow/api/declineFollower.d.ts +2 -2
  142. package/dist/userRepository/relationship/follow/api/declineFollower.d.ts.map +1 -1
  143. package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts +2 -2
  144. package/dist/userRepository/relationship/follow/api/declineMyFollower.d.ts.map +1 -1
  145. package/dist/userRepository/relationship/follow/api/follow.d.ts +2 -2
  146. package/dist/userRepository/relationship/follow/api/follow.d.ts.map +1 -1
  147. package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts +4 -4
  148. package/dist/userRepository/relationship/follow/api/getFollowInfo.d.ts.map +1 -1
  149. package/dist/userRepository/relationship/follow/api/unfollow.d.ts +3 -3
  150. package/dist/userRepository/relationship/follow/api/unfollow.d.ts.map +1 -1
  151. package/dist/userRepository/relationship/follow/api/utils.d.ts +1 -1
  152. package/dist/userRepository/relationship/follow/api/utils.d.ts.map +1 -1
  153. package/dist/userRepository/relationship/follow/observers/getFollowers.d.ts +1 -1
  154. package/dist/userRepository/relationship/follow/observers/getFollowings.d.ts +1 -1
  155. package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts +1 -1
  156. package/dist/userRepository/relationship/follow/observers/observeFollowInfo.d.ts.map +1 -1
  157. package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts +2 -2
  158. package/dist/userRepository/relationship/follow/observers/observeFollowers.d.ts.map +1 -1
  159. package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts +2 -2
  160. package/dist/userRepository/relationship/follow/observers/observeFollowings.d.ts.map +1 -1
  161. package/dist/utils/linkedObject/categoryLinkedObject.d.ts +2 -0
  162. package/dist/utils/linkedObject/categoryLinkedObject.d.ts.map +1 -0
  163. package/dist/utils/linkedObject/index.d.ts +2 -0
  164. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  165. package/dist/utils/linkedObject/userLinkedObject.d.ts +2 -0
  166. package/dist/utils/linkedObject/userLinkedObject.d.ts.map +1 -0
  167. package/dist/utils/tests/client.d.ts.map +1 -1
  168. package/dist/utils/tests/dummy/block.d.ts +4 -4
  169. package/dist/utils/tests/dummy/block.d.ts.map +1 -1
  170. package/dist/utils/tests/dummy/category.d.ts +7 -0
  171. package/dist/utils/tests/dummy/category.d.ts.map +1 -1
  172. package/dist/utils/tests/dummy/channel.d.ts +11 -1
  173. package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
  174. package/dist/utils/tests/dummy/comment.d.ts +6 -6
  175. package/dist/utils/tests/dummy/follow.d.ts +1 -1
  176. package/dist/utils/tests/dummy/follow.d.ts.map +1 -1
  177. package/dist/utils/tests/dummy/user.d.ts +5 -1
  178. package/dist/utils/tests/dummy/user.d.ts.map +1 -1
  179. package/package.json +1 -1
  180. package/src/@types/core/marker.ts +4 -4
  181. package/src/@types/core/model.ts +4 -4
  182. package/src/@types/core/payload.ts +17 -17
  183. package/src/@types/domains/block.ts +1 -1
  184. package/src/@types/domains/category.ts +6 -2
  185. package/src/@types/domains/client.ts +3 -3
  186. package/src/@types/domains/comment.ts +1 -1
  187. package/src/@types/domains/community.ts +4 -4
  188. package/src/@types/domains/follow.ts +4 -4
  189. package/src/@types/domains/group.ts +2 -2
  190. package/src/@types/domains/messagePreview.ts +2 -2
  191. package/src/@types/domains/poll.ts +1 -1
  192. package/src/@types/domains/post.ts +1 -1
  193. package/src/@types/domains/reaction.ts +1 -1
  194. package/src/@types/domains/stream.ts +2 -2
  195. package/src/@types/domains/user.ts +8 -3
  196. package/src/cache/api/pushToCache.ts +1 -1
  197. package/src/cache/api/upsertInCache.ts +1 -1
  198. package/src/categoryRepository/api/getCategory.ts +3 -2
  199. package/src/categoryRepository/api/queryCategories.ts +7 -1
  200. package/src/categoryRepository/observers/getCategories.ts +3 -2
  201. package/src/categoryRepository/observers/tests/getCategories.test.ts +2 -1
  202. package/src/channelRepsitory/api/createChannel.ts +1 -1
  203. package/src/channelRepsitory/channelMembership/api/addMembers.ts +4 -4
  204. package/src/channelRepsitory/channelMembership/api/removeMembers.ts +4 -4
  205. package/src/channelRepsitory/channelMembership/observers/tests/getMembers.test.ts +1 -1
  206. package/src/channelRepsitory/channelMembership/observers/tests/searchMembers.test.ts +1 -3
  207. package/src/channelRepsitory/channelModeration/api/addRole.ts +4 -4
  208. package/src/channelRepsitory/channelModeration/api/banMembers.ts +2 -2
  209. package/src/channelRepsitory/channelModeration/api/removeRole.ts +4 -4
  210. package/src/channelRepsitory/channelModeration/api/unbanMembers.ts +2 -2
  211. package/src/channelRepsitory/events/onChannelMemberAdded.ts +1 -1
  212. package/src/channelRepsitory/events/onChannelMemberBanned.ts +1 -1
  213. package/src/channelRepsitory/events/onChannelMemberRemoved.ts +1 -1
  214. package/src/channelRepsitory/events/onChannelMemberUnbanned.ts +1 -1
  215. package/src/channelRepsitory/observers/tests/getChannel.test.ts +73 -0
  216. package/src/channelRepsitory/observers/tests/getChannels.test.ts +462 -50
  217. package/src/client/api/getToken.ts +3 -3
  218. package/src/client/api/login.ts +1 -1
  219. package/src/communityRepository/communityMembership/api/addMembers.ts +4 -4
  220. package/src/communityRepository/communityMembership/api/removeMembers.ts +4 -4
  221. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  222. package/src/communityRepository/communityMembership/observers/tests/getMembers.test.ts +1 -1
  223. package/src/communityRepository/communityModeration/api/addRoles.ts +4 -4
  224. package/src/communityRepository/communityModeration/api/banMembers.ts +2 -2
  225. package/src/communityRepository/communityModeration/api/removeRoles.ts +4 -4
  226. package/src/communityRepository/communityModeration/api/unbanMembers.ts +2 -2
  227. package/src/core/device.ts +1 -1
  228. package/src/core/query/filtering.ts +3 -1
  229. package/src/core/query/tests/filtering.test.ts +2 -2
  230. package/src/external/api/createUserToken.ts +2 -2
  231. package/src/group/utils/withUser.ts +8 -4
  232. package/src/liveStreamPlayer/api/getPlayer.ts +1 -1
  233. package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +1 -1
  234. package/src/messagePreview/utils/getSubChannelMessagePreviewWithUser.ts +1 -1
  235. package/src/messageRepository/api/getDeliveredUsers.ts +11 -9
  236. package/src/messageRepository/api/getReadUsers.ts +11 -9
  237. package/src/messageRepository/observers/tests/getMessages.test.ts +766 -0
  238. package/src/streamRepository/api/getStreams.ts +1 -1
  239. package/src/streamRepository/api/queryStreams.ts +1 -1
  240. package/src/subChannelRepository/observers/tests/getSubChannels.test.ts +308 -15
  241. package/src/userRepository/api/flagUser.ts +1 -1
  242. package/src/userRepository/api/getUser.ts +2 -1
  243. package/src/userRepository/api/getUserByIds.ts +4 -3
  244. package/src/userRepository/api/isUserFlaggedByMe.ts +1 -1
  245. package/src/userRepository/api/queryBlockedUsers.ts +10 -8
  246. package/src/userRepository/api/queryUsers.ts +12 -10
  247. package/src/userRepository/api/unflagUser.ts +1 -1
  248. package/src/userRepository/api/updateUser.ts +6 -6
  249. package/src/userRepository/events/onUserDeleted.ts +2 -2
  250. package/src/userRepository/events/onUserFetched.ts +2 -2
  251. package/src/userRepository/events/onUserFlagCleared.ts +2 -2
  252. package/src/userRepository/events/onUserFlagged.ts +2 -2
  253. package/src/userRepository/events/onUserUnflagged.ts +2 -2
  254. package/src/userRepository/events/onUserUpdated.ts +2 -2
  255. package/src/userRepository/events/utils.ts +1 -1
  256. package/src/userRepository/observers/getBlockedUsers.ts +8 -7
  257. package/src/userRepository/observers/getUser.ts +3 -3
  258. package/src/userRepository/observers/getUsers.ts +2 -2
  259. package/src/userRepository/observers/observeUser.ts +9 -6
  260. package/src/userRepository/observers/searchUserByDisplayName.ts +2 -2
  261. package/src/userRepository/observers/tests/getUser.test.ts +1 -1
  262. package/src/userRepository/observers/tests/getUsers.test.ts +12 -11
  263. package/src/userRepository/observers/tests/searchUserByDisplayName.test.ts +1 -1
  264. package/src/userRepository/relationship/block/api/blockUser.ts +6 -4
  265. package/src/userRepository/relationship/block/api/unBlockUser.ts +6 -4
  266. package/src/userRepository/relationship/block/observers/getBlockedUsers.ts +1 -1
  267. package/src/userRepository/relationship/follow/api/acceptFollower.ts +2 -2
  268. package/src/userRepository/relationship/follow/api/acceptMyFollower.ts +2 -2
  269. package/src/userRepository/relationship/follow/api/declineFollower.ts +2 -2
  270. package/src/userRepository/relationship/follow/api/declineMyFollower.ts +2 -2
  271. package/src/userRepository/relationship/follow/api/follow.ts +2 -2
  272. package/src/userRepository/relationship/follow/api/getFollowInfo.ts +4 -4
  273. package/src/userRepository/relationship/follow/api/unfollow.ts +3 -3
  274. package/src/userRepository/relationship/follow/api/utils.ts +1 -1
  275. package/src/userRepository/relationship/follow/observers/getFollowers.ts +1 -1
  276. package/src/userRepository/relationship/follow/observers/getFollowings.ts +1 -1
  277. package/src/userRepository/relationship/follow/observers/observeFollowInfo.ts +1 -1
  278. package/src/userRepository/relationship/follow/observers/observeFollowers.ts +2 -2
  279. package/src/userRepository/relationship/follow/observers/observeFollowings.ts +2 -2
  280. package/src/utils/linkedObject/categoryLinkedObject.ts +40 -0
  281. package/src/utils/linkedObject/index.ts +4 -0
  282. package/src/utils/linkedObject/userLinkedObject.ts +36 -0
  283. package/src/utils/tests/client.ts +1 -0
  284. package/src/utils/tests/dummy/block.ts +3 -3
  285. package/src/utils/tests/dummy/category.ts +5 -0
  286. package/src/utils/tests/dummy/channel.ts +58 -1
  287. package/src/utils/tests/dummy/community.ts +1 -1
  288. package/src/utils/tests/dummy/follow.ts +1 -1
  289. package/src/utils/tests/dummy/user.ts +3 -1
  290. package/tsconfig.json +18 -23
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
8
8
  * })
9
9
  * ```
10
10
  *
11
- * Fired when a flag has been removed from a {@link Amity.User}
11
+ * Fired when a flag has been removed from a {@link Amity.InternalUser}
12
12
  *
13
13
  * @param callback The function to call when the event was fired
14
14
  * @returns an {@link Amity.Unsubscriber} function to stop listening
15
15
  *
16
16
  * @category User Events
17
17
  */
18
- export const onUserUnflagged = (callback: Amity.Listener<Amity.User>) =>
18
+ export const onUserUnflagged = (callback: Amity.Listener<Amity.InternalUser>) =>
19
19
  createUserEventSubscriber('user.unflagged', callback);
@@ -8,12 +8,12 @@ import { createUserEventSubscriber } from './utils';
8
8
  * })
9
9
  * ```
10
10
  *
11
- * Fired when a {@link Amity.User} has been updated
11
+ * Fired when a {@link Amity.InternalUser} has been updated
12
12
  *
13
13
  * @param callback The function to call when the event was fired
14
14
  * @returns an {@link Amity.Unsubscriber} function to stop listening
15
15
  *
16
16
  * @category User Events
17
17
  */
18
- export const onUserUpdated = (callback: Amity.Listener<Amity.User>) =>
18
+ export const onUserUpdated = (callback: Amity.Listener<Amity.InternalUser>) =>
19
19
  createUserEventSubscriber('user.updated', callback);
@@ -5,7 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
5
5
 
6
6
  export const createUserEventSubscriber = (
7
7
  event: keyof Amity.MqttUserEvents,
8
- callback: Amity.Listener<Amity.User>,
8
+ callback: Amity.Listener<Amity.InternalUser>,
9
9
  ) => {
10
10
  const client = getActiveClient();
11
11
 
@@ -10,6 +10,7 @@ import { createQuery, queryOptions, runQuery, toToken } from '~/core/query';
10
10
  import { CACHE_SHORTEN_LIFESPAN } from '~/cache/utils';
11
11
  import { getResolver } from '~/core/model';
12
12
  import { queryBlockedUsers } from '../api/queryBlockedUsers';
13
+ import { LinkedObject } from '~/utils/linkedObject';
13
14
 
14
15
  /* begin_public_function
15
16
  id: user.get_blocked_users
@@ -20,10 +21,10 @@ import { queryBlockedUsers } from '../api/queryBlockedUsers';
20
21
  * const unblockedUser = await UserRepository.blockUser('userId')
21
22
  * ```
22
23
  *
23
- * Blocks a {@link Amity.User}
24
+ * Blocks a {@link Amity.InternalUser}
24
25
  *
25
- * @param params The params to get blocked {@link Amity.User}s
26
- * @param callback to recieve updates on unblocked {@link Amity.User}s
26
+ * @param params The params to get blocked {@link Amity.InternalUser}s
27
+ * @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
27
28
  * @returns {@link Amity.Unsubscriber} to unsubscribe from collection
28
29
  *
29
30
  * @category Post API
@@ -31,7 +32,7 @@ import { queryBlockedUsers } from '../api/queryBlockedUsers';
31
32
  */
32
33
  export const getBlockedUsers = (
33
34
  params: Amity.BlockedUsersLiveCollection,
34
- callback: Amity.LiveCollectionCallback<Amity.User>,
35
+ callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
35
36
  config?: Amity.LiveCollectionConfig,
36
37
  ): Amity.Unsubscriber => {
37
38
  const { log, cache } = getActiveClient();
@@ -52,11 +53,11 @@ export const getBlockedUsers = (
52
53
  const cacheKey = ['blockedUsers', 'collection', {}];
53
54
 
54
55
  const responder = (data: Amity.BlockedUserLiveCollectionCache) => {
55
- const users: Amity.User[] =
56
+ const users: Amity.InternalUser[] =
56
57
  data.data
57
- .map(userId => pullFromCache<Amity.User>(['user', 'get', userId])!)
58
+ .map(userId => pullFromCache<Amity.InternalUser>(['user', 'get', userId])!)
58
59
  .filter(Boolean)
59
- .map(({ data }) => data) ?? [];
60
+ .map(({ data }) => LinkedObject.user(data)) ?? [];
60
61
 
61
62
  callback({
62
63
  onNextPage: onFetch,
@@ -23,7 +23,7 @@ import { getUser as _getUser } from '../api/getUser';
23
23
  * });
24
24
  * ```
25
25
  *
26
- * Observe all mutation on a given {@link Amity.User}
26
+ * Observe all mutation on a given {@link Amity.InternalUser}
27
27
  *
28
28
  * @param userId the ID of the user to observe
29
29
  * @param callback the function to call when new data are available
@@ -32,8 +32,8 @@ import { getUser as _getUser } from '../api/getUser';
32
32
  * @category Message Live Object
33
33
  */
34
34
  export const getUser = (
35
- userId: Amity.User['userId'],
36
- callback: Amity.LiveObjectCallback<Amity.User>,
35
+ userId: Amity.InternalUser['userId'],
36
+ callback: Amity.LiveObjectCallback<Amity.InternalUser>,
37
37
  ): Amity.Unsubscriber => {
38
38
  return liveObject(userId, callback, 'userId', _getUser, [
39
39
  onUserFetched,
@@ -28,6 +28,7 @@ import {
28
28
  onUserUnflagged,
29
29
  onUserUpdated,
30
30
  } from '../events';
31
+ import { LinkedObject } from '~/utils/linkedObject';
31
32
 
32
33
  /*
33
34
  * Exported for testing
@@ -106,7 +107,7 @@ export const getUsers = (
106
107
  data.data
107
108
  .map(userId => pullFromCache<Amity.User>(['user', 'get', userId])!)
108
109
  .filter(Boolean)
109
- .map(({ data }) => data) ?? [];
110
+ .map(({ data }) => LinkedObject.user(data)) ?? [];
110
111
 
111
112
  callback({
112
113
  onNextPage: onFetch,
@@ -125,7 +126,6 @@ export const getUsers = (
125
126
  if (!collection) return;
126
127
 
127
128
  collection.data = [...new Set([user.userId, ...collection.data])];
128
-
129
129
  pushToCache(cacheKey, collection);
130
130
  responder(collection, true);
131
131
  };
@@ -10,6 +10,7 @@ import {
10
10
  onUserUnflagged,
11
11
  onUserFlagCleared,
12
12
  } from '../events';
13
+ import { LinkedObject } from '~/utils/linkedObject';
13
14
 
14
15
  /**
15
16
  * ```js
@@ -23,14 +24,14 @@ import {
23
24
  * @param callback the function to call when new data are available
24
25
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the user
25
26
  *
26
- * Observe all mutation on a given {@link Amity.User}
27
+ * Observe all mutation on a given {@link Amity.InternalUser}
27
28
  * @category User Observer
28
29
  */
29
30
  export const observeUser = <
30
31
  Events extends ['onFetch', 'onUpdate', 'onDelete', 'onFlagged', 'onUnflagged', 'onFlagCleared'],
31
32
  >(
32
33
  userId: string,
33
- callback: Amity.ObjectListener<Amity.Snapshot<Amity.User>, Events>,
34
+ callback: Amity.ObjectListener<Amity.Snapshot<Amity.InternalUser>, Events>,
34
35
  ): Amity.Unsubscriber => {
35
36
  const { log } = getActiveClient();
36
37
 
@@ -38,15 +39,17 @@ export const observeUser = <
38
39
  log(`observeUser(tmpid: ${timestamp}) > listen`);
39
40
 
40
41
  // wrapper function to make sure
41
- const router = (result: Amity.Snapshot<Amity.User>, action: Events[number]) => {
42
+ const router = (result: Amity.Snapshot<Amity.InternalUser>, action: Events[number]) => {
42
43
  // filter function
43
44
  if (result.data?.userId !== userId) return;
44
45
 
45
- if (callback instanceof Function) return callback(result);
46
+ const newResult = { ...result, data: LinkedObject.user(result.data) };
46
47
 
47
- if (action !== 'onFetch') callback.onEvent?.(action, result);
48
+ if (callback instanceof Function) return callback(newResult);
48
49
 
49
- callback[action]?.(result);
50
+ if (action !== 'onFetch') callback.onEvent?.(action, newResult);
51
+
52
+ callback[action]?.(newResult);
50
53
  };
51
54
 
52
55
  const disposers: Amity.Unsubscriber[] = [];
@@ -11,7 +11,7 @@ import { getUsers } from './getUsers';
11
11
  * const unsub = UserRepository.searchUserByDisplayName({}, response => merge(users, response.data))
12
12
  * ```
13
13
  *
14
- * Observe all mutations on a list of {@link Amity.User}s
14
+ * Observe all mutations on a list of {@link Amity.InternalUser}s
15
15
  *
16
16
  * @param params for searching users
17
17
  * @param callback the function to call when new data are available
@@ -22,7 +22,7 @@ import { getUsers } from './getUsers';
22
22
  */
23
23
  export const searchUserByDisplayName = (
24
24
  params: Amity.UserSearchLiveCollection,
25
- callback: Amity.LiveCollectionCallback<Amity.User>,
25
+ callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
26
26
  config?: Amity.LiveCollectionConfig,
27
27
  ) => {
28
28
  return getUsers({ ...params, filter: 'all' }, callback, config);
@@ -14,7 +14,7 @@ const getSnapshot = () => {
14
14
  return {
15
15
  loading: true,
16
16
  error: undefined as any,
17
- data: undefined as undefined | Amity.User,
17
+ data: undefined as undefined | Amity.InternalUser,
18
18
  };
19
19
  };
20
20
 
@@ -18,7 +18,7 @@ const { getUsers, applyFilter } = getUsersModule;
18
18
 
19
19
  const getSnapshot = (params?: Record<string, any>) => {
20
20
  return {
21
- data: [] as Amity.User[],
21
+ data: [] as Amity.InternalUser[],
22
22
  loading: true,
23
23
  error: undefined as any,
24
24
  ...params,
@@ -127,7 +127,7 @@ describe('getUsers', () => {
127
127
  const unflaggedUser = { ...user11, flagCount: 1 };
128
128
  const flagClearedUser = { ...user11, flagCount: 0 };
129
129
 
130
- const cases: [string, keyof Amity.Events, Amity.UserPayload, Amity.User[]][] = [
130
+ const cases: [string, keyof Amity.Events, Amity.UserPayload, Amity.InternalUser[]][] = [
131
131
  [
132
132
  'it should update user in collection onUpdate',
133
133
  'user.updated',
@@ -198,20 +198,21 @@ describe('getUsers > applyFilter', () => {
198
198
  userId: 'test',
199
199
  displayName: 'a',
200
200
  createdAt: new Date().toISOString(),
201
- } as Amity.User;
201
+ } as Amity.InternalUser;
202
202
 
203
203
  const u2 = {
204
204
  userId: 'searchable',
205
205
  displayName: 'b',
206
206
  createdAt: getPastDate(),
207
- } as Amity.User;
208
-
209
- const filters: [string, Amity.UserLiveCollection, Amity.User[], Amity.User[]][] = [
210
- ['it should filter by display name', { displayName: 'a' }, [u1, u2], [u1]],
211
- ['it should sort by dispaly name', {}, [u1, u2], [u1, u2]],
212
- ['it should sort by last created', { sortBy: 'lastCreated' }, [u1, u2], [u1, u2]],
213
- ['it should sort by first created', { sortBy: 'firstCreated' }, [u1, u2], [u2, u1]],
214
- ];
207
+ } as Amity.InternalUser;
208
+
209
+ const filters: [string, Amity.UserLiveCollection, Amity.InternalUser[], Amity.InternalUser[]][] =
210
+ [
211
+ ['it should filter by display name', { displayName: 'a' }, [u1, u2], [u1]],
212
+ ['it should sort by dispaly name', {}, [u1, u2], [u1, u2]],
213
+ ['it should sort by last created', { sortBy: 'lastCreated' }, [u1, u2], [u1, u2]],
214
+ ['it should sort by first created', { sortBy: 'firstCreated' }, [u1, u2], [u2, u1]],
215
+ ];
215
216
 
216
217
  test.each(filters)('%s', (test, param, input, expected) => {
217
218
  expect(applyFilter(input, param)).toStrictEqual(expected);
@@ -13,7 +13,7 @@ import { searchUserByDisplayName } from '../searchUserByDisplayName';
13
13
 
14
14
  const getSnapshot = (params?: Record<string, any>) => {
15
15
  return {
16
- data: [] as Amity.User[],
16
+ data: [] as Amity.InternalUser[],
17
17
  loading: true,
18
18
  error: undefined as any,
19
19
  ...params,
@@ -12,15 +12,17 @@ import { upsertInCache } from '~/cache/api';
12
12
  * const blockedUser = await UserRepository.blockUser('userId')
13
13
  * ```
14
14
  *
15
- * Blocks a {@link Amity.User}
15
+ * Blocks a {@link Amity.InternalUser}
16
16
  *
17
- * @param userId The ID of the {@link Amity.User} to block
18
- * @returns the blocked {@link Amity.User} object
17
+ * @param userId The ID of the {@link Amity.InternalUser} to block
18
+ * @returns the blocked {@link Amity.InternalUser} object
19
19
  *
20
20
  * @category Post API
21
21
  * @async
22
22
  */
23
- export const blockUser = async (userId: Amity.User['userId']): Promise<Amity.BlockedPayload> => {
23
+ export const blockUser = async (
24
+ userId: Amity.InternalUser['userId'],
25
+ ): Promise<Amity.BlockedPayload> => {
24
26
  const client = getActiveClient();
25
27
 
26
28
  client.log('user/blockUser', userId);
@@ -12,15 +12,17 @@ import { upsertInCache } from '~/cache/api';
12
12
  * const unblockedUser = await UserRepository.blockUser('userId')
13
13
  * ```
14
14
  *
15
- * Blocks a {@link Amity.User}
15
+ * Blocks a {@link Amity.InternalUser}
16
16
  *
17
- * @param userId The ID of the {@link Amity.User} to unblock
18
- * @returns the unblocked {@link Amity.User} object
17
+ * @param userId The ID of the {@link Amity.InternalUser} to unblock
18
+ * @returns the unblocked {@link Amity.InternalUser} object
19
19
  *
20
20
  * @category Post API
21
21
  * @async
22
22
  */
23
- export const unBlockUser = async (userId: Amity.User['userId']): Promise<Amity.BlockedPayload> => {
23
+ export const unBlockUser = async (
24
+ userId: Amity.InternalUser['userId'],
25
+ ): Promise<Amity.BlockedPayload> => {
24
26
  const client = getActiveClient();
25
27
 
26
28
  client.log('user/unBlockUser', userId);
@@ -3,7 +3,7 @@ import { getBlockedUsers as _getBlockedUsers } from '../../../observers/getBlock
3
3
 
4
4
  export const getBlockedUsers = (
5
5
  params: Amity.BlockedUsersLiveCollection,
6
- callback: Amity.LiveCollectionCallback<Amity.User>,
6
+ callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
7
7
  config?: Amity.LiveCollectionConfig,
8
8
  ) => {
9
9
  console.log(
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
13
13
  *
14
14
  * Accept the follow request
15
15
  *
16
- * @param userId the ID of the {@link Amity.User} follower
16
+ * @param userId the ID of the {@link Amity.InternalUser} follower
17
17
  * @returns A success boolean if the follow request was accepted
18
18
  *
19
19
  * @category Follow API
20
20
  * @async
21
21
  */
22
- export const acceptFollower = async (userId: Amity.User['userId']): Promise<boolean> => {
22
+ export const acceptFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
23
23
  const client = getActiveClient();
24
24
  client.log('follow/acceptFollower', userId);
25
25
 
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
13
13
  *
14
14
  * Accept the follow request
15
15
  *
16
- * @param userId the ID of the {@link Amity.User} follower
16
+ * @param userId the ID of the {@link Amity.InternalUser} follower
17
17
  * @returns A success boolean if the follow request was accepted
18
18
  *
19
19
  * @category Follow API
20
20
  * @async
21
21
  */
22
- export const acceptMyFollower = async (userId: Amity.User['userId']): Promise<boolean> => {
22
+ export const acceptMyFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
23
23
  const client = getActiveClient();
24
24
  client.log('follow/acceptMyFollower', userId);
25
25
 
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
13
13
  *
14
14
  * Decline the follow request or delete the follower
15
15
  *
16
- * @param userId the ID of the {@link Amity.User} follower
16
+ * @param userId the ID of the {@link Amity.InternalUser} follower
17
17
  * @returns A success boolean if the follow request was decline
18
18
  *
19
19
  * @category Follow API
20
20
  * @async
21
21
  */
22
- export const declineFollower = async (userId: Amity.User['userId']): Promise<boolean> => {
22
+ export const declineFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
23
23
  const client = getActiveClient();
24
24
  client.log('follow/declineFollower', userId);
25
25
 
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
13
13
  *
14
14
  * Decline the follow request or delete the follower
15
15
  *
16
- * @param userId the ID of the {@link Amity.User} follower
16
+ * @param userId the ID of the {@link Amity.InternalUser} follower
17
17
  * @returns A success boolean if the follow request was decline
18
18
  *
19
19
  * @category Follow API
20
20
  * @async
21
21
  */
22
- export const declineMyFollower = async (userId: Amity.User['userId']): Promise<boolean> => {
22
+ export const declineMyFollower = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
23
23
  const client = getActiveClient();
24
24
  client.log('follow/declineMyFollower', userId);
25
25
 
@@ -13,14 +13,14 @@ import { fireEvent } from '~/core/events';
13
13
  *
14
14
  * Follow the user
15
15
  *
16
- * @param userId the ID of the {@link Amity.User}
16
+ * @param userId the ID of the {@link Amity.InternalUser}
17
17
  * @returns the status {@link Amity.FollowStatus}
18
18
  *
19
19
  * @category Follow API
20
20
  * @async
21
21
  */
22
22
  export const follow = async (
23
- userId: Amity.User['userId'],
23
+ userId: Amity.InternalUser['userId'],
24
24
  ): Promise<Amity.Cached<Amity.FollowStatus>> => {
25
25
  const client = getActiveClient();
26
26
  client.log('follow/follow', userId);
@@ -9,14 +9,14 @@ import { pullFromCache, pushToCache } from '~/cache/api';
9
9
  *
10
10
  * Fetches the number of followers, followings, pending requests and the follow status for current user
11
11
  *
12
- * @param userId the ID of the {@link Amity.User}
12
+ * @param userId the ID of the {@link Amity.InternalUser}
13
13
  * @returns the associated {@link Amity.FollowInfo} object
14
14
  *
15
15
  * @category Follow API
16
16
  * @async
17
17
  */
18
18
  export const getFollowInfo = async (
19
- userId: Amity.User['userId'],
19
+ userId: Amity.InternalUser['userId'],
20
20
  ): Promise<Amity.Cached<Amity.FollowInfo>> => {
21
21
  const client = getActiveClient();
22
22
  client.log('follow/getFollowInfo', userId);
@@ -54,13 +54,13 @@ export const getFollowInfo = async (
54
54
  *
55
55
  * Fetches the number of followers, followings, pending requests and the follow status for current user from cache
56
56
  *
57
- * @param userId the ID of the {@link Amity.User}
57
+ * @param userId the ID of the {@link Amity.InternalUser}
58
58
  * @returns the associated {@link Amity.FollowInfo} object
59
59
  *
60
60
  * @category Follow API
61
61
  */
62
62
  getFollowInfo.locally = (
63
- userId: Amity.User['userId'],
63
+ userId: Amity.InternalUser['userId'],
64
64
  ): Amity.Cached<Amity.FollowInfo> | undefined => {
65
65
  const client = getActiveClient();
66
66
  client.log('follow/getFollowInfo.locally', userId);
@@ -13,13 +13,13 @@ import { fireEvent } from '~/core/events';
13
13
  *
14
14
  * Cancel the follow request or unfollow the user
15
15
  *
16
- * @param userId the ID of the {@link Amity.User}
17
- * @returns A success boolean if the user {@link Amity.User} was unfollowed
16
+ * @param userId the ID of the {@link Amity.InternalUser}
17
+ * @returns A success boolean if the user {@link Amity.InternalUser} was unfollowed
18
18
  *
19
19
  * @category Follow API
20
20
  * @async
21
21
  */
22
- export const unfollow = async (userId: Amity.User['userId']): Promise<boolean> => {
22
+ export const unfollow = async (userId: Amity.InternalUser['userId']): Promise<boolean> => {
23
23
  const client = getActiveClient();
24
24
  client.log('follow/unfollow', userId);
25
25
 
@@ -7,7 +7,7 @@ import { getResolver } from '~/core/model';
7
7
  export const queryFollows = async (
8
8
  key: 'followers' | 'following',
9
9
  query: {
10
- userId: Amity.User['userId'];
10
+ userId: Amity.InternalUser['userId'];
11
11
  status?: Exclude<Amity.FollowStatusType, 'none'>;
12
12
  page?: Amity.PageRaw;
13
13
  },
@@ -29,7 +29,7 @@ import { queryFollowers } from '../api/queryFollowers';
29
29
  *
30
30
  * let followers = []
31
31
  * const unsub = getFollowers({
32
- * userId: Amity.User['userId'];
32
+ * userId: Amity.InternalUser['userId'];
33
33
  * }, response => merge(followers, response.data))
34
34
  * ```
35
35
  *
@@ -29,7 +29,7 @@ import { queryFollowings } from '../api/queryFollowings';
29
29
  *
30
30
  * let followings = []
31
31
  * const unsub = getFollowings({
32
- * userId: Amity.User['userId'];
32
+ * userId: Amity.InternalUser['userId'];
33
33
  * }, response => merge(followings, response.data))
34
34
  * ```
35
35
  *
@@ -20,7 +20,7 @@ import { onFollowInfoUpdated } from '../events';
20
20
  * @category Follow Observer
21
21
  */
22
22
  export const observeFollowInfo = <Events extends ['onFetch', 'onUpdate']>(
23
- userId: Amity.User['userId'],
23
+ userId: Amity.InternalUser['userId'],
24
24
  callback: Amity.ObjectListener<Amity.Snapshot<Amity.FollowInfo>, Events>,
25
25
  policy: Amity.QueryPolicy = 'cache_then_server',
26
26
  ): Amity.Unsubscriber => {
@@ -20,7 +20,7 @@ import {
20
20
  *
21
21
  * Observe all mutations on a list of followers {@link Amity.FollowStatus} for a given user
22
22
  *
23
- * @param userId the ID of the {@link Amity.User}
23
+ * @param userId the ID of the {@link Amity.InternalUser}
24
24
  * @param callback the function to call when new data are available
25
25
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
26
26
  *
@@ -37,7 +37,7 @@ export const observeFollowers = <
37
37
  'onDeleted',
38
38
  ],
39
39
  >(
40
- userId: Amity.User['userId'],
40
+ userId: Amity.InternalUser['userId'],
41
41
  callback: Amity.ObjectListener<Amity.FollowStatus, Events>,
42
42
  ): Amity.Unsubscriber => {
43
43
  const { log } = getActiveClient();
@@ -20,7 +20,7 @@ import {
20
20
  *
21
21
  * Observe all mutations on a list of followings {@link Amity.FollowStatus} for a given user
22
22
  *
23
- * @param userId the ID of the {@link Amity.User}
23
+ * @param userId the ID of the {@link Amity.InternalUser}
24
24
  * @param callback the function to call when new data are available
25
25
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the messages
26
26
  *
@@ -37,7 +37,7 @@ export const observeFollowings = <
37
37
  'onDeleted',
38
38
  ],
39
39
  >(
40
- userId: Amity.User['userId'],
40
+ userId: Amity.InternalUser['userId'],
41
41
  callback: Amity.ObjectListener<Amity.FollowStatus, Events>,
42
42
  ): Amity.Unsubscriber => {
43
43
  const { log } = getActiveClient();
@@ -0,0 +1,40 @@
1
+ import { pullFromCache } from '~/cache/api';
2
+
3
+ export const categoryLinkedObject = (category: Amity.InternalCategory): Amity.Category => {
4
+ return {
5
+ ...category,
6
+ get avatar(): Amity.File<'image'> | null {
7
+ if (!category.avatarFileId) return null;
8
+ let avatar: Amity.File<'image'> = {
9
+ fileId: category.avatarFileId?.toString() ? category.avatarFileId.toString() : '',
10
+ type: 'image',
11
+ fileUrl: '',
12
+ createdAt: '',
13
+ attributes: {
14
+ name: '',
15
+ extension: '',
16
+ size: '',
17
+ mimeType: '',
18
+ metadata: {
19
+ exif: {},
20
+ gps: {},
21
+ width: 0,
22
+ height: 0,
23
+ isFull: false,
24
+ },
25
+ },
26
+ };
27
+ const cacheData = pullFromCache<Amity.File<'image'>>([
28
+ 'file',
29
+ 'get',
30
+ `${category.avatarFileId}`,
31
+ ]);
32
+
33
+ if (cacheData?.data) {
34
+ avatar = cacheData?.data;
35
+ }
36
+
37
+ return avatar as Amity.File<'image'>;
38
+ },
39
+ };
40
+ };
@@ -1,5 +1,9 @@
1
+ import { categoryLinkedObject } from './categoryLinkedObject';
1
2
  import { commentLinkedObject } from './commentLinkedObject';
3
+ import { userLinkedObject } from './userLinkedObject';
2
4
 
3
5
  export const LinkedObject = {
4
6
  comment: commentLinkedObject,
7
+ user: userLinkedObject,
8
+ category: categoryLinkedObject,
5
9
  };
@@ -0,0 +1,36 @@
1
+ import { pullFromCache } from '~/cache/api/pullFromCache';
2
+
3
+ export const userLinkedObject = (user: Amity.InternalUser): Amity.InternalUser => {
4
+ return {
5
+ ...user,
6
+ get avatar(): Amity.File<'image'> | null {
7
+ if (!user.avatarFileId) return null;
8
+ let avatar: Amity.File<'image'> = {
9
+ fileId: user.avatarFileId?.toString() ? user.avatarFileId.toString() : '',
10
+ type: 'image',
11
+ fileUrl: '',
12
+ createdAt: '',
13
+ attributes: {
14
+ name: '',
15
+ extension: '',
16
+ size: '',
17
+ mimeType: '',
18
+ metadata: {
19
+ exif: {},
20
+ gps: {},
21
+ width: 0,
22
+ height: 0,
23
+ isFull: false,
24
+ },
25
+ },
26
+ };
27
+ const cacheData = pullFromCache<Amity.File<'image'>>(['file', 'get', `${user.avatarFileId}`]);
28
+
29
+ if (cacheData?.data) {
30
+ avatar = cacheData?.data;
31
+ }
32
+
33
+ return avatar as Amity.File<'image'>;
34
+ },
35
+ };
36
+ };
@@ -43,6 +43,7 @@ export const connectClient = async () => {
43
43
  },
44
44
  });
45
45
 
46
+ // test will fail randomly if we have this
46
47
  setTimeout(() => {
47
48
  client.ws.io.emit('connect');
48
49
  // fixes jest warning of open handles