@devanachat/sdk 0.12.0 → 0.14.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 (47) hide show
  1. package/CHANGELOG.md +104 -12
  2. package/README.md +13 -5
  3. package/build/index.cjs.js +345 -43
  4. package/build/index.cjs.js.map +1 -1
  5. package/build/index.mjs +345 -44
  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 +16 -1
  10. package/build/types/Permissions.d.ts +34 -0
  11. package/build/types/WebSocketChatClient.d.ts +29 -2
  12. package/build/types/index.d.ts +4 -3
  13. package/build/types/protocol/index.d.ts +21 -2
  14. package/build/types/protocol/schemes/Call.d.ts +35 -0
  15. package/build/types/protocol/schemes/IncomingCall.d.ts +6 -0
  16. package/build/types/protocol/schemes/Message.d.ts +3 -1
  17. package/build/types/protocol/schemes/MessageCall.d.ts +9 -0
  18. package/build/types/protocol/schemes/Room.d.ts +2 -0
  19. package/build/types/protocol/schemes/RoomCall.d.ts +6 -0
  20. package/build/types/protocol/schemes/UserData.d.ts +1 -0
  21. package/build/types/protocol/schemes/UserState.d.ts +4 -0
  22. package/build/types/protocol/schemes/commands/CreateMessage.d.ts +2 -0
  23. package/build/types/protocol/schemes/commands/DeclineCall.d.ts +3 -0
  24. package/build/types/protocol/schemes/commands/GetCallMembers.d.ts +5 -0
  25. package/build/types/protocol/schemes/commands/InviteToCall.d.ts +5 -0
  26. package/build/types/protocol/schemes/commands/JoinCall.d.ts +4 -0
  27. package/build/types/protocol/schemes/commands/KickCallMember.d.ts +4 -0
  28. package/build/types/protocol/schemes/commands/MuteCallMember.d.ts +4 -0
  29. package/build/types/protocol/schemes/commands/SetPermissionOverwrites.d.ts +1 -0
  30. package/build/types/protocol/schemes/commands/SetSessionData.d.ts +1 -0
  31. package/build/types/protocol/schemes/commands/SetUserData.d.ts +1 -0
  32. package/build/types/protocol/schemes/commands/UpdateCallMember.d.ts +7 -0
  33. package/build/types/protocol/schemes/commands/UpdateRoom.d.ts +2 -0
  34. package/build/types/protocol/schemes/events/Bye.d.ts +1 -0
  35. package/build/types/protocol/schemes/events/CallJoined.d.ts +7 -0
  36. package/build/types/protocol/schemes/events/CallMemberJoined.d.ts +5 -0
  37. package/build/types/protocol/schemes/events/CallMemberLeft.d.ts +4 -0
  38. package/build/types/protocol/schemes/events/CallMemberUpdated.d.ts +6 -0
  39. package/build/types/protocol/schemes/events/CallMembers.d.ts +5 -0
  40. package/build/types/protocol/schemes/events/CallUpdated.d.ts +5 -0
  41. package/build/types/protocol/schemes/events/CallVideoLimitReached.d.ts +4 -0
  42. package/build/types/protocol/schemes/events/Error.d.ts +6 -0
  43. package/build/types/protocol/schemes/events/IncomingCallUpdated.d.ts +5 -0
  44. package/build/types/state-tracker/CallsManager.d.ts +74 -0
  45. package/build/types/state-tracker/ChatStateTracker.d.ts +5 -0
  46. package/build/types/state-tracker/StateSnapshot.d.ts +1 -1
  47. 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, 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";
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, JoinCall, DeclineCall, InviteToCall, MuteCallMember, KickCallMember, UpdateCallMember, GetCallMembers, CallJoined, CallUpdated, IncomingCallUpdated, CallVideoLimitReached, CallMembers, CallMemberJoined, CallMemberUpdated, CallMemberLeft } 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>;
@@ -112,6 +112,14 @@ export type EventsMap = {
112
112
  InteractionResolved: InteractionResolved;
113
113
  ReactionDetails: ReactionDetails;
114
114
  Typing: Typing;
115
+ CallJoined: CallJoined;
116
+ CallUpdated: CallUpdated;
117
+ IncomingCallUpdated: IncomingCallUpdated;
118
+ CallVideoLimitReached: CallVideoLimitReached;
119
+ CallMembers: CallMembers;
120
+ CallMemberJoined: CallMemberJoined;
121
+ CallMemberUpdated: CallMemberUpdated;
122
+ CallMemberLeft: CallMemberLeft;
115
123
  };
