@devanachat/sdk 0.11.0 → 0.13.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 (38) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +15 -7
  3. package/build/index.cjs.js +436 -144
  4. package/build/index.cjs.js.map +1 -1
  5. package/build/index.mjs +436 -145
  6. package/build/index.mjs.map +1 -1
  7. package/build/index.umd.js +1 -1
  8. package/build/index.umd.js.map +1 -1
  9. package/build/types/AbstractChatClient.d.ts +18 -3
  10. package/build/types/Permissions.d.ts +5 -1
  11. package/build/types/WebSocketChatClient.d.ts +29 -2
  12. package/build/types/index.d.ts +2 -2
  13. package/build/types/protocol/index.d.ts +15 -3
  14. package/build/types/protocol/schemes/Message.d.ts +4 -0
  15. package/build/types/protocol/schemes/MessageEmbed.d.ts +83 -0
  16. package/build/types/protocol/schemes/commands/AckInteraction.d.ts +10 -0
  17. package/build/types/protocol/schemes/commands/CreateMessage.d.ts +9 -0
  18. package/build/types/protocol/schemes/commands/GetGifCategories.d.ts +3 -0
  19. package/build/types/protocol/schemes/commands/GetMessages.d.ts +1 -0
  20. package/build/types/protocol/schemes/commands/Interact.d.ts +5 -0
  21. package/build/types/protocol/schemes/commands/SearchGifs.d.ts +5 -0
  22. package/build/types/protocol/schemes/commands/UpdateMessage.d.ts +8 -0
  23. package/build/types/protocol/schemes/events/Bye.d.ts +1 -0
  24. package/build/types/protocol/schemes/events/Error.d.ts +1 -0
  25. package/build/types/protocol/schemes/events/FoundGifs.d.ts +14 -0
  26. package/build/types/protocol/schemes/events/GifCategories.d.ts +8 -0
  27. package/build/types/protocol/schemes/events/Interacted.d.ts +4 -0
  28. package/build/types/protocol/schemes/events/InteractionResolved.d.ts +7 -0
  29. package/build/types/protocol/schemes/events/MessageUpdated.d.ts +6 -0
  30. package/build/types/protocol/schemes/events/Messages.d.ts +6 -2
  31. package/build/types/protocol/schemes/events/NewInteraction.d.ts +10 -0
  32. package/build/types/protocol/schemes/events/NewMessage.d.ts +3 -0
  33. package/build/types/state-tracker/RoomMessagesHistory.d.ts +7 -2
  34. package/build/types/state-tracker/RoomsManager.d.ts +12 -1
  35. package/build/types/state-tracker/StateSnapshot.d.ts +5 -1
  36. package/build/types/state-tracker/TopicHistoryWindow.d.ts +29 -2
  37. package/build/types/state-tracker/functions.d.ts +8 -1
  38. 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, GetIgnoredRooms, IgnoredRooms, 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, Type, Typing, 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, GetIgnoredRooms, IgnoredRooms, 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, UpdateMessage, MessageUpdated, SearchGifs, GetGifCategories, FoundGifs, GifCategories, ReportAbuse, UpdateRoomMember, GetRelationships, GetUserInfo, UserInfo, SetSessionData, SessionData, GetSessionData, SetUserData, UserData, GetUserData, UnfollowTopic, TopicUnfollowed, Invite, Uninvite, GetInvited, Invited, React, Interact, AckInteraction, Unreact, GetReactionDetails, ReactionUpdated, Reacted, NewInteraction, Interacted, InteractionResolved, ReactionDetails, Type, Typing, 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>;
@@ -102,8 +102,14 @@ export type EventsMap = {
102
102
  Topics: Topics;
103
103
  TopicUpdated: TopicUpdated;
104
104
  MessagesRedacted: MessagesRedacted;
105
+ MessageUpdated: MessageUpdated;
106
+ FoundGifs: FoundGifs;
107
+ GifCategories: GifCategories;
105
108
  ReactionUpdated: ReactionUpdated;
106
109
  Reacted: Reacted;
110
+ NewInteraction: NewInteraction;
111
+ Interacted: Interacted;
112
+ InteractionResolved: InteractionResolved;
107
113
  ReactionDetails: ReactionDetails;
108
114
  Typing: Typing;
109
115
  };
