stream-chat 10.0.0-rc.9 → 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 +21650 -19790
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +21690 -19798
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +21755 -19895
- 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 +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 +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 +513 -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
package/dist/types/client.d.ts
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
import type { AxiosInstance } from 'axios';
|
|
2
|
-
import { Channel } from './channel';
|
|
2
|
+
import type { Channel } from './channel';
|
|
3
3
|
import type { ChannelMuteStatus } from './channel_state';
|
|
4
4
|
import { ClientState } from './client_state';
|
|
5
|
-
import { StableWSConnection } from './connection';
|
|
6
5
|
import { UploadManager } from './uploadManager';
|
|
7
6
|
import { TokenManager, type TokenManagerMinimalUser } from './token_manager';
|
|
8
7
|
import { ApiClient } from './api-client';
|
|
9
|
-
import type { APIResponse, AppIdentifier, ChannelInput, ChannelMute, ChannelOptions, ChannelResponse, ChannelStateOptions, ChannelStateResponseFields, Configs, ConnectAPIResponse, DeviceIdentifier, Event, EventHandler, EventType, FileUploadInput, GetThreadOptions, LocalMessage, OwnUserResponse, PartializeAllBut, QueryChannelsRequest, QueryChannelsResponse,
|
|
10
|
-
import {
|
|
11
|
-
import { Thread } from './thread';
|
|
8
|
+
import type { APIResponse, AppIdentifier, ChannelInput, ChannelMute, ChannelOptions, ChannelResponse, ChannelStateOptions, ChannelStateResponseFields, Configs, ConnectAPIResponse, DeviceIdentifier, Event, EventHandler, EventType, FileUploadInput, GetThreadOptions, LocalMessage, OwnUserResponse, PartializeAllBut, PinMessageOptions, QueryChannelsRequest, QueryChannelsResponse, QueryThreadsRequest, SdkIdentifier, StreamRequestOptions, TokenOrProvider, UnBanUserOptions, UserMuteResponse, UserRequest, UserResponse } from './types';
|
|
9
|
+
import { type Thread } from './thread';
|
|
12
10
|
import { Moderation } from './moderation';
|
|
13
11
|
import { ThreadManager } from './thread_manager';
|
|
14
12
|
import { PollManager } from './poll_manager';
|
|
15
13
|
import { EntityStore } from './entityStore/EntityStore';
|
|
16
14
|
import { ChannelManager } from './ChannelManager';
|
|
17
|
-
import { ConnectionRecoveryManager } from './
|
|
15
|
+
import { ConnectionIdManager, ConnectionRecoveryManager, NetworkConnectionObserver, WSConnection } from './connection';
|
|
18
16
|
import { MessageDeliveryReporter } from './messageDelivery';
|
|
19
17
|
import { NotificationManager } from './notifications';
|
|
20
18
|
import { ReminderManager } from './reminders';
|
|
21
19
|
import type { AbstractOfflineDB } from './offline-support';
|
|
22
20
|
import { FixedSizeQueueCache } from './utils/FixedSizeQueueCache';
|
|
23
21
|
import type { MessageComposer } from './messageComposer';
|
|
24
|
-
import type { InstanceSetupState } from './configuration';
|
|
22
|
+
import type { InstanceConfigTree, InstanceSetupState } from './configuration';
|
|
23
|
+
import type { DeepPartial } from './types.utility';
|
|
25
24
|
import { InstanceConfigurationRegistry } from './configuration/InstanceConfigurationRegistry';
|
|
26
|
-
import { StateStore } from '
|
|
27
|
-
import type { FileUploadRequest, GetApplicationResponse as Gen_GetApplicationResponse, MarkDeliveredRequest as Gen_MarkDeliveredRequest, ImageUploadRequest, WSEvent } from './gen/models';
|
|
25
|
+
import { StateStore } from '@stream-io/state-store';
|
|
26
|
+
import type { FileUploadRequest, GetApplicationResponse as Gen_GetApplicationResponse, MarkDeliveredRequest as Gen_MarkDeliveredRequest, ImageUploadRequest, WSAuthMessage, WSEvent } from './gen/models';
|
|
28
27
|
import { ChatApi } from './gen-imports';
|
|
29
|
-
import type {
|
|
28
|
+
import type { StreamResponse } from './types';
|
|
30
29
|
export type QueryChannelsResponseWithChannels = Omit<QueryChannelsResponse, 'channels'> & {
|
|
31
30
|
channels: Channel[];
|
|
32
31
|
};
|
|
@@ -42,61 +41,57 @@ export type ClientUser = PartializeAllBut<OwnUserResponse, 'id'> & {
|
|
|
42
41
|
export declare class StreamChat extends ChatApi {
|
|
43
42
|
private static _instance?;
|
|
44
43
|
messageDeliveryReporter: MessageDeliveryReporter;
|
|
45
|
-
/**
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
44
|
+
/** @internal */
|
|
48
45
|
uploadManager: UploadManager;
|
|
49
|
-
/**
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
46
|
+
/** @private */
|
|
52
47
|
_user?: ClientUser;
|
|
53
48
|
appSettingsPromise?: Promise<StreamResponse<Gen_GetApplicationResponse>>;
|
|
54
|
-
activeChannels: {
|
|
55
|
-
[key: string]: Channel;
|
|
56
|
-
};
|
|
57
49
|
threads: ThreadManager;
|
|
58
50
|
polls: PollManager;
|
|
59
51
|
/**
|
|
60
|
-
* Channel lists
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* It is deliberately not configurable through the client options — everything is set on the
|
|
67
|
-
* manager itself (`setOwnershipResolver`, `addEventHandler` / `setEventHandlers` /
|
|
68
|
-
* `removeEventHandlers`), which is also the only way to reconfigure it later.
|
|
52
|
+
* Channel lists (`ChannelPaginator`s kept in sync with WS events, with ownership arbitration
|
|
53
|
+
* between them). Register lists with `insertPaginator()` / `removePaginator()`. It handles events
|
|
54
|
+
* only once something calls its ref-counted `registerSubscriptions()`. It is configured on the
|
|
55
|
+
* manager itself (`setOwnershipResolver`, `addEventHandler`, ...), not through the client
|
|
56
|
+
* options.
|
|
69
57
|
*/
|
|
70
58
|
channelManager: ChannelManager;
|
|
71
59
|
/**
|
|
72
|
-
*
|
|
73
|
-
* and
|
|
74
|
-
* client
|
|
75
|
-
*
|
|
76
|
-
* Turn it off through the declarative configuration if the application recovers state itself:
|
|
77
|
-
* `client.config.set({ client: { connectionRecovery: { enabled: false } } })`.
|
|
60
|
+
* On reconnect, re-runs each loaded channel list's first-page query and reloads each active
|
|
61
|
+
* channel and thread, then dispatches `connection.recovered`. Disable it when the app recovers
|
|
62
|
+
* state itself: `client.config.set({ client: { connectionRecovery: { enabled: false } } })`.
|
|
78
63
|
*/
|
|
79
64
|
connectionRecovery: ConnectionRecoveryManager;
|
|
80
65
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
66
|
+
* The device's network status, separate from the WebSocket's ({@link wsConnection}). Platforms
|
|
67
|
+
* report it through `client.config.set({ client: { networkConnection: { statusReporter } } })` or
|
|
68
|
+
* `client.networkConnection.setStatusReporter(...)`. Browsers get a reporter automatically;
|
|
69
|
+
* elsewhere a stand-in mirrors the WebSocket. `isOnline` is `undefined` (unknown, not offline)
|
|
70
|
+
* until something reports.
|
|
71
|
+
*/
|
|
72
|
+
networkConnection: NetworkConnectionObserver;
|
|
73
|
+
/**
|
|
74
|
+
* The connection ID (the WebSocket's, or the long-poll's after an `enableWSFallback` switch). A
|
|
75
|
+
* request with `watch` or `presence` waits here for the handshake (see `requiresConnectionId`).
|
|
76
|
+
*/
|
|
77
|
+
connectionIdManager: ConnectionIdManager;
|
|
78
|
+
/**
|
|
79
|
+
* Client-global store with one canonical copy of each message. The channel and thread paginators
|
|
80
|
+
* read and write messages through it, so a message held in several of them stays consistent.
|
|
84
81
|
*/
|
|
85
82
|
messageStore: EntityStore<LocalMessage>;
|
|
86
83
|
offlineDb?: AbstractOfflineDB;
|
|
87
84
|
notifications: NotificationManager;
|
|
88
85
|
reminders: ReminderManager;
|
|
89
|
-
persistUserOnConnectionFailure?: boolean;
|
|
90
86
|
axiosInstance: AxiosInstance;
|
|
91
87
|
baseURL?: string;
|
|
92
|
-
browser: boolean;
|
|
93
88
|
cleaningIntervalRef?: ReturnType<typeof setTimeout>;
|
|
94
89
|
clientId?: string;
|
|
95
90
|
key: string;
|
|
96
91
|
listeners: Map<EventType, Set<EventHandler>>;
|
|
97
92
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
93
|
+
* When true, threads are not cleaned up while the channel state is initializing (for SDKs that
|
|
94
|
+
* recover channel state themselves).
|
|
100
95
|
*/
|
|
101
96
|
preventThreadCleanup: boolean;
|
|
102
97
|
moderation: Moderation;
|
|
@@ -105,52 +100,47 @@ export declare class StreamChat extends ChatApi {
|
|
|
105
100
|
mutedUsers: UserMuteResponse[];
|
|
106
101
|
}>;
|
|
107
102
|
/**
|
|
108
|
-
* Reactive store behind {@link channelServerConfigs}
|
|
109
|
-
*
|
|
110
|
-
* resolver is the intended replacement.
|
|
111
|
-
*
|
|
112
|
-
* Named for what it holds plus a `Store` suffix for what it is, matching {@link mutedUsersStore}. These
|
|
113
|
-
* are the backend's configs, not the ones you register through {@link config}.
|
|
103
|
+
* Reactive store behind {@link channelServerConfigs}: the backend's channel configs, not the ones
|
|
104
|
+
* registered through {@link config}.
|
|
114
105
|
*
|
|
115
106
|
* @internal
|
|
116
107
|
*/
|
|
117
108
|
readonly channelServerConfigsStore: StateStore<ChannelConfigsState>;
|
|
118
109
|
blockedUsers: StateStore<BlockedUsersState>;
|
|
119
|
-
node: boolean;
|
|
120
|
-
options: StreamChatOptions;
|
|
121
110
|
setUserPromise: ConnectAPIResponse | null;
|
|
122
111
|
state: ClientState;
|
|
123
112
|
tokenManager: TokenManager;
|
|
124
113
|
user?: ClientUser;
|
|
125
114
|
userAgent?: string;
|
|
126
115
|
wsBaseURL?: string;
|
|
127
|
-
wsConnection:
|
|
116
|
+
wsConnection: WSConnection;
|
|
128
117
|
wsPromise: ConnectAPIResponse | null;
|
|
129
|
-
|
|
130
|
-
|
|
118
|
+
private _wsPromiseSettled;
|
|
119
|
+
private _wsConnectId;
|
|
120
|
+
private _resolveWsPromise?;
|
|
121
|
+
private _rejectWsPromise?;
|
|
131
122
|
/**
|
|
132
|
-
*
|
|
123
|
+
* Whether the client runs in a browser: the `client.browser` option, else whether `window`
|
|
124
|
+
* exists.
|
|
133
125
|
*/
|
|
126
|
+
get browser(): boolean;
|
|
127
|
+
get node(): boolean;
|
|
128
|
+
get anonymous(): boolean;
|
|
129
|
+
get userId(): string | undefined;
|
|
130
|
+
/** @deprecated Use `userId` instead. */
|
|
134
131
|
get userID(): string | undefined;
|
|
135
|
-
/**
|
|
136
|
-
* @deprecated Use `clientId` instead.
|
|
137
|
-
*/
|
|
132
|
+
/** @deprecated Use `clientId` instead. */
|
|
138
133
|
get clientID(): string | undefined;
|
|
139
134
|
set clientID(id: string | undefined);
|
|
140
135
|
get api(): ApiClient;
|
|
141
|
-
insightMetrics: InsightMetrics;
|
|
142
|
-
defaultWSTimeout: number;
|
|
143
136
|
sdkIdentifier?: SdkIdentifier;
|
|
144
137
|
deviceIdentifier?: DeviceIdentifier;
|
|
145
138
|
appIdentifier?: AppIdentifier;
|
|
146
139
|
private cachedUserAgent?;
|
|
147
140
|
readonly messageComposerCache: FixedSizeQueueCache<string, MessageComposer>;
|
|
148
141
|
/**
|
|
149
|
-
* Configuration
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* Not to be confused with {@link channelServerConfigs}, which holds the **server-provided channel
|
|
153
|
-
* configs** keyed by cid. This one is yours; that one is the backend's.
|
|
142
|
+
* Configuration registered for the instances the SDK creates (channels, threads, composers, the
|
|
143
|
+
* client's own managers). Not the server-provided channel configs ({@link channelServerConfigs}).
|
|
154
144
|
*/
|
|
155
145
|
readonly config: InstanceConfigurationRegistry;
|
|
156
146
|
/** Teardown for the `'client'` setup function, released by {@link disconnectUser}. */
|
|
@@ -158,68 +148,38 @@ export declare class StreamChat extends ChatApi {
|
|
|
158
148
|
/**
|
|
159
149
|
* Initializes a client.
|
|
160
150
|
*
|
|
161
|
-
* **
|
|
151
|
+
* **Prefer `StreamChat.getInstance()`: a second client opens a second WebSocket connection.**
|
|
162
152
|
*
|
|
163
153
|
* @example <caption>initialize the client in user mode</caption>
|
|
164
154
|
* new StreamChat('api_key')
|
|
165
|
-
* @example <caption>initialize the client
|
|
166
|
-
* new StreamChat('api_key', {
|
|
167
|
-
* @example <caption>secret is optional and only used in server side mode</caption>
|
|
168
|
-
* new StreamChat('api_key', 'secret', { httpsAgent: customAgent })
|
|
155
|
+
* @example <caption>initialize the client with configuration</caption>
|
|
156
|
+
* new StreamChat('api_key', { client: { axiosRequestConfig: { timeout: 5000 } } })
|
|
169
157
|
*
|
|
170
158
|
* @param key - The API key.
|
|
171
|
-
* @param
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* @param options.logLevel - Minimum log level for the default sink (optional, defaults to `'info'`).
|
|
175
|
-
* @param options.logOptions - Per-scope sink/level overrides for `chatLoggerSystem` (optional).
|
|
176
|
-
* @param options.timeout - Request timeout (optional, defaults to `3000`).
|
|
177
|
-
* @param options.httpsAgent - Custom `httpsAgent` (optional).
|
|
159
|
+
* @param config - Declarative configuration, the tree `client.config.set()` takes (optional).
|
|
160
|
+
* Applied before anything is built, so it reaches the managers and the options read once at
|
|
161
|
+
* construction (`client.baseURL`, `client.axiosRequestConfig`, `client.notificationManager`).
|
|
178
162
|
*/
|
|
179
|
-
constructor(key: string,
|
|
163
|
+
constructor(key: string, config?: DeepPartial<InstanceConfigTree>);
|
|
180
164
|
/**
|
|
181
|
-
* Subscribes the client's managers to the `'client'` configuration key.
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* subscription to run the setup function's teardown. A client is reusable — `getInstance` hands the same
|
|
185
|
-
* object back, and disconnect/connect is the documented multi-user and mobile-background flow — and the
|
|
186
|
-
* managers this key configures (`reminders`, `threads`, `messageDeliveryReporter`, `notifications`)
|
|
187
|
-
* outlive the user. Without the re-arm the key went permanently dead on the second connect: `setConfig`,
|
|
188
|
-
* `setSetupFunction` and `reset` all stopped reaching any manager, silently.
|
|
189
|
-
*
|
|
190
|
-
* Idempotent through the `unsubscribeClientConfiguration` guard, so the constructor's wiring is not
|
|
191
|
-
* duplicated by the first `connectUser`.
|
|
165
|
+
* Subscribes the client's managers to the `'client'` configuration key. Called by the constructor
|
|
166
|
+
* and by {@link _setUser}, because {@link disconnectUser} releases the subscription (to run the
|
|
167
|
+
* setup function's teardown) while the managers outlive the user. Idempotent.
|
|
192
168
|
*/
|
|
193
169
|
private wireClientConfiguration;
|
|
194
170
|
/**
|
|
195
|
-
* Derives each manager's configuration from package defaults plus the `client`
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* Defaults are spread first, and every manager is written unconditionally, because this is a
|
|
199
|
-
* derivation* rather than a patch — the same rule `Channel.initializeConfig` follows. Guarding on
|
|
200
|
-
* `if (config?.reminders)` and merging made `reset()` a no-op for this key: the store is cleared
|
|
201
|
-
* before instances re-derive, so the guards all failed and the registered values stayed in force.
|
|
202
|
-
* It also meant a field *removed* from the tree lingered, which is exactly what a merge cannot express.
|
|
171
|
+
* Derives each manager's configuration from the package defaults plus the `client` subtree. Every
|
|
172
|
+
* manager is written unconditionally: it is a derivation, not a merge, so `config.reset()` and
|
|
173
|
+
* removed fields take effect.
|
|
203
174
|
*/
|
|
204
175
|
private initializeManagerConfig;
|
|
205
176
|
get mutedUsers(): UserMuteResponse[];
|
|
206
177
|
set mutedUsers(mutedUsers: UserMuteResponse[]);
|
|
207
178
|
/**
|
|
208
|
-
* Cache of server-provided channel configuration, keyed by
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* Read it through {@link Channel.serverConfig} rather than here. Not to be confused with
|
|
213
|
-
* {@link config}, which is the configuration *you* register for SDK-created instances.
|
|
214
|
-
*
|
|
215
|
-
* This is `client.configs` from v9 under a name that says whose configuration it is — the key space is
|
|
216
|
-
* unchanged, so a v9 `client.configs[cid]` lookup translates directly. There is deliberately no
|
|
217
|
-
* `configs` alias: it read as a sibling of the integrator-facing {@link config} while holding the
|
|
218
|
-
* backend's answer, and the two being one letter apart is what made `channel.getConfig()` ambiguous
|
|
219
|
-
* enough to rename as well.
|
|
220
|
-
*
|
|
221
|
-
* Assigning through this setter notifies subscribers; mutating the returned record in place does not.
|
|
222
|
-
* Prefer {@link _addChannelConfig}.
|
|
179
|
+
* Cache of server-provided channel configuration, keyed by cid (a channel's `config_overrides`
|
|
180
|
+
* can make it differ from other channels of its type). Read it through
|
|
181
|
+
* {@link Channel.serverConfig}. Assigning through the setter notifies subscribers, mutating the
|
|
182
|
+
* record in place does not (prefer {@link _addChannelConfig}).
|
|
223
183
|
*
|
|
224
184
|
* @internal
|
|
225
185
|
*/
|
|
@@ -227,84 +187,86 @@ export declare class StreamChat extends ChatApi {
|
|
|
227
187
|
/** @internal */
|
|
228
188
|
set channelServerConfigs(configs: Configs);
|
|
229
189
|
/**
|
|
230
|
-
* Returns
|
|
190
|
+
* Returns the shared client instance, so there is only one client and WebSocket connection.
|
|
231
191
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* **After the first call, the client configuration will not change if the key or options parameters change.**
|
|
192
|
+
* **After the first call, the `key` and `config` parameters are ignored.**
|
|
235
193
|
*
|
|
236
194
|
* @example <caption>initialize the client in user mode</caption>
|
|
237
195
|
* StreamChat.getInstance('api_key')
|
|
238
|
-
* @example <caption>initialize the client
|
|
239
|
-
* StreamChat.getInstance('api_key', { timeout: 5000 })
|
|
240
|
-
* @example <caption>secret is optional and only used in server side mode</caption>
|
|
241
|
-
* StreamChat.getInstance('api_key', 'secret', { httpsAgent: customAgent })
|
|
196
|
+
* @example <caption>initialize the client with configuration</caption>
|
|
197
|
+
* StreamChat.getInstance('api_key', { client: { axiosRequestConfig: { timeout: 5000 } } })
|
|
242
198
|
*
|
|
243
199
|
* @param key - The API key.
|
|
244
|
-
* @param
|
|
245
|
-
* @param options.browser - Enforce the client to be in browser mode (optional).
|
|
246
|
-
* @param options.warmUp - If `true`, the client will open a connection as soon as possible to speed up following requests (optional, defaults to `false`).
|
|
247
|
-
* @param options.logLevel - Minimum log level for the default sink (optional, defaults to `'info'`).
|
|
248
|
-
* @param options.logOptions - Per-scope sink/level overrides for `chatLoggerSystem` (optional).
|
|
249
|
-
* @param options.timeout - Request timeout (optional, defaults to `3000`).
|
|
250
|
-
* @param options.httpsAgent - Custom `httpsAgent` (optional, in Node defaults to `https.agent()`).
|
|
200
|
+
* @param config - Declarative configuration, as for the constructor (optional).
|
|
251
201
|
* @returns The shared client instance.
|
|
252
202
|
*/
|
|
253
|
-
static getInstance(key: string,
|
|
203
|
+
static getInstance(key: string, config?: DeepPartial<InstanceConfigTree>): StreamChat;
|
|
254
204
|
setOfflineDBApi(offlineDBInstance: AbstractOfflineDB): void;
|
|
205
|
+
/**
|
|
206
|
+
* Creates a development token for apps with auth checks disabled. Never use one in production.
|
|
207
|
+
* See {@link DevToken}.
|
|
208
|
+
*
|
|
209
|
+
* @param userId - The ID of the user the token is for.
|
|
210
|
+
* @returns The development token.
|
|
211
|
+
*/
|
|
212
|
+
devToken(userId: string): string;
|
|
255
213
|
getAuthType(): "anonymous" | "jwt";
|
|
256
214
|
setBaseURL(baseURL: string): void;
|
|
257
215
|
_getConnectionID: () => string | undefined;
|
|
258
216
|
_hasConnectionID: () => boolean;
|
|
259
|
-
/**
|
|
260
|
-
* @deprecated Use `client.config.setSetupFunction('messageComposer', fn)`.
|
|
261
|
-
*/
|
|
217
|
+
/** @deprecated Use `client.config.setSetupFunction('messageComposer', fn)`. */
|
|
262
218
|
setMessageComposerSetupFunction: (setupFunction: InstanceSetupState<"messageComposer">["setupFunction"]) => void;
|
|
263
219
|
/**
|
|
264
|
-
* Sets the current user and opens
|
|
220
|
+
* Sets the current user and opens the WebSocket connection.
|
|
265
221
|
*
|
|
266
|
-
* @param user -
|
|
267
|
-
* @param userTokenOrProvider - A token string or an async provider that
|
|
222
|
+
* @param user - The user, with its required `id`, e.g. `{ id: 'john', name: 'John' }`.
|
|
223
|
+
* @param userTokenOrProvider - A token string, or an async provider that resolves to one.
|
|
268
224
|
* @returns A promise that resolves when the connection is set up.
|
|
225
|
+
* @throws For a different user, unless `disconnectUser()` ran first.
|
|
269
226
|
*/
|
|
270
227
|
connectUser: (user: ClientUser, userTokenOrProvider: TokenOrProvider) => Promise<void | import("./types").ConnectionOpen>;
|
|
271
228
|
/**
|
|
272
|
-
* Sets the current user and opens
|
|
229
|
+
* Sets the current user and opens the WebSocket connection.
|
|
273
230
|
*
|
|
274
|
-
* @deprecated Use {@link StreamChat.connectUser} instead.
|
|
231
|
+
* @deprecated Use {@link StreamChat.connectUser} instead.
|
|
275
232
|
*
|
|
276
|
-
* @param user -
|
|
277
|
-
* @param userTokenOrProvider - A token string or an async provider that
|
|
233
|
+
* @param user - The user, with its required `id`, e.g. `{ id: 'john', name: 'John' }`.
|
|
234
|
+
* @param userTokenOrProvider - A token string, or an async provider that resolves to one.
|
|
278
235
|
* @returns A promise that resolves when the connection is set up.
|
|
279
236
|
*/
|
|
280
237
|
setUser: (user: ClientUser, userTokenOrProvider: TokenOrProvider) => Promise<void | import("./types").ConnectionOpen>;
|
|
281
238
|
_setToken: (user: TokenManagerMinimalUser, userTokenOrProvider: TokenOrProvider) => Promise<void>;
|
|
282
239
|
_setUser(user: TokenManagerMinimalUser): void;
|
|
283
240
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
241
|
+
* Closes the WebSocket without removing the user, and without auto-reconnect: call
|
|
242
|
+
* `openConnection` to reconnect. Mainly for mobile: push notifications arrive only while no
|
|
243
|
+
* WebSocket is active, so close on background and reopen on foreground. After an
|
|
244
|
+
* `enableWSFallback` switch it also closes the long-poll, telling the server to close its
|
|
245
|
+
* connection ID.
|
|
287
246
|
*
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
* So when your app goes to background, you can call `client.closeConnection`.
|
|
291
|
-
* And when app comes back to foreground, call `client.openConnection`.
|
|
292
|
-
*
|
|
293
|
-
* @param timeout - Max number of milliseconds to wait for the WebSocket close event before forcefully assuming
|
|
294
|
-
* successful disconnection. See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent (optional).
|
|
247
|
+
* @param timeout - Milliseconds to wait for the WebSocket close event and for the long-poll close
|
|
248
|
+
* request. Defaults to 1s and 2s respectively.
|
|
295
249
|
*/
|
|
296
250
|
closeConnection: (timeout?: number) => Promise<void>;
|
|
297
251
|
/**
|
|
298
|
-
*
|
|
252
|
+
* Opens a WebSocket connection for the current user. After an `enableWSFallback` switch it
|
|
253
|
+
* reconnects the long-poll instead: the client never goes back to the WebSocket.
|
|
299
254
|
*
|
|
300
|
-
* @returns The
|
|
255
|
+
* @returns The connect promise, or `undefined` when a healthy connection already exists.
|
|
301
256
|
*/
|
|
302
257
|
openConnection: () => ConnectAPIResponse | undefined;
|
|
258
|
+
/** Rejects the shared `wsPromise` and invalidates any in-flight connect attempt. */
|
|
259
|
+
private _rejectPendingWsPromise;
|
|
260
|
+
/**
|
|
261
|
+
* Keeps a single pending `wsPromise` across close/reopen, so callers already awaiting it are not
|
|
262
|
+
* stranded when `openConnection` starts a new connect.
|
|
263
|
+
*/
|
|
264
|
+
private _bindWsPromise;
|
|
303
265
|
/**
|
|
304
|
-
* Revokes
|
|
266
|
+
* Revokes the connected user's tokens issued before the given time.
|
|
305
267
|
*
|
|
306
|
-
* @param before - Cutoff date; tokens issued before
|
|
307
|
-
* @param
|
|
268
|
+
* @param before - Cutoff date; tokens issued before it are revoked (optional). Defaults to now.
|
|
269
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
308
270
|
* into the request (optional).
|
|
309
271
|
* @returns The updated users response.
|
|
310
272
|
*/
|
|
@@ -312,48 +274,46 @@ export declare class StreamChat extends ChatApi {
|
|
|
312
274
|
/**
|
|
313
275
|
* Retrieves application settings.
|
|
314
276
|
*
|
|
277
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
278
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
315
279
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
316
280
|
* into the request (optional).
|
|
317
|
-
* @returns The application settings response.
|
|
281
|
+
* @returns The application settings response. A failed request is not kept in
|
|
282
|
+
* {@link appSettingsPromise}, so the next call fetches again.
|
|
318
283
|
*/
|
|
319
|
-
getAppSettings(requestOptions?: StreamRequestOptions): Promise<StreamResponse<Gen_GetApplicationResponse>>;
|
|
284
|
+
getAppSettings(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<Gen_GetApplicationResponse>>;
|
|
320
285
|
/**
|
|
321
|
-
* Disconnects the WebSocket and removes the user
|
|
286
|
+
* Disconnects the WebSocket and removes the user and its state.
|
|
322
287
|
*
|
|
323
|
-
* @param timeout -
|
|
324
|
-
* successful disconnection. See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent (optional).
|
|
325
|
-
* @returns The close-connection promise.
|
|
288
|
+
* @param timeout - Passed to {@link closeConnection} (optional).
|
|
326
289
|
*/
|
|
327
290
|
disconnectUser: (timeout?: number) => Promise<void>;
|
|
328
|
-
/**
|
|
329
|
-
*
|
|
330
|
-
* @deprecated Please use client.disconnectUser instead.
|
|
331
|
-
*
|
|
332
|
-
* Disconnects the WebSocket and removes the user from client.
|
|
333
|
-
*/
|
|
291
|
+
/** @deprecated Use `client.disconnectUser` instead. */
|
|
334
292
|
disconnect: (timeout?: number) => Promise<void>;
|
|
335
293
|
/**
|
|
336
|
-
* Sets an anonymous user and opens
|
|
294
|
+
* Sets an anonymous user and opens the WebSocket connection.
|
|
337
295
|
*
|
|
338
296
|
* @returns A promise that resolves when the connection is set up.
|
|
339
297
|
*/
|
|
340
298
|
connectAnonymousUser: () => ConnectAPIResponse | undefined;
|
|
341
299
|
/**
|
|
342
|
-
* Creates a guest user
|
|
300
|
+
* Creates a guest user.
|
|
343
301
|
*
|
|
344
|
-
* @param args -
|
|
302
|
+
* @param ...args - `[request, requestOptions]`. `request.user` is the guest user to create;
|
|
303
|
+
* `requestOptions` carries per-request options such as an abort `signal` and is never
|
|
304
|
+
* serialized into the request.
|
|
345
305
|
* @returns The created guest user and its access token.
|
|
346
306
|
*/
|
|
347
307
|
createGuest(...args: Parameters<ChatApi['createGuest']>): Promise<StreamResponse<import(".").CreateGuestResponse>>;
|
|
348
308
|
/**
|
|
349
|
-
*
|
|
309
|
+
* Creates a temporary guest user and connects as it.
|
|
350
310
|
*
|
|
351
|
-
* @param user -
|
|
352
|
-
* @param
|
|
311
|
+
* @param user - The guest user, with its required `id`, e.g. `{ id: 'john', name: 'John' }`.
|
|
312
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
353
313
|
* into the request (optional).
|
|
354
314
|
* @returns A promise that resolves when the connection is set up.
|
|
355
315
|
*/
|
|
356
|
-
setGuestUser(user:
|
|
316
|
+
setGuestUser(user: UserRequest, requestOptions?: StreamRequestOptions): Promise<void | import("./types").ConnectionOpen>;
|
|
357
317
|
/**
|
|
358
318
|
* Listens to events on all channels and users you're watching.
|
|
359
319
|
*
|
|
@@ -367,262 +327,202 @@ export declare class StreamChat extends ChatApi {
|
|
|
367
327
|
* console.log(event.type);
|
|
368
328
|
* });
|
|
369
329
|
*
|
|
370
|
-
* @param
|
|
371
|
-
* @param callbackOrNothing - The callback to call when an event type was provided (optional).
|
|
330
|
+
* @param callback - Called with every event.
|
|
372
331
|
* @returns An object with an `unsubscribe()` method.
|
|
373
332
|
*/
|
|
374
333
|
on(callback: EventHandler): {
|
|
375
334
|
unsubscribe: () => void;
|
|
376
335
|
};
|
|
377
|
-
|
|
336
|
+
/**
|
|
337
|
+
* Listens to one event type on all channels and users you're watching.
|
|
338
|
+
*
|
|
339
|
+
* @param eventType - The event type to listen for.
|
|
340
|
+
* @param callback - Called with each event of that type.
|
|
341
|
+
* @returns An object with an `unsubscribe()` method.
|
|
342
|
+
*/
|
|
343
|
+
on<T extends EventType>(eventType: T, callback: EventHandler<T>): {
|
|
378
344
|
unsubscribe: () => void;
|
|
379
345
|
};
|
|
380
346
|
/**
|
|
381
|
-
* Removes
|
|
347
|
+
* Removes a listener for all events.
|
|
382
348
|
*
|
|
383
|
-
* @param
|
|
384
|
-
* @param callbackOrNothing - The callback to remove when an event type was provided (optional).
|
|
349
|
+
* @param callback - The listener to remove.
|
|
385
350
|
*/
|
|
386
351
|
off(callback: EventHandler): void;
|
|
387
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Removes a listener for one event type.
|
|
354
|
+
*
|
|
355
|
+
* @param eventType - The event type it listens to.
|
|
356
|
+
* @param callback - The listener to remove.
|
|
357
|
+
*/
|
|
358
|
+
off<T extends EventType>(eventType: T, callback: EventHandler<T>): void;
|
|
388
359
|
dispatchEvent: (event: Event) => void;
|
|
389
360
|
/**
|
|
390
|
-
*
|
|
361
|
+
* Puts `user`'s new object into the members, watchers, own membership and (with `readEntries`)
|
|
362
|
+
* read entries of the channels that list them, in one state update per channel.
|
|
391
363
|
*
|
|
392
|
-
* @param
|
|
364
|
+
* @param options.readEntries - Also replace the user in read entries, refreshing read receipts.
|
|
365
|
+
* Off for presence changes: receipts never show online status. Defaults to `true`.
|
|
393
366
|
*/
|
|
394
|
-
_updateMemberWatcherReferences: (user: UserResponse
|
|
367
|
+
_updateMemberWatcherReferences: (user: UserResponse, { readEntries }?: {
|
|
368
|
+
readEntries?: boolean;
|
|
369
|
+
}) => void;
|
|
395
370
|
/**
|
|
396
371
|
* @deprecated Please use `_updateMemberWatcherReferences` instead.
|
|
397
372
|
* @private
|
|
398
373
|
*/
|
|
399
|
-
_updateUserReferences: (user: UserResponse
|
|
374
|
+
_updateUserReferences: (user: UserResponse, { readEntries }?: {
|
|
375
|
+
readEntries?: boolean;
|
|
376
|
+
}) => void;
|
|
400
377
|
/**
|
|
401
|
-
*
|
|
378
|
+
* Replaces the user's object in the messages of the loaded channels.
|
|
402
379
|
*
|
|
403
380
|
* @private
|
|
404
|
-
*
|
|
405
|
-
* @param user - The updated user.
|
|
406
381
|
*/
|
|
407
382
|
_updateUserMessageReferences: (user: UserResponse) => void;
|
|
408
383
|
/**
|
|
409
|
-
* Deletes the messages
|
|
410
|
-
*
|
|
411
|
-
* If `hardDelete` is `true`, all the content of the message will be stripped down.
|
|
412
|
-
* Otherwise, only `message.type` will be set as `'deleted'`.
|
|
384
|
+
* Deletes the user's messages in the loaded channels: stripped of their content with
|
|
385
|
+
* `hardDelete`, otherwise marked as deleted. `deletedAt` defaults to now.
|
|
413
386
|
*
|
|
414
387
|
* @private
|
|
415
|
-
*
|
|
416
|
-
* @param user - The user whose messages should be deleted.
|
|
417
|
-
* @param hardDelete - Whether to fully strip the message content (optional, defaults to `false`).
|
|
418
|
-
* @param deletedAt - Timestamp to mark messages as deleted at (optional).
|
|
419
388
|
*/
|
|
420
389
|
_deleteUserMessageReference: (user: UserResponse, hardDelete?: boolean, deletedAt?: LocalMessage["deleted_at"]) => void;
|
|
421
|
-
/**
|
|
422
|
-
* Handle the following user-related events:
|
|
423
|
-
* - `user.presence.changed`
|
|
424
|
-
* - `user.updated`
|
|
425
|
-
* - `user.deleted`
|
|
426
|
-
*
|
|
427
|
-
* @private
|
|
428
|
-
*
|
|
429
|
-
* @param event - The user event.
|
|
430
|
-
*/
|
|
390
|
+
/** @private */
|
|
431
391
|
_handleUserEvent: (event: Extract<WSEvent, {
|
|
432
392
|
type: "user.presence.changed" | "user.updated" | "user.deleted";
|
|
433
393
|
}>) => void;
|
|
434
|
-
_handleClientEvent(event: WSEvent
|
|
435
|
-
/**
|
|
436
|
-
* Fans the client-owned `mutedChannels` out to every active channel's reactive `state.muteStatus`.
|
|
437
|
-
* Each channel republishes only when its own mute status actually changed, so this stays cheap on
|
|
438
|
-
* the frequent `health.check` path.
|
|
439
|
-
*/
|
|
440
|
-
_reflectMutedChannelsToActiveChannels(): void;
|
|
441
|
-
/**
|
|
442
|
-
* Resets the AI indicator state to `Idle` on every active channel. Invoked from `closeConnection`
|
|
443
|
-
* as it's a deliberate shutdown and will not natively trigger a WS event.
|
|
444
|
-
*/
|
|
445
|
-
_resetAIStateOnActiveChannels(): void;
|
|
446
|
-
/**
|
|
447
|
-
* Demotes every actively-watched channel to `WasWatching`. The server keys watches by connection
|
|
448
|
-
* ID, so losing the socket ends every watch this client held — a reconnect issues a NEW id and the
|
|
449
|
-
* channels have to be re-queried to watch again. `WasWatching` is what records that they should be.
|
|
450
|
-
*
|
|
451
|
-
* Only `Watching` is demoted: a channel the consumer stopped on purpose, or one that was torn
|
|
452
|
-
* down, stays `NotWatching` and must not be resurrected by a reconnect.
|
|
453
|
-
*
|
|
454
|
-
* Invoked from two places, because neither covers the other: `StableWSConnection._setHealth(false)`
|
|
455
|
-
* for an abnormal close/error (immediately — NOT via the `connection.changed` event, which is
|
|
456
|
-
* 5s-debounced when going offline and is skipped entirely on a quick flap, both of which would
|
|
457
|
-
* leave the status lying), and `closeConnection()` for a deliberate shutdown (e.g. mobile
|
|
458
|
-
* backgrounding), which sets `isHealthy` directly and so never reaches `_setHealth`.
|
|
459
|
-
*/
|
|
460
|
-
_markActiveChannelsWatchInterrupted(): void;
|
|
394
|
+
_handleClientEvent(event: WSEvent): (() => void)[];
|
|
461
395
|
_muteStatus(cid: string): ChannelMuteStatus;
|
|
462
396
|
_callClientListeners: (event: Event) => void;
|
|
463
397
|
/**
|
|
464
|
-
* Settles the connect promises after a successful reconnect, so
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
* {@link ConnectionRecoveryManager}, which subscribes to the connection lifecycle and so covers
|
|
469
|
-
* every reconnect path — including `closeConnection()` → `openConnection()` (mobile backgrounding),
|
|
470
|
-
* which never reaches `_reconnect()` at all.
|
|
398
|
+
* Settles the connect promises after a successful reconnect, so a held `wsPromise` /
|
|
399
|
+
* `setUserPromise` stops resolving against a superseded (possibly rejected) attempt. Called by
|
|
400
|
+
* `StableWSConnection._reconnect()` and `WSConnectionFallback.connect(true)`. Recovery itself
|
|
401
|
+
* belongs to {@link ConnectionRecoveryManager}.
|
|
471
402
|
*
|
|
472
403
|
* @internal
|
|
473
404
|
*/
|
|
474
405
|
_settleConnectPromises: () => void;
|
|
475
|
-
/**
|
|
476
|
-
* @private
|
|
477
|
-
*/
|
|
406
|
+
/** @private */
|
|
478
407
|
connect(): Promise<void | import("./types").ConnectionOpen>;
|
|
479
408
|
/**
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
* @private
|
|
483
|
-
*/
|
|
484
|
-
_sayHi(): void;
|
|
485
|
-
/**
|
|
486
|
-
* Queries users and watches user presence.
|
|
409
|
+
* Queries users and stores them in `client.state.users`. Watches presence only when
|
|
410
|
+
* `request.payload.presence` is set.
|
|
487
411
|
*
|
|
488
412
|
* @param ...args - `[request, requestOptions]`. The optional `request.payload` accepts
|
|
489
|
-
* MongoDB-style filter conditions, sort directions (e.g.
|
|
490
|
-
*
|
|
491
|
-
* abort `signal` and is never
|
|
413
|
+
* MongoDB-style filter conditions, sort directions (e.g.
|
|
414
|
+
* `[{ field: 'last_active', direction: -1 }]`), and options such as `presence`.
|
|
415
|
+
* `requestOptions` carries per-request options such as an abort `signal` and is never
|
|
416
|
+
* serialized into the request.
|
|
492
417
|
* @returns The user query response.
|
|
493
418
|
*/
|
|
494
419
|
queryUsers(...args: Parameters<ChatApi['queryUsers']>): Promise<StreamResponse<import(".").QueryUsersResponse>>;
|
|
495
420
|
/**
|
|
496
|
-
*
|
|
497
|
-
*
|
|
421
|
+
* Stops watching a channel on this client's connection. It carries no `watch` flag, but it waits
|
|
422
|
+
* for the connection ID like a watching request (through a handshake or reconnect, until the
|
|
423
|
+
* caller's abort signal fires) and throws when there is no connection and none is being
|
|
424
|
+
* established.
|
|
498
425
|
*
|
|
499
|
-
*
|
|
500
|
-
* `
|
|
501
|
-
*
|
|
502
|
-
|
|
426
|
+
* @param ...args - `[pathParams, request, requestOptions]`. `pathParams` identifies the channel
|
|
427
|
+
* (`{ type, id }`); `request.connection_id` is replaced by this client's connection ID.
|
|
428
|
+
* @returns The server response.
|
|
429
|
+
*/
|
|
430
|
+
stopWatchingChannel(...args: Parameters<ChatApi['stopWatchingChannel']>): Promise<StreamResponse<import(".").Response>>;
|
|
431
|
+
/**
|
|
432
|
+
* Queries channels and returns the raw API response. See {@link queryChannelsAndHydrate} for
|
|
433
|
+
* `Channel` instances.
|
|
503
434
|
*
|
|
504
435
|
* @param ...args - `[request, requestOptions]`. The optional `request` accepts MongoDB-style
|
|
505
436
|
* filter conditions, sort directions (e.g. `[{ field: 'created_at', direction: -1 }]`), and
|
|
506
|
-
* options such as `predefined_filter`, `filter_values`, and `sort_values`. `
|
|
507
|
-
*
|
|
508
|
-
*
|
|
437
|
+
* options such as `predefined_filter`, `filter_values`, and `sort_values`. `state`, `watch` and
|
|
438
|
+
* `presence` default to `true`, `true` and `false`. `requestOptions` carries per-request
|
|
439
|
+
* options such as an abort `signal` and is never serialized into the request.
|
|
440
|
+
* @returns The full query channels response, including metadata such as `predefined_filter`.
|
|
509
441
|
*/
|
|
510
442
|
queryChannels(...args: Parameters<ChatApi['queryChannels']>): Promise<StreamResponse<QueryChannelsResponse>>;
|
|
511
443
|
/**
|
|
512
|
-
* Queries channels and hydrates them into `Channel` instances on this client
|
|
513
|
-
*
|
|
514
|
-
* Use the inherited `queryChannels()` from `ChatApi` when only the raw API response
|
|
515
|
-
* is needed; this method wraps it with state hydration, `channels.queried` dispatch,
|
|
516
|
-
* and offline-db sync.
|
|
444
|
+
* Queries channels and hydrates them into `Channel` instances on this client, dispatching
|
|
445
|
+
* `channels.queried` and syncing the offline DB. Use `queryChannels()` for the raw API response.
|
|
517
446
|
*
|
|
518
447
|
* @param options - The query channels request payload (optional). Accepts MongoDB-style filter
|
|
519
448
|
* conditions, sort directions (e.g. `[{ field: 'created_at', direction: -1 }]`), and options
|
|
520
449
|
* such as `predefined_filter`, `filter_values`, and `sort_values`.
|
|
521
|
-
* @param stateOptions - Options that only affect state management and
|
|
522
|
-
*
|
|
523
|
-
* @param stateOptions.
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
* @param stateOptions.withResponse - Returns the full query response with hydrated channels.
|
|
528
|
-
* This is a compatibility bridge for internal callers that need response-level metadata while
|
|
529
|
-
* the default return value remains `Channel[]` (optional).
|
|
530
|
-
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
450
|
+
* @param stateOptions - Options that only affect state management and are not sent in the
|
|
451
|
+
* request. Defaults to `{}`.
|
|
452
|
+
* @param stateOptions.skipHydration - Not read: it has no effect.
|
|
453
|
+
* @param stateOptions.withResponse - Returns the full query response (with hydrated `channels`)
|
|
454
|
+
* instead of `Channel[]`.
|
|
455
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
531
456
|
* into the request (optional).
|
|
532
457
|
* @returns The hydrated channel list, or the full response when `withResponse` is `true`.
|
|
533
458
|
*/
|
|
534
|
-
queryChannelsAndHydrate(options
|
|
459
|
+
queryChannelsAndHydrate(options: QueryChannelsRequest | undefined, stateOptions: ChannelStateOptions & {
|
|
535
460
|
withResponse: true;
|
|
536
461
|
}, requestOptions?: StreamRequestOptions): Promise<QueryChannelsResponseWithChannels>;
|
|
537
462
|
queryChannelsAndHydrate(options?: QueryChannelsRequest, stateOptions?: ChannelStateOptions, requestOptions?: StreamRequestOptions): Promise<Channel[]>;
|
|
538
463
|
/**
|
|
539
|
-
* Queries
|
|
540
|
-
* request.
|
|
464
|
+
* Queries a message's reactions. On the first page, cached offline reactions are dispatched
|
|
465
|
+
* (`offline_reactions.queried`) before the network request.
|
|
541
466
|
*
|
|
542
|
-
* @param
|
|
543
|
-
* MongoDB-style filters, sort directions (e.g.
|
|
544
|
-
* and pagination options
|
|
545
|
-
*
|
|
546
|
-
* into the request (optional).
|
|
467
|
+
* @param ...args - `[pathParams, request, requestOptions]`. `pathParams.id` is the target message
|
|
468
|
+
* ID; `request` carries MongoDB-style filters, sort directions (e.g.
|
|
469
|
+
* `[{ field: 'created_at', direction: -1 }]`) and pagination options; `requestOptions` carries
|
|
470
|
+
* per-request options such as an abort `signal` and is never serialized into the request.
|
|
547
471
|
* @returns The query reactions response.
|
|
548
472
|
*/
|
|
549
|
-
queryReactionsAndHydrate(
|
|
550
|
-
|
|
473
|
+
queryReactionsAndHydrate(...args: Parameters<ChatApi['queryReactions']>): Promise<StreamResponse<import(".").QueryReactionsResponse>>;
|
|
474
|
+
hydrateChannels(channelsFromApi?: ChannelStateResponseFields[], stateOptions?: ChannelStateOptions, queryChannelsOptions?: ChannelOptions, headIntervalItemIdsAtRequestByCid?: Map<string, ReadonlySet<string>>): Channel[];
|
|
551
475
|
/**
|
|
552
|
-
*
|
|
476
|
+
* Returns the channel with the given type and ID: the stored instance for the cid, or a new one,
|
|
477
|
+
* stored (one instance per cid; a channel disposed with `disconnect()` is replaced by a fresh
|
|
478
|
+
* one). Use it instead of `new Channel()`.
|
|
553
479
|
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* Caches one channel's server configuration, read through {@link Channel.serverConfig}.
|
|
480
|
+
* For a distinct channel between users, leave out the ID and pass the members. It is stored under
|
|
481
|
+
* a temporary cid until the response of `channel.watch()`, `query()` or `create()` brings the
|
|
482
|
+
* real one; a stored distinct channel with the same loaded members is returned instead. If
|
|
483
|
+
* another instance holds the real cid by then, it stays stored and takes over from this one
|
|
484
|
+
* (`channel.supersededBy`; `watch()` resolves with it). A group with the same members as another
|
|
485
|
+
* needs its own ID. Until its query is answered such a channel is
|
|
486
|
+
* {@link Channel.isProvisional}: it has no ID yet, so nothing but that query can be sent for it.
|
|
563
487
|
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
* the API returns a fresh object every time and the store compares by reference.
|
|
571
|
-
*
|
|
572
|
-
* @internal
|
|
573
|
-
*/
|
|
574
|
-
_addChannelConfig({ cid, config }: Pick<ChannelResponse, 'cid' | 'config'>): void;
|
|
575
|
-
/**
|
|
576
|
-
* Returns a new channel with the given type, ID and custom data.
|
|
577
|
-
*
|
|
578
|
-
* If you want to create a unique conversation between 2 or more users, you can leave out the ID
|
|
579
|
-
* parameter and provide the list of members.
|
|
580
|
-
* Make sure to await `channel.create()` or `channel.watch()` before accessing channel functions,
|
|
581
|
-
* i.e. `channel = client.channel('messaging', { members: ['tommaso', 'thierry'] })` then
|
|
582
|
-
* `await channel.create()` to assign an ID to the channel.
|
|
488
|
+
* ```ts
|
|
489
|
+
* const general = client.channel('messaging', 'general');
|
|
490
|
+
* const dm = await client
|
|
491
|
+
* .channel('messaging', { members: [{ user_id: 'ann' }, { user_id: 'bob' }] })
|
|
492
|
+
* .watch();
|
|
493
|
+
* ```
|
|
583
494
|
*
|
|
584
495
|
* @param channelType - The channel type.
|
|
585
|
-
* @param
|
|
586
|
-
*
|
|
587
|
-
* @param custom -
|
|
588
|
-
*
|
|
496
|
+
* @param channelId - The channel ID; leave it out for a distinct channel created from members
|
|
497
|
+
* (optional).
|
|
498
|
+
* @param custom - Data for a new channel, e.g. `members` or `custom`; for a stored channel only
|
|
499
|
+
* `custom` is applied. Defaults to `{}`.
|
|
500
|
+
* @returns The channel; initialize it with `channel.watch()`.
|
|
589
501
|
*/
|
|
590
502
|
channel(channelType: string, channelId?: string | null, custom?: ChannelInput): Channel;
|
|
591
503
|
channel(channelType: string, custom?: ChannelInput): Channel;
|
|
592
504
|
/**
|
|
593
|
-
*
|
|
594
|
-
* channel based on member list instead of ID.
|
|
595
|
-
*
|
|
596
|
-
* If the channel already exists in `activeChannels` list, then we simply return it, since that
|
|
597
|
-
* means the same channel was already requested or created.
|
|
505
|
+
* Searches messages.
|
|
598
506
|
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
* @
|
|
604
|
-
* @
|
|
605
|
-
* @returns The channel object; initialize it using `channel.watch()`.
|
|
507
|
+
* @param ...args - `[request, requestOptions]`. The optional `request.payload` accepts channel
|
|
508
|
+
* `filter_conditions`, `message_filter_conditions`, a `query`, and options such as `limit`,
|
|
509
|
+
* `offset`, `next` and `sort`. `requestOptions` carries per-request options such as an abort
|
|
510
|
+
* `signal` and is never serialized into the request.
|
|
511
|
+
* @returns The search messages response.
|
|
512
|
+
* @throws When both `offset` and `next` are given.
|
|
606
513
|
*/
|
|
607
|
-
|
|
514
|
+
search(...args: Parameters<ChatApi['search']>): Promise<StreamResponse<import(".").SearchResponse>>;
|
|
608
515
|
/**
|
|
609
|
-
*
|
|
610
|
-
*
|
|
611
|
-
*
|
|
612
|
-
*
|
|
516
|
+
* Caches one channel's server configuration, keyed by cid (see {@link Channel.serverConfig}).
|
|
517
|
+
* Skips the write for a response without `config` (`notification.message_new` omits it) and for a
|
|
518
|
+
* config deep-equal to the stored one: the API returns a fresh object each time and the store
|
|
519
|
+
* compares by reference.
|
|
613
520
|
*
|
|
614
|
-
*
|
|
615
|
-
*
|
|
616
|
-
* @private
|
|
617
|
-
*
|
|
618
|
-
* @param channelType - The channel type.
|
|
619
|
-
* @param channelId - The channel ID.
|
|
620
|
-
* @param custom - Custom data to attach to the channel.
|
|
621
|
-
* @returns The channel object; initialize it using `channel.watch()`.
|
|
521
|
+
* @internal
|
|
622
522
|
*/
|
|
623
|
-
|
|
523
|
+
_addChannelConfig({ cid, config }: Pick<ChannelResponse, 'cid' | 'config'>): void;
|
|
624
524
|
/**
|
|
625
|
-
*
|
|
525
|
+
* Revokes a global ban.
|
|
626
526
|
*
|
|
627
527
|
* @param targetUserId - The user to unban.
|
|
628
528
|
* @param options - Unban options (optional).
|
|
@@ -633,98 +533,74 @@ export declare class StreamChat extends ChatApi {
|
|
|
633
533
|
getBlockedUsers(...args: Parameters<ChatApi['getBlockedUsers']>): Promise<StreamResponse<import(".").GetBlockedUsersResponse>>;
|
|
634
534
|
unblockUser(blockedUserId: string, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UnblockUsersResponse>>;
|
|
635
535
|
/**
|
|
636
|
-
* Checks whether a user is muted.
|
|
536
|
+
* Checks whether a user is muted.
|
|
637
537
|
*
|
|
638
538
|
* @param targetId - The user ID to check.
|
|
639
539
|
* @returns `true` if the user is muted, otherwise `false`.
|
|
540
|
+
* @throws When no user is connected.
|
|
640
541
|
*/
|
|
641
542
|
userMuteStatus(targetId: string): boolean;
|
|
642
|
-
/**
|
|
643
|
-
* Transforms an expiration value into an ISO string.
|
|
644
|
-
*
|
|
645
|
-
* A `number` is an offset in SECONDS, not a timestamp — passing a wire `pin_expires` overflows
|
|
646
|
-
* `Date`, which used to surface as an opaque `RangeError` from `toISOString()`.
|
|
647
|
-
*
|
|
648
|
-
* @param timeoutOrExpirationDate - Expiration date or timeout. Use `number` to set the timeout
|
|
649
|
-
* in seconds, `string` or `Date` to set the exact expiration date (optional).
|
|
650
|
-
* @returns The expiration as an ISO string, or `null`.
|
|
651
|
-
* @throws If a numeric offset does not resolve to a representable date.
|
|
652
|
-
*/
|
|
653
|
-
_normalizeExpiration(timeoutOrExpirationDate?: null | number | string | Date): string | null;
|
|
654
|
-
/**
|
|
655
|
-
* Extracts a string message ID from either a message object or a message ID.
|
|
656
|
-
*
|
|
657
|
-
* @param messageOrMessageId - MessageRequest object or message ID.
|
|
658
|
-
* @param errorText - Error message to report in case of message ID absence.
|
|
659
|
-
* @returns The extracted message ID.
|
|
660
|
-
*/
|
|
661
|
-
_validateAndGetMessageId(messageOrMessageId: string | {
|
|
662
|
-
id: string;
|
|
663
|
-
}, errorText: string): string;
|
|
664
543
|
/**
|
|
665
544
|
* Pins the message.
|
|
666
545
|
*
|
|
667
|
-
* @param
|
|
668
|
-
* @param
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
546
|
+
* @param message - The message to pin, or just its `{ id }`.
|
|
547
|
+
* @param options - When the pin expires and where it sorts (optional).
|
|
548
|
+
* @param options.pin_expires - When the pin expires, as a `Date` or an RFC3339 string; `null` or
|
|
549
|
+
* leaving it out pins without expiry. Hand a server-sent timestamp back with `nsToDate(timestamp)`.
|
|
550
|
+
* @param options.pinned_at - The pin time, which orders the pinned messages, as a `Date` or an
|
|
551
|
+
* RFC3339 string (optional). Defaults to now.
|
|
673
552
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
674
553
|
* into the request (optional).
|
|
675
554
|
* @returns The updated message response.
|
|
676
555
|
*/
|
|
677
|
-
pinMessage(
|
|
556
|
+
pinMessage({ id }: {
|
|
678
557
|
id: string;
|
|
679
|
-
},
|
|
558
|
+
}, { pin_expires, pinned_at }?: PinMessageOptions, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMessagePartialResponse>>;
|
|
680
559
|
/**
|
|
681
560
|
* Unpins the message that was previously pinned.
|
|
682
561
|
*
|
|
683
|
-
* @param
|
|
562
|
+
* @param message - The message to unpin, or just its `{ id }`.
|
|
684
563
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
685
564
|
* into the request (optional).
|
|
686
565
|
* @returns The updated message response.
|
|
687
566
|
*/
|
|
688
|
-
unpinMessage(
|
|
567
|
+
unpinMessage({ id }: {
|
|
689
568
|
id: string;
|
|
690
569
|
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMessagePartialResponse>>;
|
|
691
570
|
/**
|
|
692
|
-
* Updates
|
|
693
|
-
*
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
requestOptions?: StreamRequestOptions
|
|
702
|
-
]): Promise<import(".").UpdateMessageResponse & {
|
|
703
|
-
metadata: import("./types").RequestMetadata;
|
|
704
|
-
}>;
|
|
705
|
-
_updateMessage(...args: Parameters<ChatApi['updateMessage']>): Promise<StreamResponse<import(".").UpdateMessageResponse>>;
|
|
571
|
+
* Updates a message over HTTP only: no offline queueing and no local state.
|
|
572
|
+
* `messageOperations.update` on a channel or thread is the full edit.
|
|
573
|
+
*
|
|
574
|
+
* @param ...args - `[pathParams, request, requestOptions]`. `pathParams.id` is the message ID;
|
|
575
|
+
* `request.message` is the updated message; `requestOptions` carries per-request options such
|
|
576
|
+
* as an abort `signal` and is never serialized into the request.
|
|
577
|
+
* @returns The update message response.
|
|
578
|
+
*/
|
|
579
|
+
updateMessage(...args: Parameters<ChatApi['updateMessage']>): Promise<StreamResponse<import(".").UpdateMessageResponse>>;
|
|
706
580
|
/**
|
|
707
|
-
* Deletes a message
|
|
708
|
-
* is
|
|
581
|
+
* Deletes a message over HTTP only: no offline queueing and no local state.
|
|
582
|
+
* `messageOperations.delete` on a channel or thread is the full delete.
|
|
583
|
+
*
|
|
584
|
+
* @param ...args - `[pathParams, request, requestOptions]`. `pathParams.id` is the message ID;
|
|
585
|
+
* `request.hard` deletes it permanently and `request.delete_for_me` deletes it for the current
|
|
586
|
+
* user only; `requestOptions` carries per-request options such as an abort `signal` and is
|
|
587
|
+
* never serialized into the request.
|
|
588
|
+
* @returns The delete message response.
|
|
709
589
|
*/
|
|
710
|
-
deleteMessage(...args: Parameters<ChatApi['deleteMessage']>): Promise<import(".").DeleteMessageResponse
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
*
|
|
716
|
-
*
|
|
717
|
-
* @param options -
|
|
718
|
-
*
|
|
719
|
-
* @param options.
|
|
720
|
-
* @param options.
|
|
721
|
-
* @param
|
|
722
|
-
* @param options.reply_limit - Limits the number of replies returned per thread (optional).
|
|
723
|
-
* @param options.filter - MongoDB style filters for threads (optional).
|
|
724
|
-
* @param options.sort - MongoDB style sort for threads (optional).
|
|
725
|
-
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
590
|
+
deleteMessage(...args: Parameters<ChatApi['deleteMessage']>): Promise<StreamResponse<import(".").DeleteMessageResponse>>;
|
|
591
|
+
/**
|
|
592
|
+
* Returns the current user's threads as hydrated `Thread` instances.
|
|
593
|
+
*
|
|
594
|
+
* @param options - Pagination and limits for the participants and replies. Defaults to `{}`.
|
|
595
|
+
* @param options.limit - Limits the number of threads returned. Defaults to 10.
|
|
596
|
+
* @param options.watch - Subscribes the user to the channels of the threads. Defaults to `true`.
|
|
597
|
+
* @param options.participant_limit - Limits the participants returned per thread. Defaults to 10.
|
|
598
|
+
* @param options.reply_limit - Limits the replies returned per thread. Defaults to 3.
|
|
599
|
+
* @param options.filter - MongoDB-style filters for threads (optional).
|
|
600
|
+
* @param options.sort - MongoDB-style sort for threads (optional).
|
|
601
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
726
602
|
* into the request (optional).
|
|
727
|
-
* @returns The
|
|
603
|
+
* @returns The threads and the next cursor.
|
|
728
604
|
*/
|
|
729
605
|
queryThreadsAndHydrate(options?: QueryThreadsRequest, requestOptions?: StreamRequestOptions): Promise<{
|
|
730
606
|
threads: Thread[];
|
|
@@ -733,17 +609,20 @@ export declare class StreamChat extends ChatApi {
|
|
|
733
609
|
/**
|
|
734
610
|
* Returns the thread of a message by its ID, wrapped in a hydrated `Thread` instance.
|
|
735
611
|
*
|
|
736
|
-
* @param
|
|
737
|
-
* @param
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
* @param options.
|
|
741
|
-
* @param options.
|
|
612
|
+
* @param pathParams - The thread's parent message, as for `getThread`.
|
|
613
|
+
* @param pathParams.message_id - The parent message ID.
|
|
614
|
+
* @param options - Options object for pagination and limiting the participants and replies.
|
|
615
|
+
* Defaults to `{}`.
|
|
616
|
+
* @param options.watch - Subscribes the user to the channel of the thread. Defaults to `true`.
|
|
617
|
+
* @param options.participant_limit - Limits the participants returned. Defaults to 100.
|
|
618
|
+
* @param options.reply_limit - Limits the replies returned. Defaults to 3.
|
|
742
619
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
743
620
|
* into the request (optional).
|
|
744
621
|
* @returns The thread.
|
|
745
622
|
*/
|
|
746
|
-
getThreadAndHydrate(
|
|
623
|
+
getThreadAndHydrate({ message_id: messageId }: {
|
|
624
|
+
message_id: string;
|
|
625
|
+
}, options?: GetThreadOptions, requestOptions?: StreamRequestOptions): Promise<Thread>;
|
|
747
626
|
getUserAgent: () => string;
|
|
748
627
|
/**
|
|
749
628
|
* Sets the user agent string.
|
|
@@ -753,53 +632,60 @@ export declare class StreamChat extends ChatApi {
|
|
|
753
632
|
* @param userAgent - The user agent string.
|
|
754
633
|
*/
|
|
755
634
|
setUserAgent(userAgent: string): void;
|
|
756
|
-
_cacheEnabled: () => boolean;
|
|
757
635
|
_startCleaning(): void;
|
|
758
636
|
/**
|
|
759
|
-
*
|
|
637
|
+
* The JSON-encoded WebSocket auth message, sent as the first frame once the socket opens.
|
|
760
638
|
*
|
|
761
|
-
*
|
|
762
|
-
|
|
639
|
+
* @private
|
|
640
|
+
*/
|
|
641
|
+
_buildWSAuthMessage: () => string;
|
|
642
|
+
/**
|
|
643
|
+
* The auth message that {@link _buildWSAuthMessage} encodes for the WebSocket and the long-poll
|
|
644
|
+
* fallback sends as `longPoll()`'s `json` query param.
|
|
763
645
|
*
|
|
764
646
|
* @private
|
|
765
647
|
*
|
|
766
|
-
* @
|
|
648
|
+
* @param token - The long-poll passes none: it authenticates through the `Authorization` header.
|
|
767
649
|
*/
|
|
768
|
-
|
|
650
|
+
_buildWSAuthPayload: (token?: string) => WSAuthMessage;
|
|
769
651
|
/**
|
|
770
|
-
* Queries poll answers
|
|
652
|
+
* Queries poll answers: the votes with `is_answer: true`.
|
|
771
653
|
*
|
|
772
|
-
* @param
|
|
773
|
-
* filter conditions, sort directions, and pagination options
|
|
774
|
-
*
|
|
775
|
-
*
|
|
654
|
+
* @param ...args - `[pathParams, request, requestOptions]`. `pathParams.poll_id` is the poll ID;
|
|
655
|
+
* `request` carries optional vote filter conditions, sort directions, and pagination options
|
|
656
|
+
* (`limit`, `next`, `prev`); `requestOptions` carries per-request options such as an abort
|
|
657
|
+
* `signal` and is never serialized into the request.
|
|
776
658
|
* @returns The poll answers.
|
|
777
659
|
*/
|
|
778
|
-
queryPollAnswers(
|
|
660
|
+
queryPollAnswers(...args: Parameters<ChatApi['queryPollVotes']>): Promise<StreamResponse<import(".").PollVotesResponse>>;
|
|
779
661
|
/**
|
|
780
|
-
* Uploads a file to the Stream CDN
|
|
662
|
+
* Uploads a file to the Stream CDN.
|
|
781
663
|
*
|
|
782
664
|
* @param request - Upload payload. `request.file` is the file to upload.
|
|
783
|
-
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
784
|
-
*
|
|
665
|
+
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
666
|
+
* (optional).
|
|
667
|
+
* @returns The upload response, with the file URL.
|
|
785
668
|
*/
|
|
786
669
|
uploadFile(request?: Omit<FileUploadRequest, 'file'> & {
|
|
787
670
|
file?: FileUploadInput;
|
|
788
671
|
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").FileUploadResponse>>;
|
|
789
672
|
/**
|
|
790
|
-
* Uploads an image to Stream CDN
|
|
673
|
+
* Uploads an image to the Stream CDN.
|
|
791
674
|
*
|
|
792
675
|
* @param request - Upload payload. `request.file` is the image to upload.
|
|
793
|
-
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
794
|
-
*
|
|
676
|
+
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
677
|
+
* (optional).
|
|
678
|
+
* @returns The upload response, with the image URL.
|
|
795
679
|
*/
|
|
796
680
|
uploadImage(request?: Omit<ImageUploadRequest, 'file'> & {
|
|
797
681
|
file?: FileUploadInput;
|
|
798
682
|
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").ImageUploadResponse>>;
|
|
799
683
|
/**
|
|
800
|
-
* Marks
|
|
684
|
+
* Marks channels as delivered for the given messages.
|
|
801
685
|
*
|
|
802
686
|
* @param request - Mark delivered options.
|
|
687
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
688
|
+
* into the request (optional).
|
|
803
689
|
* @returns The server response, or `undefined` if there are no messages to mark.
|
|
804
690
|
*/
|
|
805
691
|
markChannelsDelivered(request?: Gen_MarkDeliveredRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").MarkDeliveredResponse> | undefined>;
|