stream-chat 10.0.0-rc.8 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/README.md +7 -6
  2. package/dist/cjs/index.browser.js +22095 -22290
  3. package/dist/cjs/index.browser.js.map +4 -4
  4. package/dist/cjs/index.node.js +22143 -22298
  5. package/dist/cjs/index.node.js.map +4 -4
  6. package/dist/esm/index.mjs +22093 -22288
  7. package/dist/esm/index.mjs.map +4 -4
  8. package/dist/types/ChannelManager.d.ts +216 -135
  9. package/dist/types/CooldownTimer.d.ts +16 -27
  10. package/dist/types/EventHandlerPipeline.d.ts +18 -38
  11. package/dist/types/LiveLocationManager.d.ts +25 -47
  12. package/dist/types/api-client.d.ts +17 -5
  13. package/dist/types/channel.d.ts +435 -500
  14. package/dist/types/channel_state.d.ts +72 -112
  15. package/dist/types/client.d.ts +323 -440
  16. package/dist/types/client_state.d.ts +1 -3
  17. package/dist/types/configuration/ConfigController.d.ts +31 -125
  18. package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +32 -124
  19. package/dist/types/configuration/keys.d.ts +5 -19
  20. package/dist/types/configuration/shape.d.ts +12 -29
  21. package/dist/types/configuration/types.d.ts +64 -79
  22. package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +14 -36
  23. package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
  24. package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
  25. package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
  26. package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
  27. package/dist/types/connection/ConnectionIdManager.d.ts +45 -0
  28. package/dist/types/connection/ConnectionRecoveryManager.d.ts +84 -0
  29. package/dist/types/connection/index.d.ts +4 -0
  30. package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +82 -0
  31. package/dist/types/connection/networkConnection/index.d.ts +3 -0
  32. package/dist/types/connection/networkConnection/reporters.d.ts +20 -0
  33. package/dist/types/connection/networkConnection/types.d.ts +40 -0
  34. package/dist/types/connection/wsConnection/StableWSConnection.d.ts +137 -0
  35. package/dist/types/connection/wsConnection/WSConnection.d.ts +105 -0
  36. package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +47 -0
  37. package/dist/types/connection/wsConnection/config.d.ts +31 -0
  38. package/dist/types/connection/wsConnection/index.d.ts +4 -0
  39. package/dist/types/connection/wsConnection/types.d.ts +46 -0
  40. package/dist/types/constants.d.ts +3 -1
  41. package/dist/types/custom_types.d.ts +0 -2
  42. package/dist/types/entityStore/EntityStore.d.ts +226 -65
  43. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +19 -33
  44. package/dist/types/entityStore/index.d.ts +0 -1
  45. package/dist/types/errors.d.ts +16 -19
  46. package/dist/types/formatMessageMemo.d.ts +5 -0
  47. package/dist/types/gen/chat/ChannelApi.d.ts +5 -1
  48. package/dist/types/gen/chat/ChatApi.d.ts +149 -105
  49. package/dist/types/gen/models/index.d.ts +2540 -698
  50. package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
  51. package/dist/types/gen/moderation/ModerationApi.d.ts +37 -14
  52. package/dist/types/index.d.ts +10 -5
  53. package/dist/types/{i18n/languageNames.d.ts → languageNames.d.ts} +9 -24
  54. package/dist/types/logger.d.ts +1 -3
  55. package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
  56. package/dist/types/messageComposer/LocationComposer.d.ts +8 -2
  57. package/dist/types/messageComposer/attachmentIdentity.d.ts +24 -0
  58. package/dist/types/messageComposer/attachmentManager.d.ts +52 -24
  59. package/dist/types/messageComposer/attachmentUtils.d.ts +23 -0
  60. package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
  61. package/dist/types/messageComposer/configuration/types.d.ts +38 -50
  62. package/dist/types/messageComposer/index.d.ts +1 -0
  63. package/dist/types/messageComposer/linkPreviewsManager.d.ts +12 -9
  64. package/dist/types/messageComposer/messageComposer.d.ts +60 -123
  65. package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +10 -1
  66. package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +4 -0
  67. package/dist/types/messageComposer/middleware/messageComposer/commandInjection.d.ts +5 -0
  68. package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +2 -0
  69. package/dist/types/messageComposer/middleware/messageComposer/pollOnly.d.ts +6 -0
  70. package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +5 -0
  71. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
  72. package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
  73. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +4 -0
  74. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +11 -2
  75. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +20 -19
  76. package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
  77. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
  78. package/dist/types/messageComposer/pollComposer.d.ts +15 -5
  79. package/dist/types/messageComposer/textComposer.d.ts +14 -7
  80. package/dist/types/messageComposer/types.d.ts +27 -7
  81. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +27 -80
  82. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +43 -73
  83. package/dist/types/messageOperations/FailedSendCache.d.ts +29 -0
  84. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +16 -22
  85. package/dist/types/messageOperations/MessageOperations.d.ts +63 -34
  86. package/dist/types/messageOperations/applyReactionLocally.d.ts +15 -0
  87. package/dist/types/messageOperations/createMessageOperations.d.ts +9 -0
  88. package/dist/types/messageOperations/index.d.ts +6 -4
  89. package/dist/types/messageOperations/reflectReactionEvent.d.ts +16 -0
  90. package/dist/types/messageOperations/sendOrdering.d.ts +14 -0
  91. package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +20 -0
  92. package/dist/types/messageOperations/types.d.ts +43 -14
  93. package/dist/types/middleware.d.ts +10 -0
  94. package/dist/types/moderation.d.ts +21 -14
  95. package/dist/types/notifications/NotificationManager.d.ts +10 -23
  96. package/dist/types/notifications/types.d.ts +21 -57
  97. package/dist/types/offline-support/offline_support_api.d.ts +150 -528
  98. package/dist/types/offline-support/offline_sync_manager.d.ts +21 -42
  99. package/dist/types/offline-support/queueableOperations.d.ts +35 -37
  100. package/dist/types/offline-support/types.d.ts +40 -185
  101. package/dist/types/pagination/FilterBuilder.d.ts +1 -18
  102. package/dist/types/pagination/ItemIndex.d.ts +4 -12
  103. package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
  104. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +4 -5
  105. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +19 -5
  106. package/dist/types/pagination/index.d.ts +1 -0
  107. package/dist/types/pagination/paginators/BasePaginator.d.ts +604 -550
  108. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +123 -106
  109. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +576 -327
  110. package/dist/types/pagination/paginators/MessagePaginator.d.ts +237 -131
  111. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +15 -26
  112. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +4 -3
  113. package/dist/types/pagination/paginators/ThreadPaginator.d.ts +44 -0
  114. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +5 -8
  115. package/dist/types/pagination/paginators/index.d.ts +1 -0
  116. package/dist/types/pagination/sortCompiler.d.ts +11 -22
  117. package/dist/types/pagination/utility.normalization.d.ts +8 -13
  118. package/dist/types/pagination/utility.search.d.ts +3 -8
  119. package/dist/types/poll.d.ts +35 -8
  120. package/dist/types/poll_manager.d.ts +12 -2
  121. package/dist/types/poll_optimistic_votes.d.ts +57 -0
  122. package/dist/types/reminders/Reminder.d.ts +17 -7
  123. package/dist/types/reminders/ReminderManager.d.ts +13 -25
  124. package/dist/types/search/BaseSearchSource.d.ts +10 -8
  125. package/dist/types/search/ChannelSearchSource.d.ts +16 -0
  126. package/dist/types/search/MessageSearchSource.d.ts +17 -0
  127. package/dist/types/search/SearchController.d.ts +26 -28
  128. package/dist/types/search/types.d.ts +6 -10
  129. package/dist/types/signing.d.ts +12 -3
  130. package/dist/types/thread.d.ts +67 -129
  131. package/dist/types/thread_manager.d.ts +95 -66
  132. package/dist/types/token_manager.d.ts +8 -13
  133. package/dist/types/types.d.ts +81 -197
  134. package/dist/types/types.utility.d.ts +3 -3
  135. package/dist/types/upload-utils.d.ts +5 -10
  136. package/dist/types/uploadManager.d.ts +31 -11
  137. package/dist/types/utils/FixedSizeQueueCache.d.ts +8 -11
  138. package/dist/types/utils/WithSubscriptions.d.ts +6 -16
  139. package/dist/types/utils/abort.d.ts +17 -0
  140. package/dist/types/utils/concurrency.d.ts +12 -20
  141. package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
  142. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
  143. package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
  144. package/dist/types/utils/objectPath.d.ts +6 -41
  145. package/dist/types/utils/retryable.d.ts +8 -12
  146. package/dist/types/utils/throttling/throttle.d.ts +8 -23
  147. package/dist/types/utils/time.d.ts +45 -0
  148. package/dist/types/utils.d.ts +74 -93
  149. package/package.json +14 -40
  150. package/src/ChannelManager.ts +494 -303
  151. package/src/CooldownTimer.ts +46 -59
  152. package/src/EventHandlerPipeline.ts +22 -45
  153. package/src/LiveLocationManager.ts +99 -91
  154. package/src/api-client.ts +113 -50
  155. package/src/campaign.ts +1 -1
  156. package/src/channel.ts +1098 -1351
  157. package/src/channel_batch_updater.ts +1 -1
  158. package/src/channel_state.ts +81 -174
  159. package/src/client.ts +755 -970
  160. package/src/client_state.ts +3 -8
  161. package/src/configuration/ConfigController.ts +42 -158
  162. package/src/configuration/InstanceConfigurationRegistry.ts +43 -172
  163. package/src/configuration/index.ts +1 -1
  164. package/src/configuration/keys.ts +13 -32
  165. package/src/configuration/shape.ts +169 -59
  166. package/src/configuration/types.ts +69 -92
  167. package/src/configuration/utils/applyInstanceConfiguration.ts +22 -54
  168. package/src/configuration/utils/copyConfigPatch.ts +11 -32
  169. package/src/configuration/utils/declarativeSlices.ts +9 -39
  170. package/src/configuration/utils/deepFreezeConfig.ts +3 -17
  171. package/src/configuration/utils/index.ts +2 -4
  172. package/src/configuration/utils/serverAuthority.ts +20 -68
  173. package/src/connection/ConnectionIdManager.ts +111 -0
  174. package/src/connection/ConnectionRecoveryManager.ts +257 -0
  175. package/src/connection/index.ts +4 -0
  176. package/src/connection/networkConnection/NetworkConnectionObserver.ts +204 -0
  177. package/src/connection/networkConnection/index.ts +3 -0
  178. package/src/connection/networkConnection/reporters.ts +58 -0
  179. package/src/connection/networkConnection/types.ts +45 -0
  180. package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +230 -231
  181. package/src/connection/wsConnection/WSConnection.ts +270 -0
  182. package/src/connection/wsConnection/WSConnectionFallback.ts +250 -0
  183. package/src/connection/wsConnection/config.ts +73 -0
  184. package/src/connection/wsConnection/index.ts +4 -0
  185. package/src/connection/wsConnection/types.ts +48 -0
  186. package/src/constants.ts +7 -5
  187. package/src/custom_types.ts +0 -1
  188. package/src/entityStore/EntityStore.ts +415 -79
  189. package/src/entityStore/StoreBackedItemIndex.ts +37 -41
  190. package/src/entityStore/index.ts +0 -1
  191. package/src/errors.ts +39 -20
  192. package/src/formatMessageMemo.ts +17 -0
  193. package/src/gen/chat/ChannelApi.ts +122 -36
  194. package/src/gen/chat/ChatApi.ts +578 -1752
  195. package/src/gen/models/index.ts +2566 -3440
  196. package/src/gen/models/timestamp-guard.ts +27 -0
  197. package/src/gen/moderation/ModerationApi.ts +183 -406
  198. package/src/index.ts +32 -10
  199. package/src/languageNames.ts +88 -0
  200. package/src/logger.ts +1 -3
  201. package/src/messageComposer/CustomDataManager.ts +19 -6
  202. package/src/messageComposer/LocationComposer.ts +49 -9
  203. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
  204. package/src/messageComposer/attachmentIdentity.ts +54 -0
  205. package/src/messageComposer/attachmentManager.ts +170 -185
  206. package/src/messageComposer/attachmentUtils.ts +44 -0
  207. package/src/messageComposer/configuration/configuration.ts +15 -8
  208. package/src/messageComposer/configuration/types.ts +38 -50
  209. package/src/messageComposer/fileUtils.ts +1 -1
  210. package/src/messageComposer/index.ts +1 -0
  211. package/src/messageComposer/linkPreviewsManager.ts +18 -21
  212. package/src/messageComposer/messageComposer.ts +234 -179
  213. package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
  214. package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +46 -33
  215. package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +4 -1
  216. package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +1 -1
  217. package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +6 -0
  218. package/src/messageComposer/middleware/messageComposer/attachments.ts +76 -5
  219. package/src/messageComposer/middleware/messageComposer/commandInjection.ts +10 -4
  220. package/src/messageComposer/middleware/messageComposer/customData.ts +17 -5
  221. package/src/messageComposer/middleware/messageComposer/index.ts +2 -0
  222. package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +22 -12
  223. package/src/messageComposer/middleware/messageComposer/pollOnly.ts +9 -1
  224. package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
  225. package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
  226. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +12 -12
  227. package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
  228. package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
  229. package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
  230. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +8 -6
  231. package/src/messageComposer/middleware/textComposer/commandUtils.ts +10 -3
  232. package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
  233. package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
  234. package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
  235. package/src/messageComposer/middleware/textComposer/types.ts +1 -6
  236. package/src/messageComposer/pollComposer.ts +21 -9
  237. package/src/messageComposer/textComposer.ts +37 -57
  238. package/src/messageComposer/types.ts +39 -11
  239. package/src/messageDelivery/MessageDeliveryReporter.ts +86 -124
  240. package/src/messageDelivery/MessageReceiptsTracker.ts +122 -139
  241. package/src/messageOperations/FailedSendCache.ts +85 -0
  242. package/src/messageOperations/MessageOperationStatePolicy.ts +124 -116
  243. package/src/messageOperations/MessageOperations.ts +297 -175
  244. package/src/{entityStore → messageOperations}/applyReactionLocally.ts +13 -25
  245. package/src/messageOperations/createMessageOperations.ts +176 -0
  246. package/src/messageOperations/index.ts +6 -14
  247. package/src/messageOperations/reflectReactionEvent.ts +43 -0
  248. package/src/messageOperations/sendOrdering.ts +25 -0
  249. package/src/messageOperations/settlePendingAttachmentUploads.ts +98 -0
  250. package/src/messageOperations/types.ts +51 -13
  251. package/src/middleware.ts +13 -5
  252. package/src/moderation.ts +25 -21
  253. package/src/notifications/NotificationManager.ts +19 -28
  254. package/src/notifications/types.ts +21 -57
  255. package/src/offline-support/offline_support_api.ts +231 -681
  256. package/src/offline-support/offline_sync_manager.ts +51 -90
  257. package/src/offline-support/queueableOperations.ts +98 -73
  258. package/src/offline-support/types.ts +43 -185
  259. package/src/pagination/FilterBuilder.ts +1 -22
  260. package/src/pagination/ItemIndex.ts +4 -12
  261. package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
  262. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +17 -62
  263. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
  264. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +53 -33
  265. package/src/pagination/filterCompiler.ts +11 -25
  266. package/src/pagination/index.ts +1 -0
  267. package/src/pagination/paginators/BasePaginator.ts +1415 -1041
  268. package/src/pagination/paginators/ChannelPaginator.ts +481 -219
  269. package/src/pagination/paginators/MessageIntervalPaginator.ts +1362 -775
  270. package/src/pagination/paginators/MessagePaginator.ts +521 -240
  271. package/src/pagination/paginators/PinnedMessagePaginator.ts +32 -40
  272. package/src/pagination/paginators/ReminderPaginator.ts +21 -16
  273. package/src/pagination/paginators/ThreadPaginator.ts +170 -0
  274. package/src/pagination/paginators/UserGroupPaginator.ts +18 -15
  275. package/src/pagination/paginators/index.ts +1 -0
  276. package/src/pagination/paginators/stateThrottling.ts +5 -10
  277. package/src/pagination/sortCompiler.ts +23 -50
  278. package/src/pagination/utility.normalization.ts +17 -24
  279. package/src/pagination/utility.search.ts +4 -11
  280. package/src/poll.ts +183 -102
  281. package/src/poll_manager.ts +24 -22
  282. package/src/poll_optimistic_votes.ts +335 -0
  283. package/src/reminders/Reminder.ts +33 -16
  284. package/src/reminders/ReminderManager.ts +23 -56
  285. package/src/reminders/ReminderTimer.ts +6 -6
  286. package/src/search/BaseSearchSource.ts +19 -25
  287. package/src/search/ChannelSearchSource.ts +43 -1
  288. package/src/search/MessageSearchSource.ts +77 -13
  289. package/src/search/SearchController.ts +39 -36
  290. package/src/search/types.ts +6 -10
  291. package/src/segment.ts +1 -1
  292. package/src/signing.ts +23 -3
  293. package/src/thread.ts +430 -712
  294. package/src/thread_manager.ts +300 -234
  295. package/src/token_manager.ts +12 -22
  296. package/src/types.ts +102 -214
  297. package/src/types.utility.ts +3 -3
  298. package/src/upload-utils.ts +5 -10
  299. package/src/uploadManager.ts +64 -18
  300. package/src/utils/FixedSizeQueueCache.ts +18 -21
  301. package/src/utils/WithSubscriptions.ts +6 -16
  302. package/src/utils/abort.ts +45 -0
  303. package/src/utils/concurrency.ts +16 -55
  304. package/src/utils/mergeWith/mergeWith.ts +10 -13
  305. package/src/utils/mergeWith/mergeWithCore.ts +24 -81
  306. package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
  307. package/src/utils/objectPath.ts +6 -41
  308. package/src/utils/retryable.ts +10 -14
  309. package/src/utils/throttling/throttle.ts +9 -25
  310. package/src/utils/time.ts +64 -0
  311. package/src/utils.ts +227 -174
  312. package/codegen/i18n/callSites.ts +0 -126
  313. package/codegen/i18n/generate.ts +0 -226
  314. package/codegen/i18n/guards.ts +0 -178
  315. package/codegen/i18n/index.ts +0 -29
  316. package/codegen/i18n/stringMaps.ts +0 -91
  317. package/codegen/i18n/types.ts +0 -100
  318. package/dist/cjs/i18n.browser.js +0 -1131
  319. package/dist/cjs/i18n.browser.js.map +0 -7
  320. package/dist/cjs/i18n.node.js +0 -1160
  321. package/dist/cjs/i18n.node.js.map +0 -7
  322. package/dist/esm/i18n-codegen.mjs +0 -409
  323. package/dist/esm/i18n-codegen.mjs.map +0 -7
  324. package/dist/esm/i18n.mjs +0 -1098
  325. package/dist/esm/i18n.mjs.map +0 -7
  326. package/dist/types/ConnectionRecoveryManager.d.ts +0 -156
  327. package/dist/types/connection.d.ts +0 -139
  328. package/dist/types/entityStore/applyReactionLocally.d.ts +0 -26
  329. package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
  330. package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
  331. package/dist/types/i18n/Streami18n.d.ts +0 -168
  332. package/dist/types/i18n/TranslationBuilder.d.ts +0 -70
  333. package/dist/types/i18n/TranslationStore.d.ts +0 -57
  334. package/dist/types/i18n/dayjs.d.ts +0 -104
  335. package/dist/types/i18n/formatters.d.ts +0 -91
  336. package/dist/types/i18n/index.d.ts +0 -15
  337. package/dist/types/i18n/translator.d.ts +0 -29
  338. package/dist/types/i18n/types.d.ts +0 -262
  339. package/dist/types/i18n-codegen/callSites.d.ts +0 -10
  340. package/dist/types/i18n-codegen/generate.d.ts +0 -15
  341. package/dist/types/i18n-codegen/guards.d.ts +0 -61
  342. package/dist/types/i18n-codegen/index.d.ts +0 -29
  343. package/dist/types/i18n-codegen/stringMaps.d.ts +0 -14
  344. package/dist/types/i18n-codegen/types.d.ts +0 -94
  345. package/dist/types/insights.d.ts +0 -56
  346. package/dist/types/messageOperations/optimistic.d.ts +0 -118
  347. package/dist/types/messageOperations/persistence.d.ts +0 -21
  348. package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
  349. package/dist/types/store.d.ts +0 -125
  350. package/src/ConnectionRecoveryManager.ts +0 -293
  351. package/src/gen/model-decoders/decoders.ts +0 -2710
  352. package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
  353. package/src/i18n/Streami18n.ts +0 -520
  354. package/src/i18n/TranslationBuilder.ts +0 -176
  355. package/src/i18n/TranslationStore.ts +0 -96
  356. package/src/i18n/dayjs.ts +0 -228
  357. package/src/i18n/formatters.ts +0 -461
  358. package/src/i18n/index.ts +0 -15
  359. package/src/i18n/languageNames.ts +0 -103
  360. package/src/i18n/translator.ts +0 -76
  361. package/src/i18n/types.ts +0 -375
  362. package/src/insights.ts +0 -82
  363. package/src/messageOperations/optimistic.ts +0 -249
  364. package/src/messageOperations/persistence.ts +0 -40
  365. package/src/pagination/utility.queryChannel.ts +0 -84
  366. package/src/store.ts +0 -304
