stream-chat 10.0.0-rc.21 → 10.0.0-rc.23

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.
Files changed (269) hide show
  1. package/dist/cjs/index.browser.js +2196 -3902
  2. package/dist/cjs/index.browser.js.map +3 -3
  3. package/dist/cjs/index.node.js +2197 -3902
  4. package/dist/cjs/index.node.js.map +3 -3
  5. package/dist/esm/index.mjs +2199 -3905
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +120 -233
  8. package/dist/types/CooldownTimer.d.ts +8 -23
  9. package/dist/types/EventHandlerPipeline.d.ts +17 -37
  10. package/dist/types/LiveLocationManager.d.ts +22 -50
  11. package/dist/types/api-client.d.ts +9 -14
  12. package/dist/types/channel.d.ts +253 -448
  13. package/dist/types/channel_state.d.ts +48 -95
  14. package/dist/types/client.d.ts +245 -370
  15. package/dist/types/client_state.d.ts +1 -3
  16. package/dist/types/configuration/ConfigController.d.ts +30 -124
  17. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
  18. package/dist/types/configuration/keys.d.ts +5 -19
  19. package/dist/types/configuration/shape.d.ts +12 -29
  20. package/dist/types/configuration/types.d.ts +59 -87
  21. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
  22. package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
  23. package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
  24. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
  25. package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
  26. package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
  27. package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
  28. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
  29. package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
  30. package/dist/types/connection/networkConnection/types.d.ts +12 -27
  31. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
  32. package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
  33. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
  34. package/dist/types/connection/wsConnection/config.d.ts +8 -28
  35. package/dist/types/connection/wsConnection/types.d.ts +17 -70
  36. package/dist/types/entityStore/EntityStore.d.ts +153 -113
  37. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
  38. package/dist/types/errors.d.ts +7 -19
  39. package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
  40. package/dist/types/gen/chat/ChatApi.d.ts +28 -14
  41. package/dist/types/gen/models/index.d.ts +769 -86
  42. package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
  43. package/dist/types/index.d.ts +2 -4
  44. package/dist/types/languageNames.d.ts +9 -24
  45. package/dist/types/logger.d.ts +1 -3
  46. package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
  47. package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
  48. package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
  49. package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
  50. package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
  51. package/dist/types/messageComposer/configuration/types.d.ts +29 -56
  52. package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
  53. package/dist/types/messageComposer/messageComposer.d.ts +30 -164
  54. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
  55. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
  56. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
  57. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
  58. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
  59. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
  60. package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
  61. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
  62. package/dist/types/messageComposer/pollComposer.d.ts +8 -4
  63. package/dist/types/messageComposer/textComposer.d.ts +3 -9
  64. package/dist/types/messageComposer/types.d.ts +5 -8
  65. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
  66. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
  67. package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
  68. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
  69. package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
  70. package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
  71. package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
  72. package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
  73. package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
  74. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
  75. package/dist/types/messageOperations/types.d.ts +15 -30
  76. package/dist/types/middleware.d.ts +7 -5
  77. package/dist/types/moderation.d.ts +21 -14
  78. package/dist/types/notifications/NotificationManager.d.ts +8 -31
  79. package/dist/types/notifications/types.d.ts +19 -59
  80. package/dist/types/offline-support/offline_support_api.d.ts +145 -539
  81. package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
  82. package/dist/types/offline-support/queueableOperations.d.ts +24 -52
  83. package/dist/types/offline-support/types.d.ts +24 -187
  84. package/dist/types/pagination/ItemIndex.d.ts +4 -12
  85. package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
  86. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
  87. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
  88. package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
  89. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
  90. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
  91. package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
  92. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
  93. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
  94. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
  95. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
  96. package/dist/types/pagination/sortCompiler.d.ts +11 -22
  97. package/dist/types/pagination/utility.normalization.d.ts +5 -23
  98. package/dist/types/pagination/utility.search.d.ts +3 -8
  99. package/dist/types/poll.d.ts +14 -14
  100. package/dist/types/poll_manager.d.ts +11 -2
  101. package/dist/types/poll_optimistic_votes.d.ts +10 -14
  102. package/dist/types/reminders/Reminder.d.ts +4 -4
  103. package/dist/types/reminders/ReminderManager.d.ts +7 -20
  104. package/dist/types/search/BaseSearchSource.d.ts +7 -12
  105. package/dist/types/search/ChannelSearchSource.d.ts +7 -7
  106. package/dist/types/search/MessageSearchSource.d.ts +7 -9
  107. package/dist/types/search/SearchController.d.ts +17 -22
  108. package/dist/types/search/types.d.ts +6 -10
  109. package/dist/types/signing.d.ts +12 -3
  110. package/dist/types/thread.d.ts +23 -71
  111. package/dist/types/thread_manager.d.ts +45 -70
  112. package/dist/types/token_manager.d.ts +8 -13
  113. package/dist/types/types.d.ts +64 -125
  114. package/dist/types/types.utility.d.ts +3 -3
  115. package/dist/types/upload-utils.d.ts +5 -10
  116. package/dist/types/uploadManager.d.ts +17 -45
  117. package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
  118. package/dist/types/utils/WithSubscriptions.d.ts +5 -15
  119. package/dist/types/utils/concurrency.d.ts +11 -19
  120. package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
  121. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
  122. package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
  123. package/dist/types/utils/objectPath.d.ts +6 -41
  124. package/dist/types/utils/retryable.d.ts +8 -12
  125. package/dist/types/utils/throttling/throttle.d.ts +8 -23
  126. package/dist/types/utils/time.d.ts +24 -64
  127. package/dist/types/utils.d.ts +40 -86
  128. package/package.json +7 -2
  129. package/src/ChannelManager.ts +159 -300
  130. package/src/CooldownTimer.ts +11 -29
  131. package/src/EventHandlerPipeline.ts +21 -44
  132. package/src/LiveLocationManager.ts +35 -74
  133. package/src/api-client.ts +43 -61
  134. package/src/campaign.ts +1 -1
  135. package/src/channel.ts +396 -749
  136. package/src/channel_batch_updater.ts +1 -1
  137. package/src/channel_state.ts +50 -105
  138. package/src/client.ts +360 -588
  139. package/src/client_state.ts +1 -6
  140. package/src/configuration/ConfigController.ts +41 -157
  141. package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
  142. package/src/configuration/index.ts +1 -1
  143. package/src/configuration/keys.ts +13 -32
  144. package/src/configuration/shape.ts +67 -70
  145. package/src/configuration/types.ts +60 -100
  146. package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
  147. package/src/configuration/utils/copyConfigPatch.ts +11 -32
  148. package/src/configuration/utils/declarativeSlices.ts +9 -39
  149. package/src/configuration/utils/deepFreezeConfig.ts +3 -17
  150. package/src/configuration/utils/index.ts +2 -4
  151. package/src/configuration/utils/serverAuthority.ts +20 -68
  152. package/src/connection/ConnectionIdManager.ts +20 -49
  153. package/src/connection/ConnectionRecoveryManager.ts +51 -178
  154. package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
  155. package/src/connection/networkConnection/reporters.ts +9 -36
  156. package/src/connection/networkConnection/types.ts +12 -27
  157. package/src/connection/wsConnection/StableWSConnection.ts +73 -193
  158. package/src/connection/wsConnection/WSConnection.ts +56 -131
  159. package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
  160. package/src/connection/wsConnection/config.ts +13 -48
  161. package/src/connection/wsConnection/types.ts +17 -70
  162. package/src/constants.ts +4 -4
  163. package/src/entityStore/EntityStore.ts +162 -167
  164. package/src/entityStore/StoreBackedItemIndex.ts +14 -47
  165. package/src/errors.ts +7 -19
  166. package/src/formatMessageMemo.ts +3 -9
  167. package/src/gen/chat/ChannelApi.ts +19 -0
  168. package/src/gen/chat/ChatApi.ts +87 -13
  169. package/src/gen/models/index.ts +793 -71
  170. package/src/gen/moderation/ModerationApi.ts +0 -4
  171. package/src/index.ts +10 -14
  172. package/src/languageNames.ts +9 -24
  173. package/src/logger.ts +1 -3
  174. package/src/messageComposer/LocationComposer.ts +7 -23
  175. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
  176. package/src/messageComposer/attachmentIdentity.ts +2 -13
  177. package/src/messageComposer/attachmentManager.ts +17 -63
  178. package/src/messageComposer/attachmentUtils.ts +3 -17
  179. package/src/messageComposer/configuration/configuration.ts +5 -8
  180. package/src/messageComposer/configuration/types.ts +29 -56
  181. package/src/messageComposer/fileUtils.ts +1 -1
  182. package/src/messageComposer/linkPreviewsManager.ts +8 -20
  183. package/src/messageComposer/messageComposer.ts +54 -222
  184. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
  185. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
  186. package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
  187. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
  188. package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
  189. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
  190. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  191. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  192. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  193. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
  194. package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
  195. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  196. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  197. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  198. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  199. package/src/messageComposer/pollComposer.ts +11 -8
  200. package/src/messageComposer/textComposer.ts +9 -59
  201. package/src/messageComposer/types.ts +9 -12
  202. package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
  203. package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
  204. package/src/messageOperations/FailedSendCache.ts +4 -9
  205. package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
  206. package/src/messageOperations/MessageOperations.ts +33 -62
  207. package/src/messageOperations/applyReactionLocally.ts +9 -28
  208. package/src/messageOperations/createMessageOperations.ts +17 -33
  209. package/src/messageOperations/reflectReactionEvent.ts +5 -13
  210. package/src/messageOperations/sendOrdering.ts +4 -7
  211. package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
  212. package/src/messageOperations/types.ts +15 -30
  213. package/src/middleware.ts +7 -10
  214. package/src/moderation.ts +25 -21
  215. package/src/notifications/NotificationManager.ts +11 -35
  216. package/src/notifications/types.ts +19 -59
  217. package/src/offline-support/offline_support_api.ts +178 -608
  218. package/src/offline-support/offline_sync_manager.ts +25 -69
  219. package/src/offline-support/queueableOperations.ts +31 -84
  220. package/src/offline-support/types.ts +25 -188
  221. package/src/pagination/ItemIndex.ts +4 -12
  222. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  223. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
  224. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  225. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
  226. package/src/pagination/filterCompiler.ts +11 -25
  227. package/src/pagination/paginators/BasePaginator.ts +422 -976
  228. package/src/pagination/paginators/ChannelPaginator.ts +130 -190
  229. package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
  230. package/src/pagination/paginators/MessagePaginator.ts +135 -175
  231. package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
  232. package/src/pagination/paginators/ReminderPaginator.ts +12 -15
  233. package/src/pagination/paginators/ThreadPaginator.ts +16 -26
  234. package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
  235. package/src/pagination/paginators/stateThrottling.ts +5 -10
  236. package/src/pagination/sortCompiler.ts +23 -50
  237. package/src/pagination/utility.normalization.ts +8 -30
  238. package/src/pagination/utility.search.ts +4 -11
  239. package/src/poll.ts +19 -19
  240. package/src/poll_manager.ts +16 -20
  241. package/src/poll_optimistic_votes.ts +17 -22
  242. package/src/reminders/Reminder.ts +5 -6
  243. package/src/reminders/ReminderManager.ts +9 -34
  244. package/src/reminders/ReminderTimer.ts +1 -2
  245. package/src/search/BaseSearchSource.ts +14 -29
  246. package/src/search/ChannelSearchSource.ts +8 -8
  247. package/src/search/MessageSearchSource.ts +19 -25
  248. package/src/search/SearchController.ts +18 -24
  249. package/src/search/types.ts +6 -10
  250. package/src/segment.ts +1 -1
  251. package/src/signing.ts +23 -3
  252. package/src/thread.ts +72 -173
  253. package/src/thread_manager.ts +59 -76
  254. package/src/token_manager.ts +11 -21
  255. package/src/types.ts +78 -126
  256. package/src/types.utility.ts +3 -3
  257. package/src/upload-utils.ts +5 -10
  258. package/src/uploadManager.ts +22 -54
  259. package/src/utils/FixedSizeQueueCache.ts +13 -21
  260. package/src/utils/WithSubscriptions.ts +5 -15
  261. package/src/utils/concurrency.ts +16 -55
  262. package/src/utils/mergeWith/mergeWith.ts +10 -13
  263. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  264. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  265. package/src/utils/objectPath.ts +6 -41
  266. package/src/utils/retryable.ts +10 -14
  267. package/src/utils/throttling/throttle.ts +9 -25
  268. package/src/utils/time.ts +26 -66
  269. package/src/utils.ts +72 -128
