@zextras/carbonio-ws-collaboration-ui-sdk 0.6.0 → 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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as HttpMethod, a as HttpPorts, c as components, W as WireMessage, b as WireInboxEntry, d as WireSystemEvent, e as WireReadMarker, f as WireTimelineMessage, g as WirePresenceStatus, h as WireTimeline } from './asyncapi-DCETfyZY.cjs';
2
- export { F as FetchLike, i as HeadersLike, L as Logger, R as RequestInitLike, j as ResponseLike, V as VersionStore, k as WireInboxMember, l as WireInboxResponse, m as WireInboxRoom, n as WireMessageSearchResult, o as WirePinnedMessage, p as WireTimelineItem } from './asyncapi-DCETfyZY.cjs';
1
+ import { H as HttpMethod, a as HttpPorts, c as components, W as WireMessage, A as AbortSignalLike, b as WireInboxEntry, d as WireSystemEvent, e as WireReadMarker, f as WireTimelineMessage, g as WirePresenceStatus, h as WireTimeline } from './asyncapi-B8fJWyes.cjs';
2
+ export { F as FetchLike, i as HeadersLike, L as Logger, R as RequestInitLike, j as ResponseLike, V as VersionStore, k as WireInboxMember, l as WireInboxResponse, m as WireInboxRoom, n as WireMessageSearchResult, o as WirePinnedMessage, p as WireTimelineItem } from './asyncapi-B8fJWyes.cjs';
3
3
 
4
4
  /**
5
5
  * Per-room FIFO queue for REST writes (send/edit/delete/forward). XMPP
@@ -11,8 +11,12 @@ type WriteQueue = Map<string, Promise<unknown>>;
11
11
 
12
12
  declare const WSC_API_VERSION_HEADER = "X-WSC-API-VERSION";
13
13
  type JsonBody = Record<string, unknown> | Array<unknown>;
14
+ type RequestOptions = {
15
+ /** Aborts the request and rejects with a `TimeoutError` when no response came in time. */
16
+ timeoutMs?: number;
17
+ };
14
18
  type HttpClient = {
15
- request: <T>(endpoint: string, method: HttpMethod, body?: JsonBody) => Promise<T>;
19
+ request: <T>(endpoint: string, method: HttpMethod, body?: JsonBody, options?: RequestOptions) => Promise<T>;
16
20
  };
17
21
  /**
18
22
  * REST core shared by web and mobile. Reproduces the semantics of the two
@@ -20,8 +24,9 @@ type HttpClient = {
20
24
  * 422 retry counter) on top of injected ports:
21
25
  *
22
26
  * - stamps `X-WSC-API-VERSION` with the client's negotiated version;
23
- * - on 422, adopts the server version when it is supported and retries
24
- * (bounded), mirroring the in-production renegotiation;
27
+ * - on 422, adopts the highest supported version not above the server's and
28
+ * retries (bounded), mirroring the in-production renegotiation;
29
+ * - times out a request on demand (`timeoutMs`), aborting its fetch;
25
30
  * - decodes JSON / image blobs, returns the raw response otherwise.
26
31
  */
27
32
  declare function createHttpClient(ports: HttpPorts): HttpClient;
@@ -51,6 +56,7 @@ type StoreAttachment = {
51
56
  };
