@amityco/ts-sdk 7.4.1-9b7bc08.0 → 7.4.1-9fe8bb83.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 (207) hide show
  1. package/dist/@types/core/events.d.ts +3 -0
  2. package/dist/@types/core/events.d.ts.map +1 -1
  3. package/dist/@types/core/model.d.ts +3 -1
  4. package/dist/@types/core/model.d.ts.map +1 -1
  5. package/dist/@types/core/payload.d.ts +11 -4
  6. package/dist/@types/core/payload.d.ts.map +1 -1
  7. package/dist/@types/domains/client.d.ts +10 -0
  8. package/dist/@types/domains/client.d.ts.map +1 -1
  9. package/dist/@types/domains/community.d.ts +8 -1
  10. package/dist/@types/domains/community.d.ts.map +1 -1
  11. package/dist/@types/domains/invitation.d.ts +72 -0
  12. package/dist/@types/domains/invitation.d.ts.map +1 -0
  13. package/dist/@types/index.d.ts +2 -0
  14. package/dist/@types/index.d.ts.map +1 -1
  15. package/dist/communityRepository/api/createCommunity.d.ts +2 -2
  16. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  17. package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
  18. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  19. package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
  20. package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
  21. package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
  22. package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
  23. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  24. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
  25. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
  26. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
  27. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
  28. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
  29. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
  30. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
  31. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
  32. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
  33. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
  34. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
  35. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
  36. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
  37. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
  38. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
  39. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
  40. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
  41. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
  42. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
  43. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
  44. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
  45. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
  46. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
  47. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
  48. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
  49. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
  50. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
  51. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
  52. package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
  53. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  54. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
  55. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
  56. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
  57. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
  58. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
  59. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
  60. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
  61. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
  62. package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
  63. package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
  64. package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
  65. package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
  66. package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
  67. package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
  68. package/dist/communityRepository/events/utils.d.ts +1 -1
  69. package/dist/communityRepository/events/utils.d.ts.map +1 -1
  70. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
  71. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
  72. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
  73. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
  74. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
  75. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
  76. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
  77. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
  78. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
  79. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
  80. package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
  81. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  82. package/dist/communityRepository/utils/payload.d.ts +1 -1
  83. package/dist/communityRepository/utils/payload.d.ts.map +1 -1
  84. package/dist/core/events.d.ts +3 -3
  85. package/dist/core/events.d.ts.map +1 -1
  86. package/dist/core/model/idResolvers.d.ts.map +1 -1
  87. package/dist/core/model/index.d.ts.map +1 -1
  88. package/dist/index.cjs.js +2939 -2421
  89. package/dist/index.d.ts +1 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.esm.js +2322 -1805
  92. package/dist/index.umd.js +4 -4
  93. package/dist/invitationRepository/events/index.d.ts +4 -0
  94. package/dist/invitationRepository/events/index.d.ts.map +1 -0
  95. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
  96. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
  97. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
  98. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
  99. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
  100. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
  101. package/dist/invitationRepository/index.d.ts +2 -0
  102. package/dist/invitationRepository/index.d.ts.map +1 -0
  103. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
  104. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
  105. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +16 -0
  106. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +1 -0
  107. package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
  108. package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
  109. package/dist/invitationRepository/internalApi/index.d.ts +5 -0
  110. package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
  111. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
  112. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
  113. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +14 -0
  114. package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +1 -0
  115. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +5 -0
  116. package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +1 -0
  117. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +15 -0
  118. package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +1 -0
  119. package/dist/invitationRepository/observers/getInvitations/enums.d.ts +6 -0
  120. package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +1 -0
  121. package/dist/invitationRepository/observers/getInvitations.d.ts +12 -0
  122. package/dist/invitationRepository/observers/getInvitations.d.ts.map +1 -0
  123. package/dist/invitationRepository/utils/index.d.ts +2 -0
  124. package/dist/invitationRepository/utils/index.d.ts.map +1 -0
  125. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +2 -0
  126. package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +1 -0
  127. package/dist/messageRepository/api/flagMessage.d.ts +3 -2
  128. package/dist/messageRepository/api/flagMessage.d.ts.map +1 -1
  129. package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
  130. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
  131. package/dist/utils/linkedObject/index.d.ts +2 -0
  132. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  133. package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
  134. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
  135. package/dist/utils/tests/dummy/post.d.ts +3 -3
  136. package/package.json +1 -1
  137. package/src/@types/core/events.ts +4 -0
  138. package/src/@types/core/model.ts +5 -1
  139. package/src/@types/core/payload.ts +13 -4
  140. package/src/@types/domains/client.ts +12 -0
  141. package/src/@types/domains/community.ts +16 -1
  142. package/src/@types/domains/invitation.ts +92 -0
  143. package/src/@types/index.ts +2 -0
  144. package/src/communityRepository/api/createCommunity.ts +5 -2
  145. package/src/communityRepository/api/getCommunities.ts +2 -1
  146. package/src/communityRepository/api/getCommunity.ts +4 -1
  147. package/src/communityRepository/api/getRecommendedCommunities.ts +2 -1
  148. package/src/communityRepository/api/getTrendingCommunities.ts +2 -1
  149. package/src/communityRepository/api/queryCommunities.ts +6 -1
  150. package/src/communityRepository/api/updateCommunity.ts +13 -3
  151. package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
  152. package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
  153. package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
  154. package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
  155. package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
  156. package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
  157. package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
  158. package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
  159. package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
  160. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
  161. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
  162. package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
  163. package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
  164. package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
  165. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  166. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
  167. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
  168. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
  169. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
  170. package/src/communityRepository/events/onCommunityCreated.ts +1 -1
  171. package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
  172. package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
  173. package/src/communityRepository/events/utils.ts +1 -1
  174. package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
  175. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
  176. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
  177. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
  178. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
  179. package/src/communityRepository/utils/communityWithMembership.ts +8 -4
  180. package/src/communityRepository/utils/payload.ts +1 -1
  181. package/src/core/liveCollection/PaginationController.ts +1 -1
  182. package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
  183. package/src/core/model/idResolvers.ts +2 -0
  184. package/src/core/model/index.ts +2 -0
  185. package/src/index.ts +2 -0
  186. package/src/invitationRepository/events/index.ts +3 -0
  187. package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
  188. package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
  189. package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
  190. package/src/invitationRepository/index.ts +1 -0
  191. package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
  192. package/src/invitationRepository/internalApi/cancelInvitation.ts +44 -0
  193. package/src/invitationRepository/internalApi/createInvitations.ts +52 -0
  194. package/src/invitationRepository/internalApi/index.ts +4 -0
  195. package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
  196. package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +148 -0
  197. package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +19 -0
  198. package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +97 -0
  199. package/src/invitationRepository/observers/getInvitations/enums.ts +5 -0
  200. package/src/invitationRepository/observers/getInvitations.ts +44 -0
  201. package/src/invitationRepository/utils/index.ts +1 -0
  202. package/src/invitationRepository/utils/prepareInvitationPayload.ts +11 -0
  203. package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
  204. package/src/messageRepository/api/flagMessage.ts +19 -2
  205. package/src/utils/linkedObject/communityLinkedObject.ts +29 -0
  206. package/src/utils/linkedObject/index.ts +4 -0
  207. package/src/utils/linkedObject/invitationLinkedObject.ts +44 -0