@@ -1,47 +1,41 @@
1
1
  import type { BasePaginatorConfig, ExecuteQueryReturnValue, Interval, PostQueryReconcileParams } from './BasePaginator';
2
2
  import { type MessagePaginatorOptions as BaseMessagePaginatorOptions, type JumpToMessageOptions, MessageIntervalPaginator, type MessageQueryShape } from './MessageIntervalPaginator';
3
- import type { LocalMessage, TimestampNS } from '../../types';
3
+ import type { LocalMessage, TimestampNS, UserResponse } from '../../types';
4
+ import type { EntityStoreChangeBatch } from '../../entityStore/EntityStore';
4
5
  import { StateStore } from '@stream-io/state-store';
5
6
  export type { JumpToMessageOptions, MergeNewestPageOptions, MessageFocusReason, MessageFocusSignal, MessageFocusSignalState, MessagePaginatorFilter, MessagePaginatorSort, MessagePaginatorState, MessageQueryShape, SeedFirstPageOptions, } from './MessageIntervalPaginator';
6
7
  export { MessageIntervalPaginator } from './MessageIntervalPaginator';
7
8
  /**
8
- * Auxiliary (non-pagination) state for the message paginator: whole-collection aggregates that are
9
- * independent of the active pagination window (the dual of pagination — values over the entire set,
10
- * not a page of it). `lastMessageAt` is effectively `MAX(created_at)` over the channel-relevant
11
- * messages and is the source of truth for channel-list ordering
9
+ * Whole-collection aggregates, independent of the active pagination window. `lastMessageAt` is the
10
+ * max `created_at` over the channel-relevant messages and orders the channel list
12
11
  * (`channel.messagePaginator.lastMessageAt`): seeded from `ChannelResponse.last_message_at`, then
13
12
  * advanced monotonically as newer messages are ingested.
14
13
  */
