@devanachat/sdk 0.11.0 → 0.12.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 (36) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +2 -2
  3. package/build/index.cjs.js +362 -115
  4. package/build/index.cjs.js.map +1 -1
  5. package/build/index.mjs +362 -116
  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/index.d.ts +2 -2
  12. package/build/types/protocol/index.d.ts +15 -3
  13. package/build/types/protocol/schemes/Message.d.ts +4 -0
  14. package/build/types/protocol/schemes/MessageEmbed.d.ts +83 -0
  15. package/build/types/protocol/schemes/commands/AckInteraction.d.ts +10 -0
  16. package/build/types/protocol/schemes/commands/CreateMessage.d.ts +7 -0
  17. package/build/types/protocol/schemes/commands/GetGifCategories.d.ts +3 -0
  18. package/build/types/protocol/schemes/commands/GetMessages.d.ts +1 -0
  19. package/build/types/protocol/schemes/commands/Interact.d.ts +5 -0
  20. package/build/types/protocol/schemes/commands/SearchGifs.d.ts +5 -0
  21. package/build/types/protocol/schemes/commands/UpdateMessage.d.ts +8 -0
  22. package/build/types/protocol/schemes/events/Error.d.ts +1 -0
  23. package/build/types/protocol/schemes/events/FoundGifs.d.ts +14 -0
  24. package/build/types/protocol/schemes/events/GifCategories.d.ts +8 -0
  25. package/build/types/protocol/schemes/events/Interacted.d.ts +4 -0
  26. package/build/types/protocol/schemes/events/InteractionResolved.d.ts +7 -0
  27. package/build/types/protocol/schemes/events/MessageUpdated.d.ts +6 -0
  28. package/build/types/protocol/schemes/events/Messages.d.ts +6 -2
  29. package/build/types/protocol/schemes/events/NewInteraction.d.ts +10 -0
  30. package/build/types/protocol/schemes/events/NewMessage.d.ts +3 -0
  31. package/build/types/state-tracker/RoomMessagesHistory.d.ts +7 -2
  32. package/build/types/state-tracker/RoomsManager.d.ts +12 -1
  33. package/build/types/state-tracker/StateSnapshot.d.ts +5 -1
  34. package/build/types/state-tracker/TopicHistoryWindow.d.ts +29 -2
  35. package/build/types/state-tracker/functions.d.ts +8 -1
  36. 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;
@@ -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,6 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
2
  import { MessagePoll } from "../MessagePoll";
3
+ import { SendableEmbed } from "../MessageEmbed";
3
4
  export interface CreateMessage {
4
5
  location: ChatLocation;
5
6
  content: string;
@@ -9,4 +10,10 @@ export interface CreateMessage {
9
10
  /** Turns the message into a poll; its content becomes the question. */
10
11
  poll?: MessagePoll;
11
12
  sticky?: boolean;
13
+ replyTo?: string;
14
+ embed?: SendableEmbed;
15
+ /** The interaction the message answers */
16
+ interactionId?: string;
17
+ /** Bots only: the id of the room member the message is shown to; it is not stored and resolves with `Ok` */
18
+ ephemeralFor?: string;
12
19
  }
@@ -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
+ }
@@ -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.
@@ -1,4 +1,4 @@
1
- import { Message, ReactionUpdated, MessagesRedacted, NewMessage, Reacted, Topic, UserReaction } from "../protocol";
1
+ import { Message, ReactionUpdated, MessagesRedacted, MessageUpdated, NewMessage, Reacted, Topic, UserReaction } from "../protocol";
2
2
  import { ChatStateTracker } from "./ChatStateTracker";
