@wtfalch/chat 0.5.1 → 0.7.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/README.md +101 -17
- package/dist/chat/admin/index.d.ts +5 -0
- package/dist/chat/admin/index.js +10 -0
- package/dist/chat/admin/react.d.ts +22 -1
- package/dist/chat/admin/react.js +115 -1
- package/dist/chat/client.d.ts +15 -7
- package/dist/chat/client.js +755 -81
- package/dist/chat/fake/server.d.ts +94 -3
- package/dist/chat/fake/server.js +505 -26
- package/dist/chat/react/NewDirectMessage.d.ts +5 -5
- package/dist/chat/react/NewDirectMessage.js +5 -5
- package/dist/chat/react/ThreadPanel.js +44 -1
- package/dist/chat/store.d.ts +44 -6
- package/dist/chat/store.js +88 -8
- package/dist/chat/types.d.ts +296 -12
- package/package.json +2 -2
|
@@ -6,6 +6,9 @@ export type FakeRoomSeed = {
|
|
|
6
6
|
isDirect?: boolean;
|
|
7
7
|
/** Seeds `unread_notifications.notification_count`. Defaults to `0`. */
|
|
8
8
|
notificationCount?: number;
|
|
9
|
+
/** Seeds `unread_notifications.highlight_count` -- the subset of
|
|
10
|
+
* `notificationCount` that mentions this account. Defaults to `0`. */
|
|
11
|
+
highlightCount?: number;
|
|
9
12
|
/** An `m.space` rather than a room -- the company space. Its `members`
|
|
10
13
|
* are what `client.people()` reads. Defaults to `false`. */
|
|
11
14
|
isSpace?: boolean;
|
|
@@ -23,6 +26,13 @@ export type FakeRoomSeed = {
|
|
|
23
26
|
* reads to report a room unsearchable (agora#252). Defaults to
|
|
24
27
|
* `false`. */
|
|
25
28
|
encrypted?: boolean;
|
|
29
|
+
/** Seeds an `m.room.power_levels` state event with `events_default: 100`
|
|
30
|
+
* -- the one thing `ChatRoomSummary.archived` and `AdminChannel.archived`
|
|
31
|
+
* both read to report a room's member writes locked. Defaults to
|
|
32
|
+
* `false`, which seeds no such event (an unset `events_default`
|
|
33
|
+
* defaults to `0` in real Matrix, same as the client and admin reads
|
|
34
|
+
* treat it). */
|
|
35
|
+
archived?: boolean;
|
|
26
36
|
/** Seeds this room as an unanswered invitation to the fake account
|
|
27
37
|
* itself, rather than a room it has joined -- a `rooms.invite` entry
|
|
28
38
|
* with the stripped state real Matrix delivers one in, the one shape
|
|
@@ -58,6 +68,11 @@ export type FakeMember = {
|
|
|
58
68
|
userId: string;
|
|
59
69
|
/** Their `m.room.member` display name. Defaults to the user id. */
|
|
60
70
|
name?: string;
|
|
71
|
+
/** Marks this member a guest, carrying `GUEST_MARKER_KEY` on their
|
|
72
|
+
* `m.room.member` content with `{ until: guestUntil }` -- what
|
|
73
|
+
* `client.ts`'s `readGuest` reads into `ChatPerson.guest`. Omitted for
|
|
74
|
+
* an ordinary member. */
|
|
75
|
+
guestUntil?: string;
|
|
61
76
|
};
|
|
62
77
|
export type FakeChatServerOptions = {
|
|
63
78
|
/** Defaults to a distinct `https://chat.<random>.example.test`, so two
|
|
@@ -70,6 +85,11 @@ export type FakeChatServerOptions = {
|
|
|
70
85
|
* which does not care about refresh timing never trips it by accident. */
|
|
71
86
|
tokenLifetimeMs?: number;
|
|
72
87
|
now?: () => number;
|
|
88
|
+
/** Whether `/versions` advertises MSC4133 extended profiles. Defaults to
|
|
89
|
+
* `true`; a test simulating production before
|
|
90
|
+
* wtfalch/foundry#41 turns it on passes `false`, the same "off" every
|
|
91
|
+
* company's Synapse ships with today (`docs/status.md`). */
|
|
92
|
+
extendedProfilesEnabled?: boolean;
|
|
73
93
|
};
|
|
74
94
|
/**
|
|
75
95
|
* A fake exchange endpoint and a fake homeserver, both answered by
|
|
@@ -98,6 +118,20 @@ export declare class FakeChatServer {
|
|
|
98
118
|
* gives a member, which `pinMessage`/`unpinMessage` must reject on
|
|
99
119
|
* rather than resolve quietly. */
|
|
100
120
|
pinStatus: number;
|
|
121
|
+
/** What `PUT .../send/...` answers with -- anything but 200 fails the
|
|
122
|
+
* send, with nothing stored. */
|
|
123
|
+
sendStatus: number;
|
|
124
|
+
/** Holds every thread follow `GET` until it resolves -- for a test of a
|
|
125
|
+
* read that is still in flight when the person clicks. */
|
|
126
|
+
threadFollowReadBarrier: Promise<void> | null;
|
|
127
|
+
/** What a thread follow `GET` answers with. */
|
|
128
|
+
threadFollowReadStatus: number;
|
|
129
|
+
/** Every call to the thread follow route, in arrival order. */
|
|
130
|
+
readonly threadFollowRequests: Array<{
|
|
131
|
+
method: string;
|
|
132
|
+
roomId: string;
|
|
133
|
+
rootId: string;
|
|
134
|
+
}>;
|
|
101
135
|
readonly userId: string;
|
|
102
136
|
/** The Matrix server name, as `userId` gives it -- what an `mxc://`
|
|
103
137
|
* reference from this homeserver names. */
|
|
@@ -149,6 +183,12 @@ export declare class FakeChatServer {
|
|
|
149
183
|
path: string;
|
|
150
184
|
authorised: boolean;
|
|
151
185
|
}>;
|
|
186
|
+
/** Who follows which thread, as `apps/chat-service`'s thread follow
|
|
187
|
+
* route keeps it: `roomId rootId` -> whether the person unfollowed. A
|
|
188
|
+
* thread with no entry is not followed. */
|
|
189
|
+
readonly threadFollows: Map<string, {
|
|
190
|
+
muted: boolean;
|
|
191
|
+
}>;
|
|
152
192
|
/** Every `PUT .../typing/...` this server has answered, in order -- for a
|
|
153
193
|
* test that asserts `sendTyping` actually reached the wire, with what
|
|
154
194
|
* it sent. */
|
|
@@ -174,15 +214,50 @@ export declare class FakeChatServer {
|
|
|
174
214
|
* `sentPresence` would pass against a client that cannot hold anybody
|
|
175
215
|
* away for longer than one poll. */
|
|
176
216
|
readonly syncPresence: Array<string | undefined>;
|
|
217
|
+
/** Every `PUT`/`DELETE` on an MSC4133 extended-profile property this
|
|
218
|
+
* server has answered, in order -- what `ChatClient.setOwnStatus`
|
|
219
|
+
* writes. `value: undefined` records a delete. */
|
|
220
|
+
readonly extendedProfileWrites: Array<{
|
|
221
|
+
userId: string;
|
|
222
|
+
key: string;
|
|
223
|
+
value: unknown;
|
|
224
|
+
}>;
|
|
225
|
+
/** Every `PUT .../sendToDevice/...` this server has answered, in order --
|
|
226
|
+
* what a `CryptoApi` verification request (chat#69) sends on its way
|
|
227
|
+
* out. Recorded rather than delivered to another device: the methods
|
|
228
|
+
* this fake exists for (`getVerificationRequestsToDeviceInProgress`)
|
|
229
|
+
* read the sender's own `OlmMachine` state, which only needs the send to
|
|
230
|
+
* succeed, not to be received. */
|
|
231
|
+
readonly sentToDevice: Array<{
|
|
232
|
+
eventType: string;
|
|
233
|
+
body: unknown;
|
|
234
|
+
}>;
|
|
177
235
|
/** Rooms currently carrying the room-scoped `dont_notify` push rule, for
|
|
178
236
|
* a test that wants to assert on the server's own state rather than
|
|
179
237
|
* only through the client's `rooms()`. */
|
|
180
238
|
get mutedRoomIds(): string[];
|
|
239
|
+
/** Rooms currently carrying MSC2867's marked-unread flag, for a test that
|
|
240
|
+
* wants to assert on the server's own state rather than only through the
|
|
241
|
+
* client's `rooms()`. */
|
|
242
|
+
get markedUnreadRoomIds(): string[];
|
|
181
243
|
constructor(options?: FakeChatServerOptions);
|
|
244
|
+
/** Sets `userId`'s MSC4133 extended-profile `key` directly, for a test
|
|
245
|
+
* simulating "somebody else already has this set on the server" --
|
|
246
|
+
* `ChatClient.status`'s background fetch then reads it exactly as it
|
|
247
|
+
* would a real peer's. Real Matrix never lets a client PUT anyone's
|
|
248
|
+
* profile but its own, which is why this exists as a server-side seed
|
|
249
|
+
* rather than something `setOwnStatus` could reach. */
|
|
250
|
+
seedExtendedProfile(userId: string, key: string, value: unknown): void;
|
|
182
251
|
dispose(): void;
|
|
183
252
|
/** Resolves once a `/sync` request is parked waiting for a test to drive
|
|
184
253
|
* it -- immediately if one already is. */
|
|
185
254
|
waitForParkedPoll(): Promise<void>;
|
|
255
|
+
/** Delivers a parked poll as if another of this account's own devices
|
|
256
|
+
* had just written `type` room account data for `roomId` -- a draft,
|
|
257
|
+
* most likely -- the way a real incremental `/sync` carries a change
|
|
258
|
+
* made from elsewhere. Throws if nothing is parked -- await
|
|
259
|
+
* `waitForParkedPoll()` first. */
|
|
260
|
+
receiveRoomAccountData(roomId: string, type: string, content: Record<string, unknown>): void;
|
|
186
261
|
/** Adds a room and, if a poll is parked, delivers it now. Throws if
|
|
187
262
|
* nothing is parked -- await `waitForParkedPoll()` first. */
|
|
188
263
|
addRoom(seed: FakeRoomSeed): void;
|
|
@@ -202,9 +277,12 @@ export declare class FakeChatServer {
|
|
|
202
277
|
/** Delivers a parked poll as an existing, already-known room receiving
|
|
203
278
|
* one new message from the fake peer -- a timeline event and a bumped
|
|
204
279
|
* notification count together, the way a real incremental `/sync`
|
|
205
|
-
* carries both at once.
|
|
206
|
-
*
|
|
207
|
-
|
|
280
|
+
* carries both at once. `highlightCount` defaults to `0`: an ordinary
|
|
281
|
+
* message that does not mention this account, same as Matrix would
|
|
282
|
+
* report. Pass it to simulate a mention arriving. Returns the minted
|
|
283
|
+
* event id, for a test that then calls `markRoomRead` against it.
|
|
284
|
+
* Throws if nothing is parked. */
|
|
285
|
+
receiveMessage(roomId: string, notificationCount?: number, highlightCount?: number): string;
|
|
208
286
|
/** Delivers a parked poll renaming an already-known room -- an
|
|
209
287
|
* `m.room.name` state event, the way a real incremental `/sync` carries
|
|
210
288
|
* a rename. Throws if nothing is parked. */
|
|
@@ -251,4 +329,17 @@ export declare class FakeChatServer {
|
|
|
251
329
|
* `#route`'s own redact endpoint does and as Synapse does -- a redacted
|
|
252
330
|
* event is still an event. Throws if nothing is parked. */
|
|
253
331
|
receiveRedaction(roomId: string, targetId: string, sender?: string): string;
|
|
332
|
+
/** The device ids that have uploaded `device_keys` so far. */
|
|
333
|
+
uploadedDeviceIds(): string[];
|
|
334
|
+
/** Delivers to-device events (a verification request, say) to the one
|
|
335
|
+
* client this fake serves, on its next `/sync` -- straight away if a poll
|
|
336
|
+
* is parked. Each event is `{ type, sender, content }`. Only one client
|
|
337
|
+
* can be answered at a time: this fake has a single parked poll, so it
|
|
338
|
+
* cannot route a to-device message from one live client to another, and
|
|
339
|
+
* `sendToDevice` writes stay recorded in `sentToDevice` only. */
|
|
340
|
+
deliverToDevice(events: Array<{
|
|
341
|
+
type: string;
|
|
342
|
+
sender: string;
|
|
343
|
+
content: unknown;
|
|
344
|
+
}>): void;
|
|
254
345
|
}
|