@@ -3,59 +3,55 @@ import { EntityStore, type EntityStoreSubscriber } from './EntityStore';
3
3
 
4
4
  export type StoreBackedItemIndexOptions<T> = {
5
5
  getEntityId: (item: T) => string;
6
- /**
7
- * The entity that owns this index; used as the store subscriber, which also holds its refcount.
8
- * Optional: an index over a private store (see `store`) has no one to fan out to, so an
9
- * owner-less index just uses an internal no-op subscriber to hold its refcount. Message paginators pass themselves so
10
- * cross-collection updates reach them; single-home collections (channels, reminders, …) omit it.
11
- */
6
+ /** The list that owns this index; the store's notifications, ID renames and removals reach it. */
12
7
  owner?: EntityStoreSubscriber;
8
+ /** The holder's name in the store, for debugging tools: no spaces, e.g. `channel-paginator`. */
9
+ holderName?: string;
13
10
  /**
14
- * The shared, client-global store that holds the canonical content. Optional: when omitted the
15
- * index provisions a **private** {@link EntityStore} of its own, so it behaves exactly like a
16
- * plain, per-instance index — same code path, no shared content, no fan-out. This is the mode used
17
- * by single-home collections and by detached paginators (e.g. built without a client, in tests).
11
+ * The store the items live in, shared with other lists. Without it the index makes a private
12
+ * store and behaves like a plain per-list map (e.g. paginators built without a client).
18
13
  */
19
14
  store?: EntityStore<T>;
20
15
  };
