polfan-server-js-client 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.idea/workspace.xml +71 -242
  2. package/build/index.cjs.js +219 -125
  3. package/build/index.cjs.js.map +1 -1
  4. package/build/index.umd.js +1 -1
  5. package/build/index.umd.js.map +1 -1
  6. package/build/types/AbstractChatClient.d.ts +7 -1
  7. package/build/types/Permissions.d.ts +8 -0
  8. package/build/types/state-tracker/TopicHistoryWindow.d.ts +26 -1
  9. package/build/types/types/src/index.d.ts +9 -1
  10. package/build/types/types/src/schemes/Message.d.ts +5 -1
  11. package/build/types/types/src/schemes/MessagePoll.d.ts +10 -0
  12. package/build/types/types/src/schemes/Reaction.d.ts +13 -0
  13. package/build/types/types/src/schemes/commands/CreateMessage.d.ts +3 -0
  14. package/build/types/types/src/schemes/commands/GetMessages.d.ts +5 -0
  15. package/build/types/types/src/schemes/commands/GetReactionDetails.d.ts +8 -0
  16. package/build/types/types/src/schemes/commands/React.d.ts +6 -0
  17. package/build/types/types/src/schemes/commands/Unreact.d.ts +6 -0
  18. package/build/types/types/src/schemes/events/Messages.d.ts +3 -0
  19. package/build/types/types/src/schemes/events/Reacted.d.ts +9 -0
  20. package/build/types/types/src/schemes/events/ReactionDetails.d.ts +11 -0
  21. package/build/types/types/src/schemes/events/ReactionUpdated.d.ts +8 -0
  22. package/package.json +43 -43
  23. package/src/AbstractChatClient.ts +12 -0
  24. package/src/Permissions.ts +2 -0
  25. package/src/index.ts +31 -31
  26. package/src/state-tracker/TopicHistoryWindow.ts +121 -42
  27. package/src/state-tracker/UsersManager.ts +51 -51
  28. package/src/types/src/index.ts +333 -313
  29. package/src/types/src/schemes/Message.ts +5 -1
  30. package/src/types/src/schemes/MessagePoll.ts +12 -0
  31. package/src/types/src/schemes/Reaction.ts +16 -0
  32. package/src/types/src/schemes/commands/CreateMessage.ts +3 -0
  33. package/src/types/src/schemes/commands/GetMessages.ts +5 -0
  34. package/src/types/src/schemes/commands/GetReactionDetails.ts +9 -0
  35. package/src/types/src/schemes/commands/React.ts +7 -0
  36. package/src/types/src/schemes/commands/Unreact.ts +7 -0
  37. package/src/types/src/schemes/events/Messages.ts +3 -0
  38. package/src/types/src/schemes/events/Reacted.ts +10 -0
  39. package/src/types/src/schemes/events/ReactionDetails.ts +12 -0
  40. package/src/types/src/schemes/events/ReactionUpdated.ts +9 -0
@@ -1,7 +1,9 @@
1
1
  import {User} from "./User";
2
2
  import {ChatLocation} from "./ChatLocation";
3
+ import {MessageReaction} from "./Reaction";
4
+ import {MessagePoll} from "./MessagePoll";
3
5
 
4
- export type MessageType = 'Text'|'RoomJoin'|'RoomMemberAdd'|'RoomLeave'|'SpaceJoin'|'SpaceLeave'|'TopicChange'|'CustomNickChange'|'Ephemeral';
6
+ export type MessageType = 'Text'|'RoomJoin'|'RoomMemberAdd'|'RoomLeave'|'SpaceJoin'|'SpaceLeave'|'TopicChange'|'CustomNickChange'|'Ephemeral'|'Poll';
5
7
 
