polfan-server-js-client 0.1.2 → 0.1.7
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/.gitmodules +3 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/polfan-server-js-client.iml +3 -1
- package/.idea/vcs.xml +2 -1
- package/README.md +17 -17
- package/build/index.js +1985 -462
- package/build/index.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +26 -9
- package/build/types/IndexedObjectCollection.d.ts +3 -3
- package/build/types/Permissions.d.ts +65 -0
- package/build/types/WebSocketChatClient.d.ts +1 -1
- package/build/types/index.d.ts +4 -1
- package/build/types/state-tracker/AsyncUtils.d.ts +14 -0
- package/build/types/state-tracker/ChatStateTracker.d.ts +26 -0
- package/build/types/state-tracker/MessagesManager.d.ts +39 -0
- package/build/types/state-tracker/PermissionsManager.d.ts +41 -0
- package/build/types/state-tracker/RoomsManager.d.ts +49 -0
- package/build/types/state-tracker/SpacesManager.d.ts +52 -0
- package/build/types/state-tracker/functions.d.ts +2 -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/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/GetAckReports.d.ts +1 -0
- package/build/types/types/dist/schemes/commands/GetComputedPermissions.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/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/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/UserUpdated.d.ts +1 -0
- package/build/types/types/src/index.d.ts +82 -0
- package/build/types/types/src/schemes/AckReport.d.ts +7 -0
- package/build/types/types/src/schemes/ChatLocation.d.ts +5 -0
- package/build/types/types/src/schemes/Envelope.d.ts +5 -0
- package/build/types/types/src/schemes/Message.d.ts +7 -0
- package/build/types/types/src/schemes/PermissionOverwritesValue.d.ts +4 -0
- package/build/types/types/src/schemes/Role.d.ts +6 -0
- package/build/types/types/src/schemes/Room.d.ts +10 -0
- package/build/types/types/src/schemes/RoomMember.d.ts +7 -0
- package/build/types/types/src/schemes/RoomSummary.d.ts +5 -0
- package/build/types/types/src/schemes/Space.d.ts +6 -0
- package/build/types/types/src/schemes/SpaceMember.d.ts +5 -0
- package/build/types/types/src/schemes/Topic.d.ts +9 -0
- package/build/types/types/src/schemes/User.d.ts +8 -0
- package/build/types/types/src/schemes/UserState.d.ts +6 -0
- package/build/types/types/src/schemes/commands/Ack.d.ts +5 -0
- package/build/types/types/src/schemes/commands/AssignRole.d.ts +6 -0
- package/build/types/types/src/schemes/commands/CreateMessage.d.ts +5 -0
- package/build/types/types/src/schemes/commands/CreateOwner.d.ts +5 -0
- package/build/types/types/src/schemes/commands/CreateRole.d.ts +5 -0
- package/build/types/types/src/schemes/commands/CreateRoom.d.ts +7 -0
- package/build/types/types/src/schemes/commands/CreateSpace.d.ts +3 -0
- package/build/types/types/src/schemes/commands/CreateTopic.d.ts +12 -0
- package/build/types/types/src/schemes/commands/DeassignRole.d.ts +6 -0
- package/build/types/types/src/schemes/commands/DeleteOwner.d.ts +5 -0
- package/build/types/types/src/schemes/commands/DeleteRole.d.ts +4 -0
- package/build/types/types/src/schemes/commands/DeleteRoom.d.ts +3 -0
- package/build/types/types/src/schemes/commands/DeleteSpace.d.ts +3 -0
- package/build/types/types/src/schemes/commands/DeleteTopic.d.ts +4 -0
- package/build/types/types/src/schemes/commands/GetAckReports.d.ts +4 -0
- package/build/types/types/src/schemes/commands/GetComputedPermissions.d.ts +4 -0
- package/build/types/types/src/schemes/commands/GetOwners.d.ts +4 -0
- package/build/types/types/src/schemes/commands/GetPermissionOverwriteTargets.d.ts +4 -0
- package/build/types/types/src/schemes/commands/GetPermissionOverwrites.d.ts +6 -0
- package/build/types/types/src/schemes/commands/GetRoomMembers.d.ts +3 -0
- package/build/types/types/src/schemes/commands/GetSession.d.ts +2 -0
- package/build/types/types/src/schemes/commands/GetSpaceMembers.d.ts +3 -0
- package/build/types/types/src/schemes/commands/GetSpaceRooms.d.ts +3 -0
- package/build/types/types/src/schemes/commands/JoinRoom.d.ts +3 -0
- package/build/types/types/src/schemes/commands/JoinSpace.d.ts +3 -0
- package/build/types/types/src/schemes/commands/LeaveRoom.d.ts +3 -0
- package/build/types/types/src/schemes/commands/LeaveSpace.d.ts +3 -0
- package/build/types/types/src/schemes/commands/SetPermissionOverwrites.d.ts +8 -0
- package/build/types/types/src/schemes/commands/UpdateRole.d.ts +7 -0
- package/build/types/types/src/schemes/commands/UpdateRoom.d.ts +5 -0
- package/build/types/types/src/schemes/commands/UpdateSpace.d.ts +4 -0
- package/build/types/types/src/schemes/events/AckReports.d.ts +4 -0
- package/build/types/types/src/schemes/events/Bye.d.ts +3 -0
- package/build/types/types/src/schemes/events/ComputedPermissions.d.ts +5 -0
- package/build/types/types/src/schemes/events/Error.d.ts +4 -0
- package/build/types/types/src/schemes/events/NewMessage.d.ts +6 -0
- package/build/types/types/src/schemes/events/NewRole.d.ts +5 -0
- package/build/types/types/src/schemes/events/NewRoom.d.ts +5 -0
- package/build/types/types/src/schemes/events/NewTopic.d.ts +5 -0
- package/build/types/types/src/schemes/events/Ok.d.ts +2 -0
- package/build/types/types/src/schemes/events/Owners.d.ts +8 -0
- package/build/types/types/src/schemes/events/PermissionOverwriteTargets.d.ts +10 -0
- package/build/types/types/src/schemes/events/PermissionOverwrites.d.ts +8 -0
- package/build/types/types/src/schemes/events/PermissionOverwritesUpdated.d.ts +8 -0
- package/build/types/types/src/schemes/events/RoleDeleted.d.ts +4 -0
- package/build/types/types/src/schemes/events/RoleUpdated.d.ts +5 -0
- package/build/types/types/src/schemes/events/RoomDeleted.d.ts +3 -0
- package/build/types/types/src/schemes/events/RoomJoined.d.ts +4 -0
- package/build/types/types/src/schemes/events/RoomLeft.d.ts +3 -0
- package/build/types/types/src/schemes/events/RoomMemberJoined.d.ts +5 -0
- package/build/types/types/src/schemes/events/RoomMemberLeft.d.ts +4 -0
- package/build/types/types/src/schemes/events/RoomMemberUpdated.d.ts +6 -0
- package/build/types/types/src/schemes/events/RoomMembers.d.ts +5 -0
- package/build/types/types/src/schemes/events/RoomUpdated.d.ts +4 -0
- package/build/types/types/src/schemes/events/Session.d.ts +7 -0
- package/build/types/types/src/schemes/events/SpaceDeleted.d.ts +3 -0
- package/build/types/types/src/schemes/events/SpaceJoined.d.ts +4 -0
- package/build/types/types/src/schemes/events/SpaceLeft.d.ts +3 -0
- package/build/types/types/src/schemes/events/SpaceMemberJoined.d.ts +5 -0
- package/build/types/types/src/schemes/events/SpaceMemberLeft.d.ts +4 -0
- package/build/types/types/src/schemes/events/SpaceMemberUpdated.d.ts +6 -0
- package/build/types/types/src/schemes/events/SpaceMembers.d.ts +5 -0
- package/build/types/types/src/schemes/events/SpaceRooms.d.ts +5 -0
- package/build/types/types/src/schemes/events/SpaceUpdated.d.ts +4 -0
- package/build/types/types/src/schemes/events/TopicDeleted.d.ts +4 -0
- package/build/types/types/src/schemes/events/UserUpdated.d.ts +4 -0
- package/jest.config.ts +199 -0
- package/package.json +4 -22
- package/src/AbstractChatClient.ts +50 -16
- package/src/AbstractRestClient.ts +65 -65
- package/src/IndexedObjectCollection.ts +3 -3
- package/src/Permissions.ts +46 -0
- package/src/WebApiChatClient.ts +1 -1
- package/src/WebSocketChatClient.ts +2 -2
- package/src/index.ts +7 -2
- package/src/state-tracker/AsyncUtils.ts +38 -0
- package/src/state-tracker/ChatStateTracker.ts +42 -0
- package/src/state-tracker/MessagesManager.ts +168 -0
- package/src/state-tracker/PermissionsManager.ts +306 -0
- package/src/state-tracker/RoomsManager.ts +272 -0
- package/src/state-tracker/SpacesManager.ts +267 -0
- package/src/state-tracker/functions.ts +25 -0
- package/src/types/README.md +2 -0
- package/src/types/dist/index.d.ts +82 -0
- package/src/types/dist/index.js +2 -0
- package/src/types/dist/schemes/AckReport.d.ts +7 -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/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/GetAckReports.d.ts +4 -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/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/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/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/UserUpdated.d.ts +4 -0
- package/src/types/dist/schemes/events/UserUpdated.js +2 -0
- package/src/types/package-lock.json +31 -0
- package/src/types/package.json +16 -0
- package/src/types/src/index.ts +168 -0
- package/src/types/src/schemes/AckReport.ts +7 -0
- package/src/types/src/schemes/ChatLocation.ts +5 -0
- package/src/types/src/schemes/Envelope.ts +5 -0
- package/src/types/src/schemes/Message.ts +8 -0
- package/src/types/src/schemes/PermissionOverwritesValue.ts +4 -0
- package/src/types/src/schemes/Role.ts +6 -0
- package/src/types/src/schemes/Room.ts +12 -0
- package/src/types/src/schemes/RoomMember.ts +8 -0
- package/src/types/src/schemes/RoomSummary.ts +5 -0
- package/src/types/src/schemes/Space.ts +7 -0
- package/src/types/src/schemes/SpaceMember.ts +6 -0
- package/src/types/src/schemes/Topic.ts +10 -0
- package/src/types/src/schemes/User.ts +9 -0
- package/src/types/src/schemes/UserState.ts +7 -0
- package/src/types/src/schemes/commands/Ack.ts +6 -0
- package/src/types/src/schemes/commands/AssignRole.ts +7 -0
- package/src/types/src/schemes/commands/CreateMessage.ts +6 -0
- package/src/types/src/schemes/commands/CreateOwner.ts +6 -0
- package/src/types/src/schemes/commands/CreateRole.ts +5 -0
- package/src/types/src/schemes/commands/CreateRoom.ts +8 -0
- package/src/types/src/schemes/commands/CreateSpace.ts +3 -0
- package/src/types/src/schemes/commands/CreateTopic.ts +14 -0
- package/src/types/src/schemes/commands/DeassignRole.ts +7 -0
- package/src/types/src/schemes/commands/DeleteOwner.ts +6 -0
- package/src/types/src/schemes/commands/DeleteRole.ts +4 -0
- package/src/types/src/schemes/commands/DeleteRoom.ts +3 -0
- package/src/types/src/schemes/commands/DeleteSpace.ts +3 -0
- package/src/types/src/schemes/commands/DeleteTopic.ts +5 -0
- package/src/types/src/schemes/commands/GetAckReports.ts +5 -0
- package/src/types/src/schemes/commands/GetComputedPermissions.ts +5 -0
- package/src/types/src/schemes/commands/GetOwners.ts +5 -0
- package/src/types/src/schemes/commands/GetPermissionOverwriteTargets.ts +5 -0
- package/src/types/src/schemes/commands/GetPermissionOverwrites.ts +7 -0
- package/src/types/src/schemes/commands/GetRoomMembers.ts +3 -0
- package/src/types/src/schemes/commands/GetSession.ts +2 -0
- package/src/types/src/schemes/commands/GetSpaceMembers.ts +3 -0
- package/src/types/src/schemes/commands/GetSpaceRooms.ts +3 -0
- package/src/types/src/schemes/commands/JoinRoom.ts +3 -0
- package/src/types/src/schemes/commands/JoinSpace.ts +3 -0
- package/src/types/src/schemes/commands/LeaveRoom.ts +3 -0
- package/src/types/src/schemes/commands/LeaveSpace.ts +3 -0
- package/src/types/src/schemes/commands/SetPermissionOverwrites.ts +9 -0
- package/src/types/src/schemes/commands/UpdateRole.ts +7 -0
- package/src/types/src/schemes/commands/UpdateRoom.ts +5 -0
- package/src/types/src/schemes/commands/UpdateSpace.ts +4 -0
- package/src/types/src/schemes/events/AckReports.ts +5 -0
- package/src/types/src/schemes/events/Bye.ts +3 -0
- package/src/types/src/schemes/events/ComputedPermissions.ts +6 -0
- package/src/types/src/schemes/events/Error.ts +4 -0
- package/src/types/src/schemes/events/NewMessage.ts +7 -0
- package/src/types/src/schemes/events/NewRole.ts +6 -0
- package/src/types/src/schemes/events/NewRoom.ts +6 -0
- package/src/types/src/schemes/events/NewTopic.ts +6 -0
- package/src/types/src/schemes/events/Ok.ts +3 -0
- package/src/types/src/schemes/events/Owners.ts +9 -0
- package/src/types/src/schemes/events/PermissionOverwriteTargets.ts +11 -0
- package/src/types/src/schemes/events/PermissionOverwrites.ts +9 -0
- package/src/types/src/schemes/events/PermissionOverwritesUpdated.ts +9 -0
- package/src/types/src/schemes/events/RoleDeleted.ts +4 -0
- package/src/types/src/schemes/events/RoleUpdated.ts +6 -0
- package/src/types/src/schemes/events/RoomDeleted.ts +3 -0
- package/src/types/src/schemes/events/RoomJoined.ts +5 -0
- package/src/types/src/schemes/events/RoomLeft.ts +3 -0
- package/src/types/src/schemes/events/RoomMemberJoined.ts +6 -0
- package/src/types/src/schemes/events/RoomMemberLeft.ts +4 -0
- package/src/types/src/schemes/events/RoomMemberUpdated.ts +7 -0
- package/src/types/src/schemes/events/RoomMembers.ts +6 -0
- package/src/types/src/schemes/events/RoomUpdated.ts +5 -0
- package/src/types/src/schemes/events/Session.ts +8 -0
- package/src/types/src/schemes/events/SpaceDeleted.ts +3 -0
- package/src/types/src/schemes/events/SpaceJoined.ts +5 -0
- package/src/types/src/schemes/events/SpaceLeft.ts +3 -0
- package/src/types/src/schemes/events/SpaceMemberJoined.ts +6 -0
- package/src/types/src/schemes/events/SpaceMemberLeft.ts +4 -0
- package/src/types/src/schemes/events/SpaceMemberUpdated.ts +7 -0
- package/src/types/src/schemes/events/SpaceMembers.ts +6 -0
- package/src/types/src/schemes/events/SpaceRooms.ts +6 -0
- package/src/types/src/schemes/events/SpaceUpdated.ts +5 -0
- package/src/types/src/schemes/events/TopicDeleted.ts +5 -0
- package/src/types/src/schemes/events/UserUpdated.ts +5 -0
- package/src/types/tsconfig.json +75 -0
- package/tests/async-utils.test.ts +30 -0
- package/tests/permissions.test.ts +14 -0
- package/tests/space-roles.test.ts +43 -0
- package/build/types/ChatStateTracker.d.ts +0 -54
- package/index.html +0 -8
- package/src/ChatStateTracker.ts +0 -336
package/jest.config.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* For a detailed explanation regarding each configuration property, visit:
|
|
3
|
+
* https://jestjs.io/docs/configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {Config} from 'jest';
|
|
7
|
+
|
|
8
|
+
const config: Config = {
|
|
9
|
+
// All imported modules in your tests should be mocked automatically
|
|
10
|
+
// automock: false,
|
|
11
|
+
|
|
12
|
+
// Stop running tests after `n` failures
|
|
13
|
+
// bail: 0,
|
|
14
|
+
|
|
15
|
+
// The directory where Jest should store its cached dependency information
|
|
16
|
+
// cacheDirectory: "C:\\Users\\Szado\\AppData\\Local\\Temp\\jest",
|
|
17
|
+
|
|
18
|
+
// Automatically clear mock calls, instances, contexts and results before every test
|
|
19
|
+
clearMocks: true,
|
|
20
|
+
|
|
21
|
+
// Indicates whether the coverage information should be collected while executing the test
|
|
22
|
+
collectCoverage: false,
|
|
23
|
+
|
|
24
|
+
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
|
25
|
+
// collectCoverageFrom: undefined,
|
|
26
|
+
|
|
27
|
+
// The directory where Jest should output its coverage files
|
|
28
|
+
coverageDirectory: "coverage",
|
|
29
|
+
|
|
30
|
+
// An array of regexp pattern strings used to skip coverage collection
|
|
31
|
+
// coveragePathIgnorePatterns: [
|
|
32
|
+
// "\\\\node_modules\\\\"
|
|
33
|
+
// ],
|
|
34
|
+
|
|
35
|
+
// Indicates which provider should be used to instrument code for coverage
|
|
36
|
+
coverageProvider: "v8",
|
|
37
|
+
|
|
38
|
+
// A list of reporter names that Jest uses when writing coverage reports
|
|
39
|
+
// coverageReporters: [
|
|
40
|
+
// "json",
|
|
41
|
+
// "text",
|
|
42
|
+
// "lcov",
|
|
43
|
+
// "clover"
|
|
44
|
+
// ],
|
|
45
|
+
|
|
46
|
+
// An object that configures minimum threshold enforcement for coverage results
|
|
47
|
+
// coverageThreshold: undefined,
|
|
48
|
+
|
|
49
|
+
// A path to a custom dependency extractor
|
|
50
|
+
// dependencyExtractor: undefined,
|
|
51
|
+
|
|
52
|
+
// Make calling deprecated APIs throw helpful error messages
|
|
53
|
+
// errorOnDeprecated: false,
|
|
54
|
+
|
|
55
|
+
// The default configuration for fake timers
|
|
56
|
+
// fakeTimers: {
|
|
57
|
+
// "enableGlobally": false
|
|
58
|
+
// },
|
|
59
|
+
|
|
60
|
+
// Force coverage collection from ignored files using an array of glob patterns
|
|
61
|
+
// forceCoverageMatch: [],
|
|
62
|
+
|
|
63
|
+
// A path to a module which exports an async function that is triggered once before all test suites
|
|
64
|
+
// globalSetup: undefined,
|
|
65
|
+
|
|
66
|
+
// A path to a module which exports an async function that is triggered once after all test suites
|
|
67
|
+
// globalTeardown: undefined,
|
|
68
|
+
|
|
69
|
+
// A set of global variables that need to be available in all test environments
|
|
70
|
+
// globals: {},
|
|
71
|
+
|
|
72
|
+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
|
73
|
+
// maxWorkers: "50%",
|
|
74
|
+
|
|
75
|
+
// An array of directory names to be searched recursively up from the requiring module's location
|
|
76
|
+
// moduleDirectories: [
|
|
77
|
+
// "node_modules"
|
|
78
|
+
// ],
|
|
79
|
+
|
|
80
|
+
// An array of file extensions your modules use
|
|
81
|
+
// moduleFileExtensions: [
|
|
82
|
+
// "js",
|
|
83
|
+
// "mjs",
|
|
84
|
+
// "cjs",
|
|
85
|
+
// "jsx",
|
|
86
|
+
// "ts",
|
|
87
|
+
// "tsx",
|
|
88
|
+
// "json",
|
|
89
|
+
// "node"
|
|
90
|
+
// ],
|
|
91
|
+
|
|
92
|
+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
93
|
+
// moduleNameMapper: {},
|
|
94
|
+
|
|
95
|
+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
96
|
+
// modulePathIgnorePatterns: [],
|
|
97
|
+
|
|
98
|
+
// Activates notifications for test results
|
|
99
|
+
// notify: false,
|
|
100
|
+
|
|
101
|
+
// An enum that specifies notification mode. Requires { notify: true }
|
|
102
|
+
// notifyMode: "failure-change",
|
|
103
|
+
|
|
104
|
+
// A preset that is used as a base for Jest's configuration
|
|
105
|
+
// preset: undefined,
|
|
106
|
+
|
|
107
|
+
// Run tests from one or more projects
|
|
108
|
+
// projects: undefined,
|
|
109
|
+
|
|
110
|
+
// Use this configuration option to add custom reporters to Jest
|
|
111
|
+
// reporters: undefined,
|
|
112
|
+
|
|
113
|
+
// Automatically reset mock state before every test
|
|
114
|
+
// resetMocks: false,
|
|
115
|
+
|
|
116
|
+
// Reset the module registry before running each individual test
|
|
117
|
+
// resetModules: false,
|
|
118
|
+
|
|
119
|
+
// A path to a custom resolver
|
|
120
|
+
// resolver: undefined,
|
|
121
|
+
|
|
122
|
+
// Automatically restore mock state and implementation before every test
|
|
123
|
+
// restoreMocks: false,
|
|
124
|
+
|
|
125
|
+
// The root directory that Jest should scan for tests and modules within
|
|
126
|
+
// rootDir: undefined,
|
|
127
|
+
|
|
128
|
+
// A list of paths to directories that Jest should use to search for files in
|
|
129
|
+
// roots: [
|
|
130
|
+
// "<rootDir>"
|
|
131
|
+
// ],
|
|
132
|
+
|
|
133
|
+
// Allows you to use a custom runner instead of Jest's default test runner
|
|
134
|
+
// runner: "jest-runner",
|
|
135
|
+
|
|
136
|
+
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
137
|
+
// setupFiles: [],
|
|
138
|
+
|
|
139
|
+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
140
|
+
// setupFilesAfterEnv: [],
|
|
141
|
+
|
|
142
|
+
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
143
|
+
// slowTestThreshold: 5,
|
|
144
|
+
|
|
145
|
+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
146
|
+
// snapshotSerializers: [],
|
|
147
|
+
|
|
148
|
+
// The test environment that will be used for testing
|
|
149
|
+
// testEnvironment: "jest-environment-node",
|
|
150
|
+
|
|
151
|
+
// Options that will be passed to the testEnvironment
|
|
152
|
+
// testEnvironmentOptions: {},
|
|
153
|
+
|
|
154
|
+
// Adds a location field to test results
|
|
155
|
+
// testLocationInResults: false,
|
|
156
|
+
|
|
157
|
+
// The glob patterns Jest uses to detect test files
|
|
158
|
+
// testMatch: [
|
|
159
|
+
// "**/__tests__/**/*.[jt]s?(x)",
|
|
160
|
+
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
|
161
|
+
// ],
|
|
162
|
+
|
|
163
|
+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
|
164
|
+
// testPathIgnorePatterns: [
|
|
165
|
+
// "\\\\node_modules\\\\"
|
|
166
|
+
// ],
|
|
167
|
+
|
|
168
|
+
// The regexp pattern or array of patterns that Jest uses to detect test files
|
|
169
|
+
// testRegex: [],
|
|
170
|
+
|
|
171
|
+
// This option allows the use of a custom results processor
|
|
172
|
+
// testResultsProcessor: undefined,
|
|
173
|
+
|
|
174
|
+
// This option allows use of a custom test runner
|
|
175
|
+
// testRunner: "jest-circus/runner",
|
|
176
|
+
|
|
177
|
+
// A map from regular expressions to paths to transformers
|
|
178
|
+
// transform: undefined,
|
|
179
|
+
|
|
180
|
+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
181
|
+
// transformIgnorePatterns: [
|
|
182
|
+
// "\\\\node_modules\\\\",
|
|
183
|
+
// "\\.pnp\\.[^\\\\]+$"
|
|
184
|
+
// ],
|
|
185
|
+
|
|
186
|
+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
|
187
|
+
// unmockedModulePathPatterns: undefined,
|
|
188
|
+
|
|
189
|
+
// Indicates whether each individual test should be reported during the run
|
|
190
|
+
// verbose: undefined,
|
|
191
|
+
|
|
192
|
+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
|
193
|
+
// watchPathIgnorePatterns: [],
|
|
194
|
+
|
|
195
|
+
// Whether to use watchman for file crawling
|
|
196
|
+
// watchman: true,
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polfan-server-js-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "JavaScript client library for handling communication with Polfan chat server.",
|
|
5
5
|
"author": "Jarosław Żak",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"start": "webpack serve --config webpack.config.demo.js",
|
|
11
11
|
"build": "webpack && tsc",
|
|
12
12
|
"build:demo": "webpack --config webpack.config.demo.js",
|
|
13
|
-
"test": "jest
|
|
13
|
+
"test": "jest",
|
|
14
14
|
"coverage": "npm run test -- --coverage",
|
|
15
15
|
"prepare": "npm run build",
|
|
16
16
|
"trypublish": "npm publish || true"
|
|
@@ -37,29 +37,11 @@
|
|
|
37
37
|
"mini-css-extract-plugin": "^2.7.2",
|
|
38
38
|
"style-loader": "^3.3.1",
|
|
39
39
|
"terser-webpack-plugin": "^5.3.5",
|
|
40
|
+
"ts-node": "^10.9.2",
|
|
40
41
|
"typescript": "^4.9.4",
|
|
41
42
|
"url-loader": "^4.1.1",
|
|
42
43
|
"webpack": "^5.75.0",
|
|
43
44
|
"webpack-cli": "^5.0.1",
|
|
44
|
-
"webpack-dev-server": "4.11.1"
|
|
45
|
-
"pserv-ts-types": "^0.0.15"
|
|
46
|
-
},
|
|
47
|
-
"jest": {
|
|
48
|
-
"moduleNameMapper": {
|
|
49
|
-
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/scripts/testMock.js",
|
|
50
|
-
"\\.(css|less)$": "<rootDir>/scripts/testMock.js"
|
|
51
|
-
},
|
|
52
|
-
"moduleFileExtensions": [
|
|
53
|
-
"web.js",
|
|
54
|
-
"js",
|
|
55
|
-
"web.ts",
|
|
56
|
-
"ts",
|
|
57
|
-
"web.tsx",
|
|
58
|
-
"tsx",
|
|
59
|
-
"json",
|
|
60
|
-
"web.jsx",
|
|
61
|
-
"jsx",
|
|
62
|
-
"node"
|
|
63
|
-
]
|
|
45
|
+
"webpack-dev-server": "4.11.1"
|
|
64
46
|
}
|
|
65
47
|
}
|
|
@@ -2,14 +2,13 @@ import {
|
|
|
2
2
|
Bye,
|
|
3
3
|
GetSession,
|
|
4
4
|
JoinSpace,
|
|
5
|
-
Ok,
|
|
6
5
|
Session,
|
|
7
6
|
SpaceJoined,
|
|
8
7
|
Error as ErrorType,
|
|
9
8
|
SpaceLeft,
|
|
10
9
|
SpaceMemberJoined,
|
|
11
10
|
SpaceMemberLeft,
|
|
12
|
-
|
|
11
|
+
SpaceMemberUpdated,
|
|
13
12
|
SpaceDeleted,
|
|
14
13
|
SpaceMembers,
|
|
15
14
|
SpaceRooms,
|
|
@@ -24,8 +23,7 @@ import {
|
|
|
24
23
|
NewTopic,
|
|
25
24
|
TopicDeleted,
|
|
26
25
|
NewMessage,
|
|
27
|
-
|
|
28
|
-
SetUserPermissions,
|
|
26
|
+
GetPermissionOverwrites,
|
|
29
27
|
GetComputedPermissions,
|
|
30
28
|
LeaveSpace,
|
|
31
29
|
CreateSpace,
|
|
@@ -36,8 +34,7 @@ import {
|
|
|
36
34
|
DeleteRole,
|
|
37
35
|
AssignRole,
|
|
38
36
|
DeassignRole,
|
|
39
|
-
|
|
40
|
-
GetRolePermissions,
|
|
37
|
+
SetPermissionOverwrites,
|
|
41
38
|
JoinRoom,
|
|
42
39
|
LeaveRoom,
|
|
43
40
|
CreateRoom,
|
|
@@ -45,8 +42,28 @@ import {
|
|
|
45
42
|
GetRoomMembers,
|
|
46
43
|
CreateTopic,
|
|
47
44
|
DeleteTopic,
|
|
48
|
-
CreateMessage,
|
|
49
|
-
|
|
45
|
+
CreateMessage,
|
|
46
|
+
Envelope,
|
|
47
|
+
PermissionOverwrites,
|
|
48
|
+
PermissionOverwritesUpdated,
|
|
49
|
+
RoomMemberUpdated,
|
|
50
|
+
UpdateRole,
|
|
51
|
+
RoleUpdated,
|
|
52
|
+
AckReports,
|
|
53
|
+
Ack,
|
|
54
|
+
GetAckReports,
|
|
55
|
+
UserUpdated,
|
|
56
|
+
UpdateRoom,
|
|
57
|
+
RoomUpdated,
|
|
58
|
+
UpdateSpace,
|
|
59
|
+
SpaceUpdated,
|
|
60
|
+
PermissionOverwriteTargets,
|
|
61
|
+
GetPermissionOverwriteTargets,
|
|
62
|
+
Owners,
|
|
63
|
+
Ok,
|
|
64
|
+
GetOwners,
|
|
65
|
+
CreateOwner, RoleDeleted,
|
|
66
|
+
} from "./types/src/index";
|
|
50
67
|
import {EventTarget} from "./EventTarget";
|
|
51
68
|
|
|
52
69
|
type ArrayOfPromiseResolvers = [(value: any) => void, (reason?: any) => void];
|
|
@@ -114,29 +131,39 @@ export type EventsMap = {
|
|
|
114
131
|
Error: ErrorType,
|
|
115
132
|
Session: Session,
|
|
116
133
|
Permissions: Permissions,
|
|
134
|
+
PermissionOverwrites: PermissionOverwrites,
|
|
135
|
+
PermissionOverwritesUpdated: PermissionOverwritesUpdated,
|
|
136
|
+
PermissionOverwriteTargets: PermissionOverwriteTargets,
|
|
137
|
+
Owners: Owners,
|
|
117
138
|
// Space events
|
|
118
139
|
SpaceJoined: SpaceJoined,
|
|
119
140
|
SpaceLeft: SpaceLeft,
|
|
120
141
|
SpaceMemberJoined: SpaceMemberJoined,
|
|
121
142
|
SpaceMemberLeft: SpaceMemberLeft,
|
|
122
|
-
|
|
143
|
+
SpaceMemberUpdated: SpaceMemberUpdated,
|
|
144
|
+
SpaceUpdated: SpaceUpdated,
|
|
123
145
|
SpaceDeleted: SpaceDeleted,
|
|
124
146
|
SpaceMembers: SpaceMembers,
|
|
125
147
|
SpaceRooms: SpaceRooms,
|
|
126
148
|
NewRole: NewRole,
|
|
127
|
-
RoleDeleted:
|
|
149
|
+
RoleDeleted: RoleDeleted,
|
|
150
|
+
RoleUpdated: RoleUpdated,
|
|
128
151
|
// Room events
|
|
129
152
|
RoomJoined: RoomJoined,
|
|
130
153
|
RoomLeft: RoomLeft,
|
|
131
154
|
RoomMemberJoined: RoomMemberJoined,
|
|
132
155
|
RoomMemberLeft: RoomMemberLeft,
|
|
156
|
+
RoomMemberUpdated: RoomMemberUpdated,
|
|
133
157
|
RoomMembers: RoomMembers,
|
|
134
158
|
NewRoom: NewRoom,
|
|
135
159
|
RoomDeleted: RoomDeleted,
|
|
160
|
+
RoomUpdated: RoomUpdated,
|
|
136
161
|
// Topic events
|
|
137
162
|
NewTopic: NewTopic,
|
|
138
163
|
TopicDeleted: TopicDeleted,
|
|
139
164
|
NewMessage: NewMessage,
|
|
165
|
+
AckReports: AckReports,
|
|
166
|
+
UserUpdated: UserUpdated,
|
|
140
167
|
};
|
|
141
168
|
|
|
142
169
|
/**
|
|
@@ -145,30 +172,37 @@ export type EventsMap = {
|
|
|
145
172
|
export type CommandsMap = {
|
|
146
173
|
// General commands
|
|
147
174
|
GetSession: [GetSession, EventsMap['Session']],
|
|
148
|
-
|
|
149
|
-
|
|
175
|
+
SetPermissionOverwrites: [SetPermissionOverwrites, EventsMap['PermissionOverwritesUpdated']],
|
|
176
|
+
GetPermissionOverwrites: [GetPermissionOverwrites, EventsMap['PermissionOverwrites']],
|
|
150
177
|
GetComputedPermissions: [GetComputedPermissions, EventsMap['Permissions']],
|
|
178
|
+
GetPermissionOverwriteTargets: [GetPermissionOverwriteTargets, EventsMap['PermissionOverwriteTargets']],
|
|
179
|
+
GetOwners: [GetOwners, EventsMap['Owners']],
|
|
180
|
+
CreateOwner: [CreateOwner, EventsMap['Owners']],
|
|
181
|
+
DeleteOwner: [CreateOwner, EventsMap['Owners']],
|
|
151
182
|
// Space commands
|
|
152
183
|
JoinSpace: [JoinSpace, EventsMap['SpaceJoined']],
|
|
153
184
|
LeaveSpace: [LeaveSpace, EventsMap['SpaceLeft']],
|
|
154
185
|
CreateSpace: [CreateSpace, EventsMap['SpaceJoined']],
|
|
186
|
+
UpdateSpace: [UpdateSpace, EventsMap['SpaceUpdated']],
|
|
155
187
|
DeleteSpace: [DeleteSpace, EventsMap['SpaceDeleted']],
|
|
156
188
|
GetSpaceMembers: [GetSpaceMembers, EventsMap['SpaceMembers']],
|
|
157
189
|
GetSpaceRooms: [GetSpaceRooms, EventsMap['SpaceRooms']],
|
|
158
190
|
CreateRole: [CreateRole, EventsMap['NewRole']],
|
|
159
191
|
DeleteRole: [DeleteRole, EventsMap['RoleDeleted']],
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
GetRolePermissions: [GetRolePermissions, EventsMap['Permissions']],
|
|
192
|
+
UpdateRole: [UpdateRole, EventsMap['RoleUpdated']],
|
|
193
|
+
AssignRole: [AssignRole, EventsMap['SpaceMemberUpdated'] | EventsMap['RoomMemberUpdated']],
|
|
194
|
+
DeassignRole: [DeassignRole, EventsMap['SpaceMemberUpdated'] | EventsMap['RoomMemberUpdated']],
|
|
164
195
|
// Room commands
|
|
165
196
|
JoinRoom: [JoinRoom, EventsMap['RoomJoined']],
|
|
166
197
|
LeaveRoom: [LeaveRoom, EventsMap['RoomLeft']],
|
|
167
198
|
CreateRoom: [CreateRoom, EventsMap['NewRoom']],
|
|
168
199
|
DeleteRoom: [DeleteRoom, EventsMap['RoomDeleted']],
|
|
200
|
+
UpdateRoom: [UpdateRoom, EventsMap['RoomUpdated']],
|
|
169
201
|
GetRoomMembers: [GetRoomMembers, EventsMap['RoomMembers']],
|
|
170
202
|
// Topic commands
|
|
171
203
|
CreateTopic: [CreateTopic, EventsMap['NewTopic']],
|
|
172
204
|
DeleteTopic: [DeleteTopic, EventsMap['TopicDeleted']],
|
|
173
205
|
CreateMessage: [CreateMessage, EventsMap['NewMessage']],
|
|
206
|
+
Ack: [Ack, EventsMap['AckReports']],
|
|
207
|
+
GetAckReports: [GetAckReports, EventsMap['AckReports']],
|
|
174
208
|
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
export interface RestClientOptions {
|
|
2
|
-
url?: string;
|
|
3
|
-
token: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface RestClientResponse<T> {
|
|
7
|
-
ok: boolean;
|
|
8
|
-
status: number;
|
|
9
|
-
data: T;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
13
|
-
|
|
14
|
-
export abstract class AbstractRestClient {
|
|
15
|
-
protected abstract defaultUrl: string;
|
|
16
|
-
|
|
17
|
-
public constructor(
|
|
18
|
-
private readonly options: RestClientOptions,
|
|
19
|
-
) {}
|
|
20
|
-
|
|
21
|
-
protected async send<ResponseT = any>(
|
|
22
|
-
method: HttpMethod,
|
|
23
|
-
uri: string,
|
|
24
|
-
data: any = undefined
|
|
25
|
-
): Promise<RestClientResponse<ResponseT>> {
|
|
26
|
-
const headers: any = {
|
|
27
|
-
'Content-Type': 'application/json',
|
|
28
|
-
Accept: 'application/json'
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
if (this.options.token) {
|
|
32
|
-
headers.Authorization = `Bearer ${this.options.token}`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let url = this.getUrl(uri);
|
|
36
|
-
let body = undefined;
|
|
37
|
-
|
|
38
|
-
if (data) {
|
|
39
|
-
if (['GET', 'DELETE'].includes(method)) {
|
|
40
|
-
url += new URLSearchParams(data).toString()
|
|
41
|
-
} else {
|
|
42
|
-
body = JSON.stringify(data);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const result = await fetch(url, {method, body, headers});
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
ok: result.ok,
|
|
50
|
-
status: result.status,
|
|
51
|
-
data: await result.json(),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
protected getUrl(uri: string): string {
|
|
56
|
-
return this.removeEndingSlash(this.options.url ?? this.defaultUrl) + '/' + this.removeStartingSlash(uri);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private removeStartingSlash(text: string): string {
|
|
60
|
-
return text.replace(/^\/+/, '');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private removeEndingSlash(text: string): string {
|
|
64
|
-
return text.replace(/\/+$/, '');
|
|
65
|
-
}
|
|
1
|
+
export interface RestClientOptions {
|
|
2
|
+
url?: string;
|
|
3
|
+
token: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface RestClientResponse<T> {
|
|
7
|
+
ok: boolean;
|
|
8
|
+
status: number;
|
|
9
|
+
data: T;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
13
|
+
|
|
14
|
+
export abstract class AbstractRestClient {
|
|
15
|
+
protected abstract defaultUrl: string;
|
|
16
|
+
|
|
17
|
+
public constructor(
|
|
18
|
+
private readonly options: RestClientOptions,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
protected async send<ResponseT = any>(
|
|
22
|
+
method: HttpMethod,
|
|
23
|
+
uri: string,
|
|
24
|
+
data: any = undefined
|
|
25
|
+
): Promise<RestClientResponse<ResponseT>> {
|
|
26
|
+
const headers: any = {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
Accept: 'application/json'
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (this.options.token) {
|
|
32
|
+
headers.Authorization = `Bearer ${this.options.token}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let url = this.getUrl(uri);
|
|
36
|
+
let body = undefined;
|
|
37
|
+
|
|
38
|
+
if (data) {
|
|
39
|
+
if (['GET', 'DELETE'].includes(method)) {
|
|
40
|
+
url += new URLSearchParams(data).toString()
|
|
41
|
+
} else {
|
|
42
|
+
body = JSON.stringify(data);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const result = await fetch(url, {method, body, headers});
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
ok: result.ok,
|
|
50
|
+
status: result.status,
|
|
51
|
+
data: result.headers.get('content-type')?.includes('json') ? await result.json() : await result.text(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
protected getUrl(uri: string): string {
|
|
56
|
+
return this.removeEndingSlash(this.options.url ?? this.defaultUrl) + '/' + this.removeStartingSlash(uri);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private removeStartingSlash(text: string): string {
|
|
60
|
+
return text.replace(/^\/+/, '');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private removeEndingSlash(text: string): string {
|
|
64
|
+
return text.replace(/\/+$/, '');
|
|
65
|
+
}
|
|
66
66
|
}
|
|
@@ -21,7 +21,7 @@ export class IndexedCollection<KeyT, ValueT> {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
public get(id: KeyT): ValueT |
|
|
24
|
+
public get(id: KeyT): ValueT | undefined {
|
|
25
25
|
return this.items.get(id);
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -81,11 +81,11 @@ export class IndexedObjectCollection<T> {
|
|
|
81
81
|
this._items.set(...(items.map(item => [this.getId(item), item] as [string, T])));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
public get(id: any): T |
|
|
84
|
+
public get(id: any): T | undefined {
|
|
85
85
|
return this._items.get(id);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
public getAt(index: number): T|
|
|
88
|
+
public getAt(index: number): T | undefined {
|
|
89
89
|
return this.items[index];
|
|
90
90
|
}
|
|
91
91
|
|