@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
package/CHANGELOG.md CHANGED
@@ -8,6 +8,37 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
8
8
 
9
9
  ### Added
10
10
 
11
+ - Editing messages: the `UpdateMessage` command (`{messageId, content?, embed?}` - a field left out stays, `embed: null`
12
+ removes the embed and hides a link preview for good; resolves with `MessageUpdated` or `Ok` when nothing changed), the `MessageUpdated` event carrying the whole message,
13
+ `Message.editedAt` (set only by an edit of the content) and the `EditMessages` permission (`1 << 29`, topic layer).
14
+ History windows replace the loaded message, also where they keep it as a replied one; the topics tracked by
15
+ `RoomsManager` replace it when it is their last or sticky message or the original message of a side topic.
16
+ - Replies: `CreateMessage.replyTo` and `Message.replyTo` (the id of the replied message). The replied messages come
17
+ beside the replies: in `Messages.repliedMessages` when `GetMessages.includeRepliedMessages` is set, and in
18
+ `NewMessage.repliedMessage`. History windows fetch them by default (`includeRepliedMessages`), keep them up to date
19
+ and return them with `getRepliedMessage(message)` - `null` once the replied message is deleted, `undefined` in a
20
+ window without `includeRepliedMessages` when the replied message is not loaded.
21
+ - Embeds: `Message.embed` (`MessageEmbed` - `type` `Link`, `Video`, `Gif` or `Rich`, a `root` list of components and
22
+ `flags`, see `MessageEmbedFlag`). The server builds `Link`, `Video` and `Gif` from the first link of a message and
23
+ attaches them with `MessageUpdated`; bots send `Rich` ones with `CreateMessage.embed` / `UpdateMessage.embed`
24
+ (`SendableEmbed`). `UpdateMessage` with `embed: null` hides a generated embed.
25
+ - Embed interactions: the `Interact` command (`{messageId, actionId, value?}`, resolves with `Interacted`
26
+ carrying the `interactionId`) uses a button or select of a message's embed; the author of the message (a bot) gets
27
+ the `NewInteraction` event (`{interactionId, location, messageId, user, actionId, value}`). Nothing is stored. The id
28
+ ties a later answer of the bot (such as a dialog) to the interaction and the client it came from.
29
+ - Answering interactions: a bot answers within 15 s with `CreateMessage.interactionId` or `UpdateMessage.interactionId`
30
+ (the resulting `NewMessage` / `MessageUpdated` carries the `interactionId`), or with `AckInteraction`
31
+ (`{interactionId, status?: 'Ok' | 'Fail', notice?}`). The user who interacted gets `InteractionResolved`
32
+ (`{interactionId, status, notice}`) for an `AckInteraction`, for an edit that changed nothing and, with the `Timeout`
33
+ status, when nothing came in time.
34
+ - Ephemeral bot messages: `CreateMessage.ephemeralFor` (a user id) shows the message only to that room member, as
35
+ `NewMessage` of the `Ephemeral` type, and resolves with `Ok`; it is not stored, takes no attachments or poll, may
36
+ reply to a message and mention its recipient (through `allowedMentions`, without a push). A recipient taking no
37
+ private messages at all does not get it. `RoomsManager` no longer counts `Ephemeral` messages nor makes them the last one of a topic.
38
+ - GIF search: the `SearchGifs` command (`{query, position?, locale?}`) resolving with `FoundGifs` (`{gifs, next}`, each
39
+ `FoundGif` with its post `url`, size, poster and MP4/WebM sources; pass `next` as `position` for the following page),
40
+ and the `GetGifCategories` command (`{locale?}`) resolving with `GifCategories` (`{categories}`, each `GifCategory`
41
+ with the search `term`, its English `name` and an `imageUrl`). Available when the server runs GIF search.
11
42
  - Typing notifications: the `Type` command and the `Typing` event (`{location, userId}`), for rooms other than
12
43
  `ClassicText`. `RoomsManager.typing.get(roomId, topicId)` returns the ids of the users typing in a topic, tracked from