6
8
  export interface MessageAuthor {
7
9
  user: User;
@@ -18,4 +20,6 @@ export interface Message {
18
20
  content?: string;
19
21
  topicRef: string | null;
20
22
  attachments: string[] | null;
23
+ reactions: MessageReaction[];
24
+ poll?: MessagePoll;
21
25
  }
@@ -0,0 +1,12 @@
1
+ import {ReactionType} from "./Reaction";
2
+
3
+ export interface MessagePollOption {
4
+ type: ReactionType;
5
+ value: string;
6
+ label: string;
7
+ }
8
+
9
+ export interface MessagePoll {
10
+ multipleChoice: boolean;
11
+ options: MessagePollOption[];
12
+ }
@@ -0,0 +1,16 @@
1
+ export type ReactionType = 'Emoji' | 'Emoticon';
2
+
3
+ export interface MessageReaction {
4
+ type: ReactionType;
5
+ value: string;
6
+ count: number;
7
+ }
8
+
9
+ export interface UserReaction {
10
+ type: ReactionType;
11
+ value: string;
12
+ }
13
+
14
+ export interface ToggledReaction extends UserReaction {
15
+ isAdded: boolean;
16
+ }
@@ -1,4 +1,5 @@
1
1
  import {ChatLocation} from "../ChatLocation";
2
+ import {MessagePoll} from "../MessagePoll";
2
3
 
3
4
  export interface CreateMessage {
4
5
  location: ChatLocation;
@@ -6,4 +7,6 @@ export interface CreateMessage {
6
7
  attachments?: string[];
7
8
  customNick?: string;
8
9
  customColor?: string;
10
+ /** Turns the message into a poll; its content becomes the question. */
11
+ poll?: MessagePoll;
9
12
  }
@@ -6,4 +6,9 @@ export interface GetMessages {
6
6
  after?: string;
7
7
  around?: string;
8
8
  limit?: number;
9
+ /**
10
+ * Pull the reactions of the asking user along with the messages, instead of
11
+ * asking for their own state separately.
12
+ */
13
+ includeMyReactions?: boolean;
9
14
  }
@@ -0,0 +1,9 @@
1
+ import {ReactionType} from "../Reaction";
2
+
3
+ export interface GetReactionDetails {
4
+ messageId: string;
5
+ type: ReactionType;
6
+ value: string;
7
+ limit?: number;
8
+ offset?: number;
9
+ }
@@ -0,0 +1,7 @@
1
+ import {ReactionType} from "../Reaction";
2
+
3
+ export interface React {
4
+ messageId: string;
5
+ type: ReactionType;
6
+ value: string;
7
+ }
@@ -0,0 +1,7 @@
1
+ import {ReactionType} from "../Reaction";
2
+
3
+ export interface Unreact {
4
+ messageId: string;
5
+ type: ReactionType;
6
+ value: string;
7
+ }
@@ -1,7 +1,10 @@
1
1
  import {ChatLocation} from "../ChatLocation";
2
2
  import {Message} from "../Message";
3
+ import {UserReaction} from "../Reaction";
3
4
 
4
5
  export interface Messages {
5
6
  location: ChatLocation;
6
7
  messages: Message[];
8
+ /** Message id => reactions of the asking user; present only when requested. */
9
+ myReactions?: Record<string, UserReaction[]>;
7
10
  }
@@ -0,0 +1,10 @@
1
+ import {ToggledReaction} from "../Reaction";
2
+
3
+ /**
4
+ * Sent to every client of the voting user, so all of their devices know what they
5
+ * voted for without refetching the message history.
6
+ */
7
+ export interface Reacted {
8
+ messageId: string;
9
+ reaction: ToggledReaction;
10
+ }
@@ -0,0 +1,12 @@
1
+ import {ReactionType} from "../Reaction";
2
+
3
+ /**
4
+ * Who reacted, oldest vote first. Only the ids travel - the nicks are already
5
+ * known from the room members collection.
6
+ */
7
+ export interface ReactionDetails {
8
+ messageId: string;
9
+ type: ReactionType;
10
+ value: string;
11
+ userIds: string[];
12
+ }
@@ -0,0 +1,9 @@
1
+ import {MessageReaction} from "../Reaction";
2
+
3
+ /**
4
+ * The single source of truth of a reaction counter, broadcast to the whole room.
5
+ */
6
+ export interface ReactionUpdated {
7
+ messageId: string;
8
+ reaction: MessageReaction;
9
+ }