@devanachat/sdk 0.0.0-stage → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +21 -0
  3. package/README.md +391 -2
  4. package/build/index.cjs.js +3559 -0
  5. package/build/index.cjs.js.map +1 -0
  6. package/build/index.mjs +3517 -0
  7. package/build/index.mjs.map +1 -0
  8. package/build/index.umd.js +2 -0
  9. package/build/index.umd.js.map +1 -0
  10. package/build/types/AbstractChatClient.d.ts +182 -0
  11. package/build/types/AbstractRestClient.d.ts +21 -0
  12. package/build/types/EventTarget.d.ts +32 -0
  13. package/build/types/FilesClient.d.ts +16 -0
  14. package/build/types/IndexedObjectCollection.d.ts +66 -0
  15. package/build/types/Permissions.d.ts +109 -0
  16. package/build/types/WebApiChatClient.d.ts +38 -0
  17. package/build/types/WebSocketChatClient.d.ts +110 -0
  18. package/build/types/index.d.ts +19 -0
  19. package/build/types/protocol/index.d.ts +163 -0
  20. package/build/types/protocol/schemes/BanObject.d.ts +14 -0
  21. package/build/types/protocol/schemes/ChatLocation.d.ts +5 -0
  22. package/build/types/protocol/schemes/Emoticon.d.ts +9 -0
  23. package/build/types/protocol/schemes/Entitlements.d.ts +92 -0
  24. package/build/types/protocol/schemes/Envelope.d.ts +5 -0
  25. package/build/types/protocol/schemes/FollowedTopic.d.ts +10 -0
  26. package/build/types/protocol/schemes/LeaveReason.d.ts +9 -0
  27. package/build/types/protocol/schemes/Message.d.ts +32 -0
  28. package/build/types/protocol/schemes/MessagePoll.d.ts +10 -0
  29. package/build/types/protocol/schemes/PermissionOverwritesTarget.d.ts +5 -0
  30. package/build/types/protocol/schemes/PermissionOverwritesValue.d.ts +4 -0
  31. package/build/types/protocol/schemes/Reaction.d.ts +13 -0
  32. package/build/types/protocol/schemes/Role.d.ts +20 -0
  33. package/build/types/protocol/schemes/Room.d.ts +17 -0
  34. package/build/types/protocol/schemes/RoomHistory.d.ts +5 -0
  35. package/build/types/protocol/schemes/RoomMember.d.ts +11 -0
  36. package/build/types/protocol/schemes/RoomStream.d.ts +5 -0
  37. package/build/types/protocol/schemes/RoomSummary.d.ts +14 -0
  38. package/build/types/protocol/schemes/SessionData.d.ts +10 -0
  39. package/build/types/protocol/schemes/Space.d.ts +19 -0
  40. package/build/types/protocol/schemes/SpaceMember.d.ts +7 -0
  41. package/build/types/protocol/schemes/SpaceSummary.d.ts +8 -0
  42. package/build/types/protocol/schemes/Topic.d.ts +8 -0
  43. package/build/types/protocol/schemes/User.d.ts +23 -0
  44. package/build/types/protocol/schemes/UserData.d.ts +10 -0
  45. package/build/types/protocol/schemes/UserInformation.d.ts +11 -0
  46. package/build/types/protocol/schemes/UserRelationship.d.ts +6 -0
  47. package/build/types/protocol/schemes/UserState.d.ts +6 -0
  48. package/build/types/protocol/schemes/commands/Ack.d.ts +5 -0
  49. package/build/types/protocol/schemes/commands/AssignRole.d.ts +6 -0
  50. package/build/types/protocol/schemes/commands/Ban.d.ts +10 -0
  51. package/build/types/protocol/schemes/commands/CreateAccessTicket.d.ts +13 -0
  52. package/build/types/protocol/schemes/commands/CreateEmoticon.d.ts +5 -0
  53. package/build/types/protocol/schemes/commands/CreateMessage.d.ts +11 -0
  54. package/build/types/protocol/schemes/commands/CreateOwner.d.ts +5 -0
  55. package/build/types/protocol/schemes/commands/CreateRelationship.d.ts +5 -0
  56. package/build/types/protocol/schemes/commands/CreateRole.d.ts +6 -0
  57. package/build/types/protocol/schemes/commands/CreateRoom.d.ts +9 -0
  58. package/build/types/protocol/schemes/commands/CreateSpace.d.ts +6 -0
  59. package/build/types/protocol/schemes/commands/CreateTopic.d.ts +11 -0
  60. package/build/types/protocol/schemes/commands/DeassignRole.d.ts +6 -0
  61. package/build/types/protocol/schemes/commands/DeleteEmoticon.d.ts +3 -0
  62. package/build/types/protocol/schemes/commands/DeleteOwner.d.ts +5 -0
  63. package/build/types/protocol/schemes/commands/DeleteRelationship.d.ts +5 -0
  64. package/build/types/protocol/schemes/commands/DeleteRole.d.ts +4 -0
  65. package/build/types/protocol/schemes/commands/DeleteRoom.d.ts +3 -0
  66. package/build/types/protocol/schemes/commands/DeleteSpace.d.ts +3 -0
  67. package/build/types/protocol/schemes/commands/DeleteTopic.d.ts +4 -0
  68. package/build/types/protocol/schemes/commands/FollowTopic.d.ts +4 -0
  69. package/build/types/protocol/schemes/commands/GetBans.d.ts +6 -0
  70. package/build/types/protocol/schemes/commands/GetClientData.d.ts +2 -0
  71. package/build/types/protocol/schemes/commands/GetComputedPermissions.d.ts +10 -0
  72. package/build/types/protocol/schemes/commands/GetDiscoverableSpaces.d.ts +2 -0
  73. package/build/types/protocol/schemes/commands/GetEmoticons.d.ts +3 -0
  74. package/build/types/protocol/schemes/commands/GetEntitlements.d.ts +8 -0
  75. package/build/types/protocol/schemes/commands/GetFollowedTopics.d.ts +4 -0
  76. package/build/types/protocol/schemes/commands/GetInvited.d.ts +3 -0
  77. package/build/types/protocol/schemes/commands/GetMessages.d.ts +13 -0
  78. package/build/types/protocol/schemes/commands/GetOwners.d.ts +4 -0
  79. package/build/types/protocol/schemes/commands/GetPermissionOverwriteTargets.d.ts +4 -0
  80. package/build/types/protocol/schemes/commands/GetPermissionOverwrites.d.ts +6 -0
  81. package/build/types/protocol/schemes/commands/GetReactionDetails.d.ts +8 -0
  82. package/build/types/protocol/schemes/commands/GetRelationships.d.ts +2 -0
  83. package/build/types/protocol/schemes/commands/GetRoomMembers.d.ts +3 -0
  84. package/build/types/protocol/schemes/commands/GetRoomSummary.d.ts +4 -0
  85. package/build/types/protocol/schemes/commands/GetSession.d.ts +2 -0
  86. package/build/types/protocol/schemes/commands/GetSessionData.d.ts +2 -0
  87. package/build/types/protocol/schemes/commands/GetSpaceMembers.d.ts +3 -0
  88. package/build/types/protocol/schemes/commands/GetSpaceRooms.d.ts +3 -0
  89. package/build/types/protocol/schemes/commands/GetSpaceSummary.d.ts +3 -0
  90. package/build/types/protocol/schemes/commands/GetTopics.d.ts +4 -0
  91. package/build/types/protocol/schemes/commands/GetUserData.d.ts +2 -0
  92. package/build/types/protocol/schemes/commands/GetUserInfo.d.ts +3 -0
  93. package/build/types/protocol/schemes/commands/Invite.d.ts +5 -0
  94. package/build/types/protocol/schemes/commands/JoinRoom.d.ts +13 -0
  95. package/build/types/protocol/schemes/commands/JoinSpace.d.ts +3 -0
  96. package/build/types/protocol/schemes/commands/Kick.d.ts +7 -0
  97. package/build/types/protocol/schemes/commands/LeaveRoom.d.ts +3 -0
  98. package/build/types/protocol/schemes/commands/LeaveSpace.d.ts +3 -0
  99. package/build/types/protocol/schemes/commands/Ping.d.ts +2 -0
  100. package/build/types/protocol/schemes/commands/React.d.ts +6 -0
  101. package/build/types/protocol/schemes/commands/RedactMessages.d.ts +3 -0
  102. package/build/types/protocol/schemes/commands/ReportAbuse.d.ts +9 -0
  103. package/build/types/protocol/schemes/commands/SetClientData.d.ts +1 -0
  104. package/build/types/protocol/schemes/commands/SetPermissionOverwrites.d.ts +8 -0
  105. package/build/types/protocol/schemes/commands/SetSessionData.d.ts +17 -0
  106. package/build/types/protocol/schemes/commands/SetUserData.d.ts +6 -0
  107. package/build/types/protocol/schemes/commands/Unban.d.ts +3 -0
  108. package/build/types/protocol/schemes/commands/UnfollowTopic.d.ts +4 -0
  109. package/build/types/protocol/schemes/commands/Uninvite.d.ts +5 -0
  110. package/build/types/protocol/schemes/commands/Unreact.d.ts +6 -0
  111. package/build/types/protocol/schemes/commands/UpdateFollowedTopic.d.ts +6 -0
  112. package/build/types/protocol/schemes/commands/UpdateRole.d.ts +8 -0
  113. package/build/types/protocol/schemes/commands/UpdateRoom.d.ts +10 -0
  114. package/build/types/protocol/schemes/commands/UpdateRoomMember.d.ts +8 -0
  115. package/build/types/protocol/schemes/commands/UpdateSpace.d.ts +12 -0
  116. package/build/types/protocol/schemes/commands/UpdateSpaceMember.d.ts +6 -0
  117. package/build/types/protocol/schemes/commands/UpdateTopic.d.ts +5 -0
  118. package/build/types/protocol/schemes/events/AccessTicket.d.ts +14 -0
  119. package/build/types/protocol/schemes/events/Bans.d.ts +6 -0
  120. package/build/types/protocol/schemes/events/Bye.d.ts +4 -0
  121. package/build/types/protocol/schemes/events/ClientData.d.ts +1 -0
  122. package/build/types/protocol/schemes/events/ComputedPermissions.d.ts +9 -0
  123. package/build/types/protocol/schemes/events/DiscoverableSpaces.d.ts +4 -0
  124. package/build/types/protocol/schemes/events/EmoticonDeleted.d.ts +4 -0
  125. package/build/types/protocol/schemes/events/Emoticons.d.ts +6 -0
  126. package/build/types/protocol/schemes/events/EntitlementUsage.d.ts +11 -0
  127. package/build/types/protocol/schemes/events/Entitlements.d.ts +12 -0
  128. package/build/types/protocol/schemes/events/Error.d.ts +4 -0
  129. package/build/types/protocol/schemes/events/FollowedTopicUpdated.d.ts +4 -0
  130. package/build/types/protocol/schemes/events/FollowedTopics.d.ts +6 -0
  131. package/build/types/protocol/schemes/events/Invited.d.ts +10 -0
  132. package/build/types/protocol/schemes/events/Messages.d.ts +9 -0
  133. package/build/types/protocol/schemes/events/MessagesRedacted.d.ts +5 -0
  134. package/build/types/protocol/schemes/events/NewEmoticon.d.ts +4 -0
  135. package/build/types/protocol/schemes/events/NewMessage.d.ts +4 -0
  136. package/build/types/protocol/schemes/events/NewRelationship.d.ts +4 -0
  137. package/build/types/protocol/schemes/events/NewRole.d.ts +5 -0
  138. package/build/types/protocol/schemes/events/NewRoom.d.ts +5 -0
  139. package/build/types/protocol/schemes/events/NewTopic.d.ts +5 -0
  140. package/build/types/protocol/schemes/events/Ok.d.ts +2 -0
  141. package/build/types/protocol/schemes/events/Owners.d.ts +8 -0
  142. package/build/types/protocol/schemes/events/PermissionOverwriteTargets.d.ts +10 -0
  143. package/build/types/protocol/schemes/events/PermissionOverwrites.d.ts +8 -0
  144. package/build/types/protocol/schemes/events/PermissionOverwritesUpdated.d.ts +8 -0
  145. package/build/types/protocol/schemes/events/Pong.d.ts +2 -0
  146. package/build/types/protocol/schemes/events/Reacted.d.ts +9 -0
  147. package/build/types/protocol/schemes/events/ReactionDetails.d.ts +11 -0
  148. package/build/types/protocol/schemes/events/ReactionUpdated.d.ts +8 -0
  149. package/build/types/protocol/schemes/events/RelationshipDeleted.d.ts +4 -0
  150. package/build/types/protocol/schemes/events/Relationships.d.ts +4 -0
  151. package/build/types/protocol/schemes/events/RoleDeleted.d.ts +4 -0
  152. package/build/types/protocol/schemes/events/RoleUpdated.d.ts +5 -0
  153. package/build/types/protocol/schemes/events/RoomDeleted.d.ts +3 -0
  154. package/build/types/protocol/schemes/events/RoomJoined.d.ts +4 -0
  155. package/build/types/protocol/schemes/events/RoomLeft.d.ts +5 -0
  156. package/build/types/protocol/schemes/events/RoomMemberLeft.d.ts +4 -0
  157. package/build/types/protocol/schemes/events/RoomMemberUpdated.d.ts +6 -0
  158. package/build/types/protocol/schemes/events/RoomMembers.d.ts +5 -0
  159. package/build/types/protocol/schemes/events/RoomMembersJoined.d.ts +9 -0
  160. package/build/types/protocol/schemes/events/RoomSummary.d.ts +4 -0
  161. package/build/types/protocol/schemes/events/RoomSummaryUpdated.d.ts +8 -0
  162. package/build/types/protocol/schemes/events/RoomUpdated.d.ts +4 -0
  163. package/build/types/protocol/schemes/events/Session.d.ts +9 -0
  164. package/build/types/protocol/schemes/events/SpaceDeleted.d.ts +3 -0
  165. package/build/types/protocol/schemes/events/SpaceJoined.d.ts +4 -0
  166. package/build/types/protocol/schemes/events/SpaceLeft.d.ts +5 -0
  167. package/build/types/protocol/schemes/events/SpaceMemberJoined.d.ts +5 -0
  168. package/build/types/protocol/schemes/events/SpaceMemberLeft.d.ts +4 -0
  169. package/build/types/protocol/schemes/events/SpaceMemberUpdated.d.ts +6 -0
  170. package/build/types/protocol/schemes/events/SpaceMembers.d.ts +5 -0
  171. package/build/types/protocol/schemes/events/SpaceRooms.d.ts +5 -0
  172. package/build/types/protocol/schemes/events/SpaceSummary.d.ts +4 -0
  173. package/build/types/protocol/schemes/events/SpaceUpdated.d.ts +4 -0
  174. package/build/types/protocol/schemes/events/TopicDeleted.d.ts +4 -0
  175. package/build/types/protocol/schemes/events/TopicFollowed.d.ts +4 -0
  176. package/build/types/protocol/schemes/events/TopicUnfollowed.d.ts +4 -0
  177. package/build/types/protocol/schemes/events/TopicUpdated.d.ts +6 -0
  178. package/build/types/protocol/schemes/events/Topics.d.ts +6 -0
  179. package/build/types/protocol/schemes/events/UserInfo.d.ts +4 -0
  180. package/build/types/protocol/schemes/events/UserUpdated.d.ts +4 -0
  181. package/build/types/state-tracker/AsyncUtils.d.ts +15 -0
  182. package/build/types/state-tracker/ChatStateTracker.d.ts +41 -0
  183. package/build/types/state-tracker/EmoticonsManager.d.ts +15 -0
  184. package/build/types/state-tracker/FollowedTopicsManager.d.ts +85 -0
  185. package/build/types/state-tracker/MessagesManager.d.ts +24 -0
  186. package/build/types/state-tracker/PermissionsManager.d.ts +47 -0
  187. package/build/types/state-tracker/RelationshipsManager.d.ts +15 -0
  188. package/build/types/state-tracker/RoomMessagesHistory.d.ts +69 -0
  189. package/build/types/state-tracker/RoomsManager.d.ts +72 -0
  190. package/build/types/state-tracker/SpacesManager.d.ts +63 -0
  191. package/build/types/state-tracker/TopicHistoryWindow.d.ts +182 -0
  192. package/build/types/state-tracker/UsersManager.d.ts +23 -0
  193. package/build/types/state-tracker/functions.d.ts +6 -0
  194. package/package.json +67 -4