13
44
  the first call, each leaving `TYPING_TIMEOUT_MS` after their last notification or with their message.
@@ -15,6 +46,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
15
46
  - Sticky messages: `Topic.stickyMessage`, `CreateMessage.sticky`, `NewMessage.sticky`, `UpdateTopic.stickyMessageId`
16
47
  (a message id sticks it, `null` unsticks it) and the `ManagePins` permission. The topics tracked by `RoomsManager`
17
48
  take a new sticky message from `NewMessage` and drop it when it is redacted.
49
+ - Reactions of sticky messages: `RoomsManager.getStickyMyReactions(location, messageId)` returns the reactions of the
50
+ connected user on sticky messages (`MessageUserReactions`, keyed by message id) - fetched once per message with `GetMessages` (`around`,
51
+ `limit: 1`, `includeMyReactions`), as a sticky message comes with its topic, then kept up to date with `Reacted`.
52
+ The topics tracked by `RoomsManager` follow the reaction counters of their sticky message with `ReactionUpdated`.
18
53
  - Role icons: `Role.icon` (`RoleIcon` - an emoji or an emoticon of the space, `{type, value}` like a reaction) and
19
54
  `UpdateRole.icon` (an icon sets it, `null` removes it).
20
55
  - Guests: `Space.guestRole` and `UpdateSpace.guestRole` (a role of the space given to temporary accounts when they
@@ -26,6 +61,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
26
61
 
27
62
  ### Changed
28
63
 
64
+ - **Breaking:** `Messages.myReactions` is a list of `MessageUserReactions` (`{messageId, reactions}`) instead of a map
65
+ keyed by message id, so this version needs a server sending the list; `TopicHistoryWindow.myReactions` keeps the map.
66
+ - **Breaking:** the `RedactMessages` permission is `ManageMessages` (the same bit, `1 << 19`; the `RedactMessages`
67
+ command keeps its name). Besides deleting messages it lets `UpdateMessage` with `embed: null` hide a preview
68
+ generated by the server in any message.
69
+ - State snapshots: version 3 (with the replied messages of the saved histories); older snapshots are rejected.
70
+ - `React` with a reaction the user already has fails with `ReactionExistsAlreadyException`; `Unreact` of a reaction the
71
+ user does not have resolves with `Ok`. Both used to get no answer.
29
72
  - `PermissionsManager.calculatePermissions` follows the server: on every layer the space default role (everyone) is
30
73
  applied before the other roles, so a deny of another role overrides what everyone allows. An allow of any role still
31
74
  wins over a deny of another one.
package/README.md CHANGED
@@ -140,7 +140,7 @@ client.on('NewMessage', async ({message}) => {
140
140
  return;
141
141
  }
142
142
 
143
- const {hasAll} = await client.state!.permissions.check(['RedactMessages'], message.location);
143
+ const {hasAll} = await client.state!.permissions.check(['ManageMessages'], message.location);
144
144
 
145
145
  if (hasAll) {
146
146
  await client.send('RedactMessages', {messageId: message.id});
@@ -216,7 +216,7 @@ because some structures are rebuilt from scratch on the `Session` event.
216
216
  | Manager | What it gives you |
217
217
  |---|---|
218
218
  | `state.spaces` | Your spaces; per space: `getRooms()`, `getMembers()`, `getRoles()`, `getMe()` |
219
- | `state.rooms` | Rooms you are in; per room: `getMembers()`, `getTopics()`, `getMe()` |
219
+ | `state.rooms` | Rooms you are in; per room: `getMembers()`, `getTopics()`, `getMe()`; your reactions on a sticky message (`Topic.stickyMessage`): `getStickyMyReactions()` |
220
220
  | `state.rooms.messages` | Message history windows per topic |
221
221
  | `state.rooms.followedTopics` | Unread counters and mentions, marking rooms as read |
222
222
  | `state.permissions` | Your effective permissions in any location |