stream-chat 10.0.0-rc.8 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/README.md +7 -6
  2. package/dist/cjs/index.browser.js +22095 -22290
  3. package/dist/cjs/index.browser.js.map +4 -4
  4. package/dist/cjs/index.node.js +22143 -22298
  5. package/dist/cjs/index.node.js.map +4 -4
  6. package/dist/esm/index.mjs +22093 -22288
  7. package/dist/esm/index.mjs.map +4 -4
  8. package/dist/types/ChannelManager.d.ts +216 -135
  9. package/dist/types/CooldownTimer.d.ts +16 -27
  10. package/dist/types/EventHandlerPipeline.d.ts +18 -38
  11. package/dist/types/LiveLocationManager.d.ts +25 -47
  12. package/dist/types/api-client.d.ts +17 -5
  13. package/dist/types/channel.d.ts +435 -500
  14. package/dist/types/channel_state.d.ts +72 -112
  15. package/dist/types/client.d.ts +323 -440
  16. package/dist/types/client_state.d.ts +1 -3
  17. package/dist/types/configuration/ConfigController.d.ts +31 -125
  18. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +32 -124
  19. package/dist/types/configuration/keys.d.ts +5 -19
  20. package/dist/types/configuration/shape.d.ts +12 -29
  21. package/dist/types/configuration/types.d.ts +64 -79
  22. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +14 -36
  23. package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
  24. package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
  25. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
  26. package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
  27. package/dist/types/connection/ConnectionIdManager.d.ts +45 -0
  28. package/dist/types/connection/ConnectionRecoveryManager.d.ts +84 -0
  29. package/dist/types/connection/index.d.ts +4 -0
  30. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +82 -0
  31. package/dist/types/connection/networkConnection/index.d.ts +3 -0
  32. package/dist/types/connection/networkConnection/reporters.d.ts +20 -0
  33. package/dist/types/connection/networkConnection/types.d.ts +40 -0
  34. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +137 -0
  35. package/dist/types/connection/wsConnection/WSConnection.d.ts +105 -0
  36. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +47 -0
  37. package/dist/types/connection/wsConnection/config.d.ts +31 -0
  38. package/dist/types/connection/wsConnection/index.d.ts +4 -0
  39. package/dist/types/connection/wsConnection/types.d.ts +46 -0
  40. package/dist/types/constants.d.ts +3 -1
  41. package/dist/types/custom_types.d.ts +0 -2
  42. package/dist/types/entityStore/EntityStore.d.ts +226 -65
  43. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +19 -33
  44. package/dist/types/entityStore/index.d.ts +0 -1
  45. package/dist/types/errors.d.ts +16 -19
  46. package/dist/types/formatMessageMemo.d.ts +5 -0
  47. package/dist/types/gen/chat/ChannelApi.d.ts +5 -1
  48. package/dist/types/gen/chat/ChatApi.d.ts +149 -105
  49. package/dist/types/gen/models/index.d.ts +2540 -698
  50. package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
  51. package/dist/types/gen/moderation/ModerationApi.d.ts +37 -14
  52. package/dist/types/index.d.ts +10 -5
  53. package/dist/types/{i18n/languageNames.d.ts → languageNames.d.ts} +9 -24
  54. package/dist/types/logger.d.ts +1 -3
  55. package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
  56. package/dist/types/messageComposer/LocationComposer.d.ts +8 -2
  57. package/dist/types/messageComposer/attachmentIdentity.d.ts +24 -0
  58. package/dist/types/messageComposer/attachmentManager.d.ts +52 -24
  59. package/dist/types/messageComposer/attachmentUtils.d.ts +23 -0
  60. package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
  61. package/dist/types/messageComposer/configuration/types.d.ts +38 -50
  62. package/dist/types/messageComposer/index.d.ts +1 -0
  63. package/dist/types/messageComposer/linkPreviewsManager.d.ts +12 -9
  64. package/dist/types/messageComposer/messageComposer.d.ts +60 -123
  65. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +10 -1
  66. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +4 -0
  67. package/dist/types/messageComposer/middleware/messageComposer/commandInjection.d.ts +5 -0
  68. package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +2 -0
  69. package/dist/types/messageComposer/middleware/messageComposer/pollOnly.d.ts +6 -0
  70. package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +5 -0
  71. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
  72. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
  73. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +4 -0
  74. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +11 -2
  75. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +20 -19
  76. package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
  77. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
  78. package/dist/types/messageComposer/pollComposer.d.ts +15 -5
  79. package/dist/types/messageComposer/textComposer.d.ts +14 -7
  80. package/dist/types/messageComposer/types.d.ts +27 -7
  81. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +27 -80
  82. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +43 -73
  83. package/dist/types/messageOperations/FailedSendCache.d.ts +29 -0
  84. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +16 -22
  85. package/dist/types/messageOperations/MessageOperations.d.ts +63 -34
  86. package/dist/types/messageOperations/applyReactionLocally.d.ts +15 -0
  87. package/dist/types/messageOperations/createMessageOperations.d.ts +9 -0
  88. package/dist/types/messageOperations/index.d.ts +6 -4
  89. package/dist/types/messageOperations/reflectReactionEvent.d.ts +16 -0
  90. package/dist/types/messageOperations/sendOrdering.d.ts +14 -0
  91. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +20 -0
  92. package/dist/types/messageOperations/types.d.ts +43 -14
  93. package/dist/types/middleware.d.ts +10 -0
  94. package/dist/types/moderation.d.ts +21 -14
  95. package/dist/types/notifications/NotificationManager.d.ts +10 -23
  96. package/dist/types/notifications/types.d.ts +21 -57
  97. package/dist/types/offline-support/offline_support_api.d.ts +150 -528
  98. package/dist/types/offline-support/offline_sync_manager.d.ts +21 -42
  99. package/dist/types/offline-support/queueableOperations.d.ts +35 -37
  100. package/dist/types/offline-support/types.d.ts +40 -185
  101. package/dist/types/pagination/FilterBuilder.d.ts +1 -18
  102. package/dist/types/pagination/ItemIndex.d.ts +4 -12
  103. package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
  104. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +4 -5
  105. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +19 -5
  106. package/dist/types/pagination/index.d.ts +1 -0
  107. package/dist/types/pagination/paginators/BasePaginator.d.ts +604 -550
  108. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +123 -106
  109. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +576 -327
  110. package/dist/types/pagination/paginators/MessagePaginator.d.ts +237 -131
  111. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +15 -26
  112. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +4 -3
  113. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +44 -0
  114. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +5 -8
  115. package/dist/types/pagination/paginators/index.d.ts +1 -0
  116. package/dist/types/pagination/sortCompiler.d.ts +11 -22
  117. package/dist/types/pagination/utility.normalization.d.ts +8 -13
  118. package/dist/types/pagination/utility.search.d.ts +3 -8
  119. package/dist/types/poll.d.ts +35 -8
  120. package/dist/types/poll_manager.d.ts +12 -2
  121. package/dist/types/poll_optimistic_votes.d.ts +57 -0
  122. package/dist/types/reminders/Reminder.d.ts +17 -7
  123. package/dist/types/reminders/ReminderManager.d.ts +13 -25
  124. package/dist/types/search/BaseSearchSource.d.ts +10 -8
  125. package/dist/types/search/ChannelSearchSource.d.ts +16 -0
  126. package/dist/types/search/MessageSearchSource.d.ts +17 -0
  127. package/dist/types/search/SearchController.d.ts +26 -28
  128. package/dist/types/search/types.d.ts +6 -10
  129. package/dist/types/signing.d.ts +12 -3
  130. package/dist/types/thread.d.ts +67 -129
  131. package/dist/types/thread_manager.d.ts +95 -66
  132. package/dist/types/token_manager.d.ts +8 -13
  133. package/dist/types/types.d.ts +81 -197
  134. package/dist/types/types.utility.d.ts +3 -3
  135. package/dist/types/upload-utils.d.ts +5 -10
  136. package/dist/types/uploadManager.d.ts +31 -11
  137. package/dist/types/utils/FixedSizeQueueCache.d.ts +8 -11
  138. package/dist/types/utils/WithSubscriptions.d.ts +6 -16
  139. package/dist/types/utils/abort.d.ts +17 -0
  140. package/dist/types/utils/concurrency.d.ts +12 -20
  141. package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
  142. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
  143. package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
  144. package/dist/types/utils/objectPath.d.ts +6 -41
  145. package/dist/types/utils/retryable.d.ts +8 -12
  146. package/dist/types/utils/throttling/throttle.d.ts +8 -23
  147. package/dist/types/utils/time.d.ts +45 -0
  148. package/dist/types/utils.d.ts +74 -93
  149. package/package.json +14 -40
  150. package/src/ChannelManager.ts +494 -303
  151. package/src/CooldownTimer.ts +46 -59
  152. package/src/EventHandlerPipeline.ts +22 -45
  153. package/src/LiveLocationManager.ts +99 -91
  154. package/src/api-client.ts +113 -50
  155. package/src/campaign.ts +1 -1
  156. package/src/channel.ts +1098 -1351
  157. package/src/channel_batch_updater.ts +1 -1
  158. package/src/channel_state.ts +81 -174
  159. package/src/client.ts +755 -970
  160. package/src/client_state.ts +3 -8
  161. package/src/configuration/ConfigController.ts +42 -158
  162. package/src/configuration/InstanceConfigurationRegistry.ts +43 -172
  163. package/src/configuration/index.ts +1 -1
  164. package/src/configuration/keys.ts +13 -32
  165. package/src/configuration/shape.ts +169 -59
  166. package/src/configuration/types.ts +69 -92
  167. package/src/configuration/utils/applyInstanceConfiguration.ts +22 -54
  168. package/src/configuration/utils/copyConfigPatch.ts +11 -32
  169. package/src/configuration/utils/declarativeSlices.ts +9 -39
  170. package/src/configuration/utils/deepFreezeConfig.ts +3 -17
  171. package/src/configuration/utils/index.ts +2 -4
  172. package/src/configuration/utils/serverAuthority.ts +20 -68
  173. package/src/connection/ConnectionIdManager.ts +111 -0
  174. package/src/connection/ConnectionRecoveryManager.ts +257 -0
  175. package/src/connection/index.ts +4 -0
  176. package/src/connection/networkConnection/NetworkConnectionObserver.ts +204 -0
  177. package/src/connection/networkConnection/index.ts +3 -0
  178. package/src/connection/networkConnection/reporters.ts +58 -0
  179. package/src/connection/networkConnection/types.ts +45 -0
  180. package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +230 -231
  181. package/src/connection/wsConnection/WSConnection.ts +270 -0
  182. package/src/connection/wsConnection/WSConnectionFallback.ts +250 -0
  183. package/src/connection/wsConnection/config.ts +73 -0
  184. package/src/connection/wsConnection/index.ts +4 -0
  185. package/src/connection/wsConnection/types.ts +48 -0
  186. package/src/constants.ts +7 -5
  187. package/src/custom_types.ts +0 -1
  188. package/src/entityStore/EntityStore.ts +415 -79
  189. package/src/entityStore/StoreBackedItemIndex.ts +37 -41
  190. package/src/entityStore/index.ts +0 -1
  191. package/src/errors.ts +39 -20
  192. package/src/formatMessageMemo.ts +17 -0
  193. package/src/gen/chat/ChannelApi.ts +122 -36
  194. package/src/gen/chat/ChatApi.ts +578 -1752
  195. package/src/gen/models/index.ts +2566 -3440
  196. package/src/gen/models/timestamp-guard.ts +27 -0
  197. package/src/gen/moderation/ModerationApi.ts +183 -406
  198. package/src/index.ts +32 -10
  199. package/src/languageNames.ts +88 -0
  200. package/src/logger.ts +1 -3
  201. package/src/messageComposer/CustomDataManager.ts +19 -6
  202. package/src/messageComposer/LocationComposer.ts +49 -9
  203. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
  204. package/src/messageComposer/attachmentIdentity.ts +54 -0
  205. package/src/messageComposer/attachmentManager.ts +170 -185
  206. package/src/messageComposer/attachmentUtils.ts +44 -0
  207. package/src/messageComposer/configuration/configuration.ts +15 -8
  208. package/src/messageComposer/configuration/types.ts +38 -50
  209. package/src/messageComposer/fileUtils.ts +1 -1
  210. package/src/messageComposer/index.ts +1 -0
  211. package/src/messageComposer/linkPreviewsManager.ts +18 -21
  212. package/src/messageComposer/messageComposer.ts +234 -179
  213. package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
  214. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +46 -33
  215. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +4 -1
  216. package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +1 -1
  217. package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +6 -0
  218. package/src/messageComposer/middleware/messageComposer/attachments.ts +76 -5
  219. package/src/messageComposer/middleware/messageComposer/commandInjection.ts +10 -4
  220. package/src/messageComposer/middleware/messageComposer/customData.ts +17 -5
  221. package/src/messageComposer/middleware/messageComposer/index.ts +2 -0
  222. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +22 -12
  223. package/src/messageComposer/middleware/messageComposer/pollOnly.ts +9 -1
  224. package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
  225. package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
  226. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +12 -12
  227. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  228. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  229. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  230. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +8 -6
  231. package/src/messageComposer/middleware/textComposer/commandUtils.ts +10 -3
  232. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  233. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  234. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  235. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  236. package/src/messageComposer/pollComposer.ts +21 -9
  237. package/src/messageComposer/textComposer.ts +37 -57
  238. package/src/messageComposer/types.ts +39 -11
  239. package/src/messageDelivery/MessageDeliveryReporter.ts +86 -124
  240. package/src/messageDelivery/MessageReceiptsTracker.ts +122 -139
  241. package/src/messageOperations/FailedSendCache.ts +85 -0
  242. package/src/messageOperations/MessageOperationStatePolicy.ts +124 -116
  243. package/src/messageOperations/MessageOperations.ts +297 -175
  244. package/src/{entityStore → messageOperations}/applyReactionLocally.ts +13 -25
  245. package/src/messageOperations/createMessageOperations.ts +176 -0
  246. package/src/messageOperations/index.ts +6 -14
  247. package/src/messageOperations/reflectReactionEvent.ts +43 -0
  248. package/src/messageOperations/sendOrdering.ts +25 -0
  249. package/src/messageOperations/settlePendingAttachmentUploads.ts +98 -0
  250. package/src/messageOperations/types.ts +51 -13
  251. package/src/middleware.ts +13 -5
  252. package/src/moderation.ts +25 -21
  253. package/src/notifications/NotificationManager.ts +19 -28
  254. package/src/notifications/types.ts +21 -57
  255. package/src/offline-support/offline_support_api.ts +231 -681
  256. package/src/offline-support/offline_sync_manager.ts +51 -90
  257. package/src/offline-support/queueableOperations.ts +98 -73
  258. package/src/offline-support/types.ts +43 -185
  259. package/src/pagination/FilterBuilder.ts +1 -22
  260. package/src/pagination/ItemIndex.ts +4 -12
  261. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  262. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +17 -62
  263. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  264. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +53 -33
  265. package/src/pagination/filterCompiler.ts +11 -25
  266. package/src/pagination/index.ts +1 -0
  267. package/src/pagination/paginators/BasePaginator.ts +1415 -1041
  268. package/src/pagination/paginators/ChannelPaginator.ts +481 -219
  269. package/src/pagination/paginators/MessageIntervalPaginator.ts +1362 -775
  270. package/src/pagination/paginators/MessagePaginator.ts +521 -240
  271. package/src/pagination/paginators/PinnedMessagePaginator.ts +32 -40
  272. package/src/pagination/paginators/ReminderPaginator.ts +21 -16
  273. package/src/pagination/paginators/ThreadPaginator.ts +170 -0
  274. package/src/pagination/paginators/UserGroupPaginator.ts +18 -15
  275. package/src/pagination/paginators/index.ts +1 -0
  276. package/src/pagination/paginators/stateThrottling.ts +5 -10
  277. package/src/pagination/sortCompiler.ts +23 -50
  278. package/src/pagination/utility.normalization.ts +17 -24
  279. package/src/pagination/utility.search.ts +4 -11
  280. package/src/poll.ts +183 -102
  281. package/src/poll_manager.ts +24 -22
  282. package/src/poll_optimistic_votes.ts +335 -0
  283. package/src/reminders/Reminder.ts +33 -16
  284. package/src/reminders/ReminderManager.ts +23 -56
  285. package/src/reminders/ReminderTimer.ts +6 -6
  286. package/src/search/BaseSearchSource.ts +19 -25
  287. package/src/search/ChannelSearchSource.ts +43 -1
  288. package/src/search/MessageSearchSource.ts +77 -13
  289. package/src/search/SearchController.ts +39 -36
  290. package/src/search/types.ts +6 -10
  291. package/src/segment.ts +1 -1
  292. package/src/signing.ts +23 -3
  293. package/src/thread.ts +430 -712
  294. package/src/thread_manager.ts +300 -234
  295. package/src/token_manager.ts +12 -22
  296. package/src/types.ts +102 -214
  297. package/src/types.utility.ts +3 -3
  298. package/src/upload-utils.ts +5 -10
  299. package/src/uploadManager.ts +64 -18
  300. package/src/utils/FixedSizeQueueCache.ts +18 -21
  301. package/src/utils/WithSubscriptions.ts +6 -16
  302. package/src/utils/abort.ts +45 -0
  303. package/src/utils/concurrency.ts +16 -55
  304. package/src/utils/mergeWith/mergeWith.ts +10 -13
  305. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  306. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  307. package/src/utils/objectPath.ts +6 -41
  308. package/src/utils/retryable.ts +10 -14
  309. package/src/utils/throttling/throttle.ts +9 -25
  310. package/src/utils/time.ts +64 -0
  311. package/src/utils.ts +227 -174
  312. package/codegen/i18n/callSites.ts +0 -126
  313. package/codegen/i18n/generate.ts +0 -226
  314. package/codegen/i18n/guards.ts +0 -178
  315. package/codegen/i18n/index.ts +0 -29
  316. package/codegen/i18n/stringMaps.ts +0 -91
  317. package/codegen/i18n/types.ts +0 -100
  318. package/dist/cjs/i18n.browser.js +0 -1131
  319. package/dist/cjs/i18n.browser.js.map +0 -7
  320. package/dist/cjs/i18n.node.js +0 -1160
  321. package/dist/cjs/i18n.node.js.map +0 -7
  322. package/dist/esm/i18n-codegen.mjs +0 -409
  323. package/dist/esm/i18n-codegen.mjs.map +0 -7
  324. package/dist/esm/i18n.mjs +0 -1098
  325. package/dist/esm/i18n.mjs.map +0 -7
  326. package/dist/types/ConnectionRecoveryManager.d.ts +0 -156
  327. package/dist/types/connection.d.ts +0 -139
  328. package/dist/types/entityStore/applyReactionLocally.d.ts +0 -26
  329. package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
  330. package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
  331. package/dist/types/i18n/Streami18n.d.ts +0 -168
  332. package/dist/types/i18n/TranslationBuilder.d.ts +0 -70
  333. package/dist/types/i18n/TranslationStore.d.ts +0 -57
  334. package/dist/types/i18n/dayjs.d.ts +0 -104
  335. package/dist/types/i18n/formatters.d.ts +0 -91
  336. package/dist/types/i18n/index.d.ts +0 -15
  337. package/dist/types/i18n/translator.d.ts +0 -29
  338. package/dist/types/i18n/types.d.ts +0 -262
  339. package/dist/types/i18n-codegen/callSites.d.ts +0 -10
  340. package/dist/types/i18n-codegen/generate.d.ts +0 -15
  341. package/dist/types/i18n-codegen/guards.d.ts +0 -61
  342. package/dist/types/i18n-codegen/index.d.ts +0 -29
  343. package/dist/types/i18n-codegen/stringMaps.d.ts +0 -14
  344. package/dist/types/i18n-codegen/types.d.ts +0 -94
  345. package/dist/types/insights.d.ts +0 -56
  346. package/dist/types/messageOperations/optimistic.d.ts +0 -118
  347. package/dist/types/messageOperations/persistence.d.ts +0 -21
  348. package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
  349. package/dist/types/store.d.ts +0 -125
  350. package/src/ConnectionRecoveryManager.ts +0 -293
  351. package/src/gen/model-decoders/decoders.ts +0 -2710
  352. package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
  353. package/src/i18n/Streami18n.ts +0 -520
  354. package/src/i18n/TranslationBuilder.ts +0 -176
  355. package/src/i18n/TranslationStore.ts +0 -96
  356. package/src/i18n/dayjs.ts +0 -228
  357. package/src/i18n/formatters.ts +0 -461
  358. package/src/i18n/index.ts +0 -15
  359. package/src/i18n/languageNames.ts +0 -103
  360. package/src/i18n/translator.ts +0 -76
  361. package/src/i18n/types.ts +0 -375
  362. package/src/insights.ts +0 -82
  363. package/src/messageOperations/optimistic.ts +0 -249
  364. package/src/messageOperations/persistence.ts +0 -40
  365. package/src/pagination/utility.queryChannel.ts +0 -84
  366. package/src/store.ts +0 -304