116
124
  /**
117
125
  * Map of commands and their corresponding events.
@@ -199,5 +207,12 @@ export type CommandsMap = {
199
207
  Unreact: CommandDefinition<Unreact, EventsMap['Reacted'] | EventsMap['Ok']>;
200
208
  GetReactionDetails: CommandDefinition<GetReactionDetails, EventsMap['ReactionDetails']>;
201
209
  Type: CommandDefinition<Type, EventsMap['Ok']>;
210
+ JoinCall: CommandDefinition<JoinCall, EventsMap['CallJoined']>;
211
+ DeclineCall: CommandDefinition<DeclineCall, EventsMap['Ok']>;
212
+ InviteToCall: CommandDefinition<InviteToCall, EventsMap['Ok']>;
213
+ MuteCallMember: CommandDefinition<MuteCallMember, EventsMap['Ok']>;
214
+ KickCallMember: CommandDefinition<KickCallMember, EventsMap['Ok']>;
215
+ UpdateCallMember: CommandDefinition<UpdateCallMember, EventsMap['Ok']>;
216
+ GetCallMembers: CommandDefinition<GetCallMembers, EventsMap['CallMembers']>;
202
217
  };
203
218
  export {};
@@ -126,7 +126,41 @@ export declare class Permissions {
126
126
  value: number;
127
127
  maxLayer: Layer;
128
128
  };
129
+ JoinCalls: {
130
+ value: number;
131
+ maxLayer: Layer;
132
+ };
133
+ ShareVideo: {
134
+ value: number;
135
+ maxLayer: Layer;
136
+ };
137
+ InviteToCall: {
138
+ value: number;
139
+ maxLayer: Layer;
140
+ };
141
+ ManageCalls: {
142
+ value: number;
143
+ maxLayer: Layer;
144
+ };
129
145
  };
146
+ /**
147
+ * Whether the permission mask (e.g. from {@link PermissionsManager.calculatePermissions}) grants the permission.
148
+ * Use it and {@link union} / {@link subtract} instead of `&` and `|`: JavaScript bitwise operators keep only
149
+ * 32 bits, and permissions go beyond them.
150
+ */
151
+ static has(mask: number, name: keyof typeof this.list): boolean;
152
+ /**
153
+ * The permission masks combined (`a | b`), safe for permissions beyond 32 bits.
154
+ */
155
+ static union(...masks: number[]): number;
156
+ /**
157
+ * The mask without the permissions of `removed` (`mask & ~removed`), safe for permissions beyond 32 bits.
158
+ */
159
+ static subtract(mask: number, removed: number): number;
160
+ /**
161
+ * Mask of all the permissions this version of the SDK knows - for `SetPermissionOverwrites.knownPermissions`.
162
+ */
163
+ static getKnownMask(): number;
130
164
  static getNames(): (keyof typeof this.list)[];
131
165
  static getByName(name: keyof typeof this.list): PermissionDefinition | undefined;
132
166
  static canBeDefinedOnLayer(permissionName: keyof typeof this.list, layer: Layer): boolean;
