@amityco/ts-sdk 7.4.1-d23fab2f.0 → 7.5.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 (180) hide show
  1. package/.env +26 -26
  2. package/dist/@types/core/events.d.ts +0 -3
  3. package/dist/@types/core/events.d.ts.map +1 -1
  4. package/dist/@types/core/model.d.ts +1 -3
  5. package/dist/@types/core/model.d.ts.map +1 -1
  6. package/dist/@types/core/payload.d.ts +4 -8
  7. package/dist/@types/core/payload.d.ts.map +1 -1
  8. package/dist/@types/domains/client.d.ts +0 -10
  9. package/dist/@types/domains/client.d.ts.map +1 -1
  10. package/dist/@types/domains/community.d.ts +1 -7
  11. package/dist/@types/domains/community.d.ts.map +1 -1
  12. package/dist/@types/index.d.ts +0 -2
  13. package/dist/@types/index.d.ts.map +1 -1
  14. package/dist/communityRepository/api/createCommunity.d.ts +2 -2
  15. package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
  16. package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
  17. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  18. package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
  19. package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
  20. package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
  21. package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
  22. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
  23. package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
  24. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
  25. package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
  26. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
  27. package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
  28. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
  29. package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
  30. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
  31. package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
  32. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
  33. package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
  34. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
  35. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
  36. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
  37. package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
  38. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
  39. package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
  40. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
  41. package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
  42. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
  43. package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
  44. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
  45. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
  46. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
  47. package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
  48. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
  49. package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
  50. package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
  51. package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
  52. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
  53. package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
  54. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
  55. package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
  56. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
  57. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
  58. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
  59. package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
  60. package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
  61. package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
  62. package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
  63. package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
  64. package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
  65. package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
  66. package/dist/communityRepository/events/utils.d.ts +1 -1
  67. package/dist/communityRepository/events/utils.d.ts.map +1 -1
  68. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
  69. package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
  70. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
  71. package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
  72. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
  73. package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
  74. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
  75. package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
  76. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
  77. package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
  78. package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
  79. package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
  80. package/dist/communityRepository/utils/payload.d.ts +1 -1
  81. package/dist/communityRepository/utils/payload.d.ts.map +1 -1
  82. package/dist/core/events.d.ts +3 -3
  83. package/dist/core/events.d.ts.map +1 -1
  84. package/dist/core/model/idResolvers.d.ts.map +1 -1
  85. package/dist/core/model/index.d.ts.map +1 -1
  86. package/dist/index.cjs.js +55 -276
  87. package/dist/index.d.ts +0 -1
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.esm.js +38 -258
  90. package/dist/index.umd.js +4 -4
  91. package/dist/utils/linkedObject/index.d.ts +0 -2
  92. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  93. package/dist/utils/tests/dummy/post.d.ts +3 -3
  94. package/package.json +1 -1
  95. package/src/@types/core/events.ts +0 -4
  96. package/src/@types/core/model.ts +1 -5
  97. package/src/@types/core/payload.ts +4 -9
  98. package/src/@types/domains/client.ts +0 -12
  99. package/src/@types/domains/community.ts +1 -13
  100. package/src/@types/index.ts +0 -2
  101. package/src/communityRepository/api/createCommunity.ts +2 -5
  102. package/src/communityRepository/api/getCommunities.ts +1 -2
  103. package/src/communityRepository/api/getCommunity.ts +1 -4
  104. package/src/communityRepository/api/getRecommendedCommunities.ts +1 -2
  105. package/src/communityRepository/api/getTrendingCommunities.ts +1 -2
  106. package/src/communityRepository/api/queryCommunities.ts +1 -6
  107. package/src/communityRepository/api/updateCommunity.ts +1 -4
  108. package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
  109. package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
  110. package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
  111. package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
  112. package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
  113. package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
  114. package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
  115. package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
  116. package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
  117. package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
  118. package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
  119. package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
  120. package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
  121. package/src/communityRepository/communityMembership/events/onUserDeleted.ts +1 -3
  122. package/src/communityRepository/communityMembership/events/utils.ts +2 -2
  123. package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +2 -8
  124. package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +2 -8
  125. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
  126. package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
  127. package/src/communityRepository/events/onCommunityCreated.ts +1 -1
  128. package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
  129. package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
  130. package/src/communityRepository/events/utils.ts +1 -1
  131. package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
  132. package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
  133. package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
  134. package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
  135. package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
  136. package/src/communityRepository/utils/communityWithMembership.ts +4 -8
  137. package/src/communityRepository/utils/payload.ts +1 -1
  138. package/src/core/model/idResolvers.ts +0 -2
  139. package/src/core/model/index.ts +0 -2
  140. package/src/index.ts +0 -2
  141. package/src/utils/linkedObject/index.ts +0 -4
  142. package/dist/@types/domains/invitation.d.ts +0 -43
  143. package/dist/@types/domains/invitation.d.ts.map +0 -1
  144. package/dist/invitationRepository/events/index.d.ts +0 -2
  145. package/dist/invitationRepository/events/index.d.ts.map +0 -1
  146. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +0 -17
  147. package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +0 -1
  148. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +0 -17
  149. package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +0 -1
  150. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +0 -17
  151. package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +0 -1
  152. package/dist/invitationRepository/index.d.ts +0 -2
  153. package/dist/invitationRepository/index.d.ts.map +0 -1
  154. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +0 -16
  155. package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +0 -1
  156. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +0 -16
  157. package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +0 -1
  158. package/dist/invitationRepository/internalApi/createInvitations.d.ts +0 -21
  159. package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +0 -1
  160. package/dist/invitationRepository/internalApi/index.d.ts +0 -5
  161. package/dist/invitationRepository/internalApi/index.d.ts.map +0 -1
  162. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +0 -16
  163. package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +0 -1
  164. package/dist/utils/linkedObject/communityLinkedObject.d.ts +0 -2
  165. package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +0 -1
  166. package/dist/utils/linkedObject/invitationLinkedObject.d.ts +0 -2
  167. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +0 -1
  168. package/src/@types/domains/invitation.ts +0 -52
  169. package/src/invitationRepository/events/index.ts +0 -1
  170. package/src/invitationRepository/events/onLocalInvitationCreated.ts +0 -33
  171. package/src/invitationRepository/events/onLocalInvitationDeleted.ts +0 -33
  172. package/src/invitationRepository/events/onLocalInvitationUpdated.ts +0 -33
  173. package/src/invitationRepository/index.ts +0 -1
  174. package/src/invitationRepository/internalApi/acceptInvitation.ts +0 -45
  175. package/src/invitationRepository/internalApi/cancelInvitation.ts +0 -44
  176. package/src/invitationRepository/internalApi/createInvitations.ts +0 -46
  177. package/src/invitationRepository/internalApi/index.ts +0 -4
  178. package/src/invitationRepository/internalApi/rejectInvitation.ts +0 -45
  179. package/src/utils/linkedObject/communityLinkedObject.ts +0 -16
  180. package/src/utils/linkedObject/invitationLinkedObject.ts +0 -20