@@ -1,33 +1,30 @@
1
1
  import { EventHandlerPipeline } from './EventHandlerPipeline';
2
2
  import { WithSubscriptions } from './utils/WithSubscriptions';
3
- import type { EventType } from './types';
3
+ import type { ChannelInput, ChannelStateResponseFields, EventType } from './types';
4
4
  import type { ChannelPaginator } from './pagination';
5
5
  import type { StreamChat } from './client';
6
- import type { Unsubscribe } from './store';
7
- import { StateStore } from './store';
6
+ import type { Unsubscribe } from '@stream-io/state-store';
7
+ import { StateStore } from '@stream-io/state-store';
8
8
  import type { EventHandlerPipelineHandler, FindEventHandlerParams, InsertEventHandlerPayload, LabeledEventHandler } from './EventHandlerPipeline';
9
- import type { Channel } from './channel';
9
+ import { Channel } from './channel';
10
+ import { EntityStore } from './entityStore/EntityStore';
10
11
  export type ChannelManagerEventHandlerContext = {
11
12
  channelManager: ChannelManager;
12
13
  };
13
14
  type EventHandlerContext = ChannelManagerEventHandlerContext;
14
15
  type SupportedEventType = EventType | (string & {});
15
16
  /**
16
- * Resolves which paginators should be the "owners" of a channel
17
- * when the channel matches multiple paginator filters.
18
- *
19
- * Return a set of paginator ids that should keep/own the item.
20
- * Returning an empty set means the channel will be removed everywhere.
17
+ * Picks which paginators own a channel that matches several, by returning their IDs. An empty list
18
+ * means every matching paginator keeps it.
21
19
  */
