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
@@ -6,11 +6,7 @@ import type { TokenOrProvider } from './types';
6
6
  const logger = chatLoggerSystem.getLogger('token-manager');
7
7
 
8
8
  export type TokenManagerMinimalUser = { id: string; anon?: boolean };
9
- /**
10
- * TokenManager
11
- *
12
- * Handles all the operations around user token.
13
- */
9
+ /** Holds the user token, either static or loaded from a provider. */
14
10
  export class TokenManager {
15
11
  loadTokenPromise: Promise<string> | null;
16
12
  type: 'static' | 'provider';
@@ -18,9 +14,6 @@ export class TokenManager {
18
14
  tokenProvider?: TokenOrProvider;
19
15
  user?: TokenManagerMinimalUser;
20
16
  private _isAnonymous = false;
21
- /**
22
- * Initializes the token manager.
23
- */
24
17
  constructor() {
25
18
  this.loadTokenPromise = null;
26
19
 
@@ -32,11 +25,11 @@ export class TokenManager {
32
25
  }
33
26
 
34
27
  /**
35
- * Sets the static string token or token provider. A token provider should return a token string
36
- * or a promise that resolves to a token string.
28
+ * Sets a static token or a token provider, then loads the token.
37
29
  *
38
- * @param tokenOrProvider - A token string or an async provider that returns one.
30
+ * @param tokenOrProvider - A token string, or an async provider that resolves to one.
39
31
  * @param user - The user the token belongs to.
32
+ * @throws When the token is not a string or function, or a string token does not match `user.id`.
40
33
  */
41
34
  setTokenOrProvider = async (
42
35
  tokenOrProvider: TokenOrProvider,
@@ -60,8 +53,10 @@ export class TokenManager {
60
53
  };
61
54
 
62
55
  /**
63
- * Resets the token manager.
64
- * Useful for client disconnection or switching user.
56
+ * Clears the token, the provider and the user. Called by the client on `disconnectUser()` and
57
+ * after an anonymous `createGuest()`.
58
+ *
59
+ * @internal
65
60
  */
66
61
  reset = () => {
67
62
  this._isAnonymous = false;
@@ -72,9 +67,8 @@ export class TokenManager {
72
67
  this.loadTokenPromise = null;
73
68
  };
74
69
 
75
- // Validates the user token.
76
70
  validateToken = (tokenOrProvider: TokenOrProvider, user: TokenManagerMinimalUser) => {
77
- // allow empty token for anon user
71
+ // Anonymous users may have an empty token.
78
72
  if (user && user.anon && !tokenOrProvider) return;
79
73
 
80
74
  if (
@@ -86,7 +80,6 @@ export class TokenManager {
86
80
  }
87
81
 
88
82
  if (typeof tokenOrProvider === 'string') {
89
- // Allow empty token for anonymous users
90
83
  if (user.anon && tokenOrProvider === '') return;
91
84
 
92
85
  const tokenUserId = UserFromToken(tokenOrProvider);
@@ -101,12 +94,10 @@ export class TokenManager {
101
94
  }
102
95
  };
103
96
 
104
- // Resolves when token is ready. This function is simply to check if loadToken is in progress, in which
105
- // case a function should wait.
97
+ // The in-flight token load, for callers that must wait for it.
106
98
  tokenReady = () => this.loadTokenPromise;
107
99
 
108
- // Fetches a token from tokenProvider function and sets in tokenManager.
109
- // In case of static token, it will simply resolve to static token.
100
+ // Fetches the token from the provider and stores it. A static token resolves as is.
110
101
  loadToken = () => {
111
102
  // eslint-disable-next-line no-async-promise-executor
112
103
  this.loadTokenPromise = new Promise(async (resolve, reject) => {
@@ -132,7 +123,6 @@ export class TokenManager {
132
123
  return this.loadTokenPromise;
133
124
  };
134
125
 
135
- // Returns a current token
136
126
  getToken = () => {
137
127
  if (this.token) {
138
128
  return this.token;
@@ -143,7 +133,7 @@ export class TokenManager {
143
133
  }
144
134
 
145
135
  throw new Error(
146
- `Both secret and user tokens are not set. Either client.connectUser wasn't called or client.disconnect was called`,
136
+ `User token is not set. Either client.connectUser wasn't called or client.disconnectUser was called`,
147
137
  );
148
138
  };
149
139
 
package/src/types.ts CHANGED
@@ -1,27 +1,26 @@
1
- import type { AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import type { StableWSConnection } from './connection';
1
+ import type { AxiosResponse } from 'axios';
3
2
  import type { CustomEventTypes } from './custom_types';
4
- import type { NotificationManager } from './notifications';
5
- import type { InstanceConfigTree } from './configuration/types';
6
- import type { DeepPartial } from './types.utility';
7
3
  import type {
8
4
  APIError,
9
5
  Attachment,
10
6
  BanRequest,
11
7
  ChannelConfigWithInfo,
12
- ChannelOwnCapability,
8
+ ChannelMemberRequest,
13
9
  ChannelStateResponseFields,
14
10
  CreateDeviceRequest,
15
11
  CreatePollRequest,
12
+ CustomEvent,
16
13
  DraftPayloadResponse,
17
14
  FlagRequest,
18
15
  Images,
16
+ MessageRequest,
19
17
  MessageResponse,
20
18
  OwnUserResponse,
21
19
  QueryChannelsRequest,
22
20
  QueryMembersPayload,
23
21
  QueryPollsRequest,
24
22
  QueryPollVotesRequest,
23
+ QueryReactionsRequest,
25
24
  QueryRemindersRequest,
26
25
  QueryThreadsRequest,
27
26
  QueryUsersPayload,
@@ -30,6 +29,7 @@ import type {
30
29
  SendMessageRequest,
31
30
  SendMessageResponse,
32
31
  SharedLocationResponseData,
32
+ TimestampNS,
33
33
  TranslateMessageRequest,
34
34
  UpdateChannelRequest,
35
35
  UpdateMessageRequest,
@@ -41,9 +41,6 @@ import type {
41
41
 
42
42
  import type { ChatApi } from './gen-imports';
43
43
 
44
- /**
45
- * Utility Types
46
- */
47
44
  export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
48
45
  {
49
46
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
@@ -53,24 +50,9 @@ export type RequireAtLeastOne<T> = {
53
50
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Omit<T, K>>;
54
51
  }[keyof T];
55
52
 
56
- export type Unpacked<T> = T extends (infer U)[]
57
- ? U
58
- : T extends (...args: any[]) => infer U
59
- ? U
60
- : T extends Promise<infer U>
61
- ? U
62
- : T;
63
-
64
53
  /**
65
- * Response Types
66
- */
67
-
68
- /**
69
- * Legacy response envelope. Every generated response already carries `duration`, and the
70
- * transport wraps results in `StreamResponse<T>`, which also carries `metadata`.
71
- *
72
- * Only still referenced by the hand-written `/moderation/*` methods on `StreamChat` that
73
- * bypass the generated client. Delete this together with those.
54
+ * Used only by `StreamChat.unbanUser`, a hand-written `/moderation/*` call that bypasses the
55
+ * generated client.
74
56
  */
75
57
  export type APIResponse = {
76
58
  duration: string;
@@ -78,6 +60,33 @@ export type APIResponse = {
78
60
 
79
61
  export type ChannelUpdateOptions = Omit<UpdateChannelRequest, 'message'>;
80
62
 
63
+ /**
64
+ * A channel update that adds or removes items (members, invitees, filter tags): the items, a message
65
+ * notifying the channel members, and any other `update()` option.
66
+ */
67
+ type ChannelItemsUpdate<Key extends string, Item> = Record<Key, Item[]> & {
68
+ /** Message object for channel members notification (optional). */
69
+ message?: MessageRequest;
70
+ } & ChannelUpdateOptions;
71
+
72
+ /** Request of `channel.addMembers`: user IDs, or member requests with a role or custom data. */
73
+ export type AddMembersRequest = ChannelItemsUpdate<
74
+ 'members',
75
+ string | ChannelMemberRequest
76
+ >;
77
+
78
+ /** Request of `channel.inviteMembers`. */
79
+ export type InviteMembersRequest = ChannelItemsUpdate<
80
+ 'members',
81
+ string | Required<Omit<ChannelMemberRequest, 'channel_role'>>
82
+ >;
83
+
84
+ /** Request of `channel.removeMembers`: the user IDs to remove. */
85
+ export type RemoveMembersRequest = ChannelItemsUpdate<'members', string>;
86
+
87
+ /** Request of `channel.addFilterTags` and `channel.removeFilterTags`. */
88
+ export type FilterTagsRequest = ChannelItemsUpdate<'tags', string>;
89
+
81
90
  export type ConnectAPIResponse = Promise<void | ConnectionOpen>;
82
91
 
83
92
  export type LocalMessage = MessageResponse & {
@@ -86,49 +95,43 @@ export type LocalMessage = MessageResponse & {
86
95
  user_id?: string;
87
96
  };
88
97
 
89
- export type GetThreadOptions = Omit<Parameters<ChatApi['getThread']>[0], 'message_id'>;
98
+ export type GetThreadOptions = NonNullable<Parameters<ChatApi['getThread']>[1]>;
99
+
100
+ /** Options of `client.pinMessage`. */
101
+ export type PinMessageOptions = {
102
+ /** When the pin expires; `null` or leaving it out pins without expiry. */
103
+ pin_expires?: Date | string | null;
104
+ /** The pin time, which orders the pinned messages. Defaults to now. */
105
+ pinned_at?: Date | string;
106
+ };
90
107
 
91
108
  /**
92
- * The fields that exist on the connected user (`OwnUserResponse`) but not on a plain
93
- * `UserResponse` — i.e. the own-user-only slice of the user object.
94
- *
95
- * Derived, never hand-listed: `client._handleUserEvent` uses this set (through
96
- * `isOwnUserBaseProperty`) to decide which keys survive a `user.updated` event, so a field
97
- * missing from it is silently deleted off `client.user`. Deriving it means a spec change
98
- * cannot desynchronise the two.
109
+ * The fields of `OwnUserResponse` that a plain `UserResponse` lacks. `client._handleUserEvent` uses
110
+ * it (through `isOwnUserBaseProperty`) to decide which keys survive a `user.updated` event.
99
111
  */
100
112
  export type OwnUserBase = Pick<
101
113
  OwnUserResponse,
102
114
  Exclude<keyof OwnUserResponse, keyof UserResponse>
103
115
  >;
104
116
 
105
- // Thumb URL(thumb_url) is added considering video attachments as the backend will return the thumbnail in the response.
106
117
  export type BanUserOptions = Omit<BanRequest, 'target_user_id'>;
107
118
 
108
119
  /**
109
120
  * Everything `queryChannels()` accepts apart from the filter and the sort.
110
121
  *
111
- * Derived from the generated request so new query options appear here automatically.
112
- *
113
- * On `predefined_filter`: the backend resolves the named filter template and interpolates it
114
- * with `filter_values`. A regular `sort` can still be passed, but backend precedence applies —
115
- * if the predefined filter has its own stored sort template that template wins and the request
116
- * `sort` is ignored; if it does not, the request `sort` is used. `sort_values` interpolates the
117
- * stored sort template's placeholders. All three are only read when `predefined_filter` is set.
122
+ * `predefined_filter` names a backend filter template, interpolated with `filter_values`. If that
123
+ * template has its own stored sort, it wins over the request `sort` and `sort_values` fills its
124
+ * placeholders; otherwise the request `sort` is used. `filter_values` and `sort_values` are sent
125
+ * only when `predefined_filter` is set.
118
126
  */
119
127
  export type ChannelOptions = Omit<QueryChannelsRequest, 'filter_conditions' | 'sort'>;
120
128
 
121
129
  export type ChannelStateOptions = {
122
130
  offlineMode?: boolean;
123
- skipInitialization?: string[];
124
131
  skipHydration?: boolean;
125
132
  /**
126
- * Returns the full query response with hydrated channels from `queryChannels()`.
127
- *
128
- * This is a compatibility bridge for internal callers that need response level
129
- * metadata such as `predefined_filter`. The default `queryChannels()` return value
130
- * remains `Channel[]` to avoid a breaking change. This should be folded into a
131
- * single full response API in the next major release.
133
+ * Makes `queryChannelsAndHydrate()` return the full query response (with hydrated `channels`,
134
+ * plus metadata such as `predefined_filter`) instead of `Channel[]`.
132
135
  */
133
136
  withResponse?: boolean;
134
137
  };
@@ -139,81 +142,12 @@ export type Automod = ChannelConfigWithInfo['automod'];
139
142
  export type AutomodBehavior = ChannelConfigWithInfo['automod_behavior'];
140
143
 
141
144
  export type PinnedMessagePaginationOptions = Omit<
142
- Parameters<ChatApi['getPinnedMessages']>[0],
143
- 'id' | 'sort' | 'type'
145
+ NonNullable<Parameters<ChatApi['getPinnedMessages']>[1]>,
146
+ 'sort'
144
147
  >;
145
148
 
146
149
  export type QueryMembersOptions = Partial<Omit<QueryMembersPayload, 'filter_conditions'>>;
147
150
 
148
- export type StreamChatOptions = {
149
- /**
150
- * Used to disable warnings that are triggered by using connectUser or connectAnonymousUser server-side.
151
- */
152
- allowServerSideConnect?: boolean;
153
- axiosRequestConfig?: AxiosRequestConfig;
154
- /**
155
- * Base url to use for API
156
- * such as https://chat-proxy-dublin.stream-io-api.com
157
- */
158
- baseURL?: string;
159
- browser?: boolean;
160
- /**
161
- * Disables the hydration of all caches within the JS Client. This includes this.activeChannels,
162
- * this.polls.pollCache and this.config.
163
- * It is mainly meant to be used for integrations where stream-chat is used as a server-side service
164
- * interacting with Stream's REST API, not depending on any state and purely serving as a wrapper
165
- * around HTTP requests. Using this property on either the client side or a backend implementation
166
- * that also relies on WS events will break these functionalities, so please use carefully.
167
- */
168
- disableCache?: boolean;
169
- enableInsights?: boolean;
170
- /**
171
- * When true, maintains a client-local unread count on channels that have read events disabled
172
- * (e.g. livestreams). The count increments on incoming messages and is reset via
173
- * `channel.markReadLocally()`. It is never sent to the backend, but is persisted to the offline DB.
174
- */
175
- isLocalUnreadCountEnabled?: boolean;
176
- /**
177
- * Custom notification manager service to use for the client.
178
- * If not provided, a default notification manager will be created.
179
- * Notifications are used to communicate events like errors, warnings, info, etc. Other services can publish notifications or subscribe to the NotificationManager state changes.
180
- */
181
- notifications?: NotificationManager;
182
- /**
183
- * Declarative configuration for instances the SDK creates on your behalf, seeded before the client's
184
- * own managers are constructed.
185
- *
186
- * Equivalent to calling `client.config.set(tree)` immediately after construction, except for the
187
- * `client` subtree — the configuration registry is created inside the constructor, so this is the only
188
- * way to configure `reminders` / `notifications` before they are built.
189
- */
190
- config?: DeepPartial<InstanceConfigTree>;
191
- /**
192
- * When true, user will be persisted on client. Otherwise if `connectUser` call fails, then you need to
193
- * call `connectUser` again to retry.
194
- * This is mainly useful for chat application working in offline mode, where you will need client.user to
195
- * persist even if connectUser call fails.
196
- */
197
- persistUserOnConnectionFailure?: boolean;
198
- warmUp?: boolean;
199
- /**
200
- * Sets the instance of `StableWSConnection` on the chat client. Intended purely for testing and
201
- * should not be used in production apps.
202
- */
203
- wsConnection?: StableWSConnection;
204
- /**
205
- * Overrides the `WebSocket` constructor used by `StableWSConnection`. Intended purely for
206
- * testing so a mock/drivable WebSocket can be swapped in; production code should leave this
207
- * unset and rely on the platform's global `WebSocket`.
208
- */
209
- WebSocketImpl?: typeof WebSocket;
210
- /**
211
- * Sets a suffix to the wsUrl when it is being built in `wsConnection`. Is meant to be
212
- * used purely in testing suites and should not be used in production apps.
213
- */
214
- wsUrlParams?: URLSearchParams;
215
- };
216
-
217
151
  export type UnBanUserOptions = {
218
152
  client_id?: string;
219
153
  connection_id?: string;
@@ -227,6 +161,13 @@ export type UnBanUserOptions = {
227
161
  /** Everything `queryUsers()` accepts apart from the filter and the sort. */
228
162
  export type UserOptions = Omit<QueryUsersPayload, 'filter_conditions' | 'sort'>;
229
163
 
164
+ /**
165
+ * Which connection a status refers to: `'network'` is the device's network (reported by the
166
+ * platform reporter installed on `client.networkConnection`), `'ws'` is this client's WebSocket.
167
+ * They can disagree, so each has its own store.
168
+ */
169
+ export type ConnectionType = 'network' | 'ws';
170
+
230
171
  type LocalEvent = (
231
172
  | ({ type: 'live_location_sharing.started' } & { message: MessageResponse })
232
173
  | ({ type: 'live_location_sharing.stopped' } & {
@@ -238,56 +179,50 @@ type LocalEvent = (
238
179
  isLatestMessageSet: boolean;
239
180
  };
240
181
  })
241
- | ({ type: 'connection.changed' } & { online: boolean })
242
182
  | { type: 'connection.recovered' }
183
+ // `enableWSFallback` switched from the WebSocket to long-polling.
184
+ | ({ type: 'connection.fallback_activated' } & { mode: string })
243
185
  | ({ type: 'offline_reactions.queried' } & {
244
186
  offlineReactions: ReactionResponse[];
245
187
  })
246
- | ({ type: 'capabilities.changed' } & {
247
- cid: string;
248
- own_capabilities: ChannelOwnCapability[];
249
- })
250
188
  | ({ type: 'message.read_locally' } & {
251
189
  channel_type: string;
252
190
  cid: string;
253
- created_at: number;
191
+ created_at: TimestampNS;
254
192
  channel_id?: string;
255
193
  last_read_message_id?: string;
256
194
  team?: string;
257
195
  user?: UserResponse;
258
196
  })
259
- ) & { received_at?: number };
260
-
261
- /**
262
- * The hello event of the `/api/v2/connect` WebSocket endpoint, sent once the auth frame
263
- * has been accepted. The v1 endpoint used `health.check` for this instead.
264
- *
265
- * Hand-written because the event is not published in the OpenAPI spec, so it cannot
266
- * come from `src/gen`. Remove this — along with the `decodeConnectionEvent` shim in
267
- * `connection.ts` — once the backend adds it to the spec and `src/gen` is regenerated.
268
- */
269
- export type ConnectedEvent = {
270
- type: 'connection.ok';
271
- connection_id: string;
272
- /** Unix nanoseconds, as every other wire event carries it. */
273
- created_at: number;
274
- me: OwnUserResponse;
275
- /** Unix nanoseconds, as every other wire event carries it. */
276
- received_at?: number;
277
- };
278
-
279
- export type Event = WSEvent | ConnectedEvent | LocalEvent | keyof CustomEventTypes;
197
+ ) & { received_at?: TimestampNS };
198
+
199
+ // Two WS events miss `received_at` in API spec, so we add it to typedef here. The spec's custom-event
200
+ // placeholder (`{ type: '*' } & CustomEvent`) is left out: nothing is dispatched under `'*'` (a
201
+ // custom event arrives under its own name, declared through `CustomEventTypes`), so it is neither an
202
+ // event a handler receives nor a name `on()` / `off()` accept.
203
+ export type Event =
204
+ | (Exclude<WSEvent, { type: '*' }> & { received_at?: TimestampNS })
205
+ | LocalEvent
206
+ | CustomEventTypeUnion;
207
+
208
+ // One member per key augmented into `CustomEventTypes`; `never` when none are declared.
209
+ type CustomEventTypeUnion = {
210
+ [K in keyof CustomEventTypes]: { type: K } & Omit<CustomEvent, 'type'> & {
211
+ received_at?: TimestampNS;
212
+ };
213
+ }[keyof CustomEventTypes];
280
214
  export type EventType = Event['type'] | 'all';
281
215
 
282
- export type EventHandler<T = string> = (event: Extract<Event, { type: T }>) => void;
283
-
284
216
  /**
285
- * Filter Types
217
+ * A listener for events of type `T`. `'all'` (the default) receives every event, any other type the
218
+ * event members declaring it. Custom event types have to be declared by augmenting
219
+ * `CustomEventTypes`; an undeclared name is not an `EventType`.
286
220
  */
221
+ export type EventHandler<T extends EventType = 'all'> = (
222
+ event: T extends 'all' ? Event : Extract<Event, { type: T }>,
223
+ ) => void;
287
224
 
288
- export type ReactionFilters = NonNullable<QueryReactionsRequestWithId['filter']>;
289
-
290
- export type QueryReactionsRequestWithId = Parameters<ChatApi['queryReactions']>[0];
225
+ export type ReactionFilters = NonNullable<QueryReactionsRequest['filter']>;
291
226
 
292
227
  export type ChannelFilters = NonNullable<QueryChannelsRequest['filter_conditions']>;
293
228
 
@@ -301,25 +236,6 @@ export type QueryVotesFilters = NonNullable<QueryPollVotesRequest['filter']>;
301
236
 
302
237
  export type MessageFilters = NonNullable<SearchPayload['message_filter_conditions']>;
303
238
 
304
- export type PrimitiveFilter<ObjectType> = ObjectType | null;
305
-
306
- export type QueryFilter<ObjectType = string> =
307
- NonNullable<ObjectType> extends string | number | boolean | Date
308
- ? {
309
- $eq?: PrimitiveFilter<ObjectType>;
310
- $exists?: boolean;
311
- $gt?: PrimitiveFilter<ObjectType>;
312
- $gte?: PrimitiveFilter<ObjectType>;
313
- $in?: PrimitiveFilter<ObjectType>[];
314
- $lt?: PrimitiveFilter<ObjectType>;
315
- $lte?: PrimitiveFilter<ObjectType>;
316
- }
317
- : {
318
- $eq?: PrimitiveFilter<ObjectType>;
319
- $exists?: boolean;
320
- $in?: PrimitiveFilter<Unpacked<ObjectType>>[];
321
- };
322
-
323
239
  export type UserFilters = QueryUsersPayload['filter_conditions'];
324
240
 
325
241
  export type MemberFilters = QueryMembersPayload['filter_conditions'];
@@ -329,20 +245,16 @@ export type OGAttachment = RequireLiteral<Attachment, 'og_scrape_url'>;
329
245
  export type PushProvider = CreateDeviceRequest['push_provider'];
330
246
 
331
247
  /**
332
- * Server-provided channel configuration, keyed by **cid** (`messaging:general`, …). Most of
333
- * `ChannelConfigWithInfo` is a type-level setting, but a channel's `config_overrides` can narrow it for
334
- * that channel alone, so the effective answer is per channel. Read it via `channel.serverConfig`.
248
+ * Server-provided channel configuration, keyed by cid (`messaging:general`). Keyed per channel
249
+ * because a channel's `config_overrides` can narrow its type's config. Read it via
250
+ * `channel.serverConfig`.
335
251
  */
336
252
  export type Configs = Record<string, ChannelConfigWithInfo | undefined>;
337
253
 
338
254
  export type ConnectionOpen = EventPayload<'health.check'> | EventPayload<'connection.ok'>;
339
255
 
340
256
  /**
341
- * The message `type` values the server can return.
342
- *
343
- * Hand-written because there is no generated equivalent: `MessageResponse['type']` is a bare
344
- * `string`, so deriving it would widen rather than narrow. Both the React and React Native
345
- * SDKs use this as a discriminant (RN types its SQLite message rows with it).
257
+ * The message `type` values the server can return (`MessageResponse['type']` is a bare `string`).
346
258
  */
347
259
  export type MessageLabel =
348
260
  | 'deleted'
@@ -358,8 +270,6 @@ export type TokenOrProvider = null | string | TokenProvider | undefined;
358
270
 
359
271
  export type TokenProvider = () => Promise<string>;
360
272
 
361
- export type MessageSetType = 'latest' | 'current' | 'new';
362
-
363
273
  export class StreamAPIError<T = APIError> extends Error {
364
274
  public code: number | undefined;
365
275
  public status: number | undefined;
@@ -372,13 +282,9 @@ export class StreamAPIError<T = APIError> extends Error {
372
282
  status,
373
283
  response,
374
284
  }: {
375
- /**
376
- * Stream error code (`APIError.code`)
377
- */
285
+ /** Stream error code (`APIError.code`) */
378
286
  code: StreamAPIError<T>['code'];
379
- /**
380
- * HTTP status code
381
- */
287
+ /** HTTP status code */
382
288
  status: StreamAPIError<T>['status'];
383
289
  response: StreamAPIError<T>['response'];
384
290
  },
@@ -426,9 +332,6 @@ export class StreamAPIError<T = APIError> extends Error {
426
332
  }
427
333
  }
428
334
 
429
- /**
430
- * Poll vote visibility. Derived from the generated request shape so it tracks the spec.
431
- */
432
335
  export type VotingVisibility = NonNullable<CreatePollRequest['voting_visibility']>;
433
336
 
434
337
  export type PartialPollUpdate = {
@@ -436,10 +339,7 @@ export type PartialPollUpdate = {
436
339
  unset?: Array<keyof UpdatePollRequest>;
437
340
  };
438
341
 
439
- /**
440
- * Options accepted by `moderation.flagUser` / `moderation.flagMessage` on top of the
441
- * entity they resolve and the `reason` they take positionally.
442
- */
342
+ /** Options of `moderation.flagUser` / `moderation.flagMessage` besides the entity and `reason`. */
443
343
  export type ModerationFlagOptions = Omit<
444
344
  FlagRequest,
445
345
  'entity_id' | 'entity_type' | 'reason'
@@ -463,26 +363,17 @@ export const AIStates = {
463
363
  Thinking: 'AI_STATE_THINKING',
464
364
  } as const satisfies Record<string, AIState>;
465
365
 
466
- /**
467
- * An identifier containing information about the downstream SDK using stream-chat. It
468
- * is used to resolve the user agent.
469
- */
366
+ /** The downstream SDK using stream-chat, used to resolve the user agent. */
470
367
  export type SdkIdentifier = {
471
368
  name: 'react' | 'react-native' | 'expo' | 'angular';
472
369
  version: string;
473
370
  };
474
371
 
475
- /**
476
- * An identifier containing information about the downstream device using stream-chat, if
477
- * available. Is used by the react-native SDKs to enrich the user agent further.
478
- */
372
+ /** The downstream device, used by the React Native SDKs to enrich the user agent. */
479
373
  export type DeviceIdentifier = { os: string; model?: string };
480
374
 
481
375
  /**
482
- * An identifier containing information about the downstream application integrating
483
- * stream-chat, if available. `name` is reported as `app` and `version` as `app_version`
484
- * in the user agent. Distinct from the SDK ({@link SdkIdentifier}) and device
485
- * ({@link DeviceIdentifier}) identifiers.
376
+ * The downstream app: `name` is reported as `app` and `version` as `app_version` in the user agent.
486
377
  */
487
378
  export type AppIdentifier = { name: string; version?: string };
488
379
 
@@ -506,8 +397,6 @@ export type SharedLiveLocationResponse = RequireLiteral<
506
397
 
507
398
  export type ThreadFilters = NonNullable<QueryThreadsRequest['filter']>;
508
399
 
509
- export type CreateReminderOptions = Parameters<ChatApi['createReminder']>[0];
510
-
511
400
  export type ReminderFilters = NonNullable<QueryRemindersRequest['filter']>;
512
401
 
513
402
  export type ListUserGroupsOptions = NonNullable<Parameters<ChatApi['listUserGroups']>[0]>;
@@ -542,14 +431,10 @@ export type PartializeAllBut<T, K extends keyof T> = {
542
431
  [P in K]-?: T[P];
543
432
  } & { [P in Exclude<keyof T, K>]?: T[P] };
544
433
 
545
- export type DeleteMessageOptions = Omit<Parameters<ChatApi['deleteMessage']>[0], 'id'>;
434
+ export type DeleteMessageOptions = NonNullable<Parameters<ChatApi['deleteMessage']>[1]>;
546
435
  export type SendMessageAPIResponse = StreamResponse<SendMessageResponse>;
547
436
  export type UpdateMessageOptions = Omit<UpdateMessageRequest, 'message'>;
548
437
  export type UpdateMessageAPIResponse = StreamResponse<UpdateMessageResponse>;
549
- /**
550
- * The Giphy rendition names, derived from the generated `Images` shape so the two cannot
551
- * drift. Consumed by the React and React Native SDKs to pick a rendition size.
552
- */
553
438
  export type GiphyVersions = keyof Images;
554
439
  export type TranslationLanguage = TranslateMessageRequest['language'];
555
440
 
@@ -562,8 +447,7 @@ export type FileReferenceBase = {
562
447
  export type FileUploadInput = File | Blob | FileReferenceBase | string;
563
448
 
564
449
  /**
565
- * Structural subset of axios' `AxiosProgressEvent`, kept transport-agnostic on purpose so the
566
- * public surface does not depend on axios.
450
+ * Structural subset of axios' `AxiosProgressEvent`, so the public surface does not depend on axios.
567
451
  */
568
452
  export type StreamProgressEvent = {
569
453
  loaded: number;
@@ -576,6 +460,8 @@ export type StreamRequestOptions = {
576
460
  signal?: AbortSignal;
577
461
  /** Only meaningful for upload (multipart) requests; ignored everywhere else. */
578
462
  onUploadProgress?: (event: StreamProgressEvent) => void;
463
+ /** Milliseconds before this request is aborted. */
464
+ timeout?: number;
579
465
  };
580
466
 
581
467
  export * from './gen/models';
@@ -3,9 +3,9 @@ export type DeepPartial<T> = {
3
3
  };
4
4
 
5
5
  /**
6
- * The keys of every union member, not only those common to all — which is what `keyof (A | B)` gives.
7
- * Distribution needs a naked type parameter: the same conditional written inline over a concrete union
8
- * silently yields the common keys instead.
6
+ * The keys of every union member, not only those common to all (`keyof (A | B)`). Distribution
7
+ * needs the naked type parameter: the same conditional inline over a concrete union yields the
8
+ * common keys.
9
9
  */
10
10
  export type KeysOfUnion<T> = T extends unknown ? keyof T : never;
11
11
 
@@ -9,17 +9,15 @@ const isFileReferenceBase = (value: unknown): value is FileReferenceBase =>
9
9
  typeof (value as FileReferenceBase).uri === 'string';
10
10
 
11
11
  /**
12
- * Turns a bare URI string into a {@link FileReferenceBase} so the multipart encoder can derive a
13
- * file name from it. `File`, `Blob` and picker objects pass through untouched.
12
+ * Wraps a bare URI string in a {@link FileReferenceBase}; `File`, `Blob` and picker objects pass
13
+ * through.
14
14
  */
15
15
  export const normalizeUploadFile = (file?: FileUploadInput) =>
16
16
  typeof file === 'string' ? { uri: file } : file;
17
17
 
18
18
  /**
19
- * Appends one request-body entry to a multipart form using Stream's encoding rules.
20
- *
21
- * Callers must pass **raw** values - objects and arrays are JSON-encoded here (that is what
22
- * the API expects for `user` and `upload_sizes`), so pre-stringifying them double-encodes.
19
+ * Appends one request-body entry to a multipart form. Pass **raw** values: objects and arrays are
20
+ * JSON-encoded here, so pre-stringifying them double-encodes.
23
21
  */
24
22
  export function appendToFormData(data: FormData, key: string, value: unknown) {
25
23
  if (value === undefined || value === null) return;
@@ -42,10 +40,7 @@ export function appendToFormData(data: FormData, key: string, value: unknown) {
42
40
  }
43
41
  }
44
42
 
45
- /**
46
- * Encodes a request body as `multipart/form-data`. Used by `ApiClient.sendRequest` for every
47
- * generated operation declaring that content type.
48
- */
43
+ /** Encodes a request body as `multipart/form-data`. */
49
44
  export function toFormData(body: Record<string, unknown>) {
50
45
  const data = new FormData();
51
46
  for (const [key, value] of Object.entries(body)) appendToFormData(data, key, value);