@devanachat/sdk 0.10.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.
- package/CHANGELOG.md +76 -0
- package/README.md +2 -2
- package/build/index.cjs.js +533 -147
- package/build/index.cjs.js.map +1 -1
- package/build/index.mjs +531 -148
- package/build/index.mjs.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/AbstractChatClient.d.ts +21 -4
- package/build/types/Permissions.d.ts +13 -1
- package/build/types/index.d.ts +4 -3
- package/build/types/protocol/index.d.ts +18 -4
- package/build/types/protocol/schemes/Message.d.ts +4 -0
- package/build/types/protocol/schemes/MessageEmbed.d.ts +83 -0
- package/build/types/protocol/schemes/Role.d.ts +6 -0
- package/build/types/protocol/schemes/Space.d.ts +1 -0
- package/build/types/protocol/schemes/Topic.d.ts +1 -0
- package/build/types/protocol/schemes/commands/AckInteraction.d.ts +10 -0
- package/build/types/protocol/schemes/commands/CreateMessage.d.ts +8 -0
- package/build/types/protocol/schemes/commands/GetGifCategories.d.ts +3 -0
- package/build/types/protocol/schemes/commands/GetMessages.d.ts +1 -0
- package/build/types/protocol/schemes/commands/Interact.d.ts +5 -0
- package/build/types/protocol/schemes/commands/SearchGifs.d.ts +5 -0
- package/build/types/protocol/schemes/commands/Type.d.ts +4 -0
- package/build/types/protocol/schemes/commands/UpdateMessage.d.ts +8 -0
- package/build/types/protocol/schemes/commands/UpdateRole.d.ts +2 -0
- package/build/types/protocol/schemes/commands/UpdateSpace.d.ts +1 -0
- package/build/types/protocol/schemes/commands/UpdateTopic.d.ts +1 -0
- package/build/types/protocol/schemes/events/Error.d.ts +3 -0
- package/build/types/protocol/schemes/events/FoundGifs.d.ts +14 -0
- package/build/types/protocol/schemes/events/GifCategories.d.ts +8 -0
- package/build/types/protocol/schemes/events/Interacted.d.ts +4 -0
- package/build/types/protocol/schemes/events/InteractionResolved.d.ts +7 -0
- package/build/types/protocol/schemes/events/MessageUpdated.d.ts +6 -0
- package/build/types/protocol/schemes/events/Messages.d.ts +6 -2
- package/build/types/protocol/schemes/events/NewInteraction.d.ts +10 -0
- package/build/types/protocol/schemes/events/NewMessage.d.ts +4 -0
- package/build/types/protocol/schemes/events/Typing.d.ts +5 -0
- package/build/types/state-tracker/PermissionsManager.d.ts +1 -1
- package/build/types/state-tracker/RoomMessagesHistory.d.ts +7 -2
- package/build/types/state-tracker/RoomsManager.d.ts +14 -1
- package/build/types/state-tracker/StateSnapshot.d.ts +5 -1
- package/build/types/state-tracker/TopicHistoryWindow.d.ts +29 -2
- package/build/types/state-tracker/TypingManager.d.ts +35 -0
- package/build/types/state-tracker/functions.d.ts +8 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,82 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project follows
|
|
5
5
|
[semver](https://semver.org) (`0.x` minor releases may break the API).
|
|
6
6
|
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
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.
|
|
42
|
+
- Typing notifications: the `Type` command and the `Typing` event (`{location, userId}`), for rooms other than
|
|
43
|
+
`ClassicText`. `RoomsManager.typing.get(roomId, topicId)` returns the ids of the users typing in a topic, tracked from
|
|
44
|
+
the first call, each leaving `TYPING_TIMEOUT_MS` after their last notification or with their message.
|
|
45
|
+
`RoomsManager.typing.notify(roomId, topicId)` sends `Type` at most once per `TYPING_INTERVAL_MS`.
|
|
46
|
+
- Sticky messages: `Topic.stickyMessage`, `CreateMessage.sticky`, `NewMessage.sticky`, `UpdateTopic.stickyMessageId`
|
|
47
|
+
(a message id sticks it, `null` unsticks it) and the `ManagePins` permission. The topics tracked by `RoomsManager`
|
|
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`.
|
|
53
|
+
- Role icons: `Role.icon` (`RoleIcon` - an emoji or an emoticon of the space, `{type, value}` like a reaction) and
|
|
54
|
+
`UpdateRole.icon` (an icon sets it, `null` removes it).
|
|
55
|
+
- Guests: `Space.guestRole` and `UpdateSpace.guestRole` (a role of the space given to temporary accounts when they
|
|
56
|
+
join, `null` turns it off); `SpacesManager` clears it when the role is deleted. The `SendAttachments` permission
|
|
57
|
+
covers attachments and links in messages.
|
|
58
|
+
- `Error.subcode`: an optional refinement of `code`. `ErrorCode.SpaceJoinRestricted` (`JoinSpace` refused) comes with
|
|
59
|
+
`Guests` (the space does not accept temporary accounts) or `Vpn` (it does not accept connections through a VPN or
|
|
60
|
+
Tor).
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
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.
|
|
72
|
+
- `PermissionsManager.calculatePermissions` follows the server: on every layer the space default role (everyone) is
|
|
73
|
+
applied before the other roles, so a deny of another role overrides what everyone allows. An allow of any role still
|
|
74
|
+
wins over a deny of another one.
|
|
75
|
+
- `LeaveRoom` with `ignore: true` is answered only with `RoomLeft`: like a plain `LeaveRoom`, it requires the membership
|
|
76
|
+
of the room and fails for a closed conversation instead of answering `Ok`.
|
|
77
|
+
|
|
78
|
+
### Fixed
|
|
79
|
+
|
|
80
|
+
- After a reconnect, or the first session after a snapshot import, `RoomsManager.getMembers()` of an unchanged
|
|
81
|
+
private conversation sent `GetRoomMembers` instead of using its participants.
|
|
82
|
+
|
|
7
83
|
## [0.10.0]
|
|
8
84
|
|
|
9
85
|
### Added
|
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(['
|
|
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 |
|