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

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 (298) hide show
  1. package/README.md +11 -8
  2. package/dist/cjs/index.browser.js +15397 -12090
  3. package/dist/cjs/index.browser.js.map +4 -4
  4. package/dist/cjs/index.node.js +15349 -11991
  5. package/dist/cjs/index.node.js.map +4 -4
  6. package/dist/esm/index.mjs +15164 -11880
  7. package/dist/esm/index.mjs.map +4 -4
  8. package/dist/types/ChannelManager.d.ts +246 -6
  9. package/dist/types/CooldownTimer.d.ts +22 -8
  10. package/dist/types/EventHandlerPipeline.d.ts +12 -16
  11. package/dist/types/LiveLocationManager.d.ts +69 -6
  12. package/dist/types/api-client.d.ts +22 -9
  13. package/dist/types/channel.d.ts +550 -300
  14. package/dist/types/channel_state.d.ts +167 -22
  15. package/dist/types/client.d.ts +325 -305
  16. package/dist/types/configuration/ConfigController.d.ts +172 -0
  17. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +192 -0
  18. package/dist/types/configuration/index.d.ts +3 -0
  19. package/dist/types/configuration/keys.d.ts +31 -0
  20. package/dist/types/configuration/shape.d.ts +58 -0
  21. package/dist/types/configuration/types.d.ts +206 -50
  22. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +59 -0
  23. package/dist/types/configuration/utils/copyConfigPatch.d.ts +1 -0
  24. package/dist/types/configuration/utils/declarativeSlices.d.ts +24 -0
  25. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +22 -0
  26. package/dist/types/configuration/utils/index.d.ts +1 -0
  27. package/dist/types/configuration/utils/serverAuthority.d.ts +49 -0
  28. package/dist/types/connection/ConnectionIdManager.d.ts +67 -0
  29. package/dist/types/connection/ConnectionRecoveryManager.d.ts +164 -0
  30. package/dist/types/connection/index.d.ts +4 -0
  31. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +153 -0
  32. package/dist/types/connection/networkConnection/index.d.ts +3 -0
  33. package/dist/types/connection/networkConnection/reporters.d.ts +43 -0
  34. package/dist/types/connection/networkConnection/types.d.ts +55 -0
  35. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +204 -0
  36. package/dist/types/connection/wsConnection/WSConnection.d.ts +168 -0
  37. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +55 -0
  38. package/dist/types/connection/wsConnection/config.d.ts +51 -0
  39. package/dist/types/connection/wsConnection/index.d.ts +4 -0
  40. package/dist/types/connection/wsConnection/types.d.ts +99 -0
  41. package/dist/types/constants.d.ts +3 -1
  42. package/dist/types/entityStore/EntityStore.d.ts +160 -40
  43. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +48 -29
  44. package/dist/types/entityStore/index.d.ts +0 -1
  45. package/dist/types/errors.d.ts +24 -4
  46. package/dist/types/formatMessageMemo.d.ts +5 -0
  47. package/dist/types/gen/chat/ChannelApi.d.ts +51 -23
  48. package/dist/types/gen/chat/ChatApi.d.ts +215 -168
  49. package/dist/types/gen/models/index.d.ts +2164 -557
  50. package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
  51. package/dist/types/gen/moderation/ModerationApi.d.ts +39 -32
  52. package/dist/types/gen-imports.d.ts +1 -0
  53. package/dist/types/index.d.ts +20 -7
  54. package/dist/types/languageNames.d.ts +97 -0
  55. package/dist/types/logger.d.ts +1 -1
  56. package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
  57. package/dist/types/messageComposer/LocationComposer.d.ts +10 -4
  58. package/dist/types/messageComposer/attachmentIdentity.d.ts +11 -0
  59. package/dist/types/messageComposer/attachmentManager.d.ts +48 -10
  60. package/dist/types/messageComposer/attachmentUtils.d.ts +34 -0
  61. package/dist/types/messageComposer/configuration/commands.configuration.d.ts +1 -3
  62. package/dist/types/messageComposer/configuration/configuration.d.ts +9 -1
  63. package/dist/types/messageComposer/configuration/index.d.ts +0 -1
  64. package/dist/types/messageComposer/configuration/types.d.ts +57 -1
  65. package/dist/types/messageComposer/index.d.ts +1 -0
  66. package/dist/types/messageComposer/linkPreviewsManager.d.ts +10 -4
  67. package/dist/types/messageComposer/messageComposer.d.ts +210 -14
  68. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +20 -1
  69. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +11 -0
  70. package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +2 -2
  71. package/dist/types/messageComposer/middleware/pollComposer/index.d.ts +1 -0
  72. package/dist/types/messageComposer/middleware/pollComposer/state.d.ts +3 -2
  73. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +9 -2
  74. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +44 -0
  75. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +2 -2
  76. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +94 -229
  77. package/dist/types/messageComposer/pollComposer.d.ts +8 -3
  78. package/dist/types/messageComposer/textComposer.d.ts +9 -1
  79. package/dist/types/messageComposer/types.d.ts +7 -3
  80. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +64 -8
  81. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +48 -11
  82. package/dist/types/messageOperations/FailedSendCache.d.ts +34 -0
  83. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +52 -6
  84. package/dist/types/messageOperations/MessageOperations.d.ts +94 -11
  85. package/dist/types/{entityStore → messageOperations}/applyReactionLocally.d.ts +8 -2
  86. package/dist/types/messageOperations/createMessageOperations.d.ts +11 -0
  87. package/dist/types/messageOperations/index.d.ts +7 -1
  88. package/dist/types/messageOperations/reflectReactionEvent.d.ts +24 -0
  89. package/dist/types/messageOperations/sendOrdering.d.ts +17 -0
  90. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +28 -0
  91. package/dist/types/messageOperations/types.d.ts +66 -1
  92. package/dist/types/middleware.d.ts +8 -0
  93. package/dist/types/moderation.d.ts +18 -4
  94. package/dist/types/notifications/NotificationManager.d.ts +43 -2
  95. package/dist/types/notifications/types.d.ts +55 -42
  96. package/dist/types/offline-support/offline_support_api.d.ts +128 -12
  97. package/dist/types/offline-support/offline_sync_manager.d.ts +26 -5
  98. package/dist/types/offline-support/queueableOperations.d.ts +106 -0
  99. package/dist/types/offline-support/types.d.ts +77 -28
  100. package/dist/types/pagination/FilterBuilder.d.ts +1 -18
  101. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -1
  102. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +21 -3
  103. package/dist/types/pagination/filterCompiler.d.ts +5 -0
  104. package/dist/types/pagination/paginators/BasePaginator.d.ts +331 -7
  105. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +54 -11
  106. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +283 -66
  107. package/dist/types/pagination/paginators/MessagePaginator.d.ts +10 -9
  108. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +17 -1
  109. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +8 -8
  110. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +57 -0
  111. package/dist/types/pagination/paginators/index.d.ts +1 -0
  112. package/dist/types/pagination/utility.normalization.d.ts +29 -2
  113. package/dist/types/poll.d.ts +41 -14
  114. package/dist/types/poll_manager.d.ts +3 -2
  115. package/dist/types/poll_optimistic_votes.d.ts +61 -0
  116. package/dist/types/reminders/Reminder.d.ts +17 -7
  117. package/dist/types/reminders/ReminderManager.d.ts +34 -6
  118. package/dist/types/search/BaseSearchSource.d.ts +50 -25
  119. package/dist/types/search/ChannelMemberSearchSource.d.ts +11 -6
  120. package/dist/types/search/ChannelSearchSource.d.ts +27 -5
  121. package/dist/types/search/MessageSearchSource.d.ts +36 -6
  122. package/dist/types/search/SearchController.d.ts +44 -11
  123. package/dist/types/search/UserSearchSource.d.ts +11 -5
  124. package/dist/types/search/types.d.ts +14 -1
  125. package/dist/types/signing.d.ts +0 -157
  126. package/dist/types/thread.d.ts +118 -62
  127. package/dist/types/thread_manager.d.ts +124 -35
  128. package/dist/types/token_manager.d.ts +5 -8
  129. package/dist/types/types.d.ts +138 -562
  130. package/dist/types/types.utility.d.ts +8 -0
  131. package/dist/types/upload-utils.d.ts +20 -0
  132. package/dist/types/uploadManager.d.ts +50 -2
  133. package/dist/types/utils/FixedSizeQueueCache.d.ts +2 -0
  134. package/dist/types/utils/WithSubscriptions.d.ts +1 -1
  135. package/dist/types/utils/objectPath.d.ts +49 -0
  136. package/dist/types/utils/time.d.ts +85 -0
  137. package/dist/types/utils.d.ts +63 -40
  138. package/package.json +22 -33
  139. package/src/ChannelManager.ts +561 -109
  140. package/src/CooldownTimer.ts +55 -45
  141. package/src/EventHandlerPipeline.ts +13 -23
  142. package/src/LiveLocationManager.ts +191 -37
  143. package/src/api-client.ts +144 -53
  144. package/src/channel.ts +1573 -1050
  145. package/src/channel_state.ts +239 -129
  146. package/src/client.ts +843 -892
  147. package/src/client_state.ts +2 -2
  148. package/src/configuration/ConfigController.ts +298 -0
  149. package/src/configuration/InstanceConfigurationRegistry.ts +430 -0
  150. package/src/configuration/index.ts +7 -0
  151. package/src/configuration/keys.ts +86 -0
  152. package/src/configuration/shape.ts +776 -0
  153. package/src/configuration/types.ts +218 -60
  154. package/src/configuration/utils/applyInstanceConfiguration.ts +184 -0
  155. package/src/configuration/utils/copyConfigPatch.ts +61 -0
  156. package/src/configuration/utils/declarativeSlices.ts +81 -0
  157. package/src/configuration/utils/deepFreezeConfig.ts +33 -0
  158. package/src/configuration/utils/index.ts +5 -0
  159. package/src/configuration/utils/serverAuthority.ts +146 -0
  160. package/src/connection/ConnectionIdManager.ts +153 -0
  161. package/src/connection/ConnectionRecoveryManager.ts +371 -0
  162. package/src/connection/index.ts +4 -0
  163. package/src/connection/networkConnection/NetworkConnectionObserver.ts +281 -0
  164. package/src/connection/networkConnection/index.ts +3 -0
  165. package/src/connection/networkConnection/reporters.ts +85 -0
  166. package/src/connection/networkConnection/types.ts +60 -0
  167. package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +242 -151
  168. package/src/connection/wsConnection/WSConnection.ts +345 -0
  169. package/src/connection/wsConnection/WSConnectionFallback.ts +259 -0
  170. package/src/connection/wsConnection/config.ts +108 -0
  171. package/src/connection/wsConnection/index.ts +4 -0
  172. package/src/connection/wsConnection/types.ts +101 -0
  173. package/src/constants.ts +5 -3
  174. package/src/entityStore/EntityStore.ts +350 -10
  175. package/src/entityStore/StoreBackedItemIndex.ts +66 -37
  176. package/src/entityStore/index.ts +0 -1
  177. package/src/errors.ts +40 -7
  178. package/src/formatMessageMemo.ts +23 -0
  179. package/src/gen/chat/ChannelApi.ts +230 -44
  180. package/src/gen/chat/ChatApi.ts +1047 -1745
  181. package/src/gen/models/index.ts +2378 -3721
  182. package/src/gen/models/timestamp-guard.ts +27 -0
  183. package/src/gen/moderation/ModerationApi.ts +218 -388
  184. package/src/gen-imports.ts +1 -0
  185. package/src/index.ts +82 -6
  186. package/src/languageNames.ts +103 -0
  187. package/src/logger.ts +1 -1
  188. package/src/messageComposer/CustomDataManager.ts +10 -1
  189. package/src/messageComposer/LocationComposer.ts +68 -20
  190. package/src/messageComposer/attachmentIdentity.ts +39 -0
  191. package/src/messageComposer/attachmentManager.ts +191 -68
  192. package/src/messageComposer/attachmentUtils.ts +58 -0
  193. package/src/messageComposer/configuration/commands.configuration.ts +1 -26
  194. package/src/messageComposer/configuration/configuration.ts +22 -3
  195. package/src/messageComposer/configuration/index.ts +0 -1
  196. package/src/messageComposer/configuration/types.ts +58 -1
  197. package/src/messageComposer/index.ts +1 -0
  198. package/src/messageComposer/linkPreviewsManager.ts +16 -10
  199. package/src/messageComposer/messageComposer.ts +487 -98
  200. package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
  201. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +58 -33
  202. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +7 -2
  203. package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +3 -2
  204. package/src/messageComposer/middleware/messageComposer/attachments.ts +98 -1
  205. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +20 -10
  206. package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
  207. package/src/messageComposer/middleware/messageComposer/types.ts +2 -7
  208. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +11 -6
  209. package/src/messageComposer/middleware/pollComposer/index.ts +1 -0
  210. package/src/messageComposer/middleware/pollComposer/state.ts +43 -11
  211. package/src/messageComposer/middleware/pollComposer/types.ts +9 -2
  212. package/src/messageComposer/middleware/pollComposer/validation.ts +76 -0
  213. package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -2
  214. package/src/messageComposer/middleware/textComposer/commands.ts +1 -2
  215. package/src/messageComposer/middleware/textComposer/mentions.ts +91 -39
  216. package/src/messageComposer/pollComposer.ts +11 -3
  217. package/src/messageComposer/textComposer.ts +36 -4
  218. package/src/messageComposer/types.ts +19 -14
  219. package/src/messageDelivery/MessageDeliveryReporter.ts +154 -53
  220. package/src/messageDelivery/MessageReceiptsTracker.ts +136 -64
  221. package/src/messageOperations/FailedSendCache.ts +90 -0
  222. package/src/messageOperations/MessageOperationStatePolicy.ts +269 -27
  223. package/src/messageOperations/MessageOperations.ts +340 -136
  224. package/src/{entityStore → messageOperations}/applyReactionLocally.ts +10 -3
  225. package/src/messageOperations/createMessageOperations.ts +192 -0
  226. package/src/messageOperations/index.ts +7 -0
  227. package/src/messageOperations/reflectReactionEvent.ts +51 -0
  228. package/src/messageOperations/sendOrdering.ts +28 -0
  229. package/src/messageOperations/settlePendingAttachmentUploads.ts +110 -0
  230. package/src/messageOperations/types.ts +74 -0
  231. package/src/middleware.ts +11 -0
  232. package/src/moderation.ts +47 -24
  233. package/src/notifications/NotificationManager.ts +73 -3
  234. package/src/notifications/configuration.ts +10 -8
  235. package/src/notifications/types.ts +58 -42
  236. package/src/offline-support/offline_support_api.ts +380 -197
  237. package/src/offline-support/offline_sync_manager.ts +105 -32
  238. package/src/offline-support/queueableOperations.ts +270 -0
  239. package/src/offline-support/types.ts +85 -39
  240. package/src/pagination/FilterBuilder.ts +1 -22
  241. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +11 -7
  242. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +25 -7
  243. package/src/pagination/filterCompiler.ts +17 -0
  244. package/src/pagination/paginators/BasePaginator.ts +731 -81
  245. package/src/pagination/paginators/ChannelPaginator.ts +210 -102
  246. package/src/pagination/paginators/MessageIntervalPaginator.ts +703 -193
  247. package/src/pagination/paginators/MessagePaginator.ts +45 -36
  248. package/src/pagination/paginators/PinnedMessagePaginator.ts +74 -28
  249. package/src/pagination/paginators/ReminderPaginator.ts +15 -13
  250. package/src/pagination/paginators/ThreadPaginator.ts +181 -0
  251. package/src/pagination/paginators/UserGroupPaginator.ts +8 -1
  252. package/src/pagination/paginators/index.ts +1 -0
  253. package/src/pagination/utility.normalization.ts +37 -9
  254. package/src/poll.ts +189 -112
  255. package/src/poll_manager.ts +14 -8
  256. package/src/poll_optimistic_votes.ts +335 -0
  257. package/src/reminders/Reminder.ts +34 -16
  258. package/src/reminders/ReminderManager.ts +68 -41
  259. package/src/reminders/ReminderTimer.ts +7 -6
  260. package/src/search/BaseSearchSource.ts +133 -40
  261. package/src/search/ChannelMemberSearchSource.ts +27 -18
  262. package/src/search/ChannelSearchSource.ts +61 -7
  263. package/src/search/MessageSearchSource.ts +133 -28
  264. package/src/search/SearchController.ts +93 -16
  265. package/src/search/UserSearchSource.ts +27 -13
  266. package/src/search/types.ts +14 -1
  267. package/src/signing.ts +1 -315
  268. package/src/thread.ts +503 -511
  269. package/src/thread_manager.ts +339 -204
  270. package/src/token_manager.ts +12 -32
  271. package/src/types.ts +159 -780
  272. package/src/types.utility.ts +14 -0
  273. package/src/upload-utils.ts +53 -0
  274. package/src/uploadManager.ts +85 -7
  275. package/src/utils/FixedSizeQueueCache.ts +5 -0
  276. package/src/utils/WithSubscriptions.ts +1 -1
  277. package/src/utils/objectPath.ts +67 -0
  278. package/src/utils/time.ts +104 -0
  279. package/src/utils.ts +209 -157
  280. package/dist/types/base64.d.ts +0 -2
  281. package/dist/types/configuration/InstanceConfigurationService.d.ts +0 -26
  282. package/dist/types/connection.d.ts +0 -146
  283. package/dist/types/connection_fallback.d.ts +0 -42
  284. package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
  285. package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
  286. package/dist/types/insights.d.ts +0 -58
  287. package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
  288. package/dist/types/permissions.d.ts +0 -55
  289. package/dist/types/store.d.ts +0 -125
  290. package/src/base64.ts +0 -78
  291. package/src/configuration/InstanceConfigurationService.ts +0 -73
  292. package/src/connection_fallback.ts +0 -215
  293. package/src/gen/model-decoders/decoders.ts +0 -2680
  294. package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
  295. package/src/insights.ts +0 -83
  296. package/src/pagination/utility.queryChannel.ts +0 -84
  297. package/src/permissions.ts +0 -102
  298. package/src/store.ts +0 -304
