@amityco/ts-sdk 7.4.1-b9f48528.0 → 7.4.1-d23fab2f.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.
- package/dist/@types/core/events.d.ts +3 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +3 -1
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +8 -4
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +5 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/invitation.d.ts +43 -0
- package/dist/@types/domains/invitation.d.ts.map +1 -0
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityJoined.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityLeft.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserBanned.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserChanged.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onCommunityUserUnbanned.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoined.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityLeft.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts +1 -1
- package/dist/communityRepository/communityMembership/events/onUserDeleted.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/utils.d.ts +2 -2
- package/dist/communityRepository/communityMembership/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.d.ts.map +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts +1 -1
- package/dist/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityCreated.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityCreated.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityDeleted.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityDeleted.d.ts.map +1 -1
- package/dist/communityRepository/events/onCommunityUpdated.d.ts +1 -1
- package/dist/communityRepository/events/onCommunityUpdated.d.ts.map +1 -1
- package/dist/communityRepository/events/utils.d.ts +1 -1
- package/dist/communityRepository/events/utils.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts +1 -1
- package/dist/communityRepository/utils/communityWithMembership.d.ts.map +1 -1
- package/dist/communityRepository/utils/payload.d.ts +1 -1
- package/dist/communityRepository/utils/payload.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +266 -51
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +248 -34
- package/dist/index.umd.js +4 -4
- package/dist/invitationRepository/events/index.d.ts +2 -0
- package/dist/invitationRepository/events/index.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +1 -0
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +17 -0
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +1 -0
- package/dist/invitationRepository/index.d.ts +2 -0
- package/dist/invitationRepository/index.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/cancelInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/cancelInvitation.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/createInvitations.d.ts +21 -0
- package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/index.d.ts +5 -0
- package/dist/invitationRepository/internalApi/index.d.ts.map +1 -0
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +16 -0
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +1 -0
- package/dist/utils/linkedObject/communityLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +2 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/@types/core/events.ts +4 -0
- package/src/@types/core/model.ts +5 -1
- package/src/@types/core/payload.ts +9 -4
- package/src/@types/domains/community.ts +10 -1
- package/src/@types/domains/invitation.ts +52 -0
- package/src/@types/index.ts +1 -0
- package/src/communityRepository/api/createCommunity.ts +2 -1
- package/src/communityRepository/api/getCommunities.ts +2 -1
- package/src/communityRepository/api/getCommunity.ts +4 -1
- package/src/communityRepository/api/getRecommendedCommunities.ts +2 -1
- package/src/communityRepository/api/getTrendingCommunities.ts +2 -1
- package/src/communityRepository/api/queryCommunities.ts +6 -1
- package/src/communityRepository/api/updateCommunity.ts +4 -1
- package/src/communityRepository/communityMembership/events/onCommunityJoined.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityLeft.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserBanned.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserChanged.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRoleAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserRoleRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onCommunityUserUnbanned.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityJoined.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityLeft.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserAdded.ts +1 -1
- package/src/communityRepository/communityMembership/events/onLocalCommunityUserRemoved.ts +1 -1
- package/src/communityRepository/communityMembership/events/onUserDeleted.ts +3 -1
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +8 -2
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +8 -2
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleAdded.ts +1 -1
- package/src/communityRepository/communityModeration/events/onLocalCommunityRoleRemoved.ts +1 -1
- package/src/communityRepository/events/onCommunityCreated.ts +1 -1
- package/src/communityRepository/events/onCommunityDeleted.ts +1 -1
- package/src/communityRepository/events/onCommunityUpdated.ts +1 -1
- package/src/communityRepository/events/utils.ts +1 -1
- package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
- package/src/communityRepository/utils/communityWithMembership.ts +8 -4
- package/src/communityRepository/utils/payload.ts +1 -1
- package/src/core/model/idResolvers.ts +2 -0
- package/src/core/model/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/invitationRepository/events/index.ts +1 -0
- package/src/invitationRepository/events/onLocalInvitationCreated.ts +33 -0
- package/src/invitationRepository/events/onLocalInvitationDeleted.ts +33 -0
- package/src/invitationRepository/events/onLocalInvitationUpdated.ts +33 -0
- package/src/invitationRepository/index.ts +1 -0
- package/src/invitationRepository/internalApi/acceptInvitation.ts +45 -0
- package/src/invitationRepository/internalApi/cancelInvitation.ts +44 -0
- package/src/invitationRepository/internalApi/createInvitations.ts +46 -0
- package/src/invitationRepository/internalApi/index.ts +4 -0
- package/src/invitationRepository/internalApi/rejectInvitation.ts +45 -0
- package/src/utils/linkedObject/communityLinkedObject.ts +16 -0
- package/src/utils/linkedObject/index.ts +4 -0
- package/src/utils/linkedObject/invitationLinkedObject.ts +20 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLocalCommunityMemberEventSubscriber } from './utils';
|
|
2
2
|
|
|
3
3
|
export const onLocalCommunityLeft = (
|
|
4
|
-
callback: (community: Amity.
|
|
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.
|
|
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.
|
|
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
|
-
(
|
|
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.
|
|
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.
|
|
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 (
|
|
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: (
|
|
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 (
|
|
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: (
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
10
|
+
callback: Amity.Listener<Amity.InternalCommunity>,
|
|
11
11
|
) => {
|
|
12
12
|
const client = getActiveClient();
|
|
13
13
|
|
package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class CommunitiesQueryStreamController extends QueryStreamController<
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
reactor(action: EnumCommunityActions | EnumCommunityMemberActions) {
|
|
63
|
-
return (community: Amity.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
31
|
+
communities: Amity.RawCommunity[],
|
|
32
32
|
communityUsers: Amity.Membership<'community'>[],
|
|
33
|
-
): Amity.
|
|
33
|
+
): Amity.InternalCommunity[] {
|
|
34
34
|
return communities.map(c => {
|
|
35
|
-
const cachedCommunity = pullFromCache<Amity.
|
|
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.
|
|
16
|
+
return communities.map<Amity.InternalCommunity>(
|
|
17
17
|
({ needApprovalOnPostCreation, onlyAdminCanPost, ...restCommunityPayload }) => ({
|
|
18
18
|
postSetting: getMatchPostSetting({
|
|
19
19
|
needApprovalOnPostCreation,
|
package/src/core/model/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './onLocalInvitationCreated';
|
|
@@ -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.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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './events';
|
|
@@ -0,0 +1,45 @@
|
|
|
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 */
|
|
@@ -0,0 +1,44 @@
|
|
|
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 */
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { fireEvent } from '~/core/events';
|
|
2
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
3
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
+
|
|
5
|
+
/* begin_public_function
|
|
6
|
+
id: invitation.createInvitations
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* ```js
|
|
10
|
+
* import { createInvitations } from '@amityco/ts-sdk'
|
|
11
|
+
* const created = await createInvitations({
|
|
12
|
+
* type: string,
|
|
13
|
+
* targetType: string,
|
|
14
|
+
* targetId: string,
|
|
15
|
+
* userIds: string[]
|
|
16
|
+
* }))
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Creates an {@link Amity.Invitation}
|
|
20
|
+
*
|
|
21
|
+
* @param bundle The data necessary to create a new {@link Amity.Invitation}
|
|
22
|
+
* @returns The newly created {@link Amity.Invitation}
|
|
23
|
+
*
|
|
24
|
+
* @category Invitation API
|
|
25
|
+
* @async
|
|
26
|
+
*/
|
|
27
|
+
export const createInvitations = async (
|
|
28
|
+
bundle: Amity.CreateInvitations,
|
|
29
|
+
): Promise<Amity.Cached<Amity.InternalInvitation[]>> => {
|
|
30
|
+
const client = getActiveClient();
|
|
31
|
+
client.log('invitation/createInvitations', bundle);
|
|
32
|
+
|
|
33
|
+
const { data } = await client.http.post<Amity.InvitationPayload>('/api/v1/invitations', bundle);
|
|
34
|
+
|
|
35
|
+
const cachedAt = client.cache && Date.now();
|
|
36
|
+
|
|
37
|
+
if (client.cache) ingestInCache(data, { cachedAt });
|
|
38
|
+
|
|
39
|
+
fireEvent('local.invitation.created', data);
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
data: data.invitations,
|
|
43
|
+
cachedAt,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/* end_public_function */
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { fireEvent } from '~/core/events';
|
|
2
|
+
import { InvitationStatusEnum } from '~/@types';
|
|
3
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
4
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
5
|
+
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: invitation.reject
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* ```js
|
|
11
|
+
* import { rejectInvitation } from '@amityco/ts-sdk'
|
|
12
|
+
* const isRejected = await rejectInvitation(invitationId)
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Rejects a {@link Amity.Invitation} object
|
|
16
|
+
*
|
|
17
|
+
* @param invitationId the {@link Amity.Invitation} to reject
|
|
18
|
+
* @returns A success boolean if the {@link Amity.Invitation} was rejected
|
|
19
|
+
*
|
|
20
|
+
* @category Invitation API
|
|
21
|
+
* @async
|
|
22
|
+
*/
|
|
23
|
+
export const rejectInvitation = async (invitationId: Amity.Invitation['_id']): Promise<boolean> => {
|
|
24
|
+
const client = getActiveClient();
|
|
25
|
+
client.log('invitation/rejectInvitation', invitationId);
|
|
26
|
+
|
|
27
|
+
const { data } = await client.http.post<{ success: boolean }>(
|
|
28
|
+
`/api/v1/invitations/${invitationId}/reject`,
|
|
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.Rejected });
|
|
39
|
+
|
|
40
|
+
fireEvent('local.invitation.updated', { invitations: [invitation] });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return data.success;
|
|
44
|
+
};
|
|
45
|
+
/* end_public_function */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InvitationTypeEnum } from '~/@types';
|
|
2
|
+
import { createInvitations } from '~/invitationRepository/internalApi';
|
|
3
|
+
|
|
4
|
+
export const communityLinkedObject = (community: Amity.RawCommunity): Amity.Community => {
|
|
5
|
+
return {
|
|
6
|
+
...community,
|
|
7
|
+
createInvitations: async (userIds: string[]): Promise<void> => {
|
|
8
|
+
await createInvitations({
|
|
9
|
+
type: InvitationTypeEnum.CommunityMemberInvite,
|
|
10
|
+
targetType: 'community',
|
|
11
|
+
targetId: community.communityId,
|
|
12
|
+
userIds,
|
|
13
|
+
});
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
};
|
|
@@ -11,6 +11,8 @@ 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';
|
|
14
16
|
|
|
15
17
|
export const LinkedObject = {
|
|
16
18
|
ad: adLinkedObject,
|
|
@@ -26,4 +28,6 @@ export const LinkedObject = {
|
|
|
26
28
|
channel: channelLinkedObject,
|
|
27
29
|
pinnedPost: pinnedPostLinkedObject,
|
|
28
30
|
notificationTray: notificationTrayLinkedObject,
|
|
31
|
+
community: communityLinkedObject,
|
|
32
|
+
invitation: invitationLinkedObject,
|
|
29
33
|
};
|