polfan-server-js-client 0.2.47 → 0.2.49

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.
@@ -57,7 +57,7 @@ import { LeaveRoom } from "./schemes/commands/LeaveRoom";
57
57
  import { CreateRoom } from "./schemes/commands/CreateRoom";
58
58
  import { DeleteRoom } from "./schemes/commands/DeleteRoom";
59
59
  import { GetRoomMembers } from "./schemes/commands/GetRoomMembers";
60
- import { CreateTopic } from "./schemes/commands/CreateTopic";
60
+ import { CreateTopic, CreateTopicInitialMessage } from "./schemes/commands/CreateTopic";
61
61
  import { DeleteTopic } from "./schemes/commands/DeleteTopic";
62
62
  import { CreateMessage } from "./schemes/commands/CreateMessage";
63
63
  import { UpdateRole } from "./schemes/commands/UpdateRole";
@@ -111,6 +111,7 @@ import { GetClientData } from "./schemes/commands/GetClientData";
111
111
  import { SetClientData } from "./schemes/commands/SetClientData";
112
112
  import { ClientData } from "./schemes/events/ClientData";
113
113
  import { RoomStream, RoomStreamType } from "./schemes/RoomStream";
114
+ import { RoomHistory, RoomHistoryMode } from "./schemes/RoomHistory";
114
115
  import { GetRoomSummary } from "./schemes/commands/GetRoomSummary";
115
116
  import { GetSpaceSummary } from "./schemes/commands/GetSpaceSummary";
116
117
  import { SpaceFlag } from "./schemes/Space";
@@ -123,4 +124,4 @@ import { UserRelationship, UserRelationshipType } from "./schemes/UserRelationsh
123
124
  import { DeleteRelationship } from "./schemes/commands/DeleteRelationship";
124
125
  import { Relationships } from "./schemes/events/Relationships";
125
126
  import { CreateRelationship } from "./schemes/commands/CreateRelationship";
126
- export { Envelope, Message, MessageType, MessageAuthor, Role, Room, RoomFlag, RoomType, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceFlag, SpaceMember, Topic, FollowedTopic, User, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, RoomStream, RoomStreamType, UserRelationship, UserRelationshipType, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, 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, TopicUpdated, PermissionOverwriteTargets, Owners, Ok, DiscoverableSpaces, Emoticons, EmoticonDeleted, NewEmoticon, Bans, ClientData, SpaceSummaryEvent, RoomSummaryEvent, NewRelationship, RelationshipDeleted, Relationships, AssignRole, GetMessages, 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, UpdateTopic, GetPermissionOverwriteTargets, CreateOwner, DeleteOwner, GetOwners, Topics, GetTopics, GetDiscoverableSpaces, GetEmoticons, CreateEmoticon, DeleteEmoticon, Ban, Unban, GetBans, Kick, GetClientData, SetClientData, GetSpaceSummary, GetRoomSummary, SetCustomNick, CreateRelationship, DeleteRelationship };
127
+ export { Envelope, Message, MessageType, MessageAuthor, Role, Room, RoomFlag, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceFlag, SpaceMember, Topic, FollowedTopic, User, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, 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, TopicUpdated, PermissionOverwriteTargets, Owners, Ok, DiscoverableSpaces, Emoticons, EmoticonDeleted, NewEmoticon, Bans, ClientData, SpaceSummaryEvent, RoomSummaryEvent, NewRelationship, RelationshipDeleted, Relationships, AssignRole, GetMessages, 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, UpdateTopic, GetPermissionOverwriteTargets, CreateOwner, DeleteOwner, GetOwners, Topics, GetTopics, GetDiscoverableSpaces, GetEmoticons, CreateEmoticon, DeleteEmoticon, Ban, Unban, GetBans, Kick, GetClientData, SetClientData, GetSpaceSummary, GetRoomSummary, SetCustomNick, CreateRelationship, DeleteRelationship };
@@ -1,6 +1,6 @@
1
1
  import { User } from "./User";
2
2
  import { ChatLocation } from "./ChatLocation";