3
3
  import { CollectionEventMap, ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
4
4
  export declare enum WindowState {
@@ -143,6 +143,8 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
143
143
  traverseLock: boolean;
144
144
  includeMyReactions: boolean;
145
145
  myReactions: Record<string, UserReaction[]>;
146
+ includeRepliedMessages: boolean;
147
+ repliedMessages: Map<string, Message>;
146
148
  liveLimit: number | null;
147
149
  };
148
150
  /**
@@ -166,6 +168,17 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
166
168
  */
167
169
  get includeMyReactions(): boolean;
168
170
  set includeMyReactions(value: boolean);
171
+ /**
172
+ * Whether the history is fetched together with the messages its messages reply to.
173
+ * Turn it off only where replies are never shown with what they reply to.
174
+ */
175
+ get includeRepliedMessages(): boolean;
176
+ set includeRepliedMessages(value: boolean);
177
+ /**
178
+ * The message the given one replies to: null when it replies to nothing or the replied message is gone,
179
+ * undefined when the window does not know it (replied messages are not fetched).
180
+ */
181
+ getRepliedMessage(message: Message): Message | null | undefined;
169
182
  /**
170
183
  * Maximum number of items a window that has not been fetched yet (LIVE state) collects from the incoming
171
184
  * messages. Null for the same as {@link limit}. It keeps the windows of topics nobody looks at small;
@@ -186,13 +199,14 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
186
199
  _exportLatest(limit: number): {
187
200
  messages: Message[];
188
201
  myReactions: Record<string, UserReaction[]>;
202
+ repliedMessages: Message[];
189
203
  } | null;
190
204
  /**
191
205
  * Fill the window with saved latest messages, as if they were just fetched; the next reset to the latest replaces
192
206
  * them.
193
207
  * @internal
194
208
  */
195
- _restoreLatest(messages: Message[], myReactions: Record<string, UserReaction[]>): void;
209
+ _restoreLatest(messages: Message[], myReactions: Record<string, UserReaction[]>, repliedMessages: Message[]): void;
196
210
  /**
197
211
  * For internal use.
198
212
  * @internal
@@ -208,6 +222,13 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
208
222
  * mention has no reaction of this user left on it.
209
223
  */
210
224
  private storeMyReactions;
225
+ /**
226
+ * The response is the truth for its replies: an original it leaves out is gone. The originals the page holds
227
+ * itself are kept too, as the window may drop them while their replies stay.
228
+ */
229
+ private storeRepliedMessages;
230
+ private emitChange;
231
+ private repliesTo;
211
232
  private getTopic;
212
233
  private getLatestMessageId;
213
234
  protected isLatestItemLoaded(): Promise<boolean>;
@@ -228,6 +249,12 @@ export declare class TopicHistoryWindow extends TraversableRemoteCollection<Mess
228
249
  * @internal
229
250
  */
230
251
  _handleReacted(ev: Reacted): void;
252
+ /**
253
+ * Replaces a loaded message, also where it is kept as a replied one.
254
+ * For internal use.
255
+ * @internal
256
+ */
257
+ _handleMessageUpdated(ev: MessageUpdated): void;
231
258
  /**
232
259
  * For internal use.
233
260
  * @internal
@@ -1,4 +1,4 @@
1
- import { PmParticipant, Role, Room, RoomMember, SpaceMember, User } from "../protocol";
1
+ import { MessageReaction, PmParticipant, Role, Room, RoomMember, SpaceMember, ToggledReaction, User, UserReaction } from "../protocol";
2
2
  /**
3
3
  * @return New objects of the other roles whose priority has to move; the given roles are left intact.
4
4
  */
@@ -15,3 +15,10 @@ export declare function isGroupPm(room: Room): boolean;
15
15
  export declare function getPmPeers(room: Room, meId: string): PmParticipant[];
16
16
  export declare function getActivePmParticipants(room: Room): PmParticipant[];
17
17
  export declare function isSameUser(a: User, b: User): boolean;
18
+ /**
19
+ * The counter arrives as the global source of truth - only it is overwritten, and a reaction nobody holds any more
20
+ * (count 0) leaves the message.
21
+ * @return Null when the reactions stay as they are.
22
+ */
23
+ export declare function applyReactionCounter(reactions: MessageReaction[], counter: MessageReaction): MessageReaction[] | null;
24
+ export declare function applyToggledReaction(own: UserReaction[], toggled: ToggledReaction): UserReaction[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devanachat/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "TypeScript/JavaScript SDK for the Devana chat platform: WebSocket and Web API clients, state tracking, permissions and files.",
5
5
  "keywords": [
6
6
  "devana",