@amityco/ts-sdk 7.5.2-4215b84.0 → 7.5.2
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/.env +26 -26
- package/dist/@types/core/events.d.ts +0 -7
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +1 -5
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +5 -38
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts +0 -10
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +1 -51
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/notification.d.ts +2 -4
- package/dist/@types/domains/notification.d.ts.map +1 -1
- package/dist/@types/index.d.ts +0 -3
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/communityRepository/api/createCommunity.d.ts +2 -2
- package/dist/communityRepository/api/createCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/getCommunities.d.ts +1 -1
- package/dist/communityRepository/api/getCommunities.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/getRecommendedCommunities.d.ts +1 -3
- package/dist/communityRepository/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/getTrendingCommunities.d.ts +1 -3
- package/dist/communityRepository/api/getTrendingCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/joinCommunity.d.ts +0 -3
- package/dist/communityRepository/api/joinCommunity.d.ts.map +1 -1
- package/dist/communityRepository/api/queryCommunities.d.ts.map +1 -1
- package/dist/communityRepository/api/updateCommunity.d.ts +2 -2
- package/dist/communityRepository/api/updateCommunity.d.ts.map +1 -1
- package/dist/communityRepository/communityMembership/events/index.d.ts +0 -1
- package/dist/communityRepository/communityMembership/events/index.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/getMembers/enums.d.ts +1 -2
- package/dist/communityRepository/communityMembership/observers/getMembers/enums.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/communityMembership/observers/searchMembers/enums.d.ts +0 -1
- package/dist/communityRepository/communityMembership/observers/searchMembers/enums.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/CommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getCommunities/CommunitiesPaginationController.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/getCommunity.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.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/getRecommendedCommunities/enums.d.ts +1 -2
- 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/getTrendingCommunities/TrendingCommunitiesPaginationController.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/index.d.ts +0 -1
- package/dist/communityRepository/observers/index.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.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/SemanticSearchCommunityLiveCollectionController.d.ts.map +1 -1
- package/dist/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.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 -2
- 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 +1399 -2860
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1665 -3125
- 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/index.d.ts +0 -3
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/@types/core/events.ts +0 -10
- package/src/@types/core/model.ts +1 -8
- package/src/@types/core/payload.ts +5 -48
- package/src/@types/domains/client.ts +0 -12
- package/src/@types/domains/community.ts +3 -82
- package/src/@types/domains/notification.ts +0 -2
- package/src/@types/index.ts +0 -3
- package/src/communityRepository/api/createCommunity.ts +2 -5
- package/src/communityRepository/api/getCommunities.ts +2 -9
- package/src/communityRepository/api/getCommunity.ts +2 -13
- package/src/communityRepository/api/getRecommendedCommunities.ts +4 -11
- package/src/communityRepository/api/getTrendingCommunities.ts +4 -11
- package/src/communityRepository/api/joinCommunity.ts +1 -4
- package/src/communityRepository/api/queryCommunities.ts +1 -7
- package/src/communityRepository/api/updateCommunity.ts +3 -13
- package/src/communityRepository/communityMembership/events/index.ts +0 -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 +1 -3
- package/src/communityRepository/communityMembership/events/utils.ts +2 -2
- package/src/communityRepository/communityMembership/observers/getMembers/CommunityMembersQueryStreamController.ts +2 -8
- package/src/communityRepository/communityMembership/observers/getMembers/enums.ts +0 -1
- package/src/communityRepository/communityMembership/observers/searchMembers/SearchCommunityMembersQueryStreamController.ts +2 -8
- package/src/communityRepository/communityMembership/observers/searchMembers/enums.ts +0 -1
- 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/CommunitiesLiveCollectionController.ts +0 -6
- package/src/communityRepository/observers/getCommunities/CommunitiesPaginationController.ts +0 -1
- package/src/communityRepository/observers/getCommunities/CommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getCommunity.ts +0 -3
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesLiveCollectionController.ts +1 -8
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesPaginationController.ts +1 -6
- package/src/communityRepository/observers/getRecommendedCommunities/RecommendedCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/getRecommendedCommunities/enums.ts +0 -1
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesLiveCollectionController.ts +1 -9
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesPaginationController.ts +1 -6
- package/src/communityRepository/observers/getTrendingCommunities/TrendingCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/index.ts +0 -1
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesLiveCollectionController.ts +0 -6
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesPaginationController.ts +0 -1
- package/src/communityRepository/observers/searchCommunities/SearchCommunitiesQueryStreamController.ts +2 -2
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityLiveCollectionController.ts +0 -6
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityPaginationController.ts +0 -1
- package/src/communityRepository/observers/semanticSearch/SemanticSearchCommunityQueryStreamController.ts +2 -2
- package/src/communityRepository/utils/communityWithMembership.ts +5 -9
- package/src/communityRepository/utils/payload.ts +2 -28
- package/src/core/liveCollection/PaginationController.ts +1 -1
- package/src/core/liveCollection/PaginationNoPageController.ts +1 -1
- package/src/core/model/idResolvers.ts +0 -3
- package/src/core/model/index.ts +0 -3
- package/src/index.ts +0 -2
- package/src/messagePreview/utils/getChannelMessagePreviewWithUser.ts +3 -3
- package/src/postRepository/observers/getGlobalPinnedPosts/GlobalPinnedPostQueryStreamController.ts +1 -7
- package/src/postRepository/observers/getPinnedPosts/PinnedPostQueryStreamController.ts +1 -7
- package/src/subChannelRepository/utils/prepareSubChannelPayload.ts +0 -4
- package/src/utils/linkedObject/index.ts +0 -6
- package/dist/@types/domains/invitation.d.ts +0 -92
- package/dist/@types/domains/invitation.d.ts.map +0 -1
- package/dist/@types/domains/joinRequest.d.ts +0 -53
- package/dist/@types/domains/joinRequest.d.ts.map +0 -1
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts +0 -2
- package/dist/communityRepository/communityMembership/events/onLocalCommunityJoin.d.ts.map +0 -1
- package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts +0 -16
- package/dist/communityRepository/internalAPI/getMyJoinRequest.d.ts.map +0 -1
- package/dist/communityRepository/internalAPI/joinCommunity.d.ts +0 -16
- package/dist/communityRepository/internalAPI/joinCommunity.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/events/index.d.ts +0 -4
- package/dist/communityRepository/joinRequest/events/index.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts +0 -17
- package/dist/communityRepository/joinRequest/events/onJoinRequestCreated.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts +0 -17
- package/dist/communityRepository/joinRequest/events/onJoinRequestDeleted.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts +0 -17
- package/dist/communityRepository/joinRequest/events/onJoinRequestUpdated.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts +0 -16
- package/dist/communityRepository/joinRequest/internalAPI/approveJoinRequest.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts +0 -16
- package/dist/communityRepository/joinRequest/internalAPI/cancelJoinRequest.d.ts.map +0 -1
- package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts +0 -16
- package/dist/communityRepository/joinRequest/internalAPI/rejectJoinRequest.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts +0 -14
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts +0 -9
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts +0 -15
- package/dist/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts +0 -6
- package/dist/communityRepository/observers/getJoinRequestList/enum.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequestList.d.ts +0 -12
- package/dist/communityRepository/observers/getJoinRequestList.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts +0 -14
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts +0 -9
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts +0 -15
- package/dist/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequests/enum.d.ts +0 -6
- package/dist/communityRepository/observers/getJoinRequests/enum.d.ts.map +0 -1
- package/dist/communityRepository/observers/getJoinRequests.d.ts +0 -12
- package/dist/communityRepository/observers/getJoinRequests.d.ts.map +0 -1
- package/dist/invitationRepository/events/index.d.ts +0 -4
- package/dist/invitationRepository/events/index.d.ts.map +0 -1
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts +0 -17
- package/dist/invitationRepository/events/onLocalInvitationCreated.d.ts.map +0 -1
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts +0 -17
- package/dist/invitationRepository/events/onLocalInvitationDeleted.d.ts.map +0 -1
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts +0 -17
- package/dist/invitationRepository/events/onLocalInvitationUpdated.d.ts.map +0 -1
- package/dist/invitationRepository/index.d.ts +0 -3
- package/dist/invitationRepository/index.d.ts.map +0 -1
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts +0 -16
- package/dist/invitationRepository/internalApi/acceptInvitation.d.ts.map +0 -1
- package/dist/invitationRepository/internalApi/createInvitations.d.ts +0 -21
- package/dist/invitationRepository/internalApi/createInvitations.d.ts.map +0 -1
- package/dist/invitationRepository/internalApi/getInvitation.d.ts +0 -17
- package/dist/invitationRepository/internalApi/getInvitation.d.ts.map +0 -1
- package/dist/invitationRepository/internalApi/index.d.ts +0 -4
- package/dist/invitationRepository/internalApi/index.d.ts.map +0 -1
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts +0 -16
- package/dist/invitationRepository/internalApi/rejectInvitation.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts +0 -14
- package/dist/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts +0 -5
- package/dist/invitationRepository/observers/getInvitations/InvitationsPaginationController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts +0 -15
- package/dist/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts +0 -6
- package/dist/invitationRepository/observers/getInvitations/enums.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getInvitations.d.ts +0 -12
- package/dist/invitationRepository/observers/getInvitations.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts +0 -12
- package/dist/invitationRepository/observers/getMyCommunityInvitations.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts +0 -14
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts +0 -5
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts +0 -15
- package/dist/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.d.ts.map +0 -1
- package/dist/invitationRepository/observers/index.d.ts +0 -2
- package/dist/invitationRepository/observers/index.d.ts.map +0 -1
- package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts +0 -2
- package/dist/invitationRepository/utils/convertRawInvitationToInternalInvitation.d.ts.map +0 -1
- package/dist/invitationRepository/utils/index.d.ts +0 -2
- package/dist/invitationRepository/utils/index.d.ts.map +0 -1
- package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts +0 -2
- package/dist/invitationRepository/utils/prepareInvitationPayload.d.ts.map +0 -1
- package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts +0 -2
- package/dist/invitationRepository/utils/prepareMyInvitationsPayload.d.ts.map +0 -1
- package/dist/utils/linkedObject/communityLinkedObject.d.ts +0 -2
- package/dist/utils/linkedObject/communityLinkedObject.d.ts.map +0 -1
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts +0 -2
- package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +0 -1
- package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts +0 -2
- package/dist/utils/linkedObject/joinRequestLinkedObject.d.ts.map +0 -1
- package/src/@types/domains/invitation.ts +0 -119
- package/src/@types/domains/joinRequest.ts +0 -66
- package/src/communityRepository/communityMembership/events/onLocalCommunityJoin.ts +0 -20
- package/src/communityRepository/internalAPI/getMyJoinRequest.ts +0 -43
- package/src/communityRepository/internalAPI/joinCommunity.ts +0 -66
- package/src/communityRepository/joinRequest/events/index.ts +0 -3
- package/src/communityRepository/joinRequest/events/onJoinRequestCreated.ts +0 -33
- package/src/communityRepository/joinRequest/events/onJoinRequestDeleted.ts +0 -33
- package/src/communityRepository/joinRequest/events/onJoinRequestUpdated.ts +0 -33
- package/src/communityRepository/joinRequest/internalAPI/approveJoinRequest.ts +0 -52
- package/src/communityRepository/joinRequest/internalAPI/cancelJoinRequest.ts +0 -49
- package/src/communityRepository/joinRequest/internalAPI/rejectJoinRequest.ts +0 -52
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListLiveCollectionController.ts +0 -135
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.ts +0 -30
- package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts +0 -116
- package/src/communityRepository/observers/getJoinRequestList/enum.ts +0 -5
- package/src/communityRepository/observers/getJoinRequestList.ts +0 -51
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts +0 -126
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +0 -26
- package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts +0 -108
- package/src/communityRepository/observers/getJoinRequests/enum.ts +0 -5
- package/src/communityRepository/observers/getJoinRequests.ts +0 -44
- package/src/invitationRepository/events/index.ts +0 -3
- package/src/invitationRepository/events/onLocalInvitationCreated.ts +0 -33
- package/src/invitationRepository/events/onLocalInvitationDeleted.ts +0 -33
- package/src/invitationRepository/events/onLocalInvitationUpdated.ts +0 -33
- package/src/invitationRepository/index.ts +0 -2
- package/src/invitationRepository/internalApi/acceptInvitation.ts +0 -45
- package/src/invitationRepository/internalApi/createInvitations.ts +0 -52
- package/src/invitationRepository/internalApi/getInvitation.ts +0 -47
- package/src/invitationRepository/internalApi/index.ts +0 -3
- package/src/invitationRepository/internalApi/rejectInvitation.ts +0 -45
- package/src/invitationRepository/observers/getInvitations/InvitationsLiveCollectionController.ts +0 -148
- package/src/invitationRepository/observers/getInvitations/InvitationsPaginationController.ts +0 -19
- package/src/invitationRepository/observers/getInvitations/InvitationsQueryStreamController.ts +0 -97
- package/src/invitationRepository/observers/getInvitations/enums.ts +0 -5
- package/src/invitationRepository/observers/getInvitations.ts +0 -44
- package/src/invitationRepository/observers/getMyCommunityInvitations.ts +0 -48
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsLiveCollectionController.ts +0 -148
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsPaginationController.ts +0 -22
- package/src/invitationRepository/observers/getMyInvitations/MyInvitationsQueryStreamController.ts +0 -105
- package/src/invitationRepository/observers/index.ts +0 -1
- package/src/invitationRepository/utils/convertRawInvitationToInternalInvitation.ts +0 -8
- package/src/invitationRepository/utils/index.ts +0 -1
- package/src/invitationRepository/utils/prepareInvitationPayload.ts +0 -12
- package/src/invitationRepository/utils/prepareMyInvitationsPayload.ts +0 -12
- package/src/utils/linkedObject/communityLinkedObject.ts +0 -57
- package/src/utils/linkedObject/invitationLinkedObject.ts +0 -37
- package/src/utils/linkedObject/joinRequestLinkedObject.ts +0 -31
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import hash from 'object-hash';
|
|
2
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
-
import { JoinRequestListPaginationController } from './JoinRequestListPaginationController';
|
|
4
|
-
import { JoinRequestListQueryStreamController } from './JoinRequestListQueryStreamController';
|
|
5
|
-
import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
|
|
6
|
-
import { sortByFirstCreated, sortByLastCreated } from '~/core/query';
|
|
7
|
-
import { prepareCommunityJoinRequestPayload } from '~/communityRepository/utils';
|
|
8
|
-
import { EnumJoinRequestAction } from './enum';
|
|
9
|
-
import { isNonNullable } from '~/utils';
|
|
10
|
-
import { joinRequestLinkedObject } from '~/utils/linkedObject/joinRequestLinkedObject';
|
|
11
|
-
import {
|
|
12
|
-
onJoinRequestCreated,
|
|
13
|
-
onJoinRequestDeleted,
|
|
14
|
-
onJoinRequestUpdated,
|
|
15
|
-
} from '~/communityRepository/joinRequest/events/';
|
|
16
|
-
import { onLocalCommunityJoin } from '~/communityRepository/communityMembership';
|
|
17
|
-
|
|
18
|
-
export class JoinRequestListLiveCollectionController extends LiveCollectionController<
|
|
19
|
-
'joinRequest',
|
|
20
|
-
Amity.JoinRequestListLiveCollection,
|
|
21
|
-
Amity.JoinRequest,
|
|
22
|
-
JoinRequestListPaginationController
|
|
23
|
-
> {
|
|
24
|
-
private queryStreamController: JoinRequestListQueryStreamController;
|
|
25
|
-
|
|
26
|
-
private query: Amity.JoinRequestListLiveCollection;
|
|
27
|
-
|
|
28
|
-
constructor(
|
|
29
|
-
query: Amity.JoinRequestListLiveCollection,
|
|
30
|
-
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|
|
31
|
-
) {
|
|
32
|
-
const queryStreamId = hash(query);
|
|
33
|
-
const cacheKey = ['joinRequestList', 'collection', queryStreamId];
|
|
34
|
-
const paginationController = new JoinRequestListPaginationController(query);
|
|
35
|
-
|
|
36
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
37
|
-
|
|
38
|
-
this.query = query;
|
|
39
|
-
this.queryStreamController = new JoinRequestListQueryStreamController(
|
|
40
|
-
this.query,
|
|
41
|
-
this.cacheKey,
|
|
42
|
-
this.notifyChange.bind(this),
|
|
43
|
-
prepareCommunityJoinRequestPayload,
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
this.callback = callback.bind(this);
|
|
47
|
-
this.loadPage({ initial: true });
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected setup() {
|
|
51
|
-
const collection = pullFromCache<Amity.JoinRequestListLiveCollectionCache>(this.cacheKey)?.data;
|
|
52
|
-
|
|
53
|
-
if (!collection) {
|
|
54
|
-
pushToCache(this.cacheKey, {
|
|
55
|
-
data: [],
|
|
56
|
-
params: this.query,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
protected async persistModel(queryPayload: Amity.CommunityJoinRequestPayload & Amity.Pagination) {
|
|
62
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
protected persistQueryStream({
|
|
66
|
-
response,
|
|
67
|
-
direction,
|
|
68
|
-
refresh,
|
|
69
|
-
}: Amity.LiveCollectionPersistQueryStreamParams<'joinRequest'>) {
|
|
70
|
-
const joinRequestResponse = response as unknown as Amity.CommunityJoinRequestPayload &
|
|
71
|
-
Partial<Amity.Pagination>;
|
|
72
|
-
this.queryStreamController.appendToQueryStream(joinRequestResponse, direction, refresh);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
startSubscription() {
|
|
76
|
-
return this.queryStreamController.subscribeRTE([
|
|
77
|
-
{ fn: onJoinRequestCreated, action: EnumJoinRequestAction.OnLocalJoinRequestCreated },
|
|
78
|
-
{ fn: onJoinRequestUpdated, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
79
|
-
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
80
|
-
{
|
|
81
|
-
fn: onLocalCommunityJoin,
|
|
82
|
-
action: EnumJoinRequestAction.OnLocalJoinRequestUpdated,
|
|
83
|
-
},
|
|
84
|
-
]);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
|
|
88
|
-
const collection = pullFromCache<Amity.JoinRequestListLiveCollectionCache>(this.cacheKey)?.data;
|
|
89
|
-
|
|
90
|
-
if (!collection) return;
|
|
91
|
-
|
|
92
|
-
const data = this.applyFilter(
|
|
93
|
-
collection.data
|
|
94
|
-
.map(id => pullFromCache<Amity.InternalJoinRequest>(['joinRequest', 'get', id])!)
|
|
95
|
-
.filter(isNonNullable)
|
|
96
|
-
.map(({ data }) => data)
|
|
97
|
-
.map(joinRequestLinkedObject),
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
101
|
-
|
|
102
|
-
this.callback({
|
|
103
|
-
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
104
|
-
data,
|
|
105
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
106
|
-
loading,
|
|
107
|
-
error,
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
applyFilter(data: Amity.JoinRequest[]) {
|
|
112
|
-
let joinRequest = data;
|
|
113
|
-
|
|
114
|
-
if (this.query.communityIds && this.query.communityIds.length > 0) {
|
|
115
|
-
joinRequest = joinRequest.filter(joinRequest =>
|
|
116
|
-
this.query.communityIds.some(id => id === joinRequest.targetId),
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const sortFn = (() => {
|
|
121
|
-
switch (this.query.sortBy) {
|
|
122
|
-
case 'firstCreated':
|
|
123
|
-
return sortByFirstCreated;
|
|
124
|
-
case 'lastCreated':
|
|
125
|
-
return sortByLastCreated;
|
|
126
|
-
default:
|
|
127
|
-
return sortByLastCreated;
|
|
128
|
-
}
|
|
129
|
-
})();
|
|
130
|
-
|
|
131
|
-
joinRequest = joinRequest.sort(sortFn);
|
|
132
|
-
|
|
133
|
-
return joinRequest;
|
|
134
|
-
}
|
|
135
|
-
}
|
package/src/communityRepository/observers/getJoinRequestList/JoinRequestListPaginationController.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { PaginationController } from '~/core/liveCollection/PaginationController';
|
|
2
|
-
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
6
|
-
* TODO: check if querybyIds is supported
|
|
7
|
-
*/
|
|
8
|
-
export class JoinRequestListPaginationController extends PaginationController<
|
|
9
|
-
'joinRequest',
|
|
10
|
-
Amity.JoinRequestListLiveCollection
|
|
11
|
-
> {
|
|
12
|
-
async getRequest(queryParams: Amity.JoinRequestListLiveCollection, token: string | undefined) {
|
|
13
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityIds, ...params } = queryParams;
|
|
14
|
-
const options = token ? { token } : { limit };
|
|
15
|
-
|
|
16
|
-
const encodedChannelIds = communityIds.map(communityId => encodeURIComponent(communityId));
|
|
17
|
-
|
|
18
|
-
const { data: queryResponse } = await this.http.get<
|
|
19
|
-
Amity.CommunityJoinRequestPayload & Amity.Pagination
|
|
20
|
-
>(`/api/v4/communities/join/requests`, {
|
|
21
|
-
params: {
|
|
22
|
-
...params,
|
|
23
|
-
options,
|
|
24
|
-
communityIds: encodedChannelIds,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return queryResponse;
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/communityRepository/observers/getJoinRequestList/JoinRequestListQueryStreamController.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
|
|
2
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
-
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
-
import { getResolver } from '~/core/model';
|
|
5
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
6
|
-
import { EnumJoinRequestAction } from './enum';
|
|
7
|
-
|
|
8
|
-
export class JoinRequestListQueryStreamController extends QueryStreamController<
|
|
9
|
-
Amity.CommunityJoinRequestPayload,
|
|
10
|
-
Amity.JoinRequestListLiveCollection
|
|
11
|
-
> {
|
|
12
|
-
private notifyChange: (params: Amity.LiveCollectionNotifyParams) => void;
|
|
13
|
-
|
|
14
|
-
private preparePayload: (
|
|
15
|
-
response: Amity.CommunityJoinRequestPayload,
|
|
16
|
-
) => Amity.ProcessedJoinRequestPayload;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
query: Amity.JoinRequestListLiveCollection,
|
|
20
|
-
cacheKey: string[],
|
|
21
|
-
notifyChange: (params: Amity.LiveCollectionNotifyParams) => void,
|
|
22
|
-
preparePayload: (
|
|
23
|
-
response: Amity.CommunityJoinRequestPayload,
|
|
24
|
-
) => Amity.ProcessedJoinRequestPayload,
|
|
25
|
-
) {
|
|
26
|
-
super(query, cacheKey);
|
|
27
|
-
this.notifyChange = notifyChange;
|
|
28
|
-
this.preparePayload = preparePayload;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async saveToMainDB(response: Amity.CommunityJoinRequestPayload) {
|
|
32
|
-
const processedPayload = await this.preparePayload(response);
|
|
33
|
-
|
|
34
|
-
const client = getActiveClient();
|
|
35
|
-
const cachedAt = client.cache && Date.now();
|
|
36
|
-
|
|
37
|
-
if (client.cache) {
|
|
38
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
appendToQueryStream(
|
|
43
|
-
response: Amity.CommunityJoinRequestPayload & Partial<Amity.Pagination>,
|
|
44
|
-
direction: Amity.LiveCollectionPageDirection,
|
|
45
|
-
refresh = false,
|
|
46
|
-
) {
|
|
47
|
-
if (refresh) {
|
|
48
|
-
pushToCache(this.cacheKey, {
|
|
49
|
-
data: response.joinRequests.map(joinRequest =>
|
|
50
|
-
getResolver('joinRequest')({ joinRequestId: joinRequest._id }),
|
|
51
|
-
),
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
const collection = pullFromCache<Amity.JoinRequestListLiveCollectionCache>(
|
|
55
|
-
this.cacheKey,
|
|
56
|
-
)?.data;
|
|
57
|
-
|
|
58
|
-
const joinRequests = collection?.data ?? [];
|
|
59
|
-
|
|
60
|
-
pushToCache(this.cacheKey, {
|
|
61
|
-
...collection,
|
|
62
|
-
data: [
|
|
63
|
-
...new Set([
|
|
64
|
-
...joinRequests,
|
|
65
|
-
...response.joinRequests.map(joinRequest =>
|
|
66
|
-
getResolver('joinRequest')({ joinRequestId: joinRequest._id }),
|
|
67
|
-
),
|
|
68
|
-
]),
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
reactor(action: EnumJoinRequestAction) {
|
|
75
|
-
return (joinRequest: Amity.InternalJoinRequest[] | Amity.InternalJoinRequest) => {
|
|
76
|
-
const collection = pullFromCache<Amity.JoinRequestListLiveCollectionCache>(
|
|
77
|
-
this.cacheKey,
|
|
78
|
-
)?.data;
|
|
79
|
-
if (!collection) return;
|
|
80
|
-
|
|
81
|
-
const isArrayJoinRequest = Array.isArray(joinRequest);
|
|
82
|
-
|
|
83
|
-
const joinRequestIds = (isArrayJoinRequest ? joinRequest : [joinRequest]).map(
|
|
84
|
-
jr => jr.joinRequestId,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestUpdated) {
|
|
88
|
-
const isExist = collection.data.find(id => joinRequestIds.includes(id));
|
|
89
|
-
|
|
90
|
-
if (!isExist) return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestCreated) {
|
|
94
|
-
collection.data = [...new Set([...joinRequestIds, ...collection.data])];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestDeleted) {
|
|
98
|
-
collection.data = collection.data.filter(id => !joinRequestIds.includes(id));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
pushToCache(this.cacheKey, collection);
|
|
102
|
-
this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
subscribeRTE(
|
|
107
|
-
createSubscriber: {
|
|
108
|
-
fn: (
|
|
109
|
-
reactor: Amity.Listener<Amity.InternalJoinRequest[] | Amity.InternalJoinRequest>,
|
|
110
|
-
) => Amity.Unsubscriber;
|
|
111
|
-
action: EnumJoinRequestAction;
|
|
112
|
-
}[],
|
|
113
|
-
) {
|
|
114
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { dropFromCache } from '~/cache/api/dropFromCache';
|
|
2
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
3
|
-
import { ENABLE_CACHE_MESSAGE } from '~/utils/constants';
|
|
4
|
-
import { JoinRequestListLiveCollectionController } from './getJoinRequestList/JoinRequestListLiveCollectionController';
|
|
5
|
-
|
|
6
|
-
/* begin_public_function
|
|
7
|
-
id: community.getJoinRequestList
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Get Join Requests
|
|
11
|
-
*
|
|
12
|
-
* @param params the query parameters
|
|
13
|
-
* @param callback the callback to be called when the join request are updated
|
|
14
|
-
* @returns joinRequest[]
|
|
15
|
-
*
|
|
16
|
-
* @category joinRequestList Live Collection
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export const getJoinRequestList = (
|
|
20
|
-
params: Amity.JoinRequestListLiveCollection,
|
|
21
|
-
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|
|
22
|
-
config?: Amity.LiveCollectionConfig,
|
|
23
|
-
) => {
|
|
24
|
-
const { log, cache } = getActiveClient();
|
|
25
|
-
|
|
26
|
-
if (!cache) {
|
|
27
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const timestamp = Date.now();
|
|
31
|
-
log(`getJoinRequestList: (tmpid: ${timestamp}) > listen`);
|
|
32
|
-
|
|
33
|
-
const joinRequestListLiveCollection = new JoinRequestListLiveCollectionController(
|
|
34
|
-
params,
|
|
35
|
-
callback,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const disposers = joinRequestListLiveCollection.startSubscription();
|
|
39
|
-
|
|
40
|
-
const cacheKey = joinRequestListLiveCollection.getCacheKey();
|
|
41
|
-
|
|
42
|
-
disposers.push(() => {
|
|
43
|
-
dropFromCache(cacheKey);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return () => {
|
|
47
|
-
log(`getJoinRequestList (tmpid: ${timestamp}) > dispose`);
|
|
48
|
-
disposers.forEach(fn => fn());
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
/* end_public_function */
|
package/src/communityRepository/observers/getJoinRequests/JoinRequestsLiveCollectionController.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import hash from 'object-hash';
|
|
2
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
-
import { JoinRequestsPaginationController } from './JoinRequestsPaginationController';
|
|
4
|
-
import { JoinRequestsQueryStreamController } from './JoinRequestsQueryStreamController';
|
|
5
|
-
import { LiveCollectionController } from '~/core/liveCollection/LiveCollectionController';
|
|
6
|
-
import { sortByFirstCreated, sortByLastCreated } from '~/core/query';
|
|
7
|
-
import { prepareCommunityJoinRequestPayload } from '~/communityRepository/utils';
|
|
8
|
-
import { EnumJoinRequestAction } from './enum';
|
|
9
|
-
import { isNonNullable } from '~/utils';
|
|
10
|
-
import { joinRequestLinkedObject } from '~/utils/linkedObject/joinRequestLinkedObject';
|
|
11
|
-
import {
|
|
12
|
-
onJoinRequestCreated,
|
|
13
|
-
onJoinRequestDeleted,
|
|
14
|
-
onJoinRequestUpdated,
|
|
15
|
-
} from '~/communityRepository/joinRequest/events/';
|
|
16
|
-
|
|
17
|
-
export class JoinRequestsLiveCollectionController extends LiveCollectionController<
|
|
18
|
-
'joinRequest',
|
|
19
|
-
Amity.JoinRequestLiveCollection,
|
|
20
|
-
Amity.JoinRequest,
|
|
21
|
-
JoinRequestsPaginationController
|
|
22
|
-
> {
|
|
23
|
-
private queryStreamController: JoinRequestsQueryStreamController;
|
|
24
|
-
|
|
25
|
-
private query: Amity.JoinRequestLiveCollection;
|
|
26
|
-
|
|
27
|
-
constructor(
|
|
28
|
-
query: Amity.JoinRequestLiveCollection,
|
|
29
|
-
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|
|
30
|
-
) {
|
|
31
|
-
const queryStreamId = hash(query);
|
|
32
|
-
const cacheKey = ['joinRequest', 'collection', queryStreamId];
|
|
33
|
-
const paginationController = new JoinRequestsPaginationController(query);
|
|
34
|
-
|
|
35
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
36
|
-
|
|
37
|
-
this.query = query;
|
|
38
|
-
this.queryStreamController = new JoinRequestsQueryStreamController(
|
|
39
|
-
this.query,
|
|
40
|
-
this.cacheKey,
|
|
41
|
-
this.notifyChange.bind(this),
|
|
42
|
-
prepareCommunityJoinRequestPayload,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
this.callback = callback.bind(this);
|
|
46
|
-
this.loadPage({ initial: true });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
protected setup() {
|
|
50
|
-
const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
|
|
51
|
-
if (!collection) {
|
|
52
|
-
pushToCache(this.cacheKey, {
|
|
53
|
-
data: [],
|
|
54
|
-
params: this.query,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
protected async persistModel(queryPayload: Amity.CommunityJoinRequestPayload & Amity.Pagination) {
|
|
60
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
protected persistQueryStream({
|
|
64
|
-
response,
|
|
65
|
-
direction,
|
|
66
|
-
refresh,
|
|
67
|
-
}: Amity.LiveCollectionPersistQueryStreamParams<'joinRequest'>) {
|
|
68
|
-
const joinRequestResponse = response as unknown as Amity.CommunityJoinRequestPayload &
|
|
69
|
-
Partial<Amity.Pagination>;
|
|
70
|
-
this.queryStreamController.appendToQueryStream(joinRequestResponse, direction, refresh);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
startSubscription() {
|
|
74
|
-
return this.queryStreamController.subscribeRTE([
|
|
75
|
-
{ fn: onJoinRequestCreated, action: EnumJoinRequestAction.OnLocalJoinRequestCreated },
|
|
76
|
-
{ fn: onJoinRequestUpdated, action: EnumJoinRequestAction.OnLocalJoinRequestUpdated },
|
|
77
|
-
{ fn: onJoinRequestDeleted, action: EnumJoinRequestAction.OnLocalJoinRequestDeleted },
|
|
78
|
-
]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
notifyChange({ origin, loading, error }: Amity.LiveCollectionNotifyParams) {
|
|
82
|
-
const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
|
|
83
|
-
if (!collection) return;
|
|
84
|
-
|
|
85
|
-
const data = this.applyFilter(
|
|
86
|
-
collection.data
|
|
87
|
-
.map(id => pullFromCache<Amity.InternalJoinRequest>(['joinRequest', 'get', id])!)
|
|
88
|
-
.filter(isNonNullable)
|
|
89
|
-
.map(({ data }) => data)
|
|
90
|
-
.map(joinRequestLinkedObject),
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (!this.shouldNotify(data) && origin === 'event') return;
|
|
94
|
-
|
|
95
|
-
this.callback({
|
|
96
|
-
onNextPage: () => this.loadPage({ direction: Amity.LiveCollectionPageDirection.NEXT }),
|
|
97
|
-
data,
|
|
98
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
99
|
-
loading,
|
|
100
|
-
error,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
applyFilter(data: Amity.JoinRequest[]) {
|
|
105
|
-
let joinRequest = data;
|
|
106
|
-
|
|
107
|
-
if (this.query.status) {
|
|
108
|
-
joinRequest = joinRequest.filter(joinRequest => joinRequest.status === this.query.status);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const sortFn = (() => {
|
|
112
|
-
switch (this.query.sortBy) {
|
|
113
|
-
case 'firstCreated':
|
|
114
|
-
return sortByFirstCreated;
|
|
115
|
-
case 'lastCreated':
|
|
116
|
-
return sortByLastCreated;
|
|
117
|
-
default:
|
|
118
|
-
return sortByLastCreated;
|
|
119
|
-
}
|
|
120
|
-
})();
|
|
121
|
-
|
|
122
|
-
joinRequest = joinRequest.sort(sortFn);
|
|
123
|
-
|
|
124
|
-
return joinRequest;
|
|
125
|
-
}
|
|
126
|
-
}
|
package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { PaginationController } from '~/core/liveCollection/PaginationController';
|
|
2
|
-
import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* TODO: handle cache receive cache option, and cache policy
|
|
6
|
-
* TODO: check if querybyIds is supported
|
|
7
|
-
*/
|
|
8
|
-
export class JoinRequestsPaginationController extends PaginationController<
|
|
9
|
-
'joinRequest',
|
|
10
|
-
Amity.JoinRequestLiveCollection
|
|
11
|
-
> {
|
|
12
|
-
async getRequest(queryParams: Amity.JoinRequestLiveCollection, token: string | undefined) {
|
|
13
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityId, ...params } = queryParams;
|
|
14
|
-
const options = token ? { token } : { limit };
|
|
15
|
-
|
|
16
|
-
const { data: queryResponse } = await this.http.get<
|
|
17
|
-
Amity.CommunityJoinRequestPayload & Amity.Pagination
|
|
18
|
-
>(`/api/v4/communities/${communityId}/join`, {
|
|
19
|
-
params: {
|
|
20
|
-
...params,
|
|
21
|
-
options,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
return queryResponse;
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/communityRepository/observers/getJoinRequests/JoinRequestsQueryStreamController.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { QueryStreamController } from '~/core/liveCollection/QueryStreamController';
|
|
2
|
-
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
3
|
-
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
|
-
import { getResolver } from '~/core/model';
|
|
5
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
6
|
-
import { EnumJoinRequestAction } from './enum';
|
|
7
|
-
|
|
8
|
-
export class JoinRequestsQueryStreamController extends QueryStreamController<
|
|
9
|
-
Amity.CommunityJoinRequestPayload,
|
|
10
|
-
Amity.JoinRequestLiveCollection
|
|
11
|
-
> {
|
|
12
|
-
private notifyChange: (params: Amity.LiveCollectionNotifyParams) => void;
|
|
13
|
-
|
|
14
|
-
private preparePayload: (
|
|
15
|
-
response: Amity.CommunityJoinRequestPayload,
|
|
16
|
-
) => Amity.ProcessedJoinRequestPayload;
|
|
17
|
-
|
|
18
|
-
constructor(
|
|
19
|
-
query: Amity.JoinRequestLiveCollection,
|
|
20
|
-
cacheKey: string[],
|
|
21
|
-
notifyChange: (params: Amity.LiveCollectionNotifyParams) => void,
|
|
22
|
-
preparePayload: (
|
|
23
|
-
response: Amity.CommunityJoinRequestPayload,
|
|
24
|
-
) => Amity.ProcessedJoinRequestPayload,
|
|
25
|
-
) {
|
|
26
|
-
super(query, cacheKey);
|
|
27
|
-
this.notifyChange = notifyChange;
|
|
28
|
-
this.preparePayload = preparePayload;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async saveToMainDB(response: Amity.CommunityJoinRequestPayload) {
|
|
32
|
-
const processedPayload = await this.preparePayload(response);
|
|
33
|
-
|
|
34
|
-
const client = getActiveClient();
|
|
35
|
-
const cachedAt = client.cache && Date.now();
|
|
36
|
-
|
|
37
|
-
if (client.cache) {
|
|
38
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
appendToQueryStream(
|
|
43
|
-
response: Amity.CommunityJoinRequestPayload & Partial<Amity.Pagination>,
|
|
44
|
-
direction: Amity.LiveCollectionPageDirection,
|
|
45
|
-
refresh = false,
|
|
46
|
-
) {
|
|
47
|
-
if (refresh) {
|
|
48
|
-
pushToCache(this.cacheKey, {
|
|
49
|
-
data: response.joinRequests.map(joinRequest =>
|
|
50
|
-
getResolver('joinRequest')({ joinRequestId: joinRequest._id }),
|
|
51
|
-
),
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
|
|
55
|
-
|
|
56
|
-
const joinRequests = collection?.data ?? [];
|
|
57
|
-
|
|
58
|
-
pushToCache(this.cacheKey, {
|
|
59
|
-
...collection,
|
|
60
|
-
data: [
|
|
61
|
-
...new Set([
|
|
62
|
-
...joinRequests,
|
|
63
|
-
...response.joinRequests.map(joinRequest =>
|
|
64
|
-
getResolver('joinRequest')({ joinRequestId: joinRequest._id }),
|
|
65
|
-
),
|
|
66
|
-
]),
|
|
67
|
-
],
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
reactor(action: EnumJoinRequestAction) {
|
|
73
|
-
return (joinRequest: Amity.InternalJoinRequest[]) => {
|
|
74
|
-
const collection = pullFromCache<Amity.JoinRequestLiveCollectionCache>(this.cacheKey)?.data;
|
|
75
|
-
if (!collection) return;
|
|
76
|
-
|
|
77
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestUpdated) {
|
|
78
|
-
const isExist = collection.data.find(id => id === joinRequest[0].joinRequestId);
|
|
79
|
-
if (!isExist) return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestCreated) {
|
|
83
|
-
collection.data = [
|
|
84
|
-
...new Set([
|
|
85
|
-
...joinRequest.map(joinRequest => joinRequest.joinRequestId),
|
|
86
|
-
...collection.data,
|
|
87
|
-
]),
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (action === EnumJoinRequestAction.OnLocalJoinRequestDeleted) {
|
|
92
|
-
collection.data = collection.data.filter(id => id !== joinRequest[0].joinRequestId);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
pushToCache(this.cacheKey, collection);
|
|
96
|
-
this.notifyChange({ origin: Amity.LiveDataOrigin.EVENT, loading: false });
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
subscribeRTE(
|
|
101
|
-
createSubscriber: {
|
|
102
|
-
fn: (reactor: Amity.Listener<Amity.InternalJoinRequest[]>) => Amity.Unsubscriber;
|
|
103
|
-
action: EnumJoinRequestAction;
|
|
104
|
-
}[],
|
|
105
|
-
) {
|
|
106
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { dropFromCache } from '~/cache/api/dropFromCache';
|
|
2
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
3
|
-
import { ENABLE_CACHE_MESSAGE } from '~/utils/constants';
|
|
4
|
-
import { JoinRequestsLiveCollectionController } from './getJoinRequests/JoinRequestsLiveCollectionController';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get Join Requests
|
|
8
|
-
*
|
|
9
|
-
* @param params the query parameters
|
|
10
|
-
* @param callback the callback to be called when the join request are updated
|
|
11
|
-
* @returns joinRequests
|
|
12
|
-
*
|
|
13
|
-
* @category joinRequest Live Collection
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export const getJoinRequests = (
|
|
17
|
-
params: Amity.JoinRequestLiveCollection,
|
|
18
|
-
callback: Amity.LiveCollectionCallback<Amity.JoinRequest>,
|
|
19
|
-
config?: Amity.LiveCollectionConfig,
|
|
20
|
-
) => {
|
|
21
|
-
const { log, cache } = getActiveClient();
|
|
22
|
-
|
|
23
|
-
if (!cache) {
|
|
24
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const timestamp = Date.now();
|
|
28
|
-
log(`getJoinRequests: (tmpid: ${timestamp}) > listen`);
|
|
29
|
-
|
|
30
|
-
const joinRequestLiveCollection = new JoinRequestsLiveCollectionController(params, callback);
|
|
31
|
-
|
|
32
|
-
const disposers = joinRequestLiveCollection.startSubscription();
|
|
33
|
-
|
|
34
|
-
const cacheKey = joinRequestLiveCollection.getCacheKey();
|
|
35
|
-
|
|
36
|
-
disposers.push(() => {
|
|
37
|
-
dropFromCache(cacheKey);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return () => {
|
|
41
|
-
log(`getJoinRequests (tmpid: ${timestamp}) > dispose`);
|
|
42
|
-
disposers.forEach(fn => fn());
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -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.InternalInvitation[]>,
|
|
21
|
-
): Amity.Unsubscriber => {
|
|
22
|
-
const client = getActiveClient();
|
|
23
|
-
|
|
24
|
-
const disposers = [
|
|
25
|
-
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload =>
|
|
26
|
-
callback(payload),
|
|
27
|
-
),
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
return () => {
|
|
31
|
-
disposers.forEach(fn => fn());
|
|
32
|
-
};
|
|
33
|
-
};
|