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,53 +1,209 @@
|
|
|
1
1
|
import type { StreamChat } from '../client';
|
|
2
|
+
import type { LiveLocationManager, LiveLocationManagerConfig } from '../LiveLocationManager';
|
|
3
|
+
import type { SearchController, SearchControllerConfig } from '../search/SearchController';
|
|
2
4
|
import type { MessageComposer } from '../messageComposer';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export type
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
5
|
+
import type { MessageComposerConfig } from '../messageComposer/configuration/types';
|
|
6
|
+
import type { Channel, ChannelConfig } from '../channel';
|
|
7
|
+
import type { Thread, ThreadConfig } from '../thread';
|
|
8
|
+
import type { ReminderManagerConfig } from '../reminders/ReminderManager';
|
|
9
|
+
import type { NotificationManagerConfig } from '../notifications/types';
|
|
10
|
+
import type { MessageDeliveryReporterConfig } from '../messageDelivery/MessageDeliveryReporter';
|
|
11
|
+
import type { ThreadManagerConfig } from '../thread_manager';
|
|
12
|
+
import type { ConnectionRecoveryManagerConfig, NetworkConnectionObserverConfig, WSConnectionConfig } from '../connection';
|
|
13
|
+
import type { MessageOperationsConfig } from '../messageOperations/MessageOperations';
|
|
14
|
+
import type { DeclarativePaginatorConfig as ImportedDeclarativePaginatorConfig } from '../pagination/paginators/BasePaginator';
|
|
15
|
+
import type { DeepPartial } from '../types.utility';
|
|
16
|
+
/**
|
|
17
|
+
* Maps a configuration key to the argument its setup function receives.
|
|
18
|
+
*
|
|
19
|
+
* A closed set, and deliberately not an `interface`: a type alias cannot be reached by module
|
|
20
|
+
* augmentation, so the key space cannot be extended from outside this package. Configuration for a class
|
|
21
|
+
* this package does not own belongs to whoever owns that class — a registry of its own, not a key in this
|
|
22
|
+
* one, which the SDK could neither type nor apply.
|
|
23
|
+
*/
|
|
24
|
+
export type InstanceSetupFunctionArgs = {
|
|
25
|
+
channel: {
|
|
26
|
+
channel: Channel;
|
|
27
|
+
};
|
|
28
|
+
client: {
|
|
29
|
+
client: StreamChat;
|
|
30
|
+
};
|
|
31
|
+
liveLocationManager: {
|
|
32
|
+
liveLocationManager: LiveLocationManager;
|
|
33
|
+
};
|
|
34
|
+
messageComposer: {
|
|
35
|
+
composer: MessageComposer;
|
|
36
|
+
};
|
|
37
|
+
searchController: {
|
|
38
|
+
searchController: SearchController;
|
|
39
|
+
};
|
|
40
|
+
thread: {
|
|
41
|
+
thread: Thread;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The keys that take a **setup function** — every one names a class the setup function receives an
|
|
46
|
+
* instance of.
|
|
47
|
+
*
|
|
48
|
+
* Closed, and not extensible: an undeclared string is a compile error, and {@link
|
|
49
|
+
* InstanceSetupFunctionArgs} is a type alias rather than an interface, so a key cannot be added by module
|
|
50
|
+
* augmentation either. This key space describes what *this package* configures.
|
|
51
|
+
*
|
|
52
|
+
* A strict subset of {@link InstanceConfigKey}: `messagePaginator` and `messageOperations` take
|
|
53
|
+
* configuration but have no setup function, because they are not built one-per-key — a channel and every
|
|
54
|
+
* one of its threads each own one.
|
|
55
|
+
*/
|
|
56
|
+
export type InstanceSetupKey = keyof InstanceSetupFunctionArgs;
|
|
57
|
+
export type InstanceSetupFunctionArgsOf<K extends InstanceSetupKey> = InstanceSetupFunctionArgs[K];
|
|
58
|
+
export type InstanceSetupTearDownFunction = () => void;
|
|
59
|
+
/**
|
|
60
|
+
* Runs against every instance of its class — those that already exist when it is registered, and
|
|
61
|
+
* every one created afterwards. Return a function that undoes whatever you changed: it is invoked
|
|
62
|
+
* before the setup function is re-applied, and when the instance is disposed of.
|
|
63
|
+
*/
|
|
64
|
+
export type InstanceSetupFunction<K extends InstanceSetupKey = InstanceSetupKey> = (args: InstanceSetupFunctionArgsOf<K>) => void | InstanceSetupTearDownFunction;
|
|
65
|
+
export type InstanceSetupState<K extends InstanceSetupKey = InstanceSetupKey> = {
|
|
66
|
+
setupFunction: InstanceSetupFunction<K> | null;
|
|
67
|
+
};
|
|
68
|
+
/** Whether `jumpToTheFirstUnreadMessage` prefers the paginator's snapshot or the channel read state. */
|
|
69
|
+
export type UnreadReferencePolicy = 'snapshot' | 'read-state-only';
|
|
70
|
+
/**
|
|
71
|
+
* Paginator fields settable through the declarative tree. Single source of truth lives with the
|
|
72
|
+
* paginator itself (`DeclarativePaginatorConfig` in `BasePaginator`), so the tree and the paginator's
|
|
73
|
+
* own `initializeConfig` can never accept different sets of fields.
|
|
74
|
+
*
|
|
75
|
+
* Deliberately excluded there:
|
|
76
|
+
* - `itemIndex` / `createItemIndex` — an index instance and a factory, not configuration. Deep-merging
|
|
77
|
+
* a class instance is unsound, and swapping an index would drop already-loaded items.
|
|
78
|
+
* - `doRequest`, `itemOrderComparator`, `deriveCursor` — installed per paginator subclass
|
|
79
|
+
* (`PinnedMessagePaginator` supplies all three). Replace them through a setup function, where the
|
|
80
|
+
* existing value is visible and restorable.
|
|
81
|
+
*
|
|
82
|
+
* `initialCursor` and `initialOffset` are included but read only during construction — see
|
|
83
|
+
* {@link CONSTRUCTION_ONLY_CONFIG_PATHS}.
|
|
84
|
+
*/
|
|
85
|
+
export type { DeclarativePaginatorConfig } from '../pagination/paginators/BasePaginator';
|
|
86
|
+
/** Adds the message-list-only unread reference policy, which is a constructor argument. */
|
|
87
|
+
export type DeclarativeMessagePaginatorConfig = ImportedDeclarativePaginatorConfig & {
|
|
88
|
+
unreadReferencePolicy?: UnreadReferencePolicy;
|
|
89
|
+
};
|
|
90
|
+
export type ChannelDeclarativeConfig = {
|
|
91
|
+
/** Overrides the shared top-level `messageOperations` key for channels only. */
|
|
92
|
+
messageOperations?: Partial<MessageOperationsConfig>;
|
|
93
|
+
messagePaginator?: DeclarativeMessagePaginatorConfig;
|
|
94
|
+
pinnedMessagesPaginator?: ImportedDeclarativePaginatorConfig;
|
|
95
|
+
requestHandlers?: ChannelConfig['requestHandlers'];
|
|
96
|
+
/** Typing indicators, ANDed with the channel type's `typing_events`. */
|
|
97
|
+
typingEvents?: Partial<ChannelConfig['typingEvents']>;
|
|
98
|
+
/** Read receipts, ANDed with the channel type's `read_events`. */
|
|
99
|
+
readEvents?: Partial<ChannelConfig['readEvents']>;
|
|
100
|
+
/** Threaded replies, ANDed with the channel type's `replies`. */
|
|
101
|
+
replies?: Partial<ChannelConfig['replies']>;
|
|
102
|
+
/** Message reminders, ANDed with the channel type's `user_message_reminders`. */
|
|
103
|
+
userMessageReminders?: Partial<ChannelConfig['userMessageReminders']>;
|
|
104
|
+
/** Delivery receipts, ANDed with the channel type's `delivery_events`. */
|
|
105
|
+
deliveryEvents?: Partial<ChannelConfig['deliveryEvents']>;
|
|
106
|
+
};
|
|
107
|
+
export type ThreadDeclarativeConfig = {
|
|
108
|
+
/** Overrides the shared top-level `messageOperations` key for thread replies only. */
|
|
109
|
+
messageOperations?: Partial<MessageOperationsConfig>;
|
|
110
|
+
messagePaginator?: DeclarativeMessagePaginatorConfig;
|
|
111
|
+
requestHandlers?: ThreadConfig['requestHandlers'];
|
|
112
|
+
};
|
|
113
|
+
export type ClientDeclarativeConfig = {
|
|
114
|
+
/**
|
|
115
|
+
* Nested rather than top-level keys: each of these managers has exactly one parent — the client — so
|
|
116
|
+
* there is nothing to say once and reuse, which is what a top-level key buys (**DEC-25**).
|
|
117
|
+
*/
|
|
118
|
+
connectionRecovery?: Partial<ConnectionRecoveryManagerConfig>;
|
|
119
|
+
messageDelivery?: Partial<MessageDeliveryReporterConfig>;
|
|
120
|
+
/**
|
|
121
|
+
* Connection status — specifically, the platform listener that reports the device's network. There
|
|
122
|
+
* is no default outside the browser, so this is how React Native and other hosts supply one.
|
|
123
|
+
* `Partial`, not `DeepPartial`: the only field holds a function, which `DeepPartial` would descend
|
|
124
|
+
* into.
|
|
125
|
+
*/
|
|
126
|
+
networkConnection?: Partial<NetworkConnectionObserverConfig>;
|
|
127
|
+
threads?: Partial<ThreadManagerConfig>;
|
|
128
|
+
/**
|
|
129
|
+
* The WebSocket's timing: connect timeout, ping interval, and the health-check grace period on top of it.
|
|
130
|
+
* These three, and only these, because each was a public mutable field before it was configuration.
|
|
131
|
+
* `Partial`, not `DeepPartial`: every field is a flat number.
|
|
132
|
+
*/
|
|
133
|
+
wsConnection?: Partial<WSConnectionConfig>;
|
|
134
|
+
notifications?: DeepPartial<NotificationManagerConfig>;
|
|
135
|
+
/**
|
|
136
|
+
* `Partial`, not `DeepPartial`: `scheduledOffsetsMs` is a `number[]`, and `DeepPartial` would widen
|
|
137
|
+
* its elements to `number | undefined`, which `ReminderManager.updateConfig` rightly rejects.
|
|
138
|
+
*/
|
|
139
|
+
reminders?: Partial<ReminderManagerConfig>;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Maps a configuration key to its declarative configuration subtree. Augmentable alongside
|
|
143
|
+
* {@link InstanceSetupFunctionArgs}, so a custom key gets declarative configuration on the same terms
|
|
144
|
+
* as a built-in one.
|
|
145
|
+
*
|
|
146
|
+
* **When something gets its own key rather than being nested under a parent** — the rule that decides
|
|
147
|
+
* the shape of this interface:
|
|
148
|
+
*
|
|
149
|
+
* - **One parent type ⇒ nest it.** `channel.pinnedMessagesPaginator`, `channel.cooldownTimer`, the
|
|
150
|
+
* composer's own sub-managers. There is only one place it can be reached from.
|
|
151
|
+
* - **Several parent types, and the configuration means the same thing under each ⇒ own key.**
|
|
152
|
+
* `MessageComposer` hangs off a `Channel`, a `Thread`, *and* a message (the React SDK builds
|
|
153
|
+
* message-scoped composers for editing). `drafts.enabled` means the same in all three, so nesting it
|
|
154
|
+
* under `channel` would silently miss two thirds of the composers.
|
|
155
|
+
* - **Several parent types, but the configuration is inherently parent-specific ⇒ nest it anyway.**
|
|
156
|
+
* No built-in falls here today. It is kept as a case because it is the one that decides against a shared
|
|
157
|
+
* key, and the next entity to arrive may need it.
|
|
158
|
+
* - **Several parent types, mixed ⇒ both.** A shared top-level key for what means the same thing, plus
|
|
159
|
+
* per-parent paths that override it field by field (see {@link mergeDeclarativeMessageOperationsConfig}).
|
|
160
|
+
* Both shared keys are here: `MessagePaginator` backs the channel message list *and* thread replies
|
|
161
|
+
* (`stateThrottleMs` / `retryCount` have no reason to differ, `pageSize` legitimately does), and
|
|
162
|
+
* `MessageOperations` backs channel *and* thread sends. `messageOperations` was briefly nested under
|
|
163
|
+
* `channel` on the reasoning that a channel send and a thread reply are different operations — which made
|
|
164
|
+
* `thread.messageOperations` unconfigurable entirely (**DV-15**). Counting parents is the check.
|
|
165
|
+
*/
|
|
166
|
+
export type InstanceConfigTree = {
|
|
167
|
+
channel: ChannelDeclarativeConfig;
|
|
168
|
+
client: ClientDeclarativeConfig;
|
|
169
|
+
/**
|
|
170
|
+
* Constructed by whoever needs it — the React SDK's `useLiveLocationSharingManager`, or an app
|
|
171
|
+
* directly — never by this package. It reaches its configuration the way a `MessageComposer` does, by
|
|
172
|
+
* registering itself against this key, so its owner does not have to thread a slice through.
|
|
173
|
+
*/
|
|
174
|
+
liveLocationManager: Partial<LiveLocationManagerConfig>;
|
|
175
|
+
messageComposer: DeepPartial<MessageComposerConfig>;
|
|
176
|
+
/**
|
|
177
|
+
* Applies to **every** `MessageOperations` — the channel's and every thread's, since messages are sent
|
|
178
|
+
* from both. `channel.messageOperations` and `thread.messageOperations` override it per parent.
|
|
179
|
+
*/
|
|
180
|
+
messageOperations: Partial<MessageOperationsConfig>;
|
|
181
|
+
/**
|
|
182
|
+
* Applies to **every** `MessagePaginator` — the channel message list and thread replies alike.
|
|
183
|
+
* `channel.messagePaginator` and `thread.messagePaginator` override it per parent.
|
|
184
|
+
*
|
|
185
|
+
* `channel.pinnedMessagesPaginator` is deliberately **not** included: it has a single parent, so by
|
|
186
|
+
* the rule above it stays nested. It is also a different class (`PinnedMessagePaginator`, with its own
|
|
187
|
+
* ordering and endpoint) rather than a `MessagePaginator`.
|
|
188
|
+
*/
|
|
189
|
+
messagePaginator: DeclarativeMessagePaginatorConfig;
|
|
190
|
+
/**
|
|
191
|
+
* Same story as {@link InstanceConfigTree.liveLocationManager}, with one caveat: a `SearchController`
|
|
192
|
+
* only reaches this key when it was constructed with a `client` — it is the one configurable class the
|
|
193
|
+
* SDK does not hand a client to. See `SearchControllerOptions.client`.
|
|
194
|
+
*/
|
|
195
|
+
searchController: Partial<SearchControllerConfig>;
|
|
196
|
+
thread: ThreadDeclarativeConfig;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Every key that takes **declarative configuration** — {@link InstanceSetupKey} plus the two that are
|
|
200
|
+
* configuration-only.
|
|
201
|
+
*
|
|
202
|
+
* Closed for the same reason, and {@link InstanceConfigTree} is likewise a type alias, so this set is
|
|
203
|
+
* fixed by the package.
|
|
204
|
+
*/
|
|
205
|
+
export type InstanceConfigKey = keyof InstanceConfigTree;
|
|
206
|
+
export type InstanceConfigOf<K extends InstanceConfigKey> = InstanceConfigTree[K];
|
|
207
|
+
export type InstanceConfigState<K extends InstanceConfigKey = InstanceConfigKey> = {
|
|
208
|
+
config: DeepPartial<InstanceConfigOf<K>> | null;
|
|
53
209
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { InstanceConfigurationRegistry } from '../InstanceConfigurationRegistry';
|
|
2
|
+
import type { InstanceConfigKey, InstanceConfigOf, InstanceSetupFunctionArgsOf, InstanceSetupKey } from '../types';
|
|
3
|
+
import type { DeepPartial } from '../../types.utility';
|
|
4
|
+
import type { Unsubscribe } from '@stream-io/state-store';
|
|
5
|
+
/** @internal */
|
|
6
|
+
export type ApplyInstanceConfigurationParams<K extends InstanceSetupKey> = {
|
|
7
|
+
/** The instance's argument for its setup function — `{ channel }`, `{ composer }`, and so on. */
|
|
8
|
+
args: InstanceSetupFunctionArgsOf<K>;
|
|
9
|
+
/** The client's configuration registry, i.e. `client.config`. */
|
|
10
|
+
config: InstanceConfigurationRegistry;
|
|
11
|
+
key: K;
|
|
12
|
+
/**
|
|
13
|
+
* Other keys this instance derives from. `Channel` and `Thread` both read the shared `messagePaginator`
|
|
14
|
+
* and `messageOperations` keys, so a change there has to re-run this instance's own cycle rather than
|
|
15
|
+
* only re-deriving: re-deriving alone would drop the setup function's overrides, since tier 2 is
|
|
16
|
+
* applied after tier 1.
|
|
17
|
+
*
|
|
18
|
+
* Keys rather than stores, which buys two things beyond brevity. The instance is registered as a
|
|
19
|
+
* live instance of each, so `hasLiveInstances` is true for a shared key and its construction-only paths get
|
|
20
|
+
* same late-registration warning the per-parent slices already got. And there is no longer a structural
|
|
21
|
+
* store type needed to work around `StateStore`'s invariance.
|
|
22
|
+
*/
|
|
23
|
+
alsoWatch?: readonly InstanceConfigKey[];
|
|
24
|
+
/**
|
|
25
|
+
* Applies a declarative configuration slice to the instance. Omit it if the instance has no
|
|
26
|
+
* declarative surface and only wants the setup function.
|
|
27
|
+
*
|
|
28
|
+
* Called on every cycle, **including when this key has no configuration of its own** — an instance may
|
|
29
|
+
* derive from other inputs too (`alsoWatch`, or the server), so it has to be told to re-derive rather
|
|
30
|
+
* than being skipped. Hence the optional argument.
|
|
31
|
+
*/
|
|
32
|
+
applyConfig?: (config?: DeepPartial<InstanceConfigOf<K>>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The instance's own `initializeConfig`, bound. Invoked by `config.reset()` after both slots are
|
|
35
|
+
* cleared, so the instance re-derives its configuration from current inputs. Omit it to get
|
|
36
|
+
* clear-registrations-only reset semantics.
|
|
37
|
+
*/
|
|
38
|
+
reinitializeConfig?: () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Subscribes one instance to the configuration registered for its key, and returns the unsubscribe.
|
|
42
|
+
*
|
|
43
|
+
* This is the single place the *subscription* semantics live, so every configured instance behaves
|
|
44
|
+
* identically:
|
|
45
|
+
*
|
|
46
|
+
* - applies whatever is already registered, immediately;
|
|
47
|
+
* - re-applies on every change to either slot, declarative configuration first and the setup function
|
|
48
|
+
* second, so a setup function always wins for the same field;
|
|
49
|
+
* - runs the previous setup function's teardown before re-applying, and again on unsubscribe;
|
|
50
|
+
* - contains errors — a throwing setup function, teardown or applier is logged and never propagates,
|
|
51
|
+
* so it cannot break `client.channelManager.ensure()` or a `Thread` construction.
|
|
52
|
+
*
|
|
53
|
+
* Not exported from the package. It only does anything for a key in {@link InstanceSetupKey}, and those
|
|
54
|
+
* keys all belong to classes this package constructs, so there is no caller outside it. `ConfigController`
|
|
55
|
+
* _is_ exported, because resolution is reusable on its own — see `docs/instance-configuration.md` §6.
|
|
56
|
+
*
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
export declare const applyInstanceConfiguration: <K extends InstanceSetupKey>({ alsoWatch, applyConfig, args, config: service, key, reinitializeConfig, }: ApplyInstanceConfigurationParams<K>) => Unsubscribe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const copyConfigPatch: <T>(value: T) => T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DeclarativePaginatorConfig } from '../../pagination/paginators/BasePaginator';
|
|
2
|
+
import type { MessageOperationsConfig } from '../../messageOperations/MessageOperations';
|
|
3
|
+
import type { DeclarativeMessagePaginatorConfig } from '../types';
|
|
4
|
+
/** Layers `channel.messageOperations` / `thread.messageOperations` over the shared `messageOperations` key. */
|
|
5
|
+
export declare const mergeDeclarativeMessageOperationsConfig: (general?: Partial<MessageOperationsConfig>, specific?: Partial<MessageOperationsConfig>) => Partial<MessageOperationsConfig> | undefined;
|
|
6
|
+
/** Layers `channel.messagePaginator` / `thread.messagePaginator` over the shared `messagePaginator` key. */
|
|
7
|
+
export declare const mergeDeclarativePaginatorConfig: (general?: DeclarativeMessagePaginatorConfig, specific?: DeclarativeMessagePaginatorConfig) => DeclarativeMessagePaginatorConfig | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Drops the construction-only arguments from a message-paginator slice, leaving only what is actually
|
|
10
|
+
* paginator *configuration*.
|
|
11
|
+
*
|
|
12
|
+
* `unreadReferencePolicy` rides in the same subtree for the integrator's convenience, but it is not a
|
|
13
|
+
* `BasePaginatorConfig` field — `MessagePaginator` reads it once into a private member. Passed through to
|
|
14
|
+
* `initializeConfig` it landed in the published `config` as an untyped key that nothing reads, and a
|
|
15
|
+
* registration arriving after construction made resolved configuration *contradict* behaviour: the
|
|
16
|
+
* construction-only warning correctly said the value would not apply, and then
|
|
17
|
+
* `paginator.config.unreadReferencePolicy` reported it as though it had. A settings UI reading resolved
|
|
18
|
+
* config showed `read-state-only` for a paginator behaving as `snapshot`.
|
|
19
|
+
*
|
|
20
|
+
* So the owning `Channel` / `Thread` splits the slice: the constructor argument goes to the constructor,
|
|
21
|
+
* and only this half reaches the paginator's configuration. Both already read the policy separately, so
|
|
22
|
+
* nothing is lost.
|
|
23
|
+
*/
|
|
24
|
+
export declare const toDeclarativePaginatorConfig: (slice?: DeclarativeMessagePaginatorConfig) => DeclarativePaginatorConfig | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively freezes a package-level default configuration object.
|
|
3
|
+
*
|
|
4
|
+
* **Why a runtime guard rather than a type.** Resolved configuration is built by deep-merging over these
|
|
5
|
+
* constants, and the merge only *copies* a subtree that some layer actually touches — so a subtree nobody
|
|
6
|
+
* configured stays identical by reference to the module-level default, and is reachable through the
|
|
7
|
+
* instance's public `config` getter. A write through it therefore changed the default for every instance
|
|
8
|
+
* of every client in the process, including ones created afterwards. `Readonly<T>` cannot catch that: it
|
|
9
|
+
* is shallow, so it rejects `config.pageSize = 5` but accepts `config.drafts.enabled = true` — and the
|
|
10
|
+
* nested form is the one that reaches shared state. In ESM, which is always strict, a write to a frozen
|
|
11
|
+
* object throws a `TypeError` at the offending line instead of silently succeeding somewhere else.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately lives in its own module rather than `src/utils.ts`: that barrel is `vi.mock`ed wholesale by
|
|
14
|
+
* some suites, and a default-config constant must not depend on which of its exports a test happens to
|
|
15
|
+
* stub.
|
|
16
|
+
*
|
|
17
|
+
* Functions are frozen as values but not walked — a function's `prototype` is not configuration. Freezing
|
|
18
|
+
* is idempotent and stops at anything already frozen, so shared sub-configs cost one visit.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
export declare const deepFreezeConfig: <T>(value: T) => Readonly<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './serverAuthority';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DeepPartial } from '../../types.utility';
|
|
2
|
+
/**
|
|
3
|
+
* The fields a server decides for some configurable object — a partial configuration holding *only* those
|
|
4
|
+
* fields, with the value the server currently reports.
|
|
5
|
+
*
|
|
6
|
+
* Only server-decided fields may appear. The merge below lets any scalar on this side win, so an
|
|
7
|
+
* unrelated field smuggled in here would override the caller's value while looking like a server
|
|
8
|
+
* restriction.
|
|
9
|
+
*/
|
|
10
|
+
export type ServerRestrictions<TConfig extends object> = DeepPartial<TConfig>;
|
|
11
|
+
/**
|
|
12
|
+
* Numeric ceilings the server imposes — a partial configuration holding only fields where the server states
|
|
13
|
+
* a *maximum*, such as a channel type's `max_message_length`.
|
|
14
|
+
*
|
|
15
|
+
* Separate from {@link ServerRestrictions} because the two combine differently, and putting a ceiling in the
|
|
16
|
+
* wrong bucket is a silent bug rather than a type error: a restriction *replaces* the requested value, which
|
|
17
|
+
* for a limit would widen a caller who deliberately asked for something stricter.
|
|
18
|
+
*/
|
|
19
|
+
export type ServerUpperBounds<TConfig extends object> = DeepPartial<TConfig>;
|
|
20
|
+
/**
|
|
21
|
+
* Applies a server's restrictions to a configuration a caller asked for, so the result never claims more
|
|
22
|
+
* than the server allows.
|
|
23
|
+
*
|
|
24
|
+
* **Why this is a named function rather than an inline merge.** It has to run on *every* route by which a
|
|
25
|
+
* configuration can change — construction, the declarative tree, a setup function, a direct
|
|
26
|
+
* `updateConfig` — because a restriction applied only at construction holds until the first time anything
|
|
27
|
+
* updates the configuration and then silently stops holding. `MessageComposer` learned this the hard way:
|
|
28
|
+
* only its `deriveConfig` applied the restrictions, so registering `location.enabled: true` on a running
|
|
29
|
+
* app widened past a `shared_locations: false` server and produced a composer offering a feature the API
|
|
30
|
+
* rejects (**DV-16**).
|
|
31
|
+
*
|
|
32
|
+
* **What it deliberately does not do.** It knows nothing about *where* restrictions come from. Reading
|
|
33
|
+
* them is the entity's job, because only the entity knows what to ask — a composer reads its channel's
|
|
34
|
+
* `serverConfig`, something else might read capabilities — and the answer depends on an instance that
|
|
35
|
+
* exists. That is also why this does not live in `InstanceConfigurationRegistry`: that service merges
|
|
36
|
+
* declarative layers before any instance exists, and its merges follow the opposite rule (a more specific
|
|
37
|
+
* layer *may* re-enable what a broader one disabled), which rule 1 would break.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Inside a configurable class, on every path that resolves configuration:
|
|
42
|
+
* this.configState.partialNext(
|
|
43
|
+
* mergeServerRestrictions(requestedConfig, {
|
|
44
|
+
* location: { enabled: this.channel.serverConfig?.shared_locations },
|
|
45
|
+
* }),
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const mergeServerRestrictions: <TConfig extends object>(requested: TConfig, restrictions: ServerRestrictions<TConfig>, upperBounds?: ServerUpperBounds<TConfig>) => TConfig;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holds the connection id — the WebSocket's, or the long-poll's after an `enableWSFallback`
|
|
3
|
+
* switch — and lets callers await one that is still being negotiated.
|
|
4
|
+
*
|
|
5
|
+
* The server keys channel watches and presence subscriptions by connection id, and answers `200`
|
|
6
|
+
* while registering nothing when a request that needs one arrives without it. Requests carrying such
|
|
7
|
+
* a subscription therefore have to wait for the handshake — see `requiresConnectionId` in
|
|
8
|
+
* `api-client.ts` for which those are.
|
|
9
|
+
*
|
|
10
|
+
* The id lives here and nowhere else. A copy kept on the socket outlives the socket it belongs to,
|
|
11
|
+
* and a copy in `client.wsConnection.state` cannot be invalidated by a socket that has already been
|
|
12
|
+
* replaced; either way requests go out keyed to a connection the server has torn down. The long-poll
|
|
13
|
+
* keeps no copy either: `WSConnection.disconnect()` reads the id before the socket's `disconnect()`
|
|
14
|
+
* drops it, and hands it to the long-poll's close.
|
|
15
|
+
*
|
|
16
|
+
* {@link StableWSConnection} drives the lifecycle: {@link arm} before a socket opens,
|
|
17
|
+
* {@link resolveConnectionId} on the hello frame, {@link invalidate} when it drops or is closed
|
|
18
|
+
* deliberately, {@link rejectConnectionId} when a reconnect gives up. After an `enableWSFallback`
|
|
19
|
+
* switch, `WSConnectionFallback` drives it the same way instead.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConnectionIdManager {
|
|
22
|
+
connectionId?: string;
|
|
23
|
+
loadConnectionIdPromise?: Promise<string>;
|
|
24
|
+
private resolve?;
|
|
25
|
+
private reject?;
|
|
26
|
+
/**
|
|
27
|
+
* Arms the deferred a connection attempt will settle, so requests issued while the handshake is in
|
|
28
|
+
* flight have something to await.
|
|
29
|
+
*/
|
|
30
|
+
arm: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Publishes the id the server answered the handshake with, releasing anything waiting on one.
|
|
33
|
+
*
|
|
34
|
+
* @param connectionId - The connection id carried by the `connection.ok` event.
|
|
35
|
+
*/
|
|
36
|
+
resolveConnectionId: (connectionId: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Fails anything waiting on an id, for a connection attempt that will not be retried.
|
|
39
|
+
*
|
|
40
|
+
* @param reason - The error to reject pending waiters with.
|
|
41
|
+
*/
|
|
42
|
+
rejectConnectionId: (reason: unknown) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Drops the id without failing anything waiting on one, for a socket that died but will be
|
|
45
|
+
* retried. Arming a fresh deferred is what makes those requests wait for the reconnect rather than
|
|
46
|
+
* race ahead with a dead id.
|
|
47
|
+
*/
|
|
48
|
+
invalidate: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Drops the id and fails any pending waiter, for a socket closed deliberately. The id is dead from
|
|
51
|
+
* that moment, and a request keyed by it would register a subscription on a connection that no
|
|
52
|
+
* longer exists.
|
|
53
|
+
*/
|
|
54
|
+
reset: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* The current id, or a promise for one while the handshake is in flight.
|
|
57
|
+
*
|
|
58
|
+
* Throws when there is neither, because no amount of waiting would produce one: no socket is open
|
|
59
|
+
* and none is being opened.
|
|
60
|
+
*
|
|
61
|
+
* @param signal - Abandons the wait when the caller abandons the request it is waiting to issue.
|
|
62
|
+
* Only the waiting path honours it; an id already in hand is returned either way, and the
|
|
63
|
+
* request layer aborts the call itself.
|
|
64
|
+
*/
|
|
65
|
+
getConnectionId: (signal?: AbortSignal) => string | Promise<string>;
|
|
66
|
+
private settle;
|
|
67
|
+
}
|