@amityco/ts-sdk 7.4.1-e8631ca7.0 → 7.4.1-fd0f791a.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 +4 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +2 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +16 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +28 -2
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/joinRequest.d.ts +53 -0
- package/dist/@types/domains/joinRequest.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/getCommunity.d.ts +1 -1
- package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/joinCommunity.d.ts +3 -0
- package/dist/communityRepository/api/joinCommunity.d.ts.map +1 -1
- package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts +16 -0
- package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts.map +1 -0
- package/dist/communityRepository/internalAPI/joinCommunity.d.ts +16 -0
- package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/events/index.d.ts +4 -0
- package/dist/communityRepository/joinRequest/events/index.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts +17 -0
- package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts +17 -0
- package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts +17 -0
- package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts +16 -0
- package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts +16 -0
- package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +1 -0
- package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts +16 -0
- package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts +14 -0
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts +9 -0
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts +15 -0
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequests/enum.d.ts +6 -0
- package/dist/communityRepository/observers/getJoinRequests/enum.d.ts.map +1 -0
- package/dist/communityRepository/observers/getJoinRequests.d.ts +12 -0
- package/dist/communityRepository/observers/getJoinRequests.d.ts.map +1 -0
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.d.ts.map +1 -1
- package/dist/communityRepository/utils/payload.d.ts +1 -0
- 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 +897 -389
- package/dist/index.esm.js +760 -252
- package/dist/index.umd.js +4 -4
- package/dist/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.d.ts.map +1 -1
- package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map +1 -1
- package/dist/subChannelRepository/utils/prepareSubChannelPayload.d.ts.map +1 -1
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +1 -1
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +1 -0
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/package.json +1 -1
- package/src/@types/core/events.ts +7 -1
- package/src/@types/core/model.ts +3 -0
- package/src/@types/core/payload.ts +22 -1
- package/src/@types/domains/community.ts +38 -2
- package/src/@types/domains/joinRequest.ts +66 -0
- package/src/@types/index.ts +1 -0
- package/src/communityRepository/api/getCommunity.ts +8 -0
- package/src/communityRepository/api/joinCommunity.ts +4 -1
- package/src/communityRepository/internalAPI/getMyJoinRequest.ts +43 -0
- package/src/communityRepository/internalAPI/joinCommunity.ts +51 -0
- package/src/communityRepository/joinRequest/events/index.ts +3 -0
- package/src/communityRepository/joinRequest/events/onJoinRequestCreated.ts +33 -0
- package/src/communityRepository/joinRequest/events/onJoinRequestDeleted.ts +33 -0
- package/src/communityRepository/joinRequest/events/onJoinRequestUpdated.ts +33 -0
- package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +52 -0
- package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +46 -0
- package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +52 -0
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts +126 -0
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +26 -0
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts +108 -0
- package/src/communityRepository/observers/getJoinRequests/enum.ts +5 -0
- package/src/communityRepository/observers/getJoinRequests.ts +44 -0
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +2 -1
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +2 -1
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +1 -0
- package/src/communityRepository/utils/communityWithMembership.ts +1 -1
- package/src/communityRepository/utils/payload.ts +27 -1
- package/src/core/model/idResolvers.ts +1 -0
- package/src/core/model/index.ts +1 -0
- package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +7 -1
- package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +7 -1
- package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +4 -0
- package/src/utils/linkedObject/communityLinkedObject.ts +22 -0
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/joinRequestLinkedObject.ts +31 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalPinnedPostQueryStreamController.d.ts","sourceRoot":"","sources":["../../../../src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAKpF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"GlobalPinnedPostQueryStreamController.d.ts","sourceRoot":"","sources":["../../../../src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAKpF,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAG3C,qBAAa,qCAAsC,SAAQ,qBAAqB,CAC9E,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,8BAA8B,CACrC;IACC,OAAO,CAAC,YAAY,CAAqD;IAEzE,OAAO,CAAC,cAAc,CAAoE;gBAGxF,KAAK,EAAE,KAAK,CAAC,8BAA8B,EAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,0BAA0B,KAAK,IAAI,EAChE,cAAc,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC,oBAAoB;IAQ7E,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB;IAcpD,mBAAmB,CACjB,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAC7D,SAAS,EAAE,KAAK,CAAC,2BAA2B,EAC5C,OAAO,UAAQ;IAuBjB,OAAO,CAAC,MAAM,EAAE,eAAe,UACf,MAAM,YAAY;IAgBlC,YAAY,CACV,gBAAgB,EAAE;QAChB,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,KAAK,IAAI,KAAK,KAAK,CAAC,YAAY,CAAC;QACxE,MAAM,EAAE,eAAe,CAAC;KACzB,EAAE;CAIN"}
|
package/dist/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinnedPostQueryStreamController.d.ts","sourceRoot":"","sources":["../../../../src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"PinnedPostQueryStreamController.d.ts","sourceRoot":"","sources":["../../../../src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAOpF,qBAAa,+BAAgC,SAAQ,qBAAqB,CACxE,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,wBAAwB,CAC/B;IACC,OAAO,CAAC,YAAY,CAAqD;IAEzE,OAAO,CAAC,cAAc,CAAoE;gBAGxF,KAAK,EAAE,KAAK,CAAC,wBAAwB,EACrC,QAAQ,EAAE,MAAM,EAAE,EAClB,YAAY,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,0BAA0B,KAAK,IAAI,EAChE,cAAc,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB,KAAK,KAAK,CAAC,oBAAoB;IAQ7E,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB;IAcpD,mBAAmB,CACjB,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAC7D,SAAS,EAAE,KAAK,CAAC,2BAA2B,EAC5C,OAAO,UAAQ;CAsBlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareSubChannelPayload.d.ts","sourceRoot":"","sources":["../../../src/subChannelRepository/utils/prepareSubChannelPayload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepareSubChannelPayload.d.ts","sourceRoot":"","sources":["../../../src/subChannelRepository/utils/prepareSubChannelPayload.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,gCAAgC,UAA6C,CAAC;AAE3F;;GAEG;AACH,eAAO,MAAM,oBAAoB,oBAAqB,KAAK,MAAM,aAAa,EAAE,aAAa,CAAC,YACtC,CAAC;AAEzD,eAAO,MAAM,wBAAwB,eAAgB,MAAM,iBAAiB,SAI3E,CAAC;AAEF,eAAO,MAAM,wBAAwB,eACvB,MAAM,iBAAiB,KAClC,QAAQ,MAAM,0BAA0B,CA+B1C,CAAC;AAEF,aAAK,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,0BAA0B,CAAC,GAAG;IACpF,yBAAyB,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,0BAA0B,CAAC,CAAC;CAChF,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,EACjC,wBAAwB,EACxB,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,gBAAgB,GAAG,mBAAmB,CAQ9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"communityLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/communityLinkedObject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"communityLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/communityLinkedObject.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,qBAAqB,cAAe,MAAM,iBAAiB,KAAG,MAAM,SAiDhF,CAAC"}
|
|
@@ -14,5 +14,6 @@ export declare const LinkedObject: {
|
|
|
14
14
|
notificationTray: (noti: Amity.RawNotificationTrayItem) => Amity.NotificationTrayItem;
|
|
15
15
|
community: (community: Amity.InternalCommunity) => Amity.Community;
|
|
16
16
|
invitation: (invitation: Amity.InternalInvitation) => Amity.Invitation;
|
|
17
|
+
joinRequest: (joinRequest: Amity.InternalJoinRequest) => Amity.JoinRequest;
|
|
17
18
|
};
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CAiBxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"joinRequestLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/joinRequestLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,gBACrB,MAAM,mBAAmB,KACrC,MAAM,WAsBR,CAAC"}
|
|
@@ -23,7 +23,7 @@ export declare const generateComment: (params?: Partial<Amity.InternalComment>)
|
|
|
23
23
|
referenceType: Amity.CommentReferenceType;
|
|
24
24
|
dataType?: any;
|
|
25
25
|
dataTypes?: any[] | undefined;
|
|
26
|
-
data?: string |
|
|
26
|
+
data?: string | Amity.ContentDataText | Amity.ContentDataFile | Amity.ContentDataImage | Amity.ContentDataVideo | Amity.ContentDataPoll | Record<string, unknown> | undefined;
|
|
27
27
|
metadata?: Record<string, any> | undefined;
|
|
28
28
|
flagCount: number;
|
|
29
29
|
hashFlag: {
|
package/package.json
CHANGED
|
@@ -188,7 +188,7 @@ declare global {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
type LocalCommunityEvents = {
|
|
191
|
-
'local.community.joined': Amity.CommunityMembershipPayload;
|
|
191
|
+
'local.community.joined': Amity.CommunityMembershipPayload; // v3 join community
|
|
192
192
|
'local.community.left': Amity.CommunityMembershipPayload;
|
|
193
193
|
'local.community.roleAdded': Amity.ProcessedCommunityPayload;
|
|
194
194
|
'local.community.roleRemoved': Amity.ProcessedCommunityPayload;
|
|
@@ -265,6 +265,12 @@ declare global {
|
|
|
265
265
|
'local.invitation.updated': Amity.InternalInvitation[];
|
|
266
266
|
'local.invitation.deleted': Amity.InternalInvitation[];
|
|
267
267
|
|
|
268
|
+
'local.community.join': Amity.InternalJoinRequest[]; // v4 join community with status
|
|
269
|
+
|
|
270
|
+
'local.joinRequest.created': Amity.InternalJoinRequest[];
|
|
271
|
+
'local.joinRequest.updated': Amity.InternalJoinRequest[];
|
|
272
|
+
'local.joinRequest.deleted': Amity.InternalJoinRequest[];
|
|
273
|
+
|
|
268
274
|
sessionStateChange: Amity.SessionStates;
|
|
269
275
|
// used by accessTokenExpiryWatcher
|
|
270
276
|
tokenExpired: Amity.SessionStates.TOKEN_EXPIRED;
|
package/src/@types/core/model.ts
CHANGED
|
@@ -62,6 +62,8 @@ declare global {
|
|
|
62
62
|
notificationTraySeen: Amity.InternalNotificationTraySeen;
|
|
63
63
|
|
|
64
64
|
invitation: Amity.InternalInvitation;
|
|
65
|
+
|
|
66
|
+
joinRequest: Amity.InternalJoinRequest;
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
type Model = ValueOf<Models>;
|
|
@@ -128,6 +130,7 @@ declare global {
|
|
|
128
130
|
notificationTraySeen: Pick<Amity.InternalNotificationTraySeen, 'userId'>;
|
|
129
131
|
|
|
130
132
|
invitation: Pick<Amity.InternalInvitation, '_id'>;
|
|
133
|
+
joinRequest: Pick<Amity.InternalJoinRequest, 'joinRequestId'>;
|
|
131
134
|
};
|
|
132
135
|
}
|
|
133
136
|
}
|
|
@@ -29,6 +29,7 @@ declare global {
|
|
|
29
29
|
notificationTrayItem: Amity.NotificationTrayPayload;
|
|
30
30
|
invitation: Amity.InvitationPayload;
|
|
31
31
|
myInvitation: Amity.MyInvitationsPayload;
|
|
32
|
+
joinRequest: Amity.CommunityJoinRequestPayload;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
type UserPayload = {
|
|
@@ -227,7 +228,7 @@ declare global {
|
|
|
227
228
|
type SubChannelPayload<T extends Amity.MessageContentType = any> = {
|
|
228
229
|
messageFeeds: Amity.RawSubChannel[];
|
|
229
230
|
messages: Amity.RawMessage<T>[];
|
|
230
|
-
users: Amity.
|
|
231
|
+
users: Amity.RawUser[];
|
|
231
232
|
files: Amity.File[];
|
|
232
233
|
};
|
|
233
234
|
|
|
@@ -299,6 +300,12 @@ declare global {
|
|
|
299
300
|
files: Amity.File[];
|
|
300
301
|
};
|
|
301
302
|
|
|
303
|
+
type CommunityJoinRequestPayload = {
|
|
304
|
+
joinRequests: Amity.RawJoinRequest[];
|
|
305
|
+
users: Amity.RawUser[];
|
|
306
|
+
files: Amity.File[];
|
|
307
|
+
};
|
|
308
|
+
|
|
302
309
|
type RecommendedCommunityPayload = Amity.CommunityPayload;
|
|
303
310
|
type TrendingCommunityPayload = Amity.CommunityPayload;
|
|
304
311
|
|
|
@@ -310,6 +317,16 @@ declare global {
|
|
|
310
317
|
type ProcessedCommunityPayload = Omit<CommunityPayload, 'communities' | 'communityUsers'> & {
|
|
311
318
|
communities: Amity.InternalCommunity[];
|
|
312
319
|
communityUsers: Amity.Membership<'community'>[];
|
|
320
|
+
users: Amity.InternalUser[];
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
type ProcessedJoinRequestPayload = Omit<
|
|
324
|
+
CommunityJoinRequestPayload,
|
|
325
|
+
'communities' | 'communityUsers' | 'joinRequests' | 'users'
|
|
326
|
+
> & {
|
|
327
|
+
joinRequests: Amity.InternalJoinRequest[];
|
|
328
|
+
files: Amity.File[];
|
|
329
|
+
users: Amity.InternalUser[];
|
|
313
330
|
};
|
|
314
331
|
|
|
315
332
|
type CategoryPayload = {
|
|
@@ -567,5 +584,9 @@ declare global {
|
|
|
567
584
|
invitations: Amity.InternalInvitation[];
|
|
568
585
|
users: Amity.InternalUser[];
|
|
569
586
|
};
|
|
587
|
+
|
|
588
|
+
type JoinRequestPayload = {
|
|
589
|
+
joinRequests: Amity.RawJoinRequest[];
|
|
590
|
+
};
|
|
570
591
|
}
|
|
571
592
|
}
|
|
@@ -96,8 +96,8 @@ declare global {
|
|
|
96
96
|
|
|
97
97
|
allowCommentInStory?: boolean;
|
|
98
98
|
|
|
99
|
-
isDiscoverable
|
|
100
|
-
requiresJoinApproval
|
|
99
|
+
isDiscoverable?: boolean;
|
|
100
|
+
requiresJoinApproval?: boolean;
|
|
101
101
|
} & Amity.Taggable &
|
|
102
102
|
Amity.Metadata &
|
|
103
103
|
Amity.Timestamps &
|
|
@@ -124,6 +124,16 @@ declare global {
|
|
|
124
124
|
limit?: number;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
type QueryJoinCommunity = {
|
|
128
|
+
communityId: string;
|
|
129
|
+
status: Amity.JoinRequestStatus;
|
|
130
|
+
sortBy?: Amity.CommunitySortBy | Amity.CommunitySortByEnum;
|
|
131
|
+
options?: {
|
|
132
|
+
limit?: number;
|
|
133
|
+
token?: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
127
137
|
type SearchQueryCommunities = {
|
|
128
138
|
displayName?: string;
|
|
129
139
|
membership?: 'all' | 'member' | 'notMember';
|
|
@@ -136,11 +146,26 @@ declare global {
|
|
|
136
146
|
includeDiscoverablePrivateCommunity?: boolean;
|
|
137
147
|
};
|
|
138
148
|
|
|
149
|
+
type QueryJoinRequest = {
|
|
150
|
+
communityId: string;
|
|
151
|
+
status: Amity.JoinRequestStatus;
|
|
152
|
+
targetType: 'community';
|
|
153
|
+
type: Amity.JoinRequestType;
|
|
154
|
+
sortBy?: Amity.CommunitySortBy | Amity.CommunitySortByEnum;
|
|
155
|
+
options?: {
|
|
156
|
+
limit?: number;
|
|
157
|
+
token?: string;
|
|
158
|
+
};
|
|
159
|
+
page?: string;
|
|
160
|
+
};
|
|
161
|
+
|
|
139
162
|
type CommunityLiveCollection = Amity.LiveCollectionParams<Omit<QueryCommunities, 'page'>>;
|
|
140
163
|
|
|
141
164
|
type RecommendedCommunityLiveCollection = Amity.LiveCollectionParams<{ limit?: number }>;
|
|
142
165
|
type TrendingCommunityLiveCollection = Amity.LiveCollectionParams<{ limit?: number }>;
|
|
143
166
|
|
|
167
|
+
type JoinRequestLiveCollection = Amity.LiveCollectionParams<QueryJoinRequest>;
|
|
168
|
+
|
|
144
169
|
type SearchCommunityLiveCollection = Amity.LiveCollectionParams<
|
|
145
170
|
Omit<SearchQueryCommunities, 'page'>
|
|
146
171
|
>;
|
|
@@ -158,6 +183,11 @@ declare global {
|
|
|
158
183
|
Pick<SearchQueryCommunities, 'page'>
|
|
159
184
|
>;
|
|
160
185
|
|
|
186
|
+
type JoinRequestLiveCollectionCache = Amity.LiveCollectionCache<
|
|
187
|
+
Amity.JoinRequest['joinRequestId'],
|
|
188
|
+
Pick<QueryJoinRequest, 'page'>
|
|
189
|
+
>;
|
|
190
|
+
|
|
161
191
|
type QueryCommunityMembers = {
|
|
162
192
|
communityId: string;
|
|
163
193
|
memberships?: ('banned' | 'member')[];
|
|
@@ -227,6 +257,12 @@ declare global {
|
|
|
227
257
|
callback: Amity.LiveCollectionCallback<Amity.Invitation>,
|
|
228
258
|
) => Amity.Unsubscriber;
|
|
229
259
|
getInvitation: () => Promise<Amity.Invitation | undefined>;
|
|
260
|
+
join: () => Promise<Amity.JoinResult>;
|
|
261
|
+
getJoinRequests: (
|
|
262
|
+
params: QueryJoinRequest,
|
|
263
|
+
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|
|
264
|
+
) => Amity.Unsubscriber;
|
|
265
|
+
getMyJoinRequest: () => Promise<Amity.JoinRequest | undefined>;
|
|
230
266
|
};
|
|
231
267
|
}
|
|
232
268
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
|
|
3
|
+
export const enum JoinRequestStatusEnum {
|
|
4
|
+
Pending = 'pending',
|
|
5
|
+
Approved = 'approved',
|
|
6
|
+
Rejected = 'rejected',
|
|
7
|
+
Cancelled = 'cancelled',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const enum JoinResultStatusEnum {
|
|
11
|
+
Success = 'success',
|
|
12
|
+
Pending = 'pending',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare global {
|
|
16
|
+
namespace Amity {
|
|
17
|
+
type JoinRequestStatus = JoinRequestStatusEnum;
|
|
18
|
+
|
|
19
|
+
type JoinResultStatus = JoinResultStatusEnum;
|
|
20
|
+
|
|
21
|
+
type JoinRequestType = 'communityJoinRequest';
|
|
22
|
+
|
|
23
|
+
type JoinResult = {
|
|
24
|
+
status: Amity.JoinResultStatus;
|
|
25
|
+
request?: Amity.JoinRequest;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type RawJoinRequest = {
|
|
29
|
+
_id: string;
|
|
30
|
+
createdAt: Amity.timestamp;
|
|
31
|
+
joinRequestId: string;
|
|
32
|
+
networkId: string;
|
|
33
|
+
|
|
34
|
+
requestorId: string;
|
|
35
|
+
requestorInternalId: string;
|
|
36
|
+
requestorPublicId: string;
|
|
37
|
+
|
|
38
|
+
respondedAt: Amity.timestamp | null;
|
|
39
|
+
responderId: string | null;
|
|
40
|
+
responderInternalId: string | null;
|
|
41
|
+
responderPublicId: string | null;
|
|
42
|
+
|
|
43
|
+
status: Amity.JoinRequestStatus;
|
|
44
|
+
targetId: string;
|
|
45
|
+
targetType: string;
|
|
46
|
+
type: Amity.JoinRequestType;
|
|
47
|
+
updatedAt: Amity.timestamp;
|
|
48
|
+
userId: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
type InternalJoinRequest = Omit<RawJoinRequest, '_id'>;
|
|
52
|
+
|
|
53
|
+
type JoinRequest = Omit<Amity.InternalJoinRequest, 'responderId'> &
|
|
54
|
+
Amity.JoinRequestLinkedObject & {
|
|
55
|
+
user?: Amity.User;
|
|
56
|
+
feeds?: Amity.Feed[];
|
|
57
|
+
files?: Amity.File[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type JoinRequestLinkedObject = {
|
|
61
|
+
cancel: () => Promise<void>;
|
|
62
|
+
approve: () => Promise<void>;
|
|
63
|
+
reject: () => Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/@types/index.ts
CHANGED
|
@@ -23,6 +23,8 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
23
23
|
*/
|
|
24
24
|
export const getCommunity = async (
|
|
25
25
|
communityId: Amity.Community['communityId'],
|
|
26
|
+
type?: Amity.JoinRequestType,
|
|
27
|
+
includeDiscoverablePrivateCommunity?: boolean,
|
|
26
28
|
): Promise<Amity.Cached<Amity.Community>> => {
|
|
27
29
|
const client = getActiveClient();
|
|
28
30
|
client.log('community/getCommunity', communityId);
|
|
@@ -30,6 +32,12 @@ export const getCommunity = async (
|
|
|
30
32
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
31
33
|
const { data: payload } = await client.http.get<Amity.CommunityPayload>(
|
|
32
34
|
`/api/v3/communities/${communityId}`,
|
|
35
|
+
{
|
|
36
|
+
params: {
|
|
37
|
+
type: 'communityJoinRequest',
|
|
38
|
+
includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity ?? true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
33
41
|
);
|
|
34
42
|
|
|
35
43
|
const data = prepareCommunityPayload(payload);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api';
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
2
|
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { prepareCommunityPayload } from '~/communityRepository/utils';
|
|
5
5
|
import { fireEvent } from '~/core/events';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated This function will to be deprecated and use the new community.join().
|
|
9
|
+
*/
|
|
7
10
|
/* begin_public_function
|
|
8
11
|
id: community.join
|
|
9
12
|
*/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
3
|
+
import { prepareCommunityJoinRequestPayload } from '~/communityRepository/utils';
|
|
4
|
+
import { joinRequestLinkedObject } from '~/utils/linkedObject/joinRequestLinkedObject';
|
|
5
|
+
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: community.getMyJoinRequest
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* ```js
|
|
11
|
+
* import { community } from '@amityco/ts-sdk'
|
|
12
|
+
* const isJoined = await community.getMyJoinRequest('foobar')
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Joins a {@link Amity.Community} object
|
|
16
|
+
*
|
|
17
|
+
* @param communityId the {@link Amity.Community} to join
|
|
18
|
+
* @returns A success boolean if the {@link Amity.Community} was joined
|
|
19
|
+
*
|
|
20
|
+
* @category Community API
|
|
21
|
+
* @async
|
|
22
|
+
*/
|
|
23
|
+
export const getMyJoinRequest = async (
|
|
24
|
+
communityId: Amity.Community['communityId'],
|
|
25
|
+
): Promise<Amity.Cached<Amity.JoinRequest | undefined>> => {
|
|
26
|
+
const client = getActiveClient();
|
|
27
|
+
client.log('community/myJoinRequest', communityId);
|
|
28
|
+
|
|
29
|
+
const { data: payload } = await client.http.get<Amity.CommunityJoinRequestPayload>(
|
|
30
|
+
`/api/v4/communities/${communityId}/join/me`,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
const data = prepareCommunityJoinRequestPayload(payload);
|
|
34
|
+
|
|
35
|
+
const cachedAt = client.cache && Date.now();
|
|
36
|
+
if (client.cache) ingestInCache(data, { cachedAt });
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
data: data.joinRequests[0] ? joinRequestLinkedObject(data.joinRequests[0]) : undefined,
|
|
40
|
+
cachedAt,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/* end_public_function */
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
3
|
+
import { prepareCommunityJoinRequestPayload } from '~/communityRepository/utils';
|
|
4
|
+
import { fireEvent } from '~/core/events';
|
|
5
|
+
import { JoinRequestStatusEnum, JoinResultStatusEnum } from '~/@types/domains/joinRequest';
|
|
6
|
+
import { joinRequestLinkedObject } from '~/utils/linkedObject/joinRequestLinkedObject';
|
|
7
|
+
|
|
8
|
+
/* begin_public_function
|
|
9
|
+
id: community.join
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* ```js
|
|
13
|
+
* import { community } from '@amityco/ts-sdk'
|
|
14
|
+
* const isJoined = await community.join('foobar')
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Joins a {@link Amity.Community} object
|
|
18
|
+
*
|
|
19
|
+
* @param communityId the {@link Amity.Community} to join
|
|
20
|
+
* @returns A status join result
|
|
21
|
+
*
|
|
22
|
+
* @category Community API
|
|
23
|
+
* @async
|
|
24
|
+
*/
|
|
25
|
+
export const joinRequest = async (
|
|
26
|
+
communityId: Amity.Community['communityId'],
|
|
27
|
+
): Promise<Amity.JoinResult> => {
|
|
28
|
+
const client = getActiveClient();
|
|
29
|
+
client.log('community/joinRequest', communityId);
|
|
30
|
+
|
|
31
|
+
const { data: payload } = await client.http.post<Amity.CommunityJoinRequestPayload>(
|
|
32
|
+
`/api/v4/communities/${communityId}/join`,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const data = prepareCommunityJoinRequestPayload(payload);
|
|
36
|
+
|
|
37
|
+
const cachedAt = client.cache && Date.now();
|
|
38
|
+
if (client.cache) ingestInCache(data, { cachedAt });
|
|
39
|
+
|
|
40
|
+
fireEvent('local.community.join', data.joinRequests);
|
|
41
|
+
|
|
42
|
+
const status =
|
|
43
|
+
data.joinRequests[0].status === JoinRequestStatusEnum.Approved
|
|
44
|
+
? JoinResultStatusEnum.Success
|
|
45
|
+
: JoinResultStatusEnum.Pending;
|
|
46
|
+
|
|
47
|
+
return status === JoinResultStatusEnum.Success
|
|
48
|
+
? { status }
|
|
49
|
+
: { status, request: joinRequestLinkedObject(data.joinRequests[0]) };
|
|
50
|
+
};
|
|
51
|
+
/* end_public_function */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
+
import { createEventSubscriber } from '~/core/events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ```js
|
|
6
|
+
* import { onJoinRequestCreated } from '@amityco/ts-sdk'
|
|
7
|
+
* const dispose = onJoinRequestCreated(data => {
|
|
8
|
+
* // ...
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Fired when an {@link Amity.CommunityJoinRequestPayload} 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 JoinRequest Events
|
|
18
|
+
*/
|
|
19
|
+
export const onJoinRequestCreated = (
|
|
20
|
+
callback: Amity.Listener<Amity.InternalJoinRequest[]>,
|
|
21
|
+
): Amity.Unsubscriber => {
|
|
22
|
+
const client = getActiveClient();
|
|
23
|
+
|
|
24
|
+
const disposers = [
|
|
25
|
+
createEventSubscriber(client, 'onJoinRequestCreated', 'local.joinRequest.created', 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 { onJoinRequestDeleted } from '@amityco/ts-sdk'
|
|
7
|
+
* const dispose = onJoinRequestDeleted(data => {
|
|
8
|
+
* // ...
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Fired when an {@link Amity.CommunityJoinRequestPayload} 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 JoinRequest Events
|
|
18
|
+
*/
|
|
19
|
+
export const onJoinRequestDeleted = (
|
|
20
|
+
callback: Amity.Listener<Amity.InternalJoinRequest[]>,
|
|
21
|
+
): Amity.Unsubscriber => {
|
|
22
|
+
const client = getActiveClient();
|
|
23
|
+
|
|
24
|
+
const disposers = [
|
|
25
|
+
createEventSubscriber(client, 'onJoinRequestDeleted', 'local.joinRequest.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 { onJoinRequestUpdated } from '@amityco/ts-sdk'
|
|
7
|
+
* const dispose = onJoinRequestUpdated(data => {
|
|
8
|
+
* // ...
|
|
9
|
+
* })
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Fired when an {@link Amity.CommunityJoinRequestPayload} 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 JoinRequest Events
|
|
18
|
+
*/
|
|
19
|
+
export const onJoinRequestUpdated = (
|
|
20
|
+
callback: Amity.Listener<Amity.InternalJoinRequest[]>,
|
|
21
|
+
): Amity.Unsubscriber => {
|
|
22
|
+
const client = getActiveClient();
|
|
23
|
+
|
|
24
|
+
const disposers = [
|
|
25
|
+
createEventSubscriber(client, 'onJoinRequestUpdated', 'local.joinRequest.updated', payload =>
|
|
26
|
+
callback(payload),
|
|
27
|
+
),
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
return () => {
|
|
31
|
+
disposers.forEach(fn => fn());
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { fireEvent } from '~/core/events';
|
|
2
|
+
import { getActiveClient } from '~/client/api/activeClient';
|
|
3
|
+
import { pullFromCache, upsertInCache } from '~/cache/api';
|
|
4
|
+
import { JoinRequestStatusEnum } from '~/@types/domains/joinRequest';
|
|
5
|
+
|
|
6
|
+
/* begin_public_function
|
|
7
|
+
id: joinRequest.approve
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* ```js
|
|
11
|
+
* import { joinRequest } from '@amityco/ts-sdk'
|
|
12
|
+
* const isAccepted = await joinRequest.approve()
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Accepts a {@link Amity.JoinRequest} object
|
|
16
|
+
*
|
|
17
|
+
* @param joinRequest the {@link Amity.JoinRequest} to accept
|
|
18
|
+
* @returns A success boolean if the {@link Amity.JoinRequest} was accepted
|
|
19
|
+
*
|
|
20
|
+
* @category Join Request API
|
|
21
|
+
* @async
|
|
22
|
+
*/
|
|
23
|
+
export const approveJoinRequest = async (
|
|
24
|
+
joinRequest: Amity.InternalJoinRequest,
|
|
25
|
+
): Promise<boolean> => {
|
|
26
|
+
const client = getActiveClient();
|
|
27
|
+
client.log('joinRequest/approveJoinRequest', joinRequest.joinRequestId);
|
|
28
|
+
|
|
29
|
+
const { data } = await client.http.post<{ success: boolean }>(
|
|
30
|
+
`/api/v4/communities/${joinRequest.targetId}/join/approve`,
|
|
31
|
+
{
|
|
32
|
+
userId: joinRequest.requestorInternalId,
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
|
|
37
|
+
'joinRequest',
|
|
38
|
+
'get',
|
|
39
|
+
joinRequest.joinRequestId,
|
|
40
|
+
])?.data;
|
|
41
|
+
|
|
42
|
+
if (joinRequestCache) {
|
|
43
|
+
upsertInCache(['joinRequest', 'get', joinRequest.joinRequestId], {
|
|
44
|
+
status: JoinRequestStatusEnum.Approved,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
fireEvent('local.joinRequest.updated', [joinRequestCache]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return data.success;
|
|
51
|
+
};
|
|
52
|
+
/* end_public_function */
|
|
@@ -0,0 +1,46 @@
|
|
|
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: joinRequest.cancel
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* ```js
|
|
10
|
+
* import { joinRequest } from '@amityco/ts-sdk'
|
|
11
|
+
* const isCanceled = await joinRequest.cancel()
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Cancels a {@link Amity.JoinRequest} object
|
|
15
|
+
*
|
|
16
|
+
* @param joinRequest the {@link Amity.JoinRequest} to cancel
|
|
17
|
+
* @returns A success boolean if the {@link Amity.JoinRequest} was canceled
|
|
18
|
+
*
|
|
19
|
+
* @category Join Request API
|
|
20
|
+
* @async
|
|
21
|
+
*/
|
|
22
|
+
export const cancelJoinRequest = async (
|
|
23
|
+
joinRequest: Amity.InternalJoinRequest,
|
|
24
|
+
): Promise<boolean> => {
|
|
25
|
+
const client = getActiveClient();
|
|
26
|
+
client.log('joinRequest/cancelJoinRequest', joinRequest.joinRequestId);
|
|
27
|
+
|
|
28
|
+
const { data } = await client.http.delete<{ success: boolean }>(
|
|
29
|
+
`/api/v4/communities/${joinRequest.targetId}/join`,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
|
|
33
|
+
'joinRequest',
|
|
34
|
+
'get',
|
|
35
|
+
joinRequest.joinRequestId,
|
|
36
|
+
])?.data;
|
|
37
|
+
|
|
38
|
+
if (joinRequestCache) {
|
|
39
|
+
dropFromCache(['joinRequest', 'get', joinRequest.joinRequestId]);
|
|
40
|
+
|
|
41
|
+
fireEvent('local.joinRequest.deleted', [joinRequestCache]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return data.success;
|
|
45
|
+
};
|
|
46
|
+
/* end_public_function */
|