stream-chat 9.50.3 → 10.0.0-rc.2

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 (242) hide show
  1. package/dist/cjs/index.browser.js +19798 -14472
  2. package/dist/cjs/index.browser.js.map +4 -4
  3. package/dist/cjs/index.node.js +19817 -14482
  4. package/dist/cjs/index.node.js.map +4 -4
  5. package/dist/esm/index.mjs +19795 -14469
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +221 -0
  8. package/dist/types/EventHandlerPipeline.d.ts +104 -0
  9. package/dist/types/api-client.d.ts +26 -0
  10. package/dist/types/campaign.d.ts +0 -44
  11. package/dist/types/channel.d.ts +454 -479
  12. package/dist/types/channel_batch_updater.d.ts +0 -93
  13. package/dist/types/channel_state.d.ts +53 -201
  14. package/dist/types/client.d.ts +451 -1920
  15. package/dist/types/client_state.d.ts +4 -4
  16. package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
  17. package/dist/types/configuration/index.d.ts +1 -0
  18. package/dist/types/configuration/types.d.ts +53 -0
  19. package/dist/types/connection.d.ts +49 -41
  20. package/dist/types/connection_fallback.d.ts +6 -4
  21. package/dist/types/constants.d.ts +0 -4
  22. package/dist/types/custom_types.d.ts +2 -0
  23. package/dist/types/entityStore/EntityStore.d.ts +111 -0
  24. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +60 -0
  25. package/dist/types/entityStore/applyReactionLocally.d.ts +26 -0
  26. package/dist/types/entityStore/index.d.ts +2 -0
  27. package/dist/types/errors.d.ts +10 -2
  28. package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
  29. package/dist/types/gen/chat/ChatApi.d.ts +334 -0
  30. package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
  31. package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
  32. package/dist/types/gen/models/index.d.ts +8836 -0
  33. package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
  34. package/dist/types/gen-imports.d.ts +3 -0
  35. package/dist/types/index.d.ts +8 -7
  36. package/dist/types/insights.d.ts +9 -8
  37. package/dist/types/logger.d.ts +9 -0
  38. package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
  39. package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
  40. package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
  41. package/dist/types/messageComposer/configuration/types.d.ts +11 -11
  42. package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
  43. package/dist/types/messageComposer/messageComposer.d.ts +10 -10
  44. package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
  45. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
  46. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
  47. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
  48. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
  49. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
  50. package/dist/types/messageComposer/pollComposer.d.ts +5 -4
  51. package/dist/types/messageComposer/textComposer.d.ts +8 -3
  52. package/dist/types/messageComposer/types.d.ts +6 -28
  53. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
  54. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
  55. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
  56. package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
  57. package/dist/types/messageOperations/index.d.ts +3 -0
  58. package/dist/types/messageOperations/types.d.ts +49 -0
  59. package/dist/types/moderation.d.ts +21 -203
  60. package/dist/types/notifications/types.d.ts +8 -7
  61. package/dist/types/offline-support/offline_support_api.d.ts +111 -87
  62. package/dist/types/offline-support/offline_sync_manager.d.ts +0 -7
  63. package/dist/types/offline-support/types.d.ts +19 -23
  64. package/dist/types/offline-support/util.d.ts +4 -2
  65. package/dist/types/pagination/FilterBuilder.d.ts +1 -1
  66. package/dist/types/pagination/ItemIndex.d.ts +25 -0
  67. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
  68. package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
  69. package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
  70. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
  71. package/dist/types/pagination/filterCompiler.d.ts +7 -0
  72. package/dist/types/pagination/index.d.ts +1 -3
  73. package/dist/types/pagination/paginators/BasePaginator.d.ts +848 -0
  74. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +212 -0
  75. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +282 -0
  76. package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
  77. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
  78. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
  79. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
  80. package/dist/types/pagination/paginators/index.d.ts +7 -0
  81. package/dist/types/pagination/paginators/stateThrottling.d.ts +2 -0
  82. package/dist/types/pagination/sortCompiler.d.ts +49 -0
  83. package/dist/types/pagination/types.normalization.d.ts +11 -0
  84. package/dist/types/pagination/utility.normalization.d.ts +18 -0
  85. package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
  86. package/dist/types/pagination/utility.search.d.ts +13 -0
  87. package/dist/types/permissions.d.ts +1 -1
  88. package/dist/types/poll.d.ts +29 -32
  89. package/dist/types/poll_manager.d.ts +2 -2
  90. package/dist/types/reminders/Reminder.d.ts +2 -5
  91. package/dist/types/reminders/ReminderManager.d.ts +2 -9
  92. package/dist/types/search/MessageSearchSource.d.ts +4 -4
  93. package/dist/types/search/UserSearchSource.d.ts +1 -1
  94. package/dist/types/search/types.d.ts +3 -3
  95. package/dist/types/segment.d.ts +0 -34
  96. package/dist/types/signing.d.ts +105 -65
  97. package/dist/types/store.d.ts +1 -0
  98. package/dist/types/thread.d.ts +70 -34
  99. package/dist/types/thread_manager.d.ts +3 -3
  100. package/dist/types/token_manager.d.ts +15 -10
  101. package/dist/types/types.d.ts +197 -3404
  102. package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
  103. package/dist/types/utils/WithSubscriptions.d.ts +2 -1
  104. package/dist/types/utils/concurrency.d.ts +4 -4
  105. package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
  106. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
  107. package/dist/types/utils/retryable.d.ts +34 -0
  108. package/dist/types/utils/throttling/throttle.d.ts +36 -0
  109. package/dist/types/utils.d.ts +100 -194
  110. package/package.json +7 -3
  111. package/src/ChannelManager.ts +724 -0
  112. package/src/CooldownTimer.ts +2 -2
  113. package/src/EventHandlerPipeline.ts +228 -0
  114. package/src/LiveLocationManager.ts +12 -11
  115. package/src/api-client.ts +275 -0
  116. package/src/campaign.ts +1 -77
  117. package/src/channel.ts +1344 -1282
  118. package/src/channel_batch_updater.ts +1 -211
  119. package/src/channel_state.ts +144 -1013
  120. package/src/client.ts +936 -3995
  121. package/src/client_state.ts +4 -4
  122. package/src/configuration/InstanceConfigurationService.ts +73 -0
  123. package/src/configuration/index.ts +1 -0
  124. package/src/configuration/types.ts +81 -0
  125. package/src/connection.ts +145 -94
  126. package/src/connection_fallback.ts +29 -27
  127. package/src/constants.ts +1 -5
  128. package/src/custom_types.ts +4 -1
  129. package/src/entityStore/EntityStore.ts +208 -0
  130. package/src/entityStore/StoreBackedItemIndex.ts +115 -0
  131. package/src/entityStore/applyReactionLocally.ts +113 -0
  132. package/src/entityStore/index.ts +2 -0
  133. package/src/errors.ts +14 -2
  134. package/src/gen/chat/ChannelApi.ts +275 -0
  135. package/src/gen/chat/ChatApi.ts +2554 -0
  136. package/src/gen/model-decoders/decoders.ts +2680 -0
  137. package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
  138. package/src/gen/models/index.ts +12673 -0
  139. package/src/gen/moderation/ModerationApi.ts +607 -0
  140. package/src/gen-imports.ts +3 -0
  141. package/src/index.ts +11 -12
  142. package/src/insights.ts +6 -5
  143. package/src/logger.ts +28 -0
  144. package/src/messageComposer/LocationComposer.ts +9 -5
  145. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
  146. package/src/messageComposer/attachmentIdentity.ts +16 -9
  147. package/src/messageComposer/attachmentManager.ts +13 -8
  148. package/src/messageComposer/configuration/types.ts +11 -11
  149. package/src/messageComposer/linkPreviewsManager.ts +9 -10
  150. package/src/messageComposer/messageComposer.ts +57 -53
  151. package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
  152. package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
  153. package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
  154. package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
  155. package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
  156. package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
  157. package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
  158. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
  159. package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
  160. package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
  161. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
  162. package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
  163. package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
  164. package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
  165. package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
  166. package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
  167. package/src/messageComposer/middleware/textComposer/types.ts +9 -4
  168. package/src/messageComposer/pollComposer.ts +6 -8
  169. package/src/messageComposer/textComposer.ts +27 -2
  170. package/src/messageComposer/types.ts +6 -28
  171. package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
  172. package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
  173. package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
  174. package/src/messageOperations/MessageOperations.ts +212 -0
  175. package/src/messageOperations/index.ts +10 -0
  176. package/src/messageOperations/types.ts +64 -0
  177. package/src/moderation.ts +38 -431
  178. package/src/notifications/types.ts +8 -7
  179. package/src/offline-support/offline_support_api.ts +200 -133
  180. package/src/offline-support/offline_sync_manager.ts +23 -44
  181. package/src/offline-support/types.ts +23 -26
  182. package/src/offline-support/util.ts +5 -4
  183. package/src/pagination/FilterBuilder.ts +4 -1
  184. package/src/pagination/ItemIndex.ts +25 -0
  185. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
  186. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
  187. package/src/pagination/cursorDerivation/index.ts +1 -0
  188. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
  189. package/src/pagination/filterCompiler.ts +196 -0
  190. package/src/pagination/index.ts +1 -3
  191. package/src/pagination/paginators/BasePaginator.ts +2859 -0
  192. package/src/pagination/paginators/ChannelPaginator.ts +729 -0
  193. package/src/pagination/paginators/MessageIntervalPaginator.ts +1116 -0
  194. package/src/pagination/paginators/MessagePaginator.ts +508 -0
  195. package/src/pagination/paginators/PinnedMessagePaginator.ts +108 -0
  196. package/src/pagination/paginators/ReminderPaginator.ts +107 -0
  197. package/src/pagination/paginators/UserGroupPaginator.ts +127 -0
  198. package/src/pagination/paginators/index.ts +7 -0
  199. package/src/pagination/paginators/stateThrottling.ts +31 -0
  200. package/src/pagination/sortCompiler.ts +193 -0
  201. package/src/pagination/types.normalization.ts +14 -0
  202. package/src/pagination/utility.normalization.ts +106 -0
  203. package/src/pagination/utility.queryChannel.ts +84 -0
  204. package/src/pagination/utility.search.ts +80 -0
  205. package/src/permissions.ts +7 -8
  206. package/src/poll.ts +101 -110
  207. package/src/poll_manager.ts +14 -8
  208. package/src/reminders/Reminder.ts +2 -5
  209. package/src/reminders/ReminderManager.ts +19 -21
  210. package/src/search/BaseSearchSource.ts +0 -3
  211. package/src/search/ChannelMemberSearchSource.ts +7 -1
  212. package/src/search/ChannelSearchSource.ts +10 -3
  213. package/src/search/MessageSearchSource.ts +29 -30
  214. package/src/search/UserSearchSource.ts +12 -8
  215. package/src/search/types.ts +3 -4
  216. package/src/segment.ts +1 -95
  217. package/src/signing.ts +107 -67
  218. package/src/store.ts +2 -1
  219. package/src/thread.ts +562 -238
  220. package/src/thread_manager.ts +37 -16
  221. package/src/token_manager.ts +21 -10
  222. package/src/types.ts +364 -4533
  223. package/src/uploadManager.ts +8 -0
  224. package/src/utils/FixedSizeQueueCache.ts +12 -6
  225. package/src/utils/WithSubscriptions.ts +2 -1
  226. package/src/utils/concurrency.ts +4 -4
  227. package/src/utils/mergeWith/mergeWith.ts +3 -3
  228. package/src/utils/mergeWith/mergeWithCore.ts +140 -164
  229. package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
  230. package/src/utils/retryable.ts +117 -0
  231. package/src/utils/throttling/throttle.ts +130 -0
  232. package/src/utils.ts +208 -754
  233. package/dist/types/channel_manager.d.ts +0 -122
  234. package/dist/types/events.d.ts +0 -72
  235. package/dist/types/pagination/BasePaginator.d.ts +0 -69
  236. package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
  237. package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
  238. package/src/channel_manager.ts +0 -830
  239. package/src/events.ts +0 -75
  240. package/src/pagination/BasePaginator.ts +0 -184
  241. package/src/pagination/ReminderPaginator.ts +0 -56
  242. package/src/pagination/UserGroupPaginator.ts +0 -93