21
16
 
22
- /** No-op subscriber that holds the refcount for an owner-less (private-store) index. */
23
- const NOOP_OWNER: EntityStoreSubscriber = { onEntitiesChanged: () => undefined };
24
-
25
17
  /**
26
- * An {@link ItemIndexApi} implementation that keeps entity **content** in an {@link EntityStore}
27
- * while keeping **membership** local.
28
- *
29
- * A consumer sees the same minimal CRUD surface ({@link ItemIndexApi}), but:
18
+ * The item index of one list (a paginator). Items live in an {@link EntityStore}, which can be
19
+ * shared with other lists; the index only records which IDs belong to this list (`memberIds`) and
20
+ * stands for the list in the store with one `holder`. Reads see only this list's items, even when a
21
+ * shared store holds other lists' items.
30
22
  *
31
- * - `get`/`has`/`values`/`entries` are scoped to *this* index's membership (`memberIds`), so
32
- * `getItem(id)` still means "does THIS index hold the id" — even though the canonical object
33
- * lives in the (possibly shared) store. This is what keeps e.g. reaction routing
34
- * (`threadPaginator.getItem(id) ? thread : channel`) correct and keeps the `.values()` scans
35
- * from ever walking other channels' entities.
36
- * - `setOne` writes content once into the store and links the owner as a subscriber (drives both
37
- * notification fan-out and refcount GC). The write passes the owner as the `subscriber` to skip, so
38
- * the owner is not notified of its own write (it re-emits its window inline); other subscribers of
39
- * the same id ARE notified and re-project.
40
- * - `remove`/`clear` unlink the owner rather than hard-deleting content, so an entity still held by
41
- * another index (e.g. a `show_in_channel` reply in both the channel list and its thread) survives;
42
- * the store GCs it only when the last subscriber unlinks.
23
+ * Store callbacks reach the owner through the holder: changes to held items (except the owner's own
24
+ * writes), removals (with the removed item), and ID renames, which are also applied to `memberIds`.
43
25
  *
44
- * When no shared store is supplied the index holds a private store — every id it links has exactly
45
- * one subscriber (its own owner), so no fan-out ever fires and removal GCs immediately, matching a plain
46
- * per-instance index.
47
- *
48
- * @template T The domain item type held by the index; collocated with the {@link EntityStore}'s.
26
+ * @template T The item type held by the index and its store.
49
27
  */
