@devanachat/sdk 0.13.0 → 0.15.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 (59) hide show
  1. package/CHANGELOG.md +99 -1
  2. package/build/index.cjs.js +686 -15
  3. package/build/index.cjs.js.map +1 -1
  4. package/build/index.mjs +684 -15
  5. package/build/index.mjs.map +1 -1
  6. package/build/index.umd.js +1 -1
  7. package/build/index.umd.js.map +1 -1
  8. package/build/types/AbstractChatClient.d.ts +28 -1
  9. package/build/types/Permissions.d.ts +38 -0
  10. package/build/types/index.d.ts +6 -3
  11. package/build/types/protocol/index.d.ts +35 -2
  12. package/build/types/protocol/schemes/Activity.d.ts +16 -0
  13. package/build/types/protocol/schemes/Call.d.ts +35 -0
  14. package/build/types/protocol/schemes/IncomingCall.d.ts +6 -0
  15. package/build/types/protocol/schemes/Message.d.ts +3 -1
  16. package/build/types/protocol/schemes/MessageCall.d.ts +9 -0
  17. package/build/types/protocol/schemes/Room.d.ts +2 -0
  18. package/build/types/protocol/schemes/RoomCall.d.ts +6 -0
  19. package/build/types/protocol/schemes/SavedItem.d.ts +7 -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/DeclineCall.d.ts +3 -0
  23. package/build/types/protocol/schemes/commands/GetActivities.d.ts +3 -0
  24. package/build/types/protocol/schemes/commands/GetCallMembers.d.ts +5 -0
  25. package/build/types/protocol/schemes/commands/GetSavedItems.d.ts +3 -0
  26. package/build/types/protocol/schemes/commands/InviteToCall.d.ts +5 -0
  27. package/build/types/protocol/schemes/commands/JoinCall.d.ts +4 -0
  28. package/build/types/protocol/schemes/commands/KickCallMember.d.ts +4 -0
  29. package/build/types/protocol/schemes/commands/MuteCallMember.d.ts +4 -0
  30. package/build/types/protocol/schemes/commands/SaveItem.d.ts +5 -0
  31. package/build/types/protocol/schemes/commands/SetPermissionOverwrites.d.ts +1 -0
  32. package/build/types/protocol/schemes/commands/SetSessionData.d.ts +1 -0
  33. package/build/types/protocol/schemes/commands/SetUserData.d.ts +1 -0
  34. package/build/types/protocol/schemes/commands/UnsaveItem.d.ts +5 -0
  35. package/build/types/protocol/schemes/commands/UpdateActivities.d.ts +4 -0
  36. package/build/types/protocol/schemes/commands/UpdateCallMember.d.ts +7 -0
  37. package/build/types/protocol/schemes/commands/UpdateRoom.d.ts +2 -0
  38. package/build/types/protocol/schemes/events/Activities.d.ts +9 -0
  39. package/build/types/protocol/schemes/events/ActivityDeleted.d.ts +3 -0
  40. package/build/types/protocol/schemes/events/ActivityUpdated.d.ts +4 -0
  41. package/build/types/protocol/schemes/events/CallJoined.d.ts +7 -0
  42. package/build/types/protocol/schemes/events/CallMemberJoined.d.ts +5 -0
  43. package/build/types/protocol/schemes/events/CallMemberLeft.d.ts +4 -0
  44. package/build/types/protocol/schemes/events/CallMemberUpdated.d.ts +6 -0
  45. package/build/types/protocol/schemes/events/CallMembers.d.ts +5 -0
  46. package/build/types/protocol/schemes/events/CallUpdated.d.ts +5 -0
  47. package/build/types/protocol/schemes/events/CallVideoLimitReached.d.ts +4 -0
  48. package/build/types/protocol/schemes/events/Error.d.ts +9 -1
  49. package/build/types/protocol/schemes/events/IncomingCallUpdated.d.ts +5 -0
  50. package/build/types/protocol/schemes/events/ItemSaved.d.ts +6 -0
  51. package/build/types/protocol/schemes/events/ItemUnsaved.d.ts +5 -0
  52. package/build/types/protocol/schemes/events/NewActivity.d.ts +8 -0
  53. package/build/types/protocol/schemes/events/SavedItems.d.ts +6 -0
  54. package/build/types/state-tracker/ActivitiesManager.d.ts +63 -0
  55. package/build/types/state-tracker/CallsManager.d.ts +74 -0
  56. package/build/types/state-tracker/ChatStateTracker.d.ts +18 -0
  57. package/build/types/state-tracker/SavedItemsManager.d.ts +46 -0
  58. package/build/types/state-tracker/StateSnapshot.d.ts +1 -1
  59. package/package.json +1 -1