3
- export type MessageType = 'Text' | 'RoomJoin' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'System';
3
+ export type MessageType = 'Text' | 'RoomJoin' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'Ephemeral';
4
4
  export interface MessageAuthor {
5
5
  user: User;
6
6
  customNick?: string;
@@ -1,6 +1,7 @@
1
1
  import { Topic } from "./Topic";
2
2
  import { User } from "./User";
3
3
  import { RoomStream } from "./RoomStream";
4
+ import { RoomHistory } from "./RoomHistory";
4
5
  export type RoomType = 'Text' | 'ClassicText' | 'Pm';
5
6
  export declare enum RoomFlag {
6
7
  AllowSystemMessages = 1,
@@ -16,4 +17,5 @@ export interface Room {
16
17
  recipients: User[] | null;
17
18
  flags: number;
18
19
  stream: RoomStream | null;
20
+ history: RoomHistory | null;
19
21
  }
@@ -0,0 +1,5 @@
1
+ export type RoomHistoryMode = 'Full' | 'Ephemeral' | 'MaxAge';
2
+ export interface RoomHistory {
3
+ mode: RoomHistoryMode;
4
+ maxAge?: number;
5
+ }
@@ -6,6 +6,7 @@ export interface RoomSummary {
6
6
  id: string;
7
7
  name: string;
8
8
  description: string;
9
+ memberCount: number;
9
10
  type: RoomType;
10
11
  extras?: RoomSummaryExtras;
11
12
  }
@@ -1,8 +1,11 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
- import { CreateMessage } from "./CreateMessage";
2
+ export interface CreateTopicInitialMessage {
3
+ content?: string;
4
+ attachments?: string[];
5
+ }
3
6
  export interface CreateTopic {
4
7
  location: ChatLocation;
5
8
  name: string;
6
9
  refMessageId?: string;
7
- initialMessage?: Omit<CreateMessage, 'location'>;
10
+ initialMessage?: CreateTopicInitialMessage;
8
11
  }
@@ -1,8 +1,10 @@
1
1
  import { RoomStream } from "../RoomStream";
2
+ import { RoomHistory } from "../RoomHistory";
2
3
  export interface UpdateRoom {
3
4
  id: string;
4
5
  name?: string;
5
6
  description?: string;
6
7
  flags?: number;
7
8
  stream?: RoomStream | null;
9
+ history?: RoomHistory;
8
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polfan-server-js-client",
3
- "version": "0.2.47",
3
+ "version": "0.2.49",
4
4
  "description": "JavaScript client library for handling communication with Polfan chat server.",
5
5
  "author": "Jarosław Żak",
6
6
  "license": "MIT",
@@ -39,10 +39,12 @@ export class IndexedCollection<KeyT, ValueT> {
39
39
  for (const id of ids) {
40
40
  this.items.delete(id);
41
41
  }
42
+ this._mutationCounter++;
42
43
  }
43
44
 
44
45
  public deleteAll(): void {
45
46
  this.items.clear();
47
+ this._mutationCounter++;
46
48
  }
47
49
 
48
50
  public findBy(field: keyof ValueT, valueToFind: any, limit: number = null): IndexedCollection<KeyT, ValueT> {
@@ -209,10 +209,9 @@ export class MessagesManager {
209
209
  private updateLocallyFollowedTopicOnNewMessage(ev: NewMessage): void {
210
210
  const roomFollowedTopics = this.followedTopics.get(ev.message.location.roomId);
211
211
  const followedTopic = roomFollowedTopics?.get(ev.message.location.topicId);
212
- const ephemeralMessageTypes = ['System'] as MessageType[];
213
212
 
214
- if (!roomFollowedTopics || !followedTopic || ephemeralMessageTypes.includes(ev.message.type)) {
215
- // Skip if we don't follow this room or targeted topic or message is ephemeral
213
+ if (!roomFollowedTopics || !followedTopic || ev.message.type === 'Ephemeral') {
214
+ // Skip if we don't follow this room or targeted topic or the message is ephemeral
216
215
  return;
217
216
  }
218
217
 
@@ -57,7 +57,7 @@ import {LeaveRoom} from "./schemes/commands/LeaveRoom";
57
57
  import {CreateRoom} from "./schemes/commands/CreateRoom";
58
58
  import {DeleteRoom} from "./schemes/commands/DeleteRoom";
59
59
  import {GetRoomMembers} from "./schemes/commands/GetRoomMembers";
60
- import {CreateTopic} from "./schemes/commands/CreateTopic";
60
+ import {CreateTopic, CreateTopicInitialMessage} from "./schemes/commands/CreateTopic";
61
61
  import {DeleteTopic} from "./schemes/commands/DeleteTopic";
62
62
  import {CreateMessage} from "./schemes/commands/CreateMessage";
63
63
  import {UpdateRole} from "./schemes/commands/UpdateRole";
@@ -111,6 +111,7 @@ import {GetClientData} from "./schemes/commands/GetClientData";
111
111
  import {SetClientData} from "./schemes/commands/SetClientData";
112
112
  import {ClientData} from "./schemes/events/ClientData";
113
113
  import {RoomStream, RoomStreamType} from "./schemes/RoomStream";
114
+ import {RoomHistory, RoomHistoryMode} from "./schemes/RoomHistory";
114
115
  import {GetRoomSummary} from "./schemes/commands/GetRoomSummary";
115
116
  import {GetSpaceSummary} from "./schemes/commands/GetSpaceSummary";
116
117
  import {SpaceFlag} from "./schemes/Space";
@@ -134,6 +135,10 @@ export {
134
135
  Room,
135
136
  RoomFlag,
136
137
  RoomType,
138
+ RoomStream,
139
+ RoomStreamType,
140
+ RoomHistory,
141
+ RoomHistoryMode,
137
142
  RoomMember,
138
143
  RoomSummary,
139
144
  RoomSummaryExtras,
@@ -152,10 +157,9 @@ export {
152
157
  PermissionOverwritesTarget,
153
158
  BanObject,
154
159
  LeaveReason,
155
- RoomStream,
156
- RoomStreamType,
157
160
  UserRelationship,
158
161
  UserRelationshipType,
162
+ CreateTopicInitialMessage,
159
163
  // events
160
164
  Bye,
161
165
  Error,
@@ -1,7 +1,7 @@
1
1
  import {User} from "./User";
2
2
  import {ChatLocation} from "./ChatLocation";
3
3
 
4
- export type MessageType = 'Text'|'RoomJoin'|'RoomLeave'|'SpaceJoin'|'SpaceLeave'|'TopicChange'|'CustomNickChange'|'System';
4
+ export type MessageType = 'Text'|'RoomJoin'|'RoomLeave'|'SpaceJoin'|'SpaceLeave'|'TopicChange'|'CustomNickChange'|'Ephemeral';
5
5
 
6
6
  export interface MessageAuthor {
7
7
  user: User;
@@ -1,6 +1,7 @@
1
1
  import {Topic} from "./Topic";
2
2
  import {User} from "./User";
3
3
  import {RoomStream} from "./RoomStream";
4
+ import {RoomHistory} from "./RoomHistory";
4
5
 
5
6
  export type RoomType = 'Text' | 'ClassicText' | 'Pm';
6
7
 
@@ -19,4 +20,5 @@ export interface Room {
19
20
  recipients: User[] | null;
20
21
  flags: number;
21
22
  stream: RoomStream | null;
23
+ history: RoomHistory | null;
22
24
  }
@@ -0,0 +1,6 @@
1
+ export type RoomHistoryMode = 'Full' | 'Ephemeral' | 'MaxAge';
2
+
3
+ export interface RoomHistory {
4
+ mode: RoomHistoryMode;
5
+ maxAge?: number;
6
+ }
@@ -8,6 +8,7 @@ export interface RoomSummary {
8
8
  id: string;
9
9
  name: string;
10
10
  description: string;
11
+ memberCount: number;
11
12
  type: RoomType;
12
13
  extras?: RoomSummaryExtras;
13
14
  }
@@ -1,9 +1,13 @@
1
1
  import {ChatLocation} from "../ChatLocation";
2
- import {CreateMessage} from "./CreateMessage";
2
+
3
+ export interface CreateTopicInitialMessage {
4
+ content?: string;
5
+ attachments?: string[];
6
+ }
3
7
 
4
8
  export interface CreateTopic {
5
9
  location: ChatLocation;
6
10
  name: string;
7
11
  refMessageId?: string;
8
- initialMessage?: Omit<CreateMessage, 'location'>;
12
+ initialMessage?: CreateTopicInitialMessage;
9
13
  }
@@ -1,4 +1,5 @@
1
1
  import {RoomStream} from "../RoomStream";
2
+ import {RoomHistory} from "../RoomHistory";
2
3
 
3
4
  export interface UpdateRoom {
4
5
  id: string;
@@ -6,4 +7,5 @@ export interface UpdateRoom {
6
7
  description?: string;
7
8
  flags?: number;
8
9
  stream?: RoomStream | null;
10
+ history?: RoomHistory;
9
11
  }