50
28
  export class StoreBackedItemIndex<T> implements ItemIndexApi<T> {
51
29
  private memberIds = new Set<string>();
52
30
  private readonly store: EntityStore<T>;
53
- private readonly owner: EntityStoreSubscriber;
31
+ /**
32
+ * This index's identity in the store: linked per ID while the index lists it, and unlinked on
33
+ * remove or clear. The store tells holders apart by object, so every index has its own, even with
34
+ * the same owner or none.
35
+ */
36
+ private readonly holder: EntityStoreSubscriber;
54
37
  private readonly getEntityId: (item: T) => string;
55
38
 
56
- constructor({ store, owner, getEntityId }: StoreBackedItemIndexOptions<T>) {
39
+ constructor({ store, owner, getEntityId, holderName }: StoreBackedItemIndexOptions<T>) {
57
40
  this.store = store ?? new EntityStore<T>({ getEntityId });
58
- this.owner = owner ?? NOOP_OWNER;
41
+ this.holder = {
42
+ name: holderName,
43
+ onEntitiesChanged: (batch) => owner?.onEntitiesChanged(batch),
44
+ flushState: () => owner?.flushState?.(),
45
+ onIdChanged: (oldId, newId) => {
46
+ if (this.memberIds.delete(oldId)) this.memberIds.add(newId);
47
+ owner?.onIdChanged?.(oldId, newId);
48
+ },
49
+ onEntityRemoved: (id, entity) => {
50
+ // Owner first: dropping the item from its intervals still reads it through this index.
51
+ owner?.onEntityRemoved?.(id, entity);
52
+ this.memberIds.delete(id);
53
+ },
54
+ };
59
55
  this.getEntityId = getEntityId;
60
56
  }
61
57
 
@@ -67,9 +63,9 @@ export class StoreBackedItemIndex<T> implements ItemIndexApi<T> {
67
63
 
68
64
  setOne(item: T) {
69
65
  const id = this.getEntityId(item);
70
- this.store.link(id, this.owner);
66
+ this.store.link(id, this.holder);
71
67
  this.memberIds.add(id);
72
- this.store.upsert(item, this.owner);
68
+ this.store.upsert(item, this.holder);
73
69
  }
74
70
 
75
71
  get(id: string): T | undefined {
@@ -83,11 +79,11 @@ export class StoreBackedItemIndex<T> implements ItemIndexApi<T> {
83
79
  remove(id: string) {
84
80
  if (!this.memberIds.has(id)) return;
85
81
  this.memberIds.delete(id);
86
- this.store.unlink(id, this.owner);
82
+ this.store.unlink(id, this.holder);
87
83
  }
88
84
 
89
85
  clear() {
90
- for (const id of this.memberIds) this.store.unlink(id, this.owner);
86
+ for (const id of this.memberIds) this.store.unlink(id, this.holder);
91
87
  this.memberIds.clear();
92
88
  }
93
89
 
@@ -1,2 +1 @@
1
- export * from './applyReactionLocally';
2
1
  export * from './EntityStore';
package/src/errors.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { AxiosResponse } from 'axios';
2
- import { isCancel } from 'axios';
3
- import type { APIError as Gen_APIError } from './types';
2
+ import { isAxiosError, isCancel } from 'axios';
3
+ import { OfflineError } from './offline-support/types';
4
+ import type { APIError as Gen_APIError, StreamAPIError } from './types';
4
5
 
5
6
  export const APIErrorCodes: Record<string, { name: string; retryable: boolean }> = {
6
7
  '-1': { name: 'InternalSystemError', retryable: true },
@@ -43,13 +44,8 @@ export function isAPIError(error: Error): error is APIError {
43
44
  }
44
45
 
45
46
  /**
46
- * Whether the server answered "this does not exist" — a definitive, expected answer rather than a
47
- * failure. Distinct from a network error: the request succeeded, the resource simply is not there.
48
- * Use it to avoid surfacing an error state for something a caller can legitimately ask about before
49
- * it exists (a thread on a parent that has no replies yet, say).
50
- *
51
- * Resolved through {@link APIErrorCodes} rather than comparing the numeric code, so the table stays
52
- * the single place the mapping lives.
47
+ * Whether the server answered "does not exist": an expected answer for a resource a caller may ask
48
+ * about before it exists, not a failure.
53
49
  */
54
50
  export function isDoesNotExistError(error: Error): boolean {
55
51
  return (
@@ -64,18 +60,15 @@ export function isErrorRetryable(error: APIError) {
64
60
  return err.retryable;
65
61
  }
66
62
 
63
+ export function isConnectionIDError(error: APIError) {
64
+ return error.code === 46; // ConnectionIDNotFoundError
65
+ }
66
+
67
67
  /**
68
- * Whether an error is EPHEMERAL — a transient failure worth queueing/retrying rather than a
69
- * definitive rejection. True when the server never responded (connection/network/offline error - no
70
- * `response`, i.e an axios network error or an `OfflineError`) and when the server responded with a
71
- * retryable code (see {@link APIErrorCodes}); false when the server responded with a
72
- * non-retryable code (InputError 4, DoesNotExist 16, NotAllowed 17, …) and when the caller
73
- * cancelled the request.
74
- *
75
- * Cancellation is deliberately NOT ephemeral even though an aborted request carries no `response`.
76
- * A caller who aborts via `StreamRequestOptions.signal` wants the operation dropped, so treating it
77
- * as transient would do the opposite of what was asked: the task would be queued and replayed on
78
- * reconnect, and any optimistic local update would be kept rather than rolled back.
68
+ * Whether an error is transient and worth queueing or retrying: the server never responded (no
69
+ * `response`, e.g. an axios network error or an `OfflineError`) or responded with a retryable code
70
+ * (see {@link APIErrorCodes}). A request cancelled by the caller is not ephemeral: it is dropped,
71
+ * not queued for replay.
79
72
  */
80
73
  export function isEphemeral(error: Error): boolean {
81
74
  if (isCancel(error)) return false;
@@ -100,3 +93,29 @@ export function isErrorResponse(
100
93
  ): res is AxiosResponse<Gen_APIError> {
101
94
  return !res.status || res.status < 200 || 300 <= res.status;
102
95
  }
96
+
97
+ /**
98
+ * Whether a request failed in transport: axios sent it and got no response (and the caller did not
99
+ * cancel it), or the offline layer refused to send it. An error thrown by anything else, such as an
100
+ * integrator's own request handler, is not one, even though it carries no response either.
101
+ */
102
+ const isTransportFailure = (error: unknown) =>
103
+ error instanceof OfflineError ||
104
+ (isAxiosError(error) && !error.response && !isCancel(error));
105
+
106
+ /**
107
+ * Turns whatever a request threw into a plain error object, so it can be stored on a message. A
108
+ * transport failure (see {@link isTransportFailure}) has no HTTP status and is given `status: 0`,
109
+ * which is how a UI tells it from a rejection.
110
+ */
111
+ export const parseError = (error: unknown): StreamAPIError => {
112
+ const stringError = JSON.stringify(error);
113
+ const parsed = (stringError ? JSON.parse(stringError) : {}) as StreamAPIError;
114
+ return parsed.status == null && isTransportFailure(error)
115
+ ? ({ ...parsed, status: 0 } as StreamAPIError)
116
+ : parsed;
117
+ };
118
+
119
+ /** Whether the server rejected a send because a message with that ID already exists. */
120
+ export const isAlreadyExistsError = (error: unknown, parsed: StreamAPIError) =>
121
+ parsed.code === 4 && error instanceof Error && error.message.includes('already exists');
@@ -0,0 +1,17 @@
1
+ import type { LocalMessage } from './types';
2
+
3
+ /**
4
+ * One `LocalMessage` per source object, shared by every subscriber that formats the same
5
+ * `event.message`, so `EntityStore.upsert`'s reference check skips redundant writes. Keyed weakly:
6
+ * an entry lives as long as its source.
7
+ */
8
+ const memo: WeakMap<object, LocalMessage> = new WeakMap();
9
+
10
+ /** The `LocalMessage` already produced for `source`, if any. */
11
+ export const getMemoizedFormat = (source: object): LocalMessage | undefined =>
12
+ memo.get(source);
13
+
14
+ /** Records `formatted` as the `LocalMessage` for `source`. */
15
+ export const memoizeFormat = (source: object, formatted: LocalMessage): void => {
16
+ memo.set(source, formatted);
17
+ };
@@ -7,6 +7,10 @@ import type {
7
7
  CreateDraftResponse,
8
8
  DeleteChannelResponse,
9
9
  EventResponse,
10
+ ForkChannelRequest,
11
+ ForkChannelResponse,
12
+ ForkMessageIDsRequest,
13
+ ForkMessageIDsResponse,
10
14
  GetDraftResponse,
11
15
  GetManyMessagesResponse,
12
16
  GetPinnedMessagesResponse,
@@ -15,7 +19,11 @@ import type {
15
19
  MarkReadRequest,
16
20
  MarkReadResponse,
17
21
  MarkUnreadRequest,
22
+ QueryChannelBansRequest,
23
+ QueryChannelBansResponse,
18
24
  Response,
25
+ RewindChannelRequest,
26
+ RewindChannelResponse,
19
27
  SendEventRequest,
20
28
  SendMessageRequest,
21
29
  SendMessageResponse,
@@ -54,7 +62,8 @@ export class ChannelApi {
54
62
  }
55
63
 
56
64
  return this.chatApi.deleteChannel(
57
- { id: this.id, type: this.type, ...request },
65
+ { id: this.id, type: this.type },
66
+ request,
58
67
  requestOptions,
59
68
  );
60
69
  }
@@ -80,14 +89,14 @@ export class ChannelApi {
80
89
  }
81
90
 
82
91
  return this.chatApi.getChannel(
83
- { id: this.id, type: this.type, ...request },
92
+ { id: this.id, type: this.type },
93
+ request,
84
94
  requestOptions,
85
95
  );
86
96
  }
87
97
 
88
98
  updateChannelPartial(
89
99
  request?: UpdateChannelPartialRequest,
90
-
91
100
  requestOptions?: StreamRequestOptions,
92
101
  ): Promise<StreamResponse<UpdateChannelPartialResponse>> {
93
102
  if (!this.id) {
@@ -97,14 +106,14 @@ export class ChannelApi {
97
106
  }
98
107
 
99
108
  return this.chatApi.updateChannelPartial(
100
- { id: this.id, type: this.type, ...request },
109
+ { id: this.id, type: this.type },
110
+ request,
101
111
  requestOptions,
102
112
  );
103
113
  }
104
114
 
105
115
  update(
106
116
  request?: UpdateChannelRequest,
107
-
108
117
  requestOptions?: StreamRequestOptions,
109
118
  ): Promise<StreamResponse<UpdateChannelResponse>> {
110
119
  if (!this.id) {
@@ -114,7 +123,25 @@ export class ChannelApi {
114
123
  }
115
124
 
116
125
  return this.chatApi.updateChannel(
117
- { id: this.id, type: this.type, ...request },
126
+ { id: this.id, type: this.type },
127
+ request,
128
+ requestOptions,
129
+ );
130
+ }
131
+
132
+ queryChannelBans(
133
+ request?: QueryChannelBansRequest,
134
+ requestOptions?: StreamRequestOptions,
135
+ ): Promise<StreamResponse<QueryChannelBansResponse>> {
136
+ if (!this.id) {
137
+ throw new Error(
138
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
139
+ );
140
+ }
141
+
142
+ return this.chatApi.queryChannelBans(
143
+ { id: this.id, type: this.type },
144
+ request,
118
145
  requestOptions,
119
146
  );
120
147
  }
@@ -130,7 +157,8 @@ export class ChannelApi {
130
157
  }
131
158
 
132
159
  return this.chatApi.deleteDraft(
133
- { id: this.id, type: this.type, ...request },
160
+ { id: this.id, type: this.type },
161
+ request,
134
162
  requestOptions,
135
163
  );
136
164
  }
@@ -146,14 +174,14 @@ export class ChannelApi {
146
174
  }
147
175
 
148
176
  return this.chatApi.getDraft(
149
- { id: this.id, type: this.type, ...request },
177
+ { id: this.id, type: this.type },
178
+ request,
150
179
  requestOptions,
151
180
  );
152
181
  }
153
182
 
154
183
  createDraft(
155
184
  request: CreateDraftRequest,
156
-
157
185
  requestOptions?: StreamRequestOptions,
158
186
  ): Promise<StreamResponse<CreateDraftResponse>> {
159
187
  if (!this.id) {
@@ -163,14 +191,14 @@ export class ChannelApi {
163
191
  }
164
192
 
165
193
  return this.chatApi.createDraft(
166
- { id: this.id, type: this.type, ...request },
194
+ { id: this.id, type: this.type },
195
+ request,
167
196
  requestOptions,
168
197
  );
169
198
  }
170
199
 
171
200
  sendEvent(
172
201
  request: SendEventRequest,
173
-
174
202
  requestOptions?: StreamRequestOptions,
175
203
  ): Promise<StreamResponse<EventResponse>> {
176
204
  if (!this.id) {
@@ -180,7 +208,8 @@ export class ChannelApi {
180
208
  }
181
209
 
182
210
  return this.chatApi.sendEvent(
183
- { id: this.id, type: this.type, ...request },
211
+ { id: this.id, type: this.type },
212
+ request,
184
213
  requestOptions,
185
214
  );
186
215
  }
@@ -196,14 +225,14 @@ export class ChannelApi {
196
225
  }
197
226
 
198
227
  return this.chatApi.deleteChannelFile(
199
- { id: this.id, type: this.type, ...request },
228
+ { id: this.id, type: this.type },
229
+ request,
200
230
  requestOptions,
201
231
  );
202
232
  }
203
233
 
204
234
  uploadChannelFile(
205
235
  request?: UploadChannelFileRequest,
206
-
207
236
  requestOptions?: StreamRequestOptions,
208
237
  ): Promise<StreamResponse<UploadChannelFileResponse>> {
209
238
  if (!this.id) {
@@ -213,14 +242,48 @@ export class ChannelApi {
213
242
  }
214
243
 
215
244
  return this.chatApi.uploadChannelFile(
216
- { id: this.id, type: this.type, ...request },
245
+ { id: this.id, type: this.type },
246
+ request,
247
+ requestOptions,
248
+ );
249
+ }
250
+
251
+ fork(
252
+ request: ForkChannelRequest,
253
+ requestOptions?: StreamRequestOptions,
254
+ ): Promise<StreamResponse<ForkChannelResponse>> {
255
+ if (!this.id) {
256
+ throw new Error(
257
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
258
+ );
259
+ }
260
+
261
+ return this.chatApi.forkChannel(
262
+ { id: this.id, type: this.type },
263
+ request,
264
+ requestOptions,
265
+ );
266
+ }
267
+
268
+ forkMessageIDs(
269
+ request: ForkMessageIDsRequest,
270
+ requestOptions?: StreamRequestOptions,
271
+ ): Promise<StreamResponse<ForkMessageIDsResponse>> {
272
+ if (!this.id) {
273
+ throw new Error(
274
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
275
+ );
276
+ }
277
+
278
+ return this.chatApi.forkMessageIDs(
279
+ { id: this.id, type: this.type },
280
+ request,
217
281
  requestOptions,
218
282
  );
219
283
  }
220
284
 
221
285
  hide(
222
286
  request?: HideChannelRequest,
223
-
224
287
  requestOptions?: StreamRequestOptions,
225
288
  ): Promise<StreamResponse<HideChannelResponse>> {
226
289
  if (!this.id) {
@@ -230,7 +293,8 @@ export class ChannelApi {
230
293
  }
231
294
 
232
295
  return this.chatApi.hideChannel(
233
- { id: this.id, type: this.type, ...request },
296
+ { id: this.id, type: this.type },
297
+ request,
234
298
  requestOptions,
235
299
  );
236
300
  }
@@ -246,14 +310,14 @@ export class ChannelApi {
246
310
  }
247
311
 
248
312
  return this.chatApi.deleteChannelImage(
249
- { id: this.id, type: this.type, ...request },
313
+ { id: this.id, type: this.type },
314
+ request,
250
315
  requestOptions,
251
316
  );
252
317
  }
253
318
 
254
319
  uploadChannelImage(
255
320
  request?: UploadChannelRequest,
256
-
257
321
  requestOptions?: StreamRequestOptions,
258
322
  ): Promise<StreamResponse<UploadChannelResponse>> {
259
323
  if (!this.id) {
@@ -263,14 +327,14 @@ export class ChannelApi {
263
327
  }
264
328
 
265
329
  return this.chatApi.uploadChannelImage(
266
- { id: this.id, type: this.type, ...request },
330
+ { id: this.id, type: this.type },
331
+ request,
267
332
  requestOptions,
268
333
  );
269
334
  }
270
335
 
271
336
  updateMemberPartial(
272
337
  request?: UpdateMemberPartialRequest,
273
-
274
338
  requestOptions?: StreamRequestOptions,
275
339
  ): Promise<StreamResponse<UpdateMemberPartialResponse>> {
276
340
  if (!this.id) {
@@ -280,14 +344,14 @@ export class ChannelApi {
280
344
  }
281
345
 
282
346
  return this.chatApi.updateMemberPartial(
283
- { id: this.id, type: this.type, ...request },
347
+ { id: this.id, type: this.type },
348
+ request,
284
349
  requestOptions,
285
350
  );
286
351
  }
287
352
 
288
353
  sendMessage(
289
354
  request: SendMessageRequest,
290
-
291
355
  requestOptions?: StreamRequestOptions,
292
356
  ): Promise<StreamResponse<SendMessageResponse>> {
293
357
  if (!this.id) {
@@ -297,7 +361,8 @@ export class ChannelApi {
297
361
  }
298
362
 
299
363
  return this.chatApi.sendMessage(
300
- { id: this.id, type: this.type, ...request },
364
+ { id: this.id, type: this.type },
365
+ request,
301
366
  requestOptions,
302
367
  );
303
368
  }
@@ -313,7 +378,8 @@ export class ChannelApi {
313
378
  }
314
379
 
315
380
  return this.chatApi.getManyMessages(
316
- { id: this.id, type: this.type, ...request },
381
+ { id: this.id, type: this.type },
382
+ request,
317
383
  requestOptions,
318
384
  );
319
385
  }
@@ -344,7 +410,8 @@ export class ChannelApi {
344
410
  }
345
411
 
346
412
  return this.chatApi.getPinnedMessages(
347
- { id: this.id, type: this.type, ...request },
413
+ { id: this.id, type: this.type },
414
+ request,
348
415
  requestOptions,
349
416
  );
350
417
  }
@@ -360,14 +427,14 @@ export class ChannelApi {
360
427
  }
361
428
 
362
429
  return this.chatApi.getOrCreateChannel(
363
- { id: this.id, type: this.type, ...request },
430
+ { id: this.id, type: this.type },
431
+ request,
364
432
  requestOptions,
365
433
  );
366
434
  }
367
435
 
368
436
  markRead(
369
437
  request?: MarkReadRequest,
370
-
371
438
  requestOptions?: StreamRequestOptions,
372
439
  ): Promise<StreamResponse<MarkReadResponse>> {
373
440
  if (!this.id) {
@@ -377,14 +444,31 @@ export class ChannelApi {
377
444
  }
378
445
 
379
446
  return this.chatApi.markRead(
380
- { id: this.id, type: this.type, ...request },
447
+ { id: this.id, type: this.type },
448
+ request,
449
+ requestOptions,
450
+ );
451
+ }
452
+
453
+ rewind(
454
+ request: RewindChannelRequest,
455
+ requestOptions?: StreamRequestOptions,
456
+ ): Promise<StreamResponse<RewindChannelResponse>> {
457
+ if (!this.id) {
458
+ throw new Error(
459
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
460
+ );
461
+ }
462
+
463
+ return this.chatApi.rewindChannel(
464
+ { id: this.id, type: this.type },
465
+ request,
381
466
  requestOptions,
382
467
  );
383
468
  }
384
469
 
385
470
  show(
386
471
  request?: ShowChannelRequest,
387
-
388
472
  requestOptions?: StreamRequestOptions,
389
473
  ): Promise<StreamResponse<ShowChannelResponse>> {
390
474
  if (!this.id) {
@@ -394,7 +478,8 @@ export class ChannelApi {
394
478
  }
395
479
 
396
480
  return this.chatApi.showChannel(
397
- { id: this.id, type: this.type, ...request },
481
+ { id: this.id, type: this.type },
482
+ request,
398
483
  requestOptions,
399
484
  );
400
485
  }
@@ -410,14 +495,14 @@ export class ChannelApi {
410
495
  }
411
496
 
412
497
  return this.chatApi.stopWatchingChannel(
413
- { id: this.id, type: this.type, ...request },
498
+ { id: this.id, type: this.type },
499
+ request,
414
500
  requestOptions,
415
501
  );
416
502
  }
417
503
 
418
504
  truncate(
419
505
  request?: TruncateChannelRequest,
420
-
421
506
  requestOptions?: StreamRequestOptions,
422
507
  ): Promise<StreamResponse<TruncateChannelResponse>> {
423
508
  if (!this.id) {
@@ -427,14 +512,14 @@ export class ChannelApi {
427
512
  }
428
513
 
429
514
  return this.chatApi.truncateChannel(
430
- { id: this.id, type: this.type, ...request },
515
+ { id: this.id, type: this.type },
516
+ request,
431
517
  requestOptions,
432
518
  );
433
519
  }
434
520
 
435
521
  markUnread(
436
522
  request?: MarkUnreadRequest,
437
-
438
523
  requestOptions?: StreamRequestOptions,
439
524
  ): Promise<StreamResponse<Response>> {
440
525
  if (!this.id) {
@@ -444,7 +529,8 @@ export class ChannelApi {
444
529
  }
445
530
 
446
531
  return this.chatApi.markUnread(
447
- { id: this.id, type: this.type, ...request },
532
+ { id: this.id, type: this.type },
533
+ request,
448
534
  requestOptions,
449
535
  );
450
536
  }