22
20
  export type PaginatorOwnershipResolver = (args: {
23
21
  channel: Channel;
24
22
  matchingPaginators: ChannelPaginator[];
25
23
  }) => string[];
26
24
  /**
27
- * Convenience factory for a priority-based ownership resolver.
28
- * - Provide an ordered list of paginator ids from highest to lowest priority.
29
- * - If two or more paginators match a channel, the one with the highest priority wins.
30
- * - If none of the matching paginator ids are in the priority list, all matches are kept (back-compat).
25
+ * Priority-based ownership resolver. `priority` lists paginator IDs from highest to lowest: of the
26
+ * paginators matching a channel, the highest-priority one owns it. If none of them is listed, all
27
+ * keep it.
31
28
  */
32
29
  export declare const createPriorityOwnershipResolver: (priority?: string[]) => PaginatorOwnershipResolver;
33
30
  export declare const ignoreEventsForUnknownChannels: EventHandlerPipelineHandler<EventHandlerContext>;
@@ -39,175 +36,272 @@ export type ChannelManagerOptions = {
39
36
  client: StreamChat;
40
37
  paginators?: ChannelPaginator[];
41
38
  /**
42
- * The complete set of event handlers to run, replacing the defaults rather than extending them.
43
- * Start from `ChannelManager.getDefaultHandlers()` (a fresh copy) and enrich it, unless the
44
- * intention really is to route events differently from scratch. Note that the manager the client
45
- * instantiates (`client.channelManager`) is constructed without this option — customize that one
46
- * through `addEventHandler` / `setEventHandlers` / `removeEventHandlers`.
39
+ * The complete set of event handlers, replacing the defaults. Start from
40
+ * `ChannelManager.getDefaultHandlers()` (a copy) and enrich it. `client.channelManager` is built
41
+ * without this option: customize it through `addEventHandler` / `setEventHandlers` /
42
+ * `removeEventHandlers`.
47
43
  */
48
44
  eventHandlers?: ChannelManagerEventHandlers;
49
45
  /**
50
- * Decide which paginator(s) should own a channel when multiple match.
51
- * Defaults to keeping the channel in all matching paginators.
52
- * Channels are kept only in the paginators that are listed in the ownershipResolver array.
53
- * Empty ownershipResolver array means that the channel is kept in all matching paginators.
46
+ * Picks which paginator(s) own a channel that matches several. Defaults to all of them. A function
47
+ * returns the owning paginator IDs; an array is a priority list (highest first), so the
48
+ * highest-priority match owns the channel, and if none of them is listed all keep it.
54
49
  */
55
50
  ownershipResolver?: PaginatorOwnershipResolver | string[];
56
51
  };