@@ -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, MessageEmbedFlag, NO_LIMIT, PmParticipantFlag, RoleFlag, SearchRange, UiPurpose, SpaceFeature, SpaceIntent, STORAGE_UNIT_BYTES, UserFeature, UserStatus } from './protocol';
7
+ import { CallMemberFlag, 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,11 +12,12 @@ 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, MessageEmbedFlag, PmParticipantFlag, UserStatus, RoleFlag, SpaceFeature, UserFeature, HistoryRotation, SearchRange, UiPurpose, SpaceIntent, NO_LIMIT, STORAGE_UNIT_BYTES, STATE_SNAPSHOT_VERSION, TYPING_INTERVAL_MS, TYPING_TIMEOUT_MS, };
15
+ import { CallsManager } from "./state-tracker/CallsManager";
16
+ export { IndexedCollection, ObservableIndexedCollection, IndexedObjectCollection, ObservableIndexedObjectCollection, Permissions, PermissionDefinition, Layer, WebSocketChatClient, WebApiChatClient, FilesClient, AbstractRestClient, extractUserFromMember, isGroupPm, getPmPeers, CallMemberFlag, 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
17
  export type { CommandResult, CommandRequest, CommandResponse, CommandsMap, EventsMap, } from "./AbstractChatClient";
17
18
  export type { WebSocketClientOptions } from "./WebSocketChatClient";
18
19
  export type { WebApiChatClientOptions } from "./WebApiChatClient";
19
20
  export type { RestClientOptions, RestClientResponse } from "./AbstractRestClient";
20
21
  export type { EventHandler, ObservableInterface } from "./EventTarget";
21
22
  export type { StateSnapshot, SpaceRoomsSnapshot, RoomFollowedTopicsSnapshot, EmoticonsSnapshot, StateSnapshotIntent, TopicHistorySnapshot, RoomMembersSnapshot, } from "./state-tracker/StateSnapshot";
22
- export type { ChatTypes, File, UnreadSummary, TopicHistoryWindow, PermissionsManager, TypingManager, TypingUsers, };
23
+ export type { ChatTypes, File, UnreadSummary, TopicHistoryWindow, PermissionsManager, TypingManager, TypingUsers, CallsManager, };
@@ -117,6 +117,7 @@ import { SetClientData } from "./schemes/commands/SetClientData";
117
117
  import { ClientData } from "./schemes/events/ClientData";
118
118
  import { RoomStream, RoomStreamType } from "./schemes/RoomStream";
119
119
  import { RoomHistory, RoomHistoryMode } from "./schemes/RoomHistory";
120
+ import { RoomCall } from "./schemes/RoomCall";
120
121
  import { GetRoomSummary } from "./schemes/commands/GetRoomSummary";
121
122
  import { GetSpaceSummary } from "./schemes/commands/GetSpaceSummary";
122
123
  import { SpaceSummary as SpaceSummaryEvent } from "./schemes/events/SpaceSummary";
@@ -178,5 +179,23 @@ import { Entitlements } from "./schemes/events/Entitlements";
178
179
  import { EntitlementUsage } from "./schemes/events/EntitlementUsage";
179
180
  import { CreateAccessTicket, TicketAudience } from "./schemes/commands/CreateAccessTicket";
180
181
  import { AccessTicket } from "./schemes/events/AccessTicket";
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, };
182
+ import { Call, CallMember, CallMemberFlag, CallMode, CallQuality, CallTurn } from "./schemes/Call";
183
+ import { MessageCall, MessageCallStatus } from "./schemes/MessageCall";
184
+ import { JoinCall } from "./schemes/commands/JoinCall";
185
+ import { DeclineCall } from "./schemes/commands/DeclineCall";
186
+ import { InviteToCall } from "./schemes/commands/InviteToCall";
187
+ import { MuteCallMember } from "./schemes/commands/MuteCallMember";
188
+ import { KickCallMember } from "./schemes/commands/KickCallMember";
189
+ import { UpdateCallMember } from "./schemes/commands/UpdateCallMember";
190
+ import { CallJoined } from "./schemes/events/CallJoined";
191
+ import { CallUpdated } from "./schemes/events/CallUpdated";
192
+ import { IncomingCall } from "./schemes/IncomingCall";
193
+ import { IncomingCallUpdated } from "./schemes/events/IncomingCallUpdated";
194
+ import { CallVideoLimitReached } from "./schemes/events/CallVideoLimitReached";
195
+ import { GetCallMembers } from "./schemes/commands/GetCallMembers";
196
+ import { CallMembers } from "./schemes/events/CallMembers";
197
+ import { CallMemberJoined } from "./schemes/events/CallMemberJoined";
198
+ import { CallMemberUpdated } from "./schemes/events/CallMemberUpdated";
199
+ import { CallMemberLeft } from "./schemes/events/CallMemberLeft";
200
+ export type { Envelope, Message, MessageType, MessageAuthor, MessageMentions, Role, RoleIcon, Room, RoomType, PmParticipant, RoomStream, RoomStreamType, RoomHistory, RoomHistoryMode, RoomCall, 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, Call, CallMember, CallQuality, CallMode, CallTurn, IncomingCall, MessageCall, MessageCallStatus, 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, CallJoined, CallUpdated, IncomingCallUpdated, CallVideoLimitReached, CallMembers, CallMemberJoined, CallMemberUpdated, CallMemberLeft, 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, JoinCall, DeclineCall, InviteToCall, MuteCallMember, KickCallMember, UpdateCallMember, GetCallMembers, };
201
+ export { CallMemberFlag, ErrorCode, MessageEmbedFlag, NO_LIMIT, STORAGE_UNIT_BYTES, HistoryRotation, PmParticipantFlag, RoleFlag, SearchRange, SpaceFeature, SpaceIntent, UiPurpose, UserFeature, UserStatus, };
@@ -0,0 +1,35 @@
1
+ import { User } from "./User";
2
+ import { ChatLocation } from "./ChatLocation";
3
+ export type CallMode = 'Conversation' | 'Stage' | 'Queue';
4
+ export declare enum CallMemberFlag {
5
+ Camera = 1,
6
+ ScreenShare = 2,
7
+ Speaker = 4,
8
+ RaiseBlocked = 16
9
+ }
10
+ export interface CallMember {
11
+ user: User;
12
+ joinedAt: string;
13
+ flags: number;
14
+ handRaisedAt: string | null;
15
+ }
16
+ export interface CallTurn {
17
+ userId: string;
18
+ endsAt: string;
19
+ claimBy: string | null;
20
+ }
21
+ export interface CallQuality {
22
+ audioBitrate: number;
23
+ cameraMaxHeight: number;
24
+ screenMaxHeight: number;
25
+ screenMaxFps: number;
26
+ }
27
+ export interface Call {
28
+ location: ChatLocation;
29
+ messageId: string;
30
+ startedAt: string;
31
+ mode: CallMode;
32
+ turn: CallTurn | null;
33
+ autoEndAt: string | null;
34
+ members: CallMember[];
35
+ }
@@ -0,0 +1,6 @@
1
+ import { Call } from "./Call";
2
+ import { User } from "./User";
3
+ export interface IncomingCall {
4
+ call: Call;
5
+ caller: User;
6
+ }
@@ -3,7 +3,8 @@ import { ChatLocation } from "./ChatLocation";
3
3
  import { MessageReaction } from "./Reaction";
