polfan-server-js-client 0.1.59 → 0.1.92
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/.idea/vcs.xml +1 -0
- package/build/index.js +174 -99
- package/build/index.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +14 -4
- package/build/types/Permissions.d.ts +4 -0
- package/build/types/state-tracker/MessagesManager.d.ts +16 -10
- package/build/types/state-tracker/RoomsManager.d.ts +1 -0
- package/build/types/types/dist/index.d.ts +1 -0
- package/build/types/types/dist/schemes/AckReport.d.ts +1 -0
- package/build/types/types/dist/schemes/ChatLocation.d.ts +1 -0
- package/build/types/types/dist/schemes/Envelope.d.ts +1 -0
- package/build/types/types/dist/schemes/FollowedTopic.d.ts +1 -0
- package/build/types/types/dist/schemes/Message.d.ts +1 -0
- package/build/types/types/dist/schemes/PermissionOverwritesValue.d.ts +1 -0
- package/build/types/types/dist/schemes/Role.d.ts +1 -0
- package/build/types/types/dist/schemes/Room.d.ts +1 -0
- package/build/types/types/dist/schemes/RoomMember.d.ts +1 -0
- package/build/types/types/dist/schemes/RoomSummary.d.ts +1 -0
- package/build/types/types/dist/schemes/Space.d.ts +1 -0
- package/build/types/types/dist/schemes/SpaceMember.d.ts +1 -0
- package/build/types/types/dist/schemes/Topic.d.ts +1 -0
- package/build/types/types/dist/schemes/User.d.ts +1 -0
- package/build/types/types/dist/schemes/UserState.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/Ack.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/AssignRole.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/CreateMessage.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/CreateOwner.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/CreateRole.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/CreateRoom.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/CreateSpace.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/CreateTopic.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/DeassignRole.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/DeleteOwner.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/DeleteRole.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/DeleteRoom.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/DeleteSpace.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/DeleteTopic.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/FollowTopic.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetAckReports.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetComputedPermissions.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetFollowedTopics.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetOwners.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetPermissionOverwriteTargets.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetPermissionOverwrites.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetRoomMembers.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetSession.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetSpaceMembers.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetSpaceRooms.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/JoinRoom.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/JoinSpace.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/LeaveRoom.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/LeaveSpace.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/SetPermissionOverwrites.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/UnfollowTopic.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/UpdateRole.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/UpdateRoom.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/UpdateSpace.d.ts +1 -0
- package/build/types/types/dist/schemes/events/AckReports.d.ts +1 -0
- package/build/types/types/dist/schemes/events/Bye.d.ts +1 -0
- package/build/types/types/dist/schemes/events/ComputedPermissions.d.ts +1 -0
- package/build/types/types/dist/schemes/events/Error.d.ts +1 -0
- package/build/types/types/dist/schemes/events/FollowedTopics.d.ts +1 -0
- package/build/types/types/dist/schemes/events/NewMessage.d.ts +1 -0
- package/build/types/types/dist/schemes/events/NewRole.d.ts +1 -0
- package/build/types/types/dist/schemes/events/NewRoom.d.ts +1 -0
- package/build/types/types/dist/schemes/events/NewTopic.d.ts +1 -0
- package/build/types/types/dist/schemes/events/Ok.d.ts +1 -0
- package/build/types/types/dist/schemes/events/Owners.d.ts +1 -0
- package/build/types/types/dist/schemes/events/PermissionOverwriteTargets.d.ts +1 -0
- package/build/types/types/dist/schemes/events/PermissionOverwrites.d.ts +1 -0
- package/build/types/types/dist/schemes/events/PermissionOverwritesUpdated.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoleDeleted.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoleUpdated.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomDeleted.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomJoined.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomLeft.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomMemberJoined.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomMemberLeft.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomMemberUpdated.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomMembers.d.ts +1 -0
- package/build/types/types/dist/schemes/events/RoomUpdated.d.ts +1 -0
- package/build/types/types/dist/schemes/events/Session.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceDeleted.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceJoined.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceLeft.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceMemberJoined.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceMemberLeft.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceMemberUpdated.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceMembers.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceRooms.d.ts +1 -0
- package/build/types/types/dist/schemes/events/SpaceUpdated.d.ts +1 -0
- package/build/types/types/dist/schemes/events/TopicDeleted.d.ts +1 -0
- package/build/types/types/dist/schemes/events/TopicFollowed.d.ts +1 -0
- package/build/types/types/dist/schemes/events/TopicUnfollowed.d.ts +1 -0
- package/build/types/types/dist/schemes/events/UserUpdated.d.ts +1 -0
- package/build/types/types/src/index.d.ts +9 -4
- package/build/types/types/src/schemes/FollowedTopic.d.ts +7 -0
- package/build/types/types/src/schemes/Room.d.ts +1 -1
- package/build/types/types/src/schemes/Topic.d.ts +5 -1
- package/build/types/types/src/schemes/commands/CreateTopic.d.ts +2 -2
- package/build/types/types/src/schemes/commands/FollowTopic.d.ts +4 -0
- package/build/types/types/src/schemes/commands/GetFollowedTopics.d.ts +4 -0
- package/build/types/types/src/schemes/commands/UnfollowTopic.d.ts +4 -0
- package/build/types/types/src/schemes/events/FollowedTopics.d.ts +4 -0
- package/build/types/types/src/schemes/events/TopicFollowed.d.ts +4 -0
- package/build/types/types/src/schemes/events/TopicUnfollowed.d.ts +4 -0
- package/package.json +1 -1
- package/src/AbstractChatClient.ts +13 -5
- package/src/Permissions.ts +8 -7
- package/src/state-tracker/MessagesManager.ts +113 -57
- package/src/state-tracker/RoomsManager.ts +15 -0
- package/src/types/dist/index.d.ts +87 -0
- package/src/types/dist/index.js +2 -0
- package/src/types/dist/schemes/AckReport.js +2 -0
- package/src/types/dist/schemes/ChatLocation.d.ts +5 -0
- package/src/types/dist/schemes/ChatLocation.js +2 -0
- package/src/types/dist/schemes/Envelope.d.ts +5 -0
- package/src/types/dist/schemes/Envelope.js +2 -0
- package/src/types/dist/schemes/FollowedTopic.d.ts +7 -0
- package/src/types/dist/schemes/FollowedTopic.js +2 -0
- package/src/types/dist/schemes/Message.d.ts +7 -0
- package/src/types/dist/schemes/Message.js +2 -0
- package/src/types/dist/schemes/PermissionOverwritesValue.d.ts +4 -0
- package/src/types/dist/schemes/PermissionOverwritesValue.js +2 -0
- package/src/types/dist/schemes/Role.d.ts +6 -0
- package/src/types/dist/schemes/Role.js +2 -0
- package/src/types/dist/schemes/Room.d.ts +10 -0
- package/src/types/dist/schemes/Room.js +2 -0
- package/src/types/dist/schemes/RoomMember.d.ts +7 -0
- package/src/types/dist/schemes/RoomMember.js +2 -0
- package/src/types/dist/schemes/RoomSummary.d.ts +5 -0
- package/src/types/dist/schemes/RoomSummary.js +2 -0
- package/src/types/dist/schemes/Space.d.ts +6 -0
- package/src/types/dist/schemes/Space.js +2 -0
- package/src/types/dist/schemes/SpaceMember.d.ts +5 -0
- package/src/types/dist/schemes/SpaceMember.js +2 -0
- package/src/types/dist/schemes/Topic.d.ts +9 -0
- package/src/types/dist/schemes/Topic.js +2 -0
- package/src/types/dist/schemes/User.d.ts +8 -0
- package/src/types/dist/schemes/User.js +2 -0
- package/src/types/dist/schemes/UserState.d.ts +6 -0
- package/src/types/dist/schemes/UserState.js +2 -0
- package/src/types/dist/schemes/commands/Ack.d.ts +5 -0
- package/src/types/dist/schemes/commands/Ack.js +2 -0
- package/src/types/dist/schemes/commands/AssignRole.d.ts +6 -0
- package/src/types/dist/schemes/commands/AssignRole.js +2 -0
- package/src/types/dist/schemes/commands/CreateMessage.d.ts +5 -0
- package/src/types/dist/schemes/commands/CreateMessage.js +2 -0
- package/src/types/dist/schemes/commands/CreateOwner.d.ts +5 -0
- package/src/types/dist/schemes/commands/CreateOwner.js +2 -0
- package/src/types/dist/schemes/commands/CreateRole.d.ts +5 -0
- package/src/types/dist/schemes/commands/CreateRole.js +2 -0
- package/src/types/dist/schemes/commands/CreateRoom.d.ts +7 -0
- package/src/types/dist/schemes/commands/CreateRoom.js +2 -0
- package/src/types/dist/schemes/commands/CreateSpace.d.ts +3 -0
- package/src/types/dist/schemes/commands/CreateSpace.js +2 -0
- package/src/types/dist/schemes/commands/CreateTopic.d.ts +12 -0
- package/src/types/dist/schemes/commands/CreateTopic.js +2 -0
- package/src/types/dist/schemes/commands/DeassignRole.d.ts +6 -0
- package/src/types/dist/schemes/commands/DeassignRole.js +2 -0
- package/src/types/dist/schemes/commands/DeleteOwner.d.ts +5 -0
- package/src/types/dist/schemes/commands/DeleteOwner.js +2 -0
- package/src/types/dist/schemes/commands/DeleteRole.d.ts +4 -0
- package/src/types/dist/schemes/commands/DeleteRole.js +2 -0
- package/src/types/dist/schemes/commands/DeleteRoom.d.ts +3 -0
- package/src/types/dist/schemes/commands/DeleteRoom.js +2 -0
- package/src/types/dist/schemes/commands/DeleteSpace.d.ts +3 -0
- package/src/types/dist/schemes/commands/DeleteSpace.js +2 -0
- package/src/types/dist/schemes/commands/DeleteTopic.d.ts +4 -0
- package/src/types/dist/schemes/commands/DeleteTopic.js +2 -0
- package/src/types/dist/schemes/commands/FollowTopic.d.ts +4 -0
- package/src/types/dist/schemes/commands/FollowTopic.js +2 -0
- package/src/types/dist/schemes/commands/GetAckReports.js +2 -0
- package/src/types/dist/schemes/commands/GetComputedPermissions.d.ts +4 -0
- package/src/types/dist/schemes/commands/GetComputedPermissions.js +2 -0
- package/src/types/dist/schemes/commands/GetFollowedTopics.d.ts +4 -0
- package/src/types/dist/schemes/commands/GetFollowedTopics.js +2 -0
- package/src/types/dist/schemes/commands/GetOwners.d.ts +4 -0
- package/src/types/dist/schemes/commands/GetOwners.js +2 -0
- package/src/types/dist/schemes/commands/GetPermissionOverwriteTargets.d.ts +4 -0
- package/src/types/dist/schemes/commands/GetPermissionOverwriteTargets.js +2 -0
- package/src/types/dist/schemes/commands/GetPermissionOverwrites.d.ts +6 -0
- package/src/types/dist/schemes/commands/GetPermissionOverwrites.js +2 -0
- package/src/types/dist/schemes/commands/GetRoomMembers.d.ts +3 -0
- package/src/types/dist/schemes/commands/GetRoomMembers.js +2 -0
- package/src/types/dist/schemes/commands/GetSession.d.ts +2 -0
- package/src/types/dist/schemes/commands/GetSession.js +2 -0
- package/src/types/dist/schemes/commands/GetSpaceMembers.d.ts +3 -0
- package/src/types/dist/schemes/commands/GetSpaceMembers.js +2 -0
- package/src/types/dist/schemes/commands/GetSpaceRooms.d.ts +3 -0
- package/src/types/dist/schemes/commands/GetSpaceRooms.js +2 -0
- package/src/types/dist/schemes/commands/JoinRoom.d.ts +3 -0
- package/src/types/dist/schemes/commands/JoinRoom.js +2 -0
- package/src/types/dist/schemes/commands/JoinSpace.d.ts +3 -0
- package/src/types/dist/schemes/commands/JoinSpace.js +2 -0
- package/src/types/dist/schemes/commands/LeaveRoom.d.ts +3 -0
- package/src/types/dist/schemes/commands/LeaveRoom.js +2 -0
- package/src/types/dist/schemes/commands/LeaveSpace.d.ts +3 -0
- package/src/types/dist/schemes/commands/LeaveSpace.js +2 -0
- package/src/types/dist/schemes/commands/SetPermissionOverwrites.d.ts +8 -0
- package/src/types/dist/schemes/commands/SetPermissionOverwrites.js +2 -0
- package/src/types/dist/schemes/commands/UnfollowTopic.d.ts +4 -0
- package/src/types/dist/schemes/commands/UnfollowTopic.js +2 -0
- package/src/types/dist/schemes/commands/UpdateRole.d.ts +7 -0
- package/src/types/dist/schemes/commands/UpdateRole.js +2 -0
- package/src/types/dist/schemes/commands/UpdateRoom.d.ts +5 -0
- package/src/types/dist/schemes/commands/UpdateRoom.js +2 -0
- package/src/types/dist/schemes/commands/UpdateSpace.d.ts +4 -0
- package/src/types/dist/schemes/commands/UpdateSpace.js +2 -0
- package/src/types/dist/schemes/events/AckReports.d.ts +4 -0
- package/src/types/dist/schemes/events/AckReports.js +2 -0
- package/src/types/dist/schemes/events/Bye.d.ts +3 -0
- package/src/types/dist/schemes/events/Bye.js +2 -0
- package/src/types/dist/schemes/events/ComputedPermissions.d.ts +5 -0
- package/src/types/dist/schemes/events/ComputedPermissions.js +2 -0
- package/src/types/dist/schemes/events/Error.d.ts +4 -0
- package/src/types/dist/schemes/events/Error.js +2 -0
- package/src/types/dist/schemes/events/FollowedTopics.d.ts +4 -0
- package/src/types/dist/schemes/events/FollowedTopics.js +2 -0
- package/src/types/dist/schemes/events/NewMessage.d.ts +6 -0
- package/src/types/dist/schemes/events/NewMessage.js +2 -0
- package/src/types/dist/schemes/events/NewRole.d.ts +5 -0
- package/src/types/dist/schemes/events/NewRole.js +2 -0
- package/src/types/dist/schemes/events/NewRoom.d.ts +5 -0
- package/src/types/dist/schemes/events/NewRoom.js +2 -0
- package/src/types/dist/schemes/events/NewTopic.d.ts +5 -0
- package/src/types/dist/schemes/events/NewTopic.js +2 -0
- package/src/types/dist/schemes/events/Ok.d.ts +2 -0
- package/src/types/dist/schemes/events/Ok.js +2 -0
- package/src/types/dist/schemes/events/Owners.d.ts +8 -0
- package/src/types/dist/schemes/events/Owners.js +2 -0
- package/src/types/dist/schemes/events/PermissionOverwriteTargets.d.ts +10 -0
- package/src/types/dist/schemes/events/PermissionOverwriteTargets.js +2 -0
- package/src/types/dist/schemes/events/PermissionOverwrites.d.ts +8 -0
- package/src/types/dist/schemes/events/PermissionOverwrites.js +2 -0
- package/src/types/dist/schemes/events/PermissionOverwritesUpdated.d.ts +8 -0
- package/src/types/dist/schemes/events/PermissionOverwritesUpdated.js +2 -0
- package/src/types/dist/schemes/events/RoleDeleted.d.ts +4 -0
- package/src/types/dist/schemes/events/RoleDeleted.js +2 -0
- package/src/types/dist/schemes/events/RoleUpdated.d.ts +5 -0
- package/src/types/dist/schemes/events/RoleUpdated.js +2 -0
- package/src/types/dist/schemes/events/RoomDeleted.d.ts +3 -0
- package/src/types/dist/schemes/events/RoomDeleted.js +2 -0
- package/src/types/dist/schemes/events/RoomJoined.d.ts +4 -0
- package/src/types/dist/schemes/events/RoomJoined.js +2 -0
- package/src/types/dist/schemes/events/RoomLeft.d.ts +3 -0
- package/src/types/dist/schemes/events/RoomLeft.js +2 -0
- package/src/types/dist/schemes/events/RoomMemberJoined.d.ts +5 -0
- package/src/types/dist/schemes/events/RoomMemberJoined.js +2 -0
- package/src/types/dist/schemes/events/RoomMemberLeft.d.ts +4 -0
- package/src/types/dist/schemes/events/RoomMemberLeft.js +2 -0
- package/src/types/dist/schemes/events/RoomMemberUpdated.d.ts +6 -0
- package/src/types/dist/schemes/events/RoomMemberUpdated.js +2 -0
- package/src/types/dist/schemes/events/RoomMembers.d.ts +5 -0
- package/src/types/dist/schemes/events/RoomMembers.js +2 -0
- package/src/types/dist/schemes/events/RoomUpdated.d.ts +4 -0
- package/src/types/dist/schemes/events/RoomUpdated.js +2 -0
- package/src/types/dist/schemes/events/Session.d.ts +7 -0
- package/src/types/dist/schemes/events/Session.js +2 -0
- package/src/types/dist/schemes/events/SpaceDeleted.d.ts +3 -0
- package/src/types/dist/schemes/events/SpaceDeleted.js +2 -0
- package/src/types/dist/schemes/events/SpaceJoined.d.ts +4 -0
- package/src/types/dist/schemes/events/SpaceJoined.js +2 -0
- package/src/types/dist/schemes/events/SpaceLeft.d.ts +3 -0
- package/src/types/dist/schemes/events/SpaceLeft.js +2 -0
- package/src/types/dist/schemes/events/SpaceMemberJoined.d.ts +5 -0
- package/src/types/dist/schemes/events/SpaceMemberJoined.js +2 -0
- package/src/types/dist/schemes/events/SpaceMemberLeft.d.ts +4 -0
- package/src/types/dist/schemes/events/SpaceMemberLeft.js +2 -0
- package/src/types/dist/schemes/events/SpaceMemberUpdated.d.ts +6 -0
- package/src/types/dist/schemes/events/SpaceMemberUpdated.js +2 -0
- package/src/types/dist/schemes/events/SpaceMembers.d.ts +5 -0
- package/src/types/dist/schemes/events/SpaceMembers.js +2 -0
- package/src/types/dist/schemes/events/SpaceRooms.d.ts +5 -0
- package/src/types/dist/schemes/events/SpaceRooms.js +2 -0
- package/src/types/dist/schemes/events/SpaceUpdated.d.ts +4 -0
- package/src/types/dist/schemes/events/SpaceUpdated.js +2 -0
- package/src/types/dist/schemes/events/TopicDeleted.d.ts +4 -0
- package/src/types/dist/schemes/events/TopicDeleted.js +2 -0
- package/src/types/dist/schemes/events/TopicFollowed.d.ts +4 -0
- package/src/types/dist/schemes/events/TopicFollowed.js +2 -0
- package/src/types/dist/schemes/events/TopicUnfollowed.d.ts +4 -0
- package/src/types/dist/schemes/events/TopicUnfollowed.js +2 -0
- package/src/types/dist/schemes/events/UserUpdated.d.ts +4 -0
- package/src/types/dist/schemes/events/UserUpdated.js +2 -0
- package/src/types/src/index.ts +16 -6
- package/src/types/src/schemes/FollowedTopic.ts +8 -0
- package/src/types/src/schemes/Room.ts +1 -1
- package/src/types/src/schemes/Topic.ts +6 -1
- package/src/types/src/schemes/commands/CreateTopic.ts +2 -2
- package/src/types/src/schemes/commands/{GetAckReports.ts → FollowTopic.ts} +1 -1
- package/src/types/src/schemes/commands/GetFollowedTopics.ts +5 -0
- package/src/types/src/schemes/commands/UnfollowTopic.ts +5 -0
- package/src/types/src/schemes/events/FollowedTopics.ts +5 -0
- package/src/types/src/schemes/events/TopicFollowed.ts +5 -0
- package/src/types/src/schemes/events/TopicUnfollowed.ts +5 -0
- package/build/types/types/src/schemes/events/AckReports.d.ts +0 -4
- package/src/types/src/schemes/AckReport.ts +0 -7
- package/src/types/src/schemes/events/AckReports.ts +0 -5
- /package/{build/types/types/src → src/types/dist}/schemes/AckReport.d.ts +0 -0
- /package/{build/types/types/src → src/types/dist}/schemes/commands/GetAckReports.d.ts +0 -0
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import {ChatStateTracker} from "./ChatStateTracker";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ChatLocation,
|
|
4
|
+
Message,
|
|
5
|
+
NewMessage,
|
|
6
|
+
Topic,
|
|
7
|
+
FollowedTopic,
|
|
8
|
+
FollowedTopics,
|
|
9
|
+
TopicFollowed,
|
|
10
|
+
TopicUnfollowed,
|
|
11
|
+
RoomDeleted,
|
|
12
|
+
RoomLeft,
|
|
13
|
+
TopicDeleted
|
|
14
|
+
} from "../types/src";
|
|
3
15
|
import {
|
|
4
16
|
IndexedCollection,
|
|
5
17
|
ObservableIndexedObjectCollection
|
|
@@ -10,11 +22,16 @@ export const getCombinedId = (location: ChatLocation) => (location.roomId ?? '')
|
|
|
10
22
|
export class MessagesManager {
|
|
11
23
|
// Temporary not lazy loaded; server must implement GetTopicMessages command.
|
|
12
24
|
private readonly list = new IndexedCollection<string, ObservableIndexedObjectCollection<Message>>();
|
|
13
|
-
private readonly
|
|
25
|
+
private readonly followedTopics = new IndexedCollection<string, ObservableIndexedObjectCollection<FollowedTopic>>();
|
|
14
26
|
|
|
15
27
|
public constructor(private tracker: ChatStateTracker) {
|
|
16
28
|
this.tracker.client.on('NewMessage', ev => this.handleNewMessage(ev));
|
|
17
|
-
this.tracker.client.on('
|
|
29
|
+
this.tracker.client.on('FollowedTopics', ev => this.handleFollowedTopics(ev));
|
|
30
|
+
this.tracker.client.on('TopicFollowed', ev => this.handleTopicFollowed(ev));
|
|
31
|
+
this.tracker.client.on('TopicUnfollowed', ev => this.handleTopicUnfollowed(ev));
|
|
32
|
+
this.tracker.client.on('RoomDeleted', ev => this.handleRoomDeleted(ev));
|
|
33
|
+
this.tracker.client.on('RoomLeft', ev => this.handleRoomLeft(ev));
|
|
34
|
+
this.tracker.client.on('TopicDeleted', ev => this.handleTopicDeleted(ev));
|
|
18
35
|
}
|
|
19
36
|
|
|
20
37
|
/**
|
|
@@ -26,54 +43,44 @@ export class MessagesManager {
|
|
|
26
43
|
|
|
27
44
|
/**
|
|
28
45
|
* Cache ack reports for all joined rooms in a space and fetch them in bulk if necessary.
|
|
29
|
-
* Then you can get the reports using
|
|
30
|
-
* @see
|
|
46
|
+
* Then you can get the reports using getRoomFollowedTopics().
|
|
47
|
+
* @see getRoomFollowedTopics
|
|
31
48
|
*/
|
|
32
|
-
public async
|
|
49
|
+
public async cacheSpaceFollowedTopic(spaceId: string): Promise<void> {
|
|
33
50
|
if (! (await this.tracker.spaces.get()).has(spaceId)) {
|
|
34
51
|
throw new Error(`You are not in space ${spaceId}`);
|
|
35
52
|
}
|
|
36
53
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
if (missingRoomIds.length) {
|
|
41
|
-
// If we don't have ack reports for all rooms in space, fetch them
|
|
42
|
-
const result = await this.tracker.client.send('GetAckReports', {location: {spaceId}});
|
|
43
|
-
|
|
44
|
-
if (result.error) {
|
|
45
|
-
throw result.error;
|
|
46
|
-
}
|
|
54
|
+
// If we don't have ack reports for all rooms in space, fetch them
|
|
55
|
+
const result = await this.tracker.client.send('GetFollowedTopics', {location: {spaceId}});
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.acks.set([roomId, new ObservableIndexedObjectCollection('topicId', reports)]);
|
|
51
|
-
});
|
|
57
|
+
if (result.error) {
|
|
58
|
+
throw result.error;
|
|
52
59
|
}
|
|
60
|
+
|
|
61
|
+
this.setFollowedTopicsArray(result.data.followedTopics);
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
/**
|
|
56
65
|
* Get ack reports for the given room. Undefined if you are not in the room.
|
|
57
66
|
* @param roomId
|
|
58
67
|
*/
|
|
59
|
-
public async
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (! room) {
|
|
68
|
+
public async getRoomFollowedTopics(roomId: string): Promise<ObservableIndexedObjectCollection<FollowedTopic> | undefined> {
|
|
69
|
+
if (! (await this.tracker.rooms.get()).has(roomId)) {
|
|
63
70
|
return undefined;
|
|
64
71
|
}
|
|
65
72
|
|
|
66
|
-
if (! this.
|
|
67
|
-
const result = await this.tracker.client.send('
|
|
73
|
+
if (! this.followedTopics.has(roomId)) {
|
|
74
|
+
const result = await this.tracker.client.send('GetFollowedTopics', {location: {roomId}});
|
|
68
75
|
|
|
69
76
|
if (result.error) {
|
|
70
77
|
throw result.error;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
this.
|
|
80
|
+
this.setFollowedTopicsArray(result.data.followedTopics);
|
|
74
81
|
}
|
|
75
82
|
|
|
76
|
-
return this.
|
|
83
|
+
return this.followedTopics.get(roomId);
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
/**
|
|
@@ -82,61 +89,70 @@ export class MessagesManager {
|
|
|
82
89
|
*/
|
|
83
90
|
public _deleteByTopicIds(roomId: string, ...topicIds: string[]): void {
|
|
84
91
|
this.list.delete(...topicIds.map(topicId => getCombinedId({roomId, topicId})));
|
|
85
|
-
this.
|
|
92
|
+
this.followedTopics.get(roomId)?.delete(...topicIds);
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
/**
|
|
89
96
|
* For internal use. If you want to add new topic, execute a proper command on client object.
|
|
90
97
|
* @internal
|
|
91
98
|
*/
|
|
92
|
-
public _handleNewTopics(roomId: string, ...
|
|
93
|
-
|
|
94
|
-
getCombinedId({roomId, topicId:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
public _handleNewTopics(roomId: string, ...newTopics: Topic[]):void {
|
|
100
|
+
for (const newTopic of newTopics) {
|
|
101
|
+
const newTopicCombinedId = getCombinedId({roomId, topicId: newTopic.id});
|
|
102
|
+
|
|
103
|
+
this.list.set([newTopicCombinedId, new ObservableIndexedObjectCollection<Message>('id')]);
|
|
104
|
+
|
|
105
|
+
// If new topic refers to some message from this room, update other structures
|
|
106
|
+
if (newTopic.messageRef) {
|
|
107
|
+
const refTopicCombinedId = getCombinedId({roomId, topicId: newTopic.messageRef.topicId});
|
|
108
|
+
const refTopicMessages = this.list.get(refTopicCombinedId);
|
|
109
|
+
const refMessage = refTopicMessages?.get(newTopic.messageRef.messageId);
|
|
110
|
+
|
|
111
|
+
if (refMessage) {
|
|
112
|
+
// Update referenced topic ID in message
|
|
113
|
+
refTopicMessages.set({...refMessage, topicRef: newTopic.id});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.createFollowedStructuresForNewTopics(roomId, newTopics);
|
|
98
119
|
}
|
|
99
120
|
|
|
100
121
|
private handleNewMessage(ev: NewMessage): void {
|
|
101
122
|
this.list.get(getCombinedId(ev.location)).set(ev.message);
|
|
102
|
-
this.
|
|
123
|
+
this.updateLocallyFollowedTopicOnNewMessage(ev);
|
|
103
124
|
}
|
|
104
125
|
|
|
105
|
-
private
|
|
106
|
-
ev.
|
|
107
|
-
const ackReports = this.acks.get(report.roomId);
|
|
108
|
-
if (ackReports) {
|
|
109
|
-
ackReports.set(report);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
126
|
+
private handleFollowedTopics(ev: FollowedTopics): void {
|
|
127
|
+
this.setFollowedTopicsArray(ev.followedTopics);
|
|
112
128
|
}
|
|
113
129
|
|
|
114
|
-
private
|
|
115
|
-
const
|
|
130
|
+
private createFollowedStructuresForNewTopics(roomId: string, topics: Topic[]): void {
|
|
131
|
+
const followedTopic = this.followedTopics.get(roomId);
|
|
116
132
|
|
|
117
|
-
if (!
|
|
133
|
+
if (! followedTopic) {
|
|
118
134
|
// If we don't follow ack reports for this room, skip
|
|
119
135
|
return;
|
|
120
136
|
}
|
|
121
137
|
|
|
122
|
-
const
|
|
123
|
-
roomId, topicId: topic.id, lastAckMessageId: null, missed: 0, missedMoreThan: null
|
|
138
|
+
const followedTopics: FollowedTopic[] = topics.map(topic => ({
|
|
139
|
+
location: {roomId, topicId: topic.id}, lastAckMessageId: null, missed: 0, missedMoreThan: null
|
|
124
140
|
}));
|
|
125
141
|
|
|
126
|
-
|
|
142
|
+
followedTopic.set(...followedTopics);
|
|
127
143
|
}
|
|
128
144
|
|
|
129
|
-
private
|
|
130
|
-
const
|
|
145
|
+
private updateLocallyFollowedTopicOnNewMessage(ev: NewMessage): void {
|
|
146
|
+
const followedTopic = this.followedTopics.get(ev.location.roomId);
|
|
131
147
|
|
|
132
|
-
if (!
|
|
148
|
+
if (! followedTopic) {
|
|
133
149
|
// If we don't follow ack reports for this room, skip
|
|
134
150
|
return;
|
|
135
151
|
}
|
|
136
152
|
|
|
137
153
|
const isMe = ev.message.author.id === this.tracker.me?.id;
|
|
138
|
-
const
|
|
139
|
-
let update: Partial<
|
|
154
|
+
const currentFollowedTopic = followedTopic.get(ev.location.topicId);
|
|
155
|
+
let update: Partial<FollowedTopic>;
|
|
140
156
|
|
|
141
157
|
if (isMe) {
|
|
142
158
|
// Reset missed messages count if new message is authored by me
|
|
@@ -144,11 +160,51 @@ export class MessagesManager {
|
|
|
144
160
|
} else {
|
|
145
161
|
// ...add 1 otherwise
|
|
146
162
|
update = {
|
|
147
|
-
missed:
|
|
148
|
-
missedMoreThan:
|
|
163
|
+
missed: currentFollowedTopic.missed === null ? null : currentFollowedTopic.missed + 1,
|
|
164
|
+
missedMoreThan: currentFollowedTopic.missedMoreThan === null ? null : currentFollowedTopic.missedMoreThan,
|
|
149
165
|
};
|
|
150
166
|
}
|
|
151
167
|
|
|
152
|
-
|
|
168
|
+
followedTopic.set({...currentFollowedTopic, ...update});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private handleTopicFollowed(ev: TopicFollowed): void {
|
|
172
|
+
this.setFollowedTopicsArray([ev.followedTopic]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private handleTopicUnfollowed(ev: TopicUnfollowed): void {
|
|
176
|
+
this.followedTopics.get(ev.location.roomId)?.delete(ev.location.topicId);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private handleRoomDeleted(ev: RoomDeleted): void {
|
|
180
|
+
this.followedTopics.delete(ev.id);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private handleRoomLeft(ev: RoomLeft): void {
|
|
184
|
+
this.followedTopics.delete(ev.id);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
private handleTopicDeleted(ev: TopicDeleted): void {
|
|
188
|
+
this.followedTopics.get(ev.location.roomId)?.delete(ev.location.topicId);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private setFollowedTopicsArray(followedTopics: FollowedTopic[]): void {
|
|
192
|
+
const roomToTopics: {[roomId: string]: FollowedTopic[]} = {};
|
|
193
|
+
|
|
194
|
+
// Reassign reports to limit collection change event emit
|
|
195
|
+
followedTopics.forEach(followedTopic => {
|
|
196
|
+
roomToTopics[followedTopic.location.roomId] ??= [];
|
|
197
|
+
roomToTopics[followedTopic.location.roomId].push(followedTopic);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
for (const roomId in roomToTopics) {
|
|
201
|
+
if (! this.followedTopics.has(roomId)) {
|
|
202
|
+
this.followedTopics.set([
|
|
203
|
+
roomId,
|
|
204
|
+
new ObservableIndexedObjectCollection<FollowedTopic>(report => report.location.topicId),
|
|
205
|
+
]);
|
|
206
|
+
}
|
|
207
|
+
this.followedTopics.get(roomId).set(...roomToTopics[roomId]);
|
|
208
|
+
}
|
|
153
209
|
}
|
|
154
210
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {IndexedCollection, ObservableIndexedObjectCollection} from "../IndexedObjectCollection";
|
|
2
2
|
import {
|
|
3
|
+
NewMessage,
|
|
3
4
|
NewTopic,
|
|
4
5
|
Room, RoomDeleted,
|
|
5
6
|
RoomJoined, RoomLeft,
|
|
@@ -26,6 +27,7 @@ export class RoomsManager {
|
|
|
26
27
|
public constructor(private tracker: ChatStateTracker) {
|
|
27
28
|
this.messages = new MessagesManager(tracker);
|
|
28
29
|
|
|
30
|
+
this.tracker.client.on('NewMessage', ev => this.handleNewMessage(ev));
|
|
29
31
|
this.tracker.client.on('NewTopic', ev => this.handleNewTopic(ev));
|
|
30
32
|
this.tracker.client.on('TopicDeleted', ev => this.handleTopicDeleted(ev));
|
|
31
33
|
this.tracker.client.on('RoomJoined', ev => this.handleRoomJoined(ev));
|
|
@@ -269,4 +271,17 @@ export class RoomsManager {
|
|
|
269
271
|
members.set(newMember);
|
|
270
272
|
});
|
|
271
273
|
}
|
|
274
|
+
|
|
275
|
+
private handleNewMessage(ev: NewMessage): void {
|
|
276
|
+
const topics = this.topics.get(ev.location.roomId);
|
|
277
|
+
const topic = topics.get(ev.location.topicId);
|
|
278
|
+
|
|
279
|
+
if (topic) {
|
|
280
|
+
topics.set({
|
|
281
|
+
...topic,
|
|
282
|
+
messageCount: topic.messageCount + 1,
|
|
283
|
+
lastMessage: ev.message,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
272
287
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Envelope } from "./schemes/Envelope";
|
|
2
|
+
import { Message } from "./schemes/Message";
|
|
3
|
+
import { PermissionOverwritesValue } from "./schemes/PermissionOverwritesValue";
|
|
4
|
+
import { Role } from "./schemes/Role";
|
|
5
|
+
import { Room } from "./schemes/Room";
|
|
6
|
+
import { RoomMember } from "./schemes/RoomMember";
|
|
7
|
+
import { RoomSummary } from "./schemes/RoomSummary";
|
|
8
|
+
import { Space } from "./schemes/Space";
|
|
9
|
+
import { SpaceMember } from "./schemes/SpaceMember";
|
|
10
|
+
import { Topic } from "./schemes/Topic";
|
|
11
|
+
import { User } from "./schemes/User";
|
|
12
|
+
import { UserState } from "./schemes/UserState";
|
|
13
|
+
import { Bye } from "./schemes/events/Bye";
|
|
14
|
+
import { Error } from "./schemes/events/Error";
|
|
15
|
+
import { Session } from "./schemes/events/Session";
|
|
16
|
+
import { ComputedPermissions } from "./schemes/events/ComputedPermissions";
|
|
17
|
+
import { SpaceJoined } from "./schemes/events/SpaceJoined";
|
|
18
|
+
import { SpaceLeft } from "./schemes/events/SpaceLeft";
|
|
19
|
+
import { SpaceMemberJoined } from "./schemes/events/SpaceMemberJoined";
|
|
20
|
+
import { SpaceMemberLeft } from "./schemes/events/SpaceMemberLeft";
|
|
21
|
+
import { SpaceMemberUpdated } from "./schemes/events/SpaceMemberUpdated";
|
|
22
|
+
import { SpaceDeleted } from "./schemes/events/SpaceDeleted";
|
|
23
|
+
import { SpaceMembers } from "./schemes/events/SpaceMembers";
|
|
24
|
+
import { SpaceRooms } from "./schemes/events/SpaceRooms";
|
|
25
|
+
import { NewRole } from "./schemes/events/NewRole";
|
|
26
|
+
import { RoleDeleted } from "./schemes/events/RoleDeleted";
|
|
27
|
+
import { RoomJoined } from "./schemes/events/RoomJoined";
|
|
28
|
+
import { RoomLeft } from "./schemes/events/RoomLeft";
|
|
29
|
+
import { RoomMemberJoined } from "./schemes/events/RoomMemberJoined";
|
|
30
|
+
import { RoomMemberLeft } from "./schemes/events/RoomMemberLeft";
|
|
31
|
+
import { RoomMembers } from "./schemes/events/RoomMembers";
|
|
32
|
+
import { RoomMemberUpdated } from "./schemes/events/RoomMemberUpdated";
|
|
33
|
+
import { NewRoom } from "./schemes/events/NewRoom";
|
|
34
|
+
import { RoomDeleted } from "./schemes/events/RoomDeleted";
|
|
35
|
+
import { NewTopic } from "./schemes/events/NewTopic";
|
|
36
|
+
import { TopicDeleted } from "./schemes/events/TopicDeleted";
|
|
37
|
+
import { NewMessage } from "./schemes/events/NewMessage";
|
|
38
|
+
import { PermissionOverwritesUpdated } from "./schemes/events/PermissionOverwritesUpdated";
|
|
39
|
+
import { PermissionOverwrites } from "./schemes/events/PermissionOverwrites";
|
|
40
|
+
import { GetSession } from "./schemes/commands/GetSession";
|
|
41
|
+
import { GetComputedPermissions } from "./schemes/commands/GetComputedPermissions";
|
|
42
|
+
import { JoinSpace } from "./schemes/commands/JoinSpace";
|
|
43
|
+
import { LeaveSpace } from "./schemes/commands/LeaveSpace";
|
|
44
|
+
import { CreateSpace } from "./schemes/commands/CreateSpace";
|
|
45
|
+
import { DeleteSpace } from "./schemes/commands/DeleteSpace";
|
|
46
|
+
import { GetSpaceMembers } from "./schemes/commands/GetSpaceMembers";
|
|
47
|
+
import { GetSpaceRooms } from "./schemes/commands/GetSpaceRooms";
|
|
48
|
+
import { CreateRole } from "./schemes/commands/CreateRole";
|
|
49
|
+
import { DeleteRole } from "./schemes/commands/DeleteRole";
|
|
50
|
+
import { RoleUpdated } from "./schemes/events/RoleUpdated";
|
|
51
|
+
import { AssignRole } from "./schemes/commands/AssignRole";
|
|
52
|
+
import { DeassignRole } from "./schemes/commands/DeassignRole";
|
|
53
|
+
import { SetPermissionOverwrites } from "./schemes/commands/SetPermissionOverwrites";
|
|
54
|
+
import { GetPermissionOverwrites } from "./schemes/commands/GetPermissionOverwrites";
|
|
55
|
+
import { JoinRoom } from "./schemes/commands/JoinRoom";
|
|
56
|
+
import { LeaveRoom } from "./schemes/commands/LeaveRoom";
|
|
57
|
+
import { CreateRoom } from "./schemes/commands/CreateRoom";
|
|
58
|
+
import { DeleteRoom } from "./schemes/commands/DeleteRoom";
|
|
59
|
+
import { GetRoomMembers } from "./schemes/commands/GetRoomMembers";
|
|
60
|
+
import { CreateTopic } from "./schemes/commands/CreateTopic";
|
|
61
|
+
import { DeleteTopic } from "./schemes/commands/DeleteTopic";
|
|
62
|
+
import { CreateMessage } from "./schemes/commands/CreateMessage";
|
|
63
|
+
import { UpdateRole } from "./schemes/commands/UpdateRole";
|
|
64
|
+
import { Ack } from "./schemes/commands/Ack";
|
|
65
|
+
import { UserUpdated } from "./schemes/events/UserUpdated";
|
|
66
|
+
import { UpdateRoom } from "./schemes/commands/UpdateRoom";
|
|
67
|
+
import { UpdateSpace } from "./schemes/commands/UpdateSpace";
|
|
68
|
+
import { RoomUpdated } from "./schemes/events/RoomUpdated";
|
|
69
|
+
import { SpaceUpdated } from "./schemes/events/SpaceUpdated";
|
|
70
|
+
import { ChatLocation } from "./schemes/ChatLocation";
|
|
71
|
+
import { GetPermissionOverwriteTargets } from "./schemes/commands/GetPermissionOverwriteTargets";
|
|
72
|
+
import { PermissionOverwriteTargets } from "./schemes/events/PermissionOverwriteTargets";
|
|
73
|
+
import { CreateOwner } from "./schemes/commands/CreateOwner";
|
|
74
|
+
import { DeleteOwner } from "./schemes/commands/DeleteOwner";
|
|
75
|
+
import { GetOwners } from "./schemes/commands/GetOwners";
|
|
76
|
+
import { Owners } from "./schemes/events/Owners";
|
|
77
|
+
import { Ok } from "./schemes/events/Ok";
|
|
78
|
+
import { RoomType } from "./schemes/Room";
|
|
79
|
+
import { MessageReference } from "./schemes/commands/CreateTopic";
|
|
80
|
+
import { FollowTopic } from "./schemes/commands/FollowTopic";
|
|
81
|
+
import { FollowedTopics } from "./schemes/events/FollowedTopics";
|
|
82
|
+
import { FollowedTopic } from "./schemes/FollowedTopic";
|
|
83
|
+
import { UnfollowTopic } from "./schemes/commands/UnfollowTopic";
|
|
84
|
+
import { TopicUnfollowed } from "./schemes/events/TopicUnfollowed";
|
|
85
|
+
import { TopicFollowed } from "./schemes/events/TopicFollowed";
|
|
86
|
+
import { GetFollowedTopics } from "./schemes/commands/GetFollowedTopics";
|
|
87
|
+
export { Envelope, Message, Role, Room, RoomType, RoomMember, RoomSummary, Space, SpaceMember, Topic, FollowedTopic, User, UserState, PermissionOverwritesValue, ChatLocation, MessageReference, Bye, Error, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMemberJoined, RoomMemberLeft, RoomMembers, RoomMemberUpdated, UserUpdated, Session, SpaceDeleted, SpaceUpdated, SpaceJoined, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMembers, SpaceMemberUpdated, SpaceRooms, TopicDeleted, PermissionOverwriteTargets, Owners, Ok, AssignRole, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, GetFollowedTopics, DeassignRole, DeleteRole, DeleteRoom, DeleteSpace, DeleteTopic, SetPermissionOverwrites, GetPermissionOverwrites, GetComputedPermissions, GetRoomMembers, GetSession, GetSpaceMembers, GetSpaceRooms, JoinRoom, JoinSpace, LeaveRoom, LeaveSpace, UpdateRole, UpdateSpace, UpdateRoom, GetPermissionOverwriteTargets, CreateOwner, DeleteOwner, GetOwners, };
|