stream-chat 10.0.0-rc.9 → 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 (361) hide show
  1. package/README.md +7 -6
  2. package/dist/cjs/index.browser.js +21650 -19790
  3. package/dist/cjs/index.browser.js.map +4 -4
  4. package/dist/cjs/index.node.js +21690 -19798
  5. package/dist/cjs/index.node.js.map +4 -4
  6. package/dist/esm/index.mjs +21755 -19895
  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 +13 -27
  10. package/dist/types/EventHandlerPipeline.d.ts +18 -38
  11. package/dist/types/LiveLocationManager.d.ts +24 -52
  12. package/dist/types/api-client.d.ts +17 -5
  13. package/dist/types/channel.d.ts +432 -470
  14. package/dist/types/channel_state.d.ts +68 -112
  15. package/dist/types/client.d.ts +321 -435
  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 +2 -0
  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 +2528 -690
  50. package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
  51. package/dist/types/gen/moderation/ModerationApi.d.ts +33 -14
  52. package/dist/types/index.d.ts +10 -6
  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 +7 -1
  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 -128
  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 +19 -18
  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 +40 -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 -186
  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 -334
  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 +5 -23
  118. package/dist/types/pagination/utility.search.d.ts +3 -8
  119. package/dist/types/poll.d.ts +34 -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 +11 -11
  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 +63 -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 -199
  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 +33 -57
  148. package/dist/types/utils.d.ts +72 -91
  149. package/package.json +14 -40
  150. package/src/ChannelManager.ts +494 -303
  151. package/src/CooldownTimer.ts +28 -38
  152. package/src/EventHandlerPipeline.ts +22 -45
  153. package/src/LiveLocationManager.ts +37 -76
  154. package/src/api-client.ts +113 -50
  155. package/src/campaign.ts +1 -1
  156. package/src/channel.ts +1067 -1276
  157. package/src/channel_batch_updater.ts +1 -1
  158. package/src/channel_state.ts +73 -168
  159. package/src/client.ts +744 -974
  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 -232
  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 +6 -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 -1540
  195. package/src/gen/models/index.ts +2498 -3383
  196. package/src/gen/models/timestamp-guard.ts +27 -0
  197. package/src/gen/moderation/ModerationApi.ts +170 -367
  198. package/src/index.ts +22 -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 +19 -23
  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 +223 -174
  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/textComposer.ts +1 -1
  225. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +12 -12
  226. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  227. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  228. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  229. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +8 -6
  230. package/src/messageComposer/middleware/textComposer/commandUtils.ts +10 -3
  231. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  232. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  233. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  234. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  235. package/src/messageComposer/pollComposer.ts +21 -9
  236. package/src/messageComposer/textComposer.ts +37 -57
  237. package/src/messageComposer/types.ts +39 -11
  238. package/src/messageDelivery/MessageDeliveryReporter.ts +86 -125
  239. package/src/messageDelivery/MessageReceiptsTracker.ts +88 -101
  240. package/src/messageOperations/FailedSendCache.ts +85 -0
  241. package/src/messageOperations/MessageOperationStatePolicy.ts +121 -112
  242. package/src/messageOperations/MessageOperations.ts +297 -175
  243. package/src/{entityStore → messageOperations}/applyReactionLocally.ts +9 -28
  244. package/src/messageOperations/createMessageOperations.ts +176 -0
  245. package/src/messageOperations/index.ts +6 -14
  246. package/src/messageOperations/reflectReactionEvent.ts +43 -0
  247. package/src/messageOperations/sendOrdering.ts +25 -0
  248. package/src/messageOperations/settlePendingAttachmentUploads.ts +98 -0
  249. package/src/messageOperations/types.ts +51 -13
  250. package/src/middleware.ts +13 -5
  251. package/src/moderation.ts +25 -21
  252. package/src/notifications/NotificationManager.ts +19 -28
  253. package/src/notifications/types.ts +21 -57
  254. package/src/offline-support/offline_support_api.ts +226 -669
  255. package/src/offline-support/offline_sync_manager.ts +51 -80
  256. package/src/offline-support/queueableOperations.ts +98 -73
  257. package/src/offline-support/types.ts +43 -186
  258. package/src/pagination/FilterBuilder.ts +1 -22
  259. package/src/pagination/ItemIndex.ts +4 -12
  260. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  261. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +15 -63
  262. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  263. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +53 -33
  264. package/src/pagination/filterCompiler.ts +11 -25
  265. package/src/pagination/index.ts +1 -0
  266. package/src/pagination/paginators/BasePaginator.ts +1415 -1041
  267. package/src/pagination/paginators/ChannelPaginator.ts +479 -217
  268. package/src/pagination/paginators/MessageIntervalPaginator.ts +1351 -772
  269. package/src/pagination/paginators/MessagePaginator.ts +513 -233
  270. package/src/pagination/paginators/PinnedMessagePaginator.ts +32 -40
  271. package/src/pagination/paginators/ReminderPaginator.ts +21 -16
  272. package/src/pagination/paginators/ThreadPaginator.ts +170 -0
  273. package/src/pagination/paginators/UserGroupPaginator.ts +16 -19
  274. package/src/pagination/paginators/index.ts +1 -0
  275. package/src/pagination/paginators/stateThrottling.ts +5 -10
  276. package/src/pagination/sortCompiler.ts +23 -50
  277. package/src/pagination/utility.normalization.ts +8 -30
  278. package/src/pagination/utility.search.ts +4 -11
  279. package/src/poll.ts +177 -98
  280. package/src/poll_manager.ts +24 -22
  281. package/src/poll_optimistic_votes.ts +335 -0
  282. package/src/reminders/Reminder.ts +16 -12
  283. package/src/reminders/ReminderManager.ts +22 -55
  284. package/src/reminders/ReminderTimer.ts +1 -2
  285. package/src/search/BaseSearchSource.ts +19 -25
  286. package/src/search/ChannelSearchSource.ts +43 -1
  287. package/src/search/MessageSearchSource.ts +77 -13
  288. package/src/search/SearchController.ts +39 -36
  289. package/src/search/types.ts +6 -10
  290. package/src/segment.ts +1 -1
  291. package/src/signing.ts +23 -3
  292. package/src/thread.ts +418 -703
  293. package/src/thread_manager.ts +300 -234
  294. package/src/token_manager.ts +12 -22
  295. package/src/types.ts +102 -216
  296. package/src/types.utility.ts +3 -3
  297. package/src/upload-utils.ts +5 -10
  298. package/src/uploadManager.ts +64 -18
  299. package/src/utils/FixedSizeQueueCache.ts +18 -21
  300. package/src/utils/WithSubscriptions.ts +6 -16
  301. package/src/utils/abort.ts +45 -0
  302. package/src/utils/concurrency.ts +16 -55
  303. package/src/utils/mergeWith/mergeWith.ts +10 -13
  304. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  305. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  306. package/src/utils/objectPath.ts +6 -41
  307. package/src/utils/retryable.ts +10 -14
  308. package/src/utils/throttling/throttle.ts +9 -25
  309. package/src/utils/time.ts +40 -60
  310. package/src/utils.ts +181 -174
  311. package/codegen/i18n/callSites.ts +0 -126
  312. package/codegen/i18n/generate.ts +0 -226
  313. package/codegen/i18n/guards.ts +0 -178
  314. package/codegen/i18n/index.ts +0 -29
  315. package/codegen/i18n/stringMaps.ts +0 -91
  316. package/codegen/i18n/types.ts +0 -100
  317. package/dist/cjs/i18n.browser.js +0 -1131
  318. package/dist/cjs/i18n.browser.js.map +0 -7
  319. package/dist/cjs/i18n.node.js +0 -1160
  320. package/dist/cjs/i18n.node.js.map +0 -7
  321. package/dist/esm/i18n-codegen.mjs +0 -409
  322. package/dist/esm/i18n-codegen.mjs.map +0 -7
  323. package/dist/esm/i18n.mjs +0 -1098
  324. package/dist/esm/i18n.mjs.map +0 -7
  325. package/dist/types/ConnectionRecoveryManager.d.ts +0 -156
  326. package/dist/types/connection.d.ts +0 -139
  327. package/dist/types/entityStore/applyReactionLocally.d.ts +0 -32
  328. package/dist/types/i18n/Streami18n.d.ts +0 -168
  329. package/dist/types/i18n/TranslationBuilder.d.ts +0 -70
  330. package/dist/types/i18n/TranslationStore.d.ts +0 -57
  331. package/dist/types/i18n/dayjs.d.ts +0 -104
  332. package/dist/types/i18n/formatters.d.ts +0 -91
  333. package/dist/types/i18n/index.d.ts +0 -15
  334. package/dist/types/i18n/translator.d.ts +0 -29
  335. package/dist/types/i18n/types.d.ts +0 -262
  336. package/dist/types/i18n-codegen/callSites.d.ts +0 -10
  337. package/dist/types/i18n-codegen/generate.d.ts +0 -15
  338. package/dist/types/i18n-codegen/guards.d.ts +0 -61
  339. package/dist/types/i18n-codegen/index.d.ts +0 -29
  340. package/dist/types/i18n-codegen/stringMaps.d.ts +0 -14
  341. package/dist/types/i18n-codegen/types.d.ts +0 -94
  342. package/dist/types/insights.d.ts +0 -56
  343. package/dist/types/messageOperations/optimistic.d.ts +0 -118
  344. package/dist/types/messageOperations/persistence.d.ts +0 -21
  345. package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
  346. package/dist/types/store.d.ts +0 -125
  347. package/src/ConnectionRecoveryManager.ts +0 -293
  348. package/src/i18n/Streami18n.ts +0 -520
  349. package/src/i18n/TranslationBuilder.ts +0 -176
  350. package/src/i18n/TranslationStore.ts +0 -96
  351. package/src/i18n/dayjs.ts +0 -228
  352. package/src/i18n/formatters.ts +0 -461
  353. package/src/i18n/index.ts +0 -15
  354. package/src/i18n/languageNames.ts +0 -103
  355. package/src/i18n/translator.ts +0 -76
  356. package/src/i18n/types.ts +0 -375
  357. package/src/insights.ts +0 -82
  358. package/src/messageOperations/optimistic.ts +0 -257
  359. package/src/messageOperations/persistence.ts +0 -40
  360. package/src/pagination/utility.queryChannel.ts +0 -84
  361. package/src/store.ts +0 -304