@@ -38,3 +38,5 @@ export * from './domains/post';
38
38
  export * from './domains/story';
39
39
  export * from './domains/ad';
40
40
  export * from './domains/notification';
41
+ export * from './domains/client';
42
+ export * from './domains/invitation';
@@ -1,3 +1,4 @@
1
+ import { LinkedObject } from '~/utils/linkedObject';
1
2
  import { getActiveClient } from '~/client/api';
2
3
 
3
4
  import { ingestInCache } from '~/cache/api/ingestInCache';
@@ -11,7 +12,7 @@ import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
11
12
  /**
12
13
  * ```js
13
14
  * import { createCommunity } from '@amityco/ts-sdk'
14
- * const created = await createCommunity({ communityId: 'foobar', displayName: 'foobar' })
15
+ * const created = await createCommunity({ communityId: 'foobar', displayName: 'foobar', isDiscoverable: true, requiresJoinApproval: false })
15
16
  * ```
16
17
  *
17
18
  * Creates an {@link Amity.Community}
@@ -33,6 +34,8 @@ export const createCommunity = async (
33
34
  | 'postSetting'
34
35
  | 'tags'
35
36
  | 'metadata'
37
+ | 'isDiscoverable'
38
+ | 'requiresJoinApproval'
36
39
  > &
37
40
  Amity.CommunityStorySettings & {
38
41
  userIds?: string[];
@@ -60,7 +63,7 @@ export const createCommunity = async (
60
63
 
61
64
  const { communities } = data;
62
65
  return {
63
- data: communities[0],
66
+ data: LinkedObject.community(communities[0]),
64
67
  cachedAt,
65
68
  };
66
69
  };
@@ -5,6 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
5
5
 
6
6
  import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
7
7
  import { prepareCommunityPayload } from '../utils';
8
+ import { LinkedObject } from '~/utils/linkedObject';
8
9
 
9
10
  /**
10
11
  * ```js
@@ -43,7 +44,7 @@ export const getCommunities = async (
43
44
  }
44
45
 
45
46
  return {
46
- data: data.communities,
47
+ data: data.communities.map(community => LinkedObject.community(community)),
47
48
  cachedAt,
48
49
  };
49
50
  };
@@ -5,6 +5,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
5
5
 
6
6
  import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
7
7
  import { prepareCommunityPayload } from '../utils';
8
+ import { LinkedObject } from '~/utils/linkedObject';
8
9
 
9
10
  /**
10
11
  * ```js
@@ -42,7 +43,9 @@ export const getCommunity = async (
42
43
  const { communities } = data;
43
44
 
44
45
  return {
45
- data: communities.find(community => community.communityId === communityId)!,
46
+ data: LinkedObject.community(
47
+ communities.find(community => community.communityId === communityId)!,
48
+ ),
46
49
  cachedAt,
47
50
  };
48
51
  };
@@ -4,6 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
 
5
5
  import { prepareCommunityPayload } from '../utils';
6
6
  import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
7
+ import { LinkedObject } from '~/utils/linkedObject';
7
8
 
8
9
  /* begin_public_function
9
10
  id: community.query.recommended_communities
@@ -47,5 +48,5 @@ export const getRecommendedCommunities = async (
47
48
  ingestInCache(data, { cachedAt });
48
49
  }
49
50
 
50
- return { data: communities, cachedAt };
51
+ return { data: communities.map(community => LinkedObject.community(community)), cachedAt };
51
52
  };
@@ -4,6 +4,7 @@ import { ingestInCache } from '~/cache/api/ingestInCache';
4
4
 
5
5
  import { prepareCommunityPayload } from '../utils';
6
6
  import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
7
+ import { LinkedObject } from '~/utils/linkedObject';
7
8
 
8
9
  /**
9
10
  * ```js
@@ -44,5 +45,5 @@ export const getTrendingCommunities = async (
44
45
  ingestInCache(data, { cachedAt });
45
46
  }
46
47
 
47
- return { data: communities, cachedAt };
48
+ return { data: communities.map(community => LinkedObject.community(community)), cachedAt };
48
49
  };
@@ -6,6 +6,7 @@ import { getResolver } from '~/core/model';
6
6
  import { inferIsDeleted } from '~/utils/inferIsDeleted';
7
7
  import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
8
8
  import { prepareCommunityPayload } from '../utils';
9
+ import { LinkedObject } from '~/utils/linkedObject';
9
10
 
10
11
  /**
11
12
  * ```js
@@ -68,5 +69,9 @@ export const queryCommunities = async (
68
69
  saveCommunityUsers(data.communities, data.communityUsers);
69
70
  }
70
71
 
71
- return { data: communities, cachedAt, paging };
72
+ return {
73
+ data: communities.map(community => LinkedObject.community(community)),
74
+ cachedAt,
75
+ paging,
76
+ };
72
77
  };
@@ -5,6 +5,7 @@ import { fireEvent } from '~/core/events';
5
5
 
6
6
  import { saveCommunityUsers } from '~/communityRepository/utils/saveCommunityUsers';
7
7
  import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
8
+ import { LinkedObject } from '~/utils/linkedObject';
8
9
 
9
10
  /* begin_public_function
10
11
  id: community.update
@@ -12,7 +13,7 @@ import { prepareCommunityPayload, prepareCommunityRequest } from '../utils';
12
13
  /**
13
14
  * ```js
14
15
  * import { updateCommunity } from '@amityco/ts-sdk'
15
- * const updated = await updateCommunity(communityId, { displayName: 'foobar' })
16
+ * const updated = await updateCommunity(communityId, { displayName: 'foobar', isDiscoverable: true, requiresJoinApproval: false })
16
17
  * ```
17
18
  *
18
19
  * Updates an {@link Amity.Community}
@@ -28,7 +29,14 @@ export const updateCommunity = async (
28
29
  communityId: Amity.Community['communityId'],
29
30
  patch: Patch<
30
31
  Amity.Community,
31
- 'displayName' | 'avatarFileId' | 'description' | 'postSetting' | 'tags' | 'metadata'
32
+ | 'displayName'
33
+ | 'avatarFileId'
34
+ | 'description'
35
+ | 'postSetting'
36
+ | 'tags'
37
+ | 'metadata'
38
+ | 'isDiscoverable'
39
+ | 'requiresJoinApproval'
32
40
  > &
33
41
  Amity.CommunityStorySettings,
34
42
  ): Promise<Amity.Cached<Amity.Community>> => {
@@ -53,7 +61,9 @@ export const updateCommunity = async (
53
61
  const { communities } = data;
54
62
 
55
63
  return {
56
- data: communities.find(community => community.communityId === communityId)!,
64
+ data: LinkedObject.community(
65
+ communities.find(community => community.communityId === communityId)!,
66
+ ),
57
67
  cachedAt,
58
68
  };
59
69
  };
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityJoined = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.joined', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityLeft = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.left', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserAdded = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.userAdded', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserBanned = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.userBanned', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserChanged = (
19
- callback: (community: Amity.Community, members: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, members: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.userChanged', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserRemoved = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.userRemoved', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserRoleAdded = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.roleAdded', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserRoleRemoved = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.roleRemoved', callback);
@@ -16,5 +16,5 @@ import { createCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onCommunityUserUnbanned = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createCommunityMemberEventSubscriber('community.userUnbanned', callback);
@@ -1,5 +1,5 @@
1
1
  import { createLocalCommunityMemberEventSubscriber } from './utils';
2
2
 
3
3
  export const onLocalCommunityJoined = (
4
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
4
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
5
5
  ) => createLocalCommunityMemberEventSubscriber('local.community.joined', callback);
@@ -1,5 +1,5 @@
1
1
  import { createLocalCommunityMemberEventSubscriber } from './utils';
2
2
 
3
3
  export const onLocalCommunityLeft = (
4
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
4
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
5
5
  ) => createLocalCommunityMemberEventSubscriber('local.community.left', callback);
@@ -16,5 +16,5 @@ import { createLocalCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onLocalCommunityUserAdded = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createLocalCommunityMemberEventSubscriber('local.community.userAdded', callback);
@@ -16,5 +16,5 @@ import { createLocalCommunityMemberEventSubscriber } from './utils';
16
16
  * @category Community Events
17
17
  */
