stream-chat 10.0.0-rc.8 → 10.0.0
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 +22095 -22290
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +22143 -22298
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +22093 -22288
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +216 -135
- package/dist/types/CooldownTimer.d.ts +16 -27
- package/dist/types/EventHandlerPipeline.d.ts +18 -38
- package/dist/types/LiveLocationManager.d.ts +25 -47
- package/dist/types/api-client.d.ts +17 -5
- package/dist/types/channel.d.ts +435 -500
- package/dist/types/channel_state.d.ts +72 -112
- package/dist/types/client.d.ts +323 -440
- 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 +3 -1
- 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 +2540 -698
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +37 -14
- package/dist/types/index.d.ts +10 -5
- 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 +8 -2
- 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 -123
- 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 +20 -19
- 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 +43 -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 -185
- 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 -327
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +237 -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 +8 -13
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +35 -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 +17 -7
- 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 +67 -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 -197
- 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 +45 -0
- package/dist/types/utils.d.ts +74 -93
- package/package.json +14 -40
- package/src/ChannelManager.ts +494 -303
- package/src/CooldownTimer.ts +46 -59
- package/src/EventHandlerPipeline.ts +22 -45
- package/src/LiveLocationManager.ts +99 -91
- package/src/api-client.ts +113 -50
- package/src/campaign.ts +1 -1
- package/src/channel.ts +1098 -1351
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +81 -174
- package/src/client.ts +755 -970
- 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 -231
- 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 +7 -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 -1752
- package/src/gen/models/index.ts +2566 -3440
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +183 -406
- package/src/index.ts +32 -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 +49 -9
- 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 +234 -179
- 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/sharedLocation.ts +7 -2
- 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 -124
- package/src/messageDelivery/MessageReceiptsTracker.ts +122 -139
- package/src/messageOperations/FailedSendCache.ts +85 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +124 -116
- package/src/messageOperations/MessageOperations.ts +297 -175
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +13 -25
- 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 +231 -681
- package/src/offline-support/offline_sync_manager.ts +51 -90
- package/src/offline-support/queueableOperations.ts +98 -73
- package/src/offline-support/types.ts +43 -185
- 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 +17 -62
- 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 +481 -219
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1362 -775
- package/src/pagination/paginators/MessagePaginator.ts +521 -240
- 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 +18 -15
- 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 +17 -24
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +183 -102
- package/src/poll_manager.ts +24 -22
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +33 -16
- package/src/reminders/ReminderManager.ts +23 -56
- package/src/reminders/ReminderTimer.ts +6 -6
- 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 +430 -712
- package/src/thread_manager.ts +300 -234
- package/src/token_manager.ts +12 -22
- package/src/types.ts +102 -214
- 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 +64 -0
- package/src/utils.ts +227 -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 -26
- 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/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/gen/model-decoders/decoders.ts +0 -2710
- package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
- 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 -249
- package/src/messageOperations/persistence.ts +0 -40
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/store.ts +0 -304
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
1
2
|
import type { StreamChat } from '../client';
|
|
2
3
|
import type { LiveLocationManager, LiveLocationManagerConfig } from '../LiveLocationManager';
|
|
3
4
|
import type { SearchController, SearchControllerConfig } from '../search/SearchController';
|
|
@@ -6,20 +7,17 @@ import type { MessageComposerConfig } from '../messageComposer/configuration/typ
|
|
|
6
7
|
import type { Channel, ChannelConfig } from '../channel';
|
|
7
8
|
import type { Thread, ThreadConfig } from '../thread';
|
|
8
9
|
import type { ReminderManagerConfig } from '../reminders/ReminderManager';
|
|
10
|
+
import type { NotificationManager } from '../notifications/NotificationManager';
|
|
9
11
|
import type { NotificationManagerConfig } from '../notifications/types';
|
|
10
12
|
import type { MessageDeliveryReporterConfig } from '../messageDelivery/MessageDeliveryReporter';
|
|
11
13
|
import type { ThreadManagerConfig } from '../thread_manager';
|
|
12
|
-
import type { ConnectionRecoveryManagerConfig } from '../
|
|
14
|
+
import type { ConnectionRecoveryManagerConfig, NetworkConnectionObserverConfig, WSConnectionConfig } from '../connection';
|
|
13
15
|
import type { MessageOperationsConfig } from '../messageOperations/MessageOperations';
|
|
14
16
|
import type { DeclarativePaginatorConfig as ImportedDeclarativePaginatorConfig } from '../pagination/paginators/BasePaginator';
|
|
15
17
|
import type { DeepPartial } from '../types.utility';
|
|
16
18
|
/**
|
|
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.
|
|
19
|
+
* Maps a configuration key to the argument its setup function receives. A type alias, so the key space
|
|
20
|
+
* is closed to module augmentation.
|
|
23
21
|
*/
|
|
24
22
|
export type InstanceSetupFunctionArgs = {
|
|
25
23
|
channel: {
|
|
@@ -42,24 +40,16 @@ export type InstanceSetupFunctionArgs = {
|
|
|
42
40
|
};
|
|
43
41
|
};
|
|
44
42
|
/**
|
|
45
|
-
* The keys that take a
|
|
46
|
-
*
|
|
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.
|
|
43
|
+
* The keys that take a setup function. A strict subset of {@link InstanceConfigKey}: `messagePaginator`
|
|
44
|
+
* and `messageOperations` take configuration but no setup function, since a channel and each of its
|
|
45
|
+
* threads own one.
|
|
55
46
|
*/
|
|
56
47
|
export type InstanceSetupKey = keyof InstanceSetupFunctionArgs;
|
|
57
48
|
export type InstanceSetupFunctionArgsOf<K extends InstanceSetupKey> = InstanceSetupFunctionArgs[K];
|
|
58
49
|
export type InstanceSetupTearDownFunction = () => void;
|
|
59
50
|
/**
|
|
60
|
-
* Runs against every instance of its class
|
|
61
|
-
*
|
|
62
|
-
* before the setup function is re-applied, and when the instance is disposed of.
|
|
51
|
+
* Runs against every instance of its class, existing and future. Return a function that undoes what you
|
|
52
|
+
* changed: it runs before the setup function is re-applied and when the instance is disposed of.
|
|
63
53
|
*/
|
|
64
54
|
export type InstanceSetupFunction<K extends InstanceSetupKey = InstanceSetupKey> = (args: InstanceSetupFunctionArgsOf<K>) => void | InstanceSetupTearDownFunction;
|
|
65
55
|
export type InstanceSetupState<K extends InstanceSetupKey = InstanceSetupKey> = {
|
|
@@ -68,22 +58,14 @@ export type InstanceSetupState<K extends InstanceSetupKey = InstanceSetupKey> =
|
|
|
68
58
|
/** Whether `jumpToTheFirstUnreadMessage` prefers the paginator's snapshot or the channel read state. */
|
|
69
59
|
export type UnreadReferencePolicy = 'snapshot' | 'read-state-only';
|
|
70
60
|
/**
|
|
71
|
-
* Paginator fields settable through the declarative tree.
|
|
72
|
-
*
|
|
73
|
-
*
|
|
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
|
|
61
|
+
* Paginator fields settable through the declarative tree. Defined in `BasePaginator`, which excludes
|
|
62
|
+
* what is not plain configuration: `itemIndex` / `createItemIndex`, and the per-subclass `doRequest`,
|
|
63
|
+
* `itemOrderComparator` and `deriveCursor` (replace those through a setup function).
|
|
64
|
+
* `initialCursor` and `initialOffset` are read only during construction, see
|
|
83
65
|
* {@link CONSTRUCTION_ONLY_CONFIG_PATHS}.
|
|
84
66
|
*/
|
|
85
67
|
export type { DeclarativePaginatorConfig } from '../pagination/paginators/BasePaginator';
|
|
86
|
-
/** Adds the message-list-only
|
|
68
|
+
/** Adds the message-list-only `unreadReferencePolicy`. */
|
|
87
69
|
export type DeclarativeMessagePaginatorConfig = ImportedDeclarativePaginatorConfig & {
|
|
88
70
|
unreadReferencePolicy?: UnreadReferencePolicy;
|
|
89
71
|
};
|
|
@@ -112,83 +94,86 @@ export type ThreadDeclarativeConfig = {
|
|
|
112
94
|
};
|
|
113
95
|
export type ClientDeclarativeConfig = {
|
|
114
96
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
97
|
+
* Silences the warning `connectUser` / `connectAnonymousUser` log when called server-side, where a
|
|
98
|
+
* connection counts towards MAU and concurrent-connection billing. Read on every connect.
|
|
117
99
|
*/
|
|
100
|
+
allowServerSideConnect?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Axios request configuration (`timeout`, `headers`, `httpsAgent`, ...). Built into the client's axios
|
|
103
|
+
* instance once, at construction; `headers` and `params` are also read on every request. Copied when
|
|
104
|
+
* registered, so mutating the object afterwards has no effect.
|
|
105
|
+
*/
|
|
106
|
+
axiosRequestConfig?: AxiosRequestConfig;
|
|
107
|
+
/** Base URL of the API, such as `https://chat-proxy-dublin.stream-io-api.com`. Read once. */
|
|
108
|
+
baseURL?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Forces browser (`true`) or Node (`false`) mode; detected from the global `window` when absent. Read
|
|
111
|
+
* live, through `client.browser` and `client.node`.
|
|
112
|
+
*/
|
|
113
|
+
browser?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* A pre-built {@link NotificationManager} to use instead of constructing one, to share it between
|
|
116
|
+
* clients or hand over one that already holds notifications. Read once, at construction. The
|
|
117
|
+
* `notifications` slice is still applied to it.
|
|
118
|
+
*/
|
|
119
|
+
notificationManager?: NotificationManager;
|
|
120
|
+
/**
|
|
121
|
+
* When true, `client.user` is kept if `connectUser` fails, so an offline-capable app does not have to
|
|
122
|
+
* call `connectUser` again to retry. Read when a connect fails.
|
|
123
|
+
*/
|
|
124
|
+
persistUserOnConnectionFailure?: boolean;
|
|
118
125
|
connectionRecovery?: Partial<ConnectionRecoveryManagerConfig>;
|
|
119
126
|
messageDelivery?: Partial<MessageDeliveryReporterConfig>;
|
|
127
|
+
/**
|
|
128
|
+
* The platform listener that reports the device's network, which React Native and other hosts supply
|
|
129
|
+
* here. Defaults to browser events, else a reporter that mirrors the WebSocket. `Partial`, not
|
|
130
|
+
* `DeepPartial`: the only field holds a function, which `DeepPartial` would descend into.
|
|
131
|
+
*/
|
|
132
|
+
networkConnection?: Partial<NetworkConnectionObserverConfig>;
|
|
120
133
|
threads?: Partial<ThreadManagerConfig>;
|
|
134
|
+
/** `Partial`, not `DeepPartial`: fields are flat or class instances, which it would descend into. */
|
|
135
|
+
wsConnection?: Partial<WSConnectionConfig>;
|
|
121
136
|
notifications?: DeepPartial<NotificationManagerConfig>;
|
|
122
137
|
/**
|
|
123
138
|
* `Partial`, not `DeepPartial`: `scheduledOffsetsMs` is a `number[]`, and `DeepPartial` would widen
|
|
124
|
-
* its elements to `number | undefined`, which `ReminderManager.updateConfig`
|
|
139
|
+
* its elements to `number | undefined`, which `ReminderManager.updateConfig` rejects.
|
|
125
140
|
*/
|
|
126
141
|
reminders?: Partial<ReminderManagerConfig>;
|
|
127
142
|
};
|
|
128
143
|
/**
|
|
129
|
-
* Maps a configuration key to its declarative configuration subtree.
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* **When something gets its own key rather than being nested under a parent** — the rule that decides
|
|
134
|
-
* the shape of this interface:
|
|
135
|
-
*
|
|
136
|
-
* - **One parent type ⇒ nest it.** `channel.pinnedMessagesPaginator`, `channel.cooldownTimer`, the
|
|
137
|
-
* composer's own sub-managers. There is only one place it can be reached from.
|
|
138
|
-
* - **Several parent types, and the configuration means the same thing under each ⇒ own key.**
|
|
139
|
-
* `MessageComposer` hangs off a `Channel`, a `Thread`, *and* a message (the React SDK builds
|
|
140
|
-
* message-scoped composers for editing). `drafts.enabled` means the same in all three, so nesting it
|
|
141
|
-
* under `channel` would silently miss two thirds of the composers.
|
|
142
|
-
* - **Several parent types, but the configuration is inherently parent-specific ⇒ nest it anyway.**
|
|
143
|
-
* No built-in falls here today. It is kept as a case because it is the one that decides against a shared
|
|
144
|
-
* key, and the next entity to arrive may need it.
|
|
145
|
-
* - **Several parent types, mixed ⇒ both.** A shared top-level key for what means the same thing, plus
|
|
146
|
-
* per-parent paths that override it field by field (see {@link mergeDeclarativeMessageOperationsConfig}).
|
|
147
|
-
* Both shared keys are here: `MessagePaginator` backs the channel message list *and* thread replies
|
|
148
|
-
* (`stateThrottleMs` / `retryCount` have no reason to differ, `pageSize` legitimately does), and
|
|
149
|
-
* `MessageOperations` backs channel *and* thread sends. `messageOperations` was briefly nested under
|
|
150
|
-
* `channel` on the reasoning that a channel send and a thread reply are different operations — which made
|
|
151
|
-
* `thread.messageOperations` unconfigurable entirely (**DV-15**). Counting parents is the check.
|
|
144
|
+
* Maps a configuration key to its declarative configuration subtree. A class with one parent type is
|
|
145
|
+
* nested under that parent. A class held by several parents (`MessageComposer`, `MessagePaginator`,
|
|
146
|
+
* `MessageOperations`) gets its own shared key, and where parents need to differ they override it per
|
|
147
|
+
* field (see {@link mergeDeclarativeMessageOperationsConfig}).
|
|
152
148
|
*/
|
|
153
149
|
export type InstanceConfigTree = {
|
|
154
150
|
channel: ChannelDeclarativeConfig;
|
|
155
151
|
client: ClientDeclarativeConfig;
|
|
156
152
|
/**
|
|
157
|
-
* Constructed by
|
|
158
|
-
*
|
|
159
|
-
* registering itself against this key, so its owner does not have to thread a slice through.
|
|
153
|
+
* Constructed by the integrator or a UI SDK, never by this package. It reaches its configuration by
|
|
154
|
+
* registering itself against this key.
|
|
160
155
|
*/
|
|
161
156
|
liveLocationManager: Partial<LiveLocationManagerConfig>;
|
|
162
157
|
messageComposer: DeepPartial<MessageComposerConfig>;
|
|
163
158
|
/**
|
|
164
|
-
* Applies to
|
|
165
|
-
*
|
|
159
|
+
* Applies to every `MessageOperations`, the channel's and each thread's.
|
|
160
|
+
* `channel.messageOperations` and `thread.messageOperations` override it per parent.
|
|
166
161
|
*/
|
|
167
162
|
messageOperations: Partial<MessageOperationsConfig>;
|
|
168
163
|
/**
|
|
169
|
-
* Applies to
|
|
164
|
+
* Applies to every `MessagePaginator`, the channel message list and thread replies alike.
|
|
170
165
|
* `channel.messagePaginator` and `thread.messagePaginator` override it per parent.
|
|
171
|
-
*
|
|
172
|
-
* `channel.pinnedMessagesPaginator` is deliberately **not** included: it has a single parent, so by
|
|
173
|
-
* the rule above it stays nested. It is also a different class (`PinnedMessagePaginator`, with its own
|
|
174
|
-
* ordering and endpoint) rather than a `MessagePaginator`.
|
|
166
|
+
* `channel.pinnedMessagesPaginator` is not included: it is a different class with a single parent.
|
|
175
167
|
*/
|
|
176
168
|
messagePaginator: DeclarativeMessagePaginatorConfig;
|
|
177
169
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* SDK does not hand a client to. See `SearchControllerOptions.client`.
|
|
170
|
+
* Like {@link InstanceConfigTree.liveLocationManager}, but a `SearchController` reaches this key only
|
|
171
|
+
* when constructed with a `client` (see `SearchControllerOptions.client`).
|
|
181
172
|
*/
|
|
182
173
|
searchController: Partial<SearchControllerConfig>;
|
|
183
174
|
thread: ThreadDeclarativeConfig;
|
|
184
175
|
};
|
|
185
|
-
/**
|
|
186
|
-
* Every key that takes **declarative configuration** — {@link InstanceSetupKey} plus the two that are
|
|
187
|
-
* configuration-only.
|
|
188
|
-
*
|
|
189
|
-
* Closed for the same reason, and {@link InstanceConfigTree} is likewise a type alias, so this set is
|
|
190
|
-
* fixed by the package.
|
|
191
|
-
*/
|
|
176
|
+
/** Every key that takes declarative configuration: {@link InstanceSetupKey} plus the config-only ones. */
|
|
192
177
|
export type InstanceConfigKey = keyof InstanceConfigTree;
|
|
193
178
|
export type InstanceConfigOf<K extends InstanceConfigKey> = InstanceConfigTree[K];
|
|
194
179
|
export type InstanceConfigState<K extends InstanceConfigKey = InstanceConfigKey> = {
|
|
@@ -1,58 +1,36 @@
|
|
|
1
1
|
import type { InstanceConfigurationRegistry } from '../InstanceConfigurationRegistry';
|
|
2
2
|
import type { InstanceConfigKey, InstanceConfigOf, InstanceSetupFunctionArgsOf, InstanceSetupKey } from '../types';
|
|
3
3
|
import type { DeepPartial } from '../../types.utility';
|
|
4
|
-
import type { Unsubscribe } from '
|
|
4
|
+
import type { Unsubscribe } from '@stream-io/state-store';
|
|
5
5
|
/** @internal */
|
|
6
6
|
export type ApplyInstanceConfigurationParams<K extends InstanceSetupKey> = {
|
|
7
|
-
/** The instance's argument for its setup function
|
|
7
|
+
/** The instance's argument for its setup function, such as `{ channel }`. */
|
|
8
8
|
args: InstanceSetupFunctionArgsOf<K>;
|
|
9
|
-
/** The client's configuration registry, i.e. `client.config`. */
|
|
10
9
|
config: InstanceConfigurationRegistry;
|
|
11
10
|
key: K;
|
|
12
11
|
/**
|
|
13
|
-
* Other keys this instance derives from
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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.
|
|
12
|
+
* Other keys this instance derives from (`Channel` and `Thread` read `messagePaginator` and
|
|
13
|
+
* `messageOperations`). A change there re-runs the whole cycle, so the setup function is re-applied
|
|
14
|
+
* over the new values. The instance is also registered as live under each.
|
|
22
15
|
*/
|
|
23
16
|
alsoWatch?: readonly InstanceConfigKey[];
|
|
24
17
|
/**
|
|
25
|
-
* Applies
|
|
26
|
-
*
|
|
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.
|
|
18
|
+
* Applies the declarative slice to the instance. Omit it if the instance only wants the setup function.
|
|
19
|
+
* Called on every cycle, with `undefined` when the key has no configuration, since the instance may
|
|
20
|
+
* derive from other inputs too.
|
|
31
21
|
*/
|
|
32
22
|
applyConfig?: (config?: DeepPartial<InstanceConfigOf<K>>) => void;
|
|
33
23
|
/**
|
|
34
|
-
* The instance's
|
|
35
|
-
*
|
|
36
|
-
* clear-registrations-only reset semantics.
|
|
24
|
+
* The instance's `initializeConfig`, bound. `reset` calls it after clearing both slots. Without it,
|
|
25
|
+
* reset only clears registrations.
|
|
37
26
|
*/
|
|
38
27
|
reinitializeConfig?: () => void;
|
|
39
28
|
};
|
|
40
29
|
/**
|
|
41
|
-
* Subscribes one instance to the configuration registered for its key
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
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.channel()` 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.
|
|
30
|
+
* Subscribes one instance to the configuration registered for its key and returns the unsubscribe.
|
|
31
|
+
* Applies what is registered immediately, then on every change: declarative configuration first and the
|
|
32
|
+
* setup function second (so it wins), running the previous teardown before each re-apply and on
|
|
33
|
+
* unsubscribe. A throwing setup function, teardown or applier is logged, never propagated.
|
|
56
34
|
*
|
|
57
35
|
* @internal
|
|
58
36
|
*/
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies a caller-supplied configuration patch so the stored value shares no mutable object with the
|
|
3
|
+
* caller (`mergeWith` reuses source subtrees verbatim). Plain objects and arrays are copied; everything
|
|
4
|
+
* else (functions, `Date`s, class instances) passes through by reference. Not `structuredClone`, which
|
|
5
|
+
* throws on the functions configuration holds. Cycles terminate and shared references stay shared.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
1
9
|
export declare const copyConfigPatch: <T>(value: T) => T;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
import type { DeclarativePaginatorConfig } from '../../pagination/paginators/BasePaginator';
|
|
2
2
|
import type { MessageOperationsConfig } from '../../messageOperations/MessageOperations';
|
|
3
3
|
import type { DeclarativeMessagePaginatorConfig } from '../types';
|
|
4
|
-
/** Layers `
|
|
4
|
+
/** Layers a per-parent `messageOperations` slice (channel or thread) over the shared key. */
|
|
5
5
|
export declare const mergeDeclarativeMessageOperationsConfig: (general?: Partial<MessageOperationsConfig>, specific?: Partial<MessageOperationsConfig>) => Partial<MessageOperationsConfig> | undefined;
|
|
6
|
-
/** Layers `
|
|
6
|
+
/** Layers a per-parent `messagePaginator` slice (channel or thread) over the shared key. */
|
|
7
7
|
export declare const mergeDeclarativePaginatorConfig: (general?: DeclarativeMessagePaginatorConfig, specific?: DeclarativeMessagePaginatorConfig) => DeclarativeMessagePaginatorConfig | undefined;
|
|
8
8
|
/**
|
|
9
|
-
* Drops
|
|
10
|
-
*
|
|
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.
|
|
9
|
+
* Drops `unreadReferencePolicy` from a message-paginator slice. `MessagePaginator` reads it once as a
|
|
10
|
+
* constructor argument, so leaving it in would make the resolved `config` report a value that does not
|
|
11
|
+
* apply.
|
|
23
12
|
*/
|
|
24
13
|
export declare const toDeclarativePaginatorConfig: (slice?: DeclarativeMessagePaginatorConfig) => DeclarativePaginatorConfig | undefined;
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Recursively freezes a package-level default configuration
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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.
|
|
2
|
+
* Recursively freezes a package-level default configuration. Resolved config shares untouched subtrees
|
|
3
|
+
* with these defaults, so an unfrozen nested write through `config` would change them for every instance
|
|
4
|
+
* in the process (`Readonly<T>` is shallow and cannot catch it). Functions are left as they are.
|
|
19
5
|
*
|
|
20
6
|
* @internal
|
|
21
7
|
*/
|
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
import type { DeepPartial } from '../../types.utility';
|
|
2
2
|
/**
|
|
3
|
-
* The fields a server decides
|
|
4
|
-
*
|
|
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.
|
|
3
|
+
* The fields a server decides, with the values it reports. Include only those: a non-boolean scalar
|
|
4
|
+
* here overrides the caller's, and a boolean is ANDed with it.
|
|
9
5
|
*/
|
|
10
6
|
export type ServerRestrictions<TConfig extends object> = DeepPartial<TConfig>;
|
|
11
7
|
/**
|
|
12
|
-
*
|
|
13
|
-
* a
|
|
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.
|
|
8
|
+
* Fields where the server states a maximum (e.g. `max_message_length`). Separate from
|
|
9
|
+
* {@link ServerRestrictions} because a restriction replaces the value, which would widen a stricter
|
|
10
|
+
* caller.
|
|
18
11
|
*/
|
|
19
12
|
export type ServerUpperBounds<TConfig extends object> = DeepPartial<TConfig>;
|
|
20
13
|
/**
|
|
21
|
-
* Applies
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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.
|
|
14
|
+
* Applies server restrictions to a requested configuration, so the result never claims more than the
|
|
15
|
+
* server allows. Call it on every route that changes a configuration (construction, declarative tree,
|
|
16
|
+
* setup function, `updateConfig`), or the restrictions stop holding at the first update. Reading the
|
|
17
|
+
* restrictions is the entity's job.
|
|
38
18
|
*
|
|
39
19
|
* @example
|
|
40
20
|
* ```ts
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holds the connection ID (the WebSocket's, or the long-poll's after an `enableWSFallback` switch)
|
|
3
|
+
* 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 carries none (see `requiresConnectionId`
|
|
7
|
+
* in `api-client.ts`), so such requests wait for the handshake. The ID lives only here, so a
|
|
8
|
+
* replaced socket cannot leave a stale copy behind.
|
|
9
|
+
*
|
|
10
|
+
* Driven by {@link StableWSConnection}, or by `WSConnectionFallback` after a fallback switch.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ConnectionIdManager {
|
|
13
|
+
connectionId?: string;
|
|
14
|
+
loadConnectionIdPromise?: Promise<string>;
|
|
15
|
+
private resolve?;
|
|
16
|
+
private reject?;
|
|
17
|
+
/** Creates the deferred a connection attempt settles, so mid-handshake requests can await it. */
|
|
18
|
+
arm: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Publishes the ID from the `connection.ok` event and releases anything waiting on one.
|
|
21
|
+
*
|
|
22
|
+
* @param connectionId - The connection ID carried by the `connection.ok` event.
|
|
23
|
+
*/
|
|
24
|
+
resolveConnectionId: (connectionId: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Rejects pending waiters, for a connection attempt that will not be retried.
|
|
27
|
+
*
|
|
28
|
+
* @param reason - The error to reject pending waiters with.
|
|
29
|
+
*/
|
|
30
|
+
rejectConnectionId: (reason: unknown) => void;
|
|
31
|
+
/** Drops the ID for a socket that died but will be retried. New requests wait for the reconnect. */
|
|
32
|
+
invalidate: () => void;
|
|
33
|
+
/** Drops the ID and rejects any pending waiter with a "connection closed" error. */
|
|
34
|
+
reset: () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the connection ID, waiting for the handshake when one is in flight.
|
|
37
|
+
*
|
|
38
|
+
* @param signal - Abandons the wait. Only the waiting path honours it; an ID already in hand is
|
|
39
|
+
* returned either way.
|
|
40
|
+
* @returns The current connection ID, or a promise for it while the handshake is in flight.
|
|
41
|
+
* @throws When no socket is open or being opened.
|
|
42
|
+
*/
|
|
43
|
+
getConnectionId: (signal?: AbortSignal) => string | Promise<string>;
|
|
44
|
+
private settle;
|
|
45
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { WithSubscriptions } from '../utils/WithSubscriptions';
|
|
2
|
+
import type { StreamChat } from '../client';
|
|
3
|
+
import type { StateStore } from '@stream-io/state-store';
|
|
4
|
+
export type ConnectionRecoveryManagerConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the client recovers its own state on reconnect. Set `false` if the app does it itself:
|
|
7
|
+
* `connection.recovered` is still dispatched on every reconnect, and `recover()` still runs a full pass.
|
|
8
|
+
*/
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const DEFAULT_CONNECTION_RECOVERY_MANAGER_CONFIG: ConnectionRecoveryManagerConfig;
|
|
12
|
+
/**
|
|
13
|
+
* After a reconnect, brings what the app is consuming back in line with the server:
|
|
14
|
+
* 1. loaded channel lists re-run their first-page query (`ChannelManager.recover`), re-watching it;
|
|
15
|
+
* 2. active channels reload (`Channel.reload`);
|
|
16
|
+
* 3. active threads reload their replies (`Thread.reload`).
|
|
17
|
+
*
|
|
18
|
+
* It does not sweep the channel store (watches are a bounded server resource). Other channels recover
|
|
19
|
+
* on demand, when an event proves them relevant.
|
|
20
|
+
*
|
|
21
|
+
* Lists and active channels recover on the offline DB's sync-status edge when offline support is on (it
|
|
22
|
+
* lands after pending tasks replay), else when the socket goes online.
|
|
23
|
+
*
|
|
24
|
+
* With `enabled: false` a reconnect recovers nothing but still dispatches `connection.recovered`, at
|
|
25
|
+
* the same point a recovery would have started.
|
|
26
|
+
*/
|
|
27
|
+
export declare class ConnectionRecoveryManager extends WithSubscriptions {
|
|
28
|
+
client: StreamChat;
|
|
29
|
+
private readonly configController;
|
|
30
|
+
/** Set while a pass over the active channels and threads is in flight. */
|
|
31
|
+
private isRecovering;
|
|
32
|
+
/** A reconnect that arrived mid-pass: re-run once when the pass finishes, not concurrently. */
|
|
33
|
+
private recoveryRequestedAgain;
|
|
34
|
+
private unsubscribeSyncStatus?;
|
|
35
|
+
constructor({ client }: {
|
|
36
|
+
client: StreamChat;
|
|
37
|
+
});
|
|
38
|
+
get configState(): StateStore<ConnectionRecoveryManagerConfig>;
|
|
39
|
+
get config(): Readonly<ConnectionRecoveryManagerConfig>;
|
|
40
|
+
/**
|
|
41
|
+
* Merges a partial configuration into the resolved config.
|
|
42
|
+
*
|
|
43
|
+
* @param config - Fields to merge into the resolved config.
|
|
44
|
+
*/
|
|
45
|
+
updateConfig(config: Partial<ConnectionRecoveryManagerConfig>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Re-derives the configuration from the declarative slice.
|
|
48
|
+
*
|
|
49
|
+
* @param config - The declarative slice. Leave it out to rebuild from the defaults.
|
|
50
|
+
*/
|
|
51
|
+
initializeConfig(config?: Partial<ConnectionRecoveryManagerConfig>): void;
|
|
52
|
+
registerSubscriptions: () => () => symbol;
|
|
53
|
+
/**
|
|
54
|
+
* Binds to the offline DB's sync-status edge once the DB is initialized (an uninitialized one
|
|
55
|
+
* publishes no edge). Safe from the status handler: the edge is published only after
|
|
56
|
+
* `syncAndExecutePendingTasks()` resolves. Returns whether the edge now drives the recovery.
|
|
57
|
+
*/
|
|
58
|
+
private ensureSyncStatusSubscription;
|
|
59
|
+
/**
|
|
60
|
+
* Recovers the lists, and the active channels and threads (that pass dispatches `connection.recovered`
|
|
61
|
+
* when done). With recovery disabled it skips the refresh and only dispatches the event, so an app that
|
|
62
|
+
* refreshes its own data knows when to do it.
|
|
63
|
+
*/
|
|
64
|
+
private handleReconnect;
|
|
65
|
+
/**
|
|
66
|
+
* Channels a consumer is reading. Not filtered on `watchStatus`: a channel opened while offline never
|
|
67
|
+
* reached `Watching`, and `Channel.reload()` has its own `initialized || offlineMode` guard.
|
|
68
|
+
*/
|
|
69
|
+
private get recoverableActiveChannels();
|
|
70
|
+
/**
|
|
71
|
+
* Threads a consumer is displaying. They need their own pass: channel reloads and the thread list
|
|
72
|
+
* refresh do not rehydrate them. Threads of a disconnected channel are skipped.
|
|
73
|
+
*/
|
|
74
|
+
private get recoverableActiveThreads();
|
|
75
|
+
/**
|
|
76
|
+
* Flags closed threads stale, since they miss events during a drop. A listed thread rehydrates via the
|
|
77
|
+
* thread list reload, any other on its next `activate()`.
|
|
78
|
+
*/
|
|
79
|
+
private markInactiveThreadsStale;
|
|
80
|
+
private recoverChannelLists;
|
|
81
|
+
private recoverActiveChannels;
|
|
82
|
+
/** Runs a full recovery now, without waiting for a connection event. A no-op while one is running. */
|
|
83
|
+
recover: () => Promise<void>;
|
|
84
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { WithSubscriptions } from '../../utils/WithSubscriptions';
|
|
2
|
+
import { StateStore } from '@stream-io/state-store';
|
|
3
|
+
import type { NetworkConnectionObserverConfig, NetworkConnectionState, NetworkStatusReporter } from './types';
|
|
4
|
+
import type { StreamChat } from '../../client';
|
|
5
|
+
export declare const DEFAULT_NETWORK_CONNECTION_OBSERVER_CONFIG: NetworkConnectionObserverConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Device network status as reactive `state`, written only through {@link setStatus} (by a
|
|
8
|
+
* {@link NetworkStatusReporter}). It is a separate fact from the WebSocket status in
|
|
9
|
+
* `client.wsConnection.state`: a socket can die on a working network, and a device can go offline
|
|
10
|
+
* before the socket notices. Read both and branch; network status must never gate requests.
|
|
11
|
+
*
|
|
12
|
+
* Browsers get their reporter automatically. Elsewhere a stand-in mirrors the WebSocket until a real
|
|
13
|
+
* one is installed, and `isOnline` stays `undefined` (unknown) until the socket has been up once.
|
|
14
|
+
*/
|
|
15
|
+
export declare class NetworkConnectionObserver extends WithSubscriptions {
|
|
16
|
+
client: StreamChat;
|
|
17
|
+
state: StateStore<NetworkConnectionState>;
|
|
18
|
+
private readonly configController;
|
|
19
|
+
/** Replaced on each install, which `addUnsubscribeFunction` (cleared on unregister) cannot do. */
|
|
20
|
+
private unsubscribeStatusReporter?;
|
|
21
|
+
/** The installed reporter, so re-installing the same one (config is re-derived) is a no-op. */
|
|
22
|
+
private installedReporter?;
|
|
23
|
+
/**
|
|
24
|
+
* What `setStatusReporter` was last given (`null` clears, `undefined` if never called). Kept out
|
|
25
|
+
* of the resolved config, which derivations rebuild.
|
|
26
|
+
*/
|
|
27
|
+
private imperativeReporter?;
|
|
28
|
+
/** The declared reporter the last install saw, to tell a changed declaration from a re-derive. */
|
|
29
|
+
private declaredReporter?;
|
|
30
|
+
/**
|
|
31
|
+
* Whether config was derived at least once. `registerSubscriptions` runs mid-construction, when
|
|
32
|
+
* the client cannot take a status report yet.
|
|
33
|
+
*/
|
|
34
|
+
private configInitialized;
|
|
35
|
+
/** The host default, built once: the socket-mirroring one is a fresh closure per call. */
|
|
36
|
+
private defaultReporter?;
|
|
37
|
+
constructor({ client }: {
|
|
38
|
+
client: StreamChat;
|
|
39
|
+
});
|
|
40
|
+
get configState(): StateStore<NetworkConnectionObserverConfig>;
|
|
41
|
+
get config(): Readonly<NetworkConnectionObserverConfig>;
|
|
42
|
+
/**
|
|
43
|
+
* Merges a partial configuration into the resolved config. Also re-installs the reporter: the
|
|
44
|
+
* `setStatusReporter` one unless the configured reporter has changed since (set, replaced or
|
|
45
|
+
* cleared), else the configured one, else the host default.
|
|
46
|
+
*
|
|
47
|
+
* @param config - Fields to merge into the resolved config.
|
|
48
|
+
*/
|
|
49
|
+
updateConfig(config: Partial<NetworkConnectionObserverConfig>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Rebuilds the resolved configuration from package defaults plus the declarative slice. Also
|
|
52
|
+
* re-installs the reporter: the `setStatusReporter` one unless the configured reporter has changed
|
|
53
|
+
* since (set, replaced or cleared), else the configured one, else the host default.
|
|
54
|
+
*
|
|
55
|
+
* @param config - The declarative slice. Leave it out to rebuild from the defaults.
|
|
56
|
+
*/
|
|
57
|
+
initializeConfig(config?: Partial<NetworkConnectionObserverConfig>): void;
|
|
58
|
+
private get hostDefaultReporter();
|
|
59
|
+
/** Installs the imperative reporter if set, else the declared one, else the host default. */
|
|
60
|
+
private installConfiguredReporter;
|
|
61
|
+
/** Device network status; `undefined` is unknown, so test `=== false`, never `!isOnline`. */
|
|
62
|
+
get isOnline(): boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the installed reporter is the default that mirrors the WebSocket
|
|
65
|
+
* (`createWSConnectionNetworkStatusReporter`), where `isOnline === false` means "socket down".
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
get usesDefaultWSConnectionNetworkStatusReporter(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Installs the platform listener that reports device network status, replacing the previous one.
|
|
72
|
+
* `null` clears it and keeps the last known status. It survives later config derivations and is
|
|
73
|
+
* superseded only when the config names a different reporter
|
|
74
|
+
* (`client.config.set({ client: { networkConnection: { statusReporter } } })`).
|
|
75
|
+
*/
|
|
76
|
+
setStatusReporter(reporter: NetworkStatusReporter | null | undefined): void;
|
|
77
|
+
private installReporter;
|
|
78
|
+
/** Reports device network status. Called by the reporter, or by a host with no listener API. */
|
|
79
|
+
setStatus(isOnline: boolean): void;
|
|
80
|
+
/** Listens to no client events; teardown only releases the platform listener. */
|
|
81
|
+
registerSubscriptions: () => () => symbol;
|
|
82
|
+
}
|