@@ -1,8 +1,8 @@
1
- import type { PaginationDirection, PaginationQueryParams, PaginatorState } from './BasePaginator';
1
+ import type { BasePaginatorConfig, PaginationDirection, PaginationQueryParams, PaginatorState } from './BasePaginator';
2
2
  import { BasePaginator, type PaginationQueryReturnValue, type PaginatorOptions } from './BasePaginator';
3
- import type { LocalMessage, MessagePaginationOptions, MessageResponse, PinnedMessagePaginationOptions, ReactionResponse, SortParamRequest, UserResponse } from '../../types';
3
+ import type { LocalMessage, MessagePaginationParams, PinnedMessagePaginationOptions, SortParamRequest, TimestampNS, UserResponse } from '../../types';
4
4
  import type { Channel } from '../../channel';
5
- import { StateStore } from '../../store';
5
+ import { StateStore } from '@stream-io/state-store';
6
6
  import type { ItemIndexApi } from '../ItemIndex';
7
7
  import type { EntityStoreChangeBatch } from '../../entityStore/EntityStore';
8
8
  export type MessageFocusReason = 'jump-to-message' | 'jump-to-first-unread' | 'jump-to-latest';
@@ -32,6 +32,14 @@ export type JumpToMessageOptions = {
32
32
  * If true, suppresses focus signal emission after a successful jump.
33
33
  */
34
34
  suppressFocusSignal?: boolean;
35
+ /**
36
+ * Also watch the channel, so it receives its events, when it isn't watched yet: the request that
37
+ * loads the window around the message asks to watch too, so it takes one request. A message
38
+ * already loaded is then loaded again with that request. Ignored for a thread's reply list, which
39
+ * loads replies through a request that can't watch, and when the paginator's `doRequest` loads
40
+ * the messages.
41
+ */
42
+ watchChannel?: boolean;
35
43
  };