@@ -3,26 +3,79 @@ import { ChannelState } from './channel_state';
3
3
  import { CooldownTimer } from './CooldownTimer';
4
4
  import { MessageComposer } from './messageComposer';
5
5
  import { MessageReceiptsTracker } from './messageDelivery';
6
+ import { MessagePaginator, PinnedMessagePaginator } from './pagination/paginators';
7
+ import { MessageOperations } from './messageOperations';
6
8
  import type { StreamChat } from './client';
7
- import type { AIState, APIResponse, AscDesc, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelMemberAPIResponse, ChannelMemberResponse, ChannelPushPreference, ChannelQueryOptions, ChannelResponse, ChannelUpdateOptions, CreateDraftResponse, DeleteChannelAPIResponse, DraftMessagePayload, Event, EventAPIResponse, EventHandler, EventTypes, GetDraftResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, LiveLocationPayload, LocalMessage, MarkReadOptions, MarkUnreadOptions, MemberFilters, MemberSort, Message, MessageFilters, MessageOptions, MessagePaginationOptions, MessageResponse, MessageSetType, MuteChannelAPIResponse, NewMemberPayload, PartialUpdateChannel, PartialUpdateChannelAPIResponse, PartialUpdateMember, PartialUpdateMemberAPIResponse, PinnedMessagePaginationOptions, PinnedMessagesSort, PollVoteData, QueryChannelAPIResponse, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, SendMessageOptions, SendReactionOptions, StaticLocationPayload, TruncateChannelAPIResponse, TruncateOptions, UnBanUserOptions, UpdateChannelAPIResponse, UpdateChannelOptions, UpdateLocationPayload, UserResponse } from './types';
8
- import type { Role } from './permissions';
9
+ import type { AIState, APIResponse, BanUserOptions, ChannelData, ChannelGetOrCreateRequest, ChannelMemberResponse, ChannelResponse, ChannelStateResponseFields, ChannelUpdateOptions, CreateDraftResponse, DeleteMessageOptions, Event, EventAPIResponse, EventHandler, EventPayload, EventType, GetRepliesAPIResponse, GetRepliesRequest, LocalMessage, MarkReadRequest, MarkUnreadRequest, MessageRequest, MessageResponse, MessageSetType, PinnedMessagePaginationOptions, PinnedMessagesSort, QueryMembersPayload, ReactionAPIResponse, ReactionRequest, SearchPayload, SendMessageOptions, SendReactionRequest, SharedLocation, UnBanUserOptions, UpdateChannelPartialRequest, UpdateLiveLocationRequest, UpdateMessageOptions, UserResponse } from './types';
10
+ import type { RoleName } from './permissions';
11
+ import { StateStore } from './store';
12
+ import type { ChannelMemberRequest as Gen_ChannelMemberRequest, ChannelPushPreferencesResponse as Gen_ChannelPushPreferencesResponse, ChannelStopWatchingRequest as Gen_ChannelStopWatchingRequest, CreateDraftRequest as Gen_CreateDraftRequest, HideChannelRequest as Gen_HideChannelRequest, MuteChannelRequest as Gen_MuteChannelRequest, SendMessageRequest as Gen_SendMessageRequest, ShowChannelRequest as Gen_ShowChannelRequest, UnmuteChannelRequest as Gen_UnmuteChannelRequest, UpdateChannelRequest as Gen_UpdateChannelRequest, WSEvent } from './gen/models';
13
+ import type { ChatApi } from './gen/chat/ChatApi';
14
+ import { ChannelApi } from './gen/chat/ChannelApi';
15
+ export type SendMessageWithStateUpdateParams = {
16
+ localMessage: LocalMessage;
17
+ message?: MessageRequest;
18
+ options?: SendMessageOptions;
19
+ /**
20
+ * Per-call override for the send/retry request (advanced).
21
+ * If set, it takes precedence over channel instance configuration handlers.
22
+ */
23
+ sendMessageRequestFn?: CustomSendMessageRequestFn;
24
+ };
25
+ export type RetrySendMessageWithLocalUpdateParams = Omit<SendMessageWithStateUpdateParams, 'message'>;
26
+ export type UpdateMessageWithStateUpdateParams = {
27
+ localMessage: LocalMessage;
28
+ options?: UpdateMessageOptions;
29
+ /**
30
+ * Per-call override for the update request (advanced).
31
+ * If set, it takes precedence over channel instance configuration handlers.
32
+ */
33
+ updateMessageRequestFn?: CustomUpdateMessageRequestFn;
34
+ };
35
+ export type DeleteMessageWithStateUpdateParams = {
36
+ localMessage: LocalMessage;
37
+ options?: DeleteMessageOptions;
38
+ /**
39
+ * Per-call override for the delete request (advanced).
40
+ * If set, it takes precedence over channel instance configuration handlers.
41
+ */
42
+ deleteMessageRequestFn?: CustomDeleteMessageRequestFn;
43
+ };
44
+ export type CustomSendMessageRequestFn = (params: Omit<SendMessageWithStateUpdateParams, 'sendMessageRequestFn'>) => Promise<{
45
+ message: MessageResponse;
46
+ }>;
47
+ export type CustomUpdateMessageRequestFn = (params: Omit<UpdateMessageWithStateUpdateParams, 'updateMessageRequestFn'>) => Promise<{
48
+ message: MessageResponse;
49
+ }>;
50
+ export type CustomDeleteMessageRequestFn = (params: Omit<DeleteMessageWithStateUpdateParams, 'deleteMessageRequestFn'>) => Promise<{
51
+ message: MessageResponse;
52
+ }>;
53
+ export type CustomMarkReadRequestFn = (params: {
54
+ channel: Channel;
55
+ options?: MarkReadRequest;
56
+ }) => Promise<EventAPIResponse | null>;
57
+ export type ChannelInstanceConfig = {
58
+ requestHandlers?: {
59
+ deleteMessageRequest?: CustomDeleteMessageRequestFn;
60
+ markReadRequest?: CustomMarkReadRequestFn;
61
+ sendMessageRequest?: CustomSendMessageRequestFn;
62
+ retrySendMessageRequest?: CustomSendMessageRequestFn;
63
+ updateMessageRequest?: CustomUpdateMessageRequestFn;
64
+ };
65
+ };
9
66
  /**
10
- * Channel - The Channel class manages it's own state.
67
+ * The Channel class manages its own state.
11
68
  */
