@devanachat/sdk 0.6.0 → 0.8.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.
- package/CHANGELOG.md +70 -0
- package/README.md +58 -0
- package/build/index.cjs.js +749 -38
- package/build/index.cjs.js.map +1 -1
- package/build/index.mjs +748 -39
- package/build/index.mjs.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +3 -1
- package/build/types/Permissions.d.ts +8 -0
- package/build/types/index.d.ts +4 -2
- package/build/types/protocol/index.d.ts +5 -3
- package/build/types/protocol/schemes/RoomSummary.d.ts +1 -0
- package/build/types/protocol/schemes/commands/GetComputedPermissions.d.ts +2 -2
- package/build/types/protocol/schemes/commands/SearchMessages.d.ts +18 -0
- package/build/types/protocol/schemes/events/Error.d.ts +10 -0
- package/build/types/protocol/schemes/events/FoundMessages.d.ts +16 -0
- package/build/types/state-tracker/ChatStateTracker.d.ts +29 -0
- package/build/types/state-tracker/EmoticonsManager.d.ts +16 -0
- package/build/types/state-tracker/FollowedTopicsManager.d.ts +16 -0
- package/build/types/state-tracker/MessagesManager.d.ts +23 -3
- package/build/types/state-tracker/PermissionsManager.d.ts +4 -0
- package/build/types/state-tracker/RelationshipsManager.d.ts +11 -0
- package/build/types/state-tracker/RoomMessagesHistory.d.ts +21 -3
- package/build/types/state-tracker/RoomsManager.d.ts +32 -0
- package/build/types/state-tracker/SpacesManager.d.ts +16 -0
- package/build/types/state-tracker/StateSnapshot.d.ts +102 -0
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +24 -1
- package/build/types/state-tracker/UsersManager.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bye, GetSession, JoinSpace, Session, SpaceJoined, Error as ErrorType, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMemberUpdated, SpaceDeleted, SpaceMembers, SpaceRooms, NewRole, RoomDeleted, RoomJoined, RoomLeft, RoomMemberLeft, RoomMembersJoined, RoomMembers, NewRoom, NewTopic, TopicDeleted, NewMessage, GetPermissionOverwrites, GetComputedPermissions, ComputedPermissions, LeaveSpace, CreateSpace, DeleteSpace, GetSpaceMembers, GetSpaceRooms, CreateRole, DeleteRole, AssignRole, DeassignRole, SetPermissionOverwrites, JoinRoom, LeaveRoom, CreateRoom, DeleteRoom, GetRoomMembers, CreateTopic, DeleteTopic, CreateMessage, Envelope, PermissionOverwrites, PermissionOverwritesUpdated, RoomMemberUpdated, UpdateRole, RoleUpdated, Ack, UserUpdated, UpdateRoom, RoomUpdated, UpdateSpace, SpaceUpdated, PermissionOverwriteTargets, GetPermissionOverwriteTargets, Owners, Ok, GetOwners, CreateOwner, RoleDeleted, FollowedTopicUpdated, TopicFollowed, FollowedTopics, FollowTopic, UpdateFollowedTopic, GetFollowedTopics, Messages, GetMessages, Topics, GetTopics, TopicUpdated, UpdateTopic, GetDiscoverableSpaces, DiscoverableSpaces, CreateEmoticon, DeleteEmoticon, GetEmoticons, Emoticons, EmoticonDeleted, NewEmoticon, Bans, GetBans, Ban, Unban, Kick, ClientData, GetClientData, SetClientData, GetRoomSummary, GetSpaceSummary, RoomSummaryEvent, SpaceSummaryEvent, UpdateSpaceMember, Relationships, RelationshipDeleted, NewRelationship, DeleteRelationship, CreateRelationship, RoomSummaryUpdated, Pong, Ping, RedactMessages, MessagesRedacted, ReportAbuse, UpdateRoomMember, GetRelationships, GetUserInfo, UserInfo, SetSessionData, SessionData, GetSessionData, SetUserData, UserData, GetUserData, UnfollowTopic, TopicUnfollowed, Invite, Uninvite, GetInvited, Invited, React, Unreact, GetReactionDetails, ReactionUpdated, Reacted, ReactionDetails, GetEntitlements, Entitlements, EntitlementUsage, CreateAccessTicket, AccessTicket } from "./protocol";
|
|
1
|
+
import { Bye, GetSession, JoinSpace, Session, SpaceJoined, Error as ErrorType, SpaceLeft, SpaceMemberJoined, SpaceMemberLeft, SpaceMemberUpdated, SpaceDeleted, SpaceMembers, SpaceRooms, NewRole, RoomDeleted, RoomJoined, RoomLeft, RoomMemberLeft, RoomMembersJoined, RoomMembers, NewRoom, NewTopic, TopicDeleted, NewMessage, GetPermissionOverwrites, GetComputedPermissions, ComputedPermissions, LeaveSpace, CreateSpace, DeleteSpace, GetSpaceMembers, GetSpaceRooms, CreateRole, DeleteRole, AssignRole, DeassignRole, SetPermissionOverwrites, JoinRoom, LeaveRoom, CreateRoom, DeleteRoom, GetRoomMembers, CreateTopic, DeleteTopic, CreateMessage, Envelope, PermissionOverwrites, PermissionOverwritesUpdated, RoomMemberUpdated, UpdateRole, RoleUpdated, Ack, UserUpdated, UpdateRoom, RoomUpdated, UpdateSpace, SpaceUpdated, PermissionOverwriteTargets, GetPermissionOverwriteTargets, Owners, Ok, GetOwners, CreateOwner, RoleDeleted, FollowedTopicUpdated, TopicFollowed, FollowedTopics, FollowTopic, UpdateFollowedTopic, GetFollowedTopics, Messages, GetMessages, SearchMessages, FoundMessages, Topics, GetTopics, TopicUpdated, UpdateTopic, GetDiscoverableSpaces, DiscoverableSpaces, CreateEmoticon, DeleteEmoticon, GetEmoticons, Emoticons, EmoticonDeleted, NewEmoticon, Bans, GetBans, Ban, Unban, Kick, ClientData, GetClientData, SetClientData, GetRoomSummary, GetSpaceSummary, RoomSummaryEvent, SpaceSummaryEvent, UpdateSpaceMember, Relationships, RelationshipDeleted, NewRelationship, DeleteRelationship, CreateRelationship, RoomSummaryUpdated, Pong, Ping, RedactMessages, MessagesRedacted, ReportAbuse, UpdateRoomMember, GetRelationships, GetUserInfo, UserInfo, SetSessionData, SessionData, GetSessionData, SetUserData, UserData, GetUserData, UnfollowTopic, TopicUnfollowed, Invite, Uninvite, GetInvited, Invited, React, Unreact, GetReactionDetails, ReactionUpdated, Reacted, ReactionDetails, GetEntitlements, Entitlements, EntitlementUsage, CreateAccessTicket, AccessTicket } from "./protocol";
|
|
2
2
|
import { EventTarget } from "./EventTarget";
|
|
3
3
|
type ArrayOfPromiseResolvers = [(value: any) => void, (reason?: any) => void];
|
|
4
4
|
type ExtraEventMap = Record<string, any>;
|
|
@@ -97,6 +97,7 @@ export type EventsMap = {
|
|
|
97
97
|
FollowedTopics: FollowedTopics;
|
|
98
98
|
FollowedTopicUpdated: FollowedTopicUpdated;
|
|
99
99
|
Messages: Messages;
|
|
100
|
+
FoundMessages: FoundMessages;
|
|
100
101
|
Topics: Topics;
|
|
101
102
|
TopicUpdated: TopicUpdated;
|
|
102
103
|
MessagesRedacted: MessagesRedacted;
|
|
@@ -172,6 +173,7 @@ export type CommandsMap = {
|
|
|
172
173
|
UpdateFollowedTopic: CommandDefinition<UpdateFollowedTopic, EventsMap['FollowedTopicUpdated']>;
|
|
173
174
|
GetFollowedTopics: CommandDefinition<GetFollowedTopics, EventsMap['FollowedTopics']>;
|
|
174
175
|
GetMessages: CommandDefinition<GetMessages, EventsMap['Messages']>;
|
|
176
|
+
SearchMessages: CommandDefinition<SearchMessages, EventsMap['FoundMessages']>;
|
|
175
177
|
GetTopics: CommandDefinition<GetTopics, EventsMap['Topics']>;
|
|
176
178
|
UpdateTopic: CommandDefinition<UpdateTopic, EventsMap['TopicUpdated']>;
|
|
177
179
|
RedactMessages: CommandDefinition<RedactMessages, EventsMap['MessagesRedacted']>;
|
|
@@ -102,6 +102,14 @@ export declare class Permissions {
|
|
|
102
102
|
value: number;
|
|
103
103
|
maxLayer: Layer;
|
|
104
104
|
};
|
|
105
|
+
PreviewRooms: {
|
|
106
|
+
value: number;
|
|
107
|
+
maxLayer: Layer;
|
|
108
|
+
};
|
|
109
|
+
SearchMessages: {
|
|
110
|
+
value: number;
|
|
111
|
+
maxLayer: Layer;
|
|
112
|
+
};
|
|
105
113
|
};
|
|
106
114
|
static getNames(): (keyof typeof this.list)[];
|
|
107
115
|
static getByName(name: keyof typeof this.list): PermissionDefinition | undefined;
|
package/build/types/index.d.ts
CHANGED
|
@@ -4,16 +4,18 @@ import { IndexedCollection, IndexedObjectCollection, ObservableIndexedCollection
|
|
|
4
4
|
import { FilesClient, File } from "./FilesClient";
|
|
5
5
|
import { Permissions, PermissionDefinition, Layer } from "./Permissions";
|
|
6
6
|
import * as ChatTypes from './protocol';
|
|
7
|
-
import { HistoryRotation, NO_LIMIT, RoleFlag, SearchRange, UiPurpose, SpaceFeature, SpaceIntent, STORAGE_UNIT_BYTES, UserFeature, UserStatus } from './protocol';
|
|
7
|
+
import { ErrorCode, HistoryRotation, NO_LIMIT, RoleFlag, SearchRange, UiPurpose, SpaceFeature, SpaceIntent, STORAGE_UNIT_BYTES, UserFeature, UserStatus } from './protocol';
|
|
8
8
|
import { extractUserFromMember } from "./state-tracker/functions";
|
|
9
9
|
import { AbstractRestClient } from "./AbstractRestClient";
|
|
10
10
|
import { UnreadSummary } from "./state-tracker/FollowedTopicsManager";
|
|
11
11
|
import { TopicHistoryWindow } from "./state-tracker/TopicHistoryWindow";
|
|
12
12
|
import { PermissionsManager } from "./state-tracker/PermissionsManager";
|
|
13
|
-
|
|
13
|
+
import { STATE_SNAPSHOT_VERSION } from "./state-tracker/StateSnapshot";
|
|
14
|
+
export { IndexedCollection, ObservableIndexedCollection, IndexedObjectCollection, ObservableIndexedObjectCollection, Permissions, PermissionDefinition, Layer, WebSocketChatClient, WebApiChatClient, FilesClient, AbstractRestClient, extractUserFromMember, ErrorCode, UserStatus, RoleFlag, SpaceFeature, UserFeature, HistoryRotation, SearchRange, UiPurpose, SpaceIntent, NO_LIMIT, STORAGE_UNIT_BYTES, STATE_SNAPSHOT_VERSION, };
|
|
14
15
|
export type { CommandResult, CommandRequest, CommandResponse, CommandsMap, EventsMap, } from "./AbstractChatClient";
|
|
15
16
|
export type { WebSocketClientOptions } from "./WebSocketChatClient";
|
|
16
17
|
export type { WebApiChatClientOptions } from "./WebApiChatClient";
|
|
17
18
|
export type { RestClientOptions, RestClientResponse } from "./AbstractRestClient";
|
|
18
19
|
export type { EventHandler, ObservableInterface } from "./EventTarget";
|
|
20
|
+
export type { StateSnapshot, SpaceRoomsSnapshot, RoomFollowedTopicsSnapshot, EmoticonsSnapshot, StateSnapshotIntent, TopicHistorySnapshot, RoomMembersSnapshot, } from "./state-tracker/StateSnapshot";
|
|
19
21
|
export type { ChatTypes, File, UnreadSummary, TopicHistoryWindow, PermissionsManager, };
|
|
@@ -11,7 +11,7 @@ import { Topic } from "./schemes/Topic";
|
|
|
11
11
|
import { User, UserStatus } from "./schemes/User";
|
|
12
12
|
import { UserState } from "./schemes/UserState";
|
|
13
13
|
import { Bye } from "./schemes/events/Bye";
|
|
14
|
-
import { Error } from "./schemes/events/Error";
|
|
14
|
+
import { Error, ErrorCode } from "./schemes/events/Error";
|
|
15
15
|
import { Session } from "./schemes/events/Session";
|
|
16
16
|
import { ComputedPermissions } from "./schemes/events/ComputedPermissions";
|
|
17
17
|
import { SpaceJoined } from "./schemes/events/SpaceJoined";
|
|
@@ -84,6 +84,8 @@ import { GetFollowedTopics } from "./schemes/commands/GetFollowedTopics";
|
|
|
84
84
|
import { FollowedTopicUpdated } from "./schemes/events/FollowedTopicUpdated";
|
|
85
85
|
import { GetMessages } from "./schemes/commands/GetMessages";
|
|
86
86
|
import { Messages } from "./schemes/events/Messages";
|
|
87
|
+
import { SearchMessages, SearchDate } from "./schemes/commands/SearchMessages";
|
|
88
|
+
import { FoundMessages, FoundMessage, TextRange } from "./schemes/events/FoundMessages";
|
|
87
89
|
import { Topics } from "./schemes/events/Topics";
|
|
88
90
|
import { GetTopics } from "./schemes/commands/GetTopics";
|
|
89
91
|
import { UpdateTopic } from "./schemes/commands/UpdateTopic";
|
|
@@ -159,5 +161,5 @@ import { Entitlements } from "./schemes/events/Entitlements";
|
|
|
159
161
|
import { EntitlementUsage } from "./schemes/events/EntitlementUsage";
|
|
160
162
|
import { CreateAccessTicket, TicketAudience } from "./schemes/commands/CreateAccessTicket";
|
|
161
163
|
import { AccessTicket } from "./schemes/events/AccessTicket";
|
|
162
|
-
export type { Envelope, Message, MessageType, MessageAuthor, MessageMentions, Role, Room, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceMember, Topic, FollowedTopic, NotificationLevel, User, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, UserInformation, SessionPush, SessionData, SessionPlatform, UserData, PrivateMessagePolicy, ReactionType, MessageReaction, UserReaction, ToggledReaction, MessagePoll, MessagePollOption, EntitlementTarget, EntitlementsSubject, EntitlementValue, EntitlementsMap, EntitlementsExtras, TicketAudience, Bye, Error, Messages, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMembersJoined, 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, RoomSummaryUpdated, Pong, MessagesRedacted, UserInfo, Invited, ReactionUpdated, Reacted, ReactionDetails, Entitlements, EntitlementUsage, AccessTicket, AssignRole, GetMessages, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, UpdateFollowedTopic, 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, UpdateSpaceMember, CreateRelationship, DeleteRelationship, GetRelationships, UpdateRoomMember, Ping, ReportAbuse, RedactMessages, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, React, Unreact, GetReactionDetails, GetEntitlements, CreateAccessTicket, };
|
|
163
|
-
export { NO_LIMIT, STORAGE_UNIT_BYTES, HistoryRotation, RoleFlag, SearchRange, SpaceFeature, SpaceIntent, UiPurpose, UserFeature, UserStatus, };
|
|
164
|
+
export type { Envelope, Message, MessageType, MessageAuthor, MessageMentions, Role, Room, RoomType, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomMember, RoomSummary, RoomSummaryExtras, Space, SpaceMember, Topic, FollowedTopic, NotificationLevel, User, UserState, PermissionOverwritesValue, ChatLocation, SpaceSummary, SpaceDiscoverable, Emoticon, PermissionOverwritesTarget, BanObject, LeaveReason, UserRelationship, UserRelationshipType, CreateTopicInitialMessage, UserInformation, SessionPush, SessionData, SessionPlatform, UserData, PrivateMessagePolicy, ReactionType, MessageReaction, UserReaction, ToggledReaction, MessagePoll, MessagePollOption, EntitlementTarget, EntitlementsSubject, EntitlementValue, EntitlementsMap, EntitlementsExtras, TicketAudience, Bye, Error, Messages, FoundMessages, FoundMessage, TextRange, NewMessage, NewRole, NewRoom, NewTopic, TopicFollowed, TopicUnfollowed, FollowedTopics, FollowedTopicUpdated, ComputedPermissions, PermissionOverwrites, PermissionOverwritesUpdated, RoleDeleted, RoleUpdated, RoomDeleted, RoomUpdated, RoomJoined, RoomLeft, RoomMembersJoined, 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, RoomSummaryUpdated, Pong, MessagesRedacted, UserInfo, Invited, ReactionUpdated, Reacted, ReactionDetails, Entitlements, EntitlementUsage, AccessTicket, AssignRole, GetMessages, SearchMessages, SearchDate, CreateMessage, Ack, CreateRole, CreateRoom, CreateSpace, CreateTopic, FollowTopic, UnfollowTopic, UpdateFollowedTopic, 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, UpdateSpaceMember, CreateRelationship, DeleteRelationship, GetRelationships, UpdateRoomMember, Ping, ReportAbuse, RedactMessages, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, React, Unreact, GetReactionDetails, GetEntitlements, CreateAccessTicket, };
|
|
165
|
+
export { ErrorCode, NO_LIMIT, STORAGE_UNIT_BYTES, HistoryRotation, RoleFlag, SearchRange, SpaceFeature, SpaceIntent, UiPurpose, UserFeature, UserStatus, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ChatLocation } from "../ChatLocation";
|
|
2
2
|
/**
|
|
3
3
|
* Computed permissions of a user in the location. Without `userId` those of the requesting
|
|
4
|
-
* user are returned. Another user may be asked about only when
|
|
5
|
-
*
|
|
4
|
+
* user are returned. Another user may be asked about only when you may read the location;
|
|
5
|
+
* on the global layer it requires the global `ManagePermissions` permission.
|
|
6
6
|
*/
|
|
7
7
|
export interface GetComputedPermissions {
|
|
8
8
|
location: ChatLocation;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** `YYYY-MM-DD` in the `timezone` of the command. */
|
|
2
|
+
export type SearchDate = string;
|
|
3
|
+
export interface SearchMessages {
|
|
4
|
+
/** Plain text, without modifiers - filters are the fields below. */
|
|
5
|
+
query?: string;
|
|
6
|
+
spaceId?: string | null;
|
|
7
|
+
/** Defaults to true. */
|
|
8
|
+
privateMessages?: boolean;
|
|
9
|
+
from?: string[];
|
|
10
|
+
in?: string[];
|
|
11
|
+
before?: SearchDate[];
|
|
12
|
+
after?: SearchDate[];
|
|
13
|
+
during?: SearchDate[];
|
|
14
|
+
hasFile?: boolean;
|
|
15
|
+
/** Defaults to `UTC`. */
|
|
16
|
+
timezone?: string;
|
|
17
|
+
cursor?: string | null;
|
|
18
|
+
}
|
|
@@ -2,3 +2,13 @@ export interface Error {
|
|
|
2
2
|
code: string;
|
|
3
3
|
message: string;
|
|
4
4
|
}
|
|
5
|
+
export declare enum ErrorCode {
|
|
6
|
+
Authentication = "AuthenticationException",
|
|
7
|
+
CommandRateLimitExceeded = "CommandRateLimitExceededException",
|
|
8
|
+
InvalidSearchQuery = "InvalidSearchQueryException",
|
|
9
|
+
MessageSearchUnavailable = "MessageSearchUnavailableException",
|
|
10
|
+
MessageNotFound = "MessageNotFoundException",
|
|
11
|
+
RoomNotFound = "RoomNotFoundException",
|
|
12
|
+
TopicNotFound = "TopicNotFoundException",
|
|
13
|
+
UserNotFound = "UserNotFoundException"
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Message } from "../Message";
|
|
2
|
+
/** In UTF-16 code units, `end` exclusive. */
|
|
3
|
+
export interface TextRange {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FoundMessage {
|
|
8
|
+
message: Message;
|
|
9
|
+
spaceId: string | null;
|
|
10
|
+
ranges: TextRange[];
|
|
11
|
+
}
|
|
12
|
+
export interface FoundMessages {
|
|
13
|
+
results: FoundMessage[];
|
|
14
|
+
/** `null` - no more results. */
|
|
15
|
+
cursor: string | null;
|
|
16
|
+
}
|
|
@@ -6,6 +6,7 @@ import { PermissionsManager } from "./PermissionsManager";
|
|
|
6
6
|
import { EmoticonsManager } from "./EmoticonsManager";
|
|
7
7
|
import { UsersManager } from "./UsersManager";
|
|
8
8
|
import { RelationshipsManager } from "./RelationshipsManager";
|
|
9
|
+
import { StateSnapshot, StateSnapshotIntent } from "./StateSnapshot";
|
|
9
10
|
export declare class ChatStateTracker {
|
|
10
11
|
readonly client: WebSocketChatClient;
|
|
11
12
|
/**
|
|
@@ -34,8 +35,36 @@ export declare class ChatStateTracker {
|
|
|
34
35
|
readonly relationships: RelationshipsManager;
|
|
35
36
|
private _me;
|
|
36
37
|
private readonly deferredSession;
|
|
38
|
+
private sessionReceived;
|
|
39
|
+
private snapshotImported;
|
|
37
40
|
constructor(client: WebSocketChatClient);
|
|
38
41
|
get me(): User | null;
|
|
39
42
|
getMe(): Promise<User>;
|
|
43
|
+
/**
|
|
44
|
+
* Export the tracked state to a plain, JSON-serializable object, to be saved and restored with
|
|
45
|
+
* {@link importSnapshot} at the next start of the application, before the connection is established.
|
|
46
|
+
* See {@link StateSnapshot} for what is included.
|
|
47
|
+
* @param intent What to include beyond the state that is always exported, e.g. the message histories.
|
|
48
|
+
* @return Null if there is no state yet (no session has been received or imported).
|
|
49
|
+
*/
|
|
50
|
+
exportSnapshot(intent?: StateSnapshotIntent): StateSnapshot | null;
|
|
51
|
+
/**
|
|
52
|
+
* Restore the state exported with {@link exportSnapshot}, so it is available before the connection is
|
|
53
|
+
* established. The collections emit their usual change events and the getters waiting for the session resolve.
|
|
54
|
+
* The first `Session` from the server then replaces the restored state the same way it does on a reconnect:
|
|
55
|
+
* removed spaces and rooms are dropped, the rest is updated in place, the restored message histories and topics
|
|
56
|
+
* other than the default ones are fetched anew (as a window holding the latest messages is on a reconnect), and
|
|
57
|
+
* the lazily loaded lists are refetched on their next access.
|
|
58
|
+
*
|
|
59
|
+
* Allowed only once and only before the first `Session`.
|
|
60
|
+
* @return False if the snapshot was rejected (another version, malformed data, or a session already received) -
|
|
61
|
+
* the state is not changed then.
|
|
62
|
+
*/
|
|
63
|
+
importSnapshot(snapshot: unknown): boolean;
|
|
40
64
|
private handleSession;
|
|
65
|
+
/**
|
|
66
|
+
* A reconnect keeps the followed topics and emoticons of rooms and spaces that are gone; for the restored ones
|
|
67
|
+
* the first session is the only chance to tell they are gone.
|
|
68
|
+
*/
|
|
69
|
+
private handleSessionAfterImport;
|
|
41
70
|
}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
2
2
|
import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
|
|
3
3
|
import { Emoticon } from "../protocol";
|
|
4
|
+
import { EmoticonsSnapshot } from "./StateSnapshot";
|
|
4
5
|
export declare class EmoticonsManager {
|
|
5
6
|
private tracker;
|
|
6
7
|
private list;
|
|
7
8
|
private emoticonsPromises;
|
|
8
9
|
constructor(tracker: ChatStateTracker);
|
|
9
10
|
get(spaceId?: string): Promise<ObservableIndexedObjectCollection<Emoticon>>;
|
|
11
|
+
/**
|
|
12
|
+
* For internal use.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
_exportEmoticons(): EmoticonsSnapshot[];
|
|
16
|
+
/**
|
|
17
|
+
* Emoticons of spaces other than the given ones are skipped.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
_importEmoticons(snapshots: EmoticonsSnapshot[], spaceIds: string[]): void;
|
|
21
|
+
/**
|
|
22
|
+
* For internal use.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
_forgetSpacesExcept(spaceIds: string[]): void;
|
|
10
26
|
private handleEmoticons;
|
|
11
27
|
private handleNewEmoticon;
|
|
12
28
|
private handleEmoticonDeleted;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventTarget } from "../EventTarget";
|
|
2
2
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
3
3
|
import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
|
|
4
|
+
import { RoomFollowedTopicsSnapshot } from "./StateSnapshot";
|
|
4
5
|
import { ChatLocation, FollowedTopic } from "../protocol";
|
|
5
6
|
interface EventMap {
|
|
6
7
|
change: {};
|
|
@@ -50,6 +51,21 @@ export declare class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
50
51
|
* @internal
|
|
51
52
|
*/
|
|
52
53
|
_deleteByTopicIds(roomId: string, ...topicIds: string[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* For internal use.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
_exportFollowedTopics(): RoomFollowedTopicsSnapshot[];
|
|
59
|
+
/**
|
|
60
|
+
* Expects the rooms to be imported already - followed topics of other rooms are skipped.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
_importFollowedTopics(snapshots: RoomFollowedTopicsSnapshot[]): void;
|
|
64
|
+
/**
|
|
65
|
+
* For internal use.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
_forgetRoomsExcept(roomIds: string[]): void;
|
|
53
69
|
private handleSession;
|
|
54
70
|
private handleNewMessage;
|
|
55
71
|
private handleFollowedTopicUpdated;
|
|
@@ -1,20 +1,40 @@
|
|
|
1
1
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
2
|
-
import { Message, ChatLocation } from "../protocol";
|
|
2
|
+
import { Room, Message, ChatLocation, Topic } from "../protocol";
|
|
3
3
|
import { RoomMessagesHistory } from "./RoomMessagesHistory";
|
|
4
|
+
import { TopicHistoryWindow } from "./TopicHistoryWindow";
|
|
5
|
+
import { TopicHistorySnapshot } from "./StateSnapshot";
|
|
4
6
|
export declare class MessagesManager {
|
|
5
7
|
private tracker;
|
|
6
8
|
private readonly roomHistories;
|
|
9
|
+
private readonly previewHistories;
|
|
7
10
|
private readonly deferredSession;
|
|
8
11
|
constructor(tracker: ChatStateTracker);
|
|
9
12
|
/**
|
|
10
|
-
* Get history manager for given room ID.
|
|
13
|
+
* Get history manager for given room ID. For a room you have not joined it is a preview (requires `PreviewRooms`),
|
|
14
|
+
* kept until {@link forgetRoomPreview} or until you join the room.
|
|
11
15
|
*/
|
|
12
|
-
getRoomHistory(roomId: string): Promise<RoomMessagesHistory
|
|
16
|
+
getRoomHistory(roomId: string): Promise<RoomMessagesHistory>;
|
|
17
|
+
forgetRoomPreview(roomId: string): void;
|
|
13
18
|
/**
|
|
14
19
|
* For internal use.
|
|
15
20
|
* @internal
|
|
16
21
|
*/
|
|
17
22
|
_resolveLastMessage(location: ChatLocation): Promise<Message | null>;
|
|
23
|
+
/**
|
|
24
|
+
* For internal use.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
_importRooms(rooms: Room[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* For internal use.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
_exportLatest(roomId: string, topicId: string, limit: number): ReturnType<TopicHistoryWindow['_exportLatest']>;
|
|
33
|
+
/**
|
|
34
|
+
* For internal use.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
_importHistory(roomId: string, topic: Topic, snapshot: TopicHistorySnapshot): void;
|
|
18
38
|
private forEachRoomHistory;
|
|
19
39
|
private createHistoryForNewRoom;
|
|
20
40
|
private handleRoomDeleted;
|
|
@@ -19,6 +19,9 @@ export declare class PermissionsManager extends EventTarget<PermissionsManagerEv
|
|
|
19
19
|
constructor(tracker: ChatStateTracker);
|
|
20
20
|
getOverwrites(location: ChatLocation, target: PermissionOverwritesTarget): Promise<PermissionOverwrites | undefined>;
|
|
21
21
|
check(permissionNames: (keyof typeof Permissions.list)[], location: ChatLocation): Promise<CheckPermissionsResult>;
|
|
22
|
+
/**
|
|
23
|
+
* For a room or a space you have not joined the permissions are fetched from the server, on every call.
|
|
24
|
+
*/
|
|
22
25
|
calculatePermissions(location: ChatLocation): Promise<number>;
|
|
23
26
|
/**
|
|
24
27
|
* Arriving overwrites change the permissions only when they replace different ones. The first ones fetched for a
|
|
@@ -40,6 +43,7 @@ export declare class PermissionsManager extends EventTarget<PermissionsManagerEv
|
|
|
40
43
|
private resolveOverwritesFromRolesByOrder;
|
|
41
44
|
private resolveOverwritesHierarchy;
|
|
42
45
|
private getRootAccessValue;
|
|
46
|
+
private fetchComputedPermissions;
|
|
43
47
|
private fetchMembersOrFail;
|
|
44
48
|
private validateLocation;
|
|
45
49
|
private handleSession;
|
|
@@ -5,9 +5,20 @@ export declare class RelationshipsManager {
|
|
|
5
5
|
private tracker;
|
|
6
6
|
private relationships;
|
|
7
7
|
private promises;
|
|
8
|
+
private loaded;
|
|
8
9
|
constructor(tracker: ChatStateTracker);
|
|
9
10
|
get(): Promise<ObservableIndexedObjectCollection<UserRelationship>>;
|
|
10
11
|
exists(refUserId: string, type: UserRelationshipType): Promise<boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* For internal use.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
_exportRelationships(): UserRelationship[] | null;
|
|
17
|
+
/**
|
|
18
|
+
* For internal use.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
_importRelationships(relationships: UserRelationship[] | null): void;
|
|
11
22
|
private handleRelationships;
|
|
12
23
|
private handleNewRelationship;
|
|
13
24
|
private handleRelationshipDeleted;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
2
|
-
import { MessagesRedacted, NewMessage, NewTopic, Reacted, ReactionUpdated, Room, RoomUpdated, TopicDeleted } from "../protocol";
|
|
2
|
+
import { Message, MessagesRedacted, NewMessage, NewTopic, Reacted, ReactionUpdated, Room, RoomUpdated, Topic, TopicDeleted, UserReaction } from "../protocol";
|
|
3
3
|
import { TopicHistoryWindow } from "./TopicHistoryWindow";
|
|
4
4
|
/**
|
|
5
5
|
* Does not subscribe to the client itself - the messages manager routes the events of its room to it, so a history
|
|
6
6
|
* dropped together with its room stops receiving them.
|
|
7
7
|
*/
|
|
8
8
|
export declare class RoomMessagesHistory {
|
|
9
|
-
private room;
|
|
10
9
|
private tracker;
|
|
10
|
+
readonly isPreview: boolean;
|
|
11
|
+
private readonly roomId;
|
|
11
12
|
private historyWindows;
|
|
12
13
|
private traverseLock;
|
|
13
|
-
|
|
14
|
+
private room;
|
|
15
|
+
constructor(room: Room | string, tracker: ChatStateTracker);
|
|
14
16
|
/**
|
|
15
17
|
* Returns a history window object for the given topic ID, allowing you to view message history.
|
|
16
18
|
* @param topicId
|
|
@@ -29,6 +31,21 @@ export declare class RoomMessagesHistory {
|
|
|
29
31
|
* untouched so their in-memory context survives the reconnect.
|
|
30
32
|
*/
|
|
31
33
|
resync(room: Room): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* For internal use.
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
get _isEphemeral(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The window of the topic, if created; unlike getMessagesWindow(), never creates nor fetches one.
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
_peekWindow(topicId: string): TopicHistoryWindow | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* For internal use.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
_restoreWindow(topic: Topic, messages: Message[], myReactions: Record<string, UserReaction[]>): void;
|
|
32
49
|
/**
|
|
33
50
|
* For internal use.
|
|
34
51
|
* @internal
|
|
@@ -65,5 +82,6 @@ export declare class RoomMessagesHistory {
|
|
|
65
82
|
*/
|
|
66
83
|
_handleReacted(ev: Reacted): void;
|
|
67
84
|
private createHistoryWindowForTopic;
|
|
85
|
+
private createHistoryWindow;
|
|
68
86
|
private updateTraverseLock;
|
|
69
87
|
}
|
|
@@ -3,6 +3,7 @@ import { Room, RoomMember, Topic } from "../protocol";
|
|
|
3
3
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
4
4
|
import { MessagesManager } from "./MessagesManager";
|
|
5
5
|
import { FollowedTopicsManager } from "./FollowedTopicsManager";
|
|
6
|
+
import { RoomMembersSnapshot, StateSnapshotIntent, TopicHistorySnapshot } from "./StateSnapshot";
|
|
6
7
|
export declare class RoomsManager {
|
|
7
8
|
private tracker;
|
|
8
9
|
readonly messages: MessagesManager;
|
|
@@ -13,6 +14,7 @@ export declare class RoomsManager {
|
|
|
13
14
|
private readonly deferredSession;
|
|
14
15
|
private readonly membersPromises;
|
|
15
16
|
private readonly topicsPromises;
|
|
17
|
+
private readonly importedTopicIds;
|
|
16
18
|
constructor(tracker: ChatStateTracker);
|
|
17
19
|
/**
|
|
18
20
|
* Get collection of room members.
|
|
@@ -41,6 +43,36 @@ export declare class RoomsManager {
|
|
|
41
43
|
* @internal
|
|
42
44
|
*/
|
|
43
45
|
_deleteTopicsFromRoom(roomId: string, ...topicIds: string[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* For internal use.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
_exportRooms(): Room[];
|
|
51
|
+
/**
|
|
52
|
+
* For internal use.
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
_importRooms(rooms: Room[]): void;
|
|
56
|
+
/**
|
|
57
|
+
* For internal use.
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
_exportHistories(intent: StateSnapshotIntent): TopicHistorySnapshot[];
|
|
61
|
+
/**
|
|
62
|
+
* Members of private conversations are not exported - they are made of the recipients of the room.
|
|
63
|
+
* @internal
|
|
64
|
+
*/
|
|
65
|
+
_exportMembers(roomIds: string[], limit: number): RoomMembersSnapshot[];
|
|
66
|
+
/**
|
|
67
|
+
* Expects the rooms to be imported already - histories and members of other rooms are skipped.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
_importHistories(histories: TopicHistorySnapshot[], roomMembers: RoomMembersSnapshot[]): void;
|
|
71
|
+
/**
|
|
72
|
+
* The session carries only the default topics, so the other restored ones are fetched anew.
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
_refreshImportedTopics(): void;
|
|
44
76
|
private deleteRoom;
|
|
45
77
|
private deleteRoomsBySpaceId;
|
|
46
78
|
private handleSpaceMemberUpdated;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChatStateTracker } from "./ChatStateTracker";
|
|
2
2
|
import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
|
|
3
3
|
import { Role, RoomSummary, Space, SpaceMember } from "../protocol";
|
|
4
|
+
import { SpaceRoomsSnapshot } from "./StateSnapshot";
|
|
4
5
|
export declare class SpacesManager {
|
|
5
6
|
private tracker;
|
|
6
7
|
private readonly list;
|
|
@@ -38,6 +39,21 @@ export declare class SpacesManager {
|
|
|
38
39
|
* Get a space member representing the current user.
|
|
39
40
|
*/
|
|
40
41
|
getMe(spaceId: string): Promise<SpaceMember | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* For internal use.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
_exportSpaces(): Space[];
|
|
47
|
+
/**
|
|
48
|
+
* Room listings of the joined spaces only - of other spaces they are fetched for a moment's look.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
_exportSpaceRooms(): SpaceRoomsSnapshot[];
|
|
52
|
+
/**
|
|
53
|
+
* For internal use.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
_importSpaces(spaces: Space[], spaceRooms: SpaceRoomsSnapshot[]): void;
|
|
41
57
|
private handleNewRole;
|
|
42
58
|
private handleNewRoom;
|
|
43
59
|
private handleRoomUpdated;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Emoticon, FollowedTopic, Message, Room, RoomMember, RoomSummary, Space, Topic, User, UserReaction, UserRelationship } from "../protocol";
|
|
2
|
+
/**
|
|
3
|
+
* Version of the {@link StateSnapshot} format. A snapshot of any other version is rejected on import.
|
|
4
|
+
*/
|
|
5
|
+
export declare const STATE_SNAPSHOT_VERSION = 1;
|
|
6
|
+
/**
|
|
7
|
+
* Plain, JSON-serializable copy of the state tracked by {@link ChatStateTracker}, made to restore the state at the
|
|
8
|
+
* application start (before the connection is established) - see {@link ChatStateTracker.exportSnapshot}.
|
|
9
|
+
*
|
|
10
|
+
* Only the data that lasts is included: the current user, the joined spaces (with roles) and rooms (with the default
|
|
11
|
+
* topics), and the lazily loaded lists already fetched - rooms of spaces, followed topics, emoticons and relationships.
|
|
12
|
+
* The message histories of the topics named in the {@link StateSnapshotIntent} are included too, with what their
|
|
13
|
+
* display needs: the topics referenced by the messages and, optionally, the members of the rooms.
|
|
14
|
+
* Left out on purpose:
|
|
15
|
+
* - presence - every user status is saved as `Offline`, a status from the past would show people online who are not;
|
|
16
|
+
* - members of spaces, and of rooms not asked for - large, made mostly of presence, and refetched cheaply on demand;
|
|
17
|
+
* - other message histories and topics, histories of ephemeral rooms (they live only in the memory of the session),
|
|
18
|
+
* permission overwrites and room previews - loaded on demand once the connection is up, as on a reconnect.
|
|
19
|
+
*/
|
|
20
|
+
export interface StateSnapshot {
|
|
21
|
+
version: typeof STATE_SNAPSHOT_VERSION;
|
|
22
|
+
/**
|
|
23
|
+
* Time of the export, in milliseconds since the epoch.
|
|
24
|
+
*/
|
|
25
|
+
createdAt: number;
|
|
26
|
+
user: User;
|
|
27
|
+
spaces: Space[];
|
|
28
|
+
rooms: Room[];
|
|
29
|
+
spaceRooms: SpaceRoomsSnapshot[];
|
|
30
|
+
followedTopics: RoomFollowedTopicsSnapshot[];
|
|
31
|
+
emoticons: EmoticonsSnapshot[];
|
|
32
|
+
/**
|
|
33
|
+
* Null when the relationships have not been loaded.
|
|
34
|
+
*/
|
|
35
|
+
relationships: UserRelationship[] | null;
|
|
36
|
+
histories: TopicHistorySnapshot[];
|
|
37
|
+
roomMembers: RoomMembersSnapshot[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* What {@link ChatStateTracker.exportSnapshot} should include beyond the state that is always exported.
|
|
41
|
+
*/
|
|
42
|
+
export interface StateSnapshotIntent {
|
|
43
|
+
/**
|
|
44
|
+
* Topics to save the latest messages of, e.g. the ones last open in the application. Without `topicId`, the default
|
|
45
|
+
* topic of the room. Only a history window holding the latest messages (the `LATEST` state) is saved.
|
|
46
|
+
*/
|
|
47
|
+
histories?: {
|
|
48
|
+
roomId: string;
|
|
49
|
+
topicId?: string;
|
|
50
|
+
}[];
|
|
51
|
+
/**
|
|
52
|
+
* Messages saved per topic, the latest ones. Never fewer than the `fetchLimit` of the window (50 by default), so a
|
|
53
|
+
* restored window tells right whether it reaches the oldest message. Defaults to that `fetchLimit`.
|
|
54
|
+
*/
|
|
55
|
+
historyLimit?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Save the members of the rooms of the histories (for the roles, colors and avatars of the authors) when they are
|
|
58
|
+
* loaded and there are not more of them than this. Defaults to 0 - none.
|
|
59
|
+
*/
|
|
60
|
+
roomMembersLimit?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface TopicHistorySnapshot {
|
|
63
|
+
roomId: string;
|
|
64
|
+
topicId: string;
|
|
65
|
+
/**
|
|
66
|
+
* Oldest first.
|
|
67
|
+
*/
|
|
68
|
+
messages: Message[];
|
|
69
|
+
myReactions: Record<string, UserReaction[]>;
|
|
70
|
+
/**
|
|
71
|
+
* The topic of the history (if not the default one of the room) and the topics the messages refer to, as far as
|
|
72
|
+
* they are known.
|
|
73
|
+
*/
|
|
74
|
+
topics: Topic[];
|
|
75
|
+
}
|
|
76
|
+
export interface RoomMembersSnapshot {
|
|
77
|
+
roomId: string;
|
|
78
|
+
members: RoomMember[];
|
|
79
|
+
}
|
|
80
|
+
export interface SpaceRoomsSnapshot {
|
|
81
|
+
spaceId: string;
|
|
82
|
+
summaries: RoomSummary[];
|
|
83
|
+
}
|
|
84
|
+
export interface RoomFollowedTopicsSnapshot {
|
|
85
|
+
roomId: string;
|
|
86
|
+
followedTopics: FollowedTopic[];
|
|
87
|
+
}
|
|
88
|
+
export interface EmoticonsSnapshot {
|
|
89
|
+
/**
|
|
90
|
+
* Null for the global emoticons.
|
|
91
|
+
*/
|
|
92
|
+
spaceId: string | null;
|
|
93
|
+
emoticons: Emoticon[];
|
|
94
|
+
}
|
|
95
|
+
export declare function withoutPresence(user: User): User;
|
|
96
|
+
export declare function messageWithoutPresence(message: Message): Message;
|
|
97
|
+
export declare function memberWithoutPresence(member: RoomMember): RoomMember;
|
|
98
|
+
/**
|
|
99
|
+
* Structural check of the data restored from a storage - deep enough that importing it cannot throw, as the state
|
|
100
|
+
* handlers dereference these fields without checking them.
|
|
101
|
+
*/
|
|
102
|
+
export declare function isValidStateSnapshot(value: unknown): value is StateSnapshot;
|
|
@@ -67,6 +67,10 @@ export declare abstract class TraversableRemoteCollection<ItemT, EventMapT exten
|
|
|
67
67
|
resetToLatest(force?: boolean): Promise<void>;
|
|
68
68
|
fetchPrevious(): Promise<void>;
|
|
69
69
|
fetchNext(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Append the items that follow the last one in the window; an empty window gets the latest items.
|
|
72
|
+
*/
|
|
73
|
+
protected fetchAfterLast(): Promise<void>;
|
|
70
74
|
jumpTo(id: string): Promise<void>;
|
|
71
75
|
protected abstract fetchLatestItems(): Promise<ItemT[]>;
|
|
72
76
|
protected abstract fetchItemsBefore(): Promise<ItemT[] | null>;
|
|
@@ -100,6 +104,7 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
100
104
|
private roomId;
|
|
101
105
|
private topicId;
|
|
102
106
|
private tracker;
|
|
107
|
+
private preview;
|
|
103
108
|
/**
|
|
104
109
|
* Reexported available window modes enum.
|
|
105
110
|
*/
|
|
@@ -113,8 +118,12 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
113
118
|
/**
|
|
114
119
|
* The window does not subscribe to the client itself - the messages manager routes the events of its topic to it.
|
|
115
120
|
*/
|
|
116
|
-
constructor(roomId: string, topicId: string, tracker: ChatStateTracker);
|
|
121
|
+
constructor(roomId: string, topicId: string, tracker: ChatStateTracker, preview?: boolean);
|
|
117
122
|
createMirror(): TopicHistoryWindow;
|
|
123
|
+
/**
|
|
124
|
+
* Window of a room you have not joined. It gets no live messages - at the latest ones fetchNext() fetches the newer.
|
|
125
|
+
*/
|
|
126
|
+
get isPreview(): boolean;
|
|
118
127
|
get isTraverseLocked(): boolean;
|
|
119
128
|
/**
|
|
120
129
|
* What the connected user has reacted with, keyed by message id. Kept apart from
|
|
@@ -139,6 +148,20 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
|
|
|
139
148
|
fetchNext(): Promise<void>;
|
|
140
149
|
fetchPrevious(): Promise<void>;
|
|
141
150
|
jumpTo(id: string): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* The latest messages (oldest first) with the reactions of the user, or null if the window does not hold them.
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
_exportLatest(limit: number): {
|
|
156
|
+
messages: Message[];
|
|
157
|
+
myReactions: Record<string, UserReaction[]>;
|
|
158
|
+
} | null;
|
|
159
|
+
/**
|
|
160
|
+
* Fill the window with saved latest messages, as if they were just fetched; the next reset to the latest replaces
|
|
161
|
+
* them.
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
_restoreLatest(messages: Message[], myReactions: Record<string, UserReaction[]>): void;
|
|
142
165
|
/**
|
|
143
166
|
* For internal use.
|
|
144
167
|
* @internal
|