@@ -1,32 +1,31 @@
1
1
  import type { AxiosInstance } from 'axios';
2
- import { Channel } from './channel';
2
+ import type { Channel } from './channel';
3
3
  import type { ChannelMuteStatus } from './channel_state';
4
4
  import { ClientState } from './client_state';
5
- import { StableWSConnection } from './connection';
6
5
  import { UploadManager } from './uploadManager';
7
6
  import { TokenManager, type TokenManagerMinimalUser } from './token_manager';
8
7
  import { ApiClient } from './api-client';
9
- import type { APIResponse, AppIdentifier, ChannelInput, ChannelMute, ChannelOptions, ChannelResponse, ChannelStateOptions, ChannelStateResponseFields, Configs, ConnectAPIResponse, DeviceIdentifier, Event, EventHandler, EventType, FileUploadInput, GetThreadOptions, LocalMessage, OwnUserResponse, PartializeAllBut, QueryChannelsRequest, QueryChannelsResponse, QueryReactionsRequestWithId, QueryThreadsRequest, SdkIdentifier, StreamChatOptions, StreamRequestOptions, TokenOrProvider, UnBanUserOptions, UserMuteResponse, UserResponse } from './types';
10
- import { InsightMetrics } from './insights';
11
- import { Thread } from './thread';
8
+ import type { APIResponse, AppIdentifier, ChannelInput, ChannelMute, ChannelOptions, ChannelResponse, ChannelStateOptions, ChannelStateResponseFields, Configs, ConnectAPIResponse, DeviceIdentifier, Event, EventHandler, EventType, FileUploadInput, GetThreadOptions, LocalMessage, OwnUserResponse, PartializeAllBut, PinMessageOptions, QueryChannelsRequest, QueryChannelsResponse, QueryThreadsRequest, SdkIdentifier, StreamRequestOptions, TokenOrProvider, UnBanUserOptions, UserMuteResponse, UserRequest, UserResponse } from './types';
9
+ import { type Thread } from './thread';
12
10
  import { Moderation } from './moderation';
13
11
  import { ThreadManager } from './thread_manager';
14
12
  import { PollManager } from './poll_manager';
15
13
  import { EntityStore } from './entityStore/EntityStore';
16
14
  import { ChannelManager } from './ChannelManager';
17
- import { ConnectionRecoveryManager } from './ConnectionRecoveryManager';
15
+ import { ConnectionIdManager, ConnectionRecoveryManager, NetworkConnectionObserver, WSConnection } from './connection';
18
16
  import { MessageDeliveryReporter } from './messageDelivery';
19
17
  import { NotificationManager } from './notifications';
20
18
  import { ReminderManager } from './reminders';
21
19
  import type { AbstractOfflineDB } from './offline-support';
22
20
  import { FixedSizeQueueCache } from './utils/FixedSizeQueueCache';
23
21
  import type { MessageComposer } from './messageComposer';
24
- import type { InstanceSetupState } from './configuration';
22
+ import type { InstanceConfigTree, InstanceSetupState } from './configuration';
23
+ import type { DeepPartial } from './types.utility';
25
24
  import { InstanceConfigurationRegistry } from './configuration/InstanceConfigurationRegistry';
26
- import { StateStore } from './store';
27
- import type { FileUploadRequest, GetApplicationResponse as Gen_GetApplicationResponse, MarkDeliveredRequest as Gen_MarkDeliveredRequest, ImageUploadRequest, WSEvent } from './gen/models';
25
+ import { StateStore } from '@stream-io/state-store';
26
+ import type { FileUploadRequest, GetApplicationResponse as Gen_GetApplicationResponse, MarkDeliveredRequest as Gen_MarkDeliveredRequest, ImageUploadRequest, WSAuthMessage, WSEvent } from './gen/models';
28
27
  import { ChatApi } from './gen-imports';
29
- import type { ConnectedEvent, StreamResponse } from './types';
28
+ import type { StreamResponse } from './types';
30
29
  export type QueryChannelsResponseWithChannels = Omit<QueryChannelsResponse, 'channels'> & {
31
30
  channels: Channel[];
32
31
  };