36
44
  export type MessagePaginatorSort = SortParamRequest[];
37
45
  export type MessagePaginatorFilter = {
@@ -39,8 +47,15 @@ export type MessagePaginatorFilter = {
39
47
  parent_id?: string;
40
48
  };
41
49
  export type MessagePaginatorState = PaginatorState<LocalMessage>;
42
- export type MessageQueryShape = MessagePaginationOptions | PinnedMessagePaginationOptions;
43
- export declare const getMessageCreatedAtTimestamp: (message: LocalMessage) => number | null;
50
+ export type MessageQueryShape = MessagePaginationParams | PinnedMessagePaginationOptions;
51
+ /**
52
+ * A message's `created_at` as the comparable wire timestamp (unix nanoseconds), or `null` when it
53
+ * is absent or not a finite number.
54
+ *
55
+ * Accepts `null`/`undefined` so callers holding an optional message (e.g.
56
+ * `MessagePaginator.lastMessage`) do not each repeat the guard.
57
+ */
58
+ export declare const getMessageCreatedAtTimestamp: (message: LocalMessage | null | undefined) => TimestampNS | null;
44
59
  export type MessagePaginatorOptions = {
45
60
  channel: Channel;
46
61
  id?: string;
@@ -61,21 +76,88 @@ export type MessagePaginatorOptions = {
61
76
  itemOrder?: MessagePaginatorSort;
62
77
  paginatorOptions?: PaginatorOptions<LocalMessage, MessageQueryShape>;
63
78
  };
79
+ /**
80
+ * Options for {@link MessageIntervalPaginator.mergeNewestPage} that enable destructive
81
+ * reconciliation — removing messages that were hard-deleted (by anyone) while the client was
82
+ * offline. A hard delete emits no event to other clients, and the merge is otherwise additive, so
83
+ * without this such a message lingers as a ghost after reconnect.
84
+ *
85
+ * Throughout, `page` is the newest window the server returned for `mergeNewestPage`, and "`page`'s
86
+ * newest / oldest message" are its bounds by `created_at`. With NO options, `mergeNewestPage` prunes
87
+ * any loaded message that falls WITHIN `page`'s `created_at` span but is absent from it —
88
+ * unconditionally safe (a message that arrived live during the caller's fetch is always strictly
89
+ * newer than `page`'s newest message, so it can never fall in that span). `candidateIds` widens the
90
+ * reconcilable window at the TOP edge; `requestedLimit` only tunes the `hasMoreTail` affordance and
91
+ * can never remove a message:
92
+ */
93
+ export type MergeNewestPageOptions = {
94
+ /**
95
+ * The `limit` the caller passed to the query that produced `page`. Used ONLY to derive
96
+ * `hasMoreTail` — whether `page` reached the channel's own oldest message — by comparing it to
97
+ * `page.length`. It NEVER removes a message (reconciliation stays window-only regardless), so the
98
+ * worst a wrong value can do is show/hide the "load older" affordance for one settle. Trusted only
99
+ * when no larger than the paginator's own `pageSize` (see
100
+ * {@link MessageIntervalPaginator.pageReachedChannelStart}); a larger over-request — e.g.
101
+ * `channel.reload` re-fetching the whole loaded window to reconcile as much as possible — may have
102
+ * been silently server-capped, so its short page is ignored rather than mistaken for reaching the
103
+ * start.
104
+ */
105
+ requestedLimit?: number;
106
+ /**
107
+ * A snapshot of the loaded message ids taken BEFORE the caller's fetch await. Required to prune
108
+ * messages NEWER than `page`'s newest message (a hard-deleted newest message) and to reconcile an
109
+ * empty `page` (a fully-emptied channel): at/above that top edge a just-deleted message and a
110
+ * message that arrived live during the fetch are indistinguishable by timestamp — only the pre-fetch
111
+ * snapshot separates them (a live arrival is not in it). Must be captured before the await; the
112
+ * paginator's own items at merge time already include any live arrival.
113
+ */
114
+ candidateIds?: ReadonlySet<string>;
115
+ };
116
+ /**
117
+ * Options for {@link MessageIntervalPaginator.seedFirstPageSync}, the synchronous channel-open seed.
118
+ */
119
+ export type SeedFirstPageOptions = {
120
+ /**
121
+ * When true and the paginator has already been seeded once, fold the fresh page via
122
+ * {@link MessageIntervalPaginator.mergeNewestPage} — merge in place, reconcile offline hard-deletes,
123
+ * re-derive the tail cursor, rebuild on a disjoint window, and skip when jumped away from the head —
124
+ * instead of a plain first-page ingest. Lets callers (channel.reload, the channel-list hydrate,
125
+ * connection recovery) share one reconciling seed path. Left false for the differently-sorted
126
+ * pinned list, and a no-op on a cold open (nothing loaded to fold).
127
+ */
128
+ reconcile?: boolean;
129
+ /**
130
+ * Pre-fetch snapshot of loaded message ids (captured before the caller's network await), forwarded
131
+ * to {@link MergeNewestPageOptions.candidateIds} so a hard-deleted NEWEST message is reconciled
132
+ * without mistaking a message that arrived live during the fetch for a delete. Only consulted when
133
+ * {@link reconcile} is set and a window is already loaded.
134
+ */
135
+ candidateIds?: ReadonlySet<string>;
136
+ };
64
137
  /**
65
138
  * MessageIntervalPaginator allows configuring backend request sort, while keeping internal item ordering stable.
66
139
  * Filtering of ingested items is still limited to local predicates (`filterQueryResults`).
67
140
  */
68
141
  export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage, MessageQueryShape> {
142
+ /**
143
+ * The name this list's index goes by as a holder in the message store. A prototype getter, so it
144
+ * is already the subclass's while the base constructor builds the index.
145
+ */
146
+ protected get holderName(): string;
69
147
  state: StateStore<MessagePaginatorState>;
70
148
  private readonly _id;
71
- protected channel: Channel;
72
- protected parentMessageId?: string;
149
+ /** The channel this list belongs to. A thread's reply list holds its parent channel. */
150
+ readonly channel: Channel;
151
+ /** Set when this is a thread's reply list, to the parent message's id. */
152
+ readonly parentMessageId?: string;
73
153
  readonly messageFocusSignal: StateStore<MessageFocusSignalState>;
74
154
  private clearMessageFocusSignalTimeoutId;
75
155
  private messageFocusSignalToken;
76
156
  protected _requestSort: MessagePaginatorSort;
77
157
  protected _itemOrder: MessagePaginatorSort;
78
158
  protected _nextQueryShape: MessageQueryShape | undefined;
159
+ /** Pending below-window reached-start probe (exposed for deterministic test awaiting). */
160
+ private _belowWindowReconcile?;
79
161
  sortComparator: (a: LocalMessage, b: LocalMessage) => number;
80
162
  /**
81
163
  * Single source of truth for whether a message should be included in paginator intervals/state.
@@ -90,15 +172,68 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
90
172
  * store-backed.
91
173
  */
92
174
  onEntitiesChanged({ changedIds }: EntityStoreChangeBatch): void;
175
+ /**
176
+ * Entity-store subscriber: the store removed a message this paginator holds, so it drops it from
177
+ * its windows.
178
+ */
179
+ onEntityRemoved(id: string, message: unknown): void;
93
180
  /**
94
181
  * Entity-store subscriber flush (the optional `EntityStoreSubscriber.flushState`): the `EntityStore`
95
182
  * calls this after an optimistic (local-user) write so the change renders without throttle delay.
96
183
  * Delegates to the base's generic {@link BasePaginator.flushPendingPublishes}.
97
184
  */
98
185
  flushState(): void;
186
+ /**
187
+ * UI-driven "hold off on pruning" signal, set via {@link setPruningSuspended}. Defaults to not
188
+ * suspended, so a paginator with no UI attached still honours its configured cap.
189
+ */
190
+ protected get isPruningSuspended(): boolean;
191
+ private _pruningSuspended;
192
+ /**
193
+ * Tells the paginator to hold off on dropping the oldest loaded messages. The SDK calls this from
194
+ * its viewability tracking: while the user is reading near the oldest loaded message, pruning there
195
+ * would pull content out from under them, so the window is allowed to grow past its cap until they
196
+ * scroll back. Only meaningful alongside `maxLoadedItems`.
197
+ *
198
+ * Deliberately a plain field rather than a `StateStore` — nothing observes it, and a scroll-driven
199
+ * signal must not be able to cost a render.
200
+ */
201
+ setPruningSuspended: (suspended: boolean) => void;
202
+ /**
203
+ * A message can anchor pagination once the server has acknowledged it. Narrowing this is what keeps
204
+ * an unsent message out of both halves of a prune: it is skipped rather than dropped, and it can
205
+ * never become the window's tailward cursor (its id would go out as `id_lt` and mean nothing to the
206
+ * server).
207
+ */
208
+ protected isPaginationAnchorable(item: LocalMessage | undefined): boolean;
99
209
  protected get intervalItemIdsAreHeadFirst(): boolean;
100
210
  protected get intervalSortDirection(): 'asc' | 'desc';
101
- constructor({ channel, id, itemIndex, parentMessageId, requestSort, sort, itemOrder, paginatorOptions, }: MessagePaginatorOptions);
211
+ constructor({ channel, id, itemIndex, parentMessageId, requestSort, sort, itemOrder, paginatorOptions, }: MessagePaginatorOptions, builtInDefaults?: Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>);
212
+ /**
213
+ * Memoized so every derivation sees the *same* two functions. `initializeConfig` folds this into the
214
+ * config it publishes and skips the publish when nothing moved — which only works if these references
215
+ * are stable.
216
+ *
217
+ * Safe to build once: both close over `this` and read `_itemOrder`, which is assigned in the
218
+ * constructor and has no setter.
219
+ */
220
+ private intervalBehaviour?;
221
+ private buildIntervalBehaviour;
222
+ /**
223
+ * Cursor derivation and in-memory item ordering, which this class installs on `config` rather than
224
+ * passing as constructor options.
225
+ *
226
+ * Contributed to the base derivation rather than written after it — see
227
+ * {@link BasePaginator.getBehaviourOverrides}. That is what keeps one re-derivation to one publish,
228
+ * and stops the intermediate publish that had these two stripped.
229
+ */
230
+ protected getBehaviourOverrides(): Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>;
231
+ /**
232
+ * The constructor's route to the same overlay. Deliberately calls the private builder rather than the
233
+ * overridable hook: this runs inside the constructor, and a subclass override would execute before its
234
+ * own fields were initialized.
235
+ */
236
+ protected installIntervalBehaviour(): void;
102
237
  get id(): string;
103
238
  get sort(): MessagePaginatorSort;
104
239
  get requestSort(): MessagePaginatorSort;
@@ -115,10 +250,14 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
115
250
  tailward: string | undefined;
116
251
  headward: string | undefined;
117
252
  };
118
- query: ({ direction, }: PaginationQueryParams<MessageQueryShape>) => Promise<PaginationQueryReturnValue<LocalMessage>>;
253
+ /**
254
+ * Reads `requestOptions.watch`: `true` also watches the channel with the request. Ignored for a
255
+ * thread's reply list and with `doRequest`.
256
+ */
257
+ query: ({ direction, requestOptions, }: PaginationQueryParams<MessageQueryShape>) => Promise<PaginationQueryReturnValue<LocalMessage>>;
119
258
  /**
120
259
  * Seed the paginator with the page a channel-open query just fetched (`Channel.query` for
121
- * `watch`/`create`, and `client.hydrateActiveChannels`).
260
+ * `watch`/`create`, and `client.hydrateChannels`).
122
261
  *
123
262
  * These paths hydrate the channel read state in the SAME synchronous tick they add messages
124
263
  * (`Channel._initializeState`), and the read patch drives `MessageReceiptsTracker`, which resolves
@@ -133,9 +272,9 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
133
272
  * apply jump semantics (no forced head/tail; cursor flags derived from the around position)
134
273
  * instead of wrongly flagging the window as the head (newest) page.
135
274
  */
136
- seedFirstPageSync(messages: LocalMessage[], requestedPageSize: number, messagePaginationOptions?: MessagePaginationOptions): void;
275
+ seedFirstPageSync(messages: LocalMessage[], requestedPageSize: number, messagePaginationOptions?: MessagePaginationParams, options?: SeedFirstPageOptions): void;
137
276
  isJumpQueryShape(queryShape: MessageQueryShape): boolean;
138
- jumpToMessage: (messageId: string, { focusReason, focusSignalTtlMs, pageSize, suppressFocusSignal, }?: JumpToMessageOptions) => Promise<boolean>;
277
+ jumpToMessage: (messageId: string, { focusReason, focusSignalTtlMs, pageSize, suppressFocusSignal, watchChannel, }?: JumpToMessageOptions) => Promise<boolean>;
139
278
  jumpToTheLatestMessage: (options?: JumpToMessageOptions) => Promise<boolean>;
140
279
  /**
141
280
  * Fold an already fetched newest (head) page into the currently loaded items without issuing a
@@ -147,25 +286,143 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
147
286
  * 1. OVERLAP - the incoming page shares at least one id with the loaded head (fewer than a full
148
287
  * page is new). Merge in place: existing items are reconciled by id (edits, soft deletes), new
149
288
  * items are appended and every already loaded item (including older pages already paged in) is
150
- * kept. `hasMoreTail`/`cursor.tailward` are left as-is so the page can be any size, so deriving
151
- * "has older items" from its length would wrongly clear it while older items remain.
289
+ * kept. The tail boundary (`hasMoreTail`/`cursor.tailward`) is set from whether the page reached
290
+ * the channel start ({@link pageReachedChannelStart}): a bounded page that came back short means
291
+ * no more older, otherwise "load older" stays enabled and the cursor re-anchors to the true loaded
292
+ * oldest (which also clears a stale offline-DB cursor). Then destructive reconciliation
293
+ * ({@link reconcileHeadAgainstPage}) removes any loaded message
294
+ * that the authoritative page proves was hard-deleted while offline (see that method + the
295
+ * {@link MergeNewestPageOptions} for the exact, safe window).
152
296
  *
153
297
  * 2. DISJOINT - the incoming page shares no id with the loaded head (at least a full page is new).
154
298
  * Merging would weld the two across the gap (the interval merge treats two head intervals as
155
299
  * overlapping when one reaches further headward), hiding the items in between with no way to
156
300
  * reach them. Instead the loaded set is discarded and rebuilt from the incoming page as a fresh
157
301
  * contiguous head (`hasMoreTail: true`, cursor reanchored to the page's oldest item) so the
158
- * gap and older history load again when paginating older.
302
+ * gap and older history load again when paginating older. No separate reconciliation is needed:
303
+ * the rebuilt window IS the server truth, so any hard-deleted message is simply absent from it.
304
+ *
305
+ * Never blanks the loaded set. Noop unless the newest slice is both loaded AND the interval
306
+ * currently in view (the head interval is anchored at the head and active); when the caller has
307
+ * jumped to a separate older window the merge is skipped so their position is preserved, and the
308
+ * incoming page is picked up on a later load. An empty page never wipes the list on its own, but
309
+ * — given a pre-fetch snapshot via `options.candidateIds` — is reconciled as "the channel has no
310
+ * messages" (every server-confirmed loaded message removed).
311
+ *
312
+ * @param page - The fetched newest window (may be empty). `created_at` order is normalized on ingest.
313
+ * @param options - See {@link MergeNewestPageOptions}. Omit to prune only within the page's own span.
314
+ */
315
+ /**
316
+ * Merges a freshly fetched newest page into the loaded window (the hydrate path). Wraps the
317
+ * implementation so the query shape is recorded on EVERY exit — the body returns early in
318
+ * several places, and a window left without a shape loses itself on the next pagination (see
319
+ * `recordLoadedWindowQueryShape`).
320
+ */
321
+ mergeNewestPage: (page: LocalMessage[], options?: MergeNewestPageOptions) => void;
322
+ private _mergeNewestPage;
323
+ /**
324
+ * Whether `page` proves it reached the channel's own oldest message: the caller's request was
325
+ * bounded by this paginator's OWN `pageSize` AND `page` came back shorter than that request.
326
+ *
327
+ * `pageSize <= the server's max page size` is already the invariant normal pagination
328
+ * (`executeQuery`) relies on — `page.length < pageSize` ⟹ reached the end — so a request no larger
329
+ * than `pageSize` returns exactly what was asked unless the channel ended. This needs no hardcoded
330
+ * max page size and is per-paginator, so a thread reply paginator uses its own `pageSize`.
331
+ *
332
+ * An OVER-request (larger than `pageSize`, e.g. `channel.reload` re-fetching the whole loaded window
333
+ * to reconcile as much as possible) may have been silently capped by the server, so a short page
334
+ * there is NOT proof of reaching the start — return `false` and stay conservative. This only ever
335
+ * gates the `hasMoreTail` affordance; it never removes a message.
336
+ */
337
+ private pageReachedChannelStart;
338
+ /**
339
+ * Settle the below-window leftovers {@link reconcileHeadAgainstPage} handed back (loaded messages
340
+ * older than `anchorId` — the returned page's oldest — and absent from the page). From the page alone
341
+ * they're ambiguous: a hard-deleted oldest vs a server-capped over-request. Ask the server "anything
342
+ * older than `anchorId`?" — the only cap-free way to tell. Nothing older ⇒ genuine deletes ⇒ remove
343
+ * them and settle the tail. A probe failure or a head change across the await keeps them (never a false
344
+ * delete). The caller decides WHEN this runs.
345
+ */
346
+ private pruneBelowWindowIfReachedStart;
347
+ /** One `limit: 1` fetch of messages older than `id` (channel main list or thread replies). */
348
+ private hasMessagesOlderThan;
349
+ /**
350
+ * Whether a loaded message is server-confirmed and therefore eligible to be reconciled away when
351
+ * absent from an authoritative page. Excludes local-only messages the server has never
352
+ * acknowledged — optimistic (`sending`) and `failed` sends, and client-side `error` placeholders —
353
+ * so a legitimately-unsent message is never mistaken for a hard delete.
354
+ */
355
+ protected isServerConfirmedMessage(message: LocalMessage): boolean;
356
+ /**
357
+ * Destructive half of {@link mergeNewestPage}: remove messages in the loaded head interval that
358
+ * `page` proves were hard-deleted while offline (a hard delete emits no event to other clients, and
359
+ * the merge is additive, so they would otherwise linger forever).
360
+ *
361
+ * Here `page` is the freshly-fetched newest window the server returned for the query that produced
362
+ * it. Its two bounds are its NEWEST message (`page`'s last item by `created_at`) and its OLDEST
363
+ * message (`page`'s first item). Reconciliation removes ONLY messages `page` actually covers — no
364
+ * hardcoded page size is involved — in two regions, by a loaded message's `created_at`:
365
+ *
366
+ * - WITHIN `page` (strictly between `page`'s oldest and newest message): a server-confirmed loaded
367
+ * message absent from `page` was hard-deleted. Safe with no snapshot — a message that arrived live
368
+ * during the caller's fetch is always strictly newer than `page`'s newest message, so it can never
369
+ * fall in this span.
370
+ * - AT/ABOVE `page`'s newest message (a hard-deleted newest message), and the empty-`page` case:
371
+ * only reconcilable with a pre-fetch `candidateIds` snapshot, which alone tells a just-deleted
372
+ * message from one that arrived live during the fetch at that top edge.
373
+ *
374
+ * A loaded message BELOW `page`'s oldest is NOT removed here (window-only) — from the page alone a
375
+ * hard-deleted oldest is indistinguishable from a server-capped over-request. Those messages are
376
+ * instead RETURNED (the below-window leftovers) so {@link pruneBelowWindowIfReachedStart} can settle
377
+ * them with a `limit: 1` "anything older?" probe — the only cap-free proof — and remove them only if
378
+ * the server confirms nothing older exists. Absent that proof they are kept (a later cold/fresh query
379
+ * omits any real delete).
380
+ *
381
+ * Removal goes through {@link removeItem} (batched) so the item index, intervals, shared message
382
+ * store and — via the {@link MessagePaginator} override — the tracked last message all stay correct;
383
+ * the active window is then re-emitted once.
384
+ *
385
+ * @returns the below-window leftover ids (loaded, server-confirmed, older than `page`'s oldest, absent
386
+ * from it) for the caller's reached-start probe. Empty for the no-head / empty-page paths.
387
+ */
388
+ protected reconcileHeadAgainstPage(page: LocalMessage[], options?: MergeNewestPageOptions): string[];
389
+ /**
390
+ * Remove a set of reconciled (hard-deleted) ids from this paginator's loaded state in one coalesced
391
+ * batch. Each id goes through {@link removeItem}, which drops it from THREE places — not a single
392
+ * interval:
393
+ *
394
+ * 1. the item index — unlinks this paginator's membership from the shared entity store (GC'ing the
395
+ * content if this was the last holder);
396
+ * 2. the interval that holds it — located by id, so it is NOT head-specific in general; in practice
397
+ * it is always the head interval, because the sole caller ({@link reconcileHeadAgainstPage})
398
+ * sources these ids from `headInterval.itemIds` and an item has single-interval membership;
399
+ * 3. the active window (`state.items`) if visible — blanking to `[]` when the window empties, per
400
+ * {@link flushWindowPublish}.
159
401
  *
160
- * Both paths emit exactly once and never blank the loaded set. Noop unless the page is non empty
161
- * and the newest slice is both loaded AND the interval currently in view (the head interval is
162
- * anchored at the head and active); when the caller has jumped to a separate older window the
163
- * merge is skipped so their position is preserved, and the incoming page is picked up on a later
164
- * load.
402
+ * The coalesced batch collapses all of that into a single `state.items` publish. Then mirror the
403
+ * removal into the offline DB (see {@link purgeReconciledFromOfflineDb}) so a cold start does not
404
+ * re-seed the ghosts from SQLite. No-op for an empty set, so an unaffected merge does not touch
405
+ * state a second time.
165
406
  */
166
- mergeNewestPage: (page: LocalMessage[]) => void;
407
+ private removeReconciledItems;
408
+ /**
409
+ * Mirror a destructive reconciliation into the offline DB. A hard delete performed while the client
410
+ * was offline reaches it via no event, so the offline store never ran its own hard-delete for these
411
+ * ids; the reconnect query re-hydrates the DB by UPSERT (which never removes what is absent from the
412
+ * page), so without this the ghosts survive in SQLite and a cold start would re-seed them after the
413
+ * in-memory list already dropped them.
414
+ *
415
+ * Owned by the state layer, NOT the SDK: the SDK only supplies the platform `offlineDb`
416
+ * implementation and never orchestrates DB writes for reconciliation. Fire-and-forget and
417
+ * best-effort — the in-memory removal is the source of truth for the live list, so a failed/absent
418
+ * DB write is no worse than before (the ghost merely re-appears on a cold start until the next
419
+ * reconcile). No-op when offline support is off (`client.offlineDb` undefined). The ids are already
420
+ * server-confirmed (the reconcile excludes pending/failed/optimistic), so a plain hard delete —
421
+ * without the pending-task teardown of a local failed message — is correct.
422
+ */
423
+ private purgeReconciledFromOfflineDb;
167
424
  protected resolveUnreadBoundaryIdsByTimestamp: ({ lastReadAt, messages, }: {
168
- lastReadAt: Date;
425
+ lastReadAt: TimestampNS;
169
426
  messages: LocalMessage[];
170
427
  }) => {
171
428
  firstUnreadMessageId: string | null;
@@ -204,12 +461,12 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
204
461
  * messages may still sit between them and the cutoff). The active window is re-emitted once.
205
462
  */
206
463
  truncate: ({ truncatedAt }: {
207
- truncatedAt: Date;
464
+ truncatedAt: TimestampNS;
208
465
  }) => void;
209
466
  applyMessageDeletionForUser: ({ userId, hardDelete, deletedAt, }: {
210
467
  userId: string;
211
468
  hardDelete?: boolean;
212
- deletedAt: Date;
469
+ deletedAt: TimestampNS;
213
470
  }) => void;
214
471
  /**
215
472
  * Ensures quoted-message snapshots across loaded paginator cache are in sync
@@ -229,54 +486,14 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
229
486
  * `ingestItem` re-emit per message.
230
487
  */
231
488
  reflectUserUpdate: (user: UserResponse) => void;
232
- /**
233
- * Apply a reaction WS event (`reaction.new` / `reaction.updated` / `reaction.deleted`) to the
234
- * cached message. The event's `message` already carries the server-updated
235
- * `reaction_groups` / `latest_reactions`; only `own_reactions` needs local preservation so a
236
- * cross-user reaction does not wipe the current user's reactions. This re-homes what
237
- * `ChannelState.addReaction` / `removeReaction` used to do off the now-removed
238
- * `channel.state.messages` / `channel.state.threads` caches (the same logic backs the thread
239
- * paginator via `Thread.messagePaginator`).
240
- *
241
- * `own_reactions` is seeded from the currently cached item (so another user's reaction keeps ours),
242
- * falling back to the event's own_reactions when the message is not loaded — matching the legacy
243
- * behavior where `_updateMessage` only mutated a message that existed locally.
244
- *
245
- * @param params - The reaction event payload.
246
- * @param params.message - The reaction event's message, carrying the
247
- * server-computed `reaction_groups` / `latest_reactions`. Ingested as-is except for `own_reactions`.
248
- * @param params.reaction - The reaction from the event. Only added to/removed from
249
- * `own_reactions` when its `user_id` is the current user; otherwise the current user's
250
- * `own_reactions` are left untouched.
251
- * @param [params.removed=false] - `true` for `reaction.deleted` (remove the reaction from
252
- * `own_reactions`); `false` for `reaction.new` / `reaction.updated` (add it).
253
- * @param [params.enforceUnique=false] - When adding, first clear the current user's existing
254
- * `own_reactions` so only the incoming one remains (used by `reaction.updated`, where a user's
255
- * reaction replaces their previous one).
256
- *
257
- * TODO(reactive-store): reflect reactions ONCE at the store level, not per-paginator. Both the
258
- * channel handler (channel.ts) and the thread handler (thread.ts) call this on every reaction.*
259
- * event, so a message held in more than one collection (a show_in_channel reply, or the thread
260
- * parent) is reflected TWICE: two writes to the same canonical slot, each fanning out to the
261
- * other holder (double re-projection) and minting a fresh ref that defeats the reconcile
262
- * ref-equality bail. Idempotent (counts come wholesale from the event) so the result is correct,
263
- * just wasteful. The store already fans out to every holder, so reflect once (by id, if held) and
264
- * retire the per-collection reflect calls + parent path + enforce_unique branch.
265
- */
266
- reflectReaction: ({ enforceUnique, message, reaction, removed, }: {
267
- message: MessageResponse | LocalMessage;
268
- reaction: ReactionResponse;
269
- enforceUnique?: boolean;
270
- removed?: boolean;
271
- }) => void;
272
489
  /**
273
490
  * Map a timestamp to a loaded message — the first message in the latest (head) window whose
274
- * `created_at` is >= `timestampMs` (mirrors the legacy `ChannelState.findMessageByTimestamp`
491
+ * `created_at` is >= `timestamp` (mirrors the legacy `ChannelState.findMessageByTimestamp`
275
492
  * lower-bound search), or the newest loaded message when the timestamp is beyond it. Used by the
276
493
  * receipts tracker to resolve read/delivered cursors. Searches the newest loaded window — where
277
494
  * read cursors live — which is already sorted, so this is O(log n) with no re-sort.
278
495
  */
279
- findItemByTimestamp: (timestampMs: number, exactTsMatch?: boolean) => LocalMessage | null;
496
+ findItemByTimestamp: (timestamp: TimestampNS, exactTsMatch?: boolean) => LocalMessage | null;
280
497
  filterQueryResults: (items: LocalMessage[]) => LocalMessage[];
281
498
  private getCanonicalQueryItems;
282
499
  }
@@ -1,8 +1,8 @@
1
- import type { ExecuteQueryReturnValue, Interval, PostQueryReconcileParams } from './BasePaginator';
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 } from '../../types';
4
- import { StateStore } from '../../store';
5
- export type { JumpToMessageOptions, MessageFocusReason, MessageFocusSignal, MessageFocusSignalState, MessagePaginatorFilter, MessagePaginatorSort, MessagePaginatorState, MessageQueryShape, } from './MessageIntervalPaginator';
3
+ import type { LocalMessage, TimestampNS } from '../../types';
4
+ import { StateStore } from '@stream-io/state-store';
5
+ export type { JumpToMessageOptions, MergeNewestPageOptions, MessageFocusReason, MessageFocusSignal, MessageFocusSignalState, MessagePaginatorFilter, MessagePaginatorSort, MessagePaginatorState, MessageQueryShape, SeedFirstPageOptions, } from './MessageIntervalPaginator';
6
6
  export { MessageIntervalPaginator } from './MessageIntervalPaginator';