18
18
  export const onLocalCommunityUserRemoved = (
19
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
19
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
20
20
  ) => createLocalCommunityMemberEventSubscriber('local.community.userRemoved', callback);
@@ -22,7 +22,9 @@ import { getResolver } from '~/core/model';
22
22
  */
23
23
  export const onUserDeleted =
24
24
  (communityId: string) =>
25
- (callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void) => {
25
+ (
26
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
27
+ ) => {
26
28
  const client = getActiveClient();
27
29
 
28
30
  const filter = (payload: Amity.UserPayload) => {
@@ -53,7 +53,7 @@ function getEventRelatedMember(
53
53
 
54
54
  export const createCommunityMemberEventSubscriber = (
55
55
  event: keyof Amity.MqttCommunityUserEvents,
56
- callback: (community: Amity.Community, members: Amity.Membership<'community'>[]) => void,
56
+ callback: (community: Amity.InternalCommunity, members: Amity.Membership<'community'>[]) => void,
57
57
  ) => {
58
58
  const client = getActiveClient();
59
59
 
@@ -102,7 +102,7 @@ export const createCommunityMemberEventSubscriber = (
102
102
 
103
103
  export const createLocalCommunityMemberEventSubscriber = (
104
104
  event: keyof Amity.LocalCommunityEvents,
105
- callback: (community: Amity.Community, members: Amity.Membership<'community'>[]) => void,
105
+ callback: (community: Amity.InternalCommunity, members: Amity.Membership<'community'>[]) => void,
106
106
  ) => {
107
107
  const client = getActiveClient();
108
108
 
@@ -70,7 +70,10 @@ export class CommunityMembersQueryStreamController extends QueryStreamController
70
70
  }
71
71
 
72
72
  reactor(action: EnumCommunityMemberActions) {
73
- return (community: Amity.Community, communityMembers: Amity.Membership<'community'>[]) => {
73
+ return (
74
+ community: Amity.InternalCommunity,
75
+ communityMembers: Amity.Membership<'community'>[],
76
+ ) => {
74
77
  const collection = pullFromCache<Amity.CommunityMemberLiveCollectionCache>(
75
78
  this.cacheKey,
76
79
  )?.data;
@@ -97,7 +100,10 @@ export class CommunityMembersQueryStreamController extends QueryStreamController
97
100
  subscribeRTE(
98
101
  createSubscriber: {
99
102
  fn: (
100
- reactor: (channel: Amity.Community, communityUser: Amity.Membership<'community'>[]) => void,
103
+ reactor: (
104
+ channel: Amity.InternalCommunity,
105
+ communityUser: Amity.Membership<'community'>[],
106
+ ) => void,
101
107
  ) => Amity.Unsubscriber;
102
108
  action: EnumCommunityMemberActions;
103
109
  }[],
@@ -70,7 +70,10 @@ export class SearchCommunityMembersQueryStreamController extends QueryStreamCont
70
70
  }
71
71
 
72
72
  reactor(action: EnumCommunityMemberActions) {
73
- return (community: Amity.Community, communityMembers: Amity.Membership<'community'>[]) => {
73
+ return (
74
+ community: Amity.InternalCommunity,
75
+ communityMembers: Amity.Membership<'community'>[],
76
+ ) => {
74
77
  const collection = pullFromCache<Amity.SearchCommunityMemberLiveCollectionCache>(
75
78
  this.cacheKey,
76
79
  )?.data;
@@ -95,7 +98,10 @@ export class SearchCommunityMembersQueryStreamController extends QueryStreamCont
95
98
  subscribeRTE(
96
99
  createSubscriber: {
97
100
  fn: (
98
- reactor: (channel: Amity.Community, communityUser: Amity.Membership<'community'>[]) => void,
101
+ reactor: (
102
+ channel: Amity.InternalCommunity,
103
+ communityUser: Amity.Membership<'community'>[],
104
+ ) => void,
99
105
  ) => Amity.Unsubscriber;
100
106
  action: EnumCommunityMemberActions;
101
107
  }[],
@@ -17,7 +17,7 @@ import { createEventSubscriber } from '~/core/events';
17
17
  * @category Community Events
18
18
  */
19
19
  export const onLocalCommunityRoleAdded = (
20
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
20
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
21
21
  ): Amity.Unsubscriber => {
22
22
  const client = getActiveClient();
23
23
 
@@ -17,7 +17,7 @@ import { createEventSubscriber } from '~/core/events';
17
17
  * @category Community Events
18
18
  */
19
19
  export const onLocalCommunityRoleRemoved = (
20
- callback: (community: Amity.Community, member: Amity.Membership<'community'>[]) => void,
20
+ callback: (community: Amity.InternalCommunity, member: Amity.Membership<'community'>[]) => void,
21
21
  ): Amity.Unsubscriber => {
22
22
  const client = getActiveClient();
23
23
 
@@ -15,5 +15,5 @@ import { createCommunityEventSubscriber } from './utils';
15
15
  *
16
16
  * @category Community Events
17
17
  */
18
- export const onCommunityCreated = (callback: Amity.Listener<Amity.Community>) =>
18
+ export const onCommunityCreated = (callback: Amity.Listener<Amity.InternalCommunity>) =>
19
19
  createCommunityEventSubscriber('community.created', callback);
@@ -15,5 +15,5 @@ import { createCommunityEventSubscriber } from './utils';
15
15
  *
16
16
  * @category Community Events
17
17
  */
18
- export const onCommunityDeleted = (callback: Amity.Listener<Amity.Community>) =>
18
+ export const onCommunityDeleted = (callback: Amity.Listener<Amity.InternalCommunity>) =>
19
19
  createCommunityEventSubscriber('community.deleted', callback);
@@ -15,5 +15,5 @@ import { createCommunityEventSubscriber } from './utils';
15
15
  *
16
16
  * @category Community Events
17
17
  */
18
- export const onCommunityUpdated = (callback: Amity.Listener<Amity.Community>) =>
18
+ export const onCommunityUpdated = (callback: Amity.Listener<Amity.InternalCommunity>) =>
19
19
  createCommunityEventSubscriber('community.updated', callback);
@@ -7,7 +7,7 @@ import { prepareCommunityPayload } from '../utils';
7
7
 
8
8
  export const createCommunityEventSubscriber = (
9
9
  event: keyof Amity.MqttCommunityEvents,
10
- callback: Amity.Listener<Amity.Community>,
10
+ callback: Amity.Listener<Amity.InternalCommunity>,
11
11
  ) => {
12
12
  const client = getActiveClient();
13
13
 
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
60
60
  }
61
61
 
62
62
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
63
- return (community: Amity.Community) => {
63
+ return (community: Amity.InternalCommunity) => {
64
64
  const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
65
65
  if (!collection) return;
66
66
 
@@ -76,7 +76,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
76
76
 
77
77
  subscribeRTE(
78
78
  createSubscriber: {
79
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
79
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
80
80
  action: EnumCommunityActions | EnumCommunityMemberActions;
81
81
  }[],
82
82
  ) {
@@ -66,7 +66,7 @@ export class RecommendedCommunitiesQueryStreamController extends QueryStreamCont
66
66
  }
67
67
 
68
68
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
69
- return (community: Amity.Community) => {
69
+ return (community: Amity.InternalCommunity) => {
70
70
  const collection = pullFromCache<Amity.RecommendedCommunityLiveCollectionCache>(
71
71
  this.cacheKey,
72
72
  )?.data;
@@ -79,7 +79,7 @@ export class RecommendedCommunitiesQueryStreamController extends QueryStreamCont
79
79
 
80
80
  subscribeRTE(
81
81
  createSubscriber: {
82
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
82
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
83
83
  action: EnumCommunityActions | EnumCommunityMemberActions;
84
84
  }[],
85
85
  ) {
@@ -64,7 +64,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
64
64
  }
65
65
 
66
66
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
67
- return (community: Amity.Community) => {
67
+ return (community: Amity.InternalCommunity) => {
68
68
  const collection = pullFromCache<Amity.TrendingCommunityLiveCollectionCache>(
69
69
  this.cacheKey,
70
70
  )?.data;
@@ -77,7 +77,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
77
77
 
78
78
  subscribeRTE(
79
79
  createSubscriber: {
80
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
81
81
  action: EnumCommunityActions | EnumCommunityMemberActions;
82
82
  }[],
83
83
  ) {
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
60
60
  }
61
61
 
62
62
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
63
- return (community: Amity.Community) => {
63
+ return (community: Amity.InternalCommunity) => {
64
64
  const collection = pullFromCache<Amity.SearchCommunityLiveCollectionCache>(
65
65
  this.cacheKey,
66
66
  )?.data;
@@ -73,7 +73,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
73
73
 
74
74
  subscribeRTE(
75
75
  createSubscriber: {
76
- fn: (reactor: (channel: Amity.Community) => void) => Amity.Unsubscriber;
76
+ fn: (reactor: (channel: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
77
77
  action: EnumCommunityActions | EnumCommunityMemberActions;
78
78
  }[],
79
79
  ) {
@@ -63,7 +63,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
63
63
  }
64
64
 
65
65
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
66
- return (community: Amity.Community) => {
66
+ return (community: Amity.InternalCommunity) => {
67
67
  const collection = pullFromCache<Amity.CommunityLiveCollectionCache>(this.cacheKey)?.data;
68
68
  if (!collection) return;
69
69
 
@@ -77,7 +77,7 @@ export class SemanticSearchCommunityQueryStreamController extends QueryStreamCon
77
77
 
78
78
  subscribeRTE(
79
79
  createSubscriber: {
80
- fn: (reactor: (community: Amity.Community) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (community: Amity.InternalCommunity) => void) => Amity.Unsubscriber;
81
81
  action: EnumCommunityActions | EnumCommunityMemberActions;
82
82
  }[],
83
83
  ) {
@@ -12,7 +12,7 @@ function isMember(membership: Amity.Membership<'community'>['communityMembership
12
12
  * checks if currently logged in user is part of the community
13
13
  */
14
14
  function isCurrentUserPartOfCommunity(
15
- c: Amity.Community,
15
+ c: Amity.InternalCommunity,
16
16
  m: Amity.Membership<'community'>,
17
17
  ): boolean {
18
18
  const { userId } = getActiveUser();
@@ -28,11 +28,15 @@ function isCurrentUserPartOfCommunity(
28
28
  * Althought this can be calculated, it's not scalable.
29
29
  */
30
30
  export function updateMembershipStatus(
31
- communities: Amity.Community[],
31
+ communities: Amity.RawCommunity[],
32
32
  communityUsers: Amity.Membership<'community'>[],
33
- ): Amity.Community[] {
33
+ ): Amity.InternalCommunity[] {
34
34
  return communities.map(c => {
35
- const cachedCommunity = pullFromCache<Amity.Community>(['community', 'get', c.communityId]);
35
+ const cachedCommunity = pullFromCache<Amity.InternalCommunity>([
36
+ 'community',
37
+ 'get',
38
+ c.communityId,
39
+ ]);
36
40
  if (cachedCommunity?.data && cachedCommunity?.data.hasOwnProperty('isJoined')) {
37
41
  return {
38
42
  ...cachedCommunity.data,
@@ -13,7 +13,7 @@ const getMatchPostSetting = (value: {
13
13
  ) ?? DefaultCommunityPostSetting;
14
14
 
15
15
  export function addPostSetting({ communities }: { communities: Amity.RawCommunity[] }) {
16
- return communities.map<Amity.Community>(
16
+ return communities.map<Amity.InternalCommunity>(
17
17
  ({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
18
18
  postSetting: getMatchPostSetting({
19
19
  needApprovalOnPostCreation,
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { getActiveClient } from '~/client/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
3
 
4
4
  export abstract class PaginationController<
5
5
  TPayloadDomain extends keyof Amity.Payloads,
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { getActiveClient } from '~/client/api';
2
+ import { getActiveClient } from '~/client/api/activeClient';
3
3
 
4
4
  export abstract class PaginationNoPageController<
5
5
  TPayloadDomain extends keyof Amity.Payloads,
@@ -64,6 +64,8 @@ const idResolvers: Resolvers = {
64
64
 
65
65
  notificationTrayItem: ({ _id }) => _id,
66
66
  notificationTraySeen: ({ userId }) => userId,
67
+
68
+ invitation: ({ _id }) => _id,
67
69
  };
68
70
 
69
71
  /**
@@ -54,6 +54,8 @@ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = {
54
54
  pins: 'pin',
55
55
 
56
56
  notificationTrayItems: 'notificationTrayItem',
57
+
58
+ invitations: 'invitation',
57
59
  };
58
60
 
59
61
  /** hidden */
package/src/index.ts CHANGED
@@ -51,3 +51,5 @@ export * as AdRepository from './adRepository';
51
51
  export * from './external/api';
52
52
 
53
53
  export * as notificationTray from './notificationTray';
54
+
55
+ export * as InvitationRepository from './invitationRepository';
@@ -0,0 +1,3 @@
1
+ export * from './onLocalInvitationCreated';
2
+ export * from './onLocalInvitationUpdated';
3
+ export * from './onLocalInvitationDeleted';
@@ -0,0 +1,33 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { createEventSubscriber } from '~/core/events';
3
+
4
+ /**
5
+ * ```js
6
+ * import { onLocalInvitationCreated } from '@amityco/ts-sdk'
7
+ * const dispose = onLocalInvitationCreated(data => {
8
+ * // ...
9
+ * })
10
+ * ```
11
+ *
12
+ * Fired when an {@link Amity.InvitationPayload} has been created
13
+ *
14
+ * @param callback The function to call when the event was fired
15
+ * @returns an {@link Amity.Unsubscriber} function to stop listening
16
+ *
17
+ * @category Invitation Events
18
+ */
19
+ export const onLocalInvitationCreated = (
20
+ callback: Amity.Listener<Amity.InternalInvitation[]>,
21
+ ): Amity.Unsubscriber => {
22
+ const client = getActiveClient();
23
+
24
+ const disposers = [
25
+ createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload =>
26
+ callback(payload),
27
+ ),
28
+ ];
29
+
30
+ return () => {
31
+ disposers.forEach(fn => fn());
32
+ };
33
+ };