4
4
  import { MessagePoll } from "./MessagePoll";
5
5
  import { MessageEmbed } from "./MessageEmbed";
6
- export type MessageType = 'Text' | 'RoomJoin' | 'RoomMemberAdd' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'Ephemeral' | 'Poll' | 'RoomRename';
6
+ import { MessageCall } from "./MessageCall";
7
+ export type MessageType = 'Text' | 'RoomJoin' | 'RoomMemberAdd' | 'RoomLeave' | 'SpaceJoin' | 'SpaceLeave' | 'TopicChange' | 'CustomNickChange' | 'Ephemeral' | 'Poll' | 'RoomRename' | 'Call' | 'CallJoin' | 'CallLeave';
7
8
  /**
8
9
  * Mention targets a message actually reached, as resolved by the server: role
9
10
  * mentions the author was not allowed to fire are absent, even though they stay
@@ -29,6 +30,7 @@ export interface Message {
29
30
  attachments: string[] | null;
30
31
  reactions: MessageReaction[];
31
32
  poll?: MessagePoll;
33
+ call?: MessageCall | null;
32
34
  mentions: MessageMentions | null;
33
35
  editedAt?: string | null;
34
36
  replyTo?: string | null;
@@ -0,0 +1,9 @@
1
+ import { CallMember, CallMode } from "./Call";
2
+ export type MessageCallStatus = 'Ongoing' | 'Ended' | 'Missed' | 'Declined';
3
+ export interface MessageCall {
4
+ status: MessageCallStatus;
5
+ mode: CallMode;
6
+ duration: number | null;
7
+ partialMembers: CallMember[];
8
+ memberCount: number;
9
+ }
@@ -3,6 +3,7 @@ import { User } from "./User";
3
3
  import { RoomStream } from "./RoomStream";
4
4
  import { RoomHistory } from "./RoomHistory";
5
5
  import { PmParticipant } from "./PmParticipant";
6
+ import { RoomCall } from "./RoomCall";
6
7
  export type RoomType = 'Text' | 'ClassicText' | 'Pm';
7
8
  export interface Room {
8
9
  id: string;
@@ -17,4 +18,5 @@ export interface Room {
17
18
  flags: number;
18
19
  stream: RoomStream | null;
19
20
  history: RoomHistory | null;
21
+ call: RoomCall;
20
22
  }
@@ -0,0 +1,6 @@
1
+ import { CallMode } from "./Call";
2
+ export interface RoomCall {
3
+ mode: CallMode;
4
+ userLimit: number | null;
5
+ turnSeconds: number;
6
+ }
@@ -7,4 +7,5 @@ export interface UserData {
7
7
  */