7
7
  /**
8
8
  * Auxiliary (non-pagination) state for the message paginator: whole-collection aggregates that are
@@ -33,7 +33,7 @@ export type MessagePaginatorAggregateState = {
33
33
  * sort key {@link MessagePaginator.lastMessageAt} is derived as the max of the two, so the two can
34
34
  * never drift out of sync.
35
35
  */
36
- seededLastMessageAt: Date | null;
36
+ seededLastMessageAt: TimestampNS | null;
37
37
  };
38
38
  export type MessagePaginatorOptions = BaseMessagePaginatorOptions & {
39
39
  /**
@@ -46,7 +46,7 @@ export type MessagePaginatorOptions = BaseMessagePaginatorOptions & {
46
46
  unreadReferencePolicy?: 'snapshot' | 'read-state-only';
47
47
  };
48
48
  export type UnreadSnapshotState = {
49
- lastReadAt: Date | null;
49
+ lastReadAt: TimestampNS | null;
50
50
  unreadCount: number;
51
51
  /**
52
52
  * Snapshot of the first unread message id for the user.
@@ -77,6 +77,7 @@ export type LiveViewState = {
77
77
  * the "jump to first unread" navigation built on top of them.
78
78
  */
79
79
  export declare class MessagePaginator extends MessageIntervalPaginator {
80
+ protected get holderName(): string;
80
81
  private unreadReferencePolicy;
81
82
  /**
82
83
  * Independent unread reference state (not tied to `channel.state.read`).
@@ -97,13 +98,13 @@ export declare class MessagePaginator extends MessageIntervalPaginator {
97
98
  * distinct from the base's `intervalViews` interval-projection store.
98
99
  */
99
100
  readonly aggregateState: StateStore<MessagePaginatorAggregateState>;
100
- constructor({ unreadReferencePolicy, ...options }: MessagePaginatorOptions);
101
+ constructor({ unreadReferencePolicy, ...options }: MessagePaginatorOptions, builtInDefaults?: Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>);
101
102
  /**
102
103
  * Channel-list sort key: the later of the newest loaded message's `created_at` and the server seed.
103
104
  * **Derived** (never stored) so it cannot drift from {@link lastMessage}. `null` until seeded or a
104
105
  * message is ingested.
105
106
  */
106
- get lastMessageAt(): Date | null;
107
+ get lastMessageAt(): TimestampNS | null;
107
108
  /**
108
109
  * The newest channel-relevant message (the monotonic tracked latest), for display. Convenience read
109
110
  * of {@link aggregateState}; subscribe to `aggregateState` for reactivity. `null` until a message is
@@ -138,7 +139,7 @@ export declare class MessagePaginator extends MessageIntervalPaginator {
138
139
  * authoritative whole-channel aggregate. Monotonic: a no-op when the paginator already advanced
139
140
  * past it (e.g. from ingested messages), so seed order does not matter.
140
141
  */
141
- seedLastMessageAt(value: string | Date | null | undefined): void;
142
+ seedLastMessageAt(value: TimestampNS | null | undefined): void;
142
143
  ingestItem(item: LocalMessage): boolean;
143
144
  ingestPage(params: Parameters<MessageIntervalPaginator['ingestPage']>[0]): Interval | null;
144
145
  removeItem(params: Parameters<MessageIntervalPaginator['removeItem']>[0]): ReturnType<MessageIntervalPaginator['removeItem']>;
@@ -1,4 +1,4 @@
1
- import type { PaginatorOptions } from './BasePaginator';
1
+ import type { BasePaginatorConfig, PaginatorOptions } from './BasePaginator';
2
2
  import { MessageIntervalPaginator, type MessageQueryShape } from './MessageIntervalPaginator';
3
3
  import type { LocalMessage } from '../../types';
4
4
  import type { Channel } from '../../channel';
@@ -33,7 +33,23 @@ export type PinnedMessagePaginatorOptions = {
33
33
  * supports `id_around` — but no unread-coupled navigation exists.
34
34
  */
35
35
  export declare class PinnedMessagePaginator extends MessageIntervalPaginator {
36
+ protected get holderName(): string;
36
37
  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
+ */
43
+ private pinnedBehaviour?;
44
+ private buildPinnedBehaviour;
45
+ 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
+ */
51
+ protected getBehaviourOverrides(): Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>;
52
+ private installPinnedMessageBehaviour;
37
53
  buildMatchFilters: () => PinnedMessagePaginatorFilter;
38
54
  shouldIncludeMessageInInterval(message: LocalMessage): boolean;
39
55
  }
@@ -1,19 +1,19 @@
1
1
  import { BasePaginator } from './BasePaginator';
2
2
  import type { PaginationQueryParams, PaginationQueryReturnValue, PaginatorOptions } from './BasePaginator';
3
- import type { QueryRemindersOptions, ReminderFilters, ReminderResponseData, ReminderSort } from '../../types';
3
+ import type { QueryRemindersRequest, ReminderFilters, ReminderResponseData, SortParamRequest } from '../../types';
4
4
  import type { StreamChat } from '../../client';
5
- export declare class ReminderPaginator extends BasePaginator<ReminderResponseData, QueryRemindersOptions> {
5
+ export declare class ReminderPaginator extends BasePaginator<ReminderResponseData, QueryRemindersRequest> {
6
6
  private client;
7
7
  protected _filters: ReminderFilters | undefined;
8
- protected _sort: ReminderSort | undefined;
8
+ protected _sort: SortParamRequest[] | undefined;
9
9
  get filters(): ReminderFilters | undefined;
10
- get sort(): ReminderSort | undefined;
10
+ get sort(): SortParamRequest[] | undefined;
11
11
  set filters(filters: ReminderFilters | undefined);
12
- set sort(sort: ReminderSort | undefined);
13
- constructor(client: StreamChat, options?: PaginatorOptions<ReminderResponseData, QueryRemindersOptions>);
12
+ set sort(sort: SortParamRequest[] | undefined);
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<QueryRemindersOptions>, 'direction'>>): QueryRemindersOptions;
17
- query: ({ queryShape, }: PaginationQueryParams<QueryRemindersOptions>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
16
+ protected getNextQueryShape({ direction, }: Required<Pick<PaginationQueryParams<QueryRemindersRequest>, 'direction'>>): QueryRemindersRequest;
17
+ query: ({ queryShape, }: PaginationQueryParams<QueryRemindersRequest>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
18
18
  filterQueryResults: (items: ReminderResponseData[]) => ReminderResponseData[];
19
19
  }
@@ -0,0 +1,57 @@
1
+ import { BasePaginator } from './BasePaginator';
2
+ import type { PaginationQueryParams, PaginationQueryReturnValue, PaginatorOptions, PaginatorState } from './BasePaginator';
3
+ import type { StreamChat } from '../../client';
4
+ import { EntityStore } from '../../entityStore/EntityStore';
5
+ import type { Thread } from '../../thread';
6
+ import type { QueryThreadsRequest } from '../../types';
7
+ export declare const DEFAULT_THREAD_PAGE_SIZE = 25;
8
+ /** Per-page query options the thread list has always requested. */
9
+ export declare const DEFAULT_THREAD_QUERY: QueryThreadsRequest;
10
+ export type ThreadPaginatorOptions = {
11
+ client: StreamChat;
12
+ /** The store the list holds its threads in (`client.threads`' thread store). Omitted, it keeps a private one. */
13
+ store?: EntityStore<Thread>;
14
+ paginatorOptions?: PaginatorOptions<Thread, QueryThreadsRequest>;
15
+ };
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}).
23
+ */
24
+ export declare class ThreadPaginator extends BasePaginator<Thread, QueryThreadsRequest> {
25
+ private readonly client;
26
+ private readonly store;
27
+ 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
+ */
32
+ get initialState(): PaginatorState<Thread>;
33
+ getItemId(thread: Thread): string;
34
+ protected getNextQueryShape({ direction, }: Required<Pick<PaginationQueryParams<QueryThreadsRequest>, 'direction'>>): QueryThreadsRequest;
35
+ query: ({ queryShape, }: PaginationQueryParams<QueryThreadsRequest>) => Promise<PaginationQueryReturnValue<Thread>>;
36
+ /**
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.
40
+ */
41
+ private toStoredInstance;
42
+ filterQueryResults: (threads: Thread[]) => Thread[];
43
+ /**
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.
48
+ */
49
+ reload: ({ limit }?: {
50
+ limit?: number;
51
+ }) => 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
+ */
56
+ resetState(): void;
57
+ }