stream-chat 10.0.0-rc.2 → 10.0.0-rc.21
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/README.md +11 -8
- package/dist/cjs/index.browser.js +15397 -12090
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +15349 -11991
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +15164 -11880
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +246 -6
- package/dist/types/CooldownTimer.d.ts +22 -8
- package/dist/types/EventHandlerPipeline.d.ts +12 -16
- package/dist/types/LiveLocationManager.d.ts +69 -6
- package/dist/types/api-client.d.ts +22 -9
- package/dist/types/channel.d.ts +550 -300
- package/dist/types/channel_state.d.ts +167 -22
- package/dist/types/client.d.ts +325 -305
- package/dist/types/configuration/ConfigController.d.ts +172 -0
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +192 -0
- package/dist/types/configuration/index.d.ts +3 -0
- package/dist/types/configuration/keys.d.ts +31 -0
- package/dist/types/configuration/shape.d.ts +58 -0
- package/dist/types/configuration/types.d.ts +206 -50
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +59 -0
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +1 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +24 -0
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +22 -0
- package/dist/types/configuration/utils/index.d.ts +1 -0
- package/dist/types/configuration/utils/serverAuthority.d.ts +49 -0
- package/dist/types/connection/ConnectionIdManager.d.ts +67 -0
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +164 -0
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +153 -0
- package/dist/types/connection/networkConnection/index.d.ts +3 -0
- package/dist/types/connection/networkConnection/reporters.d.ts +43 -0
- package/dist/types/connection/networkConnection/types.d.ts +55 -0
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +204 -0
- package/dist/types/connection/wsConnection/WSConnection.d.ts +168 -0
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +55 -0
- package/dist/types/connection/wsConnection/config.d.ts +51 -0
- package/dist/types/connection/wsConnection/index.d.ts +4 -0
- package/dist/types/connection/wsConnection/types.d.ts +99 -0
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/entityStore/EntityStore.d.ts +160 -40
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +48 -29
- package/dist/types/entityStore/index.d.ts +0 -1
- package/dist/types/errors.d.ts +24 -4
- package/dist/types/formatMessageMemo.d.ts +5 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +51 -23
- package/dist/types/gen/chat/ChatApi.d.ts +215 -168
- package/dist/types/gen/models/index.d.ts +2164 -557
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +39 -32
- package/dist/types/gen-imports.d.ts +1 -0
- package/dist/types/index.d.ts +20 -7
- package/dist/types/languageNames.d.ts +97 -0
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
- package/dist/types/messageComposer/LocationComposer.d.ts +10 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +11 -0
- package/dist/types/messageComposer/attachmentManager.d.ts +48 -10
- package/dist/types/messageComposer/attachmentUtils.d.ts +34 -0
- package/dist/types/messageComposer/configuration/commands.configuration.d.ts +1 -3
- package/dist/types/messageComposer/configuration/configuration.d.ts +9 -1
- package/dist/types/messageComposer/configuration/index.d.ts +0 -1
- package/dist/types/messageComposer/configuration/types.d.ts +57 -1
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +10 -4
- package/dist/types/messageComposer/messageComposer.d.ts +210 -14
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +20 -1
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +11 -0
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +2 -2
- package/dist/types/messageComposer/middleware/pollComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/middleware/pollComposer/state.d.ts +3 -2
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +9 -2
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +44 -0
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +2 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +94 -229
- package/dist/types/messageComposer/pollComposer.d.ts +8 -3
- package/dist/types/messageComposer/textComposer.d.ts +9 -1
- package/dist/types/messageComposer/types.d.ts +7 -3
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +64 -8
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +48 -11
- package/dist/types/messageOperations/FailedSendCache.d.ts +34 -0
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +52 -6
- package/dist/types/messageOperations/MessageOperations.d.ts +94 -11
- package/dist/types/{entityStore → messageOperations}/applyReactionLocally.d.ts +8 -2
- package/dist/types/messageOperations/createMessageOperations.d.ts +11 -0
- package/dist/types/messageOperations/index.d.ts +7 -1
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +24 -0
- package/dist/types/messageOperations/sendOrdering.d.ts +17 -0
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +28 -0
- package/dist/types/messageOperations/types.d.ts +66 -1
- package/dist/types/middleware.d.ts +8 -0
- package/dist/types/moderation.d.ts +18 -4
- package/dist/types/notifications/NotificationManager.d.ts +43 -2
- package/dist/types/notifications/types.d.ts +55 -42
- package/dist/types/offline-support/offline_support_api.d.ts +128 -12
- package/dist/types/offline-support/offline_sync_manager.d.ts +26 -5
- package/dist/types/offline-support/queueableOperations.d.ts +106 -0
- package/dist/types/offline-support/types.d.ts +77 -28
- package/dist/types/pagination/FilterBuilder.d.ts +1 -18
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -1
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +21 -3
- package/dist/types/pagination/filterCompiler.d.ts +5 -0
- package/dist/types/pagination/paginators/BasePaginator.d.ts +331 -7
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +54 -11
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +283 -66
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +10 -9
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +17 -1
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +8 -8
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +57 -0
- package/dist/types/pagination/paginators/index.d.ts +1 -0
- package/dist/types/pagination/utility.normalization.d.ts +29 -2
- package/dist/types/poll.d.ts +41 -14
- package/dist/types/poll_manager.d.ts +3 -2
- package/dist/types/poll_optimistic_votes.d.ts +61 -0
- package/dist/types/reminders/Reminder.d.ts +17 -7
- package/dist/types/reminders/ReminderManager.d.ts +34 -6
- package/dist/types/search/BaseSearchSource.d.ts +50 -25
- package/dist/types/search/ChannelMemberSearchSource.d.ts +11 -6
- package/dist/types/search/ChannelSearchSource.d.ts +27 -5
- package/dist/types/search/MessageSearchSource.d.ts +36 -6
- package/dist/types/search/SearchController.d.ts +44 -11
- package/dist/types/search/UserSearchSource.d.ts +11 -5
- package/dist/types/search/types.d.ts +14 -1
- package/dist/types/signing.d.ts +0 -157
- package/dist/types/thread.d.ts +118 -62
- package/dist/types/thread_manager.d.ts +124 -35
- package/dist/types/token_manager.d.ts +5 -8
- package/dist/types/types.d.ts +138 -562
- package/dist/types/types.utility.d.ts +8 -0
- package/dist/types/upload-utils.d.ts +20 -0
- package/dist/types/uploadManager.d.ts +50 -2
- package/dist/types/utils/FixedSizeQueueCache.d.ts +2 -0
- package/dist/types/utils/WithSubscriptions.d.ts +1 -1
- package/dist/types/utils/objectPath.d.ts +49 -0
- package/dist/types/utils/time.d.ts +85 -0
- package/dist/types/utils.d.ts +63 -40
- package/package.json +22 -33
- package/src/ChannelManager.ts +561 -109
- package/src/CooldownTimer.ts +55 -45
- package/src/EventHandlerPipeline.ts +13 -23
- package/src/LiveLocationManager.ts +191 -37
- package/src/api-client.ts +144 -53
- package/src/channel.ts +1573 -1050
- package/src/channel_state.ts +239 -129
- package/src/client.ts +843 -892
- package/src/client_state.ts +2 -2
- package/src/configuration/ConfigController.ts +298 -0
- package/src/configuration/InstanceConfigurationRegistry.ts +430 -0
- package/src/configuration/index.ts +7 -0
- package/src/configuration/keys.ts +86 -0
- package/src/configuration/shape.ts +776 -0
- package/src/configuration/types.ts +218 -60
- package/src/configuration/utils/applyInstanceConfiguration.ts +184 -0
- package/src/configuration/utils/copyConfigPatch.ts +61 -0
- package/src/configuration/utils/declarativeSlices.ts +81 -0
- package/src/configuration/utils/deepFreezeConfig.ts +33 -0
- package/src/configuration/utils/index.ts +5 -0
- package/src/configuration/utils/serverAuthority.ts +146 -0
- package/src/connection/ConnectionIdManager.ts +153 -0
- package/src/connection/ConnectionRecoveryManager.ts +371 -0
- package/src/connection/index.ts +4 -0
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +281 -0
- package/src/connection/networkConnection/index.ts +3 -0
- package/src/connection/networkConnection/reporters.ts +85 -0
- package/src/connection/networkConnection/types.ts +60 -0
- package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +242 -151
- package/src/connection/wsConnection/WSConnection.ts +345 -0
- package/src/connection/wsConnection/WSConnectionFallback.ts +259 -0
- package/src/connection/wsConnection/config.ts +108 -0
- package/src/connection/wsConnection/index.ts +4 -0
- package/src/connection/wsConnection/types.ts +101 -0
- package/src/constants.ts +5 -3
- package/src/entityStore/EntityStore.ts +350 -10
- package/src/entityStore/StoreBackedItemIndex.ts +66 -37
- package/src/entityStore/index.ts +0 -1
- package/src/errors.ts +40 -7
- package/src/formatMessageMemo.ts +23 -0
- package/src/gen/chat/ChannelApi.ts +230 -44
- package/src/gen/chat/ChatApi.ts +1047 -1745
- package/src/gen/models/index.ts +2378 -3721
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +218 -388
- package/src/gen-imports.ts +1 -0
- package/src/index.ts +82 -6
- package/src/languageNames.ts +103 -0
- package/src/logger.ts +1 -1
- package/src/messageComposer/CustomDataManager.ts +10 -1
- package/src/messageComposer/LocationComposer.ts +68 -20
- package/src/messageComposer/attachmentIdentity.ts +39 -0
- package/src/messageComposer/attachmentManager.ts +191 -68
- package/src/messageComposer/attachmentUtils.ts +58 -0
- package/src/messageComposer/configuration/commands.configuration.ts +1 -26
- package/src/messageComposer/configuration/configuration.ts +22 -3
- package/src/messageComposer/configuration/index.ts +0 -1
- package/src/messageComposer/configuration/types.ts +58 -1
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/linkPreviewsManager.ts +16 -10
- package/src/messageComposer/messageComposer.ts +487 -98
- package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +58 -33
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +7 -2
- package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +3 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +98 -1
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +20 -10
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +2 -7
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +11 -6
- package/src/messageComposer/middleware/pollComposer/index.ts +1 -0
- package/src/messageComposer/middleware/pollComposer/state.ts +43 -11
- package/src/messageComposer/middleware/pollComposer/types.ts +9 -2
- package/src/messageComposer/middleware/pollComposer/validation.ts +76 -0
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +1 -2
- package/src/messageComposer/middleware/textComposer/mentions.ts +91 -39
- package/src/messageComposer/pollComposer.ts +11 -3
- package/src/messageComposer/textComposer.ts +36 -4
- package/src/messageComposer/types.ts +19 -14
- package/src/messageDelivery/MessageDeliveryReporter.ts +154 -53
- package/src/messageDelivery/MessageReceiptsTracker.ts +136 -64
- package/src/messageOperations/FailedSendCache.ts +90 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +269 -27
- package/src/messageOperations/MessageOperations.ts +340 -136
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +10 -3
- package/src/messageOperations/createMessageOperations.ts +192 -0
- package/src/messageOperations/index.ts +7 -0
- package/src/messageOperations/reflectReactionEvent.ts +51 -0
- package/src/messageOperations/sendOrdering.ts +28 -0
- package/src/messageOperations/settlePendingAttachmentUploads.ts +110 -0
- package/src/messageOperations/types.ts +74 -0
- package/src/middleware.ts +11 -0
- package/src/moderation.ts +47 -24
- package/src/notifications/NotificationManager.ts +73 -3
- package/src/notifications/configuration.ts +10 -8
- package/src/notifications/types.ts +58 -42
- package/src/offline-support/offline_support_api.ts +380 -197
- package/src/offline-support/offline_sync_manager.ts +105 -32
- package/src/offline-support/queueableOperations.ts +270 -0
- package/src/offline-support/types.ts +85 -39
- package/src/pagination/FilterBuilder.ts +1 -22
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +11 -7
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +25 -7
- package/src/pagination/filterCompiler.ts +17 -0
- package/src/pagination/paginators/BasePaginator.ts +731 -81
- package/src/pagination/paginators/ChannelPaginator.ts +210 -102
- package/src/pagination/paginators/MessageIntervalPaginator.ts +703 -193
- package/src/pagination/paginators/MessagePaginator.ts +45 -36
- package/src/pagination/paginators/PinnedMessagePaginator.ts +74 -28
- package/src/pagination/paginators/ReminderPaginator.ts +15 -13
- package/src/pagination/paginators/ThreadPaginator.ts +181 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +8 -1
- package/src/pagination/paginators/index.ts +1 -0
- package/src/pagination/utility.normalization.ts +37 -9
- package/src/poll.ts +189 -112
- package/src/poll_manager.ts +14 -8
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +34 -16
- package/src/reminders/ReminderManager.ts +68 -41
- package/src/reminders/ReminderTimer.ts +7 -6
- package/src/search/BaseSearchSource.ts +133 -40
- package/src/search/ChannelMemberSearchSource.ts +27 -18
- package/src/search/ChannelSearchSource.ts +61 -7
- package/src/search/MessageSearchSource.ts +133 -28
- package/src/search/SearchController.ts +93 -16
- package/src/search/UserSearchSource.ts +27 -13
- package/src/search/types.ts +14 -1
- package/src/signing.ts +1 -315
- package/src/thread.ts +503 -511
- package/src/thread_manager.ts +339 -204
- package/src/token_manager.ts +12 -32
- package/src/types.ts +159 -780
- package/src/types.utility.ts +14 -0
- package/src/upload-utils.ts +53 -0
- package/src/uploadManager.ts +85 -7
- package/src/utils/FixedSizeQueueCache.ts +5 -0
- package/src/utils/WithSubscriptions.ts +1 -1
- package/src/utils/objectPath.ts +67 -0
- package/src/utils/time.ts +104 -0
- package/src/utils.ts +209 -157
- package/dist/types/base64.d.ts +0 -2
- package/dist/types/configuration/InstanceConfigurationService.d.ts +0 -26
- package/dist/types/connection.d.ts +0 -146
- package/dist/types/connection_fallback.d.ts +0 -42
- package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
- package/dist/types/insights.d.ts +0 -58
- package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
- package/dist/types/permissions.d.ts +0 -55
- package/dist/types/store.d.ts +0 -125
- package/src/base64.ts +0 -78
- package/src/configuration/InstanceConfigurationService.ts +0 -73
- package/src/connection_fallback.ts +0 -215
- package/src/gen/model-decoders/decoders.ts +0 -2680
- package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
- package/src/insights.ts +0 -83
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/permissions.ts +0 -102
- package/src/store.ts +0 -304
|
@@ -1,30 +1,63 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
2
|
-
import type {
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
|
+
import type { StreamChat } from '../client';
|
|
3
3
|
import type { SearchSource } from './BaseSearchSource';
|
|
4
4
|
export type SearchControllerState = {
|
|
5
5
|
isActive: boolean;
|
|
6
6
|
searchQuery: string;
|
|
7
7
|
sources: SearchSource[];
|
|
8
8
|
};
|
|
9
|
-
export type InternalSearchControllerState = {
|
|
10
|
-
focusedMessage?: MessageResponse;
|
|
11
|
-
};
|
|
12
9
|
export type SearchControllerConfig = {
|
|
13
10
|
keepSingleActiveSource: boolean;
|
|
14
11
|
};
|
|
15
12
|
export type SearchControllerOptions = {
|
|
13
|
+
/**
|
|
14
|
+
* Required for this controller to take part in `client.config`.
|
|
15
|
+
*
|
|
16
|
+
* It is the one configurable class this package never constructs — an app or a downstream SDK does
|
|
17
|
+
* (`<Chat>` in `stream-chat-react`) — so there is no other route by which it could find the
|
|
18
|
+
* configuration registry. Left out, the controller still works and `updateConfig` still applies;
|
|
19
|
+
* only the declarative key and its setup function go unheard.
|
|
20
|
+
*/
|
|
21
|
+
client?: StreamChat;
|
|
16
22
|
config?: Partial<SearchControllerConfig>;
|
|
17
23
|
sources?: SearchSource[];
|
|
18
24
|
};
|
|
25
|
+
export declare const DEFAULT_SEARCH_CONTROLLER_CONFIG: SearchControllerConfig;
|
|
19
26
|
export declare class SearchController {
|
|
27
|
+
state: StateStore<SearchControllerState>;
|
|
28
|
+
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
29
|
+
private readonly configController;
|
|
30
|
+
private readonly client?;
|
|
31
|
+
/** Teardown for the configuration subscription, when this controller was given a client. */
|
|
32
|
+
private unsubscribeConfiguration?;
|
|
20
33
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
34
|
+
* Resolved configuration, as a store so consumers can react to it — the same shape every configurable
|
|
35
|
+
* class exposes (`configState` for the store, {@link config} for the current value).
|
|
23
36
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
get configState(): StateStore<SearchControllerConfig>;
|
|
38
|
+
constructor({ client, config, sources }?: SearchControllerOptions);
|
|
39
|
+
private subscribeConfiguration;
|
|
40
|
+
/**
|
|
41
|
+
* Takes again what {@link SearchController.dispose} released: the configuration subscription and
|
|
42
|
+
* whatever each source holds outside itself. A no-op for what is already held, so a UI can call it
|
|
43
|
+
* on every mount, including a remount of the same instance after its cleanup disposed it.
|
|
44
|
+
*/
|
|
45
|
+
registerSubscriptions(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Releases the configuration subscription, running the setup function's teardown, and what each
|
|
48
|
+
* source holds outside itself, such as a channel search's hold on its results in the channel
|
|
49
|
+
* store. {@link SearchController.registerSubscriptions} takes them again.
|
|
50
|
+
*/
|
|
51
|
+
dispose(): void;
|
|
52
|
+
/**
|
|
53
|
+
* The current resolved configuration. `Readonly` because the value is the store's live object —
|
|
54
|
+
* assigning to a field of it would change state without notifying anyone. Use {@link updateConfig}.
|
|
55
|
+
*/
|
|
56
|
+
get config(): Readonly<SearchControllerConfig>;
|
|
57
|
+
/** Merges a partial configuration into the resolved config and notifies subscribers. */
|
|
58
|
+
updateConfig(config: Partial<SearchControllerConfig>): void;
|
|
59
|
+
/** Rebuilds the resolved configuration from package defaults plus the declarative slice. */
|
|
60
|
+
initializeConfig(config?: Partial<SearchControllerConfig>): void;
|
|
28
61
|
get hasNext(): boolean;
|
|
29
62
|
get sources(): SearchSource<any>[];
|
|
30
63
|
get activeSources(): SearchSource<any>[];
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { BaseSearchSource } from './BaseSearchSource';
|
|
1
|
+
import { BaseSearchSource, type SearchQueryOptions } from './BaseSearchSource';
|
|
2
2
|
import { FilterBuilder, type FilterBuilderOptions } from '../pagination';
|
|
3
3
|
import type { StreamChat } from '../client';
|
|
4
|
-
import type { UserFilters, UserOptions, UserResponse
|
|
4
|
+
import type { SortParamRequest, UserFilters, UserOptions, UserResponse } from '../types';
|
|
5
5
|
import type { SearchSourceOptions } from './types';
|
|
6
6
|
type CustomContext = Record<string, unknown>;
|
|
7
7
|
export type UserSearchSourceFilterBuilderContext<C extends CustomContext = CustomContext> = {
|
|
8
8
|
searchQuery?: string;
|
|
9
9
|
} & C;
|
|
10
|
+
export type UserSearchSourceOptions = SearchSourceOptions & {
|
|
11
|
+
/** Static base filters merged under the dynamically generated ones. */
|
|
12
|
+
filters?: UserFilters;
|
|
13
|
+
sort?: SortParamRequest[];
|
|
14
|
+
searchOptions?: Omit<UserOptions, 'limit' | 'offset'>;
|
|
15
|
+
};
|
|
10
16
|
export declare class UserSearchSource<TFilterContext extends CustomContext = CustomContext> extends BaseSearchSource<UserResponse> {
|
|
11
17
|
readonly type = "users";
|
|
12
18
|
client: StreamChat;
|
|
13
19
|
filters: UserFilters | undefined;
|
|
14
|
-
sort:
|
|
20
|
+
sort: SortParamRequest[] | undefined;
|
|
15
21
|
searchOptions: Omit<UserOptions, 'limit' | 'offset'> | undefined;
|
|
16
22
|
filterBuilder: FilterBuilder<UserFilters, UserSearchSourceFilterBuilderContext<TFilterContext>>;
|
|
17
|
-
constructor(client: StreamChat, options?:
|
|
18
|
-
protected query(searchQuery: string): Promise<{
|
|
23
|
+
constructor(client: StreamChat, options?: UserSearchSourceOptions, filterBuilderOptions?: FilterBuilderOptions<UserFilters, UserSearchSourceFilterBuilderContext<TFilterContext>>);
|
|
24
|
+
protected query(searchQuery: string, queryOptions?: SearchQueryOptions): Promise<{
|
|
19
25
|
items: import("..").FullUserResponse[];
|
|
20
26
|
}>;
|
|
21
27
|
protected filterQueryResults(items: UserResponse[]): UserResponse[];
|
|
@@ -9,8 +9,21 @@ export type SearchSourceState<T = any> = {
|
|
|
9
9
|
offset?: number;
|
|
10
10
|
};
|
|
11
11
|
export type SearchSourceOptions = {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Legacy single debounce interval. When set, it applies to both short and long queries,
|
|
14
|
+
* unless overridden by `shortQueryDebounceMs` / `longQueryDebounceMs`.
|
|
15
|
+
*/
|
|
13
16
|
debounceMs?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Debounce interval for queries no longer than `shortQueryMaxLength`. Such queries have
|
|
19
|
+
* low selectivity and are expensive server-side, so they are debounced harder.
|
|
20
|
+
* Defaults to 500ms.
|
|
21
|
+
*/
|
|
22
|
+
shortQueryDebounceMs?: number;
|
|
23
|
+
/** Debounce interval for queries longer than `shortQueryMaxLength`. Defaults to 300ms. */
|
|
24
|
+
longQueryDebounceMs?: number;
|
|
25
|
+
/** Query length (inclusive) that still counts as short. Defaults to 2. */
|
|
26
|
+
shortQueryMaxLength?: number;
|
|
14
27
|
pageSize?: number;
|
|
15
28
|
/** When `true`, the source can execute queries with an empty search string (defaults to `false`). */
|
|
16
29
|
allowEmptySearchString?: boolean;
|
package/dist/types/signing.d.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import jwt from 'jsonwebtoken';
|
|
2
|
-
import type { UR } from './types';
|
|
3
|
-
import type { WSEvent } from './gen/models';
|
|
4
|
-
/**
|
|
5
|
-
* Creates the JWT token that can be used for a user session.
|
|
6
|
-
*
|
|
7
|
-
* @param apiSecret - API secret key.
|
|
8
|
-
* @param userId - The `user_id` key in the JWT payload.
|
|
9
|
-
* @param extraData - Extra data that should be part of the JWT token (optional, defaults to `{}`).
|
|
10
|
-
* @param jwtOptions - Options that can be passed to `jwt.sign` (optional, defaults to `{}`).
|
|
11
|
-
* @returns The signed JWT token.
|
|
12
|
-
*/
|
|
13
|
-
export declare function JWTUserToken(apiSecret: jwt.Secret, userId: string, extraData?: UR, jwtOptions?: jwt.SignOptions): string;
|
|
14
|
-
/**
|
|
15
|
-
* Creates the JWT token that can be used for a server-side session.
|
|
16
|
-
*
|
|
17
|
-
* @param apiSecret - API secret key.
|
|
18
|
-
* @param jwtOptions - Options that can be passed to `jwt.sign` (optional, defaults to `{}`).
|
|
19
|
-
* @returns The signed JWT token.
|
|
20
|
-
*/
|
|
21
|
-
export declare function JWTServerToken(apiSecret: jwt.Secret, jwtOptions?: jwt.SignOptions): string;
|
|
22
1
|
/**
|
|
23
2
|
* Decodes a JWT token and returns the embedded `user_id`.
|
|
24
3
|
*
|
|
@@ -26,139 +5,3 @@ export declare function JWTServerToken(apiSecret: jwt.Secret, jwtOptions?: jwt.S
|
|
|
26
5
|
* @returns The `user_id` extracted from the token's payload, or an empty string when the token is malformed.
|
|
27
6
|
*/
|
|
28
7
|
export declare function UserFromToken(token: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Generates a development token for the given user.
|
|
31
|
-
*
|
|
32
|
-
* Development tokens are unsigned and must only be used in environments where token validation is disabled.
|
|
33
|
-
*
|
|
34
|
-
* @param userId - The ID of the user.
|
|
35
|
-
* @returns The development token.
|
|
36
|
-
*/
|
|
37
|
-
export declare function DevToken(userId: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Constant-time HMAC-SHA256 verification of `signature` against the digest of `body` using `secret`
|
|
40
|
-
* as the key. The signature is always computed over the **uncompressed** JSON bytes, so callers that
|
|
41
|
-
* decoded a gzipped or base64-wrapped payload must pass the inflated bytes here.
|
|
42
|
-
*
|
|
43
|
-
* The legacy `client.verifyWebhook` helper wraps this function, so callers that have already
|
|
44
|
-
* migrated to {@link verifyAndParseWebhook}, {@link parseSqs}, or {@link parseSns} rarely need to
|
|
45
|
-
* invoke this directly.
|
|
46
|
-
*
|
|
47
|
-
* @param body - The uncompressed payload bytes that Stream signed.
|
|
48
|
-
* @param signature - The HMAC-SHA256 signature delivered alongside the payload.
|
|
49
|
-
* @param secret - Your app's API secret used as the HMAC key.
|
|
50
|
-
* @returns `true` when the signature matches the digest of `body`, otherwise `false`.
|
|
51
|
-
*/
|
|
52
|
-
export declare function verifySignature(body: string | Buffer, signature: string, secret: string): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Verifies an HMAC-SHA256 signature with the legacy parameter order.
|
|
55
|
-
*
|
|
56
|
-
* @param body - The uncompressed payload bytes that Stream signed.
|
|
57
|
-
* @param secret - Your app's API secret used as the HMAC key.
|
|
58
|
-
* @param signature - The HMAC-SHA256 signature delivered alongside the payload.
|
|
59
|
-
* @returns `true` when the signature matches the digest of `body`, otherwise `false`.
|
|
60
|
-
* @deprecated Use {@link verifySignature} instead — same logic, parameters reordered to match the
|
|
61
|
-
* cross-SDK contract (`verifySignature(body, signature, secret)`).
|
|
62
|
-
*/
|
|
63
|
-
export declare function CheckSignature(body: string | Buffer, secret: string, signature: string): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Canonical failure-mode messages for {@link InvalidWebhookError}.
|
|
66
|
-
*
|
|
67
|
-
* Customers that prefer exact-match filtering (security logging, retry
|
|
68
|
-
* policy) over substring matches can compare `err.message` to these
|
|
69
|
-
* constants instead of pattern-matching free-form text.
|
|
70
|
-
*/
|
|
71
|
-
export declare const InvalidWebhookErrorMessages: {
|
|
72
|
-
readonly signatureMismatch: "signature mismatch";
|
|
73
|
-
readonly invalidBase64: "invalid base64 encoding";
|
|
74
|
-
readonly gzipFailed: "gzip decompression failed";
|
|
75
|
-
readonly invalidJson: "invalid JSON payload";
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* Thrown by {@link verifyAndParseWebhook} when the supplied `x-signature` does not
|
|
79
|
-
* match the HMAC of the uncompressed payload, and by all webhook helpers (including
|
|
80
|
-
* {@link parseSqs} / {@link parseSns}) when a gzip / base64 / JSON envelope is malformed.
|
|
81
|
-
*
|
|
82
|
-
* The message identifies which failure mode fired. See
|
|
83
|
-
* {@link InvalidWebhookErrorMessages} for the canonical strings.
|
|
84
|
-
*/
|
|
85
|
-
export declare class InvalidWebhookError extends Error {
|
|
86
|
-
name: string;
|
|
87
|
-
constructor(message?: string);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Returns `body` as a `Buffer`, gzip-decompressed when its first two bytes match the gzip magic
|
|
91
|
-
* (`1f 8b`, per RFC 1952). When the body is plain JSON (no compression, or middleware already
|
|
92
|
-
* decompressed), the bytes are returned unchanged.
|
|
93
|
-
*
|
|
94
|
-
* Magic-byte detection (rather than relying on a header) keeps the same handler correct when
|
|
95
|
-
* middleware — Express, Next.js, AWS Lambda — auto-decompresses the request before your code sees it.
|
|
96
|
-
*
|
|
97
|
-
* @param rawBody - The raw HTTP request body, either as a string or a `Buffer`.
|
|
98
|
-
* @returns The uncompressed payload bytes.
|
|
99
|
-
* @throws {@link InvalidWebhookError} when the gzip envelope is malformed.
|
|
100
|
-
*/
|
|
101
|
-
export declare function gunzipPayload(rawBody: string | Buffer): Buffer;
|
|
102
|
-
/**
|
|
103
|
-
* Reverses the SQS firehose envelope: the message `Body` is base64-decoded, then the result is
|
|
104
|
-
* gzip-decompressed when it begins with the gzip magic. Returns the raw JSON `Buffer` Stream signed.
|
|
105
|
-
*
|
|
106
|
-
* SQS bodies are always base64-encoded so they remain valid UTF-8 over the queue. The same call
|
|
107
|
-
* works whether or not Stream is currently compressing payloads for this app.
|
|
108
|
-
*
|
|
109
|
-
* @param body - The base64-encoded SQS message body.
|
|
110
|
-
* @returns The decoded (and decompressed, when gzipped) payload bytes.
|
|
111
|
-
* @throws {@link InvalidWebhookError} when the body is not canonical base64 or the gzip envelope is malformed.
|
|
112
|
-
*/
|
|
113
|
-
export declare function decodeSqsPayload(body: string): Buffer;
|
|
114
|
-
/**
|
|
115
|
-
* Reverses an SNS HTTP notification envelope. When `notificationBody` is a JSON envelope
|
|
116
|
-
* (`{"Type":"Notification","MessageRequest":"..."}`), the inner `MessageRequest` field is extracted and run
|
|
117
|
-
* through the SQS pipeline (base64-decode, then gzip-if-magic). When the input is not a JSON
|
|
118
|
-
* envelope it is treated as the already-extracted `MessageRequest` string, so call sites that pre-unwrap
|
|
119
|
-
* continue to work.
|
|
120
|
-
*
|
|
121
|
-
* @param notificationBody - The raw SNS notification body, or a pre-extracted `MessageRequest` string.
|
|
122
|
-
* @returns The decoded (and decompressed, when gzipped) payload bytes.
|
|
123
|
-
* @throws {@link InvalidWebhookError} when the body is not canonical base64 or the gzip envelope is malformed.
|
|
124
|
-
*/
|
|
125
|
-
export declare function decodeSnsPayload(notificationBody: string): Buffer;
|
|
126
|
-
/**
|
|
127
|
-
* Parses a JSON-encoded webhook event into a typed {@link WSEvent}. New event types Stream
|
|
128
|
-
* introduces still parse successfully — the runtime shape is the JSON Stream sent and the `type`
|
|
129
|
-
* field stays preserved.
|
|
130
|
-
*
|
|
131
|
-
* @param payload - The raw event payload bytes or string.
|
|
132
|
-
* @returns The parsed WebSocket event.
|
|
133
|
-
* @throws {@link InvalidWebhookError} when the payload is not valid JSON.
|
|
134
|
-
*/
|
|
135
|
-
export declare function parseEvent(payload: Buffer | string): WSEvent;
|
|
136
|
-
/**
|
|
137
|
-
* Decompress (when gzipped), verify the HMAC `signature`, and return the parsed {@link WSEvent}.
|
|
138
|
-
*
|
|
139
|
-
* @param rawBody - Raw HTTP request body bytes Stream signed.
|
|
140
|
-
* @param signature - Value of the `X-Signature` header.
|
|
141
|
-
* @param secret - Your app's API secret.
|
|
142
|
-
* @returns The parsed WebSocket event.
|
|
143
|
-
* @throws {@link InvalidWebhookError} when the signature does not match or the gzip envelope is malformed.
|
|
144
|
-
*/
|
|
145
|
-
export declare function verifyAndParseWebhook(rawBody: string | Buffer, signature: string, secret: string): WSEvent;
|
|
146
|
-
/**
|
|
147
|
-
* Decodes the SQS message `Body` (base64, then gzip-if-magic) and returns the parsed {@link WSEvent}.
|
|
148
|
-
* Stream does not attach an application-level HMAC to SQS deliveries — use
|
|
149
|
-
* {@link verifyAndParseWebhook} for HTTP webhooks.
|
|
150
|
-
*
|
|
151
|
-
* @param messageBody - The base64-encoded SQS message body.
|
|
152
|
-
* @returns The parsed WebSocket event.
|
|
153
|
-
* @throws {@link InvalidWebhookError} when the body is malformed.
|
|
154
|
-
*/
|
|
155
|
-
export declare function parseSqs(messageBody: string): WSEvent;
|
|
156
|
-
/**
|
|
157
|
-
* Decodes an SNS notification (unwraps the JSON envelope when needed; same inner format as SQS).
|
|
158
|
-
* No application-level HMAC verification.
|
|
159
|
-
*
|
|
160
|
-
* @param notificationBody - The raw SNS notification body, or a pre-extracted `MessageRequest` string.
|
|
161
|
-
* @returns The parsed WebSocket event.
|
|
162
|
-
* @throws {@link InvalidWebhookError} when the body is malformed.
|
|
163
|
-
*/
|
|
164
|
-
export declare function parseSns(notificationBody: string): WSEvent;
|
package/dist/types/thread.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
2
|
-
import type { DraftResponse,
|
|
3
|
-
import type { Channel
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
|
+
import type { DraftResponse, EventPayload, LocalMessage, MarkReadRequest, MarkReadResponse, MessageResponse, StreamResponse, ThreadStateResponse, TimestampNS, UserResponse } from './types';
|
|
3
|
+
import type { Channel } from './channel';
|
|
4
4
|
import type { StreamChat } from './client';
|
|
5
5
|
import type { CustomThreadData } from './custom_types';
|
|
6
6
|
import { MessageComposer } from './messageComposer';
|
|
7
|
-
import { MessageOperations } from './messageOperations';
|
|
7
|
+
import type { MessageOperations } from './messageOperations';
|
|
8
8
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
9
9
|
import { MessagePaginator } from './pagination';
|
|
10
|
+
import type { MergeNewestPageOptions } from './pagination';
|
|
11
|
+
import type { ThreadDeclarativeConfig } from './configuration/types';
|
|
12
|
+
import type { PipelineEvent } from './EventHandlerPipeline';
|
|
10
13
|
export type ThreadState = {
|
|
11
14
|
/**
|
|
12
15
|
* Determines if the thread is currently opened and on-screen. When the thread is active,
|
|
@@ -14,9 +17,11 @@ export type ThreadState = {
|
|
|
14
17
|
*/
|
|
15
18
|
active: boolean;
|
|
16
19
|
channel: Channel;
|
|
17
|
-
|
|
20
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
21
|
+
createdAt: TimestampNS;
|
|
18
22
|
custom: CustomThreadData;
|
|
19
|
-
|
|
23
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
24
|
+
deletedAt: TimestampNS | null;
|
|
20
25
|
isLoading: boolean;
|
|
21
26
|
isStateStale: boolean;
|
|
22
27
|
/**
|
|
@@ -28,10 +33,12 @@ export type ThreadState = {
|
|
|
28
33
|
read: ThreadReadState;
|
|
29
34
|
replyCount: number;
|
|
30
35
|
title: string;
|
|
31
|
-
|
|
36
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
37
|
+
updatedAt: TimestampNS | null;
|
|
32
38
|
};
|
|
33
39
|
export type ThreadUserReadState = {
|
|
34
|
-
|
|
40
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
41
|
+
lastReadAt: TimestampNS;
|
|
35
42
|
unreadMessageCount: number;
|
|
36
43
|
user: UserResponse;
|
|
37
44
|
lastReadMessageId?: string;
|
|
@@ -41,21 +48,30 @@ export type ThreadReadState = Record<string, ThreadUserReadState | undefined>;
|
|
|
41
48
|
export type CustomThreadMarkReadRequestFn = (params: {
|
|
42
49
|
thread: Thread;
|
|
43
50
|
options?: MarkReadRequest;
|
|
44
|
-
}) => Promise<
|
|
45
|
-
export type
|
|
51
|
+
}) => Promise<Partial<StreamResponse<MarkReadResponse>> | null> | void;
|
|
52
|
+
export type ThreadConfig = {
|
|
46
53
|
requestHandlers?: {
|
|
47
54
|
markReadRequest?: CustomThreadMarkReadRequestFn;
|
|
48
55
|
};
|
|
49
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* Empty because every field of `ThreadConfig` is optional — a thread's own configuration is one handler
|
|
59
|
+
* wide. Declared and frozen anyway, so the entity carries the same defaults layer as every other
|
|
60
|
+
* configurable class rather than a special case.
|
|
61
|
+
*/
|
|
62
|
+
export declare const DEFAULT_THREAD_CONFIG: ThreadConfig;
|
|
50
63
|
export declare class Thread extends WithSubscriptions {
|
|
51
|
-
|
|
64
|
+
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
65
|
+
private readonly configController;
|
|
52
66
|
readonly state: StateStore<ThreadState>;
|
|
53
67
|
readonly id: string;
|
|
54
68
|
readonly messageComposer: MessageComposer;
|
|
55
|
-
readonly messagePaginator: MessagePaginator;
|
|
56
69
|
readonly messageOperations: MessageOperations;
|
|
70
|
+
readonly messagePaginator: MessagePaginator;
|
|
57
71
|
private client;
|
|
58
72
|
private failedRepliesMap;
|
|
73
|
+
/** How many activations (`activate()` calls) have not been released yet. */
|
|
74
|
+
private _activeRefCount;
|
|
59
75
|
constructor({ client, threadData, channel, parentMessage, draft, }: {
|
|
60
76
|
client: StreamChat;
|
|
61
77
|
threadData?: ThreadStateResponse;
|
|
@@ -63,24 +79,101 @@ export declare class Thread extends WithSubscriptions {
|
|
|
63
79
|
parentMessage?: MessageResponse | LocalMessage;
|
|
64
80
|
draft?: DraftResponse;
|
|
65
81
|
});
|
|
82
|
+
/**
|
|
83
|
+
* Derives this thread's configuration — and its reply paginator's — from the declarative slice.
|
|
84
|
+
*
|
|
85
|
+
* Called by the constructor and by `client.config.reset()`. The thread owns only its own
|
|
86
|
+
* `requestHandlers`; the paginator derives its own configuration.
|
|
87
|
+
*/
|
|
88
|
+
initializeConfig(declarativeConfig?: ThreadDeclarativeConfig): void;
|
|
89
|
+
/**
|
|
90
|
+
* Resolved configuration as a store, so consumers can react to it — the shape every configurable class
|
|
91
|
+
* exposes.
|
|
92
|
+
*/
|
|
93
|
+
get configState(): StateStore<ThreadConfig>;
|
|
94
|
+
/**
|
|
95
|
+
* This thread's resolved configuration. `Readonly` because the value is the store's live object —
|
|
96
|
+
* assigning to a field of it would change state without notifying anyone. Use {@link updateConfig}.
|
|
97
|
+
*/
|
|
98
|
+
get config(): Readonly<ThreadConfig>;
|
|
99
|
+
/** Merges a partial configuration into the resolved config and notifies subscribers. */
|
|
100
|
+
updateConfig(config: Partial<ThreadConfig>): void;
|
|
66
101
|
get channel(): Channel;
|
|
67
102
|
get hasStaleState(): boolean;
|
|
68
103
|
get ownUnreadCount(): number;
|
|
69
|
-
|
|
70
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Declares that a consumer is displaying this thread, and returns the function that ends it, as
|
|
106
|
+
* `channel.activate()` does. Refcounted, as one `Thread` can be held by several consumers at once,
|
|
107
|
+
* so it stays active until the last one releases. Each call gets its own release, and calling a
|
|
108
|
+
* release again does nothing, so a consumer can't end another one's activation.
|
|
109
|
+
*
|
|
110
|
+
* `active` is also what {@link ConnectionRecoveryManager} filters on to decide which threads to
|
|
111
|
+
* reload on reconnect, so an activation that is never released costs more than a missed auto-read.
|
|
112
|
+
*
|
|
113
|
+
* The first activation also keeps the thread in `client.threads` for the rest of the session:
|
|
114
|
+
* it stays subscribed and resolvable through `client.threads.get(id)` after it is released,
|
|
115
|
+
* whether or not the thread list holds it. Reopening it therefore needs no fetch unless it went stale.
|
|
116
|
+
*/
|
|
117
|
+
activate: () => (() => void);
|
|
118
|
+
/**
|
|
119
|
+
* Re-queries this thread's replies, sized to the loaded window, and reconciles them in place — the
|
|
120
|
+
* thread analogue of {@link Channel.reload}, and what connection recovery calls for every active
|
|
121
|
+
* thread.
|
|
122
|
+
*
|
|
123
|
+
* Preserves failed (unsent) replies. They are read out of the reply paginator rather than out of
|
|
124
|
+
* `failedRepliesMap`, because that map is only written by `upsertReplyLocally`, whose callers are
|
|
125
|
+
* this thread's own subscriptions and the offline-DB path resolved through `client.threads.get` —
|
|
126
|
+
* neither of which covers a thread that was never activated or listed. Reading the paginator
|
|
127
|
+
* is true for registered and unregistered threads alike. An overlap merge keeps them anyway (the
|
|
128
|
+
* reconcile's provenance guard never prunes a non-server message); only a disjoint rebuild can drop
|
|
129
|
+
* them, so any that actually fell out are re-ingested below.
|
|
130
|
+
*
|
|
131
|
+
* Rethrows, except for a not-found answer on a thread that never had replies (see the catch).
|
|
132
|
+
*/
|
|
71
133
|
reload: () => Promise<void>;
|
|
72
|
-
hydrateState: (thread: Thread
|
|
134
|
+
hydrateState: (thread: Thread, options?: {
|
|
135
|
+
reconcile?: MergeNewestPageOptions;
|
|
136
|
+
}) => void;
|
|
73
137
|
registerSubscriptions: () => void;
|
|
74
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Subscribes this thread to the `'thread'` configuration key. Registered through
|
|
140
|
+
* `WithSubscriptions`, so `unregisterSubscriptions()` runs the setup function's teardown.
|
|
141
|
+
*
|
|
142
|
+
* **This is where `Thread` differs from `Channel`,** which subscribes from its constructor. Everything
|
|
143
|
+
* below follows from that, and applies to a thread that never calls `registerSubscriptions()`:
|
|
144
|
+
*
|
|
145
|
+
* - no *setup function* runs for it — matching how `MessageComposer` already behaves;
|
|
146
|
+
* - it sees the declarative slice **as it stood when the thread was constructed**, because the
|
|
147
|
+
* constructor applies it directly, but no *later* `client.config.set({ thread: … })` or
|
|
148
|
+
* `set({ messagePaginator: … })` reaches it;
|
|
149
|
+
* - it is absent from the registry's `liveInstances`, so `client.config.reset()` skips it, and
|
|
150
|
+
* `hasLiveInstances('thread')` does not count it when deciding whether to warn about a
|
|
151
|
+
* construction-only path registered too late.
|
|
152
|
+
*
|
|
153
|
+
* So read "declarative configuration is unaffected" as *at construction only*. A thread registered
|
|
154
|
+
* with a `ThreadManager` that has itself registered is covered — the manager calls
|
|
155
|
+
* `registerSubscriptions()` on every thread the list holds or that is active — so the common path
|
|
156
|
+
* is fine. A thread that is neither, or held by an unregistered manager, is not.
|
|
157
|
+
*
|
|
158
|
+
* The alternative — applying the setup function at construction — would break the teardown symmetry
|
|
159
|
+
* `WithSubscriptions` provides, which is why the asymmetry stands.
|
|
160
|
+
*/
|
|
161
|
+
private subscribeThreadSetupStateChange;
|
|
162
|
+
handleThreadUpdated: (event: EventPayload<"thread.updated">) => void;
|
|
75
163
|
private subscribeMarkActiveThreadRead;
|
|
76
164
|
private subscribeReloadActiveStaleThread;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
private
|
|
82
|
-
|
|
83
|
-
|
|
165
|
+
/**
|
|
166
|
+
* A watch stopped while the connection stays up (`NotWatching`) ends the channel's events with no
|
|
167
|
+
* reconnect to catch it. A dropped connection (`WasWatching`) is left to recovery.
|
|
168
|
+
*/
|
|
169
|
+
private subscribeMarkStaleOnStopWatching;
|
|
170
|
+
handleRepliesUnread: (event: EventPayload<"notification.mark_unread">) => void;
|
|
171
|
+
handleNewReply: (event: EventPayload<"message.new">) => void;
|
|
172
|
+
handleRepliesRead: (event: EventPayload<"message.read">) => void;
|
|
173
|
+
handleMessageDeleted: (event: EventPayload<"message.deleted">) => void;
|
|
174
|
+
handleMessageUpdated: (event: PipelineEvent) => void;
|
|
175
|
+
handleReactionChanged: (event: PipelineEvent) => void;
|
|
176
|
+
handleUserMessagesDeleted: (event: PipelineEvent) => void;
|
|
84
177
|
private subscribeParentMessageFromStore;
|
|
85
178
|
unregisterSubscriptions: () => symbol;
|
|
86
179
|
deleteReplyLocally: ({ message }: {
|
|
@@ -94,51 +187,14 @@ export declare class Thread extends WithSubscriptions {
|
|
|
94
187
|
message: MessageResponse;
|
|
95
188
|
}) => void;
|
|
96
189
|
updateParentMessageOrReplyLocally: (message: MessageResponse) => void;
|
|
97
|
-
/**
|
|
98
|
-
* Sends a message with optimistic local state update.
|
|
99
|
-
*/
|
|
100
|
-
sendMessageWithLocalUpdate({ localMessage, message, options, sendMessageRequestFn, }: SendMessageWithStateUpdateParams): Promise<void>;
|
|
101
|
-
/**
|
|
102
|
-
* Retry sending a failed message.
|
|
103
|
-
*/
|
|
104
|
-
retrySendMessageWithLocalUpdate(params: Omit<SendMessageWithStateUpdateParams, 'message'>): Promise<void>;
|
|
105
|
-
/**
|
|
106
|
-
* Updates a message with optimistic local state update.
|
|
107
|
-
*
|
|
108
|
-
* The update flows through `messagePaginator`, which is the sole reply source.
|
|
109
|
-
*/
|
|
110
|
-
updateMessageWithLocalUpdate(params: UpdateMessageWithStateUpdateParams): Promise<void>;
|
|
111
|
-
/**
|
|
112
|
-
* Deletes a message with local state update.
|
|
113
|
-
*/
|
|
114
|
-
deleteMessageWithLocalUpdate(params: DeleteMessageWithStateUpdateParams): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* Adds a reaction to a reply with an optimistic local state update, mirroring
|
|
117
|
-
* {@link Channel.addReactionWithLocalUpdate}. The optimistic message is applied to THIS thread's
|
|
118
|
-
* paginator (so pure replies get optimism the channel paginator can't give); the request routes
|
|
119
|
-
* through the parent channel since reactions are channel-level.
|
|
120
|
-
*/
|
|
121
|
-
addReactionWithLocalUpdate({ messageId, reaction, options, }: {
|
|
122
|
-
messageId: string;
|
|
123
|
-
reaction: ReactionRequest;
|
|
124
|
-
options?: Pick<SendReactionRequest, 'enforce_unique' | 'skip_push'>;
|
|
125
|
-
}): Promise<void>;
|
|
126
|
-
/**
|
|
127
|
-
* Removes the current user's reaction from a reply with an optimistic local state update,
|
|
128
|
-
* mirroring {@link Thread.addReactionWithLocalUpdate}.
|
|
129
|
-
*/
|
|
130
|
-
deleteReactionWithLocalUpdate({ messageId, type, }: {
|
|
131
|
-
messageId: string;
|
|
132
|
-
type: string;
|
|
133
|
-
}): Promise<void>;
|
|
134
190
|
markRead: ({ force }?: {
|
|
135
191
|
force?: boolean;
|
|
136
|
-
}) => Promise<
|
|
192
|
+
}) => Promise<Partial<StreamResponse<MarkReadResponse>> | null>;
|
|
137
193
|
private throttledMarkRead;
|
|
138
194
|
/**
|
|
139
195
|
* @deprecated Use `thread.markRead` instead.
|
|
140
196
|
*/
|
|
141
197
|
markAsRead: ({ force }?: {
|
|
142
198
|
force?: boolean;
|
|
143
|
-
}) => Promise<
|
|
199
|
+
}) => Promise<Partial<StreamResponse<MarkReadResponse>> | null>;
|
|
144
200
|
}
|