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