@@ -42,61 +41,57 @@ export type ClientUser = PartializeAllBut<OwnUserResponse, 'id'> & {
42
41
  export declare class StreamChat extends ChatApi {
43
42
  private static _instance?;
44
43
  messageDeliveryReporter: MessageDeliveryReporter;
45
- /**
46
- * @internal
47
- */
44
+ /** @internal */
48
45
  uploadManager: UploadManager;
49
- /**
50
- * @private
51
- */
46
+ /** @private */
52
47
  _user?: ClientUser;
53
48
  appSettingsPromise?: Promise<StreamResponse<Gen_GetApplicationResponse>>;
54
- activeChannels: {
55
- [key: string]: Channel;
56
- };
57
49
  threads: ThreadManager;
58
50
  polls: PollManager;
59
51
  /**
60
- * Channel lists — one or more `ChannelPaginator`s kept in sync with WS events, with ownership
61
- * arbitration between them. Instantiated with the client and living as long as it does; register
62
- * the lists with `client.channelManager.insertPaginator()` and drop them again with
63
- * `removePaginator()`. It only starts handling events once something calls its (ref-counted)
64
- * `registerSubscriptions()`.
65
- *
66
- * It is deliberately not configurable through the client options — everything is set on the
67
- * manager itself (`setOwnershipResolver`, `addEventHandler` / `setEventHandlers` /
68
- * `removeEventHandlers`), which is also the only way to reconfigure it later.
52
+ * Channel lists (`ChannelPaginator`s kept in sync with WS events, with ownership arbitration
53
+ * between them). Register lists with `insertPaginator()` / `removePaginator()`. It handles events
54
+ * only once something calls its ref-counted `registerSubscriptions()`. It is configured on the
55
+ * manager itself (`setOwnershipResolver`, `addEventHandler`, ...), not through the client
56
+ * options.
69
57
  */
70
58
  channelManager: ChannelManager;
71
59
  /**
72
- * Owns connection recovery: on reconnect it re-runs each loaded channel list's own first-page query
73
- * and reloads each active channel, then dispatches `connection.recovered`. Instantiated with the
74
- * client and subscribed for its lifetime.
75
- *
76
- * Turn it off through the declarative configuration if the application recovers state itself:
77
- * `client.config.set({ client: { connectionRecovery: { enabled: false } } })`.
60
+ * On reconnect, re-runs each loaded channel list's first-page query and reloads each active
61
+ * channel and thread, then dispatches `connection.recovered`. Disable it when the app recovers
62
+ * state itself: `client.config.set({ client: { connectionRecovery: { enabled: false } } })`.
78
63
  */
79
64
  connectionRecovery: ConnectionRecoveryManager;
80
65
  /**
81
- * Client-global, normalized store holding one canonical copy of each message. The channel main
82
- * list and thread reply paginators read/write message content through it, so a message held in
83
- * more than one of them stays consistent without copy-to-copy fan-out.
66
+ * The device's network status, separate from the WebSocket's ({@link wsConnection}). Platforms
67
+ * report it through `client.config.set({ client: { networkConnection: { statusReporter } } })` or
68
+ * `client.networkConnection.setStatusReporter(...)`. Browsers get a reporter automatically;
69
+ * elsewhere a stand-in mirrors the WebSocket. `isOnline` is `undefined` (unknown, not offline)
70
+ * until something reports.
71
+ */
72
+ networkConnection: NetworkConnectionObserver;
73
+ /**
74
+ * The connection ID (the WebSocket's, or the long-poll's after an `enableWSFallback` switch). A
75
+ * request with `watch` or `presence` waits here for the handshake (see `requiresConnectionId`).
76
+ */
77
+ connectionIdManager: ConnectionIdManager;
78
+ /**
79
+ * Client-global store with one canonical copy of each message. The channel and thread paginators
80
+ * read and write messages through it, so a message held in several of them stays consistent.
84
81
  */
85
82
  messageStore: EntityStore<LocalMessage>;
86
83
  offlineDb?: AbstractOfflineDB;
87
84
  notifications: NotificationManager;
88
85
  reminders: ReminderManager;
89
- persistUserOnConnectionFailure?: boolean;
90
86
  axiosInstance: AxiosInstance;
91
87
  baseURL?: string;
92
- browser: boolean;
93
88
  cleaningIntervalRef?: ReturnType<typeof setTimeout>;
94
89
  clientId?: string;
95
90
  key: string;
96
91
  listeners: Map<EventType, Set<EventHandler>>;
97
92
  /**
98
- * If true, we will not clean up threads when channel state is in initializing state.
99
- * The main use case for SDKs who do independent state recovery for channels.
93
+ * When true, threads are not cleaned up while the channel state is initializing (for SDKs that
94
+ * recover channel state themselves).
100
95
  */
101
96
  preventThreadCleanup: boolean;
102
97
  moderation: Moderation;
@@ -105,52 +100,47 @@ export declare class StreamChat extends ChatApi {
105
100
  mutedUsers: UserMuteResponse[];
106
101
  }>;
107
102
  /**
108
- * Reactive store behind {@link channelServerConfigs}. The only reactive way to observe server channel
109
- * configuration today, which is why `stream-chat-react` reads it — a public, per-channel feature
110
- * resolver is the intended replacement.
111
- *
112
- * Named for what it holds plus a `Store` suffix for what it is, matching {@link mutedUsersStore}. These
113
- * are the backend's configs, not the ones you register through {@link config}.
103
+ * Reactive store behind {@link channelServerConfigs}: the backend's channel configs, not the ones
104
+ * registered through {@link config}.
114
105
  *
115
106
  * @internal
116
107
  */
117
108
  readonly channelServerConfigsStore: StateStore<ChannelConfigsState>;
118
109
  blockedUsers: StateStore<BlockedUsersState>;
119
- node: boolean;
120
- options: StreamChatOptions;
121
110
  setUserPromise: ConnectAPIResponse | null;
122
111
  state: ClientState;
123
112
  tokenManager: TokenManager;
124
113
  user?: ClientUser;
125
114
  userAgent?: string;
126
115
  wsBaseURL?: string;
127
- wsConnection: StableWSConnection | null;
116
+ wsConnection: WSConnection;
128
117
  wsPromise: ConnectAPIResponse | null;
129
- get anonymous(): boolean;
130
- get userId(): string | undefined;
118
+ private _wsPromiseSettled;
119
+ private _wsConnectId;
120
+ private _resolveWsPromise?;
121
+ private _rejectWsPromise?;
131
122
  /**
132
- * @deprecated Use `userId` instead.
123
+ * Whether the client runs in a browser: the `client.browser` option, else whether `window`
124
+ * exists.
133
125
  */
126
+ get browser(): boolean;
127
+ get node(): boolean;
128
+ get anonymous(): boolean;
129
+ get userId(): string | undefined;
130
+ /** @deprecated Use `userId` instead. */
134
131
  get userID(): string | undefined;
135
- /**
136
- * @deprecated Use `clientId` instead.
137
- */
132
+ /** @deprecated Use `clientId` instead. */
138
133
  get clientID(): string | undefined;
139
134
  set clientID(id: string | undefined);
140
135
  get api(): ApiClient;
141
- insightMetrics: InsightMetrics;
142
- defaultWSTimeout: number;
143
136
  sdkIdentifier?: SdkIdentifier;
144
137
  deviceIdentifier?: DeviceIdentifier;
145
138
  appIdentifier?: AppIdentifier;
146
139
  private cachedUserAgent?;
147
140
  readonly messageComposerCache: FixedSizeQueueCache<string, MessageComposer>;
148
141
  /**
149
- * Configuration you register for instances the SDK creates on your behalf — channels, threads,
150
- * composers, and the client's own managers. See `InstanceConfigurationRegistry`.
151
- *
152
- * Not to be confused with {@link channelServerConfigs}, which holds the **server-provided channel
153
- * configs** keyed by cid. This one is yours; that one is the backend's.
142
+ * Configuration registered for the instances the SDK creates (channels, threads, composers, the
143
+ * client's own managers). Not the server-provided channel configs ({@link channelServerConfigs}).
154
144
  */
155
145
  readonly config: InstanceConfigurationRegistry;
156
146
  /** Teardown for the `'client'` setup function, released by {@link disconnectUser}. */
@@ -158,68 +148,38 @@ export declare class StreamChat extends ChatApi {
158
148
  /**
159
149
  * Initializes a client.
160
150
  *
161
- * **Only use constructor for advanced usages. It is strongly advised to use `StreamChat.getInstance()` instead of `new StreamChat()` to reduce integration issues due to multiple WebSocket connections.**
151
+ * **Prefer `StreamChat.getInstance()`: a second client opens a second WebSocket connection.**
162
152
  *
163
153
  * @example <caption>initialize the client in user mode</caption>
164
154
  * new StreamChat('api_key')
165
- * @example <caption>initialize the client in user mode with options</caption>
166
- * new StreamChat('api_key', { warmUp: true, timeout: 5000 })
167
- * @example <caption>secret is optional and only used in server side mode</caption>
168
- * new StreamChat('api_key', 'secret', { httpsAgent: customAgent })
155
+ * @example <caption>initialize the client with configuration</caption>
156
+ * new StreamChat('api_key', { client: { axiosRequestConfig: { timeout: 5000 } } })
169
157
  *
170
158
  * @param key - The API key.
171
- * @param options - Additional options; here you can pass custom options to the axios instance (optional).
172
- * @param options.browser - Enforce the client to be in browser mode (optional).
173
- * @param options.warmUp - If `true`, the client will open a connection as soon as possible to speed up following requests (optional, defaults to `false`).
174
- * @param options.logLevel - Minimum log level for the default sink (optional, defaults to `'info'`).
175
- * @param options.logOptions - Per-scope sink/level overrides for `chatLoggerSystem` (optional).
176
- * @param options.timeout - Request timeout (optional, defaults to `3000`).
177
- * @param options.httpsAgent - Custom `httpsAgent` (optional).
159
+ * @param config - Declarative configuration, the tree `client.config.set()` takes (optional).
160
+ * Applied before anything is built, so it reaches the managers and the options read once at
161
+ * construction (`client.baseURL`, `client.axiosRequestConfig`, `client.notificationManager`).
178
162
  */
179
- constructor(key: string, options?: StreamChatOptions);
163
+ constructor(key: string, config?: DeepPartial<InstanceConfigTree>);
180
164
  /**
181
- * Subscribes the client's managers to the `'client'` configuration key.
182
- *
183
- * Called by the constructor and again by {@link _setUser}, because {@link disconnectUser} releases this
184
- * subscription to run the setup function's teardown. A client is reusable — `getInstance` hands the same
185
- * object back, and disconnect/connect is the documented multi-user and mobile-background flow — and the
186
- * managers this key configures (`reminders`, `threads`, `messageDeliveryReporter`, `notifications`)
187
- * outlive the user. Without the re-arm the key went permanently dead on the second connect: `setConfig`,
188
- * `setSetupFunction` and `reset` all stopped reaching any manager, silently.
189
- *
190
- * Idempotent through the `unsubscribeClientConfiguration` guard, so the constructor's wiring is not
191
- * duplicated by the first `connectUser`.
165
+ * Subscribes the client's managers to the `'client'` configuration key. Called by the constructor
166
+ * and by {@link _setUser}, because {@link disconnectUser} releases the subscription (to run the
167
+ * setup function's teardown) while the managers outlive the user. Idempotent.
192
168
  */
193
169
  private wireClientConfiguration;
194
170
  /**
195
- * Derives each manager's configuration from package defaults plus the `client` declarative subtree.
196
- * Shared by the constructor and `config.reset()`, so the two cannot drift.
197
- *
198
- * Defaults are spread first, and every manager is written unconditionally, because this is a
199
- * derivation* rather than a patch — the same rule `Channel.initializeConfig` follows. Guarding on
200
- * `if (config?.reminders)` and merging made `reset()` a no-op for this key: the store is cleared
201
- * before instances re-derive, so the guards all failed and the registered values stayed in force.
202
- * It also meant a field *removed* from the tree lingered, which is exactly what a merge cannot express.
171
+ * Derives each manager's configuration from the package defaults plus the `client` subtree. Every
172
+ * manager is written unconditionally: it is a derivation, not a merge, so `config.reset()` and
173
+ * removed fields take effect.
203
174
  */
204
175
  private initializeManagerConfig;
205
176
  get mutedUsers(): UserMuteResponse[];
206
177
  set mutedUsers(mutedUsers: UserMuteResponse[]);
207
178
  /**
208
- * Cache of server-provided channel configuration, keyed by **cid** — a channel's own
209
- * `config_overrides` can make it differ from every other channel of its type, so one entry per
210
- * channel is the only key space that can represent the answer. See {@link _addChannelConfig}.
211
- *
212
- * Read it through {@link Channel.serverConfig} rather than here. Not to be confused with
213
- * {@link config}, which is the configuration *you* register for SDK-created instances.
214
- *
215
- * This is `client.configs` from v9 under a name that says whose configuration it is — the key space is
216
- * unchanged, so a v9 `client.configs[cid]` lookup translates directly. There is deliberately no
217
- * `configs` alias: it read as a sibling of the integrator-facing {@link config} while holding the
218
- * backend's answer, and the two being one letter apart is what made `channel.getConfig()` ambiguous
219
- * enough to rename as well.
220
- *
221
- * Assigning through this setter notifies subscribers; mutating the returned record in place does not.
222
- * Prefer {@link _addChannelConfig}.
179
+ * Cache of server-provided channel configuration, keyed by cid (a channel's `config_overrides`
180
+ * can make it differ from other channels of its type). Read it through
181
+ * {@link Channel.serverConfig}. Assigning through the setter notifies subscribers, mutating the
182
+ * record in place does not (prefer {@link _addChannelConfig}).
223
183
  *
224
184
  * @internal
225
185
  */
@@ -227,84 +187,86 @@ export declare class StreamChat extends ChatApi {
227
187
  /** @internal */
228
188
  set channelServerConfigs(configs: Configs);
229
189
  /**
230
- * Returns a client instance.
190
+ * Returns the shared client instance, so there is only one client and WebSocket connection.
231
191
  *
232
- * This function always returns the same client instance to avoid issues raised by multiple client and WS connections.
233
- *
234
- * **After the first call, the client configuration will not change if the key or options parameters change.**
192
+ * **After the first call, the `key` and `config` parameters are ignored.**
235
193
  *
236
194
  * @example <caption>initialize the client in user mode</caption>
237
195
  * StreamChat.getInstance('api_key')
238
- * @example <caption>initialize the client in user mode with options</caption>
239
- * StreamChat.getInstance('api_key', { timeout: 5000 })
240
- * @example <caption>secret is optional and only used in server side mode</caption>
241
- * StreamChat.getInstance('api_key', 'secret', { httpsAgent: customAgent })
196
+ * @example <caption>initialize the client with configuration</caption>
197
+ * StreamChat.getInstance('api_key', { client: { axiosRequestConfig: { timeout: 5000 } } })
242
198
  *
243
199
  * @param key - The API key.
244
- * @param options - Additional options; here you can pass custom options to the axios instance (optional).
245
- * @param options.browser - Enforce the client to be in browser mode (optional).
246
- * @param options.warmUp - If `true`, the client will open a connection as soon as possible to speed up following requests (optional, defaults to `false`).
247
- * @param options.logLevel - Minimum log level for the default sink (optional, defaults to `'info'`).
248
- * @param options.logOptions - Per-scope sink/level overrides for `chatLoggerSystem` (optional).
249
- * @param options.timeout - Request timeout (optional, defaults to `3000`).
250
- * @param options.httpsAgent - Custom `httpsAgent` (optional, in Node defaults to `https.agent()`).
200
+ * @param config - Declarative configuration, as for the constructor (optional).
251
201
  * @returns The shared client instance.
252
202
  */
253
- static getInstance(key: string, options?: StreamChatOptions): StreamChat;
203
+ static getInstance(key: string, config?: DeepPartial<InstanceConfigTree>): StreamChat;
254
204
  setOfflineDBApi(offlineDBInstance: AbstractOfflineDB): void;
205
+ /**
206
+ * Creates a development token for apps with auth checks disabled. Never use one in production.
207
+ * See {@link DevToken}.
208
+ *
209
+ * @param userId - The ID of the user the token is for.
210
+ * @returns The development token.
211
+ */
212
+ devToken(userId: string): string;
255
213
  getAuthType(): "anonymous" | "jwt";
256
214
  setBaseURL(baseURL: string): void;
257
215
  _getConnectionID: () => string | undefined;
258
216
  _hasConnectionID: () => boolean;
259
- /**
260
- * @deprecated Use `client.config.setSetupFunction('messageComposer', fn)`.
261
- */
217
+ /** @deprecated Use `client.config.setSetupFunction('messageComposer', fn)`. */
262
218
  setMessageComposerSetupFunction: (setupFunction: InstanceSetupState<"messageComposer">["setupFunction"]) => void;
263
219
  /**
264
- * Sets the current user and opens a WebSocket connection.
220
+ * Sets the current user and opens the WebSocket connection.
265
221
  *
266
- * @param user - Data about this user, e.g. `{ name: 'john' }`.
267
- * @param userTokenOrProvider - A token string or an async provider that returns one.
222
+ * @param user - The user, with its required `id`, e.g. `{ id: 'john', name: 'John' }`.
223
+ * @param userTokenOrProvider - A token string, or an async provider that resolves to one.
268
224
  * @returns A promise that resolves when the connection is set up.
225
+ * @throws For a different user, unless `disconnectUser()` ran first.
269
226
  */
270
227
  connectUser: (user: ClientUser, userTokenOrProvider: TokenOrProvider) => Promise<void | import("./types").ConnectionOpen>;
271
228
  /**
272
- * Sets the current user and opens a WebSocket connection.
229
+ * Sets the current user and opens the WebSocket connection.
273
230
  *
274
- * @deprecated Use {@link StreamChat.connectUser} instead. Its naming is more consistent with its functionality.
231
+ * @deprecated Use {@link StreamChat.connectUser} instead.
275
232
  *
276
- * @param user - Data about this user, e.g. `{ name: 'john' }`.
277
- * @param userTokenOrProvider - A token string or an async provider that returns one.
233
+ * @param user - The user, with its required `id`, e.g. `{ id: 'john', name: 'John' }`.
234
+ * @param userTokenOrProvider - A token string, or an async provider that resolves to one.
278
235
  * @returns A promise that resolves when the connection is set up.
279
236
  */
280
237
  setUser: (user: ClientUser, userTokenOrProvider: TokenOrProvider) => Promise<void | import("./types").ConnectionOpen>;
281
238
  _setToken: (user: TokenManagerMinimalUser, userTokenOrProvider: TokenOrProvider) => Promise<void>;
282
239
  _setUser(user: TokenManagerMinimalUser): void;
283
240
  /**
284
- * Disconnects the WebSocket connection, without removing the user set on client.
285
- * client.closeConnection will not trigger default auto-retry mechanism for reconnection. You need
286
- * to call `client.openConnection` to reconnect to the WebSocket.
241
+ * Closes the WebSocket without removing the user, and without auto-reconnect: call
242
+ * `openConnection` to reconnect. Mainly for mobile: push notifications arrive only while no
243
+ * WebSocket is active, so close on background and reopen on foreground. After an
244
+ * `enableWSFallback` switch it also closes the long-poll, telling the server to close its
245
+ * connection ID.
287
246
  *
288
- * This is mainly useful on mobile side. You can only receive push notifications
289
- * if you don't have an active WebSocket connection.
290
- * So when your app goes to background, you can call `client.closeConnection`.
291
- * And when app comes back to foreground, call `client.openConnection`.
292
- *
293
- * @param timeout - Max number of milliseconds to wait for the WebSocket close event before forcefully assuming
294
- * successful disconnection. See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent (optional).
247
+ * @param timeout - Milliseconds to wait for the WebSocket close event and for the long-poll close
248
+ * request. Defaults to 1s and 2s respectively.
295
249
  */
296
250
  closeConnection: (timeout?: number) => Promise<void>;
297
251
  /**
298
- * Creates a new WebSocket connection with the current user.
252
+ * Opens a WebSocket connection for the current user. After an `enableWSFallback` switch it
253
+ * reconnects the long-poll instead: the client never goes back to the WebSocket.
299
254
  *
300
- * @returns The WebSocket connect promise, or an empty resolved promise if a connection is already active.
255
+ * @returns The connect promise, or `undefined` when a healthy connection already exists.
301
256
  */
302
257
  openConnection: () => ConnectAPIResponse | undefined;
258
+ /** Rejects the shared `wsPromise` and invalidates any in-flight connect attempt. */
259
+ private _rejectPendingWsPromise;
260
+ /**
261
+ * Keeps a single pending `wsPromise` across close/reopen, so callers already awaiting it are not
262
+ * stranded when `openConnection` starts a new connect.
263
+ */
264
+ private _bindWsPromise;
303
265
  /**
304
- * Revokes tokens for a connected user issued before the given time.
266
+ * Revokes the connected user's tokens issued before the given time.
305
267
  *
306
- * @param before - Cutoff date; tokens issued before this are revoked (optional, defaults to the current time).
307
- * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
268
+ * @param before - Cutoff date; tokens issued before it are revoked (optional). Defaults to now.
269
+ * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
308
270
  * into the request (optional).
309
271
  * @returns The updated users response.
310
272
  */
@@ -312,48 +274,46 @@ export declare class StreamChat extends ChatApi {
312
274
  /**
313
275
  * Retrieves application settings.
314
276
  *
277
+ * @param _request - Unused. Holds the request position so `requestOptions` stays the
278
+ * second argument, as on the generated methods; pass `undefined`.
315
279
  * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
316
280
  * into the request (optional).
317
- * @returns The application settings response.
281
+ * @returns The application settings response. A failed request is not kept in
282
+ * {@link appSettingsPromise}, so the next call fetches again.
318
283
  */
319
- getAppSettings(requestOptions?: StreamRequestOptions): Promise<StreamResponse<Gen_GetApplicationResponse>>;
284
+ getAppSettings(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<Gen_GetApplicationResponse>>;
320
285
  /**
321
- * Disconnects the WebSocket and removes the user from client.
286
+ * Disconnects the WebSocket and removes the user and its state.
322
287
  *
323
- * @param timeout - Max number of milliseconds to wait for the WebSocket close event before forcefully assuming
324
- * successful disconnection. See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent (optional).
325
- * @returns The close-connection promise.
288
+ * @param timeout - Passed to {@link closeConnection} (optional).
326
289
  */
327
290
  disconnectUser: (timeout?: number) => Promise<void>;
328
- /**
329
- *
330
- * @deprecated Please use client.disconnectUser instead.
331
- *
332
- * Disconnects the WebSocket and removes the user from client.
333
- */
291
+ /** @deprecated Use `client.disconnectUser` instead. */
334
292
  disconnect: (timeout?: number) => Promise<void>;
335
293
  /**
336
- * Sets an anonymous user and opens a WebSocket connection.
294
+ * Sets an anonymous user and opens the WebSocket connection.
337
295
  *
338
296
  * @returns A promise that resolves when the connection is set up.
339
297
  */
340
298
  connectAnonymousUser: () => ConnectAPIResponse | undefined;
341
299
  /**
342
- * Creates a guest user and returns its access token.
300
+ * Creates a guest user.
343
301
  *
344
- * @param args - The guest creation request, plus optional per-request options.
302
+ * @param ...args - `[request, requestOptions]`. `request.user` is the guest user to create;
303
+ * `requestOptions` carries per-request options such as an abort `signal` and is never
304
+ * serialized into the request.
345
305
  * @returns The created guest user and its access token.
346
306
  */
347
307
  createGuest(...args: Parameters<ChatApi['createGuest']>): Promise<StreamResponse<import(".").CreateGuestResponse>>;
348
308
  /**
349
- * Sets up a temporary guest user.
309
+ * Creates a temporary guest user and connects as it.
350
310
  *
351
- * @param user - Data about this user, e.g. `{ name: 'john' }`.
352
- * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
311
+ * @param user - The guest user, with its required `id`, e.g. `{ id: 'john', name: 'John' }`.
312
+ * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
353
313
  * into the request (optional).
354
314
  * @returns A promise that resolves when the connection is set up.
355
315
  */
356
- setGuestUser(user: UserResponse, requestOptions?: StreamRequestOptions): Promise<void | import("./types").ConnectionOpen>;
316
+ setGuestUser(user: UserRequest, requestOptions?: StreamRequestOptions): Promise<void | import("./types").ConnectionOpen>;
357
317
  /**
358
318
  * Listens to events on all channels and users you're watching.
359
319
  *
@@ -367,262 +327,202 @@ export declare class StreamChat extends ChatApi {
367
327
  * console.log(event.type);
368
328
  * });
369
329
  *
370
- * @param callbackOrString - The event type to listen for, or the callback when listening to all events.
371
- * @param callbackOrNothing - The callback to call when an event type was provided (optional).
330
+ * @param callback - Called with every event.
372
331
  * @returns An object with an `unsubscribe()` method.
373
332
  */
374
333
  on(callback: EventHandler): {
375
334
  unsubscribe: () => void;
376
335
  };
377
- on<T extends EventType | string>(eventType: T, callback: EventHandler<T>): {
336
+ /**
337
+ * Listens to one event type on all channels and users you're watching.
338
+ *
339
+ * @param eventType - The event type to listen for.
340
+ * @param callback - Called with each event of that type.
341
+ * @returns An object with an `unsubscribe()` method.
342
+ */
343
+ on<T extends EventType>(eventType: T, callback: EventHandler<T>): {
378
344
  unsubscribe: () => void;
379
345
  };
380
346
  /**
381
- * Removes the event handler.
347
+ * Removes a listener for all events.
382
348
  *
383
- * @param callbackOrString - The event type, or the callback when removing an all-events listener.
384
- * @param callbackOrNothing - The callback to remove when an event type was provided (optional).
349
+ * @param callback - The listener to remove.
385
350
  */
386
351
  off(callback: EventHandler): void;
387
- off(eventType: string, callback: EventHandler): void;
352
+ /**
353
+ * Removes a listener for one event type.
354
+ *
355
+ * @param eventType - The event type it listens to.
356
+ * @param callback - The listener to remove.
357
+ */
358
+ off<T extends EventType>(eventType: T, callback: EventHandler<T>): void;
388
359
  dispatchEvent: (event: Event) => void;
389
360
  /**
390
- * Updates the members, watchers and read references of the currently active channels that contain this user.
361
+ * Puts `user`'s new object into the members, watchers, own membership and (with `readEntries`)
362
+ * read entries of the channels that list them, in one state update per channel.
391
363
  *
392
- * @param user - The updated user.
364
+ * @param options.readEntries - Also replace the user in read entries, refreshing read receipts.
365
+ * Off for presence changes: receipts never show online status. Defaults to `true`.
393
366
  */
394
- _updateMemberWatcherReferences: (user: UserResponse) => void;
367
+ _updateMemberWatcherReferences: (user: UserResponse, { readEntries }?: {
368
+ readEntries?: boolean;
369
+ }) => void;
395
370
  /**
396
371
  * @deprecated Please use `_updateMemberWatcherReferences` instead.
397
372
  * @private
398
373
  */
399
- _updateUserReferences: (user: UserResponse) => void;
374
+ _updateUserReferences: (user: UserResponse, { readEntries }?: {
375
+ readEntries?: boolean;
376
+ }) => void;
400
377
  /**
401
- * Updates the messages from the currently active channels that contain this user, with the updated user object.
378
+ * Replaces the user's object in the messages of the loaded channels.
402
379
  *
403
380
  * @private
404
- *
405
- * @param user - The updated user.
406
381
  */
407
382
  _updateUserMessageReferences: (user: UserResponse) => void;
408
383
  /**
409
- * Deletes the messages from the currently active channels that contain this user.
410
- *
411
- * If `hardDelete` is `true`, all the content of the message will be stripped down.
412
- * Otherwise, only `message.type` will be set as `'deleted'`.
384
+ * Deletes the user's messages in the loaded channels: stripped of their content with
385
+ * `hardDelete`, otherwise marked as deleted. `deletedAt` defaults to now.
413
386
  *
414
387
  * @private
415
- *
416
- * @param user - The user whose messages should be deleted.
417
- * @param hardDelete - Whether to fully strip the message content (optional, defaults to `false`).
418
- * @param deletedAt - Timestamp to mark messages as deleted at (optional).
419
388
  */
420
389
  _deleteUserMessageReference: (user: UserResponse, hardDelete?: boolean, deletedAt?: LocalMessage["deleted_at"]) => void;
421
- /**
422
- * Handle the following user-related events:
423
- * - `user.presence.changed`
424
- * - `user.updated`
425
- * - `user.deleted`
426
- *
427
- * @private
428
- *
429
- * @param event - The user event.
430
- */
390
+ /** @private */
431
391
  _handleUserEvent: (event: Extract<WSEvent, {
432
392
  type: "user.presence.changed" | "user.updated" | "user.deleted";
433
393
  }>) => void;
434
- _handleClientEvent(event: WSEvent | ConnectedEvent): (() => void)[];
435
- /**
436
- * Fans the client-owned `mutedChannels` out to every active channel's reactive `state.muteStatus`.
437
- * Each channel republishes only when its own mute status actually changed, so this stays cheap on
438
- * the frequent `health.check` path.
439
- */
440
- _reflectMutedChannelsToActiveChannels(): void;
441
- /**
442
- * Resets the AI indicator state to `Idle` on every active channel. Invoked from `closeConnection`
443
- * as it's a deliberate shutdown and will not natively trigger a WS event.
444
- */
445
- _resetAIStateOnActiveChannels(): void;
446
- /**
447
- * Demotes every actively-watched channel to `WasWatching`. The server keys watches by connection
448
- * ID, so losing the socket ends every watch this client held — a reconnect issues a NEW id and the
449
- * channels have to be re-queried to watch again. `WasWatching` is what records that they should be.
450
- *
451
- * Only `Watching` is demoted: a channel the consumer stopped on purpose, or one that was torn
452
- * down, stays `NotWatching` and must not be resurrected by a reconnect.
453
- *
454
- * Invoked from two places, because neither covers the other: `StableWSConnection._setHealth(false)`
455
- * for an abnormal close/error (immediately — NOT via the `connection.changed` event, which is
456
- * 5s-debounced when going offline and is skipped entirely on a quick flap, both of which would
457
- * leave the status lying), and `closeConnection()` for a deliberate shutdown (e.g. mobile
458
- * backgrounding), which sets `isHealthy` directly and so never reaches `_setHealth`.
459
- */
460
- _markActiveChannelsWatchInterrupted(): void;
394
+ _handleClientEvent(event: WSEvent): (() => void)[];
461
395
  _muteStatus(cid: string): ChannelMuteStatus;
462
396
  _callClientListeners: (event: Event) => void;
463
397
  /**
464
- * Settles the connect promises after a successful reconnect, so the `await this.wsPromise` gates
465
- * spread across the client stop resolving against a superseded (possibly rejected) attempt.
466
- *
467
- * Called by `StableWSConnection._reconnect()`. Recovery itself is owned by
468
- * {@link ConnectionRecoveryManager}, which subscribes to the connection lifecycle and so covers
469
- * every reconnect path — including `closeConnection()` → `openConnection()` (mobile backgrounding),
470
- * which never reaches `_reconnect()` at all.
398
+ * Settles the connect promises after a successful reconnect, so a held `wsPromise` /
399
+ * `setUserPromise` stops resolving against a superseded (possibly rejected) attempt. Called by
400
+ * `StableWSConnection._reconnect()` and `WSConnectionFallback.connect(true)`. Recovery itself
401
+ * belongs to {@link ConnectionRecoveryManager}.
471
402
  *
472
403
  * @internal
473
404
  */
474
405
  _settleConnectPromises: () => void;
475
- /**
476
- * @private
477
- */
406
+ /** @private */
478
407
  connect(): Promise<void | import("./types").ConnectionOpen>;
479
408
  /**
480
- * Checks connectivity with the server for warmup purposes.
481
- *
482
- * @private
483
- */
484
- _sayHi(): void;
485
- /**
486
- * Queries users and watches user presence.
409
+ * Queries users and stores them in `client.state.users`. Watches presence only when
410
+ * `request.payload.presence` is set.
487
411
  *
488
412
  * @param ...args - `[request, requestOptions]`. The optional `request.payload` accepts
489
- * MongoDB-style filter conditions, sort directions (e.g. `[{ field: 'last_active', direction: -1 }]`),
490
- * and options such as `presence`. `requestOptions` carries per-request options such as an
491
- * abort `signal` and is never serialized into the request.
413
+ * MongoDB-style filter conditions, sort directions (e.g.
414
+ * `[{ field: 'last_active', direction: -1 }]`), and options such as `presence`.
415
+ * `requestOptions` carries per-request options such as an abort `signal` and is never
416
+ * serialized into the request.
492
417
  * @returns The user query response.
493
418
  */
494
419
  queryUsers(...args: Parameters<ChatApi['queryUsers']>): Promise<StreamResponse<import(".").QueryUsersResponse>>;
495
420
  /**
496
- * Queries channels and returns the full API response including top-level metadata such as
497
- * `predefined_filter`.
421
+ * Stops watching a channel on this client's connection. It carries no `watch` flag, but it waits
422
+ * for the connection ID like a watching request (through a handshake or reconnect, until the
423
+ * caller's abort signal fires) and throws when there is no connection and none is being
424
+ * established.
498
425
  *
499
- * This exists as a compatibility bridge, as changing `queryChannelsRequest()` to return
500
- * `QueryChannelsResponse` would be a breaking change because it currently returns
501
- * only the channel list. In the next major release, the request/response APIs should
502
- * be consolidated so callers can access the full response through the primary API.
426
+ * @param ...args - `[pathParams, request, requestOptions]`. `pathParams` identifies the channel
427
+ * (`{ type, id }`); `request.connection_id` is replaced by this client's connection ID.
428
+ * @returns The server response.
429
+ */
430
+ stopWatchingChannel(...args: Parameters<ChatApi['stopWatchingChannel']>): Promise<StreamResponse<import(".").Response>>;
431
+ /**
432
+ * Queries channels and returns the raw API response. See {@link queryChannelsAndHydrate} for
433
+ * `Channel` instances.
503
434
  *
504
435
  * @param ...args - `[request, requestOptions]`. The optional `request` accepts MongoDB-style
505
436
  * filter conditions, sort directions (e.g. `[{ field: 'created_at', direction: -1 }]`), and
506
- * options such as `predefined_filter`, `filter_values`, and `sort_values`. `requestOptions`
507
- * carries per-request options such as an abort `signal` and is never serialized into the request.
508
- * @returns The full query channels response.
437
+ * options such as `predefined_filter`, `filter_values`, and `sort_values`. `state`, `watch` and
438
+ * `presence` default to `true`, `true` and `false`. `requestOptions` carries per-request
439
+ * options such as an abort `signal` and is never serialized into the request.
440
+ * @returns The full query channels response, including metadata such as `predefined_filter`.
509
441
  */
510
442
  queryChannels(...args: Parameters<ChatApi['queryChannels']>): Promise<StreamResponse<QueryChannelsResponse>>;
511
443
  /**
512
- * Queries channels and hydrates them into `Channel` instances on this client.
513
- *
514
- * Use the inherited `queryChannels()` from `ChatApi` when only the raw API response
515
- * is needed; this method wraps it with state hydration, `channels.queried` dispatch,
516
- * and offline-db sync.
444
+ * Queries channels and hydrates them into `Channel` instances on this client, dispatching
445
+ * `channels.queried` and syncing the offline DB. Use `queryChannels()` for the raw API response.
517
446
  *
518
447
  * @param options - The query channels request payload (optional). Accepts MongoDB-style filter
519
448
  * conditions, sort directions (e.g. `[{ field: 'created_at', direction: -1 }]`), and options
520
449
  * such as `predefined_filter`, `filter_values`, and `sort_values`.
521
- * @param stateOptions - Options that only affect state management and aren't sent in the request
522
- * (optional, defaults to `{}`).
523
- * @param stateOptions.skipInitialization - Skips the initialization of the state for the
524
- * channels matching the IDs in the list (optional).
525
- * @param stateOptions.skipHydration - Skips returning the channels as instances of the `Channel`
526
- * class and instead returns the raw query response (optional).
527
- * @param stateOptions.withResponse - Returns the full query response with hydrated channels.
528
- * This is a compatibility bridge for internal callers that need response-level metadata while
529
- * the default return value remains `Channel[]` (optional).
530
- * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
450
+ * @param stateOptions - Options that only affect state management and are not sent in the
451
+ * request. Defaults to `{}`.
452
+ * @param stateOptions.skipHydration - Not read: it has no effect.
453
+ * @param stateOptions.withResponse - Returns the full query response (with hydrated `channels`)
454
+ * instead of `Channel[]`.
455
+ * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
531
456
  * into the request (optional).
532
457
  * @returns The hydrated channel list, or the full response when `withResponse` is `true`.
533
458
  */
534
- queryChannelsAndHydrate(options?: QueryChannelsRequest, stateOptions?: ChannelStateOptions & {
459
+ queryChannelsAndHydrate(options: QueryChannelsRequest | undefined, stateOptions: ChannelStateOptions & {
535
460
  withResponse: true;
536
461
  }, requestOptions?: StreamRequestOptions): Promise<QueryChannelsResponseWithChannels>;
537
462
  queryChannelsAndHydrate(options?: QueryChannelsRequest, stateOptions?: ChannelStateOptions, requestOptions?: StreamRequestOptions): Promise<Channel[]>;
538
463
  /**
539
- * Queries reactions for a message and hydrates any cached offline reactions before the network
540
- * request.
464
+ * Queries a message's reactions. On the first page, cached offline reactions are dispatched
465
+ * (`offline_reactions.queried`) before the network request.
541
466
  *
542
- * @param request - The query reactions request payload, including the target message ID,
543
- * MongoDB-style filters, sort directions (e.g. `[{ field: 'created_at', direction: -1 }]`),
544
- * and pagination options.
545
- * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
546
- * into the request (optional).
467
+ * @param ...args - `[pathParams, request, requestOptions]`. `pathParams.id` is the target message
468
+ * ID; `request` carries MongoDB-style filters, sort directions (e.g.
469
+ * `[{ field: 'created_at', direction: -1 }]`) and pagination options; `requestOptions` carries
470
+ * per-request options such as an abort `signal` and is never serialized into the request.
547
471
  * @returns The query reactions response.
548
472
  */
549
- queryReactionsAndHydrate(request: QueryReactionsRequestWithId, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").QueryReactionsResponse>>;
550
- hydrateActiveChannels(channelsFromApi?: ChannelStateResponseFields[], stateOptions?: ChannelStateOptions, queryChannelsOptions?: ChannelOptions, candidateIdsByCid?: Map<string, ReadonlySet<string>>): Channel[];
473
+ queryReactionsAndHydrate(...args: Parameters<ChatApi['queryReactions']>): Promise<StreamResponse<import(".").QueryReactionsResponse>>;
474
+ hydrateChannels(channelsFromApi?: ChannelStateResponseFields[], stateOptions?: ChannelStateOptions, queryChannelsOptions?: ChannelOptions, headIntervalItemIdsAtRequestByCid?: Map<string, ReadonlySet<string>>): Channel[];
551
475
  /**
552
- * Queries messages.
476
+ * Returns the channel with the given type and ID: the stored instance for the cid, or a new one,
477
+ * stored (one instance per cid; a channel disposed with `disconnect()` is replaced by a fresh
478
+ * one). Use it instead of `new Channel()`.
553
479
  *
554
- * @param ...args - `[request, requestOptions]`. The optional `request.payload` accepts
555
- * MongoDB-style filter conditions, a search query, and options such as `user_id`.
556
- * `requestOptions` carries per-request options such as an abort `signal` and is never
557
- * serialized into the request.
558
- * @returns The search messages response.
559
- */
560
- search(...args: Parameters<ChatApi['search']>): Promise<StreamResponse<import(".").SearchResponse>>;
561
- /**
562
- * Caches one channel's server configuration, read through {@link Channel.serverConfig}.
480
+ * For a distinct channel between users, leave out the ID and pass the members. It is stored under
481
+ * a temporary cid until the response of `channel.watch()`, `query()` or `create()` brings the
482
+ * real one; a stored distinct channel with the same loaded members is returned instead. If
483
+ * another instance holds the real cid by then, it stays stored and takes over from this one
484
+ * (`channel.supersededBy`; `watch()` resolves with it). A group with the same members as another
485
+ * needs its own ID. Until its query is answered such a channel is
486
+ * {@link Channel.isProvisional}: it has no ID yet, so nothing but that query can be sent for it.
563
487
  *
564
- * Keyed by **cid** rather than by channel type: a channel's own `config_overrides` narrow its type's
565
- * settings for that channel alone, so two channels of one type can disagree.
566
- *
567
- * Two writes are skipped. A response with no `config` — `notification.message_new` is one route that
568
- * omits it — would otherwise un-learn a config already known for the channel. A config deep-equal to
569
- * the stored one keeps a repeated query from waking that channel's subscribers, which matters because
570
- * the API returns a fresh object every time and the store compares by reference.
571
- *
572
- * @internal
573
- */
574
- _addChannelConfig({ cid, config }: Pick<ChannelResponse, 'cid' | 'config'>): void;
575
- /**
576
- * Returns a new channel with the given type, ID and custom data.
577
- *
578
- * If you want to create a unique conversation between 2 or more users, you can leave out the ID
579
- * parameter and provide the list of members.
580
- * Make sure to await `channel.create()` or `channel.watch()` before accessing channel functions,
581
- * i.e. `channel = client.channel('messaging', { members: ['tommaso', 'thierry'] })` then
582
- * `await channel.create()` to assign an ID to the channel.
488
+ * ```ts
489
+ * const general = client.channel('messaging', 'general');
490
+ * const dm = await client
491
+ * .channel('messaging', { members: [{ user_id: 'ann' }, { user_id: 'bob' }] })
492
+ * .watch();
493
+ * ```
583
494
  *
584
495
  * @param channelType - The channel type.
585
- * @param channelIdOrCustom - The channel ID; you can leave this out if you want to create a
586
- * conversation channel (optional).
587
- * @param custom - Custom data to attach to the channel (optional, defaults to `{}`).
588
- * @returns The channel object; initialize it using `channel.watch()`.
496
+ * @param channelId - The channel ID; leave it out for a distinct channel created from members
497
+ * (optional).
498
+ * @param custom - Data for a new channel, e.g. `members` or `custom`; for a stored channel only
499
+ * `custom` is applied. Defaults to `{}`.
500
+ * @returns The channel; initialize it with `channel.watch()`.
589
501
  */
590
502
  channel(channelType: string, channelId?: string | null, custom?: ChannelInput): Channel;
591
503
  channel(channelType: string, custom?: ChannelInput): Channel;
592
504
  /**
593
- * It's a helper method for `client.channel()` method, used to create unique conversation or
594
- * channel based on member list instead of ID.
595
- *
596
- * If the channel already exists in `activeChannels` list, then we simply return it, since that
597
- * means the same channel was already requested or created.
505
+ * Searches messages.
598
506
  *
599
- * Otherwise we create a new instance of Channel class and return it.
600
- *
601
- * @private
602
- *
603
- * @param channelType - The channel type.
604
- * @param custom - Custom data to attach to the channel.
605
- * @returns The channel object; initialize it using `channel.watch()`.
507
+ * @param ...args - `[request, requestOptions]`. The optional `request.payload` accepts channel
508
+ * `filter_conditions`, `message_filter_conditions`, a `query`, and options such as `limit`,
509
+ * `offset`, `next` and `sort`. `requestOptions` carries per-request options such as an abort
510
+ * `signal` and is never serialized into the request.
511
+ * @returns The search messages response.
512
+ * @throws When both `offset` and `next` are given.
606
513
  */
607
- getChannelByMembers: (channelType: string, custom: ChannelInput) => Channel;
514
+ search(...args: Parameters<ChatApi['search']>): Promise<StreamResponse<import(".").SearchResponse>>;
608
515
  /**
609
- * It's a helper method for `client.channel()`, used to retrieve a channel given its ID.
610
- *
611
- * If the channel already exists in `activeChannels` list, then we simply return it, since that
612
- * means the same channel was already requested or created.
516
+ * Caches one channel's server configuration, keyed by cid (see {@link Channel.serverConfig}).
517
+ * Skips the write for a response without `config` (`notification.message_new` omits it) and for a
518
+ * config deep-equal to the stored one: the API returns a fresh object each time and the store
519
+ * compares by reference.
613
520
  *
614
- * Otherwise we create a new instance of `Channel` class and return it.
615
- *
616
- * @private
617
- *
618
- * @param channelType - The channel type.
619
- * @param channelId - The channel ID.
620
- * @param custom - Custom data to attach to the channel.
621
- * @returns The channel object; initialize it using `channel.watch()`.
521
+ * @internal
622
522
  */
623
- getChannelById: (channelType: string, channelId: string, custom: ChannelInput) => Channel;
523
+ _addChannelConfig({ cid, config }: Pick<ChannelResponse, 'cid' | 'config'>): void;
624
524
  /**
625
- * Revoke a global ban for a user.
525
+ * Revokes a global ban.
626
526
  *
627
527
  * @param targetUserId - The user to unban.
628
528
  * @param options - Unban options (optional).
@@ -633,98 +533,74 @@ export declare class StreamChat extends ChatApi {
633
533
  getBlockedUsers(...args: Parameters<ChatApi['getBlockedUsers']>): Promise<StreamResponse<import(".").GetBlockedUsersResponse>>;
634
534
  unblockUser(blockedUserId: string, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UnblockUsersResponse>>;
635
535
  /**
636
- * Checks whether a user is muted. Can be used after `connectUser()` is called.
536
+ * Checks whether a user is muted.
637
537
  *
638
538
  * @param targetId - The user ID to check.
639
539
  * @returns `true` if the user is muted, otherwise `false`.
540
+ * @throws When no user is connected.
640
541
  */
641
542
  userMuteStatus(targetId: string): boolean;
642
- /**
643
- * Transforms an expiration value into an ISO string.
644
- *
645
- * A `number` is an offset in SECONDS, not a timestamp — passing a wire `pin_expires` overflows
646
- * `Date`, which used to surface as an opaque `RangeError` from `toISOString()`.
647
- *
648
- * @param timeoutOrExpirationDate - Expiration date or timeout. Use `number` to set the timeout
649
- * in seconds, `string` or `Date` to set the exact expiration date (optional).
650
- * @returns The expiration as an ISO string, or `null`.
651
- * @throws If a numeric offset does not resolve to a representable date.
652
- */
653
- _normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
654
- /**
655
- * Extracts a string message ID from either a message object or a message ID.
656
- *
657
- * @param messageOrMessageId - MessageRequest object or message ID.
658
- * @param errorText - Error message to report in case of message ID absence.
659
- * @returns The extracted message ID.
660
- */
661
- _validateAndGetMessageId(messageOrMessageId: string | {
662
- id: string;
663
- }, errorText: string): string;
664
543
  /**
665
544
  * Pins the message.
666
545
  *
667
- * @param messageOrMessageId - MessageRequest object or message ID.
668
- * @param timeoutOrExpirationDate - Expiration date or timeout. Use `number` to set the timeout
669
- * in seconds, `string` or `Date` to set the exact expiration date (optional).
670
- * @param pinnedAt - Date when the message should be pinned. It affects the order of pinned
671
- * messages. Use a negative number to set relative time in the past, `string` or `Date` to
672
- * set the exact date of pin (optional).
546
+ * @param message - The message to pin, or just its `{ id }`.
547
+ * @param options - When the pin expires and where it sorts (optional).
548
+ * @param options.pin_expires - When the pin expires, as a `Date` or an RFC3339 string; `null` or
549
+ * leaving it out pins without expiry. Hand a server-sent timestamp back with `nsToDate(timestamp)`.
550
+ * @param options.pinned_at - The pin time, which orders the pinned messages, as a `Date` or an
551
+ * RFC3339 string (optional). Defaults to now.
673
552
  * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
674
553
  * into the request (optional).
675
554
  * @returns The updated message response.
676
555
  */
677
- pinMessage(messageOrMessageId: string | {
556
+ pinMessage({ id }: {
678
557
  id: string;
679
- }, timeoutOrExpirationDate?: null | number | string | Date, pinnedAt?: number | string | Date, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMessagePartialResponse>>;
558
+ }, { pin_expires, pinned_at }?: PinMessageOptions, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMessagePartialResponse>>;
680
559
  /**
681
560
  * Unpins the message that was previously pinned.
682
561
  *
683
- * @param messageOrMessageId - MessageRequest object or message ID.
562
+ * @param message - The message to unpin, or just its `{ id }`.
684
563
  * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
685
564
  * into the request (optional).
686
565
  * @returns The updated message response.
687
566
  */
688
- unpinMessage(messageOrMessageId: string | {
567
+ unpinMessage({ id }: {
689
568
  id: string;
690
569
  }, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMessagePartialResponse>>;
691
570
  /**
692
- * Updates the given message. When an `offlineDb` is registered the call is queued
693
- * so it is replayed on reconnect.
694
- */
695
- updateMessage(...args: [
696
- request: Parameters<ChatApi['updateMessage']>[0] & {
697
- message: {
698
- cid?: string;
699
- };
700
- },
701
- requestOptions?: StreamRequestOptions
702
- ]): Promise<import(".").UpdateMessageResponse & {
703
- metadata: import("./types").RequestMetadata;
704
- }>;
705
- _updateMessage(...args: Parameters<ChatApi['updateMessage']>): Promise<StreamResponse<import(".").UpdateMessageResponse>>;
571
+ * Updates a message over HTTP only: no offline queueing and no local state.
572
+ * `messageOperations.update` on a channel or thread is the full edit.
573
+ *
574
+ * @param ...args - `[pathParams, request, requestOptions]`. `pathParams.id` is the message ID;
575
+ * `request.message` is the updated message; `requestOptions` carries per-request options such
576
+ * as an abort `signal` and is never serialized into the request.
577
+ * @returns The update message response.
578
+ */
579
+ updateMessage(...args: Parameters<ChatApi['updateMessage']>): Promise<StreamResponse<import(".").UpdateMessageResponse>>;
706
580
  /**
707
- * Deletes a message. When an `offlineDb` is registered the call is queued so it
708
- * is replayed on reconnect.
581
+ * Deletes a message over HTTP only: no offline queueing and no local state.
582
+ * `messageOperations.delete` on a channel or thread is the full delete.
583
+ *
584
+ * @param ...args - `[pathParams, request, requestOptions]`. `pathParams.id` is the message ID;
585
+ * `request.hard` deletes it permanently and `request.delete_for_me` deletes it for the current
586
+ * user only; `requestOptions` carries per-request options such as an abort `signal` and is
587
+ * never serialized into the request.
588
+ * @returns The delete message response.
709
589
  */
710
- deleteMessage(...args: Parameters<ChatApi['deleteMessage']>): Promise<import(".").DeleteMessageResponse & {
711
- metadata: import("./types").RequestMetadata;
712
- }>;
713
- _deleteMessage(...args: Parameters<ChatApi['deleteMessage']>): Promise<StreamResponse<import(".").DeleteMessageResponse>>;
714
- /**
715
- * Returns the list of threads of the current user.
716
- *
717
- * @param options - Options object for pagination and limiting the participants and replies
718
- * (optional, defaults to `{}`).
719
- * @param options.limit - Limits the number of threads to be returned (optional).
720
- * @param options.watch - Subscribes the user to the channels of the threads (optional).
721
- * @param options.participant_limit - Limits the number of participants returned per thread (optional).
722
- * @param options.reply_limit - Limits the number of replies returned per thread (optional).
723
- * @param options.filter - MongoDB style filters for threads (optional).
724
- * @param options.sort - MongoDB style sort for threads (optional).
725
- * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
590
+ deleteMessage(...args: Parameters<ChatApi['deleteMessage']>): Promise<StreamResponse<import(".").DeleteMessageResponse>>;
591
+ /**
592
+ * Returns the current user's threads as hydrated `Thread` instances.
593
+ *
594
+ * @param options - Pagination and limits for the participants and replies. Defaults to `{}`.
595
+ * @param options.limit - Limits the number of threads returned. Defaults to 10.
596
+ * @param options.watch - Subscribes the user to the channels of the threads. Defaults to `true`.
597
+ * @param options.participant_limit - Limits the participants returned per thread. Defaults to 10.
598
+ * @param options.reply_limit - Limits the replies returned per thread. Defaults to 3.
599
+ * @param options.filter - MongoDB-style filters for threads (optional).
600
+ * @param options.sort - MongoDB-style sort for threads (optional).
601
+ * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
726
602
  * into the request (optional).
727
- * @returns The list of threads and the next cursor.
603
+ * @returns The threads and the next cursor.
728
604
  */
729
605
  queryThreadsAndHydrate(options?: QueryThreadsRequest, requestOptions?: StreamRequestOptions): Promise<{
730
606
  threads: Thread[];
@@ -733,17 +609,20 @@ export declare class StreamChat extends ChatApi {
733
609
  /**
734
610
  * Returns the thread of a message by its ID, wrapped in a hydrated `Thread` instance.
735
611
  *
736
- * @param messageId - The message ID.
737
- * @param options - Options object for pagination and limiting the participants and replies
738
- * (optional, defaults to `{}`).
739
- * @param options.watch - Subscribes the user to the channel of the thread (optional).
740
- * @param options.participant_limit - Limits the number of participants returned per thread (optional).
741
- * @param options.reply_limit - Limits the number of replies returned per thread (optional).
612
+ * @param pathParams - The thread's parent message, as for `getThread`.
613
+ * @param pathParams.message_id - The parent message ID.
614
+ * @param options - Options object for pagination and limiting the participants and replies.
615
+ * Defaults to `{}`.
616
+ * @param options.watch - Subscribes the user to the channel of the thread. Defaults to `true`.
617
+ * @param options.participant_limit - Limits the participants returned. Defaults to 100.
618
+ * @param options.reply_limit - Limits the replies returned. Defaults to 3.
742
619
  * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
743
620
  * into the request (optional).
744
621
  * @returns The thread.
745
622
  */
746
- getThreadAndHydrate(messageId: string, options?: GetThreadOptions, requestOptions?: StreamRequestOptions): Promise<Thread>;
623
+ getThreadAndHydrate({ message_id: messageId }: {
624
+ message_id: string;
625
+ }, options?: GetThreadOptions, requestOptions?: StreamRequestOptions): Promise<Thread>;
747
626
  getUserAgent: () => string;
748
627
  /**
749
628
  * Sets the user agent string.
@@ -753,53 +632,60 @@ export declare class StreamChat extends ChatApi {
753
632
  * @param userAgent - The user agent string.
754
633
  */
755
634
  setUserAgent(userAgent: string): void;
756
- _cacheEnabled: () => boolean;
757
635
  _startCleaning(): void;
758
636
  /**
759
- * Encodes the WebSocket auth message, sent as the first frame once the socket opens.
637
+ * The JSON-encoded WebSocket auth message, sent as the first frame once the socket opens.
760
638
  *
761
- * `products` is not optional in practice: without `'chat'` the server treats the
762
- * connection as video-only, which drops every chat event and unread count.
639
+ * @private
640
+ */
641
+ _buildWSAuthMessage: () => string;
642
+ /**
643
+ * The auth message that {@link _buildWSAuthMessage} encodes for the WebSocket and the long-poll
644
+ * fallback sends as `longPoll()`'s `json` query param.
763
645
  *
764
646
  * @private
765
647
  *
766
- * @returns The JSON-encoded auth message.
648
+ * @param token - The long-poll passes none: it authenticates through the `Authorization` header.
767
649
  */
768
- _buildWSAuthMessage: () => string;
650
+ _buildWSAuthPayload: (token?: string) => WSAuthMessage;
769
651
  /**
770
- * Queries poll answers.
652
+ * Queries poll answers: the votes with `is_answer: true`.
771
653
  *
772
- * @param request - The query poll answers request payload, including the poll ID, optional vote
773
- * filter conditions, sort directions, and pagination options (`limit`, `offset`).
774
- * @param request.poll_id - The poll ID.
775
- * @param request.filter - Vote filter conditions.
654
+ * @param ...args - `[pathParams, request, requestOptions]`. `pathParams.poll_id` is the poll ID;
655
+ * `request` carries optional vote filter conditions, sort directions, and pagination options
656
+ * (`limit`, `next`, `prev`); `requestOptions` carries per-request options such as an abort
657
+ * `signal` and is never serialized into the request.
776
658
  * @returns The poll answers.
777
659
  */
778
- queryPollAnswers({ poll_id, filter, ...options }: Parameters<ChatApi['queryPollVotes']>[0], requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").PollVotesResponse>>;
660
+ queryPollAnswers(...args: Parameters<ChatApi['queryPollVotes']>): Promise<StreamResponse<import(".").PollVotesResponse>>;
779
661
  /**
780
- * Uploads a file to the Stream CDN
662
+ * Uploads a file to the Stream CDN.
781
663
  *
782
664
  * @param request - Upload payload. `request.file` is the file to upload.
783
- * @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal` (optional).
784
- * @returns Response containing the file URL.
665
+ * @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
666
+ * (optional).
667
+ * @returns The upload response, with the file URL.
785
668
  */
786
669
  uploadFile(request?: Omit<FileUploadRequest, 'file'> & {
787
670
  file?: FileUploadInput;
788
671
  }, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").FileUploadResponse>>;
789
672
  /**
790
- * Uploads an image to Stream CDN
673
+ * Uploads an image to the Stream CDN.
791
674
  *
792
675
  * @param request - Upload payload. `request.file` is the image to upload.
793
- * @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal` (optional).
794
- * @returns Response containing the image URL.
676
+ * @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
677
+ * (optional).
678
+ * @returns The upload response, with the image URL.
795
679
  */
796
680
  uploadImage(request?: Omit<ImageUploadRequest, 'file'> & {
797
681
  file?: FileUploadInput;
798
682
  }, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").ImageUploadResponse>>;
799
683
  /**
800
- * Marks the channels as delivered for the given messages and the user.
684
+ * Marks channels as delivered for the given messages.
801
685
  *
802
686
  * @param request - Mark delivered options.
687
+ * @param requestOptions - Per-request options such as an abort `signal`. Never serialized
688
+ * into the request (optional).
803
689
  * @returns The server response, or `undefined` if there are no messages to mark.
804
690
  */
805
691
  markChannelsDelivered(request?: Gen_MarkDeliveredRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").MarkDeliveredResponse> | undefined>;