korero-chat 0.1.0 → 0.1.2
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/README.md +3 -7
- package/dist/channel.d.ts +21 -5
- package/dist/channel.js +24 -6
- package/dist/http.d.ts +96 -11
- package/dist/http.js +9 -2
- package/dist/index.d.ts +2 -2
- package/dist/session.d.ts +29 -3
- package/dist/session.js +93 -9
- package/dist/types.d.ts +105 -2
- package/dist/types.js +2 -0
- package/package.json +1 -1
- package/src/channel.ts +39 -8
- package/src/http.ts +59 -6
- package/src/index.ts +2 -2
- package/src/session.ts +101 -11
- package/src/types.ts +98 -2
package/src/types.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export interface Account {
|
|
2
2
|
id: string;
|
|
3
3
|
displayName: string;
|
|
4
|
+
/** The highest-ranked held role, used for display. */
|
|
4
5
|
role: string;
|
|
6
|
+
/** Every held role, highest rank first. Servers without multiple roles omit it. */
|
|
7
|
+
roles?: string[];
|
|
5
8
|
badge?: string | null;
|
|
6
9
|
avatarId?: string | null;
|
|
7
10
|
}
|
|
@@ -20,6 +23,13 @@ export interface ChannelData {
|
|
|
20
23
|
canDelete?: boolean;
|
|
21
24
|
/** The account may delete other members' messages in this channel. */
|
|
22
25
|
canDeleteMessages?: boolean;
|
|
26
|
+
/** The server supports pins in this channel. */
|
|
27
|
+
messagePins?: boolean;
|
|
28
|
+
/** The server can search this channel's stored messages with `message.search`. */
|
|
29
|
+
messageSearch?: boolean;
|
|
30
|
+
canPinMessages?: boolean;
|
|
31
|
+
/** The server stores reactions on this channel's messages. */
|
|
32
|
+
messageReactions?: boolean;
|
|
23
33
|
/**
|
|
24
34
|
* The account may read and send this channel's messages, even without joining it.
|
|
25
35
|
* Servers that predate outside chat omit this; chat then needs membership.
|
|
@@ -48,6 +58,7 @@ export interface Member {
|
|
|
48
58
|
adminMuted: boolean;
|
|
49
59
|
adminDeafened?: boolean;
|
|
50
60
|
role?: string;
|
|
61
|
+
roles?: string[];
|
|
51
62
|
badge?: string | null;
|
|
52
63
|
speaking?: boolean;
|
|
53
64
|
}
|
|
@@ -64,11 +75,17 @@ export interface Snapshot {
|
|
|
64
75
|
serverPermissions: string[];
|
|
65
76
|
lowerRoles?: string[];
|
|
66
77
|
assignableRoles?: string[];
|
|
78
|
+
/** Sent to role managers. Changes whenever any account's roles change. */
|
|
79
|
+
accountsRevision?: number;
|
|
67
80
|
bannerImageUrl?: string | null;
|
|
68
81
|
motd?: string;
|
|
82
|
+
/** Formatted MOTD in the chat markup allowlist, when the message has formatting. */
|
|
83
|
+
motdHtml?: string;
|
|
69
84
|
targetAudioBitrate?: number;
|
|
70
85
|
maxAttachmentBytes?: number;
|
|
71
86
|
canReorderChannels?: boolean;
|
|
87
|
+
/** Roles that messages may mention. */
|
|
88
|
+
mentionableRoles?: string[];
|
|
72
89
|
canSendText?: boolean;
|
|
73
90
|
canAttachFiles?: boolean;
|
|
74
91
|
directMessages?: { maxBytes: number; persistent: boolean; offlineDelivery?: boolean; canSend?: boolean };
|
|
@@ -91,19 +108,86 @@ export type MemberRequest =
|
|
|
91
108
|
| { kind: "channel.move"; payload: { channelId: string } & ({ connectionId: string } | { connectionIds: string[] }) }
|
|
92
109
|
| { kind: "moderation.mute"; payload: { connectionId: string; muted: boolean } }
|
|
93
110
|
| { kind: "moderation.deafen"; payload: { connectionId: string; deafened: boolean } }
|
|
94
|
-
| { kind: "moderation.
|
|
95
|
-
| { kind: "
|
|
111
|
+
| { kind: "moderation.ban"; payload: { accountId: string; expiresInSeconds?: number } }
|
|
112
|
+
| { kind: "moderation.kick" | "moderation.unban"; payload: { accountId: string } }
|
|
113
|
+
| { kind: "role.add" | "role.remove"; payload: { accountId: string; role: string } };
|
|
96
114
|
|
|
97
115
|
export interface Message {
|
|
98
116
|
id: string;
|
|
99
117
|
channelId: string | null;
|
|
100
118
|
recipientId?: string | null;
|
|
101
119
|
senderId: string;
|
|
120
|
+
senderName?: string;
|
|
102
121
|
createdAt: number;
|
|
103
122
|
text: string;
|
|
104
123
|
html?: string;
|
|
105
124
|
editedAt?: number | null;
|
|
125
|
+
pinnedAt?: number | null;
|
|
106
126
|
attachment?: { name: string; size: number };
|
|
127
|
+
/** The message this one answers. `missing` once the original is deleted or expires. */
|
|
128
|
+
replyTo?: ReplyPreview | { id: string; missing: true };
|
|
129
|
+
mentions?: MessageMentions;
|
|
130
|
+
/** Present only on stored messages with reactions; `me` reflects the reading account. */
|
|
131
|
+
reactions?: MessageReaction[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface ReplyPreview {
|
|
135
|
+
id: string;
|
|
136
|
+
senderId: string;
|
|
137
|
+
senderName: string;
|
|
138
|
+
/** Up to 120 characters of the original text. */
|
|
139
|
+
text: string;
|
|
140
|
+
attachmentName?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface MessageMentions {
|
|
144
|
+
accounts: string[];
|
|
145
|
+
roles: string[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface MessageReaction {
|
|
149
|
+
emoji: string;
|
|
150
|
+
count: number;
|
|
151
|
+
me: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Sent to each mentioned reader, including those not following the channel. */
|
|
155
|
+
export interface MessageMention {
|
|
156
|
+
channelId: string;
|
|
157
|
+
messageId: string;
|
|
158
|
+
senderId: string;
|
|
159
|
+
senderName: string;
|
|
160
|
+
text: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface ReactionChange {
|
|
164
|
+
channelId: string;
|
|
165
|
+
messageId: string;
|
|
166
|
+
emoji: string;
|
|
167
|
+
count: number;
|
|
168
|
+
accountId: string;
|
|
169
|
+
reacted: boolean;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface PinCursor {
|
|
173
|
+
id: string;
|
|
174
|
+
pinnedAt: number;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface PinnedMessagePage {
|
|
178
|
+
messages: (PinCursor & Pick<Message, "senderId" | "senderName" | "createdAt" | "text"> & { attachmentName: string | null })[];
|
|
179
|
+
next: PinCursor | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface SearchCursor {
|
|
183
|
+
id: string;
|
|
184
|
+
createdAt: number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface MessageSearchPage {
|
|
188
|
+
/** `text` is a preview of up to 240 characters around the first match, with "…" where it was cut. */
|
|
189
|
+
messages: (SearchCursor & Pick<Message, "senderId" | "senderName" | "text"> & { attachmentName: string | null })[];
|
|
190
|
+
next: SearchCursor | null;
|
|
107
191
|
}
|
|
108
192
|
|
|
109
193
|
export interface DirectMessageReference {
|
|
@@ -141,16 +225,27 @@ export interface Poke {
|
|
|
141
225
|
|
|
142
226
|
export type DirectOperation = "direct.peer" | "direct.inbox" | "direct.history" | "direct.send" | "direct.edit" | "direct.delete" | "direct.poke";
|
|
143
227
|
|
|
228
|
+
/** A received typing ping. `channelId` is absent for direct messages; `at` is the receiver's clock. */
|
|
229
|
+
export interface TypingEntry { channelId?: string; accountId: string; displayName: string; at: number }
|
|
230
|
+
/** How long a typing indicator lasts after its most recent ping. */
|
|
231
|
+
export const typingExpiryMs = 6000;
|
|
232
|
+
|
|
144
233
|
export interface VoiceState {
|
|
145
234
|
/** Server origin of the desktop session that produced this state. */
|
|
146
235
|
origin?: string;
|
|
147
236
|
phase: "offline" | "connecting" | "online" | "reconnecting" | "error";
|
|
148
237
|
snapshot: Snapshot | null;
|
|
149
238
|
messages: Message[];
|
|
239
|
+
/** Changes when a channel's stored messages are edited, deleted, pinned or unpinned. */
|
|
240
|
+
messageRevisions?: Record<string, number>;
|
|
150
241
|
directMessages?: DirectMessage[];
|
|
151
242
|
/** A live change to apply to any history the client has already loaded. */
|
|
152
243
|
directChange?: DirectMessageChange;
|
|
153
244
|
lastPoke?: Poke | null;
|
|
245
|
+
/** The latest message that mentioned this account or one of its roles. */
|
|
246
|
+
lastMention?: MessageMention | null;
|
|
247
|
+
/** Recent typing pings from other accounts; filter by `at` against `typingExpiryMs` when showing them. */
|
|
248
|
+
typing?: TypingEntry[];
|
|
154
249
|
speaking: string[];
|
|
155
250
|
voice: "idle" | "active" | "muted" | "deafened" | "error";
|
|
156
251
|
voiceError: string | null;
|
|
@@ -168,6 +263,7 @@ export interface ServerInfo {
|
|
|
168
263
|
profilePictures?: boolean;
|
|
169
264
|
maxAttachmentBytes?: number;
|
|
170
265
|
richChat?: boolean;
|
|
266
|
+
typingIndicators?: boolean;
|
|
171
267
|
maxWebSocketBytes?: number;
|
|
172
268
|
screenSharing?: boolean;
|
|
173
269
|
channelAudioQuality?: boolean;
|