15
14
  export type MessagePaginatorAggregateState = {
16
15
  /**
17
- * The newest channel-relevant message, for display (e.g. a channel/thread list item's last-message
18
- * preview or latest-reply avatar). A LIVE reference: it advances to a strictly newer message, is
19
- * refreshed in place when that message is edited/soft-deleted/reacted-to, and is recomputed to the
20
- * next newest when it is hard-removed. Respects `shouldAdvanceLastMessage` (skips system messages
21
- * per `skip_last_msg_update_for_system_msgs`, and thread-only replies). `null` until one is ingested.
16
+ * The newest channel-relevant message, for display (last-message preview, latest-reply avatar). A
17
+ * live reference: it advances to a strictly newer message, is refreshed in place on edit,
18
+ * soft-delete or reaction, and is recomputed when hard-removed. Follows `shouldAdvanceLastMessage`
19
+ * (skips system messages per `skip_last_msg_update_for_system_msgs`, and thread-only replies).
20
+ * `null` until one is ingested.
22
21
  *
23
- * Lives here, NOT derived from pagination `state`, so it stays reactive when a WS message lands in
24
- * the head interval while an older window is active — the pagination store only emits when the
25
- * active* interval is impacted (see `BasePaginator.ingestItem`), so a `state`-derived latest would
26
- * go stale in that case.
22
+ * It lives outside pagination `state`, which only emits when the active interval is affected: a
23
+ * message landing in the head interval while an older window is active would go stale there.
27
24
  */
28
25
  lastMessage: LocalMessage | null;
29
26
  /**
30
- * Server-provided `ChannelResponse.last_message_at` floor, for channels whose newest message is not
31
- * loaded (e.g. surfaced by a channel-list query). Kept SEPARATE from {@link lastMessage} so it can
32
- * outrank a stale/absent loaded message for sorting without overwriting the display message. The
33
- * sort key {@link MessagePaginator.lastMessageAt} is derived as the max of the two, so the two can
34
- * never drift out of sync.
27
+ * `ChannelResponse.last_message_at` floor, for channels whose newest message is not loaded. Kept
28
+ * apart from {@link lastMessage} so it can outrank a stale or absent loaded message for sorting
29
+ * without replacing the display message. {@link MessagePaginator.lastMessageAt} is the max of
30
+ * the two.
35
31
  */
36
32
  seededLastMessageAt: TimestampNS | null;
37
33
  };
38
34
  export type MessagePaginatorOptions = BaseMessagePaginatorOptions & {
39
35
  /**
40
- * Controls whether `jumpToTheFirstUnreadMessage()` should prefer the `unreadStateSnapshot`
41
- * state over `channel.state.read[...]`.
42
- *
43
- * - 'snapshot' (default): retrieve the first unread message id from the unreadStateSnapshot state when jumping to the first unread message
44
- * - 'read-state-only': retrieve the last read message id from the channel read state when jumping to the first unread message
36
+ * Where `jumpToTheFirstUnreadMessage()` reads the unread reference from: `'snapshot'`
37
+ * prefers `unreadStateSnapshot`, `'read-state-only'` uses only `channel.state.read[...]`.
38
+ * Defaults to `'snapshot'`.
45
39
  */
46
40
  unreadReferencePolicy?: 'snapshot' | 'read-state-only';
47
41
  };
@@ -49,160 +43,117 @@ export type UnreadSnapshotState = {
49
43
  lastReadAt: TimestampNS | null;
50
44
  unreadCount: number;
51
45
  /**
52
- * Snapshot of the first unread message id for the user.
53
- * This is intentionally decoupled from `channel.state.read[...]` because apps
54
- * may mark the channel read immediately on open, while still wanting to render
55
- * UI indicators that jump to the previously-unread location.
46
+ * First unread message ID. Decoupled from `channel.state.read[...]` because apps may mark the
47
+ * channel read on open yet still want UI that jumps to the previously unread location.
56
48
  */
57
49
  firstUnreadMessageId: string | null;
58
- /**
59
- * Snapshot of the last read message id for the user (fallback when first unread
60
- * is not known).
61
- */
50
+ /** Last read message ID, a fallback when the first unread is unknown. */
62
51
  lastReadMessageId: string | null;
63
52
  };
64
53
  /**
65
- * External, UI-driven signal: `true` while the user is actively viewing the latest messages of
66
- * this collection (app foregrounded AND the newest message on screen). The owning SDK sets it — the
67
- * state layer has no viewport. When live, an incoming message is NOT counted as unread (the count /
68
- * snapshot bump is skipped), so the "N new" separator/banner never flash for a message the user is
69
- * already looking at. Defaults to `false` (assume not viewing until the SDK proves otherwise).
54
+ * Set by the owning SDK (the state layer has no viewport): `true` while the user views the latest
55
+ * messages (app foregrounded and newest message on screen). While live, an incoming message does
56
+ * not bump the unread count or snapshot. Defaults to `false`.
70
57
  */