12
- export declare class Channel {
69
+ export declare class Channel extends ChannelApi {
13
70
  _client: StreamChat;
14
- type: string;
15
- id: string | undefined;
16
- data: Partial<ChannelData & ChannelResponse> | undefined;
17
- _data: Partial<ChannelData & ChannelResponse>;
71
+ data: Partial<ChannelResponse> | undefined;
72
+ _data: ChannelData;
18
73
  cid: string;
19
74
  /** */
20
- listeners: {
21
- [key: string]: (string | EventHandler)[];
22
- };
75
+ listeners: Map<EventType, Set<EventHandler>>;
23
76
  state: ChannelState;
24
77
  /**
25
- * This boolean is a vague indication of weather the channel exists on chat backend.
78
+ * This boolean is a vague indication of whether the channel exists on chat backend.
26
79
  *
27
80
  * If the value is true, then that means the channel has been initialized by either calling
28
81
  * channel.create() or channel.query() or channel.watch().
@@ -32,7 +85,7 @@ export declare class Channel {
32
85
  */
33
86
  initialized: boolean;
34
87
  /**
35
- * Indicates weather channel has been initialized by manually populating the state with some messages, members etc.
88
+ * Indicates whether channel has been initialized by manually populating the state with some messages, members etc.
36
89
  * Static state indicates that channel exists on backend, but is not being watched yet.
37
90
  */
38
91
  offlineMode: boolean;
@@ -40,410 +93,364 @@ export declare class Channel {
40
93
  lastTypingEvent: Date | null;
41
94
  isTyping: boolean;
42
95
  disconnected: boolean;
43
- push_preferences?: ChannelPushPreference;
96
+ push_preferences?: Gen_ChannelPushPreferencesResponse;
97
+ readonly configState: StateStore<ChannelInstanceConfig>;
44
98
  readonly messageComposer: MessageComposer;
45
99
  readonly messageReceiptsTracker: MessageReceiptsTracker;
100
+ readonly messagePaginator: MessagePaginator;
101
+ readonly pinnedMessagesPaginator: PinnedMessagePaginator;
102
+ readonly messageOperations: MessageOperations;
46
103
  readonly cooldownTimer: CooldownTimer;
47
104
  /**
48
- * constructor - Create a channel
49
- *
50
- * @param {StreamChat} client the chat client
51
- * @param {string} type the type of channel
52
- * @param {string} [id] the id of the chat
53
- * @param {ChannelData} data any additional custom params
105
+ * Creates a `Channel` instance bound to the given chat client.
54
106
  *
55
- * @return {Channel} Returns a new uninitialized channel
107
+ * @param client - The chat client.
108
+ * @param type - The type of channel.
109
+ * @param id - The ID of the chat (optional).
110
+ * @param data - Any additional custom params.
111
+ * @returns A new uninitialized channel.
56
112
  */
57
113
  constructor(client: StreamChat, type: string, id: string | undefined, data: ChannelData);
58
114
  /**
59
- * getClient - Get the chat client for this channel. If client.disconnect() was called, this function will error
115
+ * Returns the chat client for this channel. Throws if `client.disconnect()` was called.
60
116
  *
61
- * @return {StreamChat}
117
+ * @returns The chat client.
62
118
  */
63
119
  getClient(): StreamChat;
64
120
  /**
65
- * getConfig - Get the config for this channel id (cid)
121
+ * Returns the config for this channel ID (CID).
66
122
  *
67
- * @return {Record<string, unknown>}
123
+ * @returns The channel config.
68
124
  */
69
- getConfig(): import("./types").ChannelConfigWithInfo | undefined;
125
+ getConfig(): import(".").ChannelConfigWithInfo | undefined;
126
+ _sendMessage(request: Gen_SendMessageRequest): Promise<import("./types").StreamResponse<import(".").SendMessageResponse>>;
70
127
  /**
71
- * sendMessage - Send a message to this channel
128
+ * Sends a message to this channel.
72
129
  *
73
- * @param {Message} message The Message object
74
- * @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
75
- * @param {boolean} [options.skip_push] Skip sending push notifications
76
- * @param {boolean} [options.is_pending_message] DEPRECATED, please use `pending` instead.
77
- * @param {boolean} [options.pending] Make this message pending
78
- * @param {Record<string,string>} [options.pending_message_metadata] Metadata for the pending message
79
- * @param {boolean} [options.force_moderation] Apply force moderation for server-side requests
80
- *
81
- * @return {Promise<SendMessageAPIResponse>} The Server Response
130
+ * @param request - The send message request payload, including the message body and optional flags
131
+ * such as `skip_enrich_url`, `skip_push`, and `keep_channel_hidden`.
132
+ * @returns The server response.
82
133
  */
83
- _sendMessage(message: Message, options?: SendMessageOptions): Promise<SendMessageAPIResponse>;
84
- sendMessage(message: Message, options?: SendMessageOptions): Promise<SendMessageAPIResponse>;
134
+ sendMessage(request: Gen_SendMessageRequest): Promise<import("./types").StreamResponse<import(".").SendMessageResponse>>;
85
135
  /**
86
- * Upload a file to this channel’s file endpoint (multipart). Forwards to the client’s `sendFile` implementation.
87
- *
88
- * @param uri File source: URL string, `File`, `Buffer`, or readable stream (Node).
89
- * @param name File name sent in the multipart body.
90
- * @param contentType MIME type; defaults are applied when omitted.
91
- * @param user Optional user payload appended to the form as JSON.
92
- * @param axiosRequestConfig Optional Axios per-request config, merged after upload defaults (e.g. `onUploadProgress`, `signal` from `AbortController`).
93
- * @return Promise resolving to `{ file: string, ... }` with the CDN URL.
136
+ * Sends a message with optimistic local state update.
94
137
  */
95
- sendFile(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse, axiosRequestConfig?: AxiosRequestConfig): Promise<import("./types").SendFileAPIResponse>;
138
+ sendMessageWithLocalUpdate(params: SendMessageWithStateUpdateParams): Promise<void>;
96
139
  /**
97
- * Upload an image to this channel’s image endpoint (multipart). Uses the same transport as `sendFile`.
98
- *
99
- * @param uri Image source: URL string, `File`, or readable stream (Node). For `Buffer` uploads, use `sendFile` toward the channel file endpoint instead.
100
- * @param name File name sent in the multipart body.
101
- * @param contentType MIME type.
102
- * @param user Optional user payload appended to the form as JSON.
103
- * @param axiosRequestConfig Optional Axios per-request config, merged after upload defaults (e.g. `onUploadProgress`, `signal`).
104
- * @return Promise resolving to `{ file: string, ... }` with the CDN URL.
140
+ * Retry sending a failed message.
105
141
  */
106
- sendImage(uri: string | NodeJS.ReadableStream | File, name?: string, contentType?: string, user?: UserResponse, axiosRequestConfig?: AxiosRequestConfig): Promise<import("./types").SendFileAPIResponse>;
107
- deleteFile(url: string): Promise<APIResponse>;
108
- deleteImage(url: string): Promise<APIResponse>;
142
+ retrySendMessageWithLocalUpdate(params: Omit<SendMessageWithStateUpdateParams, 'message'>): Promise<void>;
109
143
  /**
110
- * sendEvent - Send an event on this channel
111
- *
112
- * @param {Event} event for example {type: 'message.read'}
113
- *
114
- * @return {Promise<EventAPIResponse>} The Server Response
144
+ * Updates a message with optimistic local state update.
115
145
  */
116
- sendEvent(event: Event): Promise<EventAPIResponse>;
146
+ updateMessageWithLocalUpdate(params: UpdateMessageWithStateUpdateParams): Promise<void>;
117
147
  /**
118
- * search - Query messages
119
- *
120
- * @param {MessageFilters | string} query search query or object MongoDB style filters
121
- * @param {{client_id?: string; connection_id?: string; query?: string; message_filter_conditions?: MessageFilters}} options Option object, {user_id: 'tommaso'}
122
- *
123
- * @return {Promise<SearchAPIResponse>} search messages response
148
+ * Deletes a message with local state update.
124
149
  */
125
- search(query: MessageFilters | string, options?: SearchOptions & {
126
- client_id?: string;
127
- connection_id?: string;
128
- message_filter_conditions?: MessageFilters;
129
- message_options?: MessageOptions;
130
- query?: string;
131
- }): Promise<SearchAPIResponse>;
150
+ deleteMessageWithLocalUpdate(params: DeleteMessageWithStateUpdateParams): Promise<void>;
132
151
  /**
133
- * queryMembers - Query Members
134
- *
135
- * @param {MemberFilters} filterConditions object MongoDB style filters
136
- * @param {MemberSort} [sort] Sort options, for instance [{created_at: -1}].
137
- * When using multiple fields, make sure you use array of objects to guarantee field order, for instance [{name: -1}, {created_at: 1}]
138
- * @param {{ limit?: number; offset?: number }} [options] Option object, {limit: 10, offset:10}
139
- *
140
- * @return {Promise<ChannelMemberAPIResponse>} Query Members response
152
+ * Adds a reaction with an optimistic local state update: the reaction is applied to the cached
153
+ * message immediately ({@link applyReactionLocally}), then the request is
154
+ * fired via {@link Channel.sendReaction} (which owns the offline-DB write + queue). The
155
+ * server-authoritative counts reconcile on the response; the message is rolled back on failure.
141
156
  */
142
- queryMembers(filterConditions: MemberFilters, sort?: MemberSort, options?: QueryMembersOptions): Promise<ChannelMemberAPIResponse>;
157
+ addReactionWithLocalUpdate({ messageId, reaction, options, }: {
158
+ messageId: string;
159
+ reaction: ReactionRequest;
160
+ options?: Pick<SendReactionRequest, 'enforce_unique' | 'skip_push'>;
161
+ }): Promise<void>;
143
162
  /**
144
- * updateMemberPartial - Partial update a member
145
- *
146
- * @param {PartialUpdateMember} updates
147
- * @param {{ user_id?: string }} [options] Option object, {user_id: 'jane'} to optionally specify the user id
148
-
149
- * @return {Promise<ChannelMemberResponse>} Updated member
163
+ * Removes the current user's reaction with an optimistic local state update, mirroring
164
+ * {@link Channel.addReactionWithLocalUpdate}.
150
165
  */
151
- updateMemberPartial(updates: PartialUpdateMember, options?: {
152
- userId?: string;
153
- }): Promise<PartialUpdateMemberAPIResponse>;
166
+ deleteReactionWithLocalUpdate({ messageId, type, }: {
167
+ messageId: string;
168
+ type: string;
169
+ }): Promise<void>;
154
170
  /**
155
- * @deprecated Use `updateMemberPartial` instead
156
- * partialUpdateMember - Partial update a member
157
- *
158
- * @param {string} user_id member user id
159
- * @param {PartialUpdateMember} updates
171
+ * Upload a file to this channel’s file endpoint (multipart). Forwards to the client’s `sendFile` implementation.
160
172
  *
161
- * @return {Promise<ChannelMemberResponse>} Updated member
173
+ * @param uri - File source: URL string, `File`, `Buffer`, or readable stream (Node).
174
+ * @param name - File name sent in the multipart body (optional).
175
+ * @param contentType - MIME type; defaults are applied when omitted (optional).
176
+ * @param user - User payload appended to the form as JSON (optional).
177
+ * @param axiosRequestConfig - Axios per-request config, merged after upload defaults, e.g. `onUploadProgress`, `signal` from `AbortController` (optional).
178
+ * @returns A promise resolving to `{ file: string, ... }` with the CDN URL.
162
179
  */
163
- partialUpdateMember(user_id: string, updates: PartialUpdateMember): Promise<PartialUpdateMemberAPIResponse>;
180
+ sendFile(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse, axiosRequestConfig?: AxiosRequestConfig): Promise<import("./types").SendFileAPIResponse>;
164
181
  /**
165
- * sendReaction - Sends a reaction to a message. If offline support is enabled, it will make sure
166
- * that sending the reaction is queued up if it fails due to bad internet conditions and executed
167
- * later.
182
+ * Upload an image to this channel's image endpoint (multipart). Uses the same transport as `sendFile`.
168
183
  *
169
- * @param {string} messageID the message id
170
- * @param {Reaction} reaction the reaction object for instance {type: 'love'}
171
- * @param {{ enforce_unique?: boolean, skip_push?: boolean }} [options] Option object, {enforce_unique: true, skip_push: true} to override any existing reaction or skip sending push notifications
172
- *
173
- * @return {Promise<ReactionAPIResponse>} The Server Response
184
+ * @param uri - Image source: URL string, `File`, or readable stream (Node). For `Buffer` uploads, use `sendFile` toward the channel file endpoint instead.
185
+ * @param name - File name sent in the multipart body (optional).
186
+ * @param contentType - MIME type (optional).
187
+ * @param user - User payload appended to the form as JSON (optional).
188
+ * @param axiosRequestConfig - Axios per-request config, merged after upload defaults, e.g. `onUploadProgress`, `signal` (optional).
189
+ * @returns A promise resolving to `{ file: string, ... }` with the CDN URL.
174
190
  */
175
- sendReaction(messageID: string, reaction: Reaction, options?: SendReactionOptions): Promise<ReactionAPIResponse>;
191
+ sendImage(uri: string | NodeJS.ReadableStream | File, name?: string, contentType?: string, user?: UserResponse, axiosRequestConfig?: AxiosRequestConfig): Promise<import("./types").SendFileAPIResponse>;
192
+ deleteFile(url: string): Promise<import("./types").StreamResponse<import(".").Response>>;
193
+ deleteImage(url: string): Promise<import("./types").StreamResponse<import(".").Response>>;
176
194
  /**
177
- * sendReaction - Send a reaction about a message
195
+ * Sends an event on this channel.
178
196
  *
179
- * @param {string} messageID the message id
180
- * @param {Reaction} reaction the reaction object for instance {type: 'love'}
181
- * @param {{ enforce_unique?: boolean, skip_push?: boolean }} [options] Option object, {enforce_unique: true, skip_push: true} to override any existing reaction or skip sending push notifications
182
- *
183
- * @return {Promise<ReactionAPIResponse>} The Server Response
197
+ * @param event - For example `{ type: 'message.read' }`.
198
+ * @returns The server response.
184
199
  */
185
- _sendReaction(messageID: string, reaction: Reaction, options?: SendReactionOptions): Promise<ReactionAPIResponse>;
186
- deleteReaction(messageID: string, reactionType: string, user_id?: string): Promise<ReactionAPIResponse>;
200
+ sendEvent(request: {
201
+ event: Event;
202
+ }): Promise<import("./types").StreamResponse<import(".").EventResponse>>;
187
203
  /**
188
- * deleteReaction - Delete a reaction by user and type
189
- *
190
- * @param {string} messageID the id of the message from which te remove the reaction
191
- * @param {string} reactionType the type of reaction that should be removed
192
- * @param {string} [user_id] the id of the user (used only for server side request) default null
204
+ * Queries messages.
193
205
  *
194
- * @return {Promise<ReactionAPIResponse>} The Server Response
206
+ * @param request - The search request payload (optional). The inner `payload` accepts
207
+ * MongoDB-style filters and additional options such as `user_id`.
208
+ * @returns The search messages response.
195
209
  */
196
- _deleteReaction(messageID: string, reactionType: string, user_id?: string): Promise<ReactionAPIResponse>;
210
+ search(request?: {
211
+ payload?: SearchPayload;
212
+ }): Promise<import("./types").StreamResponse<import(".").SearchResponse>>;
197
213
  /**
198
- * update - Edit the channel's custom properties
214
+ * Queries members.
199
215
  *
200
- * @param {ChannelData} channelData The object to update the custom properties of this channel with
201
- * @param {Message} [updateMessage] Optional message object for channel members notification
202
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
203
- * @return {Promise<UpdateChannelAPIResponse>} The server response
216
+ * @param request - The query members request payload (optional). The inner `payload` accepts
217
+ * MongoDB-style filters, sort directions (e.g. `[{ field: 'created_at', direction: -1 }]`),
218
+ * and pagination options (`limit`, `offset`).
219
+ * @returns The query members response.
204
220
  */
205
- update(channelData?: Partial<ChannelData & ChannelResponse>, updateMessage?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
221
+ queryMembers(request?: {
222
+ payload?: Partial<QueryMembersPayload>;
223
+ }): Promise<import("./types").StreamResponse<import(".").MembersResponse>>;
206
224
  /**
207
- * updatePartial - partial update channel properties
208
- *
209
- * @param {PartialUpdateChannel} partial update request
225
+ * Sends a reaction to a message. If offline support is enabled, it will make sure
226
+ * that sending the reaction is queued up if it fails due to bad internet conditions and executed
227
+ * later.
210
228
  *
211
- * @return {Promise<PartialUpdateChannelAPIResponse>}
229
+ * @param request - The send-reaction request payload, including the target message ID, the
230
+ * reaction object (e.g. `{ type: 'love' }`), and optional flags such as `enforce_unique` and
231
+ * `skip_push`.
232
+ * @returns The server response.
212
233
  */
213
- updatePartial(update: PartialUpdateChannel): Promise<PartialUpdateChannelAPIResponse>;
234
+ sendReaction(request: Parameters<ChatApi['sendReaction']>[0]): Promise<ReactionAPIResponse>;
235
+ _sendReaction(request: Parameters<ChatApi['sendReaction']>[0]): Promise<import("./types").StreamResponse<import(".").SendReactionResponse>>;
236
+ deleteReaction(request: Parameters<ChatApi['deleteReaction']>[0]): Promise<ReactionAPIResponse>;
214
237
  /**
215
- * enableSlowMode - enable slow mode
238
+ * Deletes a reaction by user and type.
216
239
  *
217
- * @param {number} coolDownInterval the cooldown interval in seconds
218
- * @return {Promise<UpdateChannelAPIResponse>} The server response
240
+ * @param request - The delete reaction request payload identifying the target message and reaction type.
241
+ * @returns The server response.
219
242
  */
220
- enableSlowMode(coolDownInterval: number): Promise<UpdateChannelAPIResponse>;
243
+ _deleteReaction(request: Parameters<ChatApi['deleteReaction']>[0]): Promise<import("./types").StreamResponse<import(".").DeleteReactionResponse>>;
221
244
  /**
222
- * disableSlowMode - disable slow mode
245
+ * Edit the channel using the inherited `update()` from `ChannelApi`. Caches the
246
+ * server-returned channel onto `this.data`.
223
247
  *
224
- * @return {Promise<UpdateChannelAPIResponse>} The server response
248
+ * @param request - Channel update payload, e.g. `{ data: { name: 'foo' }, message }` (optional).
249
+ * @returns The server response.
225
250
  */
226
- disableSlowMode(): Promise<UpdateChannelAPIResponse>;
227
- sendSharedLocation(location: StaticLocationPayload | LiveLocationPayload, userId?: string): Promise<SendMessageAPIResponse>;
228
- stopLiveLocationSharing(payload: UpdateLocationPayload): Promise<void>;
251
+ update(request?: Gen_UpdateChannelRequest): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
229
252
  /**
230
- * delete - Delete the channel. Messages are permanently removed.
253
+ * Partial update of channel properties.
231
254
  *
232
- * @param {boolean} [options.hard_delete] Defines if the channel is hard deleted or not
233
- *
234
- * @return {Promise<DeleteChannelAPIResponse>} The server response
255
+ * @param update - The partial update request.
256
+ * @returns The server response.
235
257
  */
236
- delete(options?: {
237
- hard_delete?: boolean;
238
- }): Promise<DeleteChannelAPIResponse>;
258
+ updatePartial(update: UpdateChannelPartialRequest): Promise<import("./types").StreamResponse<import(".").UpdateChannelPartialResponse>>;
239
259
  /**
240
- * truncate - Removes all messages from the channel
241
- * @param {TruncateOptions} [options] Defines truncation options
242
- * @return {Promise<TruncateChannelAPIResponse>} The server response
260
+ * Enables slow mode.
261
+ *
262
+ * @param coolDownInterval - The cooldown interval in seconds.
263
+ * @returns The server response.
243
264
  */
244
- truncate(options?: TruncateOptions): Promise<TruncateChannelAPIResponse>;
265
+ enableSlowMode(coolDownInterval: number): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
245
266
  /**
246
- * acceptInvite - accept invitation to the channel
247
- *
248
- * @param {UpdateChannelOptions} [options] The object to update the custom properties of this channel with
267
+ * Disables slow mode.
249
268
  *
250
- * @return {Promise<UpdateChannelAPIResponse>} The server response
269
+ * @returns The server response.
251
270
  */
252
- acceptInvite(options?: UpdateChannelOptions): Promise<UpdateChannelAPIResponse>;
271
+ disableSlowMode(): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
272
+ sendSharedLocation(location: SharedLocation & {
273
+ message_id?: string;
274
+ }): Promise<import("./types").StreamResponse<import(".").SendMessageResponse>>;
275
+ stopLiveLocationSharing(payload: UpdateLiveLocationRequest): Promise<void>;
253
276
  /**
254
- * rejectInvite - reject invitation to the channel
277
+ * Accepts an invitation to the channel.
255
278
  *
256
- * @param {UpdateChannelOptions} [options] The object to update the custom properties of this channel with
279
+ * @param options - The object to update the custom properties of this channel with (optional, defaults to `{}`).
280
+ * @returns The server response.
281
+ */
282
+ acceptInvite(options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
283
+ /**
284
+ * Rejects an invitation to the channel.
257
285
  *
258
- * @return {Promise<UpdateChannelAPIResponse>} The server response
286
+ * @param options - The object to update the custom properties of this channel with (optional, defaults to `{}`).
287
+ * @returns The server response.
259
288
  */
260
- rejectInvite(options?: UpdateChannelOptions): Promise<UpdateChannelAPIResponse>;
289
+ rejectInvite(options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
261
290
  /**
262
- * addMembers - add members to the channel
291
+ * Adds members to the channel.
263
292
  *
264
- * @param {string[] | Array<NewMemberPayload>} members An array of members to add to the channel
265
- * @param {Message} [message] Optional message object for channel members notification
266
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
267
- * @return {Promise<UpdateChannelAPIResponse>} The server response
293
+ * @param members - An array of members to add to the channel.
294
+ * @param message - Message object for channel members notification (optional).
295
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
296
+ * @returns The server response.
268
297
  */
269
- addMembers(members: string[] | Array<NewMemberPayload>, message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
298
+ addMembers(members: string[] | Array<Gen_ChannelMemberRequest>, message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
270
299
  /**
271
- * addFilterTags - add filter tags to the channel
300
+ * Adds filter tags to the channel.
272
301
  *
273
- * @param {string[]} tags An array of tags to add to the channel
274
- * @param {Message} [message] Optional message object for channel members notification
275
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
276
- * @return {Promise<UpdateChannelAPIResponse>} The server response
302
+ * @param tags - An array of tags to add to the channel.
303
+ * @param message - Message object for channel members notification (optional).
304
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
305
+ * @returns The server response.
277
306
  */
278
- addFilterTags(tags: string[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
307
+ addFilterTags(tags: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
279
308
  /**
280
- * removeFilterTags - remove filter tags from the channel
309
+ * Removes filter tags from the channel.
281
310
  *
282
- * @param {string[]} tags An array of tags to remove from the channel
283
- * @param {Message} [message] Optional message object for channel members notification
284
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
285
- * @return {Promise<UpdateChannelAPIResponse>} The server response
311
+ * @param tags - An array of tags to remove from the channel.
312
+ * @param message - Message object for channel members notification (optional).
313
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
314
+ * @returns The server response.
286
315
  */
287
- removeFilterTags(tags: string[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
316
+ removeFilterTags(tags: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
288
317
  /**
289
- * addModerators - add moderators to the channel
318
+ * Adds moderators to the channel.
290
319
  *
291
- * @param {string[]} members An array of member identifiers
292
- * @param {Message} [message] Optional message object for channel members notification
293
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
294
- * @return {Promise<UpdateChannelAPIResponse>} The server response
320
+ * @param members - An array of member identifiers.
321
+ * @param message - Message object for channel members notification (optional).
322
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
323
+ * @returns The server response.
295
324
  */
296
- addModerators(members: string[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
325
+ addModerators(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
297
326
  /**
298
- * assignRoles - sets member roles in a channel
327
+ * Sets member roles in a channel.
299
328
  *
300
- * @param {{channel_role: Role, user_id: string}[]} roles List of role assignments
301
- * @param {Message} [message] Optional message object for channel members notification
302
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
303
- * @return {Promise<UpdateChannelAPIResponse>} The server response
329
+ * @param roles - List of role assignments.
330
+ * @param message - Message object for channel members notification (optional).
331
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
332
+ * @returns The server response.
304
333
  */
305
334
  assignRoles(roles: {
306
- channel_role: Role;
335
+ channel_role: RoleName;
307
336
  user_id: string;
308
- }[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
337
+ }[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
309
338
  /**
310
- * inviteMembers - invite members to the channel
339
+ * Invite members to the channel.
311
340
  *
312
- * @param {string[] | Array<NewMemberPayload>} members An array of members to invite to the channel
313
- * @param {Message} [message] Optional message object for channel members notification
314
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
315
- * @return {Promise<UpdateChannelAPIResponse>} The server response
341
+ * @param members - An array of members to invite to the channel.
342
+ * @param message - Message object for channel members notification (optional).
343
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
344
+ * @returns The server response.
316
345
  */
317
- inviteMembers(members: string[] | Required<Omit<NewMemberPayload, 'channel_role'>>[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
346
+ inviteMembers(members: string[] | Required<Omit<Gen_ChannelMemberRequest, 'channel_role'>>[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
318
347
  /**
319
- * removeMembers - remove members from channel
348
+ * Removes members from the channel.
320
349
  *
321
- * @param {string[]} members An array of member identifiers
322
- * @param {Message} [message] Optional message object for channel members notification
323
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
324
- * @return {Promise<UpdateChannelAPIResponse>} The server response
350
+ * @param members - An array of member identifiers.
351
+ * @param message - Message object for channel members notification (optional).
352
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
353
+ * @returns The server response.
325
354
  */
326
- removeMembers(members: string[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
355
+ removeMembers(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
327
356
  /**
328
- * demoteModerators - remove moderator role from channel members
357
+ * Removes the moderator role from channel members.
329
358
  *
330
- * @param {string[]} members An array of member identifiers
331
- * @param {Message} [message] Optional message object for channel members notification
332
- * @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
333
- * @return {Promise<UpdateChannelAPIResponse>} The server response
359
+ * @param members - An array of member identifiers.
360
+ * @param message - Message object for channel members notification (optional).
361
+ * @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
362
+ * @returns The server response.
334
363
  */
335
- demoteModerators(members: string[], message?: Message, options?: ChannelUpdateOptions): Promise<UpdateChannelAPIResponse>;
364
+ demoteModerators(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
336
365
  /**
337
- * _update - executes channel update request
338
- * @param payload Object Update Channel payload
339
- * @return {Promise<UpdateChannelAPIResponse>} The server response
340
- * TODO: introduce new type instead of Object in the next major update
341
- */
342
- _update(payload: object): Promise<UpdateChannelAPIResponse>;
343
- /**
344
- * mute - mutes the current channel
345
- * @param {{ user_id?: string, expiration?: string }} opts expiration in minutes or user_id
346
- * @return {Promise<MuteChannelAPIResponse>} The server response
366
+ * Mutes the current channel.
347
367
  *
348
- * example with expiration:
349
- * await channel.mute({expiration: moment.duration(2, 'weeks')});
368
+ * @example
369
+ * // with expiration
370
+ * await channel.mute({ expiration: moment.duration(2, 'weeks') });
350
371
  *
351
- * example server side:
352
- * await channel.mute({user_id: userId});
372
+ * @example
373
+ * // server side
374
+ * await channel.mute({ user_id: userId });
353
375
  *
376
+ * @param options - Mute options (optional, defaults to `{}`).
377
+ * @param options.expiration - Expiration in minutes (optional).
378
+ * @returns The server response.
354
379
  */
355
- mute(opts?: {
356
- expiration?: number;
357
- user_id?: string;
358
- }): Promise<MuteChannelAPIResponse>;
380
+ mute(options?: Gen_MuteChannelRequest): Promise<import("./types").StreamResponse<import(".").MuteChannelResponse>>;
359
381
  /**
360
- * unmute - mutes the current channel
361
- * @param {{ user_id?: string}} opts user_id
362
- * @return {Promise<APIResponse>} The server response
382
+ * Unmutes the current channel.
363
383
  *
364
- * example server side:
365
- * await channel.unmute({user_id: userId});
384
+ * @example
385
+ * // server side
386
+ * await channel.unmute({ user_id: userId });
387
+ *
388
+ * @param options - Unmute options (optional, defaults to `{}`).
389
+ * @param options.user_id - User ID (optional).
390
+ * @returns The server response.
366
391
  */
367
- unmute(opts?: {
368
- user_id?: string;
369
- }): Promise<APIResponse>;
392
+ unmute(options?: Gen_UnmuteChannelRequest): Promise<import("./types").StreamResponse<import(".").UnmuteResponse>>;
370
393
  /**
371
- * archive - archives the current channel
372
- * @param {{ user_id?: string }} opts user_id if called server side
373
- * @return {Promise<ChannelMemberResponse>} The server response
374
- *
375
- * example:
376
- * await channel.archives();
394
+ * Archives the current channel.
377
395
  *
378
- * example server side:
379
- * await channel.archive({user_id: userId});
396
+ * @example
397
+ * await channel.archive();
380
398
  *
399
+ * @returns The server response.
381
400
  */
382
- archive(opts?: {
383
- user_id?: string;
384
- }): Promise<ChannelMemberResponse>;
401
+ archive(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
385
402
  /**
386
- * unarchive - unarchives the current channel
387
- * @param {{ user_id?: string }} opts user_id if called server side
388
- * @return {Promise<ChannelMemberResponse>} The server response
403
+ * Unarchives the current channel.
389
404
  *
390
- * example:
405
+ * @example
391
406
  * await channel.unarchive();
392
407
  *
393
- * example server side:
394
- * await channel.unarchive({user_id: userId});
395
- *
408
+ * @returns The server response.
396
409
  */
397
- unarchive(opts?: {
398
- user_id?: string;
399
- }): Promise<ChannelMemberResponse>;
410
+ unarchive(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
400
411
  /**
401
- * pin - pins the current channel
402
- * @param {{ user_id?: string }} opts user_id if called server side
403
- * @return {Promise<ChannelMemberResponse>} The server response
412
+ * Pins the current channel.
404
413
  *
405
- * example:
414
+ * @example
406
415
  * await channel.pin();
407
416
  *
408
- * example server side:
409
- * await channel.pin({user_id: userId});
410
- *
417
+ * @returns The server response.
411
418
  */
412
- pin(opts?: {
413
- user_id?: string;
414
- }): Promise<ChannelMemberResponse>;
419
+ pin(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
415
420
  /**
416
- * unpin - unpins the current channel
417
- * @param {{ user_id?: string }} opts user_id if called server side
418
- * @return {Promise<ChannelMemberResponse>} The server response
421
+ * Unpins the current channel.
419
422
  *
420
- * example:
423
+ * @example
421
424
  * await channel.unpin();
422
425
  *
423
- * example server side:
424
- * await channel.unpin({user_id: userId});
425
- *
426
+ * @returns The server response.
426
427
  */
427
- unpin(opts?: {
428
- user_id?: string;
429
- }): Promise<ChannelMemberResponse>;
428
+ unpin(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
430
429
  /**
431
- * muteStatus - returns the mute status for the current channel
432
- * @return {{ muted: boolean; createdAt: Date | null; expiresAt: Date | null }} { muted: true | false, createdAt: Date | null, expiresAt: Date | null}
430
+ * Returns the mute status for the current channel.
431
+ *
432
+ * @returns An object of the form `{ muted: true | false, createdAt: Date | null, expiresAt: Date | null }`.
433
433
  */
434
434
  muteStatus(): {
435
- createdAt: Date | null;
435
+ muted: boolean;
436
+ createdAt: Date;
436
437
  expiresAt: Date | null;
438
+ } | {
437
439
  muted: boolean;
440
+ createdAt: null;
441
+ expiresAt: null;
438
442
  };
439
- sendAction(messageID: string, formData: Record<string, string>): Promise<SendMessageAPIResponse>;
443
+ sendAction(messageId: string, formData: Record<string, string>): Promise<import("./types").StreamResponse<import(".").MessageActionResponse>>;
440
444
  /**
441
- * keystroke - First of the typing.start and typing.stop events based on the users keystrokes.
442
- * Call this on every keystroke
445
+ * First of the `typing.start` and `typing.stop` events based on the user's keystrokes.
446
+ * Call this on every keystroke.
447
+ *
443
448
  * @see {@link https://getstream.io/chat/docs/typing_indicators/?language=js|Docs}
444
- * @param {string} [parent_id] set this field to `message.id` to indicate that typing event is happening in a thread
449
+ *
450
+ * @param parentId - Set this field to `message.id` to indicate that the typing event is happening in a thread (optional).
451
+ * @param options - Optional override carrying a `user_id` (optional).
445
452
  */
446
- keystroke(parent_id?: string, options?: {
453
+ keystroke(parentId?: string, options?: {
447
454
  user_id: string;
448
455
  }): Promise<void>;
449
456
  /**
@@ -451,8 +458,9 @@ export declare class Channel {
451
458
  * Typically used by the server connected to the AI service to notify clients of state changes.
452
459
  *
453
460
  * @param messageId - The ID of the message associated with the AI state.
454
- * @param state - The new state of the AI process (e.g., thinking, generating).
455
- * @param options - Optional parameters, such as `ai_message`, to include additional details in the event.
461
+ * @param state - The new state of the AI process, e.g. thinking, generating.
462
+ * @param options - Parameters such as `ai_message` to include additional details in the event (optional, defaults to `{}`).
463
+ * @param options.ai_message - Additional message detail to include in the event (optional).
456
464
  */
457
465
  updateAIState(messageId: string, state: AIState, options?: {
458
466
  ai_message?: string;
@@ -468,43 +476,44 @@ export declare class Channel {
468
476
  */
469
477
  stopAIResponse(): Promise<void>;
470
478
  /**
471
- * stopTyping - Sets last typing to null and sends the typing.stop event
479
+ * Sets last typing to null and sends the `typing.stop` event.
480
+ *
472
481
  * @see {@link https://getstream.io/chat/docs/typing_indicators/?language=js|Docs}
473
- * @param {string} [parent_id] set this field to `message.id` to indicate that typing event is happening in a thread
482
+ *
483
+ * @param parentId - Set this field to `message.id` to indicate that the typing event is happening in a thread (optional).
484
+ * @param options - Optional override carrying a `user_id` (optional).
474
485
  */
475
- stopTyping(parent_id?: string, options?: {
486
+ stopTyping(parentId?: string, options?: {
476
487
  user_id: string;
477
488
  }): Promise<void>;
478
489
  _isTypingIndicatorsEnabled(): boolean;
479
490
  /**
480
- * lastMessage - return the last message, takes into account that last few messages might not be perfectly sorted
491
+ * Run this user's mark-read reporter for this channel. Delegates to
492
+ * `MessageDeliveryReporter`, which batches the underlying `markRead` request
493
+ * with the user's read receipts state.
481
494
  *
482
- * @return {ReturnType<ChannelState['formatMessage']> | undefined} Description
483
- */
484
- lastMessage(): LocalMessage | undefined;
485
- /**
486
- * markRead - Send the mark read event for this user, only works if the `read_events` setting is enabled. Syncs the message delivery report candidates local state.
495
+ * Use the inherited `markRead()` from `ChannelApi` for a direct, unbatched call.
487
496
  *
488
- * @param {MarkReadOptions} data
489
- * @return {Promise<EventAPIResponse | null>} Description
497
+ * @param data - Mark read options (optional, defaults to `{}`).
490
498
  */
491
- markRead(data?: MarkReadOptions): Promise<EventAPIResponse | null>;
499
+ markReadViaReporter(data?: MarkReadRequest): Promise<EventAPIResponse | import("./types").StreamResponse<import(".").MarkReadResponse> | null>;
492
500
  /**
493
- * markReadRequest - Send the mark read event for this user, only works if the `read_events` setting is enabled
501
+ * Override of the inherited `markRead()` from `ChannelApi` that requires the
502
+ * channel to be initialized and respects the `read_events` channel config.
494
503
  *
495
- * @param {MarkReadOptions} data
496
- * @return {Promise<EventAPIResponse | null>} Description
504
+ * @param data - Mark read options (optional, defaults to `{}`).
505
+ * @returns The server response, or `null` if the request was skipped.
497
506
  */
498
- markAsReadRequest(data?: MarkReadOptions): Promise<EventAPIResponse | null>;
507
+ markRead(data?: MarkReadRequest): Promise<import("./types").StreamResponse<import(".").MarkReadResponse>>;
499
508
  /**
500
- * markUnread - Mark the channel as unread from messageID, only works if the `read_events` setting is enabled
509
+ * Marks the channel as unread from `messageId`. Only works when the `read_events` setting is enabled.
501
510
  *
502
- * @param {MarkUnreadOptions} data
503
- * @return {APIResponse} An API response
511
+ * @param data - Mark unread options.
512
+ * @returns An API response, or `null` if the request was skipped.
504
513
  */
505
- markUnread(data: MarkUnreadOptions): Promise<APIResponse | null>;
514
+ markUnread(data?: MarkUnreadRequest): Promise<import("./types").StreamResponse<import(".").Response>>;
506
515
  /**
507
- * markReadLocally - Resets this user's unread count locally, without any backend call. Intended for
516
+ * Resets this user's unread count locally, without any backend call. Intended for
508
517
  * channels that have read events disabled (e.g. livestreams) when the client is created with the
509
518
  * `isLocalUnreadCountEnabled` option. Dispatches a dedicated, client-only `message.read_locally` event
510
519
  * that runs through the same `_handleChannelEvent` read logic as a real `message.read` (minus the
@@ -512,257 +521,223 @@ export declare class Channel {
512
521
  * is enabled, the offline DB persists the reset for read-events-disabled channels, so the local
513
522
  * count stays consistent across app restarts.
514
523
  *
515
- * @return {Event | undefined} The dispatched `message.read_locally` event, or `undefined` if there is no connected user.
516
- */
517
- markReadLocally(): Event | undefined;
524
+ * @returns The dispatched `message.read_locally` event, or `undefined` if there is no connected user.
525
+ */
526
+ markReadLocally(): ({
527
+ type: "message.read_locally";
528
+ } & {
529
+ channel_type: string;
530
+ cid: string;
531
+ created_at: Date;
532
+ channel_id?: string;
533
+ last_read_message_id?: string;
534
+ team?: string;
535
+ user?: UserResponse;
536
+ } & {
537
+ received_at?: Date;
538
+ }) | undefined;
518
539
  /**
519
- * clean - Cleans the channel state and fires stop typing if needed
540
+ * Cleans the channel state and fires stop typing if needed.
520
541
  */
521
542
  clean(): void;
522
543
  /**
523
- * watch - Loads the initial channel state and watches for changes
544
+ * Loads the initial channel state and watches for changes.
524
545
  *
525
- * @param {ChannelQueryOptions} options additional options for the query endpoint
526
- *
527
- * @return {Promise<QueryChannelAPIResponse>} The server response
546
+ * @param options - Additional options for the query endpoint (optional).
547
+ * @returns The server response.
528
548
  */
529
- watch(options?: ChannelQueryOptions): Promise<QueryChannelAPIResponse>;
549
+ watch(options?: ChannelGetOrCreateRequest): Promise<import("./types").StreamResponse<import(".").ChannelStateResponse>>;
530
550
  /**
531
- * stopWatching - Stops watching the channel
551
+ * Stops watching the channel.
532
552
  *
533
- * @return {Promise<APIResponse>} The server response
553
+ * @param request - The stop-watching request payload (optional).
554
+ * @returns The server response.
534
555
  */
535
- stopWatching(): Promise<APIResponse>;
556
+ stopWatching(request?: Gen_ChannelStopWatchingRequest): Promise<import("./types").StreamResponse<import(".").Response>>;
536
557
  /**
537
- * getReplies - List the message replies for a parent message.
538
- *
539
- * The recommended way of working with threads is to use the Thread class.
558
+ * List the message replies for a parent message.
540
559
  *
541
- * @param {string} parent_id The message parent id, ie the top of the thread
542
- * @param {MessagePaginationOptions & { user?: UserResponse; user_id?: string }} options Pagination params, ie {limit:10, id_lte: 10}
560
+ * The recommended way of working with threads is to use the `Thread` class.
543
561
  *
544
- * @return {Promise<GetRepliesAPIResponse>} A response with a list of messages
562
+ * @param request - The get-replies request payload, including the parent message ID, pagination
563
+ * params, and optional sort directions for `created_at`.
564
+ * @returns A response with a list of messages.
545
565
  */
546
- getReplies(parent_id: string, options: MessagePaginationOptions & {
547
- user?: UserResponse;
548
- user_id?: string;
549
- }, sort?: {
550
- created_at: AscDesc;
551
- }[]): Promise<GetRepliesAPIResponse>;
566
+ getReplies(request: GetRepliesRequest): Promise<import("./types").StreamResponse<import(".").GetRepliesResponse>>;
552
567
  /**
553
- * getPinnedMessages - List list pinned messages of the channel
554
- *
555
- * @param {PinnedMessagePaginationOptions & { user?: UserResponse; user_id?: string }} options Pagination params, ie {limit:10, id_lte: 10}
556
- * @param {PinnedMessagesSort} sort defines sorting direction of pinned messages
568
+ * List pinned messages of the channel.
557
569
  *
558
- * @return {Promise<GetRepliesAPIResponse>} A response with a list of messages
570
+ * @param options - Pagination params, e.g. `{ limit: 10, id_lte: 10 }`.
571
+ * @param sort - Defines sorting direction of pinned messages (optional, defaults to `[]`).
572
+ * @returns A response with a list of messages.
559
573
  */
560
- getPinnedMessages(options: PinnedMessagePaginationOptions & {
561
- user?: UserResponse;
562
- user_id?: string;
563
- }, sort?: PinnedMessagesSort): Promise<GetRepliesAPIResponse>;
574
+ getPinnedMessages(options: PinnedMessagePaginationOptions, sort?: PinnedMessagesSort): Promise<GetRepliesAPIResponse>;
564
575
  /**
565
- * getReactions - List the reactions, supports pagination
576
+ * List the reactions; supports pagination.
566
577
  *
567
- * @param {string} message_id The message id
568
- * @param {{ limit?: number; offset?: number }} options The pagination options
569
- *
570
- * @return {Promise<GetReactionsAPIResponse>} Server response
578
+ * @param request - The request payload, including the target message ID and
579
+ * pagination options (`limit`, `offset`).
580
+ * @returns The server response.
571
581
  */
572
- getReactions(message_id: string, options: {
573
- limit?: number;
574
- offset?: number;
575
- }): Promise<GetReactionsAPIResponse>;
582
+ getReactions(request: Parameters<ChatApi['getReactions']>[0]): Promise<import("./types").StreamResponse<import(".").GetReactionsResponse>>;
576
583
  /**
577
- * getMessagesById - Retrieves a list of messages by ID
578
- *
579
- * @param {string[]} messageIds The ids of the messages to retrieve from this channel
584
+ * Retrieves a list of messages by ID.
580
585
  *
581
- * @return {Promise<GetMultipleMessagesAPIResponse>} Server response
586
+ * @param messageIds - The IDs of the messages to retrieve from this channel.
587
+ * @returns Server response.
582
588
  */
583
- getMessagesById(messageIds: string[]): Promise<GetMultipleMessagesAPIResponse>;
589
+ getMessagesById(messageIds: string[]): Promise<import("./types").StreamResponse<import(".").GetManyMessagesResponse>>;
584
590
  /**
585
- * lastRead - returns the last time the user marked the channel as read if the user never marked the channel as read, this will return null
586
- * @return {Date | null | undefined}
591
+ * Returns the last time the user marked the channel as read. If the user never marked the channel as read, this will return `null`.
592
+ *
593
+ * @returns The last-read `Date`, `null` if never read, or `undefined` if the user is unset.
587
594
  */
588
595
  lastRead(): Date | null | undefined;
589
596
  _countMessageAsUnread(message: LocalMessage | MessageResponse): boolean;
590
597
  /**
591
- * countUnread - Count of unread messages
592
- *
593
- * @param {Date | null} [lastRead] lastRead the time that the user read a message, defaults to current user's read state
598
+ * Count of unread messages.
594
599
  *
595
- * @return {number} Unread count
600
+ * @param lastRead - The time that the user read a message (optional, defaults to the current user's read state).
601
+ * @returns Unread count.
596
602
  */
597
603
  countUnread(lastRead?: Date | null): number;
598
604
  /**
599
- * countUnreadMentions - Count the number of unread messages mentioning the current user
605
+ * Count the number of unread messages mentioning the current user.
600
606
  *
601
- * @return {number} Unread mentions count
607
+ * @returns Unread mentions count.
602
608
  */
603
609
  countUnreadMentions(): number;
604
610
  /**
605
- * create - Creates a new channel
606
- *
607
- * @return {Promise<QueryChannelAPIResponse>} The Server Response
611
+ * Creates a new channel.
608
612
  *
613
+ * @param options - Channel query options (optional).
614
+ * @returns The server response.
609
615
  */
610
- create: (options?: ChannelQueryOptions) => Promise<QueryChannelAPIResponse>;
616
+ create: (options?: ChannelGetOrCreateRequest) => Promise<import("./types").StreamResponse<import(".").ChannelStateResponse>>;
611
617
  /**
612
- * query - Query the API, get messages, members or other channel fields
618
+ * Queries the API to load messages, members, or other channel fields.
613
619
  *
614
- * @param {ChannelQueryOptions} options The query options
615
- * @param {MessageSetType} messageSetToAddToIfDoesNotExist It's possible to load disjunct sets of a channel's messages into state, use `current` to load the initial channel state or if you want to extend the currently displayed messages, use `latest` if you want to load/extend the latest messages, `new` is used for loading a specific message and it's surroundings
616
- *
617
- * @return {Promise<QueryChannelAPIResponse>} Returns a query response
620
+ * @param options - The query options (optional, defaults to `{}`).
621
+ * @param messageSetToAddToIfDoesNotExist - It's possible to load disjunct sets of a channel's
622
+ * messages into state. Use `current` to load the initial channel state or to extend the
623
+ * currently displayed messages; use `latest` to load/extend the latest messages; `new` is
624
+ * used for loading a specific message and its surroundings (optional, defaults to `'current'`).
625
+ * @returns A query response.
618
626
  */
619
- query(options?: ChannelQueryOptions, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<QueryChannelAPIResponse>;
627
+ query(options?: ChannelGetOrCreateRequest, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<import("./types").StreamResponse<import(".").ChannelStateResponse>>;
620
628
  /**
621
- * banUser - Bans a user from a channel
629
+ * Bans a user from a channel.
622
630
  *
623
- * @param {string} targetUserID
624
- * @param {BanUserOptions} options
625
- * @returns {Promise<APIResponse>}
631
+ * @param targetUserId - The user to ban.
632
+ * @param options - Ban options.
633
+ * @returns The server response.
626
634
  */
627
- banUser(targetUserID: string, options: BanUserOptions): Promise<APIResponse>;
635
+ banUser(targetUserId: string, options: BanUserOptions): Promise<APIResponse>;
628
636
  /**
629
- * hides the channel from queryChannels for the user until a message is added
630
- * If clearHistory is set to true - all messages will be removed for the user
637
+ * Hides the channel from `queryChannels` for the user until a message is added.
638
+ * If `clear_history` is set to `true`, all messages will be removed for the user.
631
639
  *
632
- * @param {string | null} userId
633
- * @param {boolean} clearHistory
634
- * @returns {Promise<APIResponse>}
640
+ * @param request - The hide channel request payload (optional). Pass `{ clear_history: true }`
641
+ * to clear message history for the user.
642
+ * @returns The server response.
635
643
  */
636
- hide(userId?: string | null, clearHistory?: boolean): Promise<APIResponse>;
644
+ hide(request?: Gen_HideChannelRequest): Promise<import("./types").StreamResponse<import(".").HideChannelResponse>>;
637
645
  /**
638
- * removes the hidden status for a channel
646
+ * Removes the hidden status for a channel. Ensures the channel is initialized first.
639
647
  *
640
- * @param {string | null} userId
641
- * @returns {Promise<APIResponse>}
648
+ * @param request - The show channel request payload (optional).
649
+ * @returns The server response.
642
650
  */
643
- show(userId?: string | null): Promise<APIResponse>;
651
+ show(request?: Gen_ShowChannelRequest): Promise<import("./types").StreamResponse<import(".").ShowChannelResponse>>;
644
652
  /**
645
- * unbanUser - Removes the bans for a user on a channel
653
+ * Removes the bans for a user on a channel.
646
654
  *
647
- * @param {string} targetUserID
648
- * @param {UnBanUserOptions} options
649
- * @returns {Promise<APIResponse>}
655
+ * @param targetUserId - The user to unban.
656
+ * @param options - Unban options (optional).
657
+ * @returns The server response.
650
658
  */
651
- unbanUser(targetUserID: string, options?: UnBanUserOptions): Promise<APIResponse>;
659
+ unbanUser(targetUserId: string, options?: UnBanUserOptions): Promise<APIResponse>;
652
660
  /**
653
- * shadowBan - Shadow bans a user from a channel
661
+ * Shadow bans a user from a channel.
654
662
  *
655
- * @param {string} targetUserID
656
- * @param {BanUserOptions} options
657
- * @returns {Promise<APIResponse>}
663
+ * @param targetUserId - The user to shadow ban.
664
+ * @param options - Ban options.
665
+ * @returns The server response.
658
666
  */
659
- shadowBan(targetUserID: string, options: BanUserOptions): Promise<APIResponse>;
667
+ shadowBan(targetUserId: string, options: BanUserOptions): Promise<APIResponse>;
660
668
  /**
661
- * removeShadowBan - Removes the shadow ban for a user on a channel
669
+ * Removes the shadow ban for a user on a channel.
662
670
  *
663
- * @param {string} targetUserID
664
- * @returns {Promise<APIResponse>}
665
- */
666
- removeShadowBan(targetUserID: string): Promise<APIResponse>;
667
- /**
668
- * Cast or cancel one or more votes on a poll
669
- * @param pollId string The poll id
670
- * @param votes PollVoteData[] The votes that will be casted (or canceled in case of an empty array)
671
- * @returns {APIResponse & PollVoteResponse} The poll votes
671
+ * @param targetUserId - The user to remove the shadow ban for.
672
+ * @returns The server response.
672
673
  */
673
- vote(messageId: string, pollId: string, vote: PollVoteData): Promise<APIResponse & import("./types").CastVoteAPIResponse>;
674
- removeVote(messageId: string, pollId: string, voteId: string): Promise<APIResponse & {
675
- vote: import("./types").PollVote;
676
- }>;
674
+ removeShadowBan(targetUserId: string): Promise<APIResponse>;
677
675
  /**
678
- * createDraft - Creates or updates a draft message in a channel
679
- *
680
- * @param {DraftMessagePayload} message The draft message to create or update
676
+ * Casts or cancels one or more votes on a poll.
681
677
  *
682
- * @return {Promise<CreateDraftResponse>} Response containing the created draft
678
+ * @param request - The cast-poll-vote request payload, including the target message ID, poll ID,
679
+ * and the vote to cast (or an empty payload to cancel).
680
+ * @returns The poll vote response.
683
681
  */
684
- _createDraft(message: DraftMessagePayload): Promise<CreateDraftResponse>;
682
+ vote(request: Parameters<ChatApi['castPollVote']>[0]): Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
683
+ removeVote(request: Parameters<ChatApi['deletePollVote']>[0]): Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
684
+ _createDraft(request: Gen_CreateDraftRequest): Promise<import("./types").StreamResponse<CreateDraftResponse>>;
685
685
  /**
686
- * createDraft - Creates or updates a draft message in a channel. If offline support is
687
- * enabled, it will make sure that creating the draft is queued up if it fails due to
688
- * bad internet conditions and executed later.
689
- *
690
- * @param {DraftMessagePayload} message The draft message to create or update
691
- *
692
- * @return {Promise<CreateDraftResponse>} Response containing the created draft
686
+ * Creates or updates a draft message in a channel. If offline support is enabled, the
687
+ * call is queued so it is replayed on reconnect.
693
688
  */
694
- createDraft(message: DraftMessagePayload): Promise<CreateDraftResponse>;
689
+ createDraft(request: Gen_CreateDraftRequest): Promise<import("./types").StreamResponse<CreateDraftResponse>>;
690
+ _deleteDraft(request?: Parameters<ChannelApi['deleteDraft']>[0]): Promise<import("./types").StreamResponse<import(".").Response>>;
695
691
  /**
696
- * deleteDraft - Deletes a draft message from a channel or a thread.
697
- *
698
- * @param {Object} options
699
- * @param {string} options.parent_id Optional parent message ID for drafts in threads
700
- *
701
- * @return {Promise<APIResponse>} API response
692
+ * Deletes a draft message from a channel or a thread. If offline support is enabled, the
693
+ * call is queued so it is replayed on reconnect.
702
694
  */
703
- _deleteDraft({ parent_id }?: {
704
- parent_id?: string;
705
- }): Promise<APIResponse>;
695
+ deleteDraft(request?: Parameters<ChannelApi['deleteDraft']>[0]): Promise<import("./types").StreamResponse<import(".").Response>>;
706
696
  /**
707
- * deleteDraft - Deletes a draft message from a channel or a thread. If offline support is
708
- * enabled, it will make sure that deleting the draft is queued up if it fails due to
709
- * bad internet conditions and executed later.
697
+ * Listens to events on this channel.
710
698
  *
711
- * @param {Object} options
712
- * @param {string} options.parent_id Optional parent message ID for drafts in threads
699
+ * @example
700
+ * channel.on('message.new', (event) => {
701
+ * console.log('my new message', event, channel.state.messages);
702
+ * });
713
703
  *
714
- * @return {Promise<APIResponse>} API response
715
- */
716
- deleteDraft(options?: {
717
- parent_id?: string;
718
- }): Promise<APIResponse>;
719
- /**
720
- * getDraft - Retrieves a draft message from a channel
704
+ * @example
705
+ * channel.on((event) => {
706
+ * console.log(event.type);
707
+ * });
721
708
  *
722
- * @param {Object} options
723
- * @param {string} options.parent_id Optional parent message ID for drafts in threads
724
- *
725
- * @return {Promise<GetDraftResponse>} Response containing the draft
709
+ * @param callbackOrString - The event type to listen for, or the callback when listening to all events.
710
+ * @param callbackOrNothing - The callback to call when an event type was provided (optional).
711
+ * @returns An object with an `unsubscribe()` method.
726
712
  */
727
- getDraft({ parent_id }?: {
728
- parent_id?: string;
729
- }): Promise<GetDraftResponse>;
730
- /**
731
- * on - Listen to events on this channel.
732
- *
733
- * channel.on('message.new', event => {console.log("my new message", event, channel.state.messages)})
734
- * or
735
- * channel.on(event => {console.log(event.type)})
736
- *
737
- * @param {EventHandler | EventTypes} callbackOrString The event type to listen for (optional)
738
- * @param {EventHandler} [callbackOrNothing] The callback to call
739
- */
740
- on(eventType: EventTypes, callback: EventHandler): {
713
+ on<T extends EventType | string>(eventType: T, callback: EventHandler<T>): {
741
714
  unsubscribe: () => void;
742
715
  };
743
716
  on(callback: EventHandler): {
744
717
  unsubscribe: () => void;
745
718
  };
746
719
  /**
747
- * off - Remove the event handler
720
+ * Removes the event handler.
748
721
  *
722
+ * @param callbackOrString - The event type, or the callback when removing an all-events listener.
723
+ * @param callbackOrNothing - The callback to remove when an event type was provided (optional).
749
724
  */
750
- off(eventType: EventTypes, callback: EventHandler): void;
725
+ off<T extends EventType | string>(eventType: T, callback: EventHandler): void;
751
726
  off(callback: EventHandler): void;
727
+ private _patchReadState;
728
+ private _upsertReadState;
752
729
  _handleChannelEvent(event: Event): void;
753
- _callChannelListeners: (event: Event) => void;
730
+ _callChannelListeners: (event: WSEvent) => void;
754
731
  /**
755
- * _channelURL - Returns the channel url
732
+ * Returns the channel url.
756
733
  *
757
- * @return {string} The channel url
734
+ * @returns The channel url.
758
735
  */
759
736
  _channelURL: () => string;
760
737
  _checkInitialized(): void;
761
- _initializeState(state: ChannelAPIResponse, messageSetToAddToIfDoesNotExist?: MessageSetType): {
762
- messageSet: import("./types").MessageSet;
763
- filteredMessageIds: string[];
764
- };
765
- _extendEventWithOwnReactions(event: Event): void;
738
+ _syncStateFromChannelData(data: Channel['data'], fallbackData?: Channel['data']): void;
739
+ _initializeState(state: ChannelStateResponseFields): void;
740
+ _extendEventWithOwnReactions(event: EventPayload<'message.undeleted' | 'message.updated' | 'message.deleted'>): void;
766
741
  _hydrateMembers({ members, overrideCurrentState, }: {
767
742
  members: ChannelMemberResponse[];
768
743
  /**