52
+ /**
53
+ * A stored channel, its store key, and what keeps it: its own state (`'watched'`, `'active'`,
54
+ * `'querying-channel'`) and the names of its holders. If none, `releaseUnusedChannels()` removes
55
+ * it.
56
+ */
57
+ export type ChannelUsage = {
58
+ channel: Channel;
59
+ key: string;
60
+ keptBy: string[];
61
+ };
57
62
  export declare class ChannelManager extends WithSubscriptions {
58
63
  client: StreamChat;
59
64
  state: StateStore<ChannelManagerState>;
65
+ /**
66
+ * Every `Channel`, one per cid (a channel created from members sits under a temporary cid until
67
+ * {@link ChannelManager.changeChannelId}). A channel stays until it is deleted, the user is
68
+ * removed from it or logs out, or {@link ChannelManager.releaseUnusedChannels} removes it;
69
+ * removal runs {@link Channel.disconnect}. Lists hold the channels they show by linking them,
70
+ * others by claims.
71
+ *
72
+ * @internal
73
+ */
74
+ readonly channelStore: EntityStore<Channel>;
60
75
  protected _pipelines: Map<SupportedEventType, EventHandlerPipeline<ChannelManagerEventHandlerContext>>;
61
76
  protected ownershipResolver?: PaginatorOwnershipResolver;
62
77
  /**
63
- * The `filterQueryResults` each registered paginator had before this manager wrapped it.
64
- *
65
- * A server query bypasses the manager — the paginator fetches and ingests a page on its own, and
66
- * the backend knows nothing about client-side ownership — so a "Work" (`{ team: 'work' }`) channel
67
- * comes back in a catch-all list's page too and would render in both. `wrapPaginatorFiltering`
68
- * therefore composes the ownership check onto that hook, which every page passes through.
69
- *
70
- * Keys = already wrapped (so re-inserting does not wrap twice); values = what to restore on
71
- * removal, since a detached paginator must stop applying rules resolved against lists it left.
72
- * Weakly keyed so a dropped paginator is not kept alive by this manager.
78
+ * Instances replaced by a stored one ({@link ChannelManager.supersedeChannel}). Not in the store,
79
+ * so they are disconnected at logout ({@link ChannelManager.clearChannels}).
80
+ */
81
+ private readonly supersededChannels;
82
+ /**
83
+ * The `filterQueryResults` each registered paginator had before `wrapPaginatorFiltering` wrapped
84
+ * it. Keys mark paginators already wrapped, values are restored on removal. Weakly keyed.
73
85
  */
74
86
  protected filterQueryResultsBeforeWrapping: WeakMap<ChannelPaginator, (items: Channel[]) => Channel[]>;
75
87
  protected static readonly defaultEventHandlers: ChannelManagerEventHandlers;
76
88
  constructor({ client, eventHandlers, paginators, ownershipResolver, }: ChannelManagerOptions);
77
89
  get paginators(): ChannelPaginator[];
78
- get pipelines(): Map<SupportedEventType, EventHandlerPipeline<EventHandlerContext>>;
79
- private get ctx();
80
90
  /**
81
- * Returns deep copy of default handlers mapping.
82
- * The defaults can be enriched with custom handlers or the custom handlers can be replaced.
91
+ * Returns the stored channel for a cid.
92
+ *
93
+ * @param cid - The channel's cid.
94
+ * @returns The stored channel, or `undefined` when none is stored.
83
95
  */
84
- static getDefaultHandlers(): ChannelManagerEventHandlers;
96
+ get(cid: string): Channel | undefined;
85
97
  /**
86
- * Replace the rule deciding which paginator(s) own a channel matched by several of them. Pass an
87
- * ordered array of paginator ids (highest priority first) for the built-in priority resolver, a
88
- * custom resolver function, or `undefined` to go back to the default (a channel is kept in every
89
- * paginator whose filter it matches).
98
+ * The instance a channel list should show for `channel`: the one that superseded it, else the one
99
+ * stored under its cid, else `channel` itself, so a list never displaces the stored instance.
100
+ * `undefined` when that instance is disconnected (`pendingDisposal`): it receives no events.
90
101
  *
91
- * Available as a setter because the manager is constructed by the client, before the app has had
92
- * a chance to create its paginators — their ids are therefore only known later.
102
+ * @internal
93
103
  */
94
- setOwnershipResolver(ownershipResolver?: PaginatorOwnershipResolver | string[]): void;
104
+ resolveListedChannel(channel: Channel): Channel | undefined;
95
105
  /**
96
- * Which paginators should own the channel among the ones that matched.
97
- * Default behavior keeps the channel in all matching paginators.
106
+ * Returns every stored channel.
107
+ *
108
+ * @returns The stored channels.
98
109
  */
99
- resolveOwnership(channel: Channel, matchingPaginators: ChannelPaginator[]): Set<string>;
110
+ values(): Channel[];
100
111
  /**
101
- * Route a channel into the paginator(s) that should own it, and remove it from any list it
102
- * no longer belongs to. Ownership is resolved exactly as for live WS updates — the channel is
103
- * ingested into every paginator whose filter it matches (or, when an ownership resolver picks
104
- * winners among several matches, only into the owner(s)).
112
+ * Returns the stored channel for `type` and `id`, or creates and stores it (one instance per cid;
113
+ * a stored `pendingDisposal` channel is replaced by a fresh one). Without `id`, the distinct
114
+ * channel between `data.members` (see {@link StreamChat.channel}, which documents both).
105
115
  *
106
- * Use this to surface a channel the app just opened — a search result, a freshly created DM —
107
- * in the list(s) without a full re-query. `ingestItem` dedupes by cid and inserts in sort
108
- * order, so calling this repeatedly is safe.
116
+ * Apps call {@link StreamChat.channel}, the public equivalent.
109
117
  *
110
- * A channel that matches no paginator is not added anywhere. To have such channels still
111
- * appear, register a catch-all paginator (empty filter) with the lowest ownership priority as
112
- * a local fallback list.
118
+ * @param params.type - The channel type.
119
+ * @param params.id - The channel ID; leave it out for a distinct channel created from members.
120
+ * @param params.data - Data for a new channel (members, custom fields). For a stored channel only
121
+ * `data.custom` is applied.
122
+ * @returns The channel; initialize it with `channel.watch()`.
123
+ * @internal
113
124
  */
114
- ingestChannel(channel: Channel): void;
125
+ ensure({ data, id, type, }: {
126
+ type: string;
127
+ id?: string | null;
128
+ data?: ChannelInput;
129
+ }): Channel;
130
+ private ensureById;
131
+ private ensureByMembers;
115
132
  /**
116
- * Drops a channel from the lists whose filters it no longer matches, adding it nowhere.
133
+ * Returns the channel stored under `cid`, passing it to `hydrate`, or stores and returns the result
134
+ * of `create`.
117
135
  *
118
- * For state the client changes without an event naming the channel — zeroing every unread count on a
119
- * global read. Removal-only: the backend rejects `has_unread: false`, so becoming read can never make
120
- * a channel belong to a list, and `ingestChannel` would pull unloaded channels into matching ones.
136
+ * @internal
121
137
  */
122
- dropFromUnmatchedLists(channel: Channel): void;
138
+ getOrCreateChannel(cid: string, create: () => Channel, hydrate?: (stored: Channel) => void): Channel;
139
+ /**
140
+ * Moves a channel from its temporary cid to the one the server assigned (see `Channel.query`).
141
+ * Returns `false` when `oldCid` isn't stored or `newCid` already holds another channel.
142
+ *
143
+ * @internal
144
+ */
145
+ changeChannelId(oldCid: string, newCid: string): boolean;
146
+ /**
147
+ * `previous`, created without an ID, was answered with a cid `successor` already holds (stored by
148
+ * an event or a list meanwhile). `successor` stays the one instance and takes over: the response
149
+ * is applied to it like a `queryChannels` result (local messages are never removed),
150
+ * `previous`'s local messages (sending or failed) are added by ID (`successor`'s copy wins), and
151
+ * `previous`'s composer moves over when `previous` is open and `successor` is not.
152
+ *
153
+ * `successor` is marked watched only when the query asked to watch. `previous` is dropped from
154
+ * the store (`storedUnder`) without disconnecting, as it may be on screen, marked superseded
155
+ * (`state.supersededBy`) so its holders switch over, and disconnected at logout.
156
+ *
157
+ * @internal
158
+ */
159
+ supersedeChannel(previous: Channel, successor: Channel, response: ChannelStateResponseFields, { storedUnder, watch }?: {
160
+ storedUnder?: string;
161
+ watch?: boolean;
162
+ }): void;
163
+ /**
164
+ * Removes every stored channel the app disconnected (`pendingDisposal`), whatever holds it, then
165
+ * every one that is neither watched nor held; lists drop them. Kept: watched channels
166
+ * (`watching`, or `wasWatching` until restored), active ones ({@link Channel.activate}), ones
167
+ * being queried (`Channel.isQueryingChannel`), and ones held in
168
+ * {@link ChannelManager.channelStore} (lists link theirs; threads, the composer cache and channel
169
+ * search hold theirs through claims, {@link EntityStore.addClaim}).
170
+ *
171
+ * The SDK never calls this, as it cannot see channels an app keeps in its own state. Call it when
172
+ * the app is done with them (e.g. after `searchController.dispose()`), and keep a channel your
173
+ * code still uses with {@link Channel.activate} first.
174
+ */
175
+ releaseUnusedChannels(): void;
176
+ /**
177
+ * Every stored channel with what keeps it, by the rule of
178
+ * {@link ChannelManager.releaseUnusedChannels}. For debugging tools.
179
+ *
180
+ * @internal
181
+ */
182
+ getChannelUsage(): ChannelUsage[];
123
183
  /**
124
- * Filter a page of query results for a specific paginator according to ownership rules.
125
- * If no owners are specified by the resolver, all matching paginators keep the item.
184
+ * Removes the channel stored under `cid` whatever uses it, and disconnects it
185
+ * ({@link Channel.disconnect}). Every list showing it drops it too.
186
+ *
187
+ * @internal
126
188
  */
189
+ removeChannel(cid: string): void;
190
+ /**
191
+ * Removes and disconnects ({@link Channel.disconnect}) every stored channel, and every superseded
192
+ * one.
193
+ *
194
+ * @internal
195
+ */
196
+ clearChannels(): void;
197
+ /**
198
+ * Fans the client-owned `mutedChannels` out to every stored channel's `state.muteStatus` (a
199
+ * channel republishes only when its status changed, as this runs on every `health.check`).
200
+ *
201
+ * @internal
202
+ */
203
+ reflectMutedChannels(): void;
204
+ /**
205
+ * Resets the AI indicator state to `Idle` on every stored channel. Invoked from
206
+ * `closeConnection`, a deliberate shutdown that triggers no WS event.
207
+ *
208
+ * @internal
209
+ */
210
+ resetAIStateOnChannels(): void;
211
+ /**
212
+ * Demotes every `Watching` channel to `WasWatching`: the server keys watches by connection ID, so
213
+ * a dropped socket ends them all. Channels stopped on purpose or disconnected stay `NotWatching`.
214
+ * Called when the socket goes unhealthy or offline (`StableWSConnection`, `WSConnectionFallback`)
215
+ * and by `closeConnection()`, whose `disconnect()` writes health through `_applyHealth` and never
216
+ * reaches `_setHealth`.
217
+ *
218
+ * @internal
219
+ */
220
+ markChannelsWatchInterrupted(): void;
221
+ get pipelines(): Map<SupportedEventType, EventHandlerPipeline<EventHandlerContext>>;
222
+ private get ctx();
223
+ /** Returns a copy of the default handler mapping, to enrich or replace. */
224
+ static getDefaultHandlers(): ChannelManagerEventHandlers;
225
+ /**
226
+ * Sets the rule deciding which paginator(s) own a channel matched by several. Pass paginator IDs
227
+ * (highest priority first) for the built-in priority resolver, a custom resolver, or `undefined`
228
+ * for the default (every matching paginator keeps the channel). A setter because the client
229
+ * builds the manager before the app creates its paginators.
230
+ */
231
+ setOwnershipResolver(ownershipResolver?: PaginatorOwnershipResolver | string[]): void;
232
+ /** Ids of the paginators that own the channel among the matches. Empty: all of them. */
233
+ resolveOwnership(channel: Channel, matchingPaginators: ChannelPaginator[]): Set<string>;
234
+ /**
235
+ * Routes a channel into the paginator(s) that own it and removes it from any list it no longer
236
+ * belongs to, as for live WS updates. Use it to surface a channel the app just opened (a search
237
+ * result, a new DM) without a re-query; repeated calls are safe. A channel created from members
238
+ * is ignored until its first query gives it an ID. A channel matching no paginator is added
239
+ * nowhere: register a catch-all paginator (empty filter) with the lowest ownership priority as a
240
+ * fallback.
241
+ */
242
+ ingestChannel(input: Channel): void;
243
+ /**
244
+ * Drops a channel from the lists whose filters it no longer matches, adding it nowhere. For state
245
+ * the client changes without an event naming the channel (e.g. zeroing every unread count on a
246
+ * global read). Removal-only: becoming read cannot make a channel belong to a list (the backend
247
+ * rejects `has_unread: false`).
248
+ */
249
+ dropFromUnmatchedLists(channel: Channel): void;
250
+ /** Filters a page of query results for `paginator` by ownership (no owners: all matches keep). */
127
251
  protected filterItemsByOwnership({ paginator, items, }: {
128
252
  paginator: ChannelPaginator;
129
253
  items: Channel[];
130
254
  }): Channel[];
131
255
  /**
132
- * Makes a registered paginator apply this manager's ownership rules to the pages it fetches
133
- * itself, by composing `filterItemsByOwnership` onto its `filterQueryResults`.
134
- *
135
- * A channel can enter a list through two doors, and only one of them goes through the manager:
136
- * - **WS events / `ingestChannel`** — the manager routes the channel and consults
137
- * `resolveOwnership` before ingesting, so exclusivity holds by construction.
138
- * - **A server query** — `paginator.next()` (a `ChannelList` scrolling, `reload()`) queries and
139
- * ingests on its own; the manager is not involved. Without this wrapper a page would land in
140
- * every list whose *server-side* filter matched it, so a channel matching both
141
- * `channels:archived` and `channels:default` would show up in both lists until some later event
142
- * re-routed it — the exact duplication the resolver exists to prevent.
143
- *
144
- * Wrapping (rather than subclassing or a constructor hook) is what lets the manager inject this
145
- * into paginators it does not construct: `filterQueryResults` is an instance property, so the
146
- * original is captured here and handed back by `unwrapPaginatorFiltering` when the paginator is
147
- * detached. The paginator's own filtering runs first and stays authoritative — ownership only ever
148
- * removes further items, never adds any back.
149
- *
150
- * Idempotent: the `WeakMap` guard keeps a re-inserted paginator from being wrapped twice, which
151
- * would filter the same page repeatedly and, worse, lose the reference to the true original.
256
+ * Makes a registered paginator apply the ownership rules to the pages it fetches itself (server
257
+ * queries bypass the manager), by composing `filterItemsByOwnership` onto its
258
+ * `filterQueryResults`. Its own filtering runs first. Idempotent: wrapping twice would lose the
259
+ * true original.
152
260
  */
153
261
  protected wrapPaginatorFiltering(paginator: ChannelPaginator): void;
154
262
  /**
155
- * Undo `wrapPaginatorFiltering` — restore the `filterQueryResults` the paginator had before this
156
- * manager wrapped it. A paginator that has left the manager must not keep applying its ownership
157
- * rules: those are resolved against the paginators the manager still holds, so a detached
158
- * paginator would drop channels owned by lists it is no longer part of.
263
+ * Restores the `filterQueryResults` the paginator had before `wrapPaginatorFiltering`: a detached
264
+ * paginator must not keep applying ownership rules resolved against lists it left.
159
265
  */
160
266
  protected unwrapPaginatorFiltering(paginator: ChannelPaginator): void;
161
267
  getPaginatorById(id: string): ChannelPaginator | undefined;
162
268
  /**
163
- * Replace the whole set of lists in a single state update — the primitive `insertPaginator` and
164
- * `removePaginator` build on, and what to use for a wholesale swap instead of publishing an
165
- * intermediate state per step. Paginators dropped from the set are detached exactly as
166
- * `removePaginator` detaches them; a repeated id keeps only its first occurrence.
269
+ * Replaces the whole set of lists in one state update (the primitive `insertPaginator` and
270
+ * `removePaginator` build on). Dropped paginators are detached as `removePaginator` does; a
271
+ * repeated ID keeps only its first occurrence.
167
272
  *
168
273
  * @param paginators - The lists this manager should hold, in render order.
169
274
  */
170
275
  setPaginators(paginators: ChannelPaginator[]): void;
171
276
  /**
172
- * Detach every list at once — the teardown counterpart of `setPaginators`. Each paginator is
173
- * released exactly as `removePaginator` releases it (ownership-filtering wrapper removed,
174
- * scheduled query canceled, loaded items kept), in a single state update.
277
+ * Detaches every list as `removePaginator` does, in one update.
175
278
  *
176
279
  * @returns The paginators the manager held, in the order it held them.
177
280
  */
178
281
  clearPaginators(): ChannelPaginator[];
179
282
  /**
180
- * If paginator already exists → remove old, reinsert at new index.
181
- * If index not provided → append at the end.
182
- * If index provided → insert (or move) at that index.
283
+ * Inserts a paginator. One already held with the same ID is removed first, so this moves it, or
284
+ * replaces it when it is another instance.
183
285
  *
184
- * @param params - The insertion parameters.
185
286
  * @param params.paginator - The paginator to insert or move.
186
- * @param params.index - Target index; when omitted the paginator is appended.
287
+ * @param params.index - Target index, clamped to the list. Defaults to appending.
187
288
  */
188
289
  insertPaginator({ paginator, index }: {
189
290
  paginator: ChannelPaginator;
190
291
  index?: number;
191
292
  }): void;
192
293
  /**
193
- * Remove a paginator from the manager. The paginator stops receiving WS-driven updates and
194
- * disappears from `state.paginators` (so UIs rendering one list per paginator drop its list), and
195
- * gets its own `filterQueryResults` back — from here on it is an independent paginator again.
196
- *
197
- * Its loaded items are left untouched: the paginator can be re-inserted later, or kept and
198
- * queried on its own. Any query scheduled through `nextDebounced` is canceled, so a list that was
199
- * just removed does not fire one more request.
294
+ * Removes a paginator: it leaves `state.paginators`, stops receiving WS-driven updates and gets
295
+ * its own `filterQueryResults` back. Its loaded items stay, and a query scheduled through
296
+ * `toTailDebounced` or `toHeadDebounced` is cancelled.
200
297
  *
201
- * @param paginatorOrId - The paginator to remove, or its id.
298
+ * @param paginatorOrId - The paginator to remove, or its ID.
202
299
  * @returns The removed paginator, or `undefined` when this manager did not hold it.
203
300
  */
204
301
  removePaginator(paginatorOrId: ChannelPaginator | string): ChannelPaginator | undefined;
205
302
  /**
206
- * Discard the loaded data of every registered list, keeping the registrations themselves: which
207
- * lists exist is application configuration, while the channels in them belong to the connected
208
- * user and become invalid on `disconnectUser`. Each paginator returns to "never queried"
209
- * (`items: undefined`) with its debounced query canceled. Deliberately not named `resetState` —
210
- * this manager's own `state` *is* the paginator list, which this must not touch.
303
+ * Discards the loaded data of every registered list but keeps the registrations: each paginator
304
+ * returns to "never queried" (`items: undefined`) with its debounced query cancelled.
211
305
  */
212
306
  resetPaginatorStates(): void;
213
307
  addEventHandler({ eventType, ...payload }: {
@@ -221,31 +315,18 @@ export declare class ChannelManager extends WithSubscriptions {
221
315
  eventType: SupportedEventType;
222
316
  handlers: FindEventHandlerParams<EventHandlerContext>[];
223
317
  }): void;
224
- /** Subscribe to WS (and more buses via attachBus) */
318
+ /** Subscribes to client events. The returned function releases this registration. */
225
319
  registerSubscriptions(): Unsubscribe;
226
320
  ensurePipeline(eventType: SupportedEventType): EventHandlerPipeline<EventHandlerContext>;
227
321
  reload: () => Promise<PromiseSettledResult<void>[]>;
228
322
  /**
229
- * Re-run every loaded list's own first-page query — the channel-list half of connection recovery,
230
- * driven by {@link ConnectionRecoveryManager}.
231
- *
232
- * Each list re-asserts its *own* `filters` / `sort` / `pageSize` rather than some substitute query,
233
- * and because `client.queryChannels` watches by default, that page's channels are re-watched as a
234
- * side effect. Channels below the first page are deliberately not touched — see
235
- * `restoreInterruptedWatch` for how they come back.
236
- *
237
- * `{ keepPreviousItems: true, reset: 'yes' }` is the non-destructive refresh: `reset` restarts the
238
- * window at page 1, while `keepPreviousItems` merges the fetched page into the loaded list instead
239
- * of replacing it and keeps the item index populated — the latter is what stops a concurrent
240
- * offline-replay ingest from rebuilding the list out of a cleared index. Notably NOT `silent`: the
241
- * `isLoading` transition it would suppress is the in-flight guard that keeps a second overlapping
242
- * query from being issued.
243
- *
244
- * Distinct from {@link ChannelManager.reload}, which is a destructive `reset` that blanks each list
245
- * to its loading state.
246
- *
247
- * Paginators that were never queried are skipped: they run their own first query when they mount,
248
- * and querying them here would race it.
323
+ * Re-runs every loaded list's own first-page query, the channel-list half of connection recovery
324
+ * ({@link ConnectionRecoveryManager}). The page's channels are re-watched (`queryChannels`
325
+ * watches by default), those below it come back through `restoreInterruptedWatch`.
326
+ * Never-queried paginators are skipped: they run their own first query on mount, and querying them
327
+ * here would race it. Unlike {@link ChannelManager.reload}, it merges the page into the loaded
328
+ * list (`keepPreviousItems`) instead of blanking it. Its pages are `silent` so paging is held while it
329
+ * runs and a recovery asked for meanwhile supersedes it (see `ChannelPaginator.recoverLoadedItems`).
249
330
  */
250
331
  recover: () => Promise<PromiseSettledResult<void>[]>;
251
332
  }
@@ -1,22 +1,15 @@
1
- import { StateStore } from './store';
1
+ import { StateStore } from '@stream-io/state-store';
2
+ import type { TimestampNS } from './types';
2
3
  import { WithSubscriptions } from './utils/WithSubscriptions';
3
4
  import type { Channel } from './channel';
4
5
  export type CooldownTimerState = {
5
- /**
6
- * Slow mode cooldown interval in seconds. Change reported via channel.updated WS event.
7
- */
6
+ /** Slow mode cooldown interval in seconds. Change reported via channel.updated WS event. */
8
7
  cooldownConfigSeconds: number;
9
- /**
10
- * Whether the current user can skip slow mode. Change is not reported via WS.
11
- */
8
+ /** Whether the current user can skip slow mode. Change is not reported via WS. */
12
9
  canSkipCooldown: boolean;
13
- /**
14
- * Latest message creation date authored by the current user in this channel. Change reported via message.new WS event.
15
- */
16
- ownLatestMessageDate?: Date;
17
- /**
18
- * Remaining cooldown in whole seconds (rounded).
19
- */
10
+ /** Creation time of the current user's latest message in this channel, in unix nanoseconds. */
11
+ ownLatestMessageTimestamp?: TimestampNS;
12
+ /** Remaining cooldown in whole seconds (rounded). */
20
13
  cooldownRemaining: number;
21
14
  };
22
15
  export declare class CooldownTimer extends WithSubscriptions {
@@ -29,27 +22,23 @@ export declare class CooldownTimer extends WithSubscriptions {
29
22
  get cooldownConfigSeconds(): number;
30
23
  get cooldownRemaining(): number;
31
24
  get canSkipCooldown(): boolean;
32
- get ownLatestMessageDate(): Date | undefined;
25
+ get ownLatestMessageTimestamp(): TimestampNS | undefined;
33
26
  /**
34
- * Subscribes the timer to the two stores it derives from — `channel.state` for `cooldown` and
35
- * `ownCapabilities`, the message paginator's store for the current user's latest message.
36
- *
37
- * `Channel` calls this right after constructing the timer and unregisters it in `_disconnect`, the same
38
- * way it drives `messageReceiptsTracker`. That replaces four imperative `cooldownTimer.refresh()` calls
39
- * in `Channel`, and the three WS-event handlers that used to live here — which duplicated those calls
40
- * and never ran, because nothing registered them. Between them the two arrangements still missed every
41
- * `query()`, and any `updatePartial` that changed `cooldown` without changing capabilities.
27
+ * Derives the timer from `channel.state` (`cooldown`, `ownCapabilities`) and the message
28
+ * paginator's store (the current user's latest message). `Channel` registers it on construction
29
+ * and unregisters it in `disconnect`.
42
30
  */
43
31
  registerSubscriptions: () => void;
44
32
  setCooldownRemaining: (cooldownRemaining: number) => void;
45
33
  clearTimeout: () => void;
46
34
  refresh: () => void;
47
35
  /**
48
- * Updates the known latest own message date and recomputes remaining time.
49
- * Prefer calling this when you already know the message date (e.g. from an event).
36
+ * Sets the own latest message timestamp and recomputes the remaining time.
37
+ *
38
+ * @param timestamp - Unix nanoseconds, as the API sends it.
50
39
  */
51
- setOwnLatestMessageDate: (date: Date | undefined) => void;
40
+ setOwnLatestMessageTimestamp: (timestamp: TimestampNS | undefined) => void;
52
41
  private getOwnUserId;
53
- private findOwnLatestMessageDate;
42
+ private findOwnLatestMessageTimestamp;
54
43
  private recalculate;
55
44
  }
@@ -1,15 +1,11 @@
1
1
  import type { Event, EventType } from './types';
2
2
  import type { KeysOfUnion, ValueOfUnion } from './types.utility';
3
- import type { Unsubscribe } from './store';
3
+ import type { Unsubscribe } from '@stream-io/state-store';
4
+ type EventObject = Extract<Event, object>;
4
5
  /**
5
- * Flat routing view of an event: every field any event can carry, all optional, on one object.
6
- *
7
- * Handlers route without narrowing, which `Event` does not allow — it is a discriminated union whose
8
- * `{ type: '*' } & CustomEvent` member has none of the channel fields, and it admits bare custom-event
9
- * strings (hence the `unknown` hop in `processOne`). Derived from that union, so a new generated field
10
- * is routable without widening anything by hand.
6
+ * Flat view of an event for routing without narrowing: every field any `Event` member can carry,
7
+ * all optional. Derived from the `Event` union, so new generated fields are routable automatically.
11
8
  */
12
- type EventObject = Extract<Event, object>;
13
9
  export type PipelineEvent = {
14
10
  type: EventType | (string & {});
15
11
  } & {
@@ -51,50 +47,34 @@ export declare class EventHandlerPipeline<CTX extends Record<string, unknown> =
51
47
  get size(): number;
52
48
  findIndex({ handler, idMatch }: FindEventHandlerParams<CTX>): number;
53
49
  /**
54
- * Insert a handler into the pipeline at the given index.
50
+ * Inserts a handler into the pipeline. With `replace` and an in-bounds index it overwrites the
51
+ * handler there instead.
55
52
  *
56
- * - If `replace` is `true` and the index is within bounds, the existing handler
57
- * at that position will be replaced by the new one.
58
- * - If `revertOnUnsubscribe` is also `true`, then calling the returned
59
- * unsubscribe will both remove the inserted handler *and* restore the
60
- * previously replaced handler at the same index.
61
- * - If `replace` is `false` (default), the new handler is inserted at the index
62
- * (or appended if the index is greater than the pipeline size). Unsubscribe
63
- * will only remove this handler.
64
- *
65
- * @param payload - Insertion options.
66
53
  * @param payload.handle - The handler function to insert.
67
- * @param payload.index - Target index in the pipeline (clamped to valid range).
68
- * @param payload.replace - If true, replace existing handler at index instead of inserting.
69
- * @param payload.revertOnUnsubscribe - If true, restore the replaced handler when unsubscribing.
70
- * @returns An unsubscribe function that removes (and optionally restores) the handler.
54
+ * @param payload.id - The handler ID. Defaults to a generated UUID.
55
+ * @param payload.index - Target index, clamped to the pipeline size. Defaults to appending.
56
+ * @param payload.replace - Whether to replace the handler at `index` instead of inserting.
57
+ * @param payload.revertOnUnsubscribe - Whether unsubscribing restores the replaced handler.
58
+ * @returns An unsubscribe function that removes the handler and, with `revertOnUnsubscribe`, puts
59
+ * back the one it replaced.
71
60
  */
72
61
  insert({ handle, id, index, replace, revertOnUnsubscribe, }: InsertEventHandlerPayload<CTX>): Unsubscribe;
73
62
  /**
74
- * Remove handler by:
75
- * - handler function identity or
76
- * - by id that could be an exact match or
77
- * - match by regexp.
63
+ * Removes every matching handler.
78
64
  *
79
- * @param params - {FindEventHandlerParams}
65
+ * @param params - Matches by handler function identity, exact ID or ID regexp.
80
66
  */
81
67
  remove(params: FindEventHandlerParams<CTX>): void;
82
68
  replaceAll(handlers: LabeledEventHandler<CTX>[]): void;
83
69
  clear(): void;
84
70
  /**
85
- * Queue an event for processing. Events are processed serially, in the order
86
- * `run` is called. Returns a promise that resolves/rejects for this specific
87
- * event’s processing, while the internal chain continues (errors won’t break it).
71
+ * Queues an event. Events are processed serially in call order. The promise settles for this
72
+ * event only, a rejection does not break the queue.
88
73
  */
89
74
  run(event: Event, ctx: CTX): Promise<void>;
90
- /**
91
- * Wait until all queued events have been processed.
92
- */
75
+ /** Resolves once all queued events have been processed. */
93
76
  drain(): Promise<void>;
94
- /**
95
- * Process a single event through a stable snapshot of handlers to avoid
96
- * mid-iteration mutations (insert/remove) affecting this run.
97
- */
77
+ /** Runs the event through a snapshot of the handlers, so mid-run changes do not affect it. */
98
78
  private processOne;
99
79
  }
100
80
  export {};