52
57
  type StoreForwardedInfo = {
53
58
  id: string;
59
+ /** Epoch milliseconds with the microsecond fraction (backend times are microsecond-precise). */
54
60
  date: number;
55
61
  from: string;
56
62
  count: number;
@@ -58,6 +64,7 @@ type StoreForwardedInfo = {
58
64
  type StoreTextMessage = {
59
65
  id: string;
60
66
  roomId: string;
67
+ /** Epoch milliseconds with the microsecond fraction (backend times are microsecond-precise). */
61
68
  date: number;
62
69
  stanzaId: string;
63
70
  type: 'text';
@@ -75,6 +82,7 @@ type StoreTextMessage = {
75
82
  type StoreConfigurationMessage = {
76
83
  id: string;
77
84
  roomId: string;
85
+ /** Epoch milliseconds with the microsecond fraction (backend times are microsecond-precise). */
78
86
  date: number;
79
87
  type: 'configuration';
80
88
  operation: StoreOperationType;
@@ -173,6 +181,14 @@ type StoreBridge = {
173
181
  * panel reads them; `clearSearchResults` stays app-side with the panel).
174
182
  */
175
183
  setSearchResults: (roomId: string, results: Array<StoreTextMessage>) => void;
184
+ /**
185
+ * Sets a stored room's name and description from `GET /inbox`, already resolved against the
186
+ * newest change seen; no-op for a room not stored.
187
+ */
188
+ setRoomFields: (roomId: string, fields: {
189
+ name: string | undefined;
190
+ description: string | undefined;
191
+ }) => void;
176
192
  };
177
193
 
178
194
  type Schemas = components['schemas'];
@@ -180,8 +196,7 @@ type Schemas = components['schemas'];
180
196
  * A chat push event as the SDK handlers take it: the `asyncapi.yaml` schema
181
197
  * (generated, see specs/SPEC_SOURCE.md) without its `type` discriminant. The
182
198
  * apps own the socket and route on their own event-type enum, then hand the
183
- * SDK the event as it came off the wire. `sentDate`, the `WsEvent` envelope's
184
- * send instant, stays in.
199
+ * SDK the event as it came off the wire.
185
200
  */
186
201
  type WirePushEvent<T> = Omit<T, 'type'>;
187
202
  /**
@@ -223,10 +238,13 @@ type WireMessageDeletedEvent = WirePushEvent<Schemas['MessageDeleted']>;
223
238
  */
224
239
  type WireMessageForwardedEvent = WirePushEvent<Schemas['MessageForwarded']>;
225
240
  /**
226
- * `ReactionChanged` push event: a per-user delta (`added` / `removed`), not
227
- * the aggregated state. A user has one reaction per message: replacing it
228
- * emits `removed` then `added`. Sent to the reactor too, and the only
229
- * confirmation path: both reaction endpoints answer 204.
241
+ * `ReactionChanged` push event: a per-user delta (`added` / `updated` /
242
+ * `removed`), not the aggregated state. A user has one reaction per message:
243
+ * replacing it emits one `updated` event. `added` and `updated` carry the
244
+ * stored `updatedAt`, `removed` the `deletedAt` of the delete (`reaction` is
245
+ * the removed emoji): all on the clock the timeline's `users[].updatedAt`
246
+ * uses. Sent to the reactor too, and the only confirmation path: both
247
+ * reaction endpoints answer 204.
230
248
  */
231
249
  type WireReactionChangedEvent = WirePushEvent<Schemas['ReactionChanged']>;
232
250
  /**
@@ -244,12 +262,16 @@ type WireMessageUnpinnedEvent = WirePushEvent<Schemas['MessageUnpinned']>;
244
262
  */
245
263
  type WireRoomCreatedEvent = WirePushEvent<Schemas['RoomCreated']>;
246
264
  /**
247
- * `RoomUpdated` push event. `nameSystemEventId` and `descriptionSystemEventId`
248
- * are present only for the field the update actually changed: the backend
249
- * writes one `ROOM_NAME_CHANGED` or `ROOM_DESCRIPTION_CHANGED` system event
250
- * each, name first.
265
+ * `RoomNameChanged` push event, with the `ROOM_NAME_CHANGED` system event id
266
+ * and creation time. A change of both name and description sends this event
267
+ * first, then `RoomDescriptionChanged`.
251
268
  */
252
- type WireRoomUpdatedEvent = WirePushEvent<Schemas['RoomUpdated']>;
269
+ type WireRoomNameChangedEvent = WirePushEvent<Schemas['RoomNameChanged']>;
270
+ /**
271
+ * `RoomDescriptionChanged` push event, with the `ROOM_DESCRIPTION_CHANGED`
272
+ * system event id and creation time. The description is empty when cleared.
273
+ */
274
+ type WireRoomDescriptionChangedEvent = WirePushEvent<Schemas['RoomDescriptionChanged']>;
253
275
  /** `RoomPictureChanged` push event, with the `ROOM_PICTURE_UPDATED` system event id. */
254
276
  type WireRoomPictureChangedEvent = WirePushEvent<Schemas['RoomPictureChanged']>;
255
277
  /** `RoomPictureDeleted` push event, with the `ROOM_PICTURE_DELETED` system event id. */
@@ -262,8 +284,8 @@ type WireRoomPictureDeletedEvent = WirePushEvent<Schemas['RoomPictureDeleted']>;
262
284
  type WireRoomHistoryClearedEvent = WirePushEvent<Schemas['RoomHistoryCleared']>;
263
285
  /**
264
286
  * `RoomMemberAdded` push event, one per added member. A bulk add writes one
265
- * `MEMBER_ADDED` system event, so every event of the bulk carries the same
266
- * `systemEventId`.
287
+ * `MEMBER_ADDED` system event per added member: each event carries the
288
+ * `systemEventId` of its own row.
267
289
  */
268
290
  type WireRoomMemberAddedEvent = WirePushEvent<Schemas['RoomMemberAdded']>;
269
291
  /**
@@ -288,8 +310,8 @@ type WireMeetingStoppedEvent = WirePushEvent<Schemas['MeetingStopped']>;
288
310
  type WireMeetingDeclinedEvent = WirePushEvent<Schemas['MeetingDeclined']>;
289
311
  /**
290
312
  * `Typing` push event, relayed to every member but the typist. The backend
291
- * normalizes `status` to `started` or `stopped`; its `timestamp` is not
292
- * consumed, the indicator runs on the arrival instant and the expiry timer.
313
+ * normalizes `status` to `started` or `stopped`; the event carries no
314
+ * time, the indicator runs on the arrival instant and the expiry timer.
293
315
  */
294
316
  type WireTypingEvent = WirePushEvent<Schemas['Typing']>;
295
317
  /**
@@ -305,6 +327,48 @@ type MessagesDeps = {
305
327
  bridge: StoreBridge;
306
328
  queue: WriteQueue;
307
329
  };
330
+ type PendingSend = {
331
+ roomId: string;
332
+ tempId: string;
333
+ queued: boolean;
334
+ lane: string;
335
+ backoff: {
336
+ baseMs: number;
337
+ maxMs: number;
338
+ };
339
+ maxConflicts: number;
340
+ attempt: (signal: AbortSignalLike) => Promise<WireMessage>;
341
+ confirm: (response: WireMessage) => StoreMessage | undefined;
342
+ run: () => void;
343
+ resolve: (message: StoreMessage | undefined) => void;
344
+ reject: (error: unknown) => void;
345
+ controller: {
346
+ readonly signal: AbortSignalLike;
347
+ abort: () => void;
348
+ };
349
+ deadline: number;
350
+ state: {
351
+ inFlight: boolean;
352
+ conflicts: number;
353
+ lastError?: unknown;
354
+ deadlineTimer?: unknown;
355
+ detachSignal?: () => void;
356
+ onFirstAttemptSettled?: (outcome: FirstAttemptOutcome) => void;
357
+ };
358
+ placeholder?: StoreMessage;
359
+ };
360
+ type FirstAttemptOutcome = 'confirmed' | 'pending' | 'rejected';
361
+ type SendRetries = {
362
+ sends: Map<string, PendingSend>;
363
+ lanes: Map<string, {
364
+ failures: number;
365
+ timer?: unknown;
366
+ }>;
367
+ };
368
+ declare function createSendRetries(): SendRetries;
369
+ type SendDeps = MessagesDeps & {
370
+ retries: SendRetries;
371
+ };
308
372
  type SendMessageParams = {
309
373
  roomId: string;
310
374
  text: string;
@@ -319,6 +383,30 @@ type SendMessageParams = {
319
383
  */
320
384
  repliedMessage?: StoreTextMessage;
321
385
  };
386
+ type SendAttachmentParams = Omit<ConfirmAttachmentUploadParams, 'response'> & {
387
+ /**
388
+ * One attempt of the app's multipart upload with the placeholder's `tempId`,
389
+ * resolving with its 201; called again with the same `tempId` on every
390
+ * retry. Pass `signal` to the fetch: the SDK aborts it when it gives up.
391
+ * Reject with the HTTP `status`.
392
+ *
393
+ * The SDK sets no timeout on an attempt: bounding it is the app's job (a
394
+ * stall timeout fits files of any size). An attempt that never settles
395
+ * holds back its retries, `retryPendingSends` included, until the upload
396
+ * gives up 50 minutes after the send. Reject a timed-out attempt with an
397
+ * error not named `AbortError` (`AbortSignal.timeout` gives a
398
+ * `TimeoutError`) to have it retried: an `AbortError` is a cancel and gives
399
+ * the upload up.
400
+ */
401
+ upload: (signal: AbortSignalLike) => Promise<WireMessage>;
402
+ /** The caller's cancel: aborting it gives the upload up at once. */
403
+ signal?: AbortSignalLike;
404
+ /**
405
+ * Called once, before the promise handlers, when the first attempt settles:
406
+ * `pending` means retries are scheduled. Never called after `reset()`.
407
+ */
408
+ onFirstAttemptSettled?: (outcome: FirstAttemptOutcome) => void;
409
+ };
322
410
  type ConfirmAttachmentUploadParams = {
323
411
  roomId: string;
324
412
  /** The placeholder's id, sent as the upload's `tempId` form field. */
@@ -330,6 +418,7 @@ type ConfirmAttachmentUploadParams = {
330
418
  /** The quoted message on a reply, resolved from the store like the send's. */
331
419
  repliedMessage?: StoreTextMessage;
332
420
  };
421
+ declare function retryPendingSends(deps: SendDeps): void;
333
422
  /**
334
423
  * `POST /rooms/{roomId}/messages` — one outgoing text message, serialized
335
424
  * through the per-room FIFO write queue (plan §7.4). The optimistic
@@ -338,12 +427,9 @@ type ConfirmAttachmentUploadParams = {
338
427
  * the stanza).
339
428
  *
340
429
  * Confirmation is idempotent from both ways (REST response here, self-echo in
341
- * `handleMessageReceived`). On a definitive send error the placeholder is
342
- * removed — the v1 stanza just vanished leaving an eternal PENDING; the REST
343
- * failure is at least observable (plan §3, minimal proposal) — and the error
344
- * propagates to the façade.
430
+ * `handleMessageReceived`); failures follow the rules of `WscClient.sendMessage`.
345
431
  */
346
- declare function sendMessage({ http, bridge, queue }: MessagesDeps, params: SendMessageParams): Promise<void>;
432
+ declare function sendMessage(deps: SendDeps, params: SendMessageParams): Promise<void>;
347
433
  /**
348
434
  * Confirms an attachment upload from its 201. The apps own the
349
435
  * `POST /rooms/{roomId}/attachments` multipart, whose body is
@@ -360,6 +446,7 @@ declare function sendMessage({ http, bridge, queue }: MessagesDeps, params: Send
360
446
  * the echo like the send's.
361
447
  */
362
448
  declare function confirmAttachmentUpload({ bridge }: MessagesDeps, params: ConfirmAttachmentUploadParams): StoreMessage | undefined;
449
+ declare function sendAttachment(deps: SendDeps, params: SendAttachmentParams): Promise<StoreMessage | undefined>;
363
450
  /**
364
451
  * `MessageReceived` push event — every message of every sender, own echo
365
452
  * included. The SDK performs the store writes shared by all senders; the
@@ -373,9 +460,10 @@ declare function confirmAttachmentUpload({ bridge }: MessagesDeps, params: Confi
373
460
  *
374
461
  * `tempId` promotes the optimistic placeholder. It reaches every member, but
375
462
  * only the sender holds a placeholder under that id: for the others the
376
- * removal is a no-op and the write is a plain append.
463
+ * removal is a no-op and the write is a plain append. For the sender it also
464
+ * confirms the pending send of that tempId and stops its retries.
377
465
  */
378
- declare function handleMessageReceived({ bridge }: MessagesDeps, event: WireMessageReceivedEvent): StoreMessage;
466
+ declare function handleMessageReceived(deps: SendDeps, event: WireMessageReceivedEvent): StoreMessage;
379
467
 
380
468
  type EditMessageParams = {
381
469
  roomId: string;
@@ -450,6 +538,30 @@ declare function forwardMessages({ http, queue }: MessagesDeps, toRoomId: string
450
538
  */
451
539
  declare function handleMessageForwarded({ bridge }: MessagesDeps, event: WireMessageForwardedEvent): StoreMessage;
452
540
 
541
+ type PinOperation = 'messagePinned' | 'messageUnpinned';
542
+
543
+ /**
544
+ * Per room, the time of the last banner write (a pin or unpin event time, or the `pinnedAt` of a
545
+ * `GET /pin` reply) and a count of the banner writes. All times are on the database clock.
546
+ * `fromPage`: the time comes from a pin or unpin line of a timeline page, which writes no banner, so
547
+ * the event or reply of that same change still applies; an empty `GET /pin` reply agrees with an
548
+ * unpin line.
549
+ */
550
+ type PinVersion = {
551
+ time: number;
552
+ writes: number;
553
+ localUnpins?: number;
554
+ fromPage?: PinOperation;
555
+ };
556
+ type PinVersions = Map<string, PinVersion>;
557
+ declare function createPinVersions(): PinVersions;
558
+ type PinDeps = MessagesDeps & {
559
+ pinVersions: PinVersions;
560
+ };
561
+ type PinEventResult = {
562
+ row: StoreConfigurationMessage;
563
+ bannerApplied: boolean;
564
+ };
453
565
  /** Resolves the full pinned message from the caller's store, when loaded. */
454
566
  type FindPinnedMessage = (messageId: string) => StoreTextMessage | undefined;
455
567
  /**
@@ -459,12 +571,6 @@ type FindPinnedMessage = (messageId: string) => StoreTextMessage | undefined;
459
571
  * like the v1 pin IQ that only surfaced through the MUC config broadcast.
460
572
  */
461
573
  declare function pinMessage({ http, queue }: MessagesDeps, roomId: string, messageId: string): Promise<void>;
462
- /**
463
- * `DELETE /rooms/{roomId}/messages/{messageId}/pin` — echo-only like the PUT.
464
- * The v1 façade removed the banner optimistically on unpin (and only on
465
- * unpin): that stays in the app façades, which own the store reads.
466
- */
467
- declare function unpinMessage({ http, queue }: MessagesDeps, roomId: string, messageId: string): Promise<void>;
468
574
  /**
469
575
  * `GET /rooms/{roomId}/pin` — hydrates the room's pinned-message banner (the
470
576
  * v2 replacement for the v1 pin IQ + archive-by-id round-trip). The banner
@@ -477,25 +583,50 @@ declare function unpinMessage({ http, queue }: MessagesDeps, roomId: string, mes
477
583
  * An empty list CLEARS the banner — a deliberate self-healing improvement
478
584
  * over the v1 no-op, which could leave a stale banner after an unpin missed
479
585
  * while offline.
586
+ *
587
+ * The write is skipped when a live pin or unpin touched the banner while the
588
+ * request was in flight and the reply is not newer than it, and always when
589
+ * the user unpinned meanwhile (the reply may predate the unpin, whose echo
590
+ * settles the banner). Known gap: an
591
+ * empty reply followed by a stale late `MessagePinned` cannot be told apart
592
+ * (it would need the unpin time from the backend).
593
+ */
594
+ declare function fetchPinnedMessage({ http, bridge, pinVersions }: PinDeps, roomId: string, findMessage?: FindPinnedMessage): Promise<void>;
595
+ /**
596
+ * `DELETE /rooms/{roomId}/messages/{messageId}/pin` — echo-only like the PUT.
597
+ * The v1 façade removed the banner optimistically on unpin (and only on
598
+ * unpin): that stays in the app façades, which own the store reads. When the
599
+ * DELETE fails, `GET /pin` runs again: the optimistic removal and a reply
600
+ * dropped while the DELETE was in flight would otherwise leave the banner
601
+ * empty for a pin that still exists. `findMessage` resolves the banner of that
602
+ * `GET /pin`, as in `fetchPinnedMessage`.
480
603
  */
481
- declare function fetchPinnedMessage({ http, bridge }: MessagesDeps, roomId: string, findMessage?: FindPinnedMessage): Promise<void>;
604
+ declare function unpinMessage(deps: PinDeps, roomId: string, messageId: string, findMessage?: FindPinnedMessage): Promise<void>;
482
605
  /**
483
606
  * `MessagePinned` push event — every pinner, own echo included (the only
484
607
  * confirmation path). Two v1-parity writes: the configuration row lands in
485
608
  * the timeline, and the banner is set: with the target the caller resolved
486
- * from its store, else with the event's own `message`. Returns the row for
487
- * the router's me/others effects (app events).
609
+ * from its store, else with the event's own `message`. The banner is
610
+ * written only when the event `timestamp` (the system event time, the REST
611
+ * `pinnedAt`) is newer than the room's last banner write: `bannerApplied` is
612
+ * false for a stale event, whose row still lands. Returns the row and that
613
+ * flag for the router's me/others effects (app events).
488
614
  */
489
- declare function handleMessagePinned({ bridge }: MessagesDeps, event: WireMessagePinnedEvent, pinnedMessage?: StoreTextMessage): StoreConfigurationMessage;
615
+ declare function handleMessagePinned({ bridge, pinVersions }: PinDeps, event: WireMessagePinnedEvent, pinnedMessage?: StoreTextMessage): PinEventResult;
490
616
  /**
491
617
  * `MessageUnpinned` push event — configuration row plus banner removal (a
492
618
  * no-op for the unpinner, whose façade already removed it optimistically
493
- * like in v1). The removal is unconditional like the v1 handler. It cannot
494
- * clear a fresh banner: the backend keeps one pin per room and replaces it
495
- * with a lone `MessagePinned`, no `MessageUnpinned` for the old one.
496
- * Returns the row for the router's effects.
619
+ * like in v1). The removal is ordered like the pin by the event `timestamp`:
620
+ * a stale unpin leaves the banner (`bannerApplied` false) and its row still
621
+ * lands. Returns the row and that flag for the router's effects.
497
622
  */
498
- declare function handleMessageUnpinned({ bridge }: MessagesDeps, event: WireMessageUnpinnedEvent): StoreConfigurationMessage;
623
+ declare function handleMessageUnpinned({ bridge, pinVersions }: PinDeps, event: WireMessageUnpinnedEvent): PinEventResult;
624
+ /**
625
+ * A temporary room's history clear also removes its pin. The clear time becomes the banner version,
626
+ * so a pin event older than the clear, delivered late, does not bring the banner back. Returns
627
+ * whether the banner was removed (false when a newer pin was already applied).
628
+ */
629
+ declare function clearPinnedBanner({ bridge, pinVersions }: PinDeps, roomId: string, clearedAt: string): boolean;
499
630
 
500
631
  type SearchDeps = {
501
632
  http: HttpClient;
@@ -508,6 +639,8 @@ type SearchMessagesOptions = {
508
639
  * no load-more), exposed for the future one.
509
640
  */
510
641
  before?: number;
642
+ /** Id of the oldest result of the previous page: with `before` the cursor becomes (createdAt, id). */
643
+ beforeId?: string;
511
644
  /**
512
645
  * Drop results strictly before this instant (ms since epoch) — the v1
513
646
  * MAM `start` bound (`clearedAt ?? createdAt`), inclusive like the
@@ -536,9 +669,129 @@ type SearchMessagesResult = {
536
669
  */
537
670
  declare function searchMessages({ http, bridge }: SearchDeps, roomId: string, query: string, options?: SearchMessagesOptions): Promise<SearchMessagesResult>;
538
671
 
672
+ type SystemLinesDeps = {
673
+ bridge: StoreBridge;
674
+ };
675
+ /**
676
+ * Per room and field (`name`, `description`), the time and value of the newest change seen: a
677
+ * change's `systemEventCreatedAt` or a REST room's `updatedAt`. Two quick changes published by
678
+ * different nodes can arrive inverted: the older one still lands its line, but must not overwrite
679
+ * the newer value.
680
+ */
681
+ type RoomFieldVersions = Map<string, {
682
+ time: number;
683
+ value: string | undefined;
684
+ }>;
685
+ type RoomFieldDeps = SystemLinesDeps & {
686
+ roomFieldVersions: RoomFieldVersions;
687
+ };
688
+ type RoomFieldEventResult = {
689
+ row: StoreConfigurationMessage;
690
+ applied: boolean;
691
+ };
692
+ /**
693
+ * `RoomMemberAdded` push event: lands the `memberAdded` line, whose value is
694
+ * the added member. Returns the row for the router's me/others effects, or
695
+ * undefined when the event announces no line or the line is already in the
696
+ * room. A bulk add writes one line and sends one event for each added member.
697
+ */
698
+ declare function handleRoomMemberAdded({ bridge }: SystemLinesDeps, event: WireRoomMemberAddedEvent): StoreConfigurationMessage | undefined;
699
+ /**
700
+ * `RoomMemberRemoved` push event: lands the `memberRemoved` line, whose value
701
+ * is the removed member. Returns the row, or undefined when the event
702
+ * announces no line (an automatic removal on backends before `ec635ad1`).
703
+ */
704
+ declare function handleRoomMemberRemoved({ bridge }: SystemLinesDeps, event: WireRoomMemberRemovedEvent): StoreConfigurationMessage | undefined;
705
+ /**
706
+ * A room read from REST (`GET /rooms`, `GET /rooms/{id}`) carries `updatedAt`, written by the
707
+ * database clock in the update that changes the name or the description, before that change's line.
708
+ * Returns the name and description to store: the snapshot's when it is newer than the newest change
709
+ * seen (its `updatedAt` becomes the version), otherwise that newer change's value, also when the
710
+ * room was not stored yet.
711
+ */
712
+ declare function resolveRoomSnapshot({ roomFieldVersions }: Pick<RoomFieldDeps, 'roomFieldVersions'>, roomId: string, snapshot: {
713
+ updatedAt: string;
714
+ name?: string;
715
+ description?: string;
716
+ }): {
717
+ name: string | undefined;
718
+ description: string | undefined;
719
+ };
720
+ /**
721
+ * `MeetingStarted` push event: lands the `meetingStarted` line in the
722
+ * meeting's room, which the app resolves from its meetings. Returns the row,
723
+ * or undefined when the room has no line (group meetings).
724
+ */
725
+ declare function handleMeetingStarted({ bridge }: SystemLinesDeps, event: WireMeetingStartedEvent, roomId: string): StoreConfigurationMessage | undefined;
726
+ /**
727
+ * `MeetingStopped` push event: lands the `meetingEnded` line, whose value is
728
+ * the call duration in seconds, `durationSec` (present exactly when
729
+ * `systemEventId` is; an empty value otherwise). Returns the row, or undefined
730
+ * when the room has no line.
731
+ */
732
+ declare function handleMeetingStopped({ bridge }: SystemLinesDeps, event: WireMeetingStoppedEvent, roomId: string): StoreConfigurationMessage | undefined;
733
+ /**
734
+ * `MeetingDeclined` push event: lands the `meetingDeclined` line, authored by
735
+ * the decliner. Returns the row, or undefined when the room has no line.
736
+ */
737
+ declare function handleMeetingDeclined({ bridge }: SystemLinesDeps, event: WireMeetingDeclinedEvent, roomId: string): StoreConfigurationMessage | undefined;
738
+
739
+ /**
740
+ * Latest reaction date applied per `messageId|userId`. Live events and
741
+ * history pages are dated with the same database clock, so anything dated
742
+ * below the stored maximum is a stale state and is never written. Lives as
743
+ * long as the client (it survives a chat registry reset and a reconnection);
744
+ * only `reset()` clears it.
745
+ */
746
+ type ReactionVersions = Map<string, number>;
747
+ type ReactionDeps = {
748
+ http: HttpClient;
749
+ bridge: StoreBridge;
750
+ queue: WriteQueue;
751
+ reactionVersions: ReactionVersions;
752
+ };
753
+ declare function createReactionVersions(): ReactionVersions;
754
+ /**
755
+ * `PUT /rooms/{roomId}/messages/{messageId}/reaction` with `{reaction}` —
756
+ * sets or replaces the user's single reaction on the message. Serialized
757
+ * through the per-room FIFO write queue (plan §7.4). Confirmation is
758
+ * echo-only, like the deletion: the 204 has no body, the store moves on the
759
+ * `ReactionChanged` echo (v1 parity — the reaction stanza confirmed through
760
+ * the MUC echo).
761
+ */
762
+ declare function sendReaction({ http, queue }: ReactionDeps, roomId: string, messageId: string, reaction: string): Promise<void>;
763
+ /**
764
+ * `DELETE /rooms/{roomId}/messages/{messageId}/reaction` — removes the user's
765
+ * reaction on the message, whatever emoji it is. Same queue and echo-only
766
+ * confirmation as `sendReaction`.
767
+ */
768
+ declare function removeReaction({ http, queue }: ReactionDeps, roomId: string, messageId: string): Promise<void>;
769
+ /**
770
+ * `ReactionChanged` push event — every reactor, own echo included (the only
771
+ * confirmation path). One event per write: `added` and `updated` (an emoji
772
+ * replacement, in one event) become a fastening valued with the new
773
+ * `reaction` dated `updatedAt`; `removed` an empty-valued one dated
774
+ * `deletedAt`, which the projection (latest per user by date) reads as "no
775
+ * active reaction" — the v1 semantics verbatim. The id embeds the date:
776
+ * add -> remove -> add again must produce distinct fastenings.
777
+ *
778
+ * Events are ordered per `messageId|userId` by those dates. There is one
779
+ * event per write, so a date equal to the latest applied is the same write
780
+ * delivered twice (or already shown by a history page): it is applied
781
+ * idempotently (same id) but `undefined` is returned, and a date below it is
782
+ * stale and dropped (not written, `undefined`). Only a strictly newer write
783
+ * returns the fastening: the app router owns the me/others effects
784
+ * (animation, browser notification) and must skip them on `undefined`. An
785
+ * event missing the time it needs (`updatedAt` / `deletedAt`) is ignored.
786
+ * No unread bump and no sidebar update: v1 parity.
787
+ */
788
+ declare function handleReactionChanged({ bridge, reactionVersions }: ReactionDeps, event: WireReactionChangedEvent): StoreMessageFastening | undefined;
789
+
539
790
  type TimelineDeps = {
540
791
  http: HttpClient;
541
792
  bridge: StoreBridge;
793
+ reactionVersions: ReactionVersions;
794
+ pinVersions: PinVersions;
542
795
  };
543
796
  type FetchTimelineOptions = {
544
797
  /** Return items strictly older than this instant (ms since epoch) — the v1 MAM `end` bound. */
@@ -644,12 +897,35 @@ type WscClient = {
644
897
  * markers.
645
898
  */
646
899
  handleReadUpdated: (event: WireReadUpdatedEvent) => void;
647
- /** `POST /rooms/{roomId}/messages`: one outgoing text, FIFO-serialized per room. */
900
+ /**
901
+ * `POST /rooms/{roomId}/messages`: one outgoing text, FIFO-serialized per
902
+ * room. Resolves once confirmed (201 or echo). A certain rejection (4xx but
903
+ * 408, 409, 429) removes the placeholder and rejects; any other failure,
904
+ * no answer within 30 s included, keeps it pending and retries the same
905
+ * tempId (2 s to 60 s, at once on `retryPendingSends`) for 50 minutes,
906
+ * then removes it and rejects.
907
+ */
648
908
  sendMessage: (params: SendMessageParams) => Promise<void>;
909
+ /**
910
+ * Attachment upload through the app's multipart (`upload`), confirmed and
911
+ * retried like `sendMessage` but with a 30 s to 10 minutes backoff, and
912
+ * given up at the third 409 in a row (a claim the server left stuck answers
913
+ * 409 for 1 hour: send again with a new tempId); the attempt in flight is
914
+ * aborted when the SDK gives up. Resolves with the confirmed message.
915
+ */
916
+ sendAttachment: (params: SendAttachmentParams) => Promise<StoreMessage | undefined>;
917
+ /**
918
+ * Retries the pending sends and uploads at once, in send order per room,
919
+ * restarting their backoff, after writing back the placeholders missing
920
+ * from the store. Call it on every `WebsocketConnected`, after any store
921
+ * reset of the reconnection.
922
+ */
923
+ retryPendingSends: () => void;
649
924
  /**
650
925
  * `MessageReceived` push event: store writes for every sender, the
651
- * placeholder promoted on `tempId`; returns the mapped message. Quote and
652
- * attachment come from the event's `TimelineMessage`.
926
+ * placeholder promoted on `tempId`, which also confirms the pending send
927
+ * with that tempId; returns the mapped message. Quote and attachment come
928
+ * from the event's `TimelineMessage`.
653
929
  */
654
930
  handleMessageReceived: (event: WireMessageReceivedEvent) => StoreMessage;
655
931
  /**
@@ -677,21 +953,26 @@ type WscClient = {
677
953
  * lastMessage contract as handleMessageEdited.
678
954
  */
679
955
  handleMessageDeleted: (event: WireMessageDeletedEvent, lastMessage?: StoreTextMessage) => void;
680
- /** `POST …/reactions/{reaction}`: FIFO-serialized, echo-confirmed (204 has no body). */
956
+ /**
957
+ * `PUT …/messages/{messageId}/reaction`: sets or replaces the user's single
958
+ * reaction; FIFO-serialized, echo-confirmed (204 has no body).
959
+ */
681
960
  sendReaction: (roomId: string, messageId: string, reaction: string) => Promise<void>;
682
961
  /**
683
- * `DELETE …/reactions/{reaction}` — the caller passes the emoji to remove
684
- * (v1 removed with an empty value; the façade resolves the current one
685
- * from the store).
962
+ * `DELETE …/messages/{messageId}/reaction`: removes the user's reaction,
963
+ * whatever the emoji; FIFO-serialized, echo-confirmed.
686
964
  */
687
- removeReaction: (roomId: string, messageId: string, reaction: string) => Promise<void>;
965
+ removeReaction: (roomId: string, messageId: string) => Promise<void>;
688
966
  /**
689
967
  * `ReactionChanged` push event: synthesizes the per-user reaction
690
968
  * fastening (removals carry an empty value) for every reactor, own echo
691
969
  * included — the only confirmation path. Returns the fastening for the
692
- * app router's me/others effects (animation, browser notification).
970
+ * app router's me/others effects (animation, browser notification), or
971
+ * undefined when the event is not newer than the latest applied for that
972
+ * user and message (a duplicate, applied again idempotently, or stale and
973
+ * dropped): the router must skip its effects.
693
974
  */
694
- handleReactionChanged: (event: WireReactionChangedEvent) => StoreMessageFastening;
975
+ handleReactionChanged: (event: WireReactionChangedEvent) => StoreMessageFastening | undefined;
695
976
  /**
696
977
  * `POST /rooms/{toRoomId}/forward`: one bulk request per destination,
697
978
  * FIFO-serialized on the destination room. Fire-and-forget: the
@@ -706,8 +987,11 @@ type WscClient = {
706
987
  handleMessageForwarded: (event: WireMessageForwardedEvent) => StoreMessage;
707
988
  /** `PUT …/messages/{messageId}/pin`: FIFO-serialized, echo-confirmed (204 has no body). */
708
989
  pinMessage: (roomId: string, messageId: string) => Promise<void>;
709
- /** `DELETE …/messages/{messageId}/pin`: FIFO-serialized, echo-confirmed (204 has no body). */
710
- unpinMessage: (roomId: string, messageId: string) => Promise<void>;
990
+ /**
991
+ * `DELETE …/messages/{messageId}/pin`: FIFO-serialized, echo-confirmed (204 has no body). When
992
+ * it fails, `GET /pin` runs again, with `findMessage` as in `fetchPinnedMessage`.
993
+ */
994
+ unpinMessage: (roomId: string, messageId: string, findMessage?: FindPinnedMessage) => Promise<void>;
711
995
  /**
712
996
  * `GET /rooms/{roomId}/pin`: hydrates the banner with the latest pin —
713
997
  * the full store message when the caller resolves it, the DTO's
@@ -718,14 +1002,22 @@ type WscClient = {
718
1002
  * `MessagePinned` push event: synthesizes the v1 configuration row for
719
1003
  * every pinner (own echo included — the only confirmation path) and sets
720
1004
  * the banner with the target the app resolved from its store, else with the
721
- * event's message. Returns the row for the router's me/others effects.
1005
+ * event's message, both only when the event is newer than the room's last
1006
+ * banner write (`bannerApplied`). Returns the row and that flag for the
1007
+ * router's me/others effects.
722
1008
  */
723
- handleMessagePinned: (event: WireMessagePinnedEvent, pinnedMessage?: StoreTextMessage) => StoreConfigurationMessage;
1009
+ handleMessagePinned: (event: WireMessagePinnedEvent, pinnedMessage?: StoreTextMessage) => PinEventResult;
724
1010
  /**
725
1011
  * `MessageUnpinned` push event: configuration row plus banner removal
726
- * (idempotent over the unpinner's optimistic remove). Returns the row.
1012
+ * (idempotent over the unpinner's optimistic remove), ordered by the event
1013
+ * time like the pin. Returns the row and `bannerApplied`.
727
1014
  */
728
- handleMessageUnpinned: (event: WireMessageUnpinnedEvent) => StoreConfigurationMessage;
1015
+ handleMessageUnpinned: (event: WireMessageUnpinnedEvent) => PinEventResult;
1016
+ /**
1017
+ * A temporary room's history clear removes its pin banner, versioned by `clearedAt`. Returns
1018
+ * false when a newer pin was already applied.
1019
+ */
1020
+ clearPinnedBanner: (roomId: string, clearedAt: string) => boolean;
729
1021
  /**
730
1022
  * `RoomCreated` push event: `GET /rooms/{roomId}/timeline` for the newest
731
1023
  * item, which becomes the new room's last message in the chat list.
@@ -734,7 +1026,7 @@ type WscClient = {
734
1026
  /**
735
1027
  * `RoomMemberAdded` push event: lands the `memberAdded` line in the
736
1028
  * timeline and the chat list. Returns the row, or undefined when the event
737
- * announces no line or a previous event of the same bulk add landed it.
1029
+ * announces no line or the line is already in the room.
738
1030
  */
739
1031
  handleRoomMemberAdded: (event: WireRoomMemberAddedEvent) => StoreConfigurationMessage | undefined;
740
1032
  /**
@@ -743,12 +1035,28 @@ type WscClient = {
743
1035
  */
744
1036
  handleRoomMemberRemoved: (event: WireRoomMemberRemovedEvent) => StoreConfigurationMessage | undefined;
745
1037
  /**
746
- * `RoomUpdated` push event: lands the `roomNameChanged` and
747
- * `roomDescriptionChanged` lines the update wrote, name first. Returns the
748
- * rows, none when the update changed neither field. The app still applies
749
- * the new name and description to the room.
1038
+ * `RoomNameChanged` push event: lands the `roomNameChanged` line. Returns
1039
+ * the row and `applied`; the app applies the new name to the room only
1040
+ * when `applied` is true.
750
1041
  */
751
- handleRoomUpdated: (event: WireRoomUpdatedEvent) => Array<StoreConfigurationMessage>;
1042
+ handleRoomNameChanged: (event: WireRoomNameChangedEvent) => RoomFieldEventResult;
1043
+ /**
1044
+ * A room read from REST: the name and description to store, the snapshot's or a newer change's
1045
+ * already seen (`updatedAt` against the line times).
1046
+ */
1047
+ resolveRoomSnapshot: (roomId: string, snapshot: {
1048
+ updatedAt: string;
1049
+ name?: string;
1050
+ description?: string;
1051
+ }) => {
1052
+ name: string | undefined;
1053
+ description: string | undefined;
1054
+ };
1055
+ /**
1056
+ * `RoomDescriptionChanged` push event: lands the `roomDescriptionChanged`
1057
+ * line. Returns the row and `applied`, as for the name.
1058
+ */
1059
+ handleRoomDescriptionChanged: (event: WireRoomDescriptionChangedEvent) => RoomFieldEventResult;
752
1060
  /**
753
1061
  * `RoomPictureChanged` push event: lands the `roomPictureUpdated` line.
754
1062
  * Returns the row, or undefined when the event announces no line.
@@ -772,11 +1080,11 @@ type WscClient = {
772
1080
  */
773
1081
  handleMeetingStarted: (event: WireMeetingStartedEvent, roomId: string) => StoreConfigurationMessage | undefined;
774
1082
  /**
775
- * `MeetingStopped` push event: lands the `meetingEnded` line, with the call
776
- * duration measured from the meeting's `startedAt` the app knows. Returns
777
- * the row, or undefined when the room has no line.
1083
+ * `MeetingStopped` push event: lands the `meetingEnded` line, with the
1084
+ * event's `durationSec` as value. Returns the row, or undefined when the
1085
+ * room has no line.
778
1086
  */
779
- handleMeetingStopped: (event: WireMeetingStoppedEvent, roomId: string, startedAt?: string) => StoreConfigurationMessage | undefined;
1087
+ handleMeetingStopped: (event: WireMeetingStoppedEvent, roomId: string) => StoreConfigurationMessage | undefined;
780
1088
  /**
781
1089
  * `MeetingDeclined` push event: lands the `meetingDeclined` line. Returns
782
1090
  * the row, or undefined when the room has no line.
@@ -788,6 +1096,12 @@ type WscClient = {
788
1096
  * outbound action stays app-side (the apps own the socket until step 18).
789
1097
  */
790
1098
  handleTyping: (event: WireTypingEvent) => void;
1099
+ /**
1100
+ * Drops the session state: pending sends (left unsettled, their retries,
1101
+ * deadlines and uploads cancelled), the write queue, typing timers, the
1102
+ * presence, reaction, pin and room name/description ordering. Call it on logout or session teardown.
1103
+ */
1104
+ reset: () => void;
791
1105
  };
792
1106
  /**
793
1107
  * Aggregates the per-API client modules behind a single injected-deps entry
@@ -817,25 +1131,10 @@ declare function deleteMessage({ http, queue }: MessagesDeps, roomId: string, me
817
1131
  */
818
1132
  declare function handleMessageDeleted({ bridge }: MessagesDeps, event: WireMessageDeletedEvent, lastMessage?: StoreTextMessage): void;
819
1133
 
820
- type InboxDeps = {
821
- http: HttpClient;
822
- bridge: StoreBridge;
823
- };
824
- /**
825
- * `GET /inbox` — one round-trip carrying, per room: the last message, the
826
- * server-side unread count, every member's read marker and presence.
827
- * Replaces the XMPP boot sequence (XEP-0430 inbox + smart markers + roster).
828
- *
829
- * Write order mirrors the v1 flow: last messages first (`setInboxMessages`),
830
- * then markers (the slice recomputes read statuses), then unread counters,
831
- * then presence.
832
- */
833
- declare function fetchInbox({ http, bridge }: InboxDeps): Promise<void>;
834
-
835
1134
  type PresenceUpdate = {
836
1135
  userId: string;
837
1136
  online: boolean;
838
- /** Milliseconds since epoch; only present for offline users with a known last session. */
1137
+ /** Milliseconds since epoch: the last time the user went offline, absent when never offline; also present while online. */
839
1138
  lastActivity?: number;
840
1139
  };
841
1140
  type MappedInboxEntry = {
@@ -879,17 +1178,30 @@ declare function mapWireMarkerToStoreMarker(marker: WireReadMarker, rows: Readon
879
1178
  */
880
1179
  declare function mapInboxEntry(entry: WireInboxEntry, knownRows?: ReadonlyArray<StoreMessage>): MappedInboxEntry;
881
1180
 
1181
+ /**
1182
+ * Per user, the `(lastActivity, online)` pair of the last presence applied. The backend reads
1183
+ * `lastActivity` in the same transaction as the transition, so the pair totally orders a user's
1184
+ * states (offline@T1 < online@T1 < offline@T2 < online@T2; no `lastActivity` is -infinity).
1185
+ */
1186
+ type PresenceGuard = Map<string, {
1187
+ activity: number;
1188
+ online: number;
1189
+ }>;
1190
+ declare function createPresenceGuard(): PresenceGuard;
882
1191
  type PresenceDeps = {
883
1192
  http: HttpClient;
884
1193
  bridge: StoreBridge;
1194
+ presence: PresenceGuard;
885
1195
  };
886
1196
  /**
887
- * The one presence write rule, shared by the inbox and batch hydrations: the
888
- * online flag always lands, and so does the last activity when present. It is
889
- * the last time the user went offline, returned also while online; the UI
890
- * shows "last seen" only for offline users.
1197
+ * The one presence write rule, shared by the inbox and batch hydrations and the push event: an
1198
+ * update lands unless its `(lastActivity, online)` pair is strictly older than the user's last
1199
+ * applied one: an equal pair writes again (idempotent), which re-hydrates a store the app wiped on
1200
+ * a reconnection while the SDK kept its ordering. The online flag always lands with it, and so
1201
+ * does the last activity when present: the last time the user went offline, returned also while
1202
+ * online; the UI shows "last seen" only for offline users.
891
1203
  */
892
- declare function applyPresenceUpdates(bridge: StoreBridge, updates: Array<PresenceUpdate>): void;
1204
+ declare function applyPresenceUpdates({ bridge, presence }: Pick<PresenceDeps, 'bridge' | 'presence'>, updates: Array<PresenceUpdate>): void;
893
1205
  /**
894
1206
  * `POST /presence/batch` — presence + last activity for N users: the v2
895
1207
  * replacement for the v1 per-contact `jabber:iq:last` queries (the roster
@@ -897,45 +1209,28 @@ declare function applyPresenceUpdates(bridge: StoreBridge, updates: Array<Presen
897
1209
  * sent in chunks of 100, the backend limit (400 above). A failed chunk does not
898
1210
  * stop the next ones: the first error is rethrown once every chunk has run.
899
1211
  */
900
- declare function fetchPresence({ http, bridge }: PresenceDeps, userIds: Array<string>): Promise<void>;
1212
+ declare function fetchPresence(deps: PresenceDeps, userIds: Array<string>): Promise<void>;
901
1213
  /**
902
- * `PresenceChanged` push event: the online flag lands immediately, together
903
- * with `lastActivity` (last time the user went offline, sent on both online
904
- * and offline events, same value as the snapshots) when present. No batch
905
- * refresh is needed. The backend never sends a user their own presence; the
906
- * app routers filter it anyway, like in v1 where it never reached the store.
1214
+ * `PresenceChanged` push event: lands through the same `(lastActivity, online)` ordering as the
1215
+ * snapshots, so a late or inverted event never overwrites a newer state. The backend never sends a
1216
+ * user their own presence; the app routers filter it anyway, like in v1 where it never reached the
1217
+ * store.
907
1218
  */
908
- declare function handlePresenceChanged({ bridge }: PresenceDeps, event: WirePresenceChangedEvent): Promise<void>;
1219
+ declare function handlePresenceChanged(deps: PresenceDeps, event: WirePresenceChangedEvent): Promise<void>;
909
1220
 
910
1221
  /**
911
- * `POST /rooms/{roomId}/messages/{messageId}/reactions/{reaction}` —
912
- * serialized through the per-room FIFO write queue (plan §7.4). Confirmation
913
- * is echo-only, like the deletion: the 204 has no body, the store moves on
914
- * the `ReactionChanged` echo (v1 parity — the reaction stanza confirmed
915
- * through the MUC echo).
916
- */
917
- declare function sendReaction({ http, queue }: MessagesDeps, roomId: string, messageId: string, reaction: string): Promise<void>;
918
- /**
919
- * `DELETE /rooms/{roomId}/messages/{messageId}/reactions/{reaction}` — the
920
- * caller passes the emoji to remove: v1 removed with an empty-valued
921
- * reaction stanza, v2 keys the removal on the specific emoji, so the façade
922
- * resolves the user's current one from the store (the same selector the
923
- * reaction pickers already read).
1222
+ * `GET /inbox` — one round-trip carrying, per room: the last message, the
1223
+ * server-side unread count, every member's read marker and presence.
1224
+ * Replaces the XMPP boot sequence (XEP-0430 inbox + smart markers + roster).
1225
+ *
1226
+ * The room names and descriptions land first, resolved against the newest change seen: the inbox
1227
+ * refresh after a reconnection brings the changes whose events were missed meanwhile.
1228
+ *
1229
+ * Write order mirrors the v1 flow: last messages first (`setInboxMessages`),
1230
+ * then markers (the slice recomputes read statuses), then unread counters,
1231
+ * then presence, ordered like `fetchPresence`'s.
924
1232
  */
925
- declare function removeReaction({ http, queue }: MessagesDeps, roomId: string, messageId: string, reaction: string): Promise<void>;
926
- /**
927
- * `ReactionChanged` push event — every reactor, own echo included (the only
928
- * confirmation path). Reactions are repeatable toggles, so unlike edits the
929
- * fastening id embeds the write instant: add -> remove -> add again must
930
- * produce three distinct fastenings (a deduped id would swallow the re-add),
931
- * exactly like the v1 stanzas that each carried their own archive id. A
932
- * removal is a fastening with an empty value: the projection (latest per
933
- * user by date) reads it as "no active reaction" — the v1 semantics
934
- * verbatim. No unread bump and no sidebar update: v1 parity, the app router
935
- * owns the me/others effects (animation, browser notification). Returns the
936
- * fastening for those effects.
937
- */
938
- declare function handleReactionChanged({ bridge }: MessagesDeps, event: WireReactionChangedEvent): StoreMessageFastening;
1233
+ declare function fetchInbox(deps: PresenceDeps & Pick<RoomFieldDeps, 'roomFieldVersions'>): Promise<void>;
939
1234
 
940
1235
  type ReadDeps = {
941
1236
  http: HttpClient;
@@ -974,45 +1269,6 @@ declare function fetchRoomReadMarkers({ http, bridge }: ReadDeps, roomId: string
974
1269
  */
975
1270
  declare function handleReadUpdated({ bridge }: ReadDeps, event: WireReadUpdatedEvent): void;
976
1271
 
977
- type SystemLinesDeps = {
978
- bridge: StoreBridge;
979
- };
980
- /**
981
- * `RoomMemberAdded` push event: lands the `memberAdded` line, whose value is
982
- * the added member. Returns the row for the router's me/others effects, or
983
- * undefined when the event announces no line or the line is already in the
984
- * room: a bulk add sends one event per member for its single line, which
985
- * lands with the first event, like the timeline that shows the first added
986
- * member.
987
- */
988
- declare function handleRoomMemberAdded({ bridge }: SystemLinesDeps, event: WireRoomMemberAddedEvent): StoreConfigurationMessage | undefined;
989
- /**
990
- * `RoomMemberRemoved` push event: lands the `memberRemoved` line, whose value
991
- * is the removed member. Returns the row, or undefined when the event
992
- * announces no line (an automatic removal on backends before `ec635ad1`).
993
- */
994
- declare function handleRoomMemberRemoved({ bridge }: SystemLinesDeps, event: WireRoomMemberRemovedEvent): StoreConfigurationMessage | undefined;
995
- /**
996
- * `MeetingStarted` push event: lands the `meetingStarted` line in the
997
- * meeting's room, which the app resolves from its meetings. Returns the row,
998
- * or undefined when the room has no line (group meetings).
999
- */
1000
- declare function handleMeetingStarted({ bridge }: SystemLinesDeps, event: WireMeetingStartedEvent, roomId: string): StoreConfigurationMessage | undefined;
1001
- /**
1002
- * `MeetingStopped` push event: lands the `meetingEnded` line, whose value is
1003
- * the call duration in seconds, as in the system event. The event carries
1004
- * none: it is measured from `startedAt`, the start the app knows, to the
1005
- * event's `sentDate`, so it can exceed the backend's by a second until a
1006
- * timeline page replaces the row. Without `startedAt` the line has no
1007
- * duration. Returns the row, or undefined when the room has no line.
1008
- */
1009
- declare function handleMeetingStopped({ bridge }: SystemLinesDeps, event: WireMeetingStoppedEvent, roomId: string, startedAt?: string): StoreConfigurationMessage | undefined;
1010
- /**
1011
- * `MeetingDeclined` push event: lands the `meetingDeclined` line, authored by
1012
- * the decliner. Returns the row, or undefined when the room has no line.
1013
- */
1014
- declare function handleMeetingDeclined({ bridge }: SystemLinesDeps, event: WireMeetingDeclinedEvent, roomId: string): StoreConfigurationMessage | undefined;
1015
-
1016
1272
  /**
1017
1273
  * Safety-net expiry for a typing indicator that never receives its `stopped`
1018
1274
  * (lost event, killed app): the v1 handlers used the same 7s window.
@@ -1063,9 +1319,9 @@ type MappedTimelinePage = {
1063
1319
  /**
1064
1320
  * Reaction fastenings synthesized from the messages' `ReactionGroup[]`
1065
1321
  * (current aggregated state, unlike the v1 MAM which carried the stanza
1066
- * history). Deterministic ids (`r_{messageId}_{userId}_{emoji}`) keep
1067
- * refetches idempotent through the slice dedup; dated 1ms after their
1068
- * message so any live fastening (dated now) wins the projection.
1322
+ * history). Ids (`r_{messageId}_{userId}_{emoji}_{date}`, as the live ones) keep
1323
+ * refetches idempotent through the slice dedup; dated with each user's
1324
+ * reaction `updatedAt`.
1069
1325
  */
1070
1326
  fastenings: Array<StoreMessageFastening>;
1071
1327
  markers: Array<StoreMarker>;
@@ -1101,6 +1357,9 @@ type MappedTimelinePage = {
1101
1357
  */
1102
1358
  declare function mapTimelinePage(page: WireTimeline, roomId: string, notBefore?: number, knownRows?: ReadonlyArray<StoreMessage>): MappedTimelinePage;
1103
1359
 
1360
+ declare function parseIsoMicros(iso: string | undefined): number;
1361
+ declare function toIsoMicros(ms: number): string;
1362
+
1104
1363
  declare class WscApiError extends Error {
1105
1364
  readonly status: number;
1106
1365
  readonly endpoint: string;
@@ -1109,4 +1368,4 @@ declare class WscApiError extends Error {
1109
1368
 
1110
1369
  declare function buildQueryString(params: Record<string, string | number | boolean | undefined | null>): string;
1111
1370
 
1112
- export { type ConfirmAttachmentUploadParams, type EditMessageParams, type FetchTimelineGapOptions, type FetchTimelineOptions, type FindPinnedMessage, type ForwardMessageRef, type HttpClient, HttpMethod, HttpPorts, type JsonBody, type MappedInboxEntry, type MappedTimelinePage, type MessagesDeps, type PresenceDeps, type PresenceUpdate, type ReadDeps, type SearchDeps, type SearchMessagesOptions, type SearchMessagesResult, type SendMessageParams, type StoreAttachment, type StoreBridge, type StoreConfigurationMessage, type StoreFasteningAction, type StoreForwardedInfo, type StoreMarker, type StoreMarkerStatus, type StoreMessage, type StoreMessageFastening, type StoreOperationType, type StoreTextMessage, type SystemLinesDeps, TYPING_EXPIRE_MS, type TimelineDeps, type TypingDeps, type TypingTimers, WSC_API_VERSION_HEADER, WireInboxEntry, type WireMeetingDeclinedEvent, type WireMeetingStartedEvent, type WireMeetingStoppedEvent, WireMessage, type WireMessageDeletedEvent, type WireMessageEditedEvent, type WireMessageForwardedEvent, type WireMessagePinnedEvent, type WireMessageReceivedEvent, type WireMessageUnpinnedEvent, type WirePresenceChangedEvent, WirePresenceStatus, type WireReactionChangedEvent, WireReadMarker, type WireReadUpdatedEvent, type WireRoomCreatedEvent, type WireRoomHistoryClearedEvent, type WireRoomMemberAddedEvent, type WireRoomMemberRemovedEvent, type WireRoomPictureChangedEvent, type WireRoomPictureDeletedEvent, type WireRoomUpdatedEvent, WireSystemEvent, WireTimeline, WireTimelineMessage, type WireTypingEvent, type WireWsErrorEvent, WscApiError, type WscClient, type WscClientDeps, applyPresenceUpdates, buildQueryString, confirmAttachmentUpload, createHttpClient, createTypingTimers, createWscClient, deleteMessage, editMessage, fetchInbox, fetchPinnedMessage, fetchPresence, fetchRoomReadMarkers, fetchTimeline, fetchTimelineGap, forwardMessages, handleMeetingDeclined, handleMeetingStarted, handleMeetingStopped, handleMessageDeleted, handleMessageEdited, handleMessageForwarded, handleMessagePinned, handleMessageReceived, handleMessageUnpinned, handlePresenceChanged, handleReactionChanged, handleReadUpdated, handleRoomMemberAdded, handleRoomMemberRemoved, handleTyping, mapInboxEntry, mapPresenceStatus, mapSearchMessageToStoreMessage, mapSystemEventToStoreMessage, mapTimelinePage, mapWireMarkerToStoreMarker, mapWireMessageToStoreMessage, markAsRead, pinMessage, removeReaction, searchMessages, sendMessage, sendReaction, unpinMessage };
1371
+ export { AbortSignalLike, type ConfirmAttachmentUploadParams, type EditMessageParams, type FetchTimelineGapOptions, type FetchTimelineOptions, type FindPinnedMessage, type FirstAttemptOutcome, type ForwardMessageRef, type HttpClient, HttpMethod, HttpPorts, type JsonBody, type MappedInboxEntry, type MappedTimelinePage, type MessagesDeps, type PinDeps, type PinEventResult, type PinVersions, type PresenceDeps, type PresenceGuard, type PresenceUpdate, type ReactionDeps, type ReactionVersions, type ReadDeps, type RequestOptions, type RoomFieldEventResult, type RoomFieldVersions, type SearchDeps, type SearchMessagesOptions, type SearchMessagesResult, type SendAttachmentParams, type SendDeps, type SendMessageParams, type SendRetries, type StoreAttachment, type StoreBridge, type StoreConfigurationMessage, type StoreFasteningAction, type StoreForwardedInfo, type StoreMarker, type StoreMarkerStatus, type StoreMessage, type StoreMessageFastening, type StoreOperationType, type StoreTextMessage, type SystemLinesDeps, TYPING_EXPIRE_MS, type TimelineDeps, type TypingDeps, type TypingTimers, WSC_API_VERSION_HEADER, WireInboxEntry, type WireMeetingDeclinedEvent, type WireMeetingStartedEvent, type WireMeetingStoppedEvent, WireMessage, type WireMessageDeletedEvent, type WireMessageEditedEvent, type WireMessageForwardedEvent, type WireMessagePinnedEvent, type WireMessageReceivedEvent, type WireMessageUnpinnedEvent, type WirePresenceChangedEvent, WirePresenceStatus, type WireReactionChangedEvent, WireReadMarker, type WireReadUpdatedEvent, type WireRoomCreatedEvent, type WireRoomDescriptionChangedEvent, type WireRoomHistoryClearedEvent, type WireRoomMemberAddedEvent, type WireRoomMemberRemovedEvent, type WireRoomNameChangedEvent, type WireRoomPictureChangedEvent, type WireRoomPictureDeletedEvent, WireSystemEvent, WireTimeline, WireTimelineMessage, type WireTypingEvent, type WireWsErrorEvent, WscApiError, type WscClient, type WscClientDeps, applyPresenceUpdates, buildQueryString, clearPinnedBanner, confirmAttachmentUpload, createHttpClient, createPinVersions, createPresenceGuard, createReactionVersions, createSendRetries, createTypingTimers, createWscClient, deleteMessage, editMessage, fetchInbox, fetchPinnedMessage, fetchPresence, fetchRoomReadMarkers, fetchTimeline, fetchTimelineGap, forwardMessages, handleMeetingDeclined, handleMeetingStarted, handleMeetingStopped, handleMessageDeleted, handleMessageEdited, handleMessageForwarded, handleMessagePinned, handleMessageReceived, handleMessageUnpinned, handlePresenceChanged, handleReactionChanged, handleReadUpdated, handleRoomMemberAdded, handleRoomMemberRemoved, handleTyping, mapInboxEntry, mapPresenceStatus, mapSearchMessageToStoreMessage, mapSystemEventToStoreMessage, mapTimelinePage, mapWireMarkerToStoreMarker, mapWireMessageToStoreMessage, markAsRead, parseIsoMicros, pinMessage, removeReaction, resolveRoomSnapshot, retryPendingSends, searchMessages, sendAttachment, sendMessage, sendReaction, toIsoMicros, unpinMessage };