stream-chat 10.0.0-rc.9 → 10.0.1
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 +7 -6
- package/dist/cjs/index.browser.js +21653 -19788
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +21693 -19796
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +21651 -19786
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +216 -135
- package/dist/types/CooldownTimer.d.ts +13 -27
- package/dist/types/EventHandlerPipeline.d.ts +18 -38
- package/dist/types/LiveLocationManager.d.ts +24 -52
- package/dist/types/api-client.d.ts +17 -5
- package/dist/types/channel.d.ts +432 -470
- package/dist/types/channel_state.d.ts +68 -112
- package/dist/types/client.d.ts +321 -435
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +31 -125
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +32 -124
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +64 -79
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +14 -36
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +45 -0
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +84 -0
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +82 -0
- package/dist/types/connection/networkConnection/index.d.ts +3 -0
- package/dist/types/connection/networkConnection/reporters.d.ts +20 -0
- package/dist/types/connection/networkConnection/types.d.ts +40 -0
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +137 -0
- package/dist/types/connection/wsConnection/WSConnection.d.ts +105 -0
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +47 -0
- package/dist/types/connection/wsConnection/config.d.ts +31 -0
- package/dist/types/connection/wsConnection/index.d.ts +4 -0
- package/dist/types/connection/wsConnection/types.d.ts +46 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/custom_types.d.ts +0 -2
- package/dist/types/entityStore/EntityStore.d.ts +226 -65
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +19 -33
- package/dist/types/entityStore/index.d.ts +0 -1
- package/dist/types/errors.d.ts +16 -19
- package/dist/types/formatMessageMemo.d.ts +5 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +5 -1
- package/dist/types/gen/chat/ChatApi.d.ts +149 -105
- package/dist/types/gen/models/index.d.ts +2528 -690
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +33 -14
- package/dist/types/index.d.ts +10 -6
- package/dist/types/{i18n/languageNames.d.ts → languageNames.d.ts} +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +24 -0
- package/dist/types/messageComposer/attachmentManager.d.ts +52 -24
- package/dist/types/messageComposer/attachmentUtils.d.ts +23 -0
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +38 -50
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +12 -9
- package/dist/types/messageComposer/messageComposer.d.ts +60 -128
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +10 -1
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +4 -0
- package/dist/types/messageComposer/middleware/messageComposer/commandInjection.d.ts +5 -0
- package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +2 -0
- package/dist/types/messageComposer/middleware/messageComposer/pollOnly.d.ts +6 -0
- package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +5 -0
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +4 -0
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +11 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +19 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +15 -5
- package/dist/types/messageComposer/textComposer.d.ts +14 -7
- package/dist/types/messageComposer/types.d.ts +27 -7
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +27 -80
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +40 -73
- package/dist/types/messageOperations/FailedSendCache.d.ts +29 -0
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +16 -22
- package/dist/types/messageOperations/MessageOperations.d.ts +63 -34
- package/dist/types/messageOperations/applyReactionLocally.d.ts +15 -0
- package/dist/types/messageOperations/createMessageOperations.d.ts +9 -0
- package/dist/types/messageOperations/index.d.ts +6 -4
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +16 -0
- package/dist/types/messageOperations/sendOrdering.d.ts +14 -0
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +20 -0
- package/dist/types/messageOperations/types.d.ts +43 -14
- package/dist/types/middleware.d.ts +10 -0
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +10 -23
- package/dist/types/notifications/types.d.ts +21 -57
- package/dist/types/offline-support/offline_support_api.d.ts +150 -528
- package/dist/types/offline-support/offline_sync_manager.d.ts +21 -42
- package/dist/types/offline-support/queueableOperations.d.ts +35 -37
- package/dist/types/offline-support/types.d.ts +40 -186
- package/dist/types/pagination/FilterBuilder.d.ts +1 -18
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +4 -5
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +19 -5
- package/dist/types/pagination/index.d.ts +1 -0
- package/dist/types/pagination/paginators/BasePaginator.d.ts +604 -550
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +123 -106
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +576 -334
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +239 -131
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +15 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +4 -3
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +44 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +5 -8
- package/dist/types/pagination/paginators/index.d.ts +1 -0
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +34 -8
- package/dist/types/poll_manager.d.ts +12 -2
- package/dist/types/poll_optimistic_votes.d.ts +57 -0
- package/dist/types/reminders/Reminder.d.ts +11 -11
- package/dist/types/reminders/ReminderManager.d.ts +13 -25
- package/dist/types/search/BaseSearchSource.d.ts +10 -8
- package/dist/types/search/ChannelSearchSource.d.ts +16 -0
- package/dist/types/search/MessageSearchSource.d.ts +17 -0
- package/dist/types/search/SearchController.d.ts +26 -28
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +63 -129
- package/dist/types/thread_manager.d.ts +95 -66
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +81 -199
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +31 -11
- package/dist/types/utils/FixedSizeQueueCache.d.ts +8 -11
- package/dist/types/utils/WithSubscriptions.d.ts +6 -16
- package/dist/types/utils/abort.d.ts +17 -0
- package/dist/types/utils/concurrency.d.ts +12 -20
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +33 -57
- package/dist/types/utils.d.ts +72 -91
- package/package.json +14 -40
- package/src/ChannelManager.ts +494 -303
- package/src/CooldownTimer.ts +28 -38
- package/src/EventHandlerPipeline.ts +22 -45
- package/src/LiveLocationManager.ts +37 -76
- package/src/api-client.ts +113 -50
- package/src/campaign.ts +1 -1
- package/src/channel.ts +1067 -1276
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +73 -168
- package/src/client.ts +744 -974
- package/src/client_state.ts +3 -8
- package/src/configuration/ConfigController.ts +42 -158
- package/src/configuration/InstanceConfigurationRegistry.ts +43 -172
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +169 -59
- package/src/configuration/types.ts +69 -92
- package/src/configuration/utils/applyInstanceConfiguration.ts +22 -54
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +111 -0
- package/src/connection/ConnectionRecoveryManager.ts +257 -0
- package/src/connection/index.ts +4 -0
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +204 -0
- package/src/connection/networkConnection/index.ts +3 -0
- package/src/connection/networkConnection/reporters.ts +58 -0
- package/src/connection/networkConnection/types.ts +45 -0
- package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +230 -232
- package/src/connection/wsConnection/WSConnection.ts +270 -0
- package/src/connection/wsConnection/WSConnectionFallback.ts +250 -0
- package/src/connection/wsConnection/config.ts +73 -0
- package/src/connection/wsConnection/index.ts +4 -0
- package/src/connection/wsConnection/types.ts +48 -0
- package/src/constants.ts +6 -5
- package/src/custom_types.ts +0 -1
- package/src/entityStore/EntityStore.ts +415 -79
- package/src/entityStore/StoreBackedItemIndex.ts +37 -41
- package/src/entityStore/index.ts +0 -1
- package/src/errors.ts +39 -20
- package/src/formatMessageMemo.ts +17 -0
- package/src/gen/chat/ChannelApi.ts +122 -36
- package/src/gen/chat/ChatApi.ts +578 -1540
- package/src/gen/models/index.ts +2498 -3383
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +170 -367
- package/src/index.ts +22 -10
- package/src/languageNames.ts +88 -0
- package/src/logger.ts +1 -3
- package/src/messageComposer/CustomDataManager.ts +19 -6
- package/src/messageComposer/LocationComposer.ts +19 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +54 -0
- package/src/messageComposer/attachmentManager.ts +170 -185
- package/src/messageComposer/attachmentUtils.ts +44 -0
- package/src/messageComposer/configuration/configuration.ts +15 -8
- package/src/messageComposer/configuration/types.ts +38 -50
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/linkPreviewsManager.ts +18 -21
- package/src/messageComposer/messageComposer.ts +223 -174
- package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +46 -33
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +4 -1
- package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +6 -0
- package/src/messageComposer/middleware/messageComposer/attachments.ts +76 -5
- package/src/messageComposer/middleware/messageComposer/commandInjection.ts +10 -4
- package/src/messageComposer/middleware/messageComposer/customData.ts +17 -5
- package/src/messageComposer/middleware/messageComposer/index.ts +2 -0
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +22 -12
- package/src/messageComposer/middleware/messageComposer/pollOnly.ts +9 -1
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +12 -12
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +8 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +10 -3
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +21 -9
- package/src/messageComposer/textComposer.ts +37 -57
- package/src/messageComposer/types.ts +39 -11
- package/src/messageDelivery/MessageDeliveryReporter.ts +86 -125
- package/src/messageDelivery/MessageReceiptsTracker.ts +88 -101
- package/src/messageOperations/FailedSendCache.ts +85 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +121 -112
- package/src/messageOperations/MessageOperations.ts +297 -175
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +176 -0
- package/src/messageOperations/index.ts +6 -14
- package/src/messageOperations/reflectReactionEvent.ts +43 -0
- package/src/messageOperations/sendOrdering.ts +25 -0
- package/src/messageOperations/settlePendingAttachmentUploads.ts +98 -0
- package/src/messageOperations/types.ts +51 -13
- package/src/middleware.ts +13 -5
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +19 -28
- package/src/notifications/types.ts +21 -57
- package/src/offline-support/offline_support_api.ts +226 -669
- package/src/offline-support/offline_sync_manager.ts +51 -80
- package/src/offline-support/queueableOperations.ts +98 -73
- package/src/offline-support/types.ts +43 -186
- package/src/pagination/FilterBuilder.ts +1 -22
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +15 -63
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +53 -33
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/index.ts +1 -0
- package/src/pagination/paginators/BasePaginator.ts +1415 -1041
- package/src/pagination/paginators/ChannelPaginator.ts +479 -217
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1351 -772
- package/src/pagination/paginators/MessagePaginator.ts +518 -233
- package/src/pagination/paginators/PinnedMessagePaginator.ts +32 -40
- package/src/pagination/paginators/ReminderPaginator.ts +21 -16
- package/src/pagination/paginators/ThreadPaginator.ts +170 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +16 -19
- package/src/pagination/paginators/index.ts +1 -0
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +177 -98
- package/src/poll_manager.ts +24 -22
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +16 -12
- package/src/reminders/ReminderManager.ts +22 -55
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +19 -25
- package/src/search/ChannelSearchSource.ts +43 -1
- package/src/search/MessageSearchSource.ts +77 -13
- package/src/search/SearchController.ts +39 -36
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +418 -703
- package/src/thread_manager.ts +300 -234
- package/src/token_manager.ts +12 -22
- package/src/types.ts +102 -216
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +64 -18
- package/src/utils/FixedSizeQueueCache.ts +18 -21
- package/src/utils/WithSubscriptions.ts +6 -16
- package/src/utils/abort.ts +45 -0
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +40 -60
- package/src/utils.ts +181 -174
- package/codegen/i18n/callSites.ts +0 -126
- package/codegen/i18n/generate.ts +0 -226
- package/codegen/i18n/guards.ts +0 -178
- package/codegen/i18n/index.ts +0 -29
- package/codegen/i18n/stringMaps.ts +0 -91
- package/codegen/i18n/types.ts +0 -100
- package/dist/cjs/i18n.browser.js +0 -1131
- package/dist/cjs/i18n.browser.js.map +0 -7
- package/dist/cjs/i18n.node.js +0 -1160
- package/dist/cjs/i18n.node.js.map +0 -7
- package/dist/esm/i18n-codegen.mjs +0 -409
- package/dist/esm/i18n-codegen.mjs.map +0 -7
- package/dist/esm/i18n.mjs +0 -1098
- package/dist/esm/i18n.mjs.map +0 -7
- package/dist/types/ConnectionRecoveryManager.d.ts +0 -156
- package/dist/types/connection.d.ts +0 -139
- package/dist/types/entityStore/applyReactionLocally.d.ts +0 -32
- package/dist/types/i18n/Streami18n.d.ts +0 -168
- package/dist/types/i18n/TranslationBuilder.d.ts +0 -70
- package/dist/types/i18n/TranslationStore.d.ts +0 -57
- package/dist/types/i18n/dayjs.d.ts +0 -104
- package/dist/types/i18n/formatters.d.ts +0 -91
- package/dist/types/i18n/index.d.ts +0 -15
- package/dist/types/i18n/translator.d.ts +0 -29
- package/dist/types/i18n/types.d.ts +0 -262
- package/dist/types/i18n-codegen/callSites.d.ts +0 -10
- package/dist/types/i18n-codegen/generate.d.ts +0 -15
- package/dist/types/i18n-codegen/guards.d.ts +0 -61
- package/dist/types/i18n-codegen/index.d.ts +0 -29
- package/dist/types/i18n-codegen/stringMaps.d.ts +0 -14
- package/dist/types/i18n-codegen/types.d.ts +0 -94
- package/dist/types/insights.d.ts +0 -56
- package/dist/types/messageOperations/optimistic.d.ts +0 -118
- package/dist/types/messageOperations/persistence.d.ts +0 -21
- package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
- package/dist/types/store.d.ts +0 -125
- package/src/ConnectionRecoveryManager.ts +0 -293
- package/src/i18n/Streami18n.ts +0 -520
- package/src/i18n/TranslationBuilder.ts +0 -176
- package/src/i18n/TranslationStore.ts +0 -96
- package/src/i18n/dayjs.ts +0 -228
- package/src/i18n/formatters.ts +0 -461
- package/src/i18n/index.ts +0 -15
- package/src/i18n/languageNames.ts +0 -103
- package/src/i18n/translator.ts +0 -76
- package/src/i18n/types.ts +0 -375
- package/src/insights.ts +0 -82
- package/src/messageOperations/optimistic.ts +0 -257
- package/src/messageOperations/persistence.ts +0 -40
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/store.ts +0 -304
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
import { EventHandlerPipeline } from './EventHandlerPipeline';
|
|
2
2
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
3
|
-
import type { EventType } from './types';
|
|
3
|
+
import type { ChannelInput, ChannelStateResponseFields, EventType } from './types';
|
|
4
4
|
import type { ChannelPaginator } from './pagination';
|
|
5
5
|
import type { StreamChat } from './client';
|
|
6
|
-
import type { Unsubscribe } from '
|
|
7
|
-
import { StateStore } from '
|
|
6
|
+
import type { Unsubscribe } from '@stream-io/state-store';
|
|
7
|
+
import { StateStore } from '@stream-io/state-store';
|
|
8
8
|
import type { EventHandlerPipelineHandler, FindEventHandlerParams, InsertEventHandlerPayload, LabeledEventHandler } from './EventHandlerPipeline';
|
|
9
|
-
import
|
|
9
|
+
import { Channel } from './channel';
|
|
10
|
+
import { EntityStore } from './entityStore/EntityStore';
|
|
10
11
|
export type ChannelManagerEventHandlerContext = {
|
|
11
12
|
channelManager: ChannelManager;
|
|
12
13
|
};
|
|
13
14
|
type EventHandlerContext = ChannelManagerEventHandlerContext;
|
|
14
15
|
type SupportedEventType = EventType | (string & {});
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Return a set of paginator ids that should keep/own the item.
|
|
20
|
-
* Returning an empty set means the channel will be removed everywhere.
|
|
17
|
+
* Picks which paginators own a channel that matches several, by returning their IDs. An empty list
|
|
18
|
+
* means every matching paginator keeps it.
|
|
21
19
|
*/
|
|
22
20
|
export type PaginatorOwnershipResolver = (args: {
|
|
23
21
|
channel: Channel;
|
|
24
22
|
matchingPaginators: ChannelPaginator[];
|
|
25
23
|
}) => string[];
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* - If none of the matching paginator ids are in the priority list, all matches are kept (back-compat).
|
|
25
|
+
* Priority-based ownership resolver. `priority` lists paginator IDs from highest to lowest: of the
|
|
26
|
+
* paginators matching a channel, the highest-priority one owns it. If none of them is listed, all
|
|
27
|
+
* keep it.
|
|
31
28
|
*/
|
|
32
29
|
export declare const createPriorityOwnershipResolver: (priority?: string[]) => PaginatorOwnershipResolver;
|
|
33
30
|
export declare const ignoreEventsForUnknownChannels: EventHandlerPipelineHandler<EventHandlerContext>;
|
|
@@ -39,175 +36,272 @@ export type ChannelManagerOptions = {
|
|
|
39
36
|
client: StreamChat;
|
|
40
37
|
paginators?: ChannelPaginator[];
|
|
41
38
|
/**
|
|
42
|
-
* The complete set of event handlers
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* through `addEventHandler` / `setEventHandlers` / `removeEventHandlers`.
|
|
39
|
+
* The complete set of event handlers, replacing the defaults. Start from
|
|
40
|
+
* `ChannelManager.getDefaultHandlers()` (a copy) and enrich it. `client.channelManager` is built
|
|
41
|
+
* without this option: customize it through `addEventHandler` / `setEventHandlers` /
|
|
42
|
+
* `removeEventHandlers`.
|
|
47
43
|
*/
|
|
48
44
|
eventHandlers?: ChannelManagerEventHandlers;
|
|
49
45
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* Empty ownershipResolver array means that the channel is kept in all matching paginators.
|
|
46
|
+
* Picks which paginator(s) own a channel that matches several. Defaults to all of them. A function
|
|
47
|
+
* returns the owning paginator IDs; an array is a priority list (highest first), so the
|
|
48
|
+
* highest-priority match owns the channel, and if none of them is listed all keep it.
|
|
54
49
|
*/
|
|
55
50
|
ownershipResolver?: PaginatorOwnershipResolver | string[];
|
|
56
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* A stored channel, its store key, and what keeps it: its own state (`'watched'`, `'active'`,
|
|
54
|
+
* `'querying-channel'`) and the names of its holders. If none, `releaseUnusedChannels()` removes
|
|
55
|
+
* it.
|
|
56
|
+
*/
|
|
57
|
+
export type ChannelUsage = {
|
|
58
|
+
channel: Channel;
|
|
59
|
+
key: string;
|
|
60
|
+
keptBy: string[];
|
|
61
|
+
};
|
|
57
62
|
export declare class ChannelManager extends WithSubscriptions {
|
|
58
63
|
client: StreamChat;
|
|
59
64
|
state: StateStore<ChannelManagerState>;
|
|
65
|
+
/**
|
|
66
|
+
* Every `Channel`, one per cid (a channel created from members sits under a temporary cid until
|
|
67
|
+
* {@link ChannelManager.changeChannelId}). A channel stays until it is deleted, the user is
|
|
68
|
+
* removed from it or logs out, or {@link ChannelManager.releaseUnusedChannels} removes it;
|
|
69
|
+
* removal runs {@link Channel.disconnect}. Lists hold the channels they show by linking them,
|
|
70
|
+
* others by claims.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
readonly channelStore: EntityStore<Channel>;
|
|
60
75
|
protected _pipelines: Map<SupportedEventType, EventHandlerPipeline<ChannelManagerEventHandlerContext>>;
|
|
61
76
|
protected ownershipResolver?: PaginatorOwnershipResolver;
|
|
62
77
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* Keys = already wrapped (so re-inserting does not wrap twice); values = what to restore on
|
|
71
|
-
* removal, since a detached paginator must stop applying rules resolved against lists it left.
|
|
72
|
-
* Weakly keyed so a dropped paginator is not kept alive by this manager.
|
|
78
|
+
* Instances replaced by a stored one ({@link ChannelManager.supersedeChannel}). Not in the store,
|
|
79
|
+
* so they are disconnected at logout ({@link ChannelManager.clearChannels}).
|
|
80
|
+
*/
|
|
81
|
+
private readonly supersededChannels;
|
|
82
|
+
/**
|
|
83
|
+
* The `filterQueryResults` each registered paginator had before `wrapPaginatorFiltering` wrapped
|
|
84
|
+
* it. Keys mark paginators already wrapped, values are restored on removal. Weakly keyed.
|
|
73
85
|
*/
|
|
74
86
|
protected filterQueryResultsBeforeWrapping: WeakMap<ChannelPaginator, (items: Channel[]) => Channel[]>;
|
|
75
87
|
protected static readonly defaultEventHandlers: ChannelManagerEventHandlers;
|
|
76
88
|
constructor({ client, eventHandlers, paginators, ownershipResolver, }: ChannelManagerOptions);
|
|
77
89
|
get paginators(): ChannelPaginator[];
|
|
78
|
-
get pipelines(): Map<SupportedEventType, EventHandlerPipeline<EventHandlerContext>>;
|
|
79
|
-
private get ctx();
|
|
80
90
|
/**
|
|
81
|
-
* Returns
|
|
82
|
-
*
|
|
91
|
+
* Returns the stored channel for a cid.
|
|
92
|
+
*
|
|
93
|
+
* @param cid - The channel's cid.
|
|
94
|
+
* @returns The stored channel, or `undefined` when none is stored.
|
|
83
95
|
*/
|
|
84
|
-
|
|
96
|
+
get(cid: string): Channel | undefined;
|
|
85
97
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* paginator whose filter it matches).
|
|
98
|
+
* The instance a channel list should show for `channel`: the one that superseded it, else the one
|
|
99
|
+
* stored under its cid, else `channel` itself, so a list never displaces the stored instance.
|
|
100
|
+
* `undefined` when that instance is disconnected (`pendingDisposal`): it receives no events.
|
|
90
101
|
*
|
|
91
|
-
*
|
|
92
|
-
* a chance to create its paginators — their ids are therefore only known later.
|
|
102
|
+
* @internal
|
|
93
103
|
*/
|
|
94
|
-
|
|
104
|
+
resolveListedChannel(channel: Channel): Channel | undefined;
|
|
95
105
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
106
|
+
* Returns every stored channel.
|
|
107
|
+
*
|
|
108
|
+
* @returns The stored channels.
|
|
98
109
|
*/
|
|
99
|
-
|
|
110
|
+
values(): Channel[];
|
|
100
111
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* winners among several matches, only into the owner(s)).
|
|
112
|
+
* Returns the stored channel for `type` and `id`, or creates and stores it (one instance per cid;
|
|
113
|
+
* a stored `pendingDisposal` channel is replaced by a fresh one). Without `id`, the distinct
|
|
114
|
+
* channel between `data.members` (see {@link StreamChat.channel}, which documents both).
|
|
105
115
|
*
|
|
106
|
-
*
|
|
107
|
-
* in the list(s) without a full re-query. `ingestItem` dedupes by cid and inserts in sort
|
|
108
|
-
* order, so calling this repeatedly is safe.
|
|
116
|
+
* Apps call {@link StreamChat.channel}, the public equivalent.
|
|
109
117
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* a
|
|
118
|
+
* @param params.type - The channel type.
|
|
119
|
+
* @param params.id - The channel ID; leave it out for a distinct channel created from members.
|
|
120
|
+
* @param params.data - Data for a new channel (members, custom fields). For a stored channel only
|
|
121
|
+
* `data.custom` is applied.
|
|
122
|
+
* @returns The channel; initialize it with `channel.watch()`.
|
|
123
|
+
* @internal
|
|
113
124
|
*/
|
|
114
|
-
|
|
125
|
+
ensure({ data, id, type, }: {
|
|
126
|
+
type: string;
|
|
127
|
+
id?: string | null;
|
|
128
|
+
data?: ChannelInput;
|
|
129
|
+
}): Channel;
|
|
130
|
+
private ensureById;
|
|
131
|
+
private ensureByMembers;
|
|
115
132
|
/**
|
|
116
|
-
*
|
|
133
|
+
* Returns the channel stored under `cid`, passing it to `hydrate`, or stores and returns the result
|
|
134
|
+
* of `create`.
|
|
117
135
|
*
|
|
118
|
-
*
|
|
119
|
-
* global read. Removal-only: the backend rejects `has_unread: false`, so becoming read can never make
|
|
120
|
-
* a channel belong to a list, and `ingestChannel` would pull unloaded channels into matching ones.
|
|
136
|
+
* @internal
|
|
121
137
|
*/
|
|
122
|
-
|
|
138
|
+
getOrCreateChannel(cid: string, create: () => Channel, hydrate?: (stored: Channel) => void): Channel;
|
|
139
|
+
/**
|
|
140
|
+
* Moves a channel from its temporary cid to the one the server assigned (see `Channel.query`).
|
|
141
|
+
* Returns `false` when `oldCid` isn't stored or `newCid` already holds another channel.
|
|
142
|
+
*
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
changeChannelId(oldCid: string, newCid: string): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* `previous`, created without an ID, was answered with a cid `successor` already holds (stored by
|
|
148
|
+
* an event or a list meanwhile). `successor` stays the one instance and takes over: the response
|
|
149
|
+
* is applied to it like a `queryChannels` result (local messages are never removed),
|
|
150
|
+
* `previous`'s local messages (sending or failed) are added by ID (`successor`'s copy wins), and
|
|
151
|
+
* `previous`'s composer moves over when `previous` is open and `successor` is not.
|
|
152
|
+
*
|
|
153
|
+
* `successor` is marked watched only when the query asked to watch. `previous` is dropped from
|
|
154
|
+
* the store (`storedUnder`) without disconnecting, as it may be on screen, marked superseded
|
|
155
|
+
* (`state.supersededBy`) so its holders switch over, and disconnected at logout.
|
|
156
|
+
*
|
|
157
|
+
* @internal
|
|
158
|
+
*/
|
|
159
|
+
supersedeChannel(previous: Channel, successor: Channel, response: ChannelStateResponseFields, { storedUnder, watch }?: {
|
|
160
|
+
storedUnder?: string;
|
|
161
|
+
watch?: boolean;
|
|
162
|
+
}): void;
|
|
163
|
+
/**
|
|
164
|
+
* Removes every stored channel the app disconnected (`pendingDisposal`), whatever holds it, then
|
|
165
|
+
* every one that is neither watched nor held; lists drop them. Kept: watched channels
|
|
166
|
+
* (`watching`, or `wasWatching` until restored), active ones ({@link Channel.activate}), ones
|
|
167
|
+
* being queried (`Channel.isQueryingChannel`), and ones held in
|
|
168
|
+
* {@link ChannelManager.channelStore} (lists link theirs; threads, the composer cache and channel
|
|
169
|
+
* search hold theirs through claims, {@link EntityStore.addClaim}).
|
|
170
|
+
*
|
|
171
|
+
* The SDK never calls this, as it cannot see channels an app keeps in its own state. Call it when
|
|
172
|
+
* the app is done with them (e.g. after `searchController.dispose()`), and keep a channel your
|
|
173
|
+
* code still uses with {@link Channel.activate} first.
|
|
174
|
+
*/
|
|
175
|
+
releaseUnusedChannels(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Every stored channel with what keeps it, by the rule of
|
|
178
|
+
* {@link ChannelManager.releaseUnusedChannels}. For debugging tools.
|
|
179
|
+
*
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
getChannelUsage(): ChannelUsage[];
|
|
123
183
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
184
|
+
* Removes the channel stored under `cid` whatever uses it, and disconnects it
|
|
185
|
+
* ({@link Channel.disconnect}). Every list showing it drops it too.
|
|
186
|
+
*
|
|
187
|
+
* @internal
|
|
126
188
|
*/
|
|
189
|
+
removeChannel(cid: string): void;
|
|
190
|
+
/**
|
|
191
|
+
* Removes and disconnects ({@link Channel.disconnect}) every stored channel, and every superseded
|
|
192
|
+
* one.
|
|
193
|
+
*
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
clearChannels(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Fans the client-owned `mutedChannels` out to every stored channel's `state.muteStatus` (a
|
|
199
|
+
* channel republishes only when its status changed, as this runs on every `health.check`).
|
|
200
|
+
*
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
reflectMutedChannels(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Resets the AI indicator state to `Idle` on every stored channel. Invoked from
|
|
206
|
+
* `closeConnection`, a deliberate shutdown that triggers no WS event.
|
|
207
|
+
*
|
|
208
|
+
* @internal
|
|
209
|
+
*/
|
|
210
|
+
resetAIStateOnChannels(): void;
|
|
211
|
+
/**
|
|
212
|
+
* Demotes every `Watching` channel to `WasWatching`: the server keys watches by connection ID, so
|
|
213
|
+
* a dropped socket ends them all. Channels stopped on purpose or disconnected stay `NotWatching`.
|
|
214
|
+
* Called when the socket goes unhealthy or offline (`StableWSConnection`, `WSConnectionFallback`)
|
|
215
|
+
* and by `closeConnection()`, whose `disconnect()` writes health through `_applyHealth` and never
|
|
216
|
+
* reaches `_setHealth`.
|
|
217
|
+
*
|
|
218
|
+
* @internal
|
|
219
|
+
*/
|
|
220
|
+
markChannelsWatchInterrupted(): void;
|
|
221
|
+
get pipelines(): Map<SupportedEventType, EventHandlerPipeline<EventHandlerContext>>;
|
|
222
|
+
private get ctx();
|
|
223
|
+
/** Returns a copy of the default handler mapping, to enrich or replace. */
|
|
224
|
+
static getDefaultHandlers(): ChannelManagerEventHandlers;
|
|
225
|
+
/**
|
|
226
|
+
* Sets the rule deciding which paginator(s) own a channel matched by several. Pass paginator IDs
|
|
227
|
+
* (highest priority first) for the built-in priority resolver, a custom resolver, or `undefined`
|
|
228
|
+
* for the default (every matching paginator keeps the channel). A setter because the client
|
|
229
|
+
* builds the manager before the app creates its paginators.
|
|
230
|
+
*/
|
|
231
|
+
setOwnershipResolver(ownershipResolver?: PaginatorOwnershipResolver | string[]): void;
|
|
232
|
+
/** Ids of the paginators that own the channel among the matches. Empty: all of them. */
|
|
233
|
+
resolveOwnership(channel: Channel, matchingPaginators: ChannelPaginator[]): Set<string>;
|
|
234
|
+
/**
|
|
235
|
+
* Routes a channel into the paginator(s) that own it and removes it from any list it no longer
|
|
236
|
+
* belongs to, as for live WS updates. Use it to surface a channel the app just opened (a search
|
|
237
|
+
* result, a new DM) without a re-query; repeated calls are safe. A channel created from members
|
|
238
|
+
* is ignored until its first query gives it an ID. A channel matching no paginator is added
|
|
239
|
+
* nowhere: register a catch-all paginator (empty filter) with the lowest ownership priority as a
|
|
240
|
+
* fallback.
|
|
241
|
+
*/
|
|
242
|
+
ingestChannel(input: Channel): void;
|
|
243
|
+
/**
|
|
244
|
+
* Drops a channel from the lists whose filters it no longer matches, adding it nowhere. For state
|
|
245
|
+
* the client changes without an event naming the channel (e.g. zeroing every unread count on a
|
|
246
|
+
* global read). Removal-only: becoming read cannot make a channel belong to a list (the backend
|
|
247
|
+
* rejects `has_unread: false`).
|
|
248
|
+
*/
|
|
249
|
+
dropFromUnmatchedLists(channel: Channel): void;
|
|
250
|
+
/** Filters a page of query results for `paginator` by ownership (no owners: all matches keep). */
|
|
127
251
|
protected filterItemsByOwnership({ paginator, items, }: {
|
|
128
252
|
paginator: ChannelPaginator;
|
|
129
253
|
items: Channel[];
|
|
130
254
|
}): Channel[];
|
|
131
255
|
/**
|
|
132
|
-
* Makes a registered paginator apply
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* - **WS events / `ingestChannel`** — the manager routes the channel and consults
|
|
137
|
-
* `resolveOwnership` before ingesting, so exclusivity holds by construction.
|
|
138
|
-
* - **A server query** — `paginator.next()` (a `ChannelList` scrolling, `reload()`) queries and
|
|
139
|
-
* ingests on its own; the manager is not involved. Without this wrapper a page would land in
|
|
140
|
-
* every list whose *server-side* filter matched it, so a channel matching both
|
|
141
|
-
* `channels:archived` and `channels:default` would show up in both lists until some later event
|
|
142
|
-
* re-routed it — the exact duplication the resolver exists to prevent.
|
|
143
|
-
*
|
|
144
|
-
* Wrapping (rather than subclassing or a constructor hook) is what lets the manager inject this
|
|
145
|
-
* into paginators it does not construct: `filterQueryResults` is an instance property, so the
|
|
146
|
-
* original is captured here and handed back by `unwrapPaginatorFiltering` when the paginator is
|
|
147
|
-
* detached. The paginator's own filtering runs first and stays authoritative — ownership only ever
|
|
148
|
-
* removes further items, never adds any back.
|
|
149
|
-
*
|
|
150
|
-
* Idempotent: the `WeakMap` guard keeps a re-inserted paginator from being wrapped twice, which
|
|
151
|
-
* would filter the same page repeatedly and, worse, lose the reference to the true original.
|
|
256
|
+
* Makes a registered paginator apply the ownership rules to the pages it fetches itself (server
|
|
257
|
+
* queries bypass the manager), by composing `filterItemsByOwnership` onto its
|
|
258
|
+
* `filterQueryResults`. Its own filtering runs first. Idempotent: wrapping twice would lose the
|
|
259
|
+
* true original.
|
|
152
260
|
*/
|
|
153
261
|
protected wrapPaginatorFiltering(paginator: ChannelPaginator): void;
|
|
154
262
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
* rules: those are resolved against the paginators the manager still holds, so a detached
|
|
158
|
-
* paginator would drop channels owned by lists it is no longer part of.
|
|
263
|
+
* Restores the `filterQueryResults` the paginator had before `wrapPaginatorFiltering`: a detached
|
|
264
|
+
* paginator must not keep applying ownership rules resolved against lists it left.
|
|
159
265
|
*/
|
|
160
266
|
protected unwrapPaginatorFiltering(paginator: ChannelPaginator): void;
|
|
161
267
|
getPaginatorById(id: string): ChannelPaginator | undefined;
|
|
162
268
|
/**
|
|
163
|
-
*
|
|
164
|
-
* `removePaginator` build on
|
|
165
|
-
*
|
|
166
|
-
* `removePaginator` detaches them; a repeated id keeps only its first occurrence.
|
|
269
|
+
* Replaces the whole set of lists in one state update (the primitive `insertPaginator` and
|
|
270
|
+
* `removePaginator` build on). Dropped paginators are detached as `removePaginator` does; a
|
|
271
|
+
* repeated ID keeps only its first occurrence.
|
|
167
272
|
*
|
|
168
273
|
* @param paginators - The lists this manager should hold, in render order.
|
|
169
274
|
*/
|
|
170
275
|
setPaginators(paginators: ChannelPaginator[]): void;
|
|
171
276
|
/**
|
|
172
|
-
*
|
|
173
|
-
* released exactly as `removePaginator` releases it (ownership-filtering wrapper removed,
|
|
174
|
-
* scheduled query canceled, loaded items kept), in a single state update.
|
|
277
|
+
* Detaches every list as `removePaginator` does, in one update.
|
|
175
278
|
*
|
|
176
279
|
* @returns The paginators the manager held, in the order it held them.
|
|
177
280
|
*/
|
|
178
281
|
clearPaginators(): ChannelPaginator[];
|
|
179
282
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
* If index provided → insert (or move) at that index.
|
|
283
|
+
* Inserts a paginator. One already held with the same ID is removed first, so this moves it, or
|
|
284
|
+
* replaces it when it is another instance.
|
|
183
285
|
*
|
|
184
|
-
* @param params - The insertion parameters.
|
|
185
286
|
* @param params.paginator - The paginator to insert or move.
|
|
186
|
-
* @param params.index - Target index
|
|
287
|
+
* @param params.index - Target index, clamped to the list. Defaults to appending.
|
|
187
288
|
*/
|
|
188
289
|
insertPaginator({ paginator, index }: {
|
|
189
290
|
paginator: ChannelPaginator;
|
|
190
291
|
index?: number;
|
|
191
292
|
}): void;
|
|
192
293
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* Its loaded items are left untouched: the paginator can be re-inserted later, or kept and
|
|
198
|
-
* queried on its own. Any query scheduled through `nextDebounced` is canceled, so a list that was
|
|
199
|
-
* just removed does not fire one more request.
|
|
294
|
+
* Removes a paginator: it leaves `state.paginators`, stops receiving WS-driven updates and gets
|
|
295
|
+
* its own `filterQueryResults` back. Its loaded items stay, and a query scheduled through
|
|
296
|
+
* `toTailDebounced` or `toHeadDebounced` is cancelled.
|
|
200
297
|
*
|
|
201
|
-
* @param paginatorOrId - The paginator to remove, or its
|
|
298
|
+
* @param paginatorOrId - The paginator to remove, or its ID.
|
|
202
299
|
* @returns The removed paginator, or `undefined` when this manager did not hold it.
|
|
203
300
|
*/
|
|
204
301
|
removePaginator(paginatorOrId: ChannelPaginator | string): ChannelPaginator | undefined;
|
|
205
302
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* user and become invalid on `disconnectUser`. Each paginator returns to "never queried"
|
|
209
|
-
* (`items: undefined`) with its debounced query canceled. Deliberately not named `resetState` —
|
|
210
|
-
* this manager's own `state` *is* the paginator list, which this must not touch.
|
|
303
|
+
* Discards the loaded data of every registered list but keeps the registrations: each paginator
|
|
304
|
+
* returns to "never queried" (`items: undefined`) with its debounced query cancelled.
|
|
211
305
|
*/
|
|
212
306
|
resetPaginatorStates(): void;
|
|
213
307
|
addEventHandler({ eventType, ...payload }: {
|
|
@@ -221,31 +315,18 @@ export declare class ChannelManager extends WithSubscriptions {
|
|
|
221
315
|
eventType: SupportedEventType;
|
|
222
316
|
handlers: FindEventHandlerParams<EventHandlerContext>[];
|
|
223
317
|
}): void;
|
|
224
|
-
/**
|
|
318
|
+
/** Subscribes to client events. The returned function releases this registration. */
|
|
225
319
|
registerSubscriptions(): Unsubscribe;
|
|
226
320
|
ensurePipeline(eventType: SupportedEventType): EventHandlerPipeline<EventHandlerContext>;
|
|
227
321
|
reload: () => Promise<PromiseSettledResult<void>[]>;
|
|
228
322
|
/**
|
|
229
|
-
* Re-
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* `{ keepPreviousItems: true, reset: 'yes' }` is the non-destructive refresh: `reset` restarts the
|
|
238
|
-
* window at page 1, while `keepPreviousItems` merges the fetched page into the loaded list instead
|
|
239
|
-
* of replacing it and keeps the item index populated — the latter is what stops a concurrent
|
|
240
|
-
* offline-replay ingest from rebuilding the list out of a cleared index. Notably NOT `silent`: the
|
|
241
|
-
* `isLoading` transition it would suppress is the in-flight guard that keeps a second overlapping
|
|
242
|
-
* query from being issued.
|
|
243
|
-
*
|
|
244
|
-
* Distinct from {@link ChannelManager.reload}, which is a destructive `reset` that blanks each list
|
|
245
|
-
* to its loading state.
|
|
246
|
-
*
|
|
247
|
-
* Paginators that were never queried are skipped: they run their own first query when they mount,
|
|
248
|
-
* and querying them here would race it.
|
|
323
|
+
* Re-runs every loaded list's own first-page query, the channel-list half of connection recovery
|
|
324
|
+
* ({@link ConnectionRecoveryManager}). The page's channels are re-watched (`queryChannels`
|
|
325
|
+
* watches by default), those below it come back through `restoreInterruptedWatch`.
|
|
326
|
+
* Never-queried paginators are skipped: they run their own first query on mount, and querying them
|
|
327
|
+
* here would race it. Unlike {@link ChannelManager.reload}, it merges the page into the loaded
|
|
328
|
+
* list (`keepPreviousItems`) instead of blanking it. Its pages are `silent` so paging is held while it
|
|
329
|
+
* runs and a recovery asked for meanwhile supersedes it (see `ChannelPaginator.recoverLoadedItems`).
|
|
249
330
|
*/
|
|
250
331
|
recover: () => Promise<PromiseSettledResult<void>[]>;
|
|
251
332
|
}
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
|
+
import type { TimestampNS } from './types';
|
|
2
3
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
3
4
|
import type { Channel } from './channel';
|
|
4
5
|
export type CooldownTimerState = {
|
|
5
|
-
/**
|
|
6
|
-
* Slow mode cooldown interval in seconds. Change reported via channel.updated WS event.
|
|
7
|
-
*/
|
|
6
|
+
/** Slow mode cooldown interval in seconds. Change reported via channel.updated WS event. */
|
|
8
7
|
cooldownConfigSeconds: number;
|
|
9
|
-
/**
|
|
10
|
-
* Whether the current user can skip slow mode. Change is not reported via WS.
|
|
11
|
-
*/
|
|
8
|
+
/** Whether the current user can skip slow mode. Change is not reported via WS. */
|
|
12
9
|
canSkipCooldown: boolean;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
ownLatestMessageTimestamp?: number;
|
|
18
|
-
/**
|
|
19
|
-
* Remaining cooldown in whole seconds (rounded).
|
|
20
|
-
*/
|
|
10
|
+
/** Creation time of the current user's latest message in this channel, in unix nanoseconds. */
|
|
11
|
+
ownLatestMessageTimestamp?: TimestampNS;
|
|
12
|
+
/** Remaining cooldown in whole seconds (rounded). */
|
|
21
13
|
cooldownRemaining: number;
|
|
22
14
|
};
|
|
23
15
|
export declare class CooldownTimer extends WithSubscriptions {
|
|
@@ -30,28 +22,22 @@ export declare class CooldownTimer extends WithSubscriptions {
|
|
|
30
22
|
get cooldownConfigSeconds(): number;
|
|
31
23
|
get cooldownRemaining(): number;
|
|
32
24
|
get canSkipCooldown(): boolean;
|
|
33
|
-
get ownLatestMessageTimestamp():
|
|
25
|
+
get ownLatestMessageTimestamp(): TimestampNS | undefined;
|
|
34
26
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* `Channel` calls this right after constructing the timer and unregisters it in `_disconnect`, the same
|
|
39
|
-
* way it drives `messageReceiptsTracker`. That replaces four imperative `cooldownTimer.refresh()` calls
|
|
40
|
-
* in `Channel`, and the three WS-event handlers that used to live here — which duplicated those calls
|
|
41
|
-
* and never ran, because nothing registered them. Between them the two arrangements still missed every
|
|
42
|
-
* `query()`, and any `updatePartial` that changed `cooldown` without changing capabilities.
|
|
27
|
+
* Derives the timer from `channel.state` (`cooldown`, `ownCapabilities`) and the message
|
|
28
|
+
* paginator's store (the current user's latest message). `Channel` registers it on construction
|
|
29
|
+
* and unregisters it in `disconnect`.
|
|
43
30
|
*/
|
|
44
31
|
registerSubscriptions: () => void;
|
|
45
32
|
setCooldownRemaining: (cooldownRemaining: number) => void;
|
|
46
33
|
clearTimeout: () => void;
|
|
47
34
|
refresh: () => void;
|
|
48
35
|
/**
|
|
49
|
-
*
|
|
50
|
-
* Prefer calling this when you already know it (e.g. from an event).
|
|
36
|
+
* Sets the own latest message timestamp and recomputes the remaining time.
|
|
51
37
|
*
|
|
52
38
|
* @param timestamp - Unix nanoseconds, as the API sends it.
|
|
53
39
|
*/
|
|
54
|
-
setOwnLatestMessageTimestamp: (timestamp:
|
|
40
|
+
setOwnLatestMessageTimestamp: (timestamp: TimestampNS | undefined) => void;
|
|
55
41
|
private getOwnUserId;
|
|
56
42
|
private findOwnLatestMessageTimestamp;
|
|
57
43
|
private recalculate;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { Event, EventType } from './types';
|
|
2
2
|
import type { KeysOfUnion, ValueOfUnion } from './types.utility';
|
|
3
|
-
import type { Unsubscribe } from '
|
|
3
|
+
import type { Unsubscribe } from '@stream-io/state-store';
|
|
4
|
+
type EventObject = Extract<Event, object>;
|
|
4
5
|
/**
|
|
5
|
-
* Flat
|
|
6
|
-
*
|
|
7
|
-
* Handlers route without narrowing, which `Event` does not allow — it is a discriminated union whose
|
|
8
|
-
* `{ type: '*' } & CustomEvent` member has none of the channel fields, and it admits bare custom-event
|
|
9
|
-
* strings (hence the `unknown` hop in `processOne`). Derived from that union, so a new generated field
|
|
10
|
-
* is routable without widening anything by hand.
|
|
6
|
+
* Flat view of an event for routing without narrowing: every field any `Event` member can carry,
|
|
7
|
+
* all optional. Derived from the `Event` union, so new generated fields are routable automatically.
|
|
11
8
|
*/
|
|
12
|
-
type EventObject = Extract<Event, object>;
|
|
13
9
|
export type PipelineEvent = {
|
|
14
10
|
type: EventType | (string & {});
|
|
15
11
|
} & {
|
|
@@ -51,50 +47,34 @@ export declare class EventHandlerPipeline<CTX extends Record<string, unknown> =
|
|
|
51
47
|
get size(): number;
|
|
52
48
|
findIndex({ handler, idMatch }: FindEventHandlerParams<CTX>): number;
|
|
53
49
|
/**
|
|
54
|
-
*
|
|
50
|
+
* Inserts a handler into the pipeline. With `replace` and an in-bounds index it overwrites the
|
|
51
|
+
* handler there instead.
|
|
55
52
|
*
|
|
56
|
-
* - If `replace` is `true` and the index is within bounds, the existing handler
|
|
57
|
-
* at that position will be replaced by the new one.
|
|
58
|
-
* - If `revertOnUnsubscribe` is also `true`, then calling the returned
|
|
59
|
-
* unsubscribe will both remove the inserted handler *and* restore the
|
|
60
|
-
* previously replaced handler at the same index.
|
|
61
|
-
* - If `replace` is `false` (default), the new handler is inserted at the index
|
|
62
|
-
* (or appended if the index is greater than the pipeline size). Unsubscribe
|
|
63
|
-
* will only remove this handler.
|
|
64
|
-
*
|
|
65
|
-
* @param payload - Insertion options.
|
|
66
53
|
* @param payload.handle - The handler function to insert.
|
|
67
|
-
* @param payload.
|
|
68
|
-
* @param payload.
|
|
69
|
-
* @param payload.
|
|
70
|
-
* @
|
|
54
|
+
* @param payload.id - The handler ID. Defaults to a generated UUID.
|
|
55
|
+
* @param payload.index - Target index, clamped to the pipeline size. Defaults to appending.
|
|
56
|
+
* @param payload.replace - Whether to replace the handler at `index` instead of inserting.
|
|
57
|
+
* @param payload.revertOnUnsubscribe - Whether unsubscribing restores the replaced handler.
|
|
58
|
+
* @returns An unsubscribe function that removes the handler and, with `revertOnUnsubscribe`, puts
|
|
59
|
+
* back the one it replaced.
|
|
71
60
|
*/
|
|
72
61
|
insert({ handle, id, index, replace, revertOnUnsubscribe, }: InsertEventHandlerPayload<CTX>): Unsubscribe;
|
|
73
62
|
/**
|
|
74
|
-
*
|
|
75
|
-
* - handler function identity or
|
|
76
|
-
* - by id that could be an exact match or
|
|
77
|
-
* - match by regexp.
|
|
63
|
+
* Removes every matching handler.
|
|
78
64
|
*
|
|
79
|
-
* @param params -
|
|
65
|
+
* @param params - Matches by handler function identity, exact ID or ID regexp.
|
|
80
66
|
*/
|
|
81
67
|
remove(params: FindEventHandlerParams<CTX>): void;
|
|
82
68
|
replaceAll(handlers: LabeledEventHandler<CTX>[]): void;
|
|
83
69
|
clear(): void;
|
|
84
70
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* event’s processing, while the internal chain continues (errors won’t break it).
|
|
71
|
+
* Queues an event. Events are processed serially in call order. The promise settles for this
|
|
72
|
+
* event only, a rejection does not break the queue.
|
|
88
73
|
*/
|
|
89
74
|
run(event: Event, ctx: CTX): Promise<void>;
|
|
90
|
-
/**
|
|
91
|
-
* Wait until all queued events have been processed.
|
|
92
|
-
*/
|
|
75
|
+
/** Resolves once all queued events have been processed. */
|
|
93
76
|
drain(): Promise<void>;
|
|
94
|
-
/**
|
|
95
|
-
* Process a single event through a stable snapshot of handlers to avoid
|
|
96
|
-
* mid-iteration mutations (insert/remove) affecting this run.
|
|
97
|
-
*/
|
|
77
|
+
/** Runs the event through a snapshot of the handlers, so mid-run changes do not affect it. */
|
|
98
78
|
private processOne;
|
|
99
79
|
}
|
|
100
80
|
export {};
|