@@ -0,0 +1,63 @@
1
+ import { EventTarget } from "../EventTarget";
2
+ import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
3
+ import { Activity, Message, User } from "../protocol";
4
+ import { ChatStateTracker } from "./ChatStateTracker";
5
+ interface EventMap {
6
+ seenAtChange: {};
7
+ }
8
+ export declare class ActivitiesManager extends EventTarget<EventMap> {
9
+ private tracker;
10
+ private readonly activities;
11
+ private readonly messages;
12
+ private readonly users;
13
+ private readonly promises;
14
+ private readonly acks;
15
+ private readonly hiddenRoomIds;
16
+ private activitiesWanted;
17
+ private messagesWanted;
18
+ private refreshScheduled;
19
+ private seen;
20
+ constructor(tracker: ChatStateTracker);
21
+ /**
22
+ * Your latest activities, keyed by id; always the same collection. The first call fetches them, later ones resolve
23
+ * with them. Once fetched, they are fetched again after every reconnect, also when the first fetch failed because
24
+ * the connection was not ready yet. The collection keeps no meaningful order - sort by `createdAt`. Marking the list
25
+ * as seen and clearing it is done with the `UpdateActivities` command.
26
+ * @param fetchWithMessages Fetch the messages and the actors of the activities along, so {@link getMessages} and
27
+ * {@link getUsers} need no request.
28
+ */
29
+ get(fetchWithMessages?: boolean): Promise<ObservableIndexedObjectCollection<Activity>>;
30
+ /**
31
+ * The messages the activities point at, keyed by message id; always the same collection. The first call fetches
32
+ * them together with the list of {@link get}, unless they were fetched already; afterwards they come with new
33
+ * activities, follow the edits and are fetched again after every reconnect.
34
+ */
35
+ getMessages(): Promise<ObservableIndexedObjectCollection<Message>>;
36
+ /**
37
+ * The actors of the activities, keyed by user id; always the same collection, fetched and kept together with
38
+ * {@link getMessages}.
39
+ */
40
+ getUsers(): Promise<ObservableIndexedObjectCollection<User>>;
41
+ /**
42
+ * When the list was last seen, on any device; null until it is fetched or while it was never seen. A change emits
43
+ * `seenAtChange`. Activities created later that are not {@link Activity.isRead} are the unread ones.
44
+ */
45
+ get seenAt(): string | null;
46
+ private registerFetch;
47
+ private fetch;
48
+ private apply;
49
+ private refresh;
50
+ private setSeen;
51
+ private handleNewActivity;
52
+ private handleActivityUpdated;
53
+ private handleActivityDeleted;
54
+ private handleFollowedTopicUpdated;
55
+ private handleMessageUpdated;
56
+ private handleMessagesRedacted;
57
+ private handleRoomDeleted;
58
+ private handleRoomLeft;
59
+ private handleRoomJoined;
60
+ private deleteActivities;
61
+ private handleSession;
62
+ }
63
+ export {};
@@ -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,9 @@ 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";
10
+ import { ActivitiesManager } from "./ActivitiesManager";
11
+ import { SavedItemsManager } from "./SavedItemsManager";
9
12
  import { StateSnapshot, StateSnapshotIntent } from "./StateSnapshot";
10
13
  export declare class ChatStateTracker {
11
14
  readonly client: WebSocketChatClient;
@@ -33,6 +36,21 @@ export declare class ChatStateTracker {
33
36
  * State of relationships with other users.
34
37
  */
35
38
  readonly relationships: RelationshipsManager;
39
+ /**
40
+ * State of the calls in your rooms and of the calls ringing at you.
41
+ */
42
+ readonly calls: CallsManager;
43
+ /**
44
+ * Your latest personal events from all spaces (mentions, replies, reactions, followed threads, missed calls) and the
45
+ * activities the server publishes. Private conversations keep their own unread state. Nothing is fetched until you
46
+ * ask for it. Not part of the state snapshot.
47
+ */
48
+ readonly activities: ActivitiesManager;
49
+ /**
50
+ * The rooms and messages you saved, from all spaces. Nothing is fetched until you ask for it. Not part of the state
51
+ * snapshot.
52
+ */
53
+ readonly savedItems: SavedItemsManager;
36
54
  private _me;
37
55
  private readonly deferredSession;
38
56
  private sessionReceived;
@@ -0,0 +1,46 @@
1
+ import { ObservableIndexedObjectCollection } from "../IndexedObjectCollection";
2
+ import { Message, SavedItem, SavedItemType } from "../protocol";
3
+ import { ChatStateTracker } from "./ChatStateTracker";
4
+ /**
5
+ * The key of a saved item in the collection returned by {@link SavedItemsManager.get}.
6
+ */
7
+ export declare const savedItemKey: (type: SavedItemType, id: string) => string;
8
+ export declare class SavedItemsManager {
9
+ private tracker;
10
+ private readonly items;
11
+ private readonly messages;
12
+ private readonly promises;
13
+ private readonly hiddenRoomIds;
14
+ private itemsWanted;
15
+ private messagesWanted;
16
+ private refreshScheduled;
17
+ constructor(tracker: ChatStateTracker);
18
+ /**
19
+ * The rooms and messages you saved, keyed by {@link savedItemKey}; always the same collection. The first call fetches
20
+ * the list, later ones resolve with it. Items of rooms you are not a member of are left out until you rejoin. The
21
+ * collection keeps no meaningful order - sort by `savedAt`. Once fetched, the list is fetched again after every
22
+ * reconnect. Saving and unsaving is done with the `SaveItem` and `UnsaveItem` commands.
23
+ * @param fetchWithMessages Fetch the contents of the saved messages along, so {@link getMessages} needs no request.
24
+ */
25
+ get(fetchWithMessages?: boolean): Promise<ObservableIndexedObjectCollection<SavedItem>>;
26
+ /**
27
+ * The contents of the saved messages, keyed by message id; always the same collection. The first call fetches them
28
+ * together with the list of {@link get}, unless they were fetched already; afterwards they follow the edits and are
29
+ * fetched again after every reconnect.
30
+ */
31
+ getMessages(): Promise<ObservableIndexedObjectCollection<Message>>;
32
+ isSaved(type: SavedItemType, id: string): Promise<boolean>;
33
+ private registerFetch;
34
+ private fetch;
35
+ private apply;
36
+ private refresh;
37
+ private handleItemSaved;
38
+ private handleItemUnsaved;
39
+ private handleMessageUpdated;
40
+ private handleMessagesRedacted;
41
+ private handleRoomDeleted;
42
+ private handleRoomLeft;
43
+ private handleRoomJoined;
44
+ private deleteRoomItems;
45
+ private handleSession;
46
+ }
@@ -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}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devanachat/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.15.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",