@@ -169,7 +175,8 @@ export type CommandsMap = {
169
175
  GetInvited: CommandDefinition<GetInvited, EventsMap['Invited']>;
170
176
  CreateTopic: CommandDefinition<CreateTopic, EventsMap['NewTopic']>;
171
177
  DeleteTopic: CommandDefinition<DeleteTopic, EventsMap['TopicDeleted']>;
172
- CreateMessage: CommandDefinition<CreateMessage, EventsMap['NewMessage']>;
178
+ /** `Ok` for an ephemeral message (`ephemeralFor`), which goes to its recipient alone. */
179
+ CreateMessage: CommandDefinition<CreateMessage, EventsMap['NewMessage'] | EventsMap['Ok']>;
173
180
  Ack: CommandDefinition<Ack, EventsMap['FollowedTopicUpdated'] | EventsMap['Ok']>;
174
181
  FollowTopic: CommandDefinition<FollowTopic, EventsMap['TopicFollowed']>;
175
182
  UnfollowTopic: CommandDefinition<UnfollowTopic, EventsMap['TopicUnfollowed']>;
@@ -180,8 +187,16 @@ export type CommandsMap = {
180
187
  GetTopics: CommandDefinition<GetTopics, EventsMap['Topics']>;
181
188
  UpdateTopic: CommandDefinition<UpdateTopic, EventsMap['TopicUpdated']>;
182
189
  RedactMessages: CommandDefinition<RedactMessages, EventsMap['MessagesRedacted']>;
190
+ /** Resolves with `Ok` when the edit changes nothing. */
191
+ UpdateMessage: CommandDefinition<UpdateMessage, EventsMap['MessageUpdated'] | EventsMap['Ok']>;
192
+ /** Available when the server runs GIF search; featured GIFs without a query. */
193
+ SearchGifs: CommandDefinition<SearchGifs, EventsMap['FoundGifs']>;
194
+ GetGifCategories: CommandDefinition<GetGifCategories, EventsMap['GifCategories']>;
183
195
  React: CommandDefinition<React, EventsMap['Reacted']>;
184
- Unreact: CommandDefinition<Unreact, EventsMap['Reacted']>;
196
+ Interact: CommandDefinition<Interact, EventsMap['Interacted']>;
197
+ AckInteraction: CommandDefinition<AckInteraction, EventsMap['Ok']>;
198
+ /** `Ok` when the user had no such reaction. */
199
+ Unreact: CommandDefinition<Unreact, EventsMap['Reacted'] | EventsMap['Ok']>;
185
200
  GetReactionDetails: CommandDefinition<GetReactionDetails, EventsMap['ReactionDetails']>;
186
201
  Type: CommandDefinition<Type, EventsMap['Ok']>;
187
202
  };
@@ -82,7 +82,7 @@ export declare class Permissions {
82
82
  value: number;
83
83
  maxLayer: Layer;
84
84
  };
85
- RedactMessages: {
85
+ ManageMessages: {
86
86
  value: number;
87
87
  maxLayer: Layer;
88
88
  };
@@ -122,6 +122,10 @@ export declare class Permissions {
122
122
  value: number;
123
123
  maxLayer: Layer;
124
124
  };
125
+ EditMessages: {
126
+ value: number;
127
+ maxLayer: Layer;
128
+ };
125
129
  };
126
130
  static getNames(): (keyof typeof this.list)[];
127
131
  static getByName(name: keyof typeof this.list): PermissionDefinition | undefined;
@@ -6,7 +6,16 @@ import { Envelope } from "./protocol";
6
6
  export interface WebSocketClientOptions {
7
7
  url: string;
8
8
  token: string;
9
+ /**
10
+ * Time an attempt may take until the socket opens. Default is 10 seconds.
11
+ */
9
12
  connectingTimeoutMs?: number;
13
+ /**
14
+ * Time to wait for `Session` once the socket is open. The server may hold a connection in a queue before
15
+ * authenticating it when many clients connect at once, so this is longer than `connectingTimeoutMs`.
16
+ * Default is 60 seconds.
17
+ */
18
+ sessionTimeoutMs?: number;
10
19
  awaitQueueSendDelayMs?: number;
11
20
  stateTracking?: boolean;
12
21
  queryParams?: Record<string, string>;
@@ -27,17 +36,28 @@ export interface WebSocketClientOptions {
27
36
  /**
28
37
  * Automatic reconnection. After the connection is lost (error, connecting timeout, missing pong
29
38
  * or closure with a code other than 1000) the client retries indefinitely, waiting between attempts
30
- * with an exponential backoff. Calling `disconnect()` stops retrying until the next `connect()`.
39
+ * a random time up to an exponentially growing limit. Calling `disconnect()` stops retrying until
40
+ * the next `connect()`.
31
41
  */
32
42
  reconnect?: {
33
43
  /**
34
- * Delay before the first retry; each subsequent one doubles it. Default is 1 second.
44
+ * Limit of the first delay after a lost connection; each subsequent one doubles it. Default is 1 second.
35
45
  */
36
46
  minDelayMs?: number;
47
+ /**
48
+ * Limit of the first delay when the server closed the connection (close code 1001, 1012 or 1013, or after
49
+ * a `Bye`); each subsequent one doubles it. Default is 5 seconds. It wins over a lower `maxDelayMs`.
50
+ */
51
+ serverCloseMinDelayMs?: number;
37
52
  /**
38
53
  * Upper limit of the delay between retries. Default is 30 seconds.
39
54
  */
40
55
  maxDelayMs?: number;
56
+ /**
57
+ * Time an authenticated connection has to last for the next loss to start the backoff over.
58
+ * Default is 30 seconds.
59
+ */
60
+ stableConnectionMs?: number;
41
61
  };
42
62
  }
43
63
  declare enum WebSocketChatClientEvent {
@@ -68,14 +88,20 @@ export declare class WebSocketChatClient extends AbstractChatClient<Pick<WebSock
68
88
  protected reconnectEnabled: boolean;
69
89
  protected reconnectTimeoutId?: any;
70
90
  protected reconnectAttempts: number;
91
+ protected serverClosedSinceStable: boolean;
92
+ protected byeReceived: boolean;
93
+ protected byeRetryAfterMs?: number;
94
+ protected stableConnectionTimeoutId?: any;
71
95
  constructor(options: WebSocketClientOptions);
72
96
  connect(): Promise<void>;
73
97
  disconnect(): void;
74
98
  send<CommandType extends keyof CommandsMap>(commandType: CommandType, commandData: CommandRequest<CommandType>): Promise<CommandResult<CommandResponse<CommandType>>>;
75
99
  get isReady(): boolean;
76
100
  private openSocket;
101
+ private startConnectingTimeout;
77
102
  private sendEnvelope;
78
103
  private onMessage;
104
+ private onBye;
79
105
  private onClose;
80
106
  /**
81
107
  * Abandon the current socket without waiting for its close event (which
@@ -89,6 +115,7 @@ export declare class WebSocketChatClient extends AbstractChatClient<Pick<WebSock
89
115
  */
90
116
  private releaseSocket;
91
117
  private scheduleReconnect;
118
+ private resetBackoff;
92
119
  private cancelScheduledReconnect;
93
120
  /**
94
121
  * Resolve (or reject, when an error is given) a pending connect() promise.
@@ -4,7 +4,7 @@ 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 { ErrorCode, HistoryRotation, NO_LIMIT, PmParticipantFlag, RoleFlag, SearchRange, UiPurpose, SpaceFeature, SpaceIntent, STORAGE_UNIT_BYTES, UserFeature, UserStatus } from './protocol';
7
+ import { ErrorCode, HistoryRotation, MessageEmbedFlag, NO_LIMIT, PmParticipantFlag, RoleFlag, SearchRange, UiPurpose, SpaceFeature, SpaceIntent, STORAGE_UNIT_BYTES, UserFeature, UserStatus } from './protocol';
8
8
  import { extractUserFromMember, getPmPeers, isGroupPm } from "./state-tracker/functions";
9
9
  import { AbstractRestClient } from "./AbstractRestClient";
10
10
  import { UnreadSummary } from "./state-tracker/FollowedTopicsManager";
@@ -12,7 +12,7 @@ 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
14
  import { TYPING_INTERVAL_MS, TYPING_TIMEOUT_MS, TypingManager, TypingUsers } from "./state-tracker/TypingManager";
15
- export { IndexedCollection, ObservableIndexedCollection, IndexedObjectCollection, ObservableIndexedObjectCollection, Permissions, PermissionDefinition, Layer, WebSocketChatClient, WebApiChatClient, FilesClient, AbstractRestClient, extractUserFromMember, isGroupPm, getPmPeers, ErrorCode, PmParticipantFlag, UserStatus, RoleFlag, SpaceFeature, UserFeature, HistoryRotation, SearchRange, UiPurpose, SpaceIntent, NO_LIMIT, STORAGE_UNIT_BYTES, STATE_SNAPSHOT_VERSION, TYPING_INTERVAL_MS, TYPING_TIMEOUT_MS, };
15
+ export { IndexedCollection, ObservableIndexedCollection, IndexedObjectCollection, ObservableIndexedObjectCollection, Permissions, PermissionDefinition, Layer, WebSocketChatClient, WebApiChatClient, FilesClient, AbstractRestClient, extractUserFromMember, isGroupPm, getPmPeers, ErrorCode, MessageEmbedFlag, PmParticipantFlag, UserStatus, RoleFlag, SpaceFeature, UserFeature, HistoryRotation, SearchRange, UiPurpose, SpaceIntent, NO_LIMIT, STORAGE_UNIT_BYTES, STATE_SNAPSHOT_VERSION, TYPING_INTERVAL_MS, TYPING_TIMEOUT_MS, };
16
16
  export type { CommandResult, CommandRequest, CommandResponse, CommandsMap, EventsMap, } from "./AbstractChatClient";
17
17
  export type { WebSocketClientOptions } from "./WebSocketChatClient";
18
18
  export type { WebApiChatClientOptions } from "./WebApiChatClient";
@@ -1,5 +1,6 @@
1
1
  import { Envelope } from "./schemes/Envelope";
2
2
  import { Message, MessageType, MessageAuthor, MessageMentions } from "./schemes/Message";
3
+ import { MessageEmbed, MessageEmbedType, MessageEmbedFlag, SendableEmbed, EmbedTone, EmbedComponent, EmbedContainer, EmbedColumns, EmbedColumn, EmbedSeparator, EmbedText, EmbedMedia, EmbedMediaItem, EmbedPlayer, EmbedButton, EmbedSelect, EmbedSelectOption } from "./schemes/MessageEmbed";
3
4
  import { PermissionOverwritesValue } from "./schemes/PermissionOverwritesValue";
4
5
  import { Role, RoleFlag, RoleIcon } from "./schemes/Role";
5
6
  import { Room, RoomType } from "./schemes/Room";
@@ -86,7 +87,7 @@ import { TopicFollowed } from "./schemes/events/TopicFollowed";
86
87
  import { GetFollowedTopics } from "./schemes/commands/GetFollowedTopics";
87
88
  import { FollowedTopicUpdated } from "./schemes/events/FollowedTopicUpdated";
88
89
  import { GetMessages } from "./schemes/commands/GetMessages";
89
- import { Messages } from "./schemes/events/Messages";
90
+ import { Messages, MessageUserReactions } from "./schemes/events/Messages";
90
91
  import { SearchMessages, SearchDate } from "./schemes/commands/SearchMessages";
91
92
  import { FoundMessages, FoundMessage, TextRange } from "./schemes/events/FoundMessages";
92
93
  import { Topics } from "./schemes/events/Topics";
@@ -134,6 +135,17 @@ import { Pong } from "./schemes/events/Pong";
134
135
  import { ReportAbuse } from "./schemes/commands/ReportAbuse";
135
136
  import { RedactMessages } from "./schemes/commands/RedactMessages";
136
137
  import { MessagesRedacted } from "./schemes/events/MessagesRedacted";
138
+ import { UpdateMessage } from "./schemes/commands/UpdateMessage";
139
+ import { Interact } from "./schemes/commands/Interact";
140
+ import { NewInteraction } from "./schemes/events/NewInteraction";
141
+ import { Interacted } from "./schemes/events/Interacted";
142
+ import { InteractionResolved, InteractionStatus } from "./schemes/events/InteractionResolved";
143
+ import { AckInteraction } from "./schemes/commands/AckInteraction";
144
+ import { MessageUpdated } from "./schemes/events/MessageUpdated";
145
+ import { SearchGifs } from "./schemes/commands/SearchGifs";
146
+ import { GetGifCategories } from "./schemes/commands/GetGifCategories";
147
+ import { GifCategory, GifCategories } from "./schemes/events/GifCategories";
148
+ import { FoundGif, FoundGifs } from "./schemes/events/FoundGifs";
137
149
  import { GetRelationships } from "./schemes/commands/GetRelationships";
138
150
  import { GetUserInfo } from "./schemes/commands/GetUserInfo";
139
151
  import { UserInfo } from "./schemes/events/UserInfo";
@@ -166,5 +178,5 @@ import { Entitlements } from "./schemes/events/Entitlements";
166
178
  import { EntitlementUsage } from "./schemes/events/EntitlementUsage";
167
179
  import { CreateAccessTicket, TicketAudience } from "./schemes/commands/CreateAccessTicket";
168
180
  import { AccessTicket } from "./schemes/events/AccessTicket";
169
- export type { Envelope, Message, MessageType, MessageAuthor, MessageMentions, Role, RoleIcon, Room, RoomType, PmParticipant, 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, ErrorDetails, IgnoredRooms, 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, Typing, 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, GetIgnoredRooms, 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, Type, GetEntitlements, CreateAccessTicket, };
170
- export { ErrorCode, NO_LIMIT, STORAGE_UNIT_BYTES, HistoryRotation, PmParticipantFlag, RoleFlag, SearchRange, SpaceFeature, SpaceIntent, UiPurpose, UserFeature, UserStatus, };
181
+ export type { Envelope, Message, MessageType, MessageAuthor, MessageMentions, Role, RoleIcon, Room, RoomType, PmParticipant, 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, MessageEmbed, MessageEmbedType, SendableEmbed, EmbedTone, EmbedComponent, EmbedContainer, EmbedColumns, EmbedColumn, EmbedSeparator, EmbedText, EmbedMedia, EmbedMediaItem, EmbedPlayer, EmbedButton, EmbedSelect, EmbedSelectOption, EntitlementTarget, EntitlementsSubject, EntitlementValue, EntitlementsMap, EntitlementsExtras, TicketAudience, Bye, Error, ErrorDetails, IgnoredRooms, Messages, MessageUserReactions, NewInteraction, Interacted, InteractionResolved, InteractionStatus, 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, MessageUpdated, FoundGif, FoundGifs, GifCategory, GifCategories, UserInfo, Invited, ReactionUpdated, Reacted, ReactionDetails, Typing, 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, GetIgnoredRooms, 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, UpdateMessage, Interact, AckInteraction, SearchGifs, GetGifCategories, GetUserInfo, SetSessionData, GetSessionData, SetUserData, GetUserData, Invite, Uninvite, GetInvited, React, Unreact, GetReactionDetails, Type, GetEntitlements, CreateAccessTicket, };
182
+ export { ErrorCode, MessageEmbedFlag, NO_LIMIT, STORAGE_UNIT_BYTES, HistoryRotation, PmParticipantFlag, RoleFlag, SearchRange, SpaceFeature, SpaceIntent, UiPurpose, UserFeature, UserStatus, };
@@ -2,6 +2,7 @@ import { User } from "./User";
2
2
  import { ChatLocation } from "./ChatLocation";
3
3
  import { MessageReaction } from "./Reaction";
4
4
  import { MessagePoll } from "./MessagePoll";
5
+ import { MessageEmbed } from "./MessageEmbed";
5
6
  export type MessageType = 'Text' | 'RoomJoin' | 'RoomMemberAdd' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'Ephemeral' | 'Poll' | 'RoomRename';
6
7
  /**
7
8
  * Mention targets a message actually reached, as resolved by the server: role
@@ -29,4 +30,7 @@ export interface Message {
29
30
  reactions: MessageReaction[];
30
31
  poll?: MessagePoll;
31
32
  mentions: MessageMentions | null;
33
+ editedAt?: string | null;
34
+ replyTo?: string | null;
35
+ embed?: MessageEmbed | null;
32
36
  }
@@ -0,0 +1,83 @@
1
+ export type MessageEmbedType = 'Link' | 'Video' | 'Gif' | 'Rich';
2
+ export declare enum MessageEmbedFlag {
3
+ HideContent = 1,
4
+ Suppressed = 2
5
+ }
6
+ export interface MessageEmbed {
7
+ type: MessageEmbedType;
8
+ root: EmbedComponent[];
9
+ flags: number;
10
+ }
11
+ export interface SendableEmbed {
12
+ root: EmbedComponent[];
13
+ hideContent?: boolean;
14
+ }
15
+ export type EmbedTone = 'Accent' | 'Positive' | 'Warning' | 'Danger' | 'Muted';
16
+ export interface EmbedContainer {
17
+ type: 'Container';
18
+ style?: 'Filled' | 'Outlined' | 'Plain';
19
+ accent?: EmbedTone | string;
20
+ spoiler?: boolean;
21
+ collapsible?: number;
22
+ children: EmbedComponent[];
23
+ }
24
+ export interface EmbedColumns {
25
+ type: 'Columns';
26
+ stack?: 'Auto' | 'Never';
27
+ children: EmbedColumn[];
28
+ }
29
+ export interface EmbedColumn {
30
+ type: 'Column';
31
+ weight?: 1 | 2 | 3 | 'Auto';
32
+ align?: 'Start' | 'Center';
33
+ children: EmbedComponent[];
34
+ }
35
+ export interface EmbedSeparator {
36
+ type: 'Separator';
37
+ }
38
+ export interface EmbedText {
39
+ type: 'Text';
40
+ content: string;
41
+ align?: 'Start' | 'Center';
42
+ }
43
+ export interface EmbedMediaItem {
44
+ url?: string;
45
+ attachmentId?: string;
46
+ width?: number;
47
+ height?: number;
48
+ alt?: string;
49
+ animated?: boolean;
50
+ }
51
+ export interface EmbedMedia {
52
+ type: 'Media';
53
+ items: EmbedMediaItem[];
54
+ size?: 'Auto' | 'Thumbnail';
55
+ spoiler?: boolean;
56
+ }
57
+ export interface EmbedPlayer {
58
+ type: 'Player';
59
+ provider: 'YouTube';
60
+ videoId: string;
61
+ start?: number;
62
+ }
63
+ export interface EmbedButton {
64
+ type: 'Button';
65
+ label: string;
66
+ variant?: 'Filled' | 'Tonal' | 'Outlined' | 'Text';
67
+ tone?: 'Default' | 'Danger';
68
+ icon?: string;
69
+ disabled?: boolean;
70
+ url?: string;
71
+ actionId?: string;
72
+ }
73
+ export interface EmbedSelectOption {
74
+ label: string;
75
+ value: string;
76
+ }
77
+ export interface EmbedSelect {
78
+ type: 'Select';
79
+ actionId: string;
80
+ placeholder?: string;
81
+ options: EmbedSelectOption[];
82
+ }
83
+ export type EmbedComponent = EmbedContainer | EmbedColumns | EmbedSeparator | EmbedText | EmbedMedia | EmbedPlayer | EmbedButton | EmbedSelect;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Answers an interaction without a message or an edit. Bots only; the author of the interacted message.
3
+ * `Timeout` is sent by the server alone.
4
+ */
5
+ export interface AckInteraction {
6
+ interactionId: string;
7
+ status?: 'Ok' | 'Fail';
8
+ /** A short plain text (up to 150 characters) shown to the user who interacted */
9
+ notice?: string;
10
+ }
@@ -1,5 +1,7 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
2
  import { MessagePoll } from "../MessagePoll";
3
+ import { SendableEmbed } from "../MessageEmbed";
4
+ import { MessageMentions } from "../Message";
3
5
  export interface CreateMessage {
4
6
  location: ChatLocation;
5
7
  content: string;
@@ -9,4 +11,11 @@ export interface CreateMessage {
9
11
  /** Turns the message into a poll; its content becomes the question. */
10
12
  poll?: MessagePoll;
11
13
  sticky?: boolean;
14
+ replyTo?: string;
15
+ embed?: SendableEmbed;
16
+ /** The interaction the message answers */
17
+ interactionId?: string;
18
+ /** Bots only: the id of the room member the message is shown to; it is not stored and resolves with `Ok` */
19
+ ephemeralFor?: string;
20
+ allowedMentions?: MessageMentions;
12
21
  }
@@ -0,0 +1,3 @@
1
+ export interface GetGifCategories {
2
+ locale?: string;
3
+ }
@@ -10,4 +10,5 @@ export interface GetMessages {
10
10
  * asking for their own state separately.
11
11
  */
12
12
  includeMyReactions?: boolean;
13
+ includeRepliedMessages?: boolean;
13
14
  }
@@ -0,0 +1,5 @@
1
+ export interface Interact {
2
+ messageId: string;
3
+ actionId: string;
4
+ value?: string;
5
+ }
@@ -0,0 +1,5 @@
1
+ export interface SearchGifs {
2
+ query: string;
3
+ position?: string;
4
+ locale?: string;
5
+ }
@@ -0,0 +1,8 @@
1
+ import { SendableEmbed } from "../MessageEmbed";
2
+ export interface UpdateMessage {
3
+ messageId: string;
4
+ content?: string;
5
+ embed?: SendableEmbed | null;
6
+ /** The interaction the edit answers */
7
+ interactionId?: string;
8
+ }
@@ -1,4 +1,5 @@
1
1
  import { LeaveReason } from "../LeaveReason";
2
2
  export interface Bye {
3
3
  reason: LeaveReason;
4
+ retryAfterMs?: number;
4
5
  }
@@ -13,6 +13,7 @@ export declare enum ErrorCode {
13
13
  InvalidSearchQuery = "InvalidSearchQueryException",
14
14
  MessageSearchUnavailable = "MessageSearchUnavailableException",
15
15
  MessageNotFound = "MessageNotFoundException",
16
+ ReactionExistsAlready = "ReactionExistsAlreadyException",
16
17
  RoomIgnored = "RoomIgnoredException",
17
18
  RoomNotFound = "RoomNotFoundException",
18
19
  SpaceJoinRestricted = "SpaceJoinRestrictedException",
@@ -0,0 +1,14 @@
1
+ export interface FoundGif {
2
+ id: string;
3
+ url: string;
4
+ title: string;
5
+ width: number;
6
+ height: number;
7
+ posterUrl: string;
8
+ mp4Url: string | null;
9
+ webmUrl: string | null;
10
+ }
11
+ export interface FoundGifs {
12
+ gifs: FoundGif[];
13
+ next: string | null;
14
+ }
@@ -0,0 +1,8 @@
1
+ export interface GifCategory {
2
+ term: string;
3
+ name: string;
4
+ imageUrl: string;
5
+ }
6
+ export interface GifCategories {
7
+ categories: GifCategory[];
8
+ }
@@ -0,0 +1,4 @@
1
+ /** The answer to `Interact`: the id under which the author of the message gets the interaction. */
2
+ export interface Interacted {
3
+ interactionId: string;
4
+ }
@@ -0,0 +1,7 @@
1
+ export type InteractionStatus = 'Ok' | 'Fail' | 'Timeout';
2
+ /** Sent to the user who interacted when a bot acknowledges the interaction or does not answer in time. */
3
+ export interface InteractionResolved {
4
+ interactionId: string;
5
+ status: InteractionStatus;
6
+ notice: string | null;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { Message } from "../Message";
2
+ export interface MessageUpdated {
3
+ message: Message;
4
+ /** The interaction the edit answers */
5
+ interactionId?: string | null;
6
+ }
@@ -1,9 +1,13 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
2
  import { Message } from "../Message";
3
3
  import { UserReaction } from "../Reaction";
4
+ export interface MessageUserReactions {
5
+ messageId: string;
6
+ reactions: UserReaction[];
7
+ }
4
8
  export interface Messages {
5
9
  location: ChatLocation;
6
10
  messages: Message[];
7
- /** Message id => reactions of the asking user; present only when requested. */
8
- myReactions?: Record<string, UserReaction[]>;
11
+ myReactions?: MessageUserReactions[] | null;
12
+ repliedMessages?: Message[] | null;
9
13
  }
@@ -0,0 +1,10 @@
1
+ import { ChatLocation } from "../ChatLocation";
2
+ import { User } from "../User";
3
+ export interface NewInteraction {
4
+ interactionId: string;
5
+ location: ChatLocation;
6
+ messageId: string;
7
+ user: User;
8
+ actionId: string;
9
+ value: string | null;
10
+ }
@@ -2,4 +2,7 @@ import { Message } from "../Message";
2
2
  export interface NewMessage {
3
3
  message: Message;
4
4
  sticky?: boolean;
5
+ repliedMessage?: Message | null;
6
+ /** The interaction the message answers */
7
+ interactionId?: string | null;
5
8
  }
@@ -1,5 +1,5 @@
1
1
  import { ChatStateTracker } from "./ChatStateTracker";
2
- import { Message, MessagesRedacted, NewMessage, NewTopic, Reacted, ReactionUpdated, Room, RoomUpdated, Topic, TopicDeleted, UserReaction } from "../protocol";
2
+ import { Message, MessagesRedacted, MessageUpdated, 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
@@ -52,7 +52,7 @@ export declare class RoomMessagesHistory {
52
52
  * For internal use.
53
53
  * @internal
54
54
  */
55
- _restoreWindow(topic: Topic, messages: Message[], myReactions: Record<string, UserReaction[]>): void;
55
+ _restoreWindow(topic: Topic, messages: Message[], myReactions: Record<string, UserReaction[]>, repliedMessages: Message[]): void;
56
56
  /**
57
57
  * For internal use.
58
58
  * @internal
@@ -78,6 +78,11 @@ export declare class RoomMessagesHistory {
78
78
  * @internal
79
79
  */
80
80
  _handleMessagesRedacted(ev: MessagesRedacted): void;
81
+ /**
82
+ * For internal use.
83
+ * @internal
84
+ */
85
+ _handleMessageUpdated(ev: MessageUpdated): void;
81
86
  /**
82
87
  * For internal use.
83
88
  * @internal
@@ -1,5 +1,5 @@
1
1
  import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
2
- import { Room, RoomMember, Topic } from "../protocol";
2
+ import { ChatLocation, Room, RoomMember, Topic, MessageUserReactions } from "../protocol";
3
3
  import { ChatStateTracker } from "./ChatStateTracker";
4
4
  import { MessagesManager } from "./MessagesManager";
5
5
  import { FollowedTopicsManager } from "./FollowedTopicsManager";
@@ -17,11 +17,19 @@ export declare class RoomsManager {
17
17
  private readonly membersPromises;
18
18
  private readonly topicsPromises;
19
19
  private readonly importedTopicIds;
20
+ private readonly stickyMyReactions;
21
+ private readonly stickyMyReactionsPromises;
20
22
  constructor(tracker: ChatStateTracker);
21
23
  /**
22
24
  * Get collection of room members.
23
25
  */
24
26
  getMembers(roomId: string): Promise<ObservableIndexedObjectCollection<RoomMember> | undefined>;
27
+ /**
28
+ * Get the reactions of the connected user on sticky messages, keyed by message id. A sticky message comes with its
29
+ * topic, outside of the message history, so the reactions of the given one are fetched once and then follow
30
+ * the reactions of the user.
31
+ */
32
+ getStickyMyReactions(location: ChatLocation, messageId: string): Promise<ObservableIndexedObjectCollection<MessageUserReactions>>;
25
33
  /**
26
34
  * Get a room member representing the current user.
27
35
  */
@@ -97,6 +105,9 @@ export declare class RoomsManager {
97
105
  private handleSession;
98
106
  private handleUserUpdated;
99
107
  private handleNewMessage;
108
+ private handleMessageUpdated;
109
+ private handleReactionUpdated;
110
+ private handleReacted;
100
111
  private handleMessagesRedacted;
101
112
  /**
102
113
  * The topics collection is where the message counters of a topic are kept up to date; a room in the list
@@ -2,7 +2,7 @@ import { Emoticon, FollowedTopic, Message, Room, RoomMember, RoomSummary, Space,
2
2
  /**
3
3
  * Version of the {@link StateSnapshot} format. A snapshot of any other version is rejected on import.
4
4
  */
5
- export declare const STATE_SNAPSHOT_VERSION = 2;
5
+ export declare const STATE_SNAPSHOT_VERSION = 3;
6
6
  /**
7
7
  * Plain, JSON-serializable copy of the state tracked by {@link ChatStateTracker}, made to restore the state at the
8
8
  * application start (before the connection is established) - see {@link ChatStateTracker.exportSnapshot}.
@@ -67,6 +67,10 @@ export interface TopicHistorySnapshot {
67
67
  */
68
68
  messages: Message[];
69
69
  myReactions: Record<string, UserReaction[]>;
70
+ /**
71
+ * The messages replied to by the ones above.
72
+ */
73
+ repliedMessages: Message[];
70
74
  /**
71
75
  * The topic of the history (if not the default one of the room) and the topics the messages refer to, as far as
72
76
  * they are known.