@amityco/ts-sdk 7.5.2-aad2dac.0 → 7.5.3-5f273be.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/communityRepository/communityMembership/observers/getMembers/enums.d.ts +2 -1
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/enums.d.ts +1 -0
- package/dist/communityRepository/communityMembership/observers/searchMembers/enums.d.ts.map +1 -1
- package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +1 -1
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts +2 -2
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts +2 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/enums.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.d.ts.map +1 -1
- package/dist/index.cjs.js +34 -12
- package/dist/index.esm.js +34 -12
- package/dist/index.umd.js +2 -2
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +1 -0
- package/src/communityRepository/communityMembership/observers/searchMembers/enums.ts +1 -0
- package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +5 -2
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.ts +6 -1
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts +14 -10
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +6 -0
- package/src/communityRepository/observers/getRecommendedCommunities/enums.ts +1 -0
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +7 -0
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.ts +6 -0
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.ts +6 -0
|
@@ -18,7 +18,7 @@ export declare const generateComment: (params?: Partial<Amity.InternalComment>)
|
|
|
18
18
|
editedAt: string;
|
|
19
19
|
attachments?: Amity.Attachment[] | undefined;
|
|
20
20
|
targetId: string;
|
|
21
|
-
targetType: "
|
|
21
|
+
targetType: "user" | "community" | "content";
|
|
22
22
|
referenceId: string;
|
|
23
23
|
referenceType: Amity.CommentReferenceType;
|
|
24
24
|
dataType?: any;
|
|
@@ -28,21 +28,21 @@ export declare const emptyPostPayload: {
|
|
|
28
28
|
files: never[];
|
|
29
29
|
};
|
|
30
30
|
export declare const postQueryResponse: {
|
|
31
|
-
data: Omit<Amity.PostPayload<any>, "
|
|
31
|
+
data: Omit<Amity.PostPayload<any>, "communities" | "communityUsers" | "posts"> & {
|
|
32
32
|
posts: Amity.InternalPost<any>[];
|
|
33
33
|
communities: Amity.InternalCommunity[];
|
|
34
34
|
communityUsers: Amity.Membership<"community">[];
|
|
35
35
|
} & Amity.Pagination;
|
|
36
36
|
};
|
|
37
37
|
export declare const postQueryResponse2: {
|
|
38
|
-
data: Omit<Amity.PostPayload<any>, "
|
|
38
|
+
data: Omit<Amity.PostPayload<any>, "communities" | "communityUsers" | "posts"> & {
|
|
39
39
|
posts: Amity.InternalPost<any>[];
|
|
40
40
|
communities: Amity.InternalCommunity[];
|
|
41
41
|
communityUsers: Amity.Membership<"community">[];
|
|
42
42
|
} & Amity.Pagination;
|
|
43
43
|
};
|
|
44
44
|
export declare const postQueryResponsePage2: {
|
|
45
|
-
data: Omit<Amity.PostPayload<any>, "
|
|
45
|
+
data: Omit<Amity.PostPayload<any>, "communities" | "communityUsers" | "posts"> & {
|
|
46
46
|
posts: Amity.InternalPost<any>[];
|
|
47
47
|
communities: Amity.InternalCommunity[];
|
|
48
48
|
communityUsers: Amity.Membership<"community">[];
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export enum EnumCommunityMemberActions {
|
|
2
2
|
OnCommunityJoined = 'onCommunityJoined',
|
|
3
|
+
OnLocalCommunityJoin = 'onLocalCommunityJoin',
|
|
3
4
|
OnCommunityLeft = 'onCommunityLeft',
|
|
4
5
|
OnCommunityUserBanned = 'onCommunityUserBanned',
|
|
5
6
|
OnCommunityUserChanged = 'onCommunityUserChanged',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fireEvent } from '~/core/events';
|
|
2
|
-
import {
|
|
2
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
3
3
|
import { getActiveClient } from '~/client/api/activeClient';
|
|
4
|
+
import { JoinRequestStatusEnum } from '~/@types';
|
|
4
5
|
|
|
5
6
|
/* begin_public_function
|
|
6
7
|
id: joinRequest.cancel
|
|
@@ -36,7 +37,9 @@ export const cancelJoinRequest = async (
|
|
|
36
37
|
])?.data;
|
|
37
38
|
|
|
38
39
|
if (joinRequestCache) {
|
|
39
|
-
|
|
40
|
+
upsertInCache(['joinRequest', 'get', joinRequest.joinRequestId], {
|
|
41
|
+
status: JoinRequestStatusEnum.Cancelled,
|
|
42
|
+
});
|
|
40
43
|
|
|
41
44
|
fireEvent('local.joinRequest.deleted', [joinRequestCache]);
|
|
42
45
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
onJoinRequestDeleted,
|
|
14
14
|
onJoinRequestUpdated,
|
|
15
15
|
} from '~/communityRepository/joinRequest/events/';
|
|
16
|
+
import { onLocalCommunityJoin } from '~/communityRepository/communityMembership';
|
|
16
17
|
|
|
17
18
|
export class JoinRequestListLiveCollectionController extends LiveCollectionController<
|
|
18
19
|
'joinRequest',
|
|
@@ -75,7 +76,11 @@ export class JoinRequestListLiveCollectionController extends LiveCollectionContr
|
|
|
75
76
|
return this.queryStreamController.subscribeRTE([
|
|
76
77
|
{ fn: onJoinRequestCreated, action: EnumJoinRequestAction.OnLocalJoinRequestCreated },
|
|
77
78
|
{ fn: onJoinRequestUpdated, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
78
|
-
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction.
|
|
79
|
+
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
80
|
+
{
|
|
81
|
+
fn: onLocalCommunityJoin,
|
|
82
|
+
action: EnumJoinRequestAction.OnLocalJoinRequestUpdated,
|
|
83
|
+
},
|
|
79
84
|
]);
|
|
80
85
|
}
|
|
81
86
|
|
package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts
CHANGED
|
@@ -72,28 +72,30 @@ export class JoinRequestListQueryStreamController extends QueryStreamController<
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
reactor(action: EnumJoinRequestAction) {
|
|
75
|
-
return (joinRequest: Amity.InternalJoinRequest[]) => {
|
|
75
|
+
return (joinRequest: Amity.InternalJoinRequest[] | Amity.InternalJoinRequest) => {
|
|
76
76
|
const collection = pullFromCache<Amity.JoinRequestListLiveCollectionCache>(
|
|
77
77
|
this.cacheKey,
|
|
78
78
|
)?.data;
|
|
79
79
|
if (!collection) return;
|
|
80
80
|
|
|
81
|
+
const isArrayJoinRequest = Array.isArray(joinRequest);
|
|
82
|
+
|
|
83
|
+
const joinRequestIds = (isArrayJoinRequest ? joinRequest : [joinRequest]).map(
|
|
84
|
+
jr => jr.joinRequestId,
|
|
85
|
+
);
|
|
86
|
+
|
|
81
87
|
if (action === EnumJoinRequestAction.OnLocalJoinRequestUpdated) {
|
|
82
|
-
const isExist = collection.data.find(id => id
|
|
88
|
+
const isExist = collection.data.find(id => joinRequestIds.includes(id));
|
|
89
|
+
|
|
83
90
|
if (!isExist) return;
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
if (action === EnumJoinRequestAction.OnLocalJoinRequestCreated) {
|
|
87
|
-
collection.data = [
|
|
88
|
-
...new Set([
|
|
89
|
-
...joinRequest.map(joinRequest => joinRequest.joinRequestId),
|
|
90
|
-
...collection.data,
|
|
91
|
-
]),
|
|
92
|
-
];
|
|
94
|
+
collection.data = [...new Set([...joinRequestIds, ...collection.data])];
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
if (action === EnumJoinRequestAction.OnLocalJoinRequestDeleted) {
|
|
96
|
-
collection.data = collection.data.filter(id => id
|
|
98
|
+
collection.data = collection.data.filter(id => !joinRequestIds.includes(id));
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
pushToCache(this.cacheKey, collection);
|
|
@@ -103,7 +105,9 @@ export class JoinRequestListQueryStreamController extends QueryStreamController<
|
|
|
103
105
|
|
|
104
106
|
subscribeRTE(
|
|
105
107
|
createSubscriber: {
|
|
106
|
-
fn: (
|
|
108
|
+
fn: (
|
|
109
|
+
reactor: Amity.Listener<Amity.InternalJoinRequest[] | Amity.InternalJoinRequest>,
|
|
110
|
+
) => Amity.Unsubscriber;
|
|
107
111
|
action: EnumJoinRequestAction;
|
|
108
112
|
}[],
|
|
109
113
|
) {
|
|
@@ -13,9 +13,11 @@ import {
|
|
|
13
13
|
onLocalCommunityJoined,
|
|
14
14
|
onLocalCommunityLeft,
|
|
15
15
|
onCommunityUserChanged,
|
|
16
|
+
onLocalCommunityJoin,
|
|
16
17
|
} from '~/communityRepository/communityMembership';
|
|
17
18
|
import { isNonNullable } from '~/utils';
|
|
18
19
|
import { communityLinkedObject } from '~/utils/linkedObject/communityLinkedObject';
|
|
20
|
+
import { convertEventPayload } from '~/utils/event';
|
|
19
21
|
|
|
20
22
|
export class RecommendedCommunityLiveCollectionController extends LiveCollectionController<
|
|
21
23
|
'community',
|
|
@@ -82,6 +84,10 @@ export class RecommendedCommunityLiveCollectionController extends LiveCollection
|
|
|
82
84
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnMemberCountChanged },
|
|
83
85
|
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
|
|
84
86
|
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
|
|
87
|
+
{
|
|
88
|
+
fn: convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
89
|
+
action: EnumCommunityActions.OnCommunityUpdated,
|
|
90
|
+
},
|
|
85
91
|
]);
|
|
86
92
|
}
|
|
87
93
|
|
|
@@ -13,9 +13,12 @@ import {
|
|
|
13
13
|
onLocalCommunityJoined,
|
|
14
14
|
onLocalCommunityLeft,
|
|
15
15
|
onCommunityUserChanged,
|
|
16
|
+
onLocalCommunityJoin,
|
|
16
17
|
} from '~/communityRepository/communityMembership';
|
|
18
|
+
|
|
17
19
|
import { isNonNullable } from '~/utils';
|
|
18
20
|
import { communityLinkedObject } from '~/utils/linkedObject/communityLinkedObject';
|
|
21
|
+
import { convertEventPayload } from '~/utils/event';
|
|
19
22
|
|
|
20
23
|
export class TrendingCommunityLiveCollectionController extends LiveCollectionController<
|
|
21
24
|
'community',
|
|
@@ -82,6 +85,10 @@ export class TrendingCommunityLiveCollectionController extends LiveCollectionCon
|
|
|
82
85
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnMemberCountChanged },
|
|
83
86
|
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
|
|
84
87
|
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
|
|
88
|
+
{
|
|
89
|
+
fn: convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
90
|
+
action: EnumCommunityActions.OnCommunityUpdated,
|
|
91
|
+
},
|
|
85
92
|
]);
|
|
86
93
|
}
|
|
87
94
|
|
|
@@ -15,8 +15,10 @@ import {
|
|
|
15
15
|
onCommunityLeft,
|
|
16
16
|
onLocalCommunityLeft,
|
|
17
17
|
onCommunityUserChanged,
|
|
18
|
+
onLocalCommunityJoin,
|
|
18
19
|
} from '~/communityRepository/communityMembership';
|
|
19
20
|
import { isNonNullable } from '~/utils';
|
|
21
|
+
import { convertEventPayload } from '~/utils/event';
|
|
20
22
|
|
|
21
23
|
export class SearchCommunityLiveCollectionController extends LiveCollectionController<
|
|
22
24
|
'community',
|
|
@@ -81,6 +83,10 @@ export class SearchCommunityLiveCollectionController extends LiveCollectionContr
|
|
|
81
83
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnMemberCountChanged },
|
|
82
84
|
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
|
|
83
85
|
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
|
|
86
|
+
{
|
|
87
|
+
fn: convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
88
|
+
action: EnumCommunityActions.OnCommunityUpdated,
|
|
89
|
+
},
|
|
84
90
|
]);
|
|
85
91
|
}
|
|
86
92
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
onLocalCommunityJoined,
|
|
16
16
|
onLocalCommunityLeft,
|
|
17
17
|
onCommunityUserChanged,
|
|
18
|
+
onLocalCommunityJoin,
|
|
18
19
|
} from '~/communityRepository/communityMembership';
|
|
19
20
|
|
|
20
21
|
import { isNonNullable } from '~/utils';
|
|
@@ -24,6 +25,7 @@ import { prepareSemanticSearchCommunityPayload } from '~/communityRepository/uti
|
|
|
24
25
|
import { getActiveClient } from '~/client';
|
|
25
26
|
import { EnumCommunityMemberActions } from '~/communityRepository/communityMembership/observers/getMembers/enums';
|
|
26
27
|
import { filterByCommunityMembership } from '~/core/query';
|
|
28
|
+
import { convertEventPayload } from '~/utils/event';
|
|
27
29
|
|
|
28
30
|
export class SemanticSearchCommunityLiveCollectionController extends LiveCollectionController<
|
|
29
31
|
'semanticSearchCommunity',
|
|
@@ -94,6 +96,10 @@ export class SemanticSearchCommunityLiveCollectionController extends LiveCollect
|
|
|
94
96
|
{ fn: onCommunityUserChanged, action: EnumCommunityMemberActions.OnMemberCountChanged },
|
|
95
97
|
{ fn: onLocalCommunityJoined, action: EnumCommunityMemberActions.OnCommunityJoined },
|
|
96
98
|
{ fn: onLocalCommunityLeft, action: EnumCommunityMemberActions.OnCommunityLeft },
|
|
99
|
+
{
|
|
100
|
+
fn: convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
|
|
101
|
+
action: EnumCommunityActions.OnCommunityUpdated,
|
|
102
|
+
},
|
|
97
103
|
]);
|
|
98
104
|
}
|
|
99
105
|
|