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.
- package/dist/cjs/index.browser.js +19798 -14472
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +19817 -14482
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +19795 -14469
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +221 -0
- package/dist/types/EventHandlerPipeline.d.ts +104 -0
- package/dist/types/api-client.d.ts +26 -0
- package/dist/types/campaign.d.ts +0 -44
- package/dist/types/channel.d.ts +454 -479
- package/dist/types/channel_batch_updater.d.ts +0 -93
- package/dist/types/channel_state.d.ts +53 -201
- package/dist/types/client.d.ts +451 -1920
- package/dist/types/client_state.d.ts +4 -4
- package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
- package/dist/types/configuration/index.d.ts +1 -0
- package/dist/types/configuration/types.d.ts +53 -0
- package/dist/types/connection.d.ts +49 -41
- package/dist/types/connection_fallback.d.ts +6 -4
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/custom_types.d.ts +2 -0
- package/dist/types/entityStore/EntityStore.d.ts +111 -0
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +60 -0
- package/dist/types/entityStore/applyReactionLocally.d.ts +26 -0
- package/dist/types/entityStore/index.d.ts +2 -0
- package/dist/types/errors.d.ts +10 -2
- package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
- package/dist/types/gen/chat/ChatApi.d.ts +334 -0
- package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
- package/dist/types/gen/models/index.d.ts +8836 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
- package/dist/types/gen-imports.d.ts +3 -0
- package/dist/types/index.d.ts +8 -7
- package/dist/types/insights.d.ts +9 -8
- package/dist/types/logger.d.ts +9 -0
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
- package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
- package/dist/types/messageComposer/configuration/types.d.ts +11 -11
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
- package/dist/types/messageComposer/messageComposer.d.ts +10 -10
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
- package/dist/types/messageComposer/pollComposer.d.ts +5 -4
- package/dist/types/messageComposer/textComposer.d.ts +8 -3
- package/dist/types/messageComposer/types.d.ts +6 -28
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
- package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
- package/dist/types/messageOperations/index.d.ts +3 -0
- package/dist/types/messageOperations/types.d.ts +49 -0
- package/dist/types/moderation.d.ts +21 -203
- package/dist/types/notifications/types.d.ts +8 -7
- package/dist/types/offline-support/offline_support_api.d.ts +111 -87
- package/dist/types/offline-support/offline_sync_manager.d.ts +0 -7
- package/dist/types/offline-support/types.d.ts +19 -23
- package/dist/types/offline-support/util.d.ts +4 -2
- package/dist/types/pagination/FilterBuilder.d.ts +1 -1
- package/dist/types/pagination/ItemIndex.d.ts +25 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
- package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/filterCompiler.d.ts +7 -0
- package/dist/types/pagination/index.d.ts +1 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +848 -0
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +212 -0
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +282 -0
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
- package/dist/types/pagination/paginators/index.d.ts +7 -0
- package/dist/types/pagination/paginators/stateThrottling.d.ts +2 -0
- package/dist/types/pagination/sortCompiler.d.ts +49 -0
- package/dist/types/pagination/types.normalization.d.ts +11 -0
- package/dist/types/pagination/utility.normalization.d.ts +18 -0
- package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
- package/dist/types/pagination/utility.search.d.ts +13 -0
- package/dist/types/permissions.d.ts +1 -1
- package/dist/types/poll.d.ts +29 -32
- package/dist/types/poll_manager.d.ts +2 -2
- package/dist/types/reminders/Reminder.d.ts +2 -5
- package/dist/types/reminders/ReminderManager.d.ts +2 -9
- package/dist/types/search/MessageSearchSource.d.ts +4 -4
- package/dist/types/search/UserSearchSource.d.ts +1 -1
- package/dist/types/search/types.d.ts +3 -3
- package/dist/types/segment.d.ts +0 -34
- package/dist/types/signing.d.ts +105 -65
- package/dist/types/store.d.ts +1 -0
- package/dist/types/thread.d.ts +70 -34
- package/dist/types/thread_manager.d.ts +3 -3
- package/dist/types/token_manager.d.ts +15 -10
- package/dist/types/types.d.ts +197 -3404
- package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
- package/dist/types/utils/WithSubscriptions.d.ts +2 -1
- package/dist/types/utils/concurrency.d.ts +4 -4
- package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
- package/dist/types/utils/retryable.d.ts +34 -0
- package/dist/types/utils/throttling/throttle.d.ts +36 -0
- package/dist/types/utils.d.ts +100 -194
- package/package.json +7 -3
- package/src/ChannelManager.ts +724 -0
- package/src/CooldownTimer.ts +2 -2
- package/src/EventHandlerPipeline.ts +228 -0
- package/src/LiveLocationManager.ts +12 -11
- package/src/api-client.ts +275 -0
- package/src/campaign.ts +1 -77
- package/src/channel.ts +1344 -1282
- package/src/channel_batch_updater.ts +1 -211
- package/src/channel_state.ts +144 -1013
- package/src/client.ts +936 -3995
- package/src/client_state.ts +4 -4
- package/src/configuration/InstanceConfigurationService.ts +73 -0
- package/src/configuration/index.ts +1 -0
- package/src/configuration/types.ts +81 -0
- package/src/connection.ts +145 -94
- package/src/connection_fallback.ts +29 -27
- package/src/constants.ts +1 -5
- package/src/custom_types.ts +4 -1
- package/src/entityStore/EntityStore.ts +208 -0
- package/src/entityStore/StoreBackedItemIndex.ts +115 -0
- package/src/entityStore/applyReactionLocally.ts +113 -0
- package/src/entityStore/index.ts +2 -0
- package/src/errors.ts +14 -2
- package/src/gen/chat/ChannelApi.ts +275 -0
- package/src/gen/chat/ChatApi.ts +2554 -0
- package/src/gen/model-decoders/decoders.ts +2680 -0
- package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
- package/src/gen/models/index.ts +12673 -0
- package/src/gen/moderation/ModerationApi.ts +607 -0
- package/src/gen-imports.ts +3 -0
- package/src/index.ts +11 -12
- package/src/insights.ts +6 -5
- package/src/logger.ts +28 -0
- package/src/messageComposer/LocationComposer.ts +9 -5
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
- package/src/messageComposer/attachmentIdentity.ts +16 -9
- package/src/messageComposer/attachmentManager.ts +13 -8
- package/src/messageComposer/configuration/types.ts +11 -11
- package/src/messageComposer/linkPreviewsManager.ts +9 -10
- package/src/messageComposer/messageComposer.ts +57 -53
- package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
- package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
- package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
- package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
- package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
- package/src/messageComposer/middleware/textComposer/types.ts +9 -4
- package/src/messageComposer/pollComposer.ts +6 -8
- package/src/messageComposer/textComposer.ts +27 -2
- package/src/messageComposer/types.ts +6 -28
- package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
- package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
- package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
- package/src/messageOperations/MessageOperations.ts +212 -0
- package/src/messageOperations/index.ts +10 -0
- package/src/messageOperations/types.ts +64 -0
- package/src/moderation.ts +38 -431
- package/src/notifications/types.ts +8 -7
- package/src/offline-support/offline_support_api.ts +200 -133
- package/src/offline-support/offline_sync_manager.ts +23 -44
- package/src/offline-support/types.ts +23 -26
- package/src/offline-support/util.ts +5 -4
- package/src/pagination/FilterBuilder.ts +4 -1
- package/src/pagination/ItemIndex.ts +25 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
- package/src/pagination/cursorDerivation/index.ts +1 -0
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
- package/src/pagination/filterCompiler.ts +196 -0
- package/src/pagination/index.ts +1 -3
- package/src/pagination/paginators/BasePaginator.ts +2859 -0
- package/src/pagination/paginators/ChannelPaginator.ts +729 -0
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1116 -0
- package/src/pagination/paginators/MessagePaginator.ts +508 -0
- package/src/pagination/paginators/PinnedMessagePaginator.ts +108 -0
- package/src/pagination/paginators/ReminderPaginator.ts +107 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +127 -0
- package/src/pagination/paginators/index.ts +7 -0
- package/src/pagination/paginators/stateThrottling.ts +31 -0
- package/src/pagination/sortCompiler.ts +193 -0
- package/src/pagination/types.normalization.ts +14 -0
- package/src/pagination/utility.normalization.ts +106 -0
- package/src/pagination/utility.queryChannel.ts +84 -0
- package/src/pagination/utility.search.ts +80 -0
- package/src/permissions.ts +7 -8
- package/src/poll.ts +101 -110
- package/src/poll_manager.ts +14 -8
- package/src/reminders/Reminder.ts +2 -5
- package/src/reminders/ReminderManager.ts +19 -21
- package/src/search/BaseSearchSource.ts +0 -3
- package/src/search/ChannelMemberSearchSource.ts +7 -1
- package/src/search/ChannelSearchSource.ts +10 -3
- package/src/search/MessageSearchSource.ts +29 -30
- package/src/search/UserSearchSource.ts +12 -8
- package/src/search/types.ts +3 -4
- package/src/segment.ts +1 -95
- package/src/signing.ts +107 -67
- package/src/store.ts +2 -1
- package/src/thread.ts +562 -238
- package/src/thread_manager.ts +37 -16
- package/src/token_manager.ts +21 -10
- package/src/types.ts +364 -4533
- package/src/uploadManager.ts +8 -0
- package/src/utils/FixedSizeQueueCache.ts +12 -6
- package/src/utils/WithSubscriptions.ts +2 -1
- package/src/utils/concurrency.ts +4 -4
- package/src/utils/mergeWith/mergeWith.ts +3 -3
- package/src/utils/mergeWith/mergeWithCore.ts +140 -164
- package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
- package/src/utils/retryable.ts +117 -0
- package/src/utils/throttling/throttle.ts +130 -0
- package/src/utils.ts +208 -754
- package/dist/types/channel_manager.d.ts +0 -122
- package/dist/types/events.d.ts +0 -72
- package/dist/types/pagination/BasePaginator.d.ts +0 -69
- package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
- package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
- package/src/channel_manager.ts +0 -830
- package/src/events.ts +0 -75
- package/src/pagination/BasePaginator.ts +0 -184
- package/src/pagination/ReminderPaginator.ts +0 -56
- package/src/pagination/UserGroupPaginator.ts +0 -93
package/dist/types/channel.d.ts
CHANGED
|
@@ -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,
|
|
8
|
-
import type {
|
|
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
|
-
*
|
|
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
|
-
|
|
15
|
-
|
|
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
|
|
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
|
|
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?:
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
115
|
+
* Returns the chat client for this channel. Throws if `client.disconnect()` was called.
|
|
60
116
|
*
|
|
61
|
-
* @
|
|
117
|
+
* @returns The chat client.
|
|
62
118
|
*/
|
|
63
119
|
getClient(): StreamChat;
|
|
64
120
|
/**
|
|
65
|
-
*
|
|
121
|
+
* Returns the config for this channel ID (CID).
|
|
66
122
|
*
|
|
67
|
-
* @
|
|
123
|
+
* @returns The channel config.
|
|
68
124
|
*/
|
|
69
|
-
getConfig(): import("
|
|
125
|
+
getConfig(): import(".").ChannelConfigWithInfo | undefined;
|
|
126
|
+
_sendMessage(request: Gen_SendMessageRequest): Promise<import("./types").StreamResponse<import(".").SendMessageResponse>>;
|
|
70
127
|
/**
|
|
71
|
-
*
|
|
128
|
+
* Sends a message to this channel.
|
|
72
129
|
*
|
|
73
|
-
* @param
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
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
|
-
|
|
84
|
-
sendMessage(message: Message, options?: SendMessageOptions): Promise<SendMessageAPIResponse>;
|
|
134
|
+
sendMessage(request: Gen_SendMessageRequest): Promise<import("./types").StreamResponse<import(".").SendMessageResponse>>;
|
|
85
135
|
/**
|
|
86
|
-
*
|
|
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
|
-
|
|
138
|
+
sendMessageWithLocalUpdate(params: SendMessageWithStateUpdateParams): Promise<void>;
|
|
96
139
|
/**
|
|
97
|
-
*
|
|
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
|
-
|
|
107
|
-
deleteFile(url: string): Promise<APIResponse>;
|
|
108
|
-
deleteImage(url: string): Promise<APIResponse>;
|
|
142
|
+
retrySendMessageWithLocalUpdate(params: Omit<SendMessageWithStateUpdateParams, 'message'>): Promise<void>;
|
|
109
143
|
/**
|
|
110
|
-
*
|
|
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
|
-
|
|
146
|
+
updateMessageWithLocalUpdate(params: UpdateMessageWithStateUpdateParams): Promise<void>;
|
|
117
147
|
/**
|
|
118
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @
|
|
136
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
166
|
+
deleteReactionWithLocalUpdate({ messageId, type, }: {
|
|
167
|
+
messageId: string;
|
|
168
|
+
type: string;
|
|
169
|
+
}): Promise<void>;
|
|
154
170
|
/**
|
|
155
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
180
|
+
sendFile(uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse, axiosRequestConfig?: AxiosRequestConfig): Promise<import("./types").SendFileAPIResponse>;
|
|
164
181
|
/**
|
|
165
|
-
*
|
|
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
|
|
170
|
-
* @param
|
|
171
|
-
* @param
|
|
172
|
-
*
|
|
173
|
-
* @
|
|
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
|
-
|
|
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
|
-
*
|
|
195
|
+
* Sends an event on this channel.
|
|
178
196
|
*
|
|
179
|
-
* @param {
|
|
180
|
-
* @
|
|
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
|
-
|
|
186
|
-
|
|
200
|
+
sendEvent(request: {
|
|
201
|
+
event: Event;
|
|
202
|
+
}): Promise<import("./types").StreamResponse<import(".").EventResponse>>;
|
|
187
203
|
/**
|
|
188
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
210
|
+
search(request?: {
|
|
211
|
+
payload?: SearchPayload;
|
|
212
|
+
}): Promise<import("./types").StreamResponse<import(".").SearchResponse>>;
|
|
197
213
|
/**
|
|
198
|
-
*
|
|
214
|
+
* Queries members.
|
|
199
215
|
*
|
|
200
|
-
* @param
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @
|
|
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
|
-
|
|
221
|
+
queryMembers(request?: {
|
|
222
|
+
payload?: Partial<QueryMembersPayload>;
|
|
223
|
+
}): Promise<import("./types").StreamResponse<import(".").MembersResponse>>;
|
|
206
224
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
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
|
-
*
|
|
238
|
+
* Deletes a reaction by user and type.
|
|
216
239
|
*
|
|
217
|
-
* @param
|
|
218
|
-
* @
|
|
240
|
+
* @param request - The delete reaction request payload identifying the target message and reaction type.
|
|
241
|
+
* @returns The server response.
|
|
219
242
|
*/
|
|
220
|
-
|
|
243
|
+
_deleteReaction(request: Parameters<ChatApi['deleteReaction']>[0]): Promise<import("./types").StreamResponse<import(".").DeleteReactionResponse>>;
|
|
221
244
|
/**
|
|
222
|
-
*
|
|
245
|
+
* Edit the channel using the inherited `update()` from `ChannelApi`. Caches the
|
|
246
|
+
* server-returned channel onto `this.data`.
|
|
223
247
|
*
|
|
224
|
-
* @
|
|
248
|
+
* @param request - Channel update payload, e.g. `{ data: { name: 'foo' }, message }` (optional).
|
|
249
|
+
* @returns The server response.
|
|
225
250
|
*/
|
|
226
|
-
|
|
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
|
-
*
|
|
253
|
+
* Partial update of channel properties.
|
|
231
254
|
*
|
|
232
|
-
* @param
|
|
233
|
-
*
|
|
234
|
-
* @return {Promise<DeleteChannelAPIResponse>} The server response
|
|
255
|
+
* @param update - The partial update request.
|
|
256
|
+
* @returns The server response.
|
|
235
257
|
*/
|
|
236
|
-
|
|
237
|
-
hard_delete?: boolean;
|
|
238
|
-
}): Promise<DeleteChannelAPIResponse>;
|
|
258
|
+
updatePartial(update: UpdateChannelPartialRequest): Promise<import("./types").StreamResponse<import(".").UpdateChannelPartialResponse>>;
|
|
239
259
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* @
|
|
260
|
+
* Enables slow mode.
|
|
261
|
+
*
|
|
262
|
+
* @param coolDownInterval - The cooldown interval in seconds.
|
|
263
|
+
* @returns The server response.
|
|
243
264
|
*/
|
|
244
|
-
|
|
265
|
+
enableSlowMode(coolDownInterval: number): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
245
266
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* @param {UpdateChannelOptions} [options] The object to update the custom properties of this channel with
|
|
267
|
+
* Disables slow mode.
|
|
249
268
|
*
|
|
250
|
-
* @
|
|
269
|
+
* @returns The server response.
|
|
251
270
|
*/
|
|
252
|
-
|
|
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
|
-
*
|
|
277
|
+
* Accepts an invitation to the channel.
|
|
255
278
|
*
|
|
256
|
-
* @param
|
|
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
|
-
* @
|
|
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?:
|
|
289
|
+
rejectInvite(options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
261
290
|
/**
|
|
262
|
-
*
|
|
291
|
+
* Adds members to the channel.
|
|
263
292
|
*
|
|
264
|
-
* @param
|
|
265
|
-
* @param
|
|
266
|
-
* @param
|
|
267
|
-
* @
|
|
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<
|
|
298
|
+
addMembers(members: string[] | Array<Gen_ChannelMemberRequest>, message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
270
299
|
/**
|
|
271
|
-
*
|
|
300
|
+
* Adds filter tags to the channel.
|
|
272
301
|
*
|
|
273
|
-
* @param
|
|
274
|
-
* @param
|
|
275
|
-
* @param
|
|
276
|
-
* @
|
|
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?:
|
|
307
|
+
addFilterTags(tags: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
279
308
|
/**
|
|
280
|
-
*
|
|
309
|
+
* Removes filter tags from the channel.
|
|
281
310
|
*
|
|
282
|
-
* @param
|
|
283
|
-
* @param
|
|
284
|
-
* @param
|
|
285
|
-
* @
|
|
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?:
|
|
316
|
+
removeFilterTags(tags: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
288
317
|
/**
|
|
289
|
-
*
|
|
318
|
+
* Adds moderators to the channel.
|
|
290
319
|
*
|
|
291
|
-
* @param
|
|
292
|
-
* @param
|
|
293
|
-
* @param
|
|
294
|
-
* @
|
|
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?:
|
|
325
|
+
addModerators(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
297
326
|
/**
|
|
298
|
-
*
|
|
327
|
+
* Sets member roles in a channel.
|
|
299
328
|
*
|
|
300
|
-
* @param
|
|
301
|
-
* @param
|
|
302
|
-
* @param
|
|
303
|
-
* @
|
|
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:
|
|
335
|
+
channel_role: RoleName;
|
|
307
336
|
user_id: string;
|
|
308
|
-
}[], message?:
|
|
337
|
+
}[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
309
338
|
/**
|
|
310
|
-
*
|
|
339
|
+
* Invite members to the channel.
|
|
311
340
|
*
|
|
312
|
-
* @param
|
|
313
|
-
* @param
|
|
314
|
-
* @param
|
|
315
|
-
* @
|
|
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<
|
|
346
|
+
inviteMembers(members: string[] | Required<Omit<Gen_ChannelMemberRequest, 'channel_role'>>[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
318
347
|
/**
|
|
319
|
-
*
|
|
348
|
+
* Removes members from the channel.
|
|
320
349
|
*
|
|
321
|
-
* @param
|
|
322
|
-
* @param
|
|
323
|
-
* @param
|
|
324
|
-
* @
|
|
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?:
|
|
355
|
+
removeMembers(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
327
356
|
/**
|
|
328
|
-
*
|
|
357
|
+
* Removes the moderator role from channel members.
|
|
329
358
|
*
|
|
330
|
-
* @param
|
|
331
|
-
* @param
|
|
332
|
-
* @param
|
|
333
|
-
* @
|
|
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?:
|
|
364
|
+
demoteModerators(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions): Promise<import("./types").StreamResponse<import(".").UpdateChannelResponse>>;
|
|
336
365
|
/**
|
|
337
|
-
*
|
|
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
|
|
349
|
-
*
|
|
368
|
+
* @example
|
|
369
|
+
* // with expiration
|
|
370
|
+
* await channel.mute({ expiration: moment.duration(2, 'weeks') });
|
|
350
371
|
*
|
|
351
|
-
* example
|
|
352
|
-
*
|
|
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(
|
|
356
|
-
expiration?: number;
|
|
357
|
-
user_id?: string;
|
|
358
|
-
}): Promise<MuteChannelAPIResponse>;
|
|
380
|
+
mute(options?: Gen_MuteChannelRequest): Promise<import("./types").StreamResponse<import(".").MuteChannelResponse>>;
|
|
359
381
|
/**
|
|
360
|
-
*
|
|
361
|
-
* @param {{ user_id?: string}} opts user_id
|
|
362
|
-
* @return {Promise<APIResponse>} The server response
|
|
382
|
+
* Unmutes the current channel.
|
|
363
383
|
*
|
|
364
|
-
* example
|
|
365
|
-
*
|
|
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(
|
|
368
|
-
user_id?: string;
|
|
369
|
-
}): Promise<APIResponse>;
|
|
392
|
+
unmute(options?: Gen_UnmuteChannelRequest): Promise<import("./types").StreamResponse<import(".").UnmuteResponse>>;
|
|
370
393
|
/**
|
|
371
|
-
*
|
|
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
|
|
379
|
-
* await channel.archive(
|
|
396
|
+
* @example
|
|
397
|
+
* await channel.archive();
|
|
380
398
|
*
|
|
399
|
+
* @returns The server response.
|
|
381
400
|
*/
|
|
382
|
-
archive(
|
|
383
|
-
user_id?: string;
|
|
384
|
-
}): Promise<ChannelMemberResponse>;
|
|
401
|
+
archive(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
385
402
|
/**
|
|
386
|
-
*
|
|
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
|
-
*
|
|
394
|
-
* await channel.unarchive({user_id: userId});
|
|
395
|
-
*
|
|
408
|
+
* @returns The server response.
|
|
396
409
|
*/
|
|
397
|
-
unarchive(
|
|
398
|
-
user_id?: string;
|
|
399
|
-
}): Promise<ChannelMemberResponse>;
|
|
410
|
+
unarchive(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
400
411
|
/**
|
|
401
|
-
*
|
|
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
|
-
*
|
|
409
|
-
* await channel.pin({user_id: userId});
|
|
410
|
-
*
|
|
417
|
+
* @returns The server response.
|
|
411
418
|
*/
|
|
412
|
-
pin(
|
|
413
|
-
user_id?: string;
|
|
414
|
-
}): Promise<ChannelMemberResponse>;
|
|
419
|
+
pin(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
415
420
|
/**
|
|
416
|
-
*
|
|
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
|
-
*
|
|
424
|
-
* await channel.unpin({user_id: userId});
|
|
425
|
-
*
|
|
426
|
+
* @returns The server response.
|
|
426
427
|
*/
|
|
427
|
-
unpin(
|
|
428
|
-
user_id?: string;
|
|
429
|
-
}): Promise<ChannelMemberResponse>;
|
|
428
|
+
unpin(): Promise<import("./types").StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
430
429
|
/**
|
|
431
|
-
*
|
|
432
|
-
*
|
|
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
|
-
|
|
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(
|
|
443
|
+
sendAction(messageId: string, formData: Record<string, string>): Promise<import("./types").StreamResponse<import(".").MessageActionResponse>>;
|
|
440
444
|
/**
|
|
441
|
-
*
|
|
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
|
-
*
|
|
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(
|
|
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
|
|
455
|
-
* @param options -
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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(
|
|
486
|
+
stopTyping(parentId?: string, options?: {
|
|
476
487
|
user_id: string;
|
|
477
488
|
}): Promise<void>;
|
|
478
489
|
_isTypingIndicatorsEnabled(): boolean;
|
|
479
490
|
/**
|
|
480
|
-
*
|
|
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
|
-
*
|
|
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 {
|
|
489
|
-
* @return {Promise<EventAPIResponse | null>} Description
|
|
497
|
+
* @param data - Mark read options (optional, defaults to `{}`).
|
|
490
498
|
*/
|
|
491
|
-
|
|
499
|
+
markReadViaReporter(data?: MarkReadRequest): Promise<EventAPIResponse | import("./types").StreamResponse<import(".").MarkReadResponse> | null>;
|
|
492
500
|
/**
|
|
493
|
-
*
|
|
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 {
|
|
496
|
-
* @
|
|
504
|
+
* @param data - Mark read options (optional, defaults to `{}`).
|
|
505
|
+
* @returns The server response, or `null` if the request was skipped.
|
|
497
506
|
*/
|
|
498
|
-
|
|
507
|
+
markRead(data?: MarkReadRequest): Promise<import("./types").StreamResponse<import(".").MarkReadResponse>>;
|
|
499
508
|
/**
|
|
500
|
-
*
|
|
509
|
+
* Marks the channel as unread from `messageId`. Only works when the `read_events` setting is enabled.
|
|
501
510
|
*
|
|
502
|
-
* @param
|
|
503
|
-
* @
|
|
511
|
+
* @param data - Mark unread options.
|
|
512
|
+
* @returns An API response, or `null` if the request was skipped.
|
|
504
513
|
*/
|
|
505
|
-
markUnread(data
|
|
514
|
+
markUnread(data?: MarkUnreadRequest): Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
506
515
|
/**
|
|
507
|
-
*
|
|
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
|
-
* @
|
|
516
|
-
*/
|
|
517
|
-
markReadLocally():
|
|
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
|
-
*
|
|
540
|
+
* Cleans the channel state and fires stop typing if needed.
|
|
520
541
|
*/
|
|
521
542
|
clean(): void;
|
|
522
543
|
/**
|
|
523
|
-
*
|
|
544
|
+
* Loads the initial channel state and watches for changes.
|
|
524
545
|
*
|
|
525
|
-
* @param
|
|
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?:
|
|
549
|
+
watch(options?: ChannelGetOrCreateRequest): Promise<import("./types").StreamResponse<import(".").ChannelStateResponse>>;
|
|
530
550
|
/**
|
|
531
|
-
*
|
|
551
|
+
* Stops watching the channel.
|
|
532
552
|
*
|
|
533
|
-
* @
|
|
553
|
+
* @param request - The stop-watching request payload (optional).
|
|
554
|
+
* @returns The server response.
|
|
534
555
|
*/
|
|
535
|
-
stopWatching(): Promise<
|
|
556
|
+
stopWatching(request?: Gen_ChannelStopWatchingRequest): Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
536
557
|
/**
|
|
537
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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(
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
576
|
+
* List the reactions; supports pagination.
|
|
566
577
|
*
|
|
567
|
-
* @param
|
|
568
|
-
*
|
|
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(
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
586
|
+
* @param messageIds - The IDs of the messages to retrieve from this channel.
|
|
587
|
+
* @returns Server response.
|
|
582
588
|
*/
|
|
583
|
-
getMessagesById(messageIds: string[]): Promise<
|
|
589
|
+
getMessagesById(messageIds: string[]): Promise<import("./types").StreamResponse<import(".").GetManyMessagesResponse>>;
|
|
584
590
|
/**
|
|
585
|
-
*
|
|
586
|
-
*
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
*
|
|
605
|
+
* Count the number of unread messages mentioning the current user.
|
|
600
606
|
*
|
|
601
|
-
* @
|
|
607
|
+
* @returns Unread mentions count.
|
|
602
608
|
*/
|
|
603
609
|
countUnreadMentions(): number;
|
|
604
610
|
/**
|
|
605
|
-
*
|
|
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?:
|
|
616
|
+
create: (options?: ChannelGetOrCreateRequest) => Promise<import("./types").StreamResponse<import(".").ChannelStateResponse>>;
|
|
611
617
|
/**
|
|
612
|
-
*
|
|
618
|
+
* Queries the API to load messages, members, or other channel fields.
|
|
613
619
|
*
|
|
614
|
-
* @param
|
|
615
|
-
* @param
|
|
616
|
-
*
|
|
617
|
-
*
|
|
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?:
|
|
627
|
+
query(options?: ChannelGetOrCreateRequest, messageSetToAddToIfDoesNotExist?: MessageSetType): Promise<import("./types").StreamResponse<import(".").ChannelStateResponse>>;
|
|
620
628
|
/**
|
|
621
|
-
*
|
|
629
|
+
* Bans a user from a channel.
|
|
622
630
|
*
|
|
623
|
-
* @param
|
|
624
|
-
* @param
|
|
625
|
-
* @returns
|
|
631
|
+
* @param targetUserId - The user to ban.
|
|
632
|
+
* @param options - Ban options.
|
|
633
|
+
* @returns The server response.
|
|
626
634
|
*/
|
|
627
|
-
banUser(
|
|
635
|
+
banUser(targetUserId: string, options: BanUserOptions): Promise<APIResponse>;
|
|
628
636
|
/**
|
|
629
|
-
*
|
|
630
|
-
* If
|
|
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 {
|
|
633
|
-
*
|
|
634
|
-
* @returns
|
|
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(
|
|
644
|
+
hide(request?: Gen_HideChannelRequest): Promise<import("./types").StreamResponse<import(".").HideChannelResponse>>;
|
|
637
645
|
/**
|
|
638
|
-
*
|
|
646
|
+
* Removes the hidden status for a channel. Ensures the channel is initialized first.
|
|
639
647
|
*
|
|
640
|
-
* @param
|
|
641
|
-
* @returns
|
|
648
|
+
* @param request - The show channel request payload (optional).
|
|
649
|
+
* @returns The server response.
|
|
642
650
|
*/
|
|
643
|
-
show(
|
|
651
|
+
show(request?: Gen_ShowChannelRequest): Promise<import("./types").StreamResponse<import(".").ShowChannelResponse>>;
|
|
644
652
|
/**
|
|
645
|
-
*
|
|
653
|
+
* Removes the bans for a user on a channel.
|
|
646
654
|
*
|
|
647
|
-
* @param
|
|
648
|
-
* @param
|
|
649
|
-
* @returns
|
|
655
|
+
* @param targetUserId - The user to unban.
|
|
656
|
+
* @param options - Unban options (optional).
|
|
657
|
+
* @returns The server response.
|
|
650
658
|
*/
|
|
651
|
-
unbanUser(
|
|
659
|
+
unbanUser(targetUserId: string, options?: UnBanUserOptions): Promise<APIResponse>;
|
|
652
660
|
/**
|
|
653
|
-
*
|
|
661
|
+
* Shadow bans a user from a channel.
|
|
654
662
|
*
|
|
655
|
-
* @param
|
|
656
|
-
* @param
|
|
657
|
-
* @returns
|
|
663
|
+
* @param targetUserId - The user to shadow ban.
|
|
664
|
+
* @param options - Ban options.
|
|
665
|
+
* @returns The server response.
|
|
658
666
|
*/
|
|
659
|
-
shadowBan(
|
|
667
|
+
shadowBan(targetUserId: string, options: BanUserOptions): Promise<APIResponse>;
|
|
660
668
|
/**
|
|
661
|
-
*
|
|
669
|
+
* Removes the shadow ban for a user on a channel.
|
|
662
670
|
*
|
|
663
|
-
* @param
|
|
664
|
-
* @returns
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
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
|
-
*
|
|
687
|
-
*
|
|
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(
|
|
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
|
-
*
|
|
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
|
-
|
|
704
|
-
parent_id?: string;
|
|
705
|
-
}): Promise<APIResponse>;
|
|
695
|
+
deleteDraft(request?: Parameters<ChannelApi['deleteDraft']>[0]): Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
706
696
|
/**
|
|
707
|
-
*
|
|
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
|
-
* @
|
|
712
|
-
*
|
|
699
|
+
* @example
|
|
700
|
+
* channel.on('message.new', (event) => {
|
|
701
|
+
* console.log('my new message', event, channel.state.messages);
|
|
702
|
+
* });
|
|
713
703
|
*
|
|
714
|
-
* @
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
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
|
|
723
|
-
* @param
|
|
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
|
-
|
|
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
|
-
*
|
|
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:
|
|
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:
|
|
730
|
+
_callChannelListeners: (event: WSEvent) => void;
|
|
754
731
|
/**
|
|
755
|
-
*
|
|
732
|
+
* Returns the channel url.
|
|
756
733
|
*
|
|
757
|
-
* @
|
|
734
|
+
* @returns The channel url.
|
|
758
735
|
*/
|
|
759
736
|
_channelURL: () => string;
|
|
760
737
|
_checkInitialized(): void;
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
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
|
/**
|