8
8
  showAsyncPresence: boolean;
9
9
  language: string | null;
10
+ acceptCalls: boolean;
10
11
  }
@@ -1,6 +1,10 @@
1
1
  import { Space } from "./Space";
2
2
  import { Room } from "./Room";
3
+ import { Call } from "./Call";
4
+ import { IncomingCall } from "./IncomingCall";
3
5
  export interface UserState {
4
6
  spaces: Space[];
5
7
  rooms: Room[];
8
+ calls: Call[];
9
+ incomingCalls: IncomingCall[];
6
10
  }
@@ -1,6 +1,7 @@
1
1
  import { ChatLocation } from "../ChatLocation";
2
2
  import { MessagePoll } from "../MessagePoll";
3
3
  import { SendableEmbed } from "../MessageEmbed";
4
+ import { MessageMentions } from "../Message";
4
5
  export interface CreateMessage {
5
6
  location: ChatLocation;
6
7
  content: string;
@@ -16,4 +17,5 @@ export interface CreateMessage {
16
17
  interactionId?: string;
17
18
  /** Bots only: the id of the room member the message is shown to; it is not stored and resolves with `Ok` */
18
19
  ephemeralFor?: string;
20
+ allowedMentions?: MessageMentions;
19
21
  }
@@ -0,0 +1,3 @@
1
+ export interface DeclineCall {
2
+ roomId: string;
3
+ }
@@ -0,0 +1,5 @@
1
+ export interface GetCallMembers {
2
+ messageId: string;
3
+ limit?: number;
4
+ offset?: number;
5
+ }
@@ -0,0 +1,5 @@
1
+ export interface InviteToCall {
2
+ roomId: string;
3
+ userIds?: string[];
4
+ roleIds?: string[];
5
+ }
@@ -0,0 +1,4 @@
1
+ export interface JoinCall {
2
+ roomId: string;
3
+ title?: string;
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface KickCallMember {
2
+ roomId: string;
3
+ userId: string;
4
+ }
@@ -0,0 +1,4 @@
1
+ export interface MuteCallMember {
2
+ roomId: string;
3
+ userId: string;
4
+ }
@@ -5,4 +5,5 @@ export interface SetPermissionOverwrites {
5
5
  location: ChatLocation;
6
6
  target: PermissionOverwritesTarget;
7
7
  overwrites: PermissionOverwritesValue;
8
+ knownPermissions?: number;
8
9
  }
@@ -1,6 +1,7 @@
1
1
  import { SessionPlatform } from "../SessionData";
2
2
  export interface SessionPush {
3
3
  token?: string;
4
+ voipToken?: string;
4
5
  active?: boolean;
5
6
  /**
6
7
  * @deprecated The platform describes the session, not its push registration.
@@ -3,4 +3,5 @@ export interface SetUserData {
3
3
  privateMessagePolicy?: PrivateMessagePolicy;
4
4
  showAsyncPresence?: boolean;
5
5
  language?: string;
6
+ acceptCalls?: boolean | null;
6
7
  }
@@ -0,0 +1,7 @@
1
+ export interface UpdateCallMember {
2
+ roomId: string;
3
+ userId: string;
4
+ speaker?: boolean;
5
+ handRaised?: boolean;
6
+ raiseBlocked?: boolean;
7
+ }
@@ -1,5 +1,6 @@
1
1
  import { RoomStream } from "../RoomStream";
2
2
  import { RoomHistory } from "../RoomHistory";
3
+ import { RoomCall } from "../RoomCall";
3
4
  export interface UpdateRoom {
4
5
  id: string;
5
6
  name?: string;
@@ -7,4 +8,5 @@ export interface UpdateRoom {
7
8
  flags?: number;
8
9
  stream?: RoomStream | null;
9
10
  history?: RoomHistory;
11
+ call?: RoomCall;
10
12
  }
@@ -1,4 +1,5 @@
1
1
  import { LeaveReason } from "../LeaveReason";
2
2
  export interface Bye {
3
3
  reason: LeaveReason;
4
+ retryAfterMs?: number;
4
5
  }
@@ -0,0 +1,7 @@
1
+ import { CallQuality } from "../Call";
2
+ export interface CallJoined {
3
+ roomId: string;
4
+ url: string;
5
+ token: string;
6
+ quality: CallQuality;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { CallMember } from "../Call";
2
+ export interface CallMemberJoined {
3
+ roomId: string;
4
+ member: CallMember;
5
+ }
@@ -0,0 +1,4 @@
1
+ export interface CallMemberLeft {
2
+ roomId: string;
3
+ userId: string;
4
+ }
@@ -0,0 +1,6 @@
1
+ import { CallMember } from "../Call";
2
+ export interface CallMemberUpdated {
3
+ roomId: string;
4
+ userId: string;
5
+ member: CallMember;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { CallMember } from "../Call";
2
+ export interface CallMembers {
3
+ messageId: string;
4
+ members: CallMember[];
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Call } from "../Call";
2
+ export interface CallUpdated {
3
+ roomId: string;
4
+ call: Call | null;
5
+ }
@@ -0,0 +1,4 @@
1
+ export interface CallVideoLimitReached {
2
+ roomId: string;
3
+ source: 'Camera' | 'ScreenShare';
4
+ }
@@ -9,6 +9,11 @@ export interface Error {
9
9
  }
10
10
  export declare enum ErrorCode {
11
11
  Authentication = "AuthenticationException",
12
+ CallFull = "CallFullException",
13
+ CallMode = "CallModeException",
14
+ CallNotFound = "CallNotFoundException",
15
+ CallsNotAccepted = "CallsNotAcceptedException",
16
+ CallsUnavailable = "CallsUnavailableException",
12
17
  CommandRateLimitExceeded = "CommandRateLimitExceededException",
13
18
  InvalidSearchQuery = "InvalidSearchQueryException",
14
19
  MessageSearchUnavailable = "MessageSearchUnavailableException",
@@ -17,6 +22,7 @@ export declare enum ErrorCode {
17
22
  RoomIgnored = "RoomIgnoredException",
18
23
  RoomNotFound = "RoomNotFoundException",
19
24
  SpaceJoinRestricted = "SpaceJoinRestrictedException",
25
+ TooManyCallInvitees = "TooManyCallInviteesException",
20
26
  TopicNotFound = "TopicNotFoundException",
21
27
  UserNotFound = "UserNotFoundException"
22
28
  }
@@ -0,0 +1,5 @@
1
+ import { IncomingCall } from "../IncomingCall";
2
+ export interface IncomingCallUpdated {
3
+ roomId: string;
4
+ incomingCall: IncomingCall | null;
5
+ }
@@ -0,0 +1,74 @@
1
+ import { ChatStateTracker } from "./ChatStateTracker";
2
+ import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
3
+ import { Call, CallJoined, CallMember, IncomingCall } from "../protocol";
4
+ export declare class CallsManager {
5
+ private tracker;
6
+ private readonly list;
7
+ private readonly ringing;
8
+ constructor(tracker: ChatStateTracker);
9
+ /**
10
+ * Ongoing calls in the rooms you are a member of, keyed by room id - at most one per room. Filled with the
11
+ * session and kept current by the server; a call leaves the collection when its last member leaves.
12
+ * Not part of the state snapshot, so it stays empty until the first session.
13
+ */
14
+ get(): Promise<ObservableIndexedObjectCollection<Call>>;
15
+ /**
16
+ * Calls ringing at you, keyed by room id. A call leaves the collection when it is answered or declined on any of
17
+ * your devices, or when it ends. Filled with the session, like the ongoing calls.
18
+ */
19
+ getRinging(): Promise<ObservableIndexedObjectCollection<IncomingCall>>;
20
+ /**
21
+ * Members of the call with a raised hand, in the order they raised it - the queue in the `Queue` mode.
22
+ */
23
+ getQueue(call: Call): CallMember[];
24
+ /**
25
+ * A page of the members of the call the call message stands for, in the order they joined. The message itself
26
+ * carries only some of them (`MessageCall.partialMembers`) and their count.
27
+ */
28
+ getMembers(messageId: string, page?: {
29
+ limit?: number;
30
+ offset?: number;
31
+ }): Promise<CallMember[]>;
32
+ /**
33
+ * Join the call in the room, starting it if there is none. Connect to the media server with the returned access
34
+ * yourself; leaving the call is disconnecting from it. Joining another call makes the server end your
35
+ * participation in the previous one. In the `Stage` and `Queue` modes you join as a listener (a moderator as a
36
+ * speaker), and the title given when starting the call names its topic.
37
+ */
38
+ join(roomId: string, title?: string): Promise<CallJoined>;
39
+ /**
40
+ * Stop the call ringing at you, on all of your devices. In a one-to-one private room it also ends the call.
41
+ */
42
+ decline(roomId: string): Promise<void>;
43
+ /**
44
+ * Invite the given members of the room, or the room members having one of the roles, to the call - it rings at
45
+ * them. Members already in the call and you are skipped.
46
+ */
47
+ invite(roomId: string, target: {
48
+ userIds?: string[];
49
+ roleIds?: string[];
50
+ }): Promise<void>;
51
+ /**
52
+ * Turn off the microphone of a call member. Only they can turn it on again.
53
+ */
54
+ muteMember(roomId: string, userId: string): Promise<void>;
55
+ kickMember(roomId: string, userId: string): Promise<void>;
56
+ /**
57
+ * Raise or lower your hand (in the `Queue` mode: enter or leave the queue) and leave the stage, which in the
58
+ * `Queue` mode ends your turn. A moderator also moves a member to the stage and off it (skipping their turn),
59
+ * lowers their hand and blocks them from raising it until the call ends.
60
+ */
61
+ updateMember(roomId: string, userId: string, change: {
62
+ speaker?: boolean;
63
+ handRaised?: boolean;
64
+ raiseBlocked?: boolean;
65
+ }): Promise<void>;
66
+ private send;
67
+ private handleSession;
68
+ private handleCallUpdated;
69
+ private handleIncomingCallUpdated;
70
+ private handleMemberChanged;
71
+ private setCall;
72
+ private handleRoomGone;
73
+ private handleSpaceGone;
74
+ }
@@ -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 { CallsManager } from "./CallsManager";
9
10
  import { StateSnapshot, StateSnapshotIntent } from "./StateSnapshot";
10
11
  export declare class ChatStateTracker {
11
12
  readonly client: WebSocketChatClient;
@@ -33,6 +34,10 @@ export declare class ChatStateTracker {
33
34
  * State of relationships with other users.
34
35
  */
35
36
  readonly relationships: RelationshipsManager;
37
+ /**
38
+ * State of the calls in your rooms and of the calls ringing at you.
39
+ */
40
+ readonly calls: CallsManager;
36
41
  private _me;
37
42
  private readonly deferredSession;
38
43
  private sessionReceived;
@@ -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 = 3;
5
+ export declare const STATE_SNAPSHOT_VERSION = 4;
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}.