korero-chat 0.1.1 → 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/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 };
@@ -93,18 +110,84 @@ export type MemberRequest =
93
110
  | { kind: "moderation.deafen"; payload: { connectionId: string; deafened: boolean } }
94
111
  | { kind: "moderation.ban"; payload: { accountId: string; expiresInSeconds?: number } }
95
112
  | { kind: "moderation.kick" | "moderation.unban"; payload: { accountId: string } }
96
- | { kind: "role.set"; payload: { accountId: string; role: string } };
113
+ | { kind: "role.add" | "role.remove"; payload: { accountId: string; role: string } };
97
114
 
98
115
  export interface Message {
99
116
  id: string;
100
117
  channelId: string | null;
101
118
  recipientId?: string | null;
102
119
  senderId: string;
120
+ senderName?: string;
103
121
  createdAt: number;
104
122
  text: string;
105
123
  html?: string;
106
124
  editedAt?: number | null;
125
+ pinnedAt?: number | null;
107
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;
108
191
  }
109
192
 
110
193
  export interface DirectMessageReference {
@@ -142,16 +225,27 @@ export interface Poke {
142
225
 
143
226
  export type DirectOperation = "direct.peer" | "direct.inbox" | "direct.history" | "direct.send" | "direct.edit" | "direct.delete" | "direct.poke";
144
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
+
145
233
  export interface VoiceState {
146
234
  /** Server origin of the desktop session that produced this state. */
147
235
  origin?: string;
148
236
  phase: "offline" | "connecting" | "online" | "reconnecting" | "error";
149
237
  snapshot: Snapshot | null;
150
238
  messages: Message[];
239
+ /** Changes when a channel's stored messages are edited, deleted, pinned or unpinned. */
240
+ messageRevisions?: Record<string, number>;
151
241
  directMessages?: DirectMessage[];
152
242
  /** A live change to apply to any history the client has already loaded. */
153
243
  directChange?: DirectMessageChange;
154
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[];
155
249
  speaking: string[];
156
250
  voice: "idle" | "active" | "muted" | "deafened" | "error";
157
251
  voiceError: string | null;
@@ -169,6 +263,7 @@ export interface ServerInfo {
169
263
  profilePictures?: boolean;
170
264
  maxAttachmentBytes?: number;
171
265
  richChat?: boolean;
266
+ typingIndicators?: boolean;
172
267
  maxWebSocketBytes?: number;
173
268
  screenSharing?: boolean;
174
269
  channelAudioQuality?: boolean;