71
58
  export type LiveViewState = {
72
59
  isViewingLive: boolean;
73
60
  };
74
61
  /**
75
- * MessagePaginator extends {@link MessageIntervalPaginator} with the unread/live-view concern:
76
- * an independent unread reference snapshot, the UI-driven "viewing the latest messages" signal, and
77
- * the "jump to first unread" navigation built on top of them.
62
+ * Adds the unread snapshot, the UI-driven live-view signal and "jump to first unread" navigation to
63
+ * {@link MessageIntervalPaginator}.
78
64
  */
79
65
  export declare class MessagePaginator extends MessageIntervalPaginator {
80
66
  protected get holderName(): string;
81
67
  private unreadReferencePolicy;
82
68
  /**
83
- * Independent unread reference state (not tied to `channel.state.read`).
84
- * Consumers may set this right before calling markRead / when opening a channel.
69
+ * Unread reference state, independent of `channel.state.read`. Seeded on each first page;
70
+ * consumers may also set it before `markRead`.
85
71
  */
86
72
  readonly unreadStateSnapshot: StateStore<UnreadSnapshotState>;
87
73
  /**
88
- * UI-driven "viewing the latest messages" signal (see {@link LiveViewState}). Set by the SDK via
89
- * {@link setViewingLive}; read by the channel to gate the unread bump on `message.new`. Subscribe to
90
- * this store for reactivity, or read the current boolean directly via the {@link isViewingLive} getter.
74
+ * The "viewing the latest messages" signal ({@link LiveViewState}), set via {@link setViewingLive}
75
+ * and read by the channel to gate the unread bump on `message.new`.
91
76
  */
92
77
  readonly liveViewState: StateStore<LiveViewState>;
93
78
  /**
94
- * Auxiliary (non-pagination) state — see {@link MessagePaginatorAggregateState}. A store separate
95
- * from `state` so `lastMessageAt` can be advanced from inside a `state.next` updater
96
- * (`ingestPage`) without being clobbered, and so consumers subscribe to a quiet signal that only
97
- * emits when the aggregate actually changes (not on every scroll/pagination emission). This is
98
- * distinct from the base's `intervalViews` interval-projection store.
79
+ * {@link MessagePaginatorAggregateState}, in a store apart from `state` so `lastMessageAt` can
80
+ * advance from inside a `state.next` updater (`ingestPage`) and subscribers only see aggregate
81
+ * changes.
99
82
  */
100
83
  readonly aggregateState: StateStore<MessagePaginatorAggregateState>;
101
84
  constructor({ unreadReferencePolicy, ...options }: MessagePaginatorOptions, builtInDefaults?: Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>);
102
85
  /**
103
86
  * Channel-list sort key: the later of the newest loaded message's `created_at` and the server seed.
104
- * **Derived** (never stored) so it cannot drift from {@link lastMessage}. `null` until seeded or a
105
- * message is ingested.
87
+ * Derived, so it cannot drift from {@link lastMessage}. `null` until seeded or a message arrives.
106
88
  */
107
89
  get lastMessageAt(): TimestampNS | null;
108
90
  /**
109
- * The newest channel-relevant message (the monotonic tracked latest), for display. Convenience read
110
- * of {@link aggregateState}; subscribe to `aggregateState` for reactivity. `null` until a message is
111
- * ingested (a server-only seed advances {@link lastMessageAt} but leaves this `null`).
91
+ * The tracked newest channel-relevant message ({@link aggregateState}), for display. `null` until
92
+ * one is ingested (a server-only seed advances {@link lastMessageAt} but not this).
112
93
  */
113
94
  get lastMessage(): LocalMessage | null;
114
95
  /**
115
- * The main channel list's notion of "latest message" for `channel.state.last_message_at`: on top of
116
- * the base rule (not shadowed) this excludes thread-only replies (a reply with a `parent_id` that is
117
- * not shown in the channel is not part of the channel list) and, when the channel is configured with
118
- * `skip_last_msg_update_for_system_msgs`, system messages. Mirrors the legacy
119
- * `Channel._trackLastMessage` skip logic.
120
- *
121
- * These exclusions are specific to the MAIN channel list. A reply list (thread paginator, which has
122
- * a `parentMessageId`) is made ENTIRELY of thread replies — there the newest reply is exactly the
123
- * "latest message", so the exclusions are skipped and only the base rule applies.
96
+ * Whether `message` may become the "latest message" behind `channel.state.last_message_at`: not
97
+ * shadowed and, in the main list, not a thread-only reply nor (with
98
+ * `skip_last_msg_update_for_system_msgs`) a system message. A reply list (`parentMessageId` set)
99
+ * holds only thread replies, so only the shadow rule applies there.
124
100
  */
125
101
  protected shouldAdvanceLastMessage(message: LocalMessage): boolean;
126
102
  /**
127
- * Monotonically advance {@link lastMessageAt} to `message.created_at` when it is newer than the
128
- * current value and {@link shouldAdvanceLastMessage} permits it. Writes the dedicated
129
- * {@link aggregateState} store (not `state`), so it is safe to call from inside a `state.next`
130
- * updater (`ingestPage`). Returns `true` when the value moved.
131
- *
132
- * Called internally on ingest; also public for callers that advance the aggregate without a normal
133
- * in-window ingest — e.g. offline pending-message replay, where the sent message has not yet been
134
- * ingested via the `message.new` event.
103
+ * Advances the tracked latest message (and so {@link lastMessageAt}) to `message` when it is newer
104
+ * and {@link shouldAdvanceLastMessage} permits. Writes {@link aggregateState} only, so it is safe
105
+ * inside a `state.next` updater (`ingestPage`). Returns `true` when the value moved. Public for
106
+ * callers that advance it without an in-window ingest, e.g. offline pending-message replay.
135
107
  */
136
108
  trackLastMessage(message: LocalMessage): boolean;
137
109
  /**
138
- * Seed {@link lastMessageAt} from the server-provided `ChannelResponse.last_message_at`, the
139
- * authoritative whole-channel aggregate. Monotonic: a no-op when the paginator already advanced
140
- * past it (e.g. from ingested messages), so seed order does not matter.
110
+ * Seeds {@link lastMessageAt} from `ChannelResponse.last_message_at`. Monotonic: a value not newer
111
+ * than the current seed is ignored, so seed order does not matter.
141
112
  */
142
113
  seedLastMessageAt(value: TimestampNS | null | undefined): void;
143
114
  ingestItem(item: LocalMessage): boolean;
144
115
  ingestPage(params: Parameters<MessageIntervalPaginator['ingestPage']>[0]): Interval | null;
116
+ onEntitiesChanged(batch: EntityStoreChangeBatch): void;
117
+ reflectUserUpdate(user: UserResponse): void;
145
118
  removeItem(params: Parameters<MessageIntervalPaginator['removeItem']>[0]): ReturnType<MessageIntervalPaginator['removeItem']>;
119
+ truncate(params: Parameters<MessageIntervalPaginator['truncate']>[0]): void;
146
120
  /**
147
- * The still-loaded message with the greatest `created_at` that passes
148
- * {@link shouldAdvanceLastMessage} (skips system / thread-only per config), from the newest-loaded
149
- * window. Used to recompute the tracked latest after the current one is removed. `null` when nothing
150
- * loaded qualifies.
151
- *
152
- * "Latest" is defined by `created_at` (matching {@link trackLastMessage}), NOT by the paginator's
153
- * display order — so this compares timestamps rather than assuming a position, and stays correct
154
- * whatever `itemOrder` / `requestSort` are configured to.
121
+ * The message in `headItems` with the greatest `created_at` that passes
122
+ * {@link shouldAdvanceLastMessage}, or `null`. It compares timestamps rather than positions, so it
123
+ * holds for any `itemOrder` / `requestSort`.
155
124
  */
156
125
  private recomputeLastMessage;
157
126
  /**
158
- * (Re)seed the unread state snapshot from the current own read state.
159
- *
160
- * Called after the first-page query, and can be called again by the SDK whenever a channel is
161
- * (re)opened from a cached paginator — where no fresh first-page query runs — so the snapshot
162
- * reflects the CURRENT read boundary rather than one frozen at the very first open. Without a
163
- * re-seed the separator position, unread count and "jump to first unread" target all go stale
164
- * across reopens.
127
+ * (Re)seeds the unread snapshot from the own read state. Runs after the first-page query, and the
128
+ * SDK calls it again when a channel is reopened from a cached paginator (no first-page query), so
129
+ * the separator, unread count and jump target follow the current read boundary.
165
130
  *
166
- * `firstUnreadMessageId` is intentionally reset to `null`: it represents an EXPLICIT mark-unread
167
- * (set by `notification.mark_unread`), not a live/computed boundary. Persisting a computed value
168
- * here would make the channel look explicitly marked-unread and suppress auto-mark-read.
131
+ * `firstUnreadMessageId` is reset to `null`: it holds only an explicit mark-unread
132
+ * (`notification.mark_unread`), and a computed value would suppress auto-mark-read.
169
133
  */
170
134
  seedUnreadSnapshot: () => void;
171
- /**
172
- * Invokes super.postQueryReconcile() and takes an unread state snapshot on the first-page query.
173
- * The snapshot has to be taken immediately after the query as the viewed channel is marked read
174
- * immediately after opening it. The snapshot can be used to display unread UI indicators.
175
- */
135
+ /** Also seeds the unread snapshot on a first page, before the opened channel is marked read. */
176
136
  postQueryReconcile(params: PostQueryReconcileParams<LocalMessage, MessageQueryShape>): ExecuteQueryReturnValue<LocalMessage>;
177
137
  /**
178
- * Jumps to the unread reference message.
179
- *
180
- * IMPORTANT: This intentionally does *not* rely on `channel.state.read[ownUserId]` only,
181
- * because apps may mark a channel read immediately after opening it, while still
182
- * wanting to keep "jump to unread" UI indicators alive (based on a snapshot).
138
+ * Jumps to the unread reference message. It does not rely on `channel.state.read` alone, since
139
+ * apps may mark a channel read on open yet keep "jump to unread" UI alive from the snapshot.
183
140
  *
184
141
  * Resolution order:
185
- * 1) explicit first-unread id from snapshot/read-state (mark-unread) — jump straight to it
186
- * 2) last-read timestamp: infer the FIRST UNREAD message from it — using the already-loaded
187
- * window when it straddles the boundary, otherwise a `created_at_around` query — and jump there
188
- * 3) last read id from snapshot/read-state (last-resort fallback when no timestamp is available)
142
+ * 1. an explicit first-unread ID (snapshot or read state): jump to it;
143
+ * 2. the last-read timestamp: infer the first unread message from the loaded window, or from a
144
+ * `created_at_around` query when the window does not straddle the boundary, and jump to it;
145
+ * 3. the last-read ID, when no timestamp is known.
189
146
  *
190
- * The timestamp inference (2) is preferred over jumping to the last-read id so that the jump lands
191
- * ON (and highlights) the first unread message rather than the last read one. The last-read id is
192
- * only used as a fallback when we cannot infer an unread boundary. The inference is NOT persisted
193
- * back into the snapshot (that is reserved for explicit mark-unread).
147
+ * The inference is not written to the snapshot: `firstUnreadMessageId` is reserved for an explicit
148
+ * mark-unread (it would suppress auto-mark-read).
194
149
  */
195
150
  jumpToTheFirstUnreadMessage: (options?: JumpToMessageOptions) => Promise<boolean>;
196
151
  setUnreadSnapshot: (next: Partial<UnreadSnapshotState>) => UnreadSnapshotState;
152
+ get isViewingLive(): boolean;
197
153
  /**
198
- * Set the UI-driven "viewing the latest messages" signal (see {@link LiveViewState}). Called by
199
- * the SDK from its message-list viewability + app-state tracking. No-ops when unchanged.
200
- *
201
- * Intentionally NOT reset by `clearStateAndCache` — it is an external input owned by the SDK, not
202
- * derived pagination state.
154
+ * Sets the live-view signal ({@link LiveViewState}). Not reset by `clearStateAndCache`: it is an
155
+ * external input owned by the SDK.
203
156
  */
204
- /** Current "viewing the latest messages" boolean (convenience read of {@link liveViewState}). */
205
- get isViewingLive(): boolean;
206
157
  setViewingLive: (isViewingLive: boolean) => void;
207
158
  clearUnreadSnapshot: () => void;
208
159
  clearStateAndCache(): void;
@@ -14,40 +14,21 @@ export type PinnedMessagePaginatorOptions = {
14
14
  paginatorOptions?: PaginatorOptions<LocalMessage, MessageQueryShape>;
15
15
  };
16
16
  /**
17
- * Pinned-message list paginator.
17
+ * The channel's pinned messages, ordered by `pinned_at` ascending (oldest-pinned first). Extends
18
+ * {@link MessageIntervalPaginator} rather than {@link MessagePaginator}: pinned messages are a subset
19
+ * of the channel and take no part in read/unread or delivery-receipt tracking.
18
20
  *
19
- * Extends the unread-free {@link MessageIntervalPaginator} base — pinned messages are a subset of
20
- * the channel and MUST NOT participate in read/unread or delivery-receipt tracking (that belongs to
21
- * the channel and thread message timelines). By extending the base rather than {@link MessagePaginator}
22
- * it simply never gets the unread surface.
23
- *
24
- * Differences from the main list:
25
- * - fetches from the `/pinned_messages` endpoint (`channel.getPinnedMessages`) rather than
26
- * `channel.query({ messages })`;
27
- * - includes only pinned, non-shadowed messages (`shouldIncludeMessageInInterval`), and filters on
28
- * `{ cid, pinned: true }` so `ingestItem` auto-adds on pin and auto-removes on unpin;
29
- * - orders by `pinned_at` ascending (oldest-pinned first), matching the legacy
30
- * `channel.state.pinnedMessages` order.
31
- *
32
- * Navigation (`jumpToMessage` / `jumpToTheLatestMessage`) is inherited and meaningful — the endpoint
33
- * supports `id_around` — but no unread-coupled navigation exists.
21
+ * Fetches through `channel.getPinnedMessages`, includes only pinned, non-shadowed messages and
22
+ * matches `{ cid, pinned: true }`, so `ingestItem` adds on pin and removes on unpin.
34
23
  */
35
24
  export declare class PinnedMessagePaginator extends MessageIntervalPaginator {
36
25
  protected get holderName(): string;
37
26
  constructor({ channel, id, itemIndex, paginatorOptions, }: PinnedMessagePaginatorOptions);
38
- /**
39
- * Memoized for the reason {@link MessageIntervalPaginator}'s overlay is: the base derivation folds
40
- * this in and skips the publish when nothing moved, which needs stable references. Both close over
41
- * `this` and over a fixed `pinned_at` sort, so there is nothing to rebuild.
42
- */
27
+ /** Memoized: stable references let the base derivation skip a publish when nothing moved. */
43
28
  private pinnedBehaviour?;
44
29
  private buildPinnedBehaviour;
45
30
  private pinnedTiebreaker;
46
- /**
47
- * The ordering and request behaviour that makes this a *pinned*-message paginator, contributed to the
48
- * base derivation so a re-derivation cannot drop it and does not need a second write to restore it.
49
- * Spread over the interval overlay, so this class's `pinned_at` comparator wins.
50
- */
31
+ /** Adds the pinned ordering and request behaviour to the derivation, over the interval overlay. */
51
32
  protected getBehaviourOverrides(): Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>;
52
33
  private installPinnedMessageBehaviour;
53
34
  buildMatchFilters: () => PinnedMessagePaginatorFilter;
@@ -13,7 +13,7 @@ export declare class ReminderPaginator extends BasePaginator<ReminderResponseDat
13
13
  constructor(client: StreamChat, options?: PaginatorOptions<ReminderResponseData, QueryRemindersRequest>);
14
14
  getItemId(item: ReminderResponseData): string;
15
15
  private buildSortComparator;
16
- protected getNextQueryShape({ direction, }: Required<Pick<PaginationQueryParams<QueryRemindersRequest>, 'direction'>>): QueryRemindersRequest;
17
- query: ({ queryShape, }: PaginationQueryParams<QueryRemindersRequest>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
16
+ protected getNextQueryShape(): QueryRemindersRequest;
17
+ query: ({ direction, queryShape, }: PaginationQueryParams<QueryRemindersRequest>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
18
18
  filterQueryResults: (items: ReminderResponseData[]) => ReminderResponseData[];
19
19
  }
@@ -5,53 +5,45 @@ import { EntityStore } from '../../entityStore/EntityStore';
5
5
  import type { Thread } from '../../thread';
6
6
  import type { QueryThreadsRequest } from '../../types';
7
7
  export declare const DEFAULT_THREAD_PAGE_SIZE = 25;
8
- /** Per-page query options the thread list has always requested. */
8
+ /** Default query options for every page of the thread list. */
9
9
  export declare const DEFAULT_THREAD_QUERY: QueryThreadsRequest;
10
10
  export type ThreadPaginatorOptions = {
11
11
  client: StreamChat;
12
- /** The store the list holds its threads in (`client.threads`' thread store). Omitted, it keeps a private one. */
12
+ /** Store holding the list's threads (`client.threads`' thread store). Omitted: a private one. */
13
13
  store?: EntityStore<Thread>;
14
14
  paginatorOptions?: PaginatorOptions<Thread, QueryThreadsRequest>;
15
15
  };
16
16
  /**
17
- * The thread list, in the order `queryThreads` returns it.
18
- *
19
- * There is deliberately no client-side sort. The server's default order (unread first, then by
20
- * latest reply) reads state a `Thread` mutates in place, so a comparator over it would corrupt the
21
- * interval storage on every mark-read or reply. Pages append in server order and a reload replaces
22
- * the list ({@link ThreadPaginator.reload}).
17
+ * The thread list, in the order `queryThreads` returns it. There is no client-side sort: the server
18
+ * order (unread first, then latest reply) depends on state a `Thread` mutates in place, so a
19
+ * comparator would corrupt interval storage. Pages append in server order and
20
+ * {@link ThreadPaginator.reload} replaces the list.
23
21
  */
24
22
  export declare class ThreadPaginator extends BasePaginator<Thread, QueryThreadsRequest> {
25
23
  private readonly client;
26
24
  private readonly store;
27
25
  constructor({ client, store, paginatorOptions, }: ThreadPaginatorOptions);
28
- /**
29
- * No next page until a load has landed (`master`'s `nextCursor: null`), so `toTail()` is a no-op
30
- * before the first successful reload, e.g. when an empty list fires `onEndReached` on mount.
31
- */
26
+ /** No next page until a load has landed, so `toTail()` is a no-op before the first reload. */
32
27
  get initialState(): PaginatorState<Thread>;
33
28
  getItemId(thread: Thread): string;
34
29
  protected getNextQueryShape({ direction, }: Required<Pick<PaginationQueryParams<QueryThreadsRequest>, 'direction'>>): QueryThreadsRequest;
35
30
  query: ({ queryShape, }: PaginationQueryParams<QueryThreadsRequest>) => Promise<PaginationQueryReturnValue<Thread>>;
36
31
  /**
37
- * The stored instance for a queried thread, so there's one per id. The index upserts, so a second
38
- * instance would replace the stored one. A stale stored thread is refreshed from the query, unless
39
- * it's open (active) at which point it reloads itself and this would replace the replies on screen.
32
+ * Keeps one instance per ID (the index upserts, so a second one would replace the stored one). A
33
+ * stale stored thread is hydrated from the query unless it is active: it reloads itself, and
34
+ * hydrating would replace the replies on screen.
40
35
  */
41
36
  private toStoredInstance;
42
37
  filterQueryResults: (threads: Thread[]) => Thread[];
43
38
  /**
44
- * Re-queries the first page and swaps the list in place, in server order; also the first load. The
45
- * current threads stay until the response lands, and a failed query leaves them untouched and
46
- * records `lastQueryError`; a successful one clears it. Like any paginator, the first load publishes
47
- * `isLoading`; a reload of a loaded list does not, since `isLoading` with items means the next page.
39
+ * Re-queries the first page and replaces the list in server order; also the first load. The
40
+ * current threads stay until the response lands. A failed query leaves them and records
41
+ * `lastQueryError`; a success clears it. Only the first load publishes `isLoading` (with items it
42
+ * would mean the next page).
48
43
  */
49
44
  reload: ({ limit }?: {
50
45
  limit?: number;
51
46
  }) => Promise<void>;
52
- /**
53
- * Also releases the list's hold on its threads, which the base reset leaves in the index. Released
54
- * before the base publishes, so a subscriber sees the threads already gone from the registry.
55
- */
47
+ /** Also clears the item index (the base reset keeps it), before the base publishes. */
56
48
  resetState(): void;
57
49
  }
@@ -3,12 +3,8 @@ import type { PaginationQueryParams, PaginationQueryReturnValue, PaginatorOption
3
3
  import type { ListUserGroupsOptions, UserGroupResponse } from '../../types';
4
4
  import type { StreamChat } from '../../client';
5
5
  /**
6
- * Paginates user-group listing through `/usergroups`.
7
- *
8
- * This entity only supports forward (tailward) cursor pagination via
9
- * `created_at_gt` and `id_gt`. Backward (headward) pagination is not available
10
- * because the API does not expose a backward cursor, so the headward cursor is
11
- * initialized as exhausted (`null`).
6
+ * Paginates `/usergroups` forward (tailward) only, via `created_at_gt` and `id_gt`. The API has no
7
+ * backward cursor, so the headward cursor starts exhausted (`null`).
12
8
  */
13
9
  export declare class UserGroupPaginator extends BasePaginator<UserGroupResponse, ListUserGroupsOptions> {
14
10
  private client;
@@ -5,42 +5,31 @@ export type ItemLocation = {
5
5
  insertionIndex: number;
6
6
  };
7
7
  /**
8
- * Generic binary-search + plateau lookup over an abstract sorted array.
9
- *
10
- * The array is represented by:
11
- * - its length
12
- * - a getter `getItemAt(index)` that returns the item (or undefined)
13
- *
14
- * It returns:
15
- * - current: actual index of the item in the array
16
- * - expected: lower-bound position where the item belongs according to compare function
8
+ * Binary search over an abstract sorted array. Returns the needle's `currentIndex` (`-1` if absent)
9
+ * and the `insertionIndex` where `compare` places it (after items that compare equal). With
10
+ * `plateauScan`, a needle not at the insertion index is looked for by identity, scanning outward
11
+ * from it.
17
12
  */
18
13
  export declare function binarySearch<T>({ needle, length, getItemAt, itemIdentityEquals, compare, plateauScan, }: {
19
- /** Target item in the searched array */
20
14
  needle: T;
21
15
  length: number;
22
- /** Retrieves the item from an array. The array could be just an array of reference by id to an index.
23
- * Therefore, we do not access the array directly but allow to determine, how the item is constructed.
24
- */
16
+ /** Reads the item at an index (the array may hold IDs resolved through an index). */
25
17
  getItemAt: (index: number) => T | undefined;
26
- /** Used to determine identity, not equality based on sort / comparator rules */
18
+ /** Identity, not equality under the sort order. */
27
19
  itemIdentityEquals: (item1: T, item2: T) => boolean;
28
- /** Used to determine equality from the sort order point of view. */
29
20
  compare: Comparator<T>;
30
21
  plateauScan?: boolean;
31
22
  }): ItemLocation;
32
23
  /**
33
- * Negative number (< 0) → a comes before b
34
- *
35
- * Zero (0) → leave a and b unchanged relative to each other
36
- * (but they can still move relative to others — sort in JS is not guaranteed stable in older engines, though modern V8/Node/Chrome/Firefox make it stable)
37
- *
38
- * Positive number (> 0) → a comes after b
24
+ * Builds a comparator from a sort spec: terms apply in order, then `tiebreaker`.
25
+ * `null`/`undefined` values sort last whatever the direction.
39
26
  *
40
27
  * @param params - Comparator configuration.
41
28
  * @param params.sort - The sort specification defining fields and directions.
42
29
  * @param params.resolvePathValue - Resolver used to read a field value from an item.
43
- * @param params.tiebreaker - Comparator applied when all sort terms are equal.
30
+ * @param params.tiebreaker - Comparator applied when all sort terms are equal. Defaults to
31
+ * comparing `cid`.
32
+ * @returns The comparator.
44
33
  */
45
34
  export declare function makeComparator<T>({ sort, resolvePathValue, tiebreaker, }: {
46
35
  sort: SortParamRequest[];
@@ -1,17 +1,8 @@
1
1
  export declare function asArray(v: any): any[];
2
2
  export declare function isISODateString(x: any): x is string;
3
3
  /**
4
- * Brings anything date-shaped into unix **nanoseconds**, the unit item fields carry, so a filter or
5
- * sort can compare an operand against a value.
6
- *
7
- * Nanoseconds rather than milliseconds because the two sides of a comparison come from different
8
- * places: an item's `created_at` is the wire number, while a filter operand is typed `Date | string`
9
- * in the generated filter types. Normalizing to ms would have meant halving the pair — a `Date`
10
- * became ms while a wire number was passed through untouched and *called* ms, so every mixed
11
- * comparison silently ordered wrong and `normKey` bucketed the two apart.
12
- *
13
- * A bare `number` is therefore read as nanoseconds. That is the SDK's unit for a timestamp
14
- * everywhere else, and it is what a value read off an item will be.
4
+ * Converts a `Date`, ISO string or finite number into unix nanoseconds, the unit item timestamps
5
+ * carry. A bare `number` is read as nanoseconds already. Returns `null` for anything else.
15
6
  */
16
7
  export declare function toEpochNanos(x: any): number | null;
17
8
  export declare function toNumberLike(x: any): number | null;
@@ -27,18 +18,9 @@ export declare function normalizeString(s: string): string;
27
18
  export declare function normalizeStringAccentInsensitive(s: string): string;
28
19
  export declare function tokenize(s: string): string[];
29
20
  /**
30
- * Reads `a.b.c` off an item, for the filter and sort compilers.
31
- *
32
- * Descends through **anything indexable** — plain objects, arrays (`items.0.id`, `items.length`) and class
33
- * instances (a `Reminder`, a `Poll`) — because a filter path legitimately reaches into all three. That is why
34
- * this is not `getPath` from `src/utils/objectPath.ts`, which deliberately walks plain records only; the two
35
- * are documented there as non-interchangeable.
36
- *
37
- * Stops at `null` / `undefined`, the only values that cannot be indexed. It used to stop at any *falsy*
38
- * value, which made the result depend on a string's contents rather than on its shape: `name.length`
39
- * resolved to `2` for `'ab'` and to `undefined` for `''`. A falsy value at the end of a path was never
40
- * affected — the guard only ever ran against an intermediate — so `{ count: 0 }` on `'count'` has always
41
- * returned `0`, and sorting and filtering on scalar fields were never wrong.
21
+ * Reads `a.b.c` off an item, for the filter and sort compilers. Descends through anything indexable
22
+ * (plain objects, arrays, class instances such as `Reminder`), unlike `getPath` in
23
+ * `src/utils/objectPath.ts`, which walks plain records only. Stops at `null` / `undefined`.
42
24
  */
43
25
  export declare function resolveDotPathValue(obj: any, path: string): unknown;
44
26
  export declare function isIterableButNotString(v: unknown): v is Iterable<unknown>;
@@ -1,12 +1,7 @@
1
1
  /**
2
- * Partition-point ("lower bound") binary search over the index range `[0, length)`.
3
- *
4
- * `predicate` must be **monotonic** over the range — `false` for a (possibly empty) prefix, then
5
- * `true` for the remaining suffix. Returns the first index at which `predicate(index)` holds, or
6
- * `length` if it never does. O(log length).
7
- *
8
- * Unlike `binarySearch`, this locates a *boundary* defined by a predicate rather than a specific
9
- * item by identity — e.g. "first message at/after a timestamp" over a chronologically sorted array.
2
+ * Lower-bound binary search over `[0, length)`: the first index where `predicate` holds, or `length`.
3
+ * `predicate` must be monotonic (`false` for a prefix, then `true`), e.g. "first item at or
4
+ * after a timestamp" over a sorted array.
10
5
  */
11
6
  export declare function lowerBound(length: number, predicate: (index: number) => boolean): number;
12
7
  export declare function locateOnPlateauAlternating<T>(items: readonly T[], needle: T, compare: (left: T, right: T) => number, getItemId: (x: T) => string, insertionIndex: number): number;
@@ -45,20 +45,17 @@ export declare class Poll {
45
45
  handleVoteChanged: (event: EventPayload<"poll.vote_changed">) => void;
46
46
  handleVoteRemoved: (event: EventPayload<"poll.vote_removed">) => void;
47
47
  /**
48
- * Puts an updated user (new name or image) into the votes, answers and creator this poll keeps,
49
- * so voter avatars show it. Each vote is replaced, not edited in place, and everything goes out in
50
- * one state update; nothing is published when the poll doesn't contain the user. An option whose
51
- * votes don't contain the user keeps its array, so what renders it doesn't re-render. The offline
52
- * DB gets the updated poll, as with the other poll events.
48
+ * Puts an updated user (new name or image) into the votes, answers and creator of the poll in one
49
+ * state update, then saves the poll to the offline DB. Does nothing when the poll does not
50
+ * contain the user. Option vote arrays without the user keep their identity.
53
51
  */
54
52
  handleUserUpdated: (user: UserResponse) => void;
55
53
  query: (id: string) => Promise<PollResponseData>;
56
54
  update: (data: Exclude<UpdatePollRequest, "id">) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
57
55
  partialUpdate: (partialPollObject: PartialPollUpdate) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
58
56
  /**
59
- * Closes the poll. The poll is marked as closed optimistically and the change is
60
- * reverted if the request fails, unless the server confirmed the close meanwhile.
61
- * Does nothing if the poll is already closed.
57
+ * Closes the poll optimistically. A failed request reverts it, unless the server confirmed the
58
+ * close meanwhile. No-op if the poll is already closed.
62
59
  */
63
60
  close: () => Promise<import("./types").StreamResponse<import(".").PollResponse> | undefined>;
64
61
  delete: () => Promise<import("./types").StreamResponse<import(".").Response>>;
@@ -66,15 +63,18 @@ export declare class Poll {
66
63
  updateOption: (option: UpdatePollOptionRequest) => Promise<import("./types").StreamResponse<import(".").PollOptionResponse>>;
67
64
  deleteOption: (option_id: string) => Promise<import("./types").StreamResponse<import(".").Response>>;
68
65
  /**
69
- * Casts a vote for an option. The vote is shown right away through a local placeholder vote,
70
- * which the server's vote replaces once the WS events of all pending vote changes arrived.
71
- * If the request fails, the change is reverted.
66
+ * Casts a vote, shown right away as a local placeholder that the server's vote replaces once the
67
+ * WS events of all pending vote changes arrived. A failed request reverts it.
72
68
  */
73
69
  castVote: (optionId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
74
70
  /**
75
- * Removes a vote. The vote is removed right away and restored if the request fails. Vote
76
- * requests are sent in order, so removing a vote whose cast is not confirmed yet uses the vote
77
- * id from the cast's response; if that cast failed, there is nothing to remove.
71
+ * Removes a vote right away; a failed request restores it. Vote requests are sent in order, so a
72
+ * vote whose cast is not confirmed yet is removed by the ID from the cast's response (if that
73
+ * cast failed, there is nothing to remove).
74
+ *
75
+ * @param voteId - The ID of the vote to remove.
76
+ * @param messageId - The ID of the poll's message.
77
+ * @returns The delete response, or `undefined` when there was nothing to remove.
78
78
  */
79
79
  removeVote: (voteId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
80
80
  addAnswer: (answerText: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;