@@ -0,0 +1,5 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ export interface MessagesRedacted {
3
+ location: ChatLocation;
4
+ ids: string[];
5
+ }
@@ -0,0 +1,4 @@
1
+ import { Emoticon } from "../Emoticon";
2
+ export interface NewEmoticon {
3
+ emoticon: Emoticon;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Message } from "../Message";
2
+ export interface NewMessage {
3
+ message: Message;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { UserRelationship } from "../UserRelationship";
2
+ export interface NewRelationship {
3
+ relationship: UserRelationship;
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Role } from "../Role";
2
+ export interface NewRole {
3
+ spaceId: string;
4
+ role: Role;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { RoomSummary } from "../RoomSummary";
2
+ export interface NewRoom {
3
+ summary: RoomSummary;
4
+ spaceId: string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Topic } from "../Topic";
2
+ export interface NewTopic {
3
+ roomId: string;
4
+ topic: Topic;
5
+ }
@@ -0,0 +1,2 @@
1
+ export interface Ok {
2
+ }
@@ -0,0 +1,8 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ import { RoomMember } from "../RoomMember";
3
+ import { SpaceMember } from "../SpaceMember";
4
+ export interface Owners {
5
+ location: ChatLocation;
6
+ spaceMembers: SpaceMember[] | null;
7
+ roomMembers: RoomMember[] | null;
8
+ }
@@ -0,0 +1,10 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ import { SpaceMember } from "../SpaceMember";
3
+ import { RoomMember } from "../RoomMember";
4
+ import { Role } from "../Role";
5
+ export interface PermissionOverwriteTargets {
6
+ location: ChatLocation;
7
+ spaceMembers: SpaceMember[] | null;
8
+ roomMembers: RoomMember[] | null;
9
+ roles: Role[] | null;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { PermissionOverwritesValue } from "../PermissionOverwritesValue";
2
+ import { ChatLocation } from "../ChatLocation";
3
+ import { PermissionOverwritesTarget } from "../PermissionOverwritesTarget";
4
+ export interface PermissionOverwrites {
5
+ location: ChatLocation;
6
+ target: PermissionOverwritesTarget;
7
+ overwrites: PermissionOverwritesValue;
8
+ }
@@ -0,0 +1,8 @@
1
+ import { PermissionOverwritesValue } from "../PermissionOverwritesValue";
2
+ import { ChatLocation } from "../ChatLocation";
3
+ import { PermissionOverwritesTarget } from "../PermissionOverwritesTarget";
4
+ export interface PermissionOverwritesUpdated {
5
+ location: ChatLocation;
6
+ target: PermissionOverwritesTarget;
7
+ overwrites: PermissionOverwritesValue;
8
+ }
@@ -0,0 +1,2 @@
1
+ export interface Pong {
2
+ }
@@ -0,0 +1,9 @@
1
+ import { ToggledReaction } from "../Reaction";
2
+ /**
3
+ * Sent to every client of the voting user, so all of their devices know what they
4
+ * voted for without refetching the message history.
5
+ */
6
+ export interface Reacted {
7
+ messageId: string;
8
+ reaction: ToggledReaction;
9
+ }
@@ -0,0 +1,11 @@
1
+ import { ReactionType } from "../Reaction";
2
+ /**
3
+ * Who reacted, oldest vote first. Only the ids travel - the nicks are already
4
+ * known from the room members collection.
5
+ */
6
+ export interface ReactionDetails {
7
+ messageId: string;
8
+ type: ReactionType;
9
+ value: string;
10
+ userIds: string[];
11
+ }
@@ -0,0 +1,8 @@
1
+ import { MessageReaction } from "../Reaction";
2
+ /**
3
+ * The single source of truth of a reaction counter, broadcast to the whole room.
4
+ */
5
+ export interface ReactionUpdated {
6
+ messageId: string;
7
+ reaction: MessageReaction;
8
+ }
@@ -0,0 +1,4 @@
1
+ import { UserRelationship } from "../UserRelationship";
2
+ export interface RelationshipDeleted {
3
+ relationship: UserRelationship;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { UserRelationship } from "../UserRelationship";
2
+ export interface Relationships {
3
+ relationships: UserRelationship[];
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface RoleDeleted {
2
+ id: string;
3
+ spaceId: string;
4
+ }
@@ -0,0 +1,5 @@
1
+ import { Role } from "../Role";
2
+ export interface RoleUpdated {
3
+ spaceId: string;
4
+ role: Role;
5
+ }
@@ -0,0 +1,3 @@
1
+ export interface RoomDeleted {
2
+ id: string;
3
+ }
@@ -0,0 +1,4 @@
1
+ import { Room } from "../Room";
2
+ export interface RoomJoined {
3
+ room: Room;
4
+ }
@@ -0,0 +1,5 @@
1
+ import { LeaveReason } from "../LeaveReason";
2
+ export interface RoomLeft {
3
+ id: string;
4
+ reason: LeaveReason;
5
+ }
@@ -0,0 +1,4 @@
1
+ export interface RoomMemberLeft {
2
+ roomId: string;
3
+ userId: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { RoomMember } from "../RoomMember";
2
+ export interface RoomMemberUpdated {
3
+ roomId: string;
4
+ userId: string;
5
+ member: RoomMember;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { RoomMember } from "../RoomMember";
2
+ export interface RoomMembers {
3
+ id: string;
4
+ members: RoomMember[];
5
+ }
@@ -0,0 +1,9 @@
1
+ import { RoomMember } from "../RoomMember";
2
+ export interface RoomMembersJoined {
3
+ roomId: string;
4
+ members: RoomMember[];
5
+ /**
6
+ * Id of the user who added the members to the room, null when they joined on their own.
7
+ */
8
+ addedByUserId: string | null;
9
+ }
@@ -0,0 +1,4 @@
1
+ import { RoomSummary as RoomSummaryTheme } from "../RoomSummary";
2
+ export interface RoomSummary {
3
+ summary: RoomSummaryTheme;
4
+ }
@@ -0,0 +1,8 @@
1
+ import { RoomSummary } from "../RoomSummary";
2
+ export interface RoomSummaryUpdated {
3
+ /**
4
+ * Partial summary - the client merges it into the cached one.
5
+ * Private rooms do not emit this event at all.
6
+ */
7
+ summary: RoomSummary;
8
+ }
@@ -0,0 +1,4 @@
1
+ import { Room } from "../Room";
2
+ export interface RoomUpdated {
3
+ room: Room;
4
+ }
@@ -0,0 +1,9 @@
1
+ import { UserState } from "../UserState";
2
+ import { User } from "../User";
3
+ export interface Session {
4
+ serverVersion: string;
5
+ protoVersion: string;
6
+ state: UserState;
7
+ user: User;
8
+ ict?: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ export interface SpaceDeleted {
2
+ id: string;
3
+ }
@@ -0,0 +1,4 @@
1
+ import { Space } from "../Space";
2
+ export interface SpaceJoined {
3
+ space: Space;
4
+ }
@@ -0,0 +1,5 @@
1
+ import { LeaveReason } from "../LeaveReason";
2
+ export interface SpaceLeft {
3
+ id: string;
4
+ reason: LeaveReason;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { SpaceMember } from "../SpaceMember";
2
+ export interface SpaceMemberJoined {
3
+ spaceId: string;
4
+ member: SpaceMember;
5
+ }
@@ -0,0 +1,4 @@
1
+ export interface SpaceMemberLeft {
2
+ spaceId: string;
3
+ userId: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { SpaceMember } from "../SpaceMember";
2
+ export interface SpaceMemberUpdated {
3
+ spaceId: string;
4
+ userId: string;
5
+ member: SpaceMember;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { SpaceMember } from "../SpaceMember";
2
+ export interface SpaceMembers {
3
+ id: string;
4
+ members: SpaceMember[];
5
+ }
@@ -0,0 +1,5 @@
1
+ import { RoomSummary } from "../RoomSummary";
2
+ export interface SpaceRooms {
3
+ id: string;
4
+ summaries: RoomSummary[];
5
+ }
@@ -0,0 +1,4 @@
1
+ import { SpaceSummary as SpaceSummaryScheme } from "../SpaceSummary";
2
+ export interface SpaceSummary {
3
+ summary: SpaceSummaryScheme;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { Space } from "../Space";
2
+ export interface SpaceUpdated {
3
+ space: Space;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ export interface TopicDeleted {
3
+ location: ChatLocation;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { FollowedTopic } from "../FollowedTopic";
2
+ export interface TopicFollowed {
3
+ followedTopic: FollowedTopic;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ export interface TopicUnfollowed {
3
+ location: ChatLocation;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ import { Topic } from "../Topic";
3
+ export interface TopicUpdated {
4
+ location: ChatLocation;
5
+ topic: Topic;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ import { Topic } from "../Topic";
3
+ export interface Topics {
4
+ location: ChatLocation;
5
+ topics: Topic[];
6
+ }
@@ -0,0 +1,4 @@
1
+ import { UserInformation } from "../UserInformation";
2
+ export interface UserInfo {
3
+ info: UserInformation;
4
+ }
@@ -0,0 +1,4 @@
1
+ import { User } from "../User";
2
+ export interface UserUpdated {
3
+ user: User;
4
+ }
@@ -0,0 +1,15 @@
1
+ export declare class DeferredTask {
2
+ readonly promise: Promise<void>;
3
+ resolve: () => void;
4
+ constructor();
5
+ }
6
+ export declare class PromiseRegistry {
7
+ private promises;
8
+ register<T = any>(promise: Promise<T>, key: string): void;
9
+ registerByFunction(fn: () => Promise<any>, key: string): void;
10
+ get<T = any>(key: string): Promise<T> | undefined;
11
+ has(key: string): boolean;
12
+ notExist(key: string): boolean;
13
+ forget(...keys: string[]): void;
14
+ forgetAll(): void;
15
+ }
@@ -0,0 +1,41 @@
1
+ import { WebSocketChatClient } from "../WebSocketChatClient";
2
+ import { User } from "../protocol";
3
+ import { RoomsManager } from "./RoomsManager";
4
+ import { SpacesManager } from "./SpacesManager";
5
+ import { PermissionsManager } from "./PermissionsManager";
6
+ import { EmoticonsManager } from "./EmoticonsManager";
7
+ import { UsersManager } from "./UsersManager";
8
+ import { RelationshipsManager } from "./RelationshipsManager";
9
+ export declare class ChatStateTracker {
10
+ readonly client: WebSocketChatClient;
11
+ /**
12
+ * State of your permissions.
13
+ */
14
+ readonly permissions: PermissionsManager;
15
+ /**
16
+ * State of the rooms you are in.
17
+ */
18
+ readonly rooms: RoomsManager;
19
+ /**
20
+ * State of the spaces you are in.
21
+ */
22
+ readonly spaces: SpacesManager;
23
+ /**
24
+ * State of the emoticons (global and space-related).
25
+ */
26
+ readonly emoticons: EmoticonsManager;
27
+ /**
28
+ * Users related state.
29
+ */
30
+ readonly users: UsersManager;
31
+ /**
32
+ * State of relationships with other users.
33
+ */
34
+ readonly relationships: RelationshipsManager;
35
+ private _me;
36
+ private readonly deferredSession;
37
+ constructor(client: WebSocketChatClient);
38
+ get me(): User | null;
39
+ getMe(): Promise<User>;
40
+ private handleSession;
41
+ }
@@ -0,0 +1,15 @@
1
+ import { ChatStateTracker } from "./ChatStateTracker";
2
+ import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
3
+ import { Emoticon } from "../protocol";
4
+ export declare class EmoticonsManager {
5
+ private tracker;
6
+ private list;
7
+ private emoticonsPromises;
8
+ constructor(tracker: ChatStateTracker);
9
+ get(spaceId?: string): Promise<ObservableIndexedObjectCollection<Emoticon>>;
10
+ private handleEmoticons;
11
+ private handleNewEmoticon;
12
+ private handleEmoticonDeleted;
13
+ private handleSpaceDeleted;
14
+ private handleSession;
15
+ }
@@ -0,0 +1,85 @@
1
+ import { EventTarget } from "../EventTarget";
2
+ import { ChatStateTracker } from "./ChatStateTracker";
3
+ import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
4
+ import { ChatLocation, FollowedTopic } from "../protocol";
5
+ interface EventMap {
6
+ change: {};
7
+ }
8
+ export interface UnreadSummary {
9
+ mentionCount: number;
10
+ unreadTopicCount: number;
11
+ unreadRoomCount: number;
12
+ isUnread: boolean;
13
+ }
14
+ export declare class FollowedTopicsManager extends EventTarget<EventMap> {
15
+ private tracker;
16
+ private readonly followedTopics;
17
+ private readonly followedTopicsPromises;
18
+ private readonly deferredSession;
19
+ private readonly summariesCache;
20
+ /**
21
+ * Rooms whose cached followed-topics are stale after a reconnect and must
22
+ * be refetched (and reconciled in place) the next time they are accessed.
23
+ */
24
+ private readonly staleRooms;
25
+ constructor(tracker: ChatStateTracker);
26
+ /**
27
+ * Cache followed topics for all joined rooms in a space and fetch them in bulk if necessary.
28
+ * Then you can get them using getRoomFollowedTopics().
29
+ * @see getForRoom
30
+ */
31
+ cacheForSpace(spaceId: string | null): Promise<void>;
32
+ /**
33
+ * Get followed topics for the given room.
34
+ * @return Undefined if you are not in the room, collection otherwise.
35
+ */
36
+ getForRoom(roomId: string): Promise<ObservableIndexedObjectCollection<FollowedTopic> | undefined>;
37
+ /**
38
+ * Batch acknowledge all messages for given room.
39
+ */
40
+ ackRoom(roomId: string): Promise<void>;
41
+ /**
42
+ * Summarize all unread messages or mentions from any topic in given location.
43
+ * This method uses an internal cache, so it's ok to call it multiple times.
44
+ * Capture the 'change' event to determine when it's worth calling this method again due to data changes.
45
+ * @return Undefined if you are not in room.
46
+ */
47
+ summarize(location: ChatLocation): Promise<UnreadSummary>;
48
+ /**
49
+ * For internal use. If you want to delete the message, execute a proper command on client object.
50
+ * @internal
51
+ */
52
+ _deleteByTopicIds(roomId: string, ...topicIds: string[]): void;
53
+ private handleSession;
54
+ private handleNewMessage;
55
+ private handleFollowedTopicUpdated;
56
+ private handleTopicFollowed;
57
+ private handleTopicUnfollowed;
58
+ private handleRoomDeleted;
59
+ private handleRoomJoin;
60
+ private handleRoomLeft;
61
+ private handleNewTopic;
62
+ private handleTopicDeleted;
63
+ /**
64
+ * Invalidate the summaries cache intentionally, only for the locations affected by the change.
65
+ */
66
+ private invalidateUnreadSummaries;
67
+ private invalidateUnreadSummariesForRooms;
68
+ private updateLocallyFollowedTopicOnNewMessage;
69
+ /**
70
+ * Reconcile the followed-topics collection for a single room to exactly
71
+ * match the provided list (upsert present, drop absent) without emitting an
72
+ * intermediate empty state, and clear its stale marker. Does not touch the
73
+ * unread summaries cache - callers decide how to invalidate it.
74
+ */
75
+ private applyRoomFollowedTopics;
76
+ /**
77
+ * Reconcile a batch of rooms from a single bulk GetFollowedTopics response.
78
+ * Rooms with no followed topics in the response are reconciled to empty, so
79
+ * topics unfollowed/removed during the downtime are correctly dropped.
80
+ */
81
+ private reconcileRoomsFollowedTopics;
82
+ private setFollowedTopicsArray;
83
+ private clearRoomFollowedTopicsStructures;
84
+ }
85
+ export {};
@@ -0,0 +1,24 @@
1
+ import { ChatStateTracker } from "./ChatStateTracker";
2
+ import { Message, ChatLocation } from "../protocol";
3
+ import { RoomMessagesHistory } from "./RoomMessagesHistory";
4
+ export declare class MessagesManager {
5
+ private tracker;
6
+ private readonly roomHistories;
7
+ private readonly deferredSession;
8
+ constructor(tracker: ChatStateTracker);
9
+ /**
10
+ * Get history manager for given room ID.
11
+ */
12
+ getRoomHistory(roomId: string): Promise<RoomMessagesHistory | undefined>;
13
+ /**
14
+ * For internal use.
15
+ * @internal
16
+ */
17
+ _resolveLastMessage(location: ChatLocation): Promise<Message | null>;
18
+ private forEachRoomHistory;
19
+ private createHistoryForNewRoom;
20
+ private handleRoomDeleted;
21
+ private handleRoomJoin;
22
+ private handleRoomLeft;
23
+ private handleSession;
24
+ }
@@ -0,0 +1,47 @@
1
+ import { ChatStateTracker } from "./ChatStateTracker";
2
+ import { ChatLocation, PermissionOverwrites, PermissionOverwritesTarget } from "../protocol";
3
+ import { ChangeEventMap, EventTarget } from "../EventTarget";
4
+ import { Permissions } from "../Permissions";
5
+ interface CheckPermissionsResult {
6
+ /**
7
+ * @deprecated Use `hasAll` instead.
8
+ */
9
+ ok: boolean;
10
+ hasAll: boolean;
11
+ hasAny: boolean;
12
+ missing: string[];
13
+ }
14
+ type PermissionsManagerEventMap = ChangeEventMap<void>;
15
+ export declare class PermissionsManager extends EventTarget<PermissionsManagerEventMap> {
16
+ private tracker;
17
+ private readonly overwrites;
18
+ private readonly overwritesPromises;
19
+ constructor(tracker: ChatStateTracker);
20
+ getOverwrites(location: ChatLocation, target: PermissionOverwritesTarget): Promise<PermissionOverwrites | undefined>;
21
+ check(permissionNames: (keyof typeof Permissions.list)[], location: ChatLocation): Promise<CheckPermissionsResult>;
22
+ calculatePermissions(location: ChatLocation): Promise<number>;
23
+ /**
24
+ * Arriving overwrites change the permissions only when they replace different ones. The first ones fetched for a
25
+ * key have not been part of any result yet - every calculation needing them awaits their fetch - and a fetch
26
+ * response arrives twice, as the command result and as an event.
27
+ */
28
+ private handlePermissionOverwrites;
29
+ private handleSpaceDeleted;
30
+ private handleRoomDeleted;
31
+ private handleTopicDeleted;
32
+ private handleRoleDeleted;
33
+ private handleSpaceMemberUpdated;
34
+ private handleRoomMemberUpdated;
35
+ /**
36
+ * @return Matched and deleted ids
37
+ */
38
+ private deleteOverwritesByIdPrefix;
39
+ private collectRoleOverwrites;
40
+ private resolveOverwritesFromRolesByOrder;
41
+ private resolveOverwritesHierarchy;
42
+ private getRootAccessValue;
43
+ private fetchMembersOrFail;
44
+ private validateLocation;
45
+ private handleSession;
46
+ }
47
+ export {};
@@ -0,0 +1,15 @@
1
+ import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
2
+ import { UserRelationship, UserRelationshipType } from "../protocol";
3
+ import { ChatStateTracker } from "./ChatStateTracker";
4
+ export declare class RelationshipsManager {
5
+ private tracker;
6
+ private relationships;
7
+ private promises;
8
+ constructor(tracker: ChatStateTracker);
9
+ get(): Promise<ObservableIndexedObjectCollection<UserRelationship>>;
10
+ exists(refUserId: string, type: UserRelationshipType): Promise<boolean>;
11
+ private handleRelationships;
12
+ private handleNewRelationship;
13
+ private handleRelationshipDeleted;
14
+ private handleSession;
15
+ }