@@ -64,7 +64,7 @@ export class TrendingCommunitiesQueryStreamController extends QueryStreamControl
64
64
  }
65
65
 
66
66
  reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
67
- return (community: Amity.InternalCommunity) => {
67
+ return (community: Amity.Community) => {
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.InternalCommunity) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (channel: Amity.Community) => 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.InternalCommunity) => {
63
+ return (community: Amity.Community) => {
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.InternalCommunity) => void) => Amity.Unsubscriber;
76
+ fn: (reactor: (channel: Amity.Community) => 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.InternalCommunity) => {
66
+ return (community: Amity.Community) => {
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.InternalCommunity) => void) => Amity.Unsubscriber;
80
+ fn: (reactor: (community: Amity.Community) => 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.InternalCommunity,
15
+ c: Amity.Community,
16
16
  m: Amity.Membership<'community'>,
17
17
  ): boolean {
18
18
  const { userId } = getActiveUser();
@@ -28,15 +28,11 @@ function isCurrentUserPartOfCommunity(
28
28
  * Althought this can be calculated, it's not scalable.
29
29
  */
30
30
  export function updateMembershipStatus(
31
- communities: Amity.RawCommunity[],
31
+ communities: Amity.Community[],
32
32
  communityUsers: Amity.Membership<'community'>[],
33
- ): Amity.InternalCommunity[] {
33
+ ): Amity.Community[] {
34
34
  return communities.map(c => {
35
- const cachedCommunity = pullFromCache<Amity.InternalCommunity>([
36
- 'community',
37
- 'get',
38
- c.communityId,
39
- ]);
35
+ const cachedCommunity = pullFromCache<Amity.Community>(['community', 'get', c.communityId]);
40
36
  if (cachedCommunity?.data && cachedCommunity?.data.hasOwnProperty('isJoined')) {
41
37
  return {
42
38
  ...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.InternalCommunity>(
16
+ return communities.map<Amity.Community>(
17
17
  ({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
18
18
  postSetting: getMatchPostSetting({
19
19
  needApprovalOnPostCreation,
@@ -64,8 +64,6 @@ const idResolvers: Resolvers = {
64
64
 
65
65
  notificationTrayItem: ({ _id }) => _id,
66
66
  notificationTraySeen: ({ userId }) => userId,
67
-
68
- invitation: ({ _id }) => _id,
69
67
  };
70
68
 
71
69
  /**
@@ -54,8 +54,6 @@ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = {
54
54
  pins: 'pin',
55
55
 
56
56
  notificationTrayItems: 'notificationTrayItem',
57
-
58
- invitations: 'invitation',
59
57
  };
60
58
 
61
59
  /** hidden */
package/src/index.ts CHANGED
@@ -51,5 +51,3 @@ 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';
@@ -11,8 +11,6 @@ import { channelLinkedObject } from './channelLinkedObject';
11
11
  import { adLinkedObject } from './adLinkedObject';
12
12
  import { pinnedPostLinkedObject } from './pinnedPostLinkedObject';
13
13
  import { notificationTrayLinkedObject } from './notificationTrayLinkedObject';
14
- import { communityLinkedObject } from './communityLinkedObject';
15
- import { invitationLinkedObject } from './invitationLinkedObject';
16
14
 
17
15
  export const LinkedObject = {
18
16
  ad: adLinkedObject,
@@ -28,6 +26,4 @@ export const LinkedObject = {
28
26
  channel: channelLinkedObject,
29
27
  pinnedPost: pinnedPostLinkedObject,
30
28
  notificationTray: notificationTrayLinkedObject,
31
- community: communityLinkedObject,
32
- invitation: invitationLinkedObject,
33
29
  };
@@ -1,43 +0,0 @@
1
- export {};
2
- export declare const enum InvitationTypeEnum {
3
- CommunityMemberInvite = "communityMemberInvite",
4
- LivestreamInvite = "livestreamInvite"
5
- }
6
- export declare const enum InvitationStatusEnum {
7
- Pending = "pending",
8
- Approved = "approved",
9
- Rejected = "rejected",
10
- Cancelled = "cancelled"
11
- }
12
- declare global {
13
- namespace Amity {
14
- type InvitationType = InvitationTypeEnum;
15
- type InvitationStatus = InvitationStatusEnum;
16
- type InvitationTargetType = Extract<Amity.Domain, 'community' | 'post' | 'comment'>;
17
- type RawInvitation = {
18
- _id: string;
19
- networkId: string;
20
- type: Amity.InvitationType;
21
- targetId: string;
22
- targetType: Amity.InvitationTargetType;
23
- userId: string;
24
- status: Amity.InvitationStatus;
25
- respondedAt: Amity.timestamp;
26
- createdBy: string;
27
- } & Amity.Timestamps;
28
- type InternalInvitation = RawInvitation;
29
- type Invitation = Amity.InternalInvitation & Amity.InvitationLinkedObject;
30
- type InvitationLinkedObject = {
31
- accept: () => Promise<void>;
32
- reject: () => Promise<void>;
33
- cancel: () => Promise<void>;
34
- };
35
- type CreateInvitations = {
36
- type: Amity.InvitationType;
37
- targetType: Amity.InvitationTargetType;
38
- targetId: string;
39
- userIds: string[];
40
- };
41
- }
42
- }
43
- //# sourceMappingURL=invitation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invitation.d.ts","sourceRoot":"","sources":["../../../src/@types/domains/invitation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC;AAEV,0BAAkB,kBAAkB;IAClC,qBAAqB,0BAA0B;IAC/C,gBAAgB,qBAAqB;CACtC;AAED,0BAAkB,oBAAoB;IACpC,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,SAAS,cAAc;CACxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC;QACd,KAAK,cAAc,GAAG,kBAAkB,CAAC;QAEzC,KAAK,gBAAgB,GAAG,oBAAoB,CAAC;QAE7C,KAAK,oBAAoB,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;QAEpF,KAAK,aAAa,GAAG;YACnB,GAAG,EAAE,MAAM,CAAC;YACZ,SAAS,EAAE,MAAM,CAAC;YAClB,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC;YAC3B,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,KAAK,CAAC,oBAAoB,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC;YACf,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC;YAC/B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC;YAC7B,SAAS,EAAE,MAAM,CAAC;SACnB,GAAG,KAAK,CAAC,UAAU,CAAC;QAErB,KAAK,kBAAkB,GAAG,aAAa,CAAC;QAExC,KAAK,UAAU,GAAG,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,sBAAsB,CAAC;QAE1E,KAAK,sBAAsB,GAAG;YAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;SAC7B,CAAC;QAEF,KAAK,iBAAiB,GAAG;YACvB,IAAI,EAAE,KAAK,CAAC,cAAc,CAAC;YAC3B,UAAU,EAAE,KAAK,CAAC,oBAAoB,CAAC;YACvC,QAAQ,EAAE,MAAM,CAAC;YACjB,OAAO,EAAE,MAAM,EAAE,CAAC;SACnB,CAAC;KACH;CACF"}
@@ -1,2 +0,0 @@
1
- export * from './onLocalInvitationCreated';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/events/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * ```js
3
- * import { onLocalInvitationCreated } from '@amityco/ts-sdk'
4
- * const dispose = onLocalInvitationCreated(data => {
5
- * // ...
6
- * })
7
- * ```
8
- *
9
- * Fired when an {@link Amity.InvitationPayload} has been created
10
- *
11
- * @param callback The function to call when the event was fired
12
- * @returns an {@link Amity.Unsubscriber} function to stop listening
13
- *
14
- * @category Invitation Events
15
- */
16
- export declare const onLocalInvitationCreated: (callback: Amity.Listener<Amity.InvitationPayload>) => Amity.Unsubscriber;
17
- //# sourceMappingURL=onLocalInvitationCreated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onLocalInvitationCreated.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/events/onLocalInvitationCreated.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,aACzB,MAAM,QAAQ,CAAC,MAAM,iBAAiB,CAAC,KAChD,MAAM,YAYR,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * ```js
3
- * import { onLocalInvitationDeleted } from '@amityco/ts-sdk'
4
- * const dispose = onLocalInvitationDeleted(data => {
5
- * // ...
6
- * })
7
- * ```
8
- *
9
- * Fired when an {@link Amity.InvitationPayload} has been deleted
10
- *
11
- * @param callback The function to call when the event was fired
12
- * @returns an {@link Amity.Unsubscriber} function to stop listening
13
- *
14
- * @category Invitation Events
15
- */
16
- export declare const onLocalInvitationDeleted: (callback: Amity.Listener<Amity.InvitationPayload>) => Amity.Unsubscriber;
17
- //# sourceMappingURL=onLocalInvitationDeleted.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onLocalInvitationDeleted.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/events/onLocalInvitationDeleted.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,aACzB,MAAM,QAAQ,CAAC,MAAM,iBAAiB,CAAC,KAChD,MAAM,YAYR,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * ```js
3
- * import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
4
- * const dispose = onLocalInvitationUpdated(data => {
5
- * // ...
6
- * })
7
- * ```
8
- *
9
- * Fired when an {@link Amity.InvitationPayload} has been updated
10
- *
11
- * @param callback The function to call when the event was fired
12
- * @returns an {@link Amity.Unsubscriber} function to stop listening
13
- *
14
- * @category Invitation Events
15
- */
16
- export declare const onLocalInvitationUpdated: (callback: Amity.Listener<Amity.InvitationPayload>) => Amity.Unsubscriber;
17
- //# sourceMappingURL=onLocalInvitationUpdated.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"onLocalInvitationUpdated.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/events/onLocalInvitationUpdated.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,wBAAwB,aACzB,MAAM,QAAQ,CAAC,MAAM,iBAAiB,CAAC,KAChD,MAAM,YAYR,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './events';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/invitationRepository/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * ```js
3
- * import { acceptInvitation } from '@amityco/ts-sdk'
4
- * const isAccepted = await acceptInvitation(invitationId)
5
- * ```
6
- *
7
- * Accepts a {@link Amity.Invitation} object
8
- *
9
- * @param invitationId the {@link Amity.Invitation} to accept
10
- * @returns A success boolean if the {@link Amity.Invitation} was accepted
11
- *
12
- * @category Invitation API
13
- * @async
14
- */
15
- export declare const acceptInvitation: (invitationId: Amity.Invitation['_id']) => Promise<boolean>;
16
- //# sourceMappingURL=acceptInvitation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acceptInvitation.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/internalApi/acceptInvitation.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,iBAAwB,MAAM,UAAU,CAAC,KAAK,CAAC,KAAG,QAAQ,OAAO,CAqB7F,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * ```js
3
- * import { cancelInvitation } from '@amityco/ts-sdk'
4
- * const isCanceled = await cancelInvitation(invitationId)
5
- * ```
6
- *
7
- * Cancels a {@link Amity.Invitation} object
8
- *
9
- * @param invitationId the {@link Amity.Invitation} to cancel
10
- * @returns A success boolean if the {@link Amity.Invitation} was canceled
11
- *
12
- * @category Invitation API
13
- * @async
14
- */
15
- export declare const cancelInvitation: (invitationId: Amity.Invitation['_id']) => Promise<boolean>;
16
- //# sourceMappingURL=cancelInvitation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cancelInvitation.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/internalApi/cancelInvitation.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,iBAAwB,MAAM,UAAU,CAAC,KAAK,CAAC,KAAG,QAAQ,OAAO,CAqB7F,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * ```js
3
- * import { createInvitations } from '@amityco/ts-sdk'
4
- * const created = await createInvitations({
5
- * type: string,
6
- * targetType: string,
7
- * targetId: string,
8
- * userIds: string[]
9
- * }))
10
- * ```
11
- *
12
- * Creates an {@link Amity.Invitation}
13
- *
14
- * @param bundle The data necessary to create a new {@link Amity.Invitation}
15
- * @returns The newly created {@link Amity.Invitation}
16
- *
17
- * @category Invitation API
18
- * @async
19
- */
20
- export declare const createInvitations: (bundle: Amity.CreateInvitations) => Promise<Amity.Cached<Amity.InternalInvitation[]>>;
21
- //# sourceMappingURL=createInvitations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createInvitations.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/internalApi/createInvitations.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,iBAAiB,WACpB,MAAM,iBAAiB,KAC9B,QAAQ,MAAM,MAAM,CAAC,MAAM,kBAAkB,EAAE,CAAC,CAgBlD,CAAC"}
@@ -1,5 +0,0 @@
1
- export * from './createInvitations';
2
- export * from './acceptInvitation';
3
- export * from './rejectInvitation';
4
- export * from './cancelInvitation';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/internalApi/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * ```js
3
- * import { rejectInvitation } from '@amityco/ts-sdk'
4
- * const isRejected = await rejectInvitation(invitationId)
5
- * ```
6
- *
7
- * Rejects a {@link Amity.Invitation} object
8
- *
9
- * @param invitationId the {@link Amity.Invitation} to reject
10
- * @returns A success boolean if the {@link Amity.Invitation} was rejected
11
- *
12
- * @category Invitation API
13
- * @async
14
- */
15
- export declare const rejectInvitation: (invitationId: Amity.Invitation['_id']) => Promise<boolean>;
16
- //# sourceMappingURL=rejectInvitation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rejectInvitation.d.ts","sourceRoot":"","sources":["../../../src/invitationRepository/internalApi/rejectInvitation.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,iBAAwB,MAAM,UAAU,CAAC,KAAK,CAAC,KAAG,QAAQ,OAAO,CAqB7F,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const communityLinkedObject: (community: Amity.RawCommunity) => Amity.Community;
2
- //# sourceMappingURL=communityLinkedObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"communityLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/communityLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,qBAAqB,cAAe,MAAM,YAAY,KAAG,MAAM,SAY3E,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const invitationLinkedObject: (invitation: Amity.RawInvitation) => Amity.Invitation;
2
- //# sourceMappingURL=invitationLinkedObject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invitationLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/invitationLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,sBAAsB,eAAgB,MAAM,aAAa,KAAG,MAAM,UAa9E,CAAC"}
@@ -1,52 +0,0 @@
1
- export {};
2
-
3
- export const enum InvitationTypeEnum {
4
- CommunityMemberInvite = 'communityMemberInvite',
5
- LivestreamInvite = 'livestreamInvite',
6
- }
7
-
8
- export const enum InvitationStatusEnum {
9
- Pending = 'pending',
10
- Approved = 'approved',
11
- Rejected = 'rejected',
12
- Cancelled = 'cancelled',
13
- }
14
-
15
- declare global {
16
- namespace Amity {
17
- type InvitationType = InvitationTypeEnum;
18
-
19
- type InvitationStatus = InvitationStatusEnum;
20
-
21
- type InvitationTargetType = Extract<Amity.Domain, 'community' | 'post' | 'comment'>;
22
-
23
- type RawInvitation = {
24
- _id: string;
25
- networkId: string;
26
- type: Amity.InvitationType;
27
- targetId: string;
28
- targetType: Amity.InvitationTargetType;
29
- userId: string;
30
- status: Amity.InvitationStatus;
31
- respondedAt: Amity.timestamp;
32
- createdBy: string;
33
- } & Amity.Timestamps;
34
-
35
- type InternalInvitation = RawInvitation;
36
-
37
- type Invitation = Amity.InternalInvitation & Amity.InvitationLinkedObject;
38
-
39
- type InvitationLinkedObject = {
40
- accept: () => Promise<void>;
41
- reject: () => Promise<void>;
42
- cancel: () => Promise<void>;
43
- };
44
-
45
- type CreateInvitations = {
46
- type: Amity.InvitationType;
47
- targetType: Amity.InvitationTargetType;
48
- targetId: string;
49
- userIds: string[];
50
- };
51
- }
52
- }
@@ -1 +0,0 @@
1
- export * from './onLocalInvitationCreated';
@@ -1,33 +0,0 @@
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.InvitationPayload>,
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
- };
@@ -1,33 +0,0 @@
1
- import { createEventSubscriber } from '~/core/events';
2
- import { getActiveClient } from '~/client/api/activeClient';
3
-
4
- /**
5
- * ```js
6
- * import { onLocalInvitationDeleted } from '@amityco/ts-sdk'
7
- * const dispose = onLocalInvitationDeleted(data => {
8
- * // ...
9
- * })
10
- * ```
11
- *
12
- * Fired when an {@link Amity.InvitationPayload} has been deleted
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 onLocalInvitationDeleted = (
20
- callback: Amity.Listener<Amity.InvitationPayload>,
21
- ): Amity.Unsubscriber => {
22
- const client = getActiveClient();
23
-
24
- const disposers = [
25
- createEventSubscriber(client, 'onLocalInvitationDeleted', 'local.invitation.deleted', payload =>
26
- callback(payload),
27
- ),
28
- ];
29
-
30
- return () => {
31
- disposers.forEach(fn => fn());
32
- };
33
- };
@@ -1,33 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
- import { createEventSubscriber } from '~/core/events';
3
-
4
- /**
5
- * ```js
6
- * import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
7
- * const dispose = onLocalInvitationUpdated(data => {
8
- * // ...
9
- * })
10
- * ```
11
- *
12
- * Fired when an {@link Amity.InvitationPayload} has been updated
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 onLocalInvitationUpdated = (
20
- callback: Amity.Listener<Amity.InvitationPayload>,
21
- ): Amity.Unsubscriber => {
22
- const client = getActiveClient();
23
-
24
- const disposers = [
25
- createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload =>
26
- callback(payload),
27
- ),
28
- ];
29
-
30
- return () => {
31
- disposers.forEach(fn => fn());
32
- };
33
- };
@@ -1 +0,0 @@
1
- export * from './events';
@@ -1,45 +0,0 @@
1
- import { fireEvent } from '~/core/events';
2
- import { getActiveClient } from '~/client/api/activeClient';
3
- import { pullFromCache, upsertInCache } from '~/cache/api';
4
- import { InvitationStatusEnum } from '~/@types';
5
-
6
- /* begin_public_function
7
- id: invitation.accept
8
- */
9
- /**
10
- * ```js
11
- * import { acceptInvitation } from '@amityco/ts-sdk'
12
- * const isAccepted = await acceptInvitation(invitationId)
13
- * ```
14
- *
15
- * Accepts a {@link Amity.Invitation} object
16
- *
17
- * @param invitationId the {@link Amity.Invitation} to accept
18
- * @returns A success boolean if the {@link Amity.Invitation} was accepted
19
- *
20
- * @category Invitation API
21
- * @async
22
- */
23
- export const acceptInvitation = async (invitationId: Amity.Invitation['_id']): Promise<boolean> => {
24
- const client = getActiveClient();
25
- client.log('invitation/acceptInvitation', invitationId);
26
-
27
- const { data } = await client.http.post<{ success: boolean }>(
28
- `/api/v1/invitations/${invitationId}/accept`,
29
- );
30
-
31
- const invitation = pullFromCache<Amity.InternalInvitation>([
32
- 'invitation',
33
- 'get',
34
- invitationId,
35
- ])?.data;
36
-
37
- if (invitation) {
38
- upsertInCache(['invitation', 'get', invitationId], { status: InvitationStatusEnum.Approved });
39
-
40
- fireEvent('local.invitation.updated', { invitations: [invitation] });
41
- }
42
-
43
- return data.success;
44
- };
45
- /* end_public_function */
@@ -1,44 +0,0 @@
1
- import { fireEvent } from '~/core/events';
2
- import { dropFromCache, pullFromCache } from '~/cache/api';
3
- import { getActiveClient } from '~/client/api/activeClient';
4
-
5
- /* begin_public_function
6
- id: invitation.cancel
7
- */
8
- /**
9
- * ```js
10
- * import { cancelInvitation } from '@amityco/ts-sdk'
11
- * const isCanceled = await cancelInvitation(invitationId)
12
- * ```
13
- *
14
- * Cancels a {@link Amity.Invitation} object
15
- *
16
- * @param invitationId the {@link Amity.Invitation} to cancel
17
- * @returns A success boolean if the {@link Amity.Invitation} was canceled
18
- *
19
- * @category Invitation API
20
- * @async
21
- */
22
- export const cancelInvitation = async (invitationId: Amity.Invitation['_id']): Promise<boolean> => {
23
- const client = getActiveClient();
24
- client.log('invitation/cancelInvitation', invitationId);
25
-
26
- const { data } = await client.http.delete<{ success: boolean }>(
27
- `/api/v1/invitations/${invitationId}`,
28
- );
29
-
30
- const invitation = pullFromCache<Amity.InternalInvitation>([
31
- 'invitation',
32
- 'get',
33
- invitationId,
34
- ])?.data;
35
-
36
- if (invitation) {
37
- dropFromCache(['invitation', 'get', invitationId]);
38
-
39
- fireEvent('local.invitation.deleted', { invitations: [invitation] });
40
- }
41
-
42
- return data.success;
43
- };
44
- /* end_public_function */