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/channel.d.ts
CHANGED
|
@@ -3,326 +3,206 @@ import { CooldownTimer } from './CooldownTimer';
|
|
|
3
3
|
import { MessageComposer } from './messageComposer';
|
|
4
4
|
import { MessageReceiptsTracker } from './messageDelivery';
|
|
5
5
|
import { MessagePaginator, PinnedMessagePaginator } from './pagination/paginators';
|
|
6
|
-
import { MessageOperations } from './messageOperations';
|
|
6
|
+
import type { MessageOperations } from './messageOperations';
|
|
7
|
+
import type { OperationRequestFn } from './messageOperations/types';
|
|
7
8
|
import type { StreamChat } from './client';
|
|
8
9
|
import type { ChannelDeclarativeConfig } from './configuration/types';
|
|
9
|
-
import type { AIState, BanUserOptions, ChannelGetOrCreateRequest, ChannelInput, ChannelMemberResponse, ChannelResponse,
|
|
10
|
-
import type { StateStore } from '
|
|
11
|
-
import type {
|
|
10
|
+
import type { AddMembersRequest, AIState, BanUserOptions, ChannelGetOrCreateRequest, ChannelInput, ChannelMemberResponse, ChannelResponse, ChannelStateResponse, ChannelStateResponseFields, Command, Event, EventHandler, EventPayload, EventType, FileUploadInput, FilterTagsRequest, InviteMembersRequest, LocalMessage, MarkReadRequest, MarkReadResponse, MessageResponse, QueryMembersPayload, RemoveMembersRequest, SharedLocation, StreamRequestOptions, StreamResponse, TimestampNS, UnBanUserOptions, UpdateChannelPartialRequest, UpdateLiveLocationRequest, UserResponse } from './types';
|
|
11
|
+
import type { StateStore } from '@stream-io/state-store';
|
|
12
|
+
import type { ChannelPushPreferencesResponse as Gen_ChannelPushPreferencesResponse, MuteChannelRequest as Gen_MuteChannelRequest, UnmuteChannelRequest as Gen_UnmuteChannelRequest, UploadChannelFileRequest, UploadChannelRequest } from './gen/models';
|
|
12
13
|
import type { ChatApi } from './gen/chat/ChatApi';
|
|
13
14
|
import { ChannelApi } from './gen/chat/ChannelApi';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
message?: MessageRequest;
|
|
17
|
-
options?: SendMessageOptions;
|
|
18
|
-
/**
|
|
19
|
-
* Per-call override for the send/retry request (advanced).
|
|
20
|
-
* If set, it takes precedence over channel instance configuration handlers.
|
|
21
|
-
*/
|
|
22
|
-
sendMessageRequestFn?: CustomSendMessageRequestFn;
|
|
23
|
-
};
|
|
24
|
-
export type RetrySendMessageWithLocalUpdateParams = Omit<SendMessageWithStateUpdateParams, 'message'>;
|
|
25
|
-
export type UpdateMessageWithStateUpdateParams = {
|
|
26
|
-
localMessage: LocalMessage;
|
|
27
|
-
options?: UpdateMessageOptions;
|
|
28
|
-
/**
|
|
29
|
-
* Per-call override for the update request (advanced).
|
|
30
|
-
* If set, it takes precedence over channel instance configuration handlers.
|
|
31
|
-
*/
|
|
32
|
-
updateMessageRequestFn?: CustomUpdateMessageRequestFn;
|
|
33
|
-
};
|
|
34
|
-
export type DeleteMessageWithStateUpdateParams = {
|
|
35
|
-
localMessage: LocalMessage;
|
|
36
|
-
options?: DeleteMessageOptions;
|
|
37
|
-
/**
|
|
38
|
-
* Per-call override for the delete request (advanced).
|
|
39
|
-
* If set, it takes precedence over channel instance configuration handlers.
|
|
40
|
-
*/
|
|
41
|
-
deleteMessageRequestFn?: CustomDeleteMessageRequestFn;
|
|
42
|
-
};
|
|
43
|
-
export type CustomSendMessageRequestFn = (params: Omit<SendMessageWithStateUpdateParams, 'sendMessageRequestFn'>) => Promise<{
|
|
44
|
-
message: MessageResponse;
|
|
45
|
-
}>;
|
|
46
|
-
export type CustomUpdateMessageRequestFn = (params: Omit<UpdateMessageWithStateUpdateParams, 'updateMessageRequestFn'>) => Promise<{
|
|
47
|
-
message: MessageResponse;
|
|
48
|
-
}>;
|
|
49
|
-
export type CustomDeleteMessageRequestFn = (params: Omit<DeleteMessageWithStateUpdateParams, 'deleteMessageRequestFn'>) => Promise<{
|
|
50
|
-
message: MessageResponse;
|
|
51
|
-
}>;
|
|
15
|
+
/** Re-exported here because `src/messageOperations` is not in the root barrel. */
|
|
16
|
+
export type { DefaultOperationRequest, MessageOperationSpec, OperationKind, OperationParams, OperationRequestFn, OperationResponse, } from './messageOperations/types';
|
|
52
17
|
export type CustomMarkReadRequestFn = (params: {
|
|
53
18
|
channel: Channel;
|
|
54
19
|
options?: MarkReadRequest;
|
|
55
20
|
}) => Promise<Partial<StreamResponse<MarkReadResponse>> | null>;
|
|
56
21
|
/**
|
|
57
|
-
* A channel's
|
|
58
|
-
*
|
|
59
|
-
* Not `ChannelConfigWithInfo`, which is the generated type for the channel *type's server*
|
|
60
|
-
* configuration behind {@link Channel.serverConfig}. The two are related: the gates below are the
|
|
61
|
-
* server's flags already ANDed with what the integrator registered.
|
|
22
|
+
* A channel's resolved configuration, returned by {@link Channel.config}. The gates are the server's
|
|
23
|
+
* flags (see {@link Channel.serverConfig}) ANDed with what the integrator registered.
|
|
62
24
|
*/
|
|
63
25
|
export type ChannelConfig = {
|
|
64
26
|
requestHandlers?: {
|
|
65
|
-
deleteMessageRequest?:
|
|
27
|
+
deleteMessageRequest?: OperationRequestFn<'delete'>;
|
|
66
28
|
markReadRequest?: CustomMarkReadRequestFn;
|
|
67
|
-
sendMessageRequest?:
|
|
68
|
-
retrySendMessageRequest?:
|
|
69
|
-
updateMessageRequest?:
|
|
29
|
+
sendMessageRequest?: OperationRequestFn<'send'>;
|
|
30
|
+
retrySendMessageRequest?: OperationRequestFn<'retry'>;
|
|
31
|
+
updateMessageRequest?: OperationRequestFn<'update'>;
|
|
70
32
|
};
|
|
71
33
|
/**
|
|
72
|
-
* Typing indicators
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* This is the channel-wide gate, read by {@link Channel.keystroke} and {@link Channel.stopTyping}.
|
|
76
|
-
* `messageComposer.text.publishTypingEvents` sits on top of it as a per-composer refinement — a thread
|
|
77
|
-
* composer can stay quiet while the channel still permits typing events.
|
|
34
|
+
* Typing indicators. Defaults to enabled. ANDed with the channel type's `typing_events`. Read by
|
|
35
|
+
* {@link Channel.keystroke} and {@link Channel.stopTyping}.
|
|
36
|
+
* `messageComposer.text.publishTypingEvents` further switches them off per composer.
|
|
78
37
|
*/
|
|
79
38
|
typingEvents: {
|
|
80
39
|
enabled: boolean;
|
|
81
40
|
};
|
|
82
41
|
/**
|
|
83
|
-
* Read receipts
|
|
84
|
-
*
|
|
85
|
-
* {@link Channel.markUnread}.
|
|
42
|
+
* Read receipts. `enabled` is ANDed with the channel type's `read_events`. Together with the own
|
|
43
|
+
* `read-events` capability it decides {@link Channel.readEventsEnabled}, which gates counting
|
|
44
|
+
* unread messages, {@link Channel.markRead} and {@link Channel.markUnread}. Defaults to `true`.
|
|
45
|
+
*
|
|
46
|
+
* `localUnreadCountEnabled` applies only while read events are off
|
|
47
|
+
* ({@link Channel.readEventsEnabled} is false): the channel keeps counting unread messages and
|
|
48
|
+
* {@link Channel.markReadLocally} resets the count, sending nothing to the server. The server does
|
|
49
|
+
* not restrict it. Defaults to `false`.
|
|
86
50
|
*/
|
|
87
51
|
readEvents: {
|
|
88
52
|
enabled: boolean;
|
|
53
|
+
localUnreadCountEnabled: boolean;
|
|
89
54
|
};
|
|
90
|
-
/**
|
|
91
|
-
* Threaded replies for this channel (defaults to enabled). ANDed with the channel type's `replies`.
|
|
92
|
-
*/
|
|
55
|
+
/** Threaded replies. Defaults to enabled. ANDed with the channel type's `replies`. */
|
|
93
56
|
replies: {
|
|
94
57
|
enabled: boolean;
|
|
95
58
|
};
|
|
96
59
|
/**
|
|
97
|
-
* Message reminders
|
|
98
|
-
* type's `user_message_reminders`.
|
|
60
|
+
* Message reminders. Defaults to enabled. ANDed with the channel type's `user_message_reminders`.
|
|
99
61
|
*/
|
|
100
62
|
userMessageReminders: {
|
|
101
63
|
enabled: boolean;
|
|
102
64
|
};
|
|
103
|
-
/**
|
|
104
|
-
* Delivery receipts (defaults to enabled). ANDed with the channel type's `delivery_events`.
|
|
105
|
-
*/
|
|
65
|
+
/** Delivery receipts. Defaults to enabled. ANDed with the channel type's `delivery_events`. */
|
|
106
66
|
deliveryEvents: {
|
|
107
67
|
enabled: boolean;
|
|
108
68
|
};
|
|
109
69
|
/**
|
|
110
|
-
* The slash commands
|
|
111
|
-
*
|
|
112
|
-
* Named for availability rather than enablement on purpose: whether any given command can be *used*
|
|
113
|
-
* right now is `messageComposer.isCommandDisabled(command)`, which depends on the message context —
|
|
114
|
-
* editing and quoting disable different ones. A list called `enabledCommands` would routinely contain
|
|
115
|
-
* disabled entries.
|
|
116
|
-
*
|
|
117
|
-
* **Server-owned, and the one field here the integrator cannot set.** It is a list rather than a gate,
|
|
118
|
-
* so there is nothing to AND and no intent to express — the server's answer simply *is* the value, and
|
|
119
|
-
* it is absent from the declarative tree for that reason.
|
|
120
|
-
*
|
|
121
|
-
* It lives on the resolved configuration anyway so that consumers never need a second place to look:
|
|
122
|
-
* every question about what this channel permits is answered by `config`. Reading the raw
|
|
123
|
-
* {@link Channel.serverConfig} instead is what made a UI show features the client had disabled — the
|
|
124
|
-
* gates below have a client half, and mixing the two sources meant sometimes reading only one.
|
|
70
|
+
* The slash commands the channel type offers. Server-owned: the integrator cannot set it. Whether a
|
|
71
|
+
* command can be used right now is `messageComposer.isCommandDisabled(command)`.
|
|
125
72
|
*/
|
|
126
73
|
availableCommands: Command[];
|
|
127
74
|
};
|
|
128
75
|
export declare const DEFAULT_CHANNEL_CONFIG: ChannelConfig;
|
|
129
|
-
/**
|
|
130
|
-
* The Channel class manages its own state.
|
|
131
|
-
*/
|
|
132
76
|
export declare class Channel extends ChannelApi {
|
|
133
77
|
_client: StreamChat;
|
|
134
|
-
data: Partial<ChannelResponse> | undefined;
|
|
135
78
|
_data: ChannelInput;
|
|
136
79
|
cid: string;
|
|
137
|
-
/** */
|
|
138
80
|
listeners: Map<EventType, Set<EventHandler>>;
|
|
139
81
|
state: ChannelState;
|
|
140
82
|
lastKeyStroke?: Date;
|
|
141
83
|
lastTypingEvent: Date | null;
|
|
142
84
|
isTyping: boolean;
|
|
143
|
-
/** Re-entrancy guard for {@link Channel.reload}
|
|
85
|
+
/** Re-entrancy guard for {@link Channel.reload}. */
|
|
144
86
|
private _reloading;
|
|
145
|
-
/** Refcount
|
|
87
|
+
/** Refcount behind the `active` flag: several consumers can hold one instance. */
|
|
146
88
|
private _activeRefCount;
|
|
147
|
-
|
|
89
|
+
/** Stops releaseUnusedChannels() from removing a channel while a query for it is still running. */
|
|
90
|
+
private _channelQueriesInFlight;
|
|
91
|
+
/** The watch queries {@link Channel.watch} callers wait for, joined by equal options. */
|
|
92
|
+
private _watchQueriesInFlight;
|
|
148
93
|
/**
|
|
149
|
-
* The
|
|
150
|
-
* `
|
|
151
|
-
*
|
|
152
|
-
* `mergeSlice: 'deep'` because the config has nested groups: registering `typingEvents.enabled` must
|
|
153
|
-
* not drop `readEvents`. `applyAuthority` is what makes `channel.config` the *whole* answer rather
|
|
154
|
-
* than the client's half — see {@link serverRestrictions}.
|
|
94
|
+
* The options of the last {@link Channel.watch} query that succeeded during the current watch: a
|
|
95
|
+
* `watch()` with these options has nothing to send. Cleared when the watch ends.
|
|
155
96
|
*/
|
|
97
|
+
private _lastWatchOptions?;
|
|
98
|
+
push_preferences?: Gen_ChannelPushPreferencesResponse;
|
|
156
99
|
private readonly configController;
|
|
157
100
|
readonly messageComposer: MessageComposer;
|
|
158
101
|
readonly messageReceiptsTracker: MessageReceiptsTracker;
|
|
102
|
+
readonly messageOperations: MessageOperations;
|
|
159
103
|
readonly messagePaginator: MessagePaginator;
|
|
160
104
|
readonly pinnedMessagesPaginator: PinnedMessagePaginator;
|
|
161
|
-
readonly messageOperations: MessageOperations;
|
|
162
105
|
readonly cooldownTimer: CooldownTimer;
|
|
163
|
-
/**
|
|
164
|
-
* Teardown for this channel's configuration subscription, released by {@link _disconnect}. Channels
|
|
165
|
-
* are retained in `client.activeChannels`, so leaving this subscribed would keep growing the
|
|
166
|
-
* configuration store's handler set across reconnects.
|
|
167
|
-
*/
|
|
168
106
|
private unsubscribeConfiguration?;
|
|
169
|
-
/** Teardown for the server-config re-derivation subscription, released by {@link _disconnect}. */
|
|
170
107
|
private unsubscribeServerConfig?;
|
|
171
|
-
/** The declarative slice last derived from, so a late server
|
|
108
|
+
/** The declarative slice last derived from, so a late server config can re-derive from it. */
|
|
172
109
|
private declarativeConfig?;
|
|
173
110
|
/**
|
|
174
|
-
* Creates
|
|
111
|
+
* Creates an uninitialized channel. Without an `id` its `cid` is a temporary one built from
|
|
112
|
+
* `data.members`, until the server answers.
|
|
175
113
|
*
|
|
176
114
|
* @param client - The chat client.
|
|
177
|
-
* @param type - The type
|
|
178
|
-
* @param id - The ID
|
|
179
|
-
* @param data -
|
|
180
|
-
* @returns A new uninitialized channel.
|
|
115
|
+
* @param type - The channel type.
|
|
116
|
+
* @param id - The channel ID, or `undefined` for a channel created from members.
|
|
117
|
+
* @param data - Data for the channel (members, custom fields).
|
|
181
118
|
*/
|
|
182
119
|
constructor(client: StreamChat, type: string, id: string | undefined, data: ChannelInput);
|
|
183
|
-
/**
|
|
184
|
-
* The configuration fields this channel's *type* decides server-side.
|
|
185
|
-
*
|
|
186
|
-
* Both are boolean gates, so `mergeServerRestrictions` ANDs them with what was requested: either the
|
|
187
|
-
* server or the integrator may switch a feature off, and neither can widen. Re-read on every
|
|
188
|
-
* derivation rather than captured, so a flag that changes mid-session is picked up.
|
|
189
|
-
*/
|
|
120
|
+
/** Flags the channel type decides server-side (ANDed with the requested ones). */
|
|
190
121
|
private get serverRestrictions();
|
|
191
122
|
/**
|
|
192
|
-
*
|
|
123
|
+
* Re-derives the configuration of the channel, its paginators and its message operations from the
|
|
124
|
+
* declarative slice. Runs at construction, on every change to the `channel`, `messagePaginator` or
|
|
125
|
+
* `messageOperations` configuration, and on `client.config.reset()`.
|
|
193
126
|
*
|
|
194
|
-
*
|
|
195
|
-
* `requestHandlers`; each sub-object derives its own configuration, so the knowledge of what
|
|
196
|
-
* `messagePaginator.pageSize` means stays inside the paginator.
|
|
127
|
+
* @param declarativeConfig - The channel's declarative slice (optional).
|
|
197
128
|
*/
|
|
198
129
|
initializeConfig(declarativeConfig?: ChannelDeclarativeConfig): void;
|
|
199
130
|
/**
|
|
200
|
-
* Returns the chat client for this channel.
|
|
201
|
-
* {@link Channel.pendingDisposal}.
|
|
131
|
+
* Returns the chat client for this channel.
|
|
202
132
|
*
|
|
203
133
|
* @returns The chat client.
|
|
134
|
+
* @throws If the channel is pending disposal ({@link Channel.pendingDisposal}).
|
|
204
135
|
*/
|
|
205
136
|
getClient(): StreamChat;
|
|
206
|
-
|
|
207
|
-
* Resolved configuration, as a store. Delegates rather than holding a copy, so the field and the
|
|
208
|
-
* controller's store cannot drift.
|
|
209
|
-
*
|
|
210
|
-
* Still directly writable, and deliberately so: the React SDK installs per-component request handlers
|
|
211
|
-
* by calling `partialNext({ requestHandlers })` on it. That write bypasses the controller, which is
|
|
212
|
-
* why `requestHandlers` is the one field a re-derivation replaces wholesale — see
|
|
213
|
-
* {@link initializeConfig}.
|
|
214
|
-
*/
|
|
137
|
+
private disposedError;
|
|
215
138
|
get configState(): StateStore<ChannelConfig>;
|
|
216
|
-
/**
|
|
217
|
-
* This channel's **resolved** configuration — the shape every configurable class exposes.
|
|
218
|
-
*
|
|
219
|
-
* Not to be confused with {@link serverConfig}, which is this channel's configuration as the
|
|
220
|
-
* server reports it. This one has already folded that in: `typingEvents.enabled` is the server's
|
|
221
|
-
* `typing_events` ANDed with whatever the integrator registered, so it is the whole answer. The
|
|
222
|
-
* near-collision is why the server side became `serverConfig`, a getter that says what it
|
|
223
|
-
* is.
|
|
224
|
-
*/
|
|
225
139
|
get config(): Readonly<ChannelConfig>;
|
|
226
140
|
/**
|
|
227
|
-
*
|
|
228
|
-
* `
|
|
229
|
-
*
|
|
230
|
-
* Mostly a property of the channel *type*, but not only: a channel's own `config_overrides` narrow it
|
|
231
|
-
* for that channel alone, which is why the cache behind this is keyed by cid rather than by type. See
|
|
232
|
-
* `StreamChat._addChannelConfig`.
|
|
233
|
-
*
|
|
234
|
-
* `undefined` until this channel has been queried or watched — there is nothing to fall back on that
|
|
235
|
-
* would not be another channel's overrides. {@link config} covers that case with its defaults.
|
|
236
|
-
*
|
|
237
|
-
* Distinct from {@link config}, which is this instance's resolved configuration and already has the
|
|
238
|
-
* relevant flags below folded into it. Prefer `config` when deciding whether a feature is available:
|
|
239
|
-
* this getter answers only the server's half, so gating UI on it offers features the client has
|
|
240
|
-
* already disabled.
|
|
141
|
+
* The channel's configuration as the server reports it (`uploads`, `typing_events`, `commands`, ...),
|
|
142
|
+
* including this channel's `config_overrides`. `undefined` until the channel is queried or watched.
|
|
143
|
+
* Gate features on {@link config} instead: it also folds in what the integrator disabled.
|
|
241
144
|
*/
|
|
242
145
|
get serverConfig(): import(".").ChannelConfigWithInfo | undefined;
|
|
243
|
-
_sendMessage(...args: Parameters<ChannelApi['sendMessage']>): Promise<StreamResponse<import(".").SendMessageResponse>>;
|
|
244
146
|
/**
|
|
245
|
-
* Sends a message to this channel.
|
|
147
|
+
* Sends a message to this channel. Strips `localMetadata` from attachments and drops those whose
|
|
148
|
+
* upload never completed.
|
|
246
149
|
*
|
|
247
150
|
* @param ...args - `[request, requestOptions]`. `request` holds the message body and optional
|
|
248
151
|
* flags such as `skip_enrich_url`, `skip_push`, and `keep_channel_hidden`; `requestOptions`
|
|
249
152
|
* carries per-request options such as an abort `signal` and is never serialized into the request.
|
|
250
153
|
* @returns The server response.
|
|
251
154
|
*/
|
|
252
|
-
sendMessage(...args: Parameters<ChannelApi['sendMessage']>): Promise<import(".").SendMessageResponse
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Sends a message with optimistic local state update.
|
|
257
|
-
*/
|
|
258
|
-
sendMessageWithLocalUpdate(params: SendMessageWithStateUpdateParams): Promise<void>;
|
|
259
|
-
/**
|
|
260
|
-
* Retry sending a failed message.
|
|
261
|
-
*/
|
|
262
|
-
retrySendMessageWithLocalUpdate(params: Omit<SendMessageWithStateUpdateParams, 'message'>): Promise<void>;
|
|
263
|
-
/**
|
|
264
|
-
* Updates a message with optimistic local state update.
|
|
265
|
-
*/
|
|
266
|
-
updateMessageWithLocalUpdate(params: UpdateMessageWithStateUpdateParams): Promise<void>;
|
|
267
|
-
/**
|
|
268
|
-
* Deletes a message with local state update.
|
|
269
|
-
*/
|
|
270
|
-
deleteMessageWithLocalUpdate(params: DeleteMessageWithStateUpdateParams): Promise<void>;
|
|
271
|
-
/**
|
|
272
|
-
* Adds a reaction with an optimistic local state update - see {@link addReactionOptimistically}.
|
|
273
|
-
*/
|
|
274
|
-
addReactionWithLocalUpdate({ messageId, reaction, options, }: {
|
|
275
|
-
messageId: string;
|
|
276
|
-
reaction: ReactionRequest;
|
|
277
|
-
options?: Pick<SendReactionRequest, 'enforce_unique' | 'skip_push'>;
|
|
278
|
-
}): Promise<void>;
|
|
279
|
-
/**
|
|
280
|
-
* Removes the current user's reaction with an optimistic local state update - see
|
|
281
|
-
* {@link deleteReactionOptimistically}.
|
|
282
|
-
*/
|
|
283
|
-
deleteReactionWithLocalUpdate({ messageId, type, }: {
|
|
284
|
-
messageId: string;
|
|
285
|
-
type: string;
|
|
286
|
-
}): Promise<void>;
|
|
155
|
+
sendMessage(...args: Parameters<ChannelApi['sendMessage']>): Promise<StreamResponse<import(".").SendMessageResponse>>;
|
|
156
|
+
sendReaction(...args: Parameters<ChatApi['sendReaction']>): Promise<StreamResponse<import(".").SendReactionResponse>>;
|
|
157
|
+
deleteReaction(...args: Parameters<ChatApi['deleteReaction']>): Promise<StreamResponse<import(".").DeleteReactionResponse>>;
|
|
287
158
|
/**
|
|
288
|
-
*
|
|
159
|
+
* Uploads a file to this channel's file endpoint (multipart).
|
|
289
160
|
*
|
|
290
161
|
* @param request - Upload payload. `request.file` is the file to upload.
|
|
291
|
-
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
292
|
-
*
|
|
162
|
+
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
163
|
+
* (optional).
|
|
164
|
+
* @returns The upload response, with the CDN URL in `file`.
|
|
293
165
|
*/
|
|
294
166
|
uploadChannelFile(request?: Omit<UploadChannelFileRequest, 'file'> & {
|
|
295
167
|
file?: FileUploadInput;
|
|
296
168
|
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UploadChannelFileResponse>>;
|
|
297
169
|
/**
|
|
298
|
-
*
|
|
170
|
+
* Uploads an image to this channel's image endpoint (multipart).
|
|
299
171
|
*
|
|
300
172
|
* @param request - Upload payload. `request.file` is the image to upload.
|
|
301
|
-
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
302
|
-
*
|
|
173
|
+
* @param requestOptions - Per-request options, e.g. `onUploadProgress` or an abort `signal`
|
|
174
|
+
* (optional).
|
|
175
|
+
* @returns The upload response, with the CDN URL in `file`.
|
|
303
176
|
*/
|
|
304
177
|
uploadChannelImage(request?: Omit<UploadChannelRequest, 'file'> & {
|
|
305
178
|
file?: FileUploadInput;
|
|
306
179
|
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UploadChannelResponse>>;
|
|
307
|
-
/**
|
|
308
|
-
* Alias for {@link uploadChannelFile}, mirroring `client.uploadFile`.
|
|
309
|
-
*/
|
|
180
|
+
/** Alias for {@link uploadChannelFile}. */
|
|
310
181
|
uploadFile: (...args: Parameters<Channel["uploadChannelFile"]>) => Promise<StreamResponse<import(".").UploadChannelFileResponse>>;
|
|
311
|
-
/** Alias for {@link uploadChannelImage}
|
|
182
|
+
/** Alias for {@link uploadChannelImage}. */
|
|
312
183
|
uploadImage: (...args: Parameters<Channel["uploadChannelImage"]>) => Promise<StreamResponse<import(".").UploadChannelResponse>>;
|
|
313
|
-
deleteFile(url: string, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").Response>>;
|
|
314
|
-
deleteImage(url: string, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").Response>>;
|
|
315
184
|
/**
|
|
316
|
-
*
|
|
185
|
+
* Deletes a file uploaded to this channel, the same request shape as `client.deleteFile`.
|
|
186
|
+
*
|
|
187
|
+
* @param request - The file to delete. `request.url` is its URL.
|
|
188
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
189
|
+
* into the request (optional).
|
|
190
|
+
* @returns The server response.
|
|
191
|
+
*/
|
|
192
|
+
deleteFile(request: {
|
|
193
|
+
url: string;
|
|
194
|
+
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").Response>>;
|
|
195
|
+
/**
|
|
196
|
+
* Deletes an image uploaded to this channel, the same request shape as `client.deleteImage`.
|
|
317
197
|
*
|
|
318
|
-
* @param request -
|
|
198
|
+
* @param request - The image to delete. `request.url` is its URL.
|
|
319
199
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
320
200
|
* into the request (optional).
|
|
321
201
|
* @returns The server response.
|
|
322
202
|
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").
|
|
203
|
+
deleteImage(request: {
|
|
204
|
+
url: string;
|
|
205
|
+
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").Response>>;
|
|
326
206
|
/**
|
|
327
207
|
* Queries members.
|
|
328
208
|
*
|
|
@@ -337,48 +217,19 @@ export declare class Channel extends ChannelApi {
|
|
|
337
217
|
payload?: Partial<QueryMembersPayload>;
|
|
338
218
|
}, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").MembersResponse>>;
|
|
339
219
|
/**
|
|
340
|
-
*
|
|
341
|
-
* that sending the reaction is queued up if it fails due to bad internet conditions and executed
|
|
342
|
-
* later.
|
|
343
|
-
*
|
|
344
|
-
* @param ...args - `[request, requestOptions]`. `request` holds the target message ID, the
|
|
345
|
-
* reaction object (e.g. `{ type: 'love' }`), and optional flags such as `enforce_unique` and
|
|
346
|
-
* `skip_push`; `requestOptions` carries per-request options such as an abort `signal`.
|
|
347
|
-
* When the call is queued for offline replay, `requestOptions` is queued with it - see the
|
|
348
|
-
* note on signal persistence in `AbstractOfflineDB.queueTask`.
|
|
349
|
-
* @returns The server response.
|
|
350
|
-
*/
|
|
351
|
-
sendReaction(...args: Parameters<ChatApi['sendReaction']>): Promise<import(".").SendReactionResponse & {
|
|
352
|
-
metadata: import("./types").RequestMetadata;
|
|
353
|
-
}>;
|
|
354
|
-
_sendReaction(...args: Parameters<ChatApi['sendReaction']>): Promise<StreamResponse<import(".").SendReactionResponse>>;
|
|
355
|
-
deleteReaction(...args: Parameters<ChatApi['deleteReaction']>): Promise<import(".").DeleteReactionResponse & {
|
|
356
|
-
metadata: import("./types").RequestMetadata;
|
|
357
|
-
}>;
|
|
358
|
-
/**
|
|
359
|
-
* Deletes a reaction by user and type.
|
|
360
|
-
*
|
|
361
|
-
* @param ...args - `[request, requestOptions]`. `request` identifies the target message and
|
|
362
|
-
* reaction type; `requestOptions` carries per-request options such as an abort `signal` and is
|
|
363
|
-
* never serialized into the request.
|
|
364
|
-
* @returns The server response.
|
|
365
|
-
*/
|
|
366
|
-
_deleteReaction(...args: Parameters<ChatApi['deleteReaction']>): Promise<StreamResponse<import(".").DeleteReactionResponse>>;
|
|
367
|
-
/**
|
|
368
|
-
* Edit the channel using the inherited `update()` from `ChannelApi`. Caches the
|
|
369
|
-
* server-returned channel onto `this.data`.
|
|
220
|
+
* Updates the channel and stores the returned channel in `this.data`.
|
|
370
221
|
*
|
|
371
222
|
* @param ...args - `[request, requestOptions]`. `request` is the channel update payload, e.g.
|
|
372
|
-
* `{ data: { name: 'foo' }, message }`; `requestOptions` carries per-request options
|
|
373
|
-
* abort `signal` and is never serialized into the request.
|
|
223
|
+
* `{ data: { custom: { name: 'foo' } }, message }`; `requestOptions` carries per-request options
|
|
224
|
+
* such as an abort `signal` and is never serialized into the request.
|
|
374
225
|
* @returns The server response.
|
|
375
226
|
*/
|
|
376
227
|
update(...args: Parameters<ChannelApi['update']>): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
377
228
|
/**
|
|
378
|
-
*
|
|
229
|
+
* Partially updates the channel's properties and stores the returned channel in `this.data`.
|
|
379
230
|
*
|
|
380
231
|
* @param update - The partial update request.
|
|
381
|
-
* @param
|
|
232
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
382
233
|
* into the request (optional).
|
|
383
234
|
* @returns The server response.
|
|
384
235
|
*/
|
|
@@ -387,7 +238,7 @@ export declare class Channel extends ChannelApi {
|
|
|
387
238
|
* Enables slow mode.
|
|
388
239
|
*
|
|
389
240
|
* @param coolDownInterval - The cooldown interval in seconds.
|
|
390
|
-
* @param
|
|
241
|
+
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
391
242
|
* into the request (optional).
|
|
392
243
|
* @returns The server response.
|
|
393
244
|
*/
|
|
@@ -395,11 +246,13 @@ export declare class Channel extends ChannelApi {
|
|
|
395
246
|
/**
|
|
396
247
|
* Disables slow mode.
|
|
397
248
|
*
|
|
249
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
250
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
398
251
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
399
252
|
* into the request (optional).
|
|
400
253
|
* @returns The server response.
|
|
401
254
|
*/
|
|
402
|
-
disableSlowMode(requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
255
|
+
disableSlowMode(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
403
256
|
sendSharedLocation(location: SharedLocation & {
|
|
404
257
|
message_id?: string;
|
|
405
258
|
}): Promise<import(".").SendMessageResponse & {
|
|
@@ -409,217 +262,183 @@ export declare class Channel extends ChannelApi {
|
|
|
409
262
|
/**
|
|
410
263
|
* Accepts an invitation to the channel.
|
|
411
264
|
*
|
|
412
|
-
* @param options -
|
|
265
|
+
* @param options - Other channel update options to send with it. Defaults to `{}`.
|
|
413
266
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
414
267
|
* into the request (optional).
|
|
415
268
|
* @returns The server response.
|
|
416
269
|
*/
|
|
417
|
-
acceptInvite(options?:
|
|
270
|
+
acceptInvite(options?: NonNullable<Parameters<ChannelApi['update']>[0]>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
418
271
|
/**
|
|
419
272
|
* Rejects an invitation to the channel.
|
|
420
273
|
*
|
|
421
|
-
* @param options -
|
|
274
|
+
* @param options - Other channel update options to send with it. Defaults to `{}`.
|
|
422
275
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
423
276
|
* into the request (optional).
|
|
424
277
|
* @returns The server response.
|
|
425
278
|
*/
|
|
426
|
-
rejectInvite(options?:
|
|
279
|
+
rejectInvite(options?: NonNullable<Parameters<ChannelApi['update']>[0]>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
427
280
|
/**
|
|
428
281
|
* Adds members to the channel.
|
|
429
282
|
*
|
|
430
|
-
* @param
|
|
431
|
-
* @param
|
|
432
|
-
* @param
|
|
283
|
+
* @param request - The members to add, and any other channel update option.
|
|
284
|
+
* @param request.members - User IDs, or member requests (`{ user_id, channel_role?, custom? }`).
|
|
285
|
+
* @param request.message - Message object for channel members notification (optional).
|
|
433
286
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
434
287
|
* into the request (optional).
|
|
435
288
|
* @returns The server response.
|
|
436
289
|
*/
|
|
437
|
-
addMembers(members
|
|
290
|
+
addMembers({ members, ...options }: AddMembersRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
438
291
|
/**
|
|
439
292
|
* Adds filter tags to the channel.
|
|
440
293
|
*
|
|
441
|
-
* @param
|
|
442
|
-
* @param
|
|
443
|
-
* @param
|
|
294
|
+
* @param request - The tags to add, and any other channel update option.
|
|
295
|
+
* @param request.tags - The tags to add.
|
|
296
|
+
* @param request.message - Message object for channel members notification (optional).
|
|
444
297
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
445
298
|
* into the request (optional).
|
|
446
299
|
* @returns The server response.
|
|
447
300
|
*/
|
|
448
|
-
addFilterTags(tags
|
|
301
|
+
addFilterTags({ tags, ...options }: FilterTagsRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
449
302
|
/**
|
|
450
303
|
* Removes filter tags from the channel.
|
|
451
304
|
*
|
|
452
|
-
* @param
|
|
453
|
-
* @param
|
|
454
|
-
* @param
|
|
455
|
-
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
456
|
-
* into the request (optional).
|
|
457
|
-
* @returns The server response.
|
|
458
|
-
*/
|
|
459
|
-
removeFilterTags(tags: string[], message?: MessageRequest, options?: ChannelUpdateOptions, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
460
|
-
/**
|
|
461
|
-
* Adds moderators to the channel.
|
|
462
|
-
*
|
|
463
|
-
* @param members - An array of member identifiers.
|
|
464
|
-
* @param message - Message object for channel members notification (optional).
|
|
465
|
-
* @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
|
|
305
|
+
* @param request - The tags to remove, and any other channel update option.
|
|
306
|
+
* @param request.tags - The tags to remove.
|
|
307
|
+
* @param request.message - Message object for channel members notification (optional).
|
|
466
308
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
467
309
|
* into the request (optional).
|
|
468
310
|
* @returns The server response.
|
|
469
311
|
*/
|
|
470
|
-
|
|
312
|
+
removeFilterTags({ tags, ...options }: FilterTagsRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
471
313
|
/**
|
|
472
314
|
* Invite members to the channel.
|
|
473
315
|
*
|
|
474
|
-
* @param
|
|
475
|
-
* @param
|
|
476
|
-
* @param
|
|
316
|
+
* @param request - The members to invite, and any other channel update option.
|
|
317
|
+
* @param request.members - User IDs, or member requests (`{ user_id, custom }`).
|
|
318
|
+
* @param request.message - Message object for channel members notification (optional).
|
|
477
319
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
478
320
|
* into the request (optional).
|
|
479
321
|
* @returns The server response.
|
|
480
322
|
*/
|
|
481
|
-
inviteMembers(members
|
|
323
|
+
inviteMembers({ members, ...options }: InviteMembersRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
482
324
|
/**
|
|
483
325
|
* Removes members from the channel.
|
|
484
326
|
*
|
|
485
|
-
* @param
|
|
486
|
-
* @param
|
|
487
|
-
* @param
|
|
488
|
-
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
489
|
-
* into the request (optional).
|
|
490
|
-
* @returns The server response.
|
|
491
|
-
*/
|
|
492
|
-
removeMembers(members: string[], message?: MessageRequest, options?: ChannelUpdateOptions, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
493
|
-
/**
|
|
494
|
-
* Removes the moderator role from channel members.
|
|
495
|
-
*
|
|
496
|
-
* @param members - An array of member identifiers.
|
|
497
|
-
* @param message - Message object for channel members notification (optional).
|
|
498
|
-
* @param options - Configuration to control the behavior while updating (optional, defaults to `{}`).
|
|
327
|
+
* @param request - The members to remove, and any other channel update option.
|
|
328
|
+
* @param request.members - The user IDs to remove.
|
|
329
|
+
* @param request.message - Message object for channel members notification (optional).
|
|
499
330
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
500
331
|
* into the request (optional).
|
|
501
332
|
* @returns The server response.
|
|
502
333
|
*/
|
|
503
|
-
|
|
334
|
+
removeMembers({ members, ...options }: RemoveMembersRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateChannelResponse>>;
|
|
504
335
|
/**
|
|
505
|
-
* Mutes the
|
|
336
|
+
* Mutes the channel.
|
|
506
337
|
*
|
|
507
338
|
* @example
|
|
508
|
-
* // with expiration
|
|
509
|
-
* await channel.mute({ expiration:
|
|
339
|
+
* // with expiration (two weeks)
|
|
340
|
+
* await channel.mute({ expiration: 14 * 24 * 60 * 60 * 1000 });
|
|
510
341
|
*
|
|
511
|
-
* @
|
|
512
|
-
*
|
|
513
|
-
* await channel.mute({ user_id: userId });
|
|
514
|
-
*
|
|
515
|
-
* @param options - Mute options (optional, defaults to `{}`).
|
|
516
|
-
* @param options.expiration - Expiration in minutes (optional).
|
|
342
|
+
* @param options - Mute options (optional).
|
|
343
|
+
* @param options.expiration - Mute duration in milliseconds (optional).
|
|
517
344
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
518
345
|
* into the request (optional).
|
|
519
346
|
* @returns The server response.
|
|
520
347
|
*/
|
|
521
348
|
mute(options?: Gen_MuteChannelRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").MuteChannelResponse>>;
|
|
522
349
|
/**
|
|
523
|
-
* Unmutes the
|
|
350
|
+
* Unmutes the channel.
|
|
524
351
|
*
|
|
525
352
|
* @example
|
|
526
|
-
*
|
|
527
|
-
* await channel.unmute({ user_id: userId });
|
|
353
|
+
* await channel.unmute();
|
|
528
354
|
*
|
|
529
|
-
* @param options - Unmute options (optional
|
|
530
|
-
* @param options.user_id - User ID (optional).
|
|
355
|
+
* @param options - Unmute options (optional).
|
|
531
356
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
532
357
|
* into the request (optional).
|
|
533
358
|
* @returns The server response.
|
|
534
359
|
*/
|
|
535
360
|
unmute(options?: Gen_UnmuteChannelRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UnmuteResponse>>;
|
|
536
361
|
/**
|
|
537
|
-
* Archives the current
|
|
362
|
+
* Archives the channel for the current user.
|
|
538
363
|
*
|
|
539
364
|
* @example
|
|
540
365
|
* await channel.archive();
|
|
541
366
|
*
|
|
367
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
368
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
542
369
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
543
370
|
* into the request (optional).
|
|
544
371
|
* @returns The server response.
|
|
545
372
|
*/
|
|
546
|
-
archive(requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
373
|
+
archive(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
547
374
|
/**
|
|
548
|
-
* Unarchives the current
|
|
375
|
+
* Unarchives the channel for the current user.
|
|
549
376
|
*
|
|
550
377
|
* @example
|
|
551
378
|
* await channel.unarchive();
|
|
552
379
|
*
|
|
380
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
381
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
553
382
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
554
383
|
* into the request (optional).
|
|
555
384
|
* @returns The server response.
|
|
556
385
|
*/
|
|
557
|
-
unarchive(requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
386
|
+
unarchive(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
558
387
|
/**
|
|
559
|
-
* Pins the current
|
|
388
|
+
* Pins the channel for the current user.
|
|
560
389
|
*
|
|
561
390
|
* @example
|
|
562
391
|
* await channel.pin();
|
|
563
392
|
*
|
|
393
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
394
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
564
395
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
565
396
|
* into the request (optional).
|
|
566
397
|
* @returns The server response.
|
|
567
398
|
*/
|
|
568
|
-
pin(requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
399
|
+
pin(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
569
400
|
/**
|
|
570
|
-
* Unpins the current
|
|
401
|
+
* Unpins the channel for the current user.
|
|
571
402
|
*
|
|
572
403
|
* @example
|
|
573
404
|
* await channel.unpin();
|
|
574
405
|
*
|
|
406
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
407
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
575
408
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
576
409
|
* into the request (optional).
|
|
577
410
|
* @returns The server response.
|
|
578
411
|
*/
|
|
579
|
-
unpin(requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
412
|
+
unpin(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").UpdateMemberPartialResponse>>;
|
|
580
413
|
/**
|
|
581
|
-
* Returns the mute status
|
|
414
|
+
* Returns the mute status of the channel.
|
|
582
415
|
*
|
|
583
|
-
* @returns
|
|
416
|
+
* @returns `{ muted, createdAt, expiresAt }`, the timestamps in unix nanoseconds as the API sends
|
|
417
|
+
* them.
|
|
584
418
|
*/
|
|
585
|
-
muteStatus():
|
|
586
|
-
muted: boolean;
|
|
587
|
-
createdAt: Date;
|
|
588
|
-
expiresAt: Date | null;
|
|
589
|
-
} | {
|
|
590
|
-
muted: boolean;
|
|
591
|
-
createdAt: null;
|
|
592
|
-
expiresAt: null;
|
|
593
|
-
};
|
|
419
|
+
muteStatus(): import("./channel_state").ChannelMuteStatus;
|
|
594
420
|
/**
|
|
595
|
-
* Recomputes
|
|
596
|
-
*
|
|
597
|
-
* churn subscribers. Called from the constructor and by the client whenever `mutedChannels`
|
|
598
|
-
* updates. Unlike `muteStatus()`, this does not require the channel to be initialized.
|
|
421
|
+
* Recomputes `state.muteStatus` from `client.mutedChannels`, publishing only on change (the client
|
|
422
|
+
* calls this on every `mutedChannels` update). Unlike `muteStatus()`, it needs no channel ID.
|
|
599
423
|
*/
|
|
600
424
|
_syncMuteStatus(): void;
|
|
601
425
|
sendAction(messageId: string, formData: Record<string, string>, requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").MessageActionResponse>>;
|
|
602
426
|
/**
|
|
603
|
-
*
|
|
604
|
-
* Call this on every keystroke.
|
|
427
|
+
* Call on every keystroke: sends `typing.start` at most every 2 seconds.
|
|
605
428
|
*
|
|
606
429
|
* @see {@link https://getstream.io/chat/docs/typing_indicators/?language=js|Docs}
|
|
607
430
|
*
|
|
608
|
-
* @param parentId -
|
|
609
|
-
* @param options - Optional override carrying a `user_id` (optional).
|
|
431
|
+
* @param parentId - The parent message ID, for a typing event in a thread (optional).
|
|
610
432
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
611
433
|
* into the request (optional).
|
|
612
434
|
*/
|
|
613
|
-
keystroke(parentId?: string,
|
|
614
|
-
user_id: string;
|
|
615
|
-
}, requestOptions?: StreamRequestOptions): Promise<void>;
|
|
435
|
+
keystroke(parentId?: string, requestOptions?: StreamRequestOptions): Promise<void>;
|
|
616
436
|
/**
|
|
617
|
-
*
|
|
618
|
-
* Typically used by the server connected to the AI service to notify clients of state changes.
|
|
437
|
+
* Notifies watchers of a message's AI state. Meant for the server connected to the AI service.
|
|
619
438
|
*
|
|
620
439
|
* @param messageId - The ID of the message associated with the AI state.
|
|
621
440
|
* @param state - The new state of the AI process, e.g. thinking, generating.
|
|
622
|
-
* @param options -
|
|
441
|
+
* @param options - Additional details for the event. Defaults to `{}`.
|
|
623
442
|
* @param options.ai_message - Additional message detail to include in the event (optional).
|
|
624
443
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
625
444
|
* into the request (optional).
|
|
@@ -631,170 +450,200 @@ export declare class Channel extends ChannelApi {
|
|
|
631
450
|
* Sends an event to notify watchers to clear the typing/thinking UI when the AI response starts streaming.
|
|
632
451
|
* Typically used by the server connected to the AI service to inform clients that the AI response has started.
|
|
633
452
|
*
|
|
453
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
454
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
634
455
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
635
456
|
* into the request (optional).
|
|
636
457
|
*/
|
|
637
|
-
clearAIIndicator(requestOptions?: StreamRequestOptions): Promise<void>;
|
|
458
|
+
clearAIIndicator(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<void>;
|
|
638
459
|
/**
|
|
639
460
|
* Sends an event to stop AI response generation, leaving the message in its current state.
|
|
640
461
|
* Triggered by the user to halt the AI response process.
|
|
641
462
|
*
|
|
463
|
+
* @param _request - Unused. Holds the request position so `requestOptions` stays the
|
|
464
|
+
* second argument, as on the generated methods; pass `undefined`.
|
|
642
465
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
643
466
|
* into the request (optional).
|
|
644
467
|
*/
|
|
645
|
-
stopAIResponse(requestOptions?: StreamRequestOptions): Promise<void>;
|
|
468
|
+
stopAIResponse(_request?: Record<string, never>, requestOptions?: StreamRequestOptions): Promise<void>;
|
|
646
469
|
/**
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
* @see {@link https://getstream.io/chat/docs/typing_indicators/?language=js|Docs}
|
|
470
|
+
* Resets the typing state and sends `typing.stop`.
|
|
650
471
|
*
|
|
651
|
-
* @param parentId -
|
|
652
|
-
* @param options - Optional override carrying a `user_id` (optional).
|
|
472
|
+
* @param parentId - The parent message ID, for a typing event in a thread (optional).
|
|
653
473
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
654
474
|
* into the request (optional).
|
|
655
475
|
*/
|
|
656
|
-
stopTyping(parentId?: string,
|
|
657
|
-
user_id: string;
|
|
658
|
-
}, requestOptions?: StreamRequestOptions): Promise<void>;
|
|
476
|
+
stopTyping(parentId?: string, requestOptions?: StreamRequestOptions): Promise<void>;
|
|
659
477
|
_isTypingIndicatorsEnabled(): boolean;
|
|
660
478
|
/**
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
|
|
479
|
+
* Whether read events are on. `config.readEvents.enabled` (the channel type's `read_events` and
|
|
480
|
+
* the client configuration) and the own `read-events` capability allow them. Unread messages are
|
|
481
|
+
* counted and marked read only while it is true, unless `readEvents.localUnreadCountEnabled` keeps
|
|
482
|
+
* a local count.
|
|
483
|
+
*/
|
|
484
|
+
get readEventsEnabled(): boolean;
|
|
485
|
+
/**
|
|
486
|
+
* Marks read through `MessageDeliveryReporter`: uses the `markReadRequest` handler if set, marks
|
|
487
|
+
* read locally when read events are off and `localUnreadCountEnabled` is set, and drops the
|
|
488
|
+
* delivery candidate when a request went out. `markRead()` does none of this.
|
|
666
489
|
*
|
|
667
|
-
* @param data - Mark read options
|
|
490
|
+
* @param data - Mark read options. Defaults to `{}`.
|
|
491
|
+
* @returns The server response, or `null` when no request went out.
|
|
668
492
|
*/
|
|
669
493
|
markReadViaReporter(data?: MarkReadRequest): Promise<Partial<StreamResponse<MarkReadResponse>> | null>;
|
|
670
494
|
/**
|
|
671
|
-
*
|
|
672
|
-
* channel to be initialized and respects the `read_events` channel config.
|
|
495
|
+
* Marks the channel read.
|
|
673
496
|
*
|
|
674
497
|
* @param ...args - `[data, requestOptions]`. `data` holds the mark-read options;
|
|
675
498
|
* `requestOptions` carries per-request options such as an abort `signal` and is never
|
|
676
499
|
* serialized into the request.
|
|
677
|
-
* @returns The server response
|
|
500
|
+
* @returns The server response.
|
|
501
|
+
* @throws If the channel is not initialized or read events are disabled.
|
|
678
502
|
*/
|
|
679
503
|
markRead(...args: Parameters<ChannelApi['markRead']>): Promise<StreamResponse<MarkReadResponse>>;
|
|
680
|
-
/**
|
|
681
|
-
* A vague indication of whether the channel exists on the chat backend — `true` once
|
|
682
|
-
* `create()`/`query()`/`watch()` has run. Store-backed and reactive: subscribe via
|
|
683
|
-
* `useStateStore(channel.state, (s) => ({ initialized: s.initialized }))`.
|
|
684
|
-
*/
|
|
504
|
+
/** See {@link ChannelLifecycleState.initialized}. */
|
|
685
505
|
get initialized(): boolean;
|
|
686
506
|
set initialized(initialized: boolean);
|
|
687
507
|
/**
|
|
688
|
-
* Whether the channel was
|
|
689
|
-
*
|
|
508
|
+
* Whether the channel has no ID yet: it was built from members and the server assigns the ID when its
|
|
509
|
+
* query is answered. Until then only that query can be sent and the cid is a temporary one.
|
|
510
|
+
*
|
|
511
|
+
* Not reactive: subscribe to {@link Channel.initialized}, which turns `true` with the response that
|
|
512
|
+
* sets `id`.
|
|
513
|
+
*/
|
|
514
|
+
get isProvisional(): boolean;
|
|
515
|
+
/**
|
|
516
|
+
* See {@link ChannelLifecycleState.supersededBy}. A superseded instance receives no events and
|
|
517
|
+
* reports `watchStatus: NotWatching`: use its successor (`watch()` resolves with it). The SDK
|
|
518
|
+
* does not disconnect it before logout, so call {@link Channel.disconnect} once nothing uses it.
|
|
690
519
|
*/
|
|
520
|
+
get supersededBy(): Channel | undefined;
|
|
521
|
+
/** See {@link ChannelLifecycleState.offlineMode}. */
|
|
691
522
|
get offlineMode(): boolean;
|
|
692
523
|
set offlineMode(offlineMode: boolean);
|
|
693
524
|
/**
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
* subscriptions) and the client drops it from `activeChannels` right after, so nothing should
|
|
700
|
-
* touch it: it is skipped by the `client.activeChannels` lookups (so `client.channel(…)` mints a
|
|
701
|
-
* fresh instance), never re-watched on recovery, refused as a source of `channel.data` by the
|
|
702
|
-
* offline DB, and `getClient()` throws on it so a reference held across a `disconnectUser()`
|
|
703
|
-
* fails loudly instead of quietly requesting on a client with no user.
|
|
525
|
+
* Reads `state.data`. Assigning publishes `data`, `memberCount` and `ownCapabilities` in one update.
|
|
526
|
+
* If the object omits `member_count` or `own_capabilities`, the last known values are carried onto
|
|
527
|
+
* a copy (the assigned object is not changed). Editing `channel.data.x` in place does not reach
|
|
528
|
+
* the state. `ownCapabilities` keeps its array while the capabilities stay the same (in any
|
|
529
|
+
* order), so a subscriber to it is notified only when they change.
|
|
704
530
|
*/
|
|
705
|
-
get
|
|
706
|
-
set
|
|
531
|
+
get data(): Partial<ChannelResponse> | undefined;
|
|
532
|
+
set data(next: Partial<ChannelResponse> | undefined);
|
|
707
533
|
/**
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
534
|
+
* See {@link ChannelLifecycleState.pendingDisposal}. Set only by {@link Channel.disconnect} and never
|
|
535
|
+
* reverted: `getClient()` throws, `client.channel()` returns a fresh instance for the
|
|
536
|
+
* cid, and lists and recovery skip it.
|
|
711
537
|
*/
|
|
538
|
+
get pendingDisposal(): boolean;
|
|
539
|
+
/** See {@link ChannelWatchStatus}. */
|
|
712
540
|
get watchStatus(): ChannelWatchStatus;
|
|
713
541
|
set watchStatus(watchStatus: ChannelWatchStatus);
|
|
714
542
|
/**
|
|
715
|
-
* Whether a
|
|
716
|
-
* {@link
|
|
717
|
-
*
|
|
543
|
+
* Whether a query for this channel (`watch()`, `query()`, `create()` or one of the message
|
|
544
|
+
* paginator's own queries, see {@link runTrackedQuery}) awaits its response. The channel store
|
|
545
|
+
* keeps the channel meanwhile.
|
|
546
|
+
*
|
|
547
|
+
* @internal
|
|
718
548
|
*/
|
|
549
|
+
get isQueryingChannel(): boolean;
|
|
550
|
+
/** See {@link Channel.activate}. */
|
|
719
551
|
get active(): boolean;
|
|
720
552
|
/**
|
|
721
|
-
* Declares that a consumer is
|
|
722
|
-
*
|
|
723
|
-
*
|
|
553
|
+
* Declares that a consumer is consuming this channel's own state and returns its release function.
|
|
554
|
+
* Refcounted: the channel stays active until the last consumer releases, and releasing twice is a
|
|
555
|
+
* no-op.
|
|
724
556
|
*
|
|
725
|
-
* While active,
|
|
726
|
-
*
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* Declares that a consumer has stopped consuming this channel (mirrors `thread.deactivate()`).
|
|
731
|
-
* Only flips `active` back to `false` once the last holder deactivates.
|
|
557
|
+
* While active, channel-list hydration places no page in the message list (`channel.reload()`
|
|
558
|
+
* owns it), the message list keeps its active interval (otherwise a fresh newest page from a
|
|
559
|
+
* query the list did not run is shown), and the channel stays in the channel store. A disposed
|
|
560
|
+
* channel is not activated: a warning is logged and the returned release does nothing.
|
|
732
561
|
*/
|
|
733
|
-
|
|
562
|
+
activate: () => (() => void);
|
|
734
563
|
/**
|
|
735
|
-
* Marks the channel
|
|
564
|
+
* Marks the channel unread from a message.
|
|
736
565
|
*
|
|
737
566
|
* @param ...args - `[data, requestOptions]`. `data` holds the mark-unread options;
|
|
738
567
|
* `requestOptions` carries per-request options such as an abort `signal` and is never
|
|
739
568
|
* serialized into the request.
|
|
740
|
-
* @returns
|
|
569
|
+
* @returns The server response.
|
|
570
|
+
* @throws If the channel is not initialized or read events are disabled.
|
|
741
571
|
*/
|
|
742
572
|
markUnread(...args: Parameters<ChannelApi['markUnread']>): Promise<StreamResponse<import(".").Response>>;
|
|
743
573
|
/**
|
|
744
|
-
* Resets
|
|
745
|
-
*
|
|
746
|
-
* `
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
*
|
|
574
|
+
* Resets the unread count without a backend call, for channels with read events off
|
|
575
|
+
* ({@link Channel.readEventsEnabled}, e.g. livestreams) that set `readEvents.localUnreadCountEnabled`. Dispatches the client-only
|
|
576
|
+
* `message.read_locally` event, handled like `message.read` minus the delivery-report sync. With
|
|
577
|
+
* offline support the reset is persisted.
|
|
578
|
+
*
|
|
579
|
+
* The event's `last_read_message_id` is the newest server-confirmed message, whatever its type,
|
|
580
|
+
* of the interval holding the channel's newest messages
|
|
581
|
+
* (`messagePaginator.anchoredHeadServerConfirmedItem`). While that interval is not loaded (e.g.
|
|
582
|
+
* only a jumped-to interval is), the event carries none and the read covers everything up to its
|
|
583
|
+
* `created_at`.
|
|
751
584
|
*
|
|
752
|
-
* @returns The dispatched `message.read_locally` event, or `undefined` if there is no connected
|
|
585
|
+
* @returns The dispatched `message.read_locally` event, or `undefined` if there is no connected
|
|
586
|
+
* user.
|
|
753
587
|
*/
|
|
754
588
|
markReadLocally(): ({
|
|
755
589
|
type: "message.read_locally";
|
|
756
590
|
} & {
|
|
757
591
|
channel_type: string;
|
|
758
592
|
cid: string;
|
|
759
|
-
created_at:
|
|
593
|
+
created_at: TimestampNS;
|
|
760
594
|
channel_id?: string;
|
|
761
595
|
last_read_message_id?: string;
|
|
762
596
|
team?: string;
|
|
763
597
|
user?: UserResponse;
|
|
764
598
|
} & {
|
|
765
|
-
received_at?:
|
|
599
|
+
received_at?: TimestampNS;
|
|
766
600
|
}) | undefined;
|
|
767
601
|
/**
|
|
768
|
-
*
|
|
602
|
+
* Sends `typing.stop` after a second without a keystroke, drops stale typing users, and resets a
|
|
603
|
+
* stuck AI indicator while the connection is unhealthy. Run by the client's cleaning interval.
|
|
604
|
+
*
|
|
605
|
+
* @internal
|
|
769
606
|
*/
|
|
770
607
|
clean(): void;
|
|
771
608
|
/**
|
|
772
|
-
*
|
|
609
|
+
* Watches the channel and loads its state and messages. Sends nothing when that is done already
|
|
610
|
+
* (`Watching`, `initialized` and `messagePaginator.hasResults`) and the call asks for nothing
|
|
611
|
+
* new: it passes no options, or the same options as the last `watch()` that succeeded during the
|
|
612
|
+
* current watch. Other options, e.g. `presence: true`, send a query. A `watch()` already in
|
|
613
|
+
* flight with the same options is joined, not repeated.
|
|
614
|
+
* Refresh a watched channel with {@link Channel.reload}. Rejects with the query's error.
|
|
773
615
|
*
|
|
774
|
-
* @param options -
|
|
775
|
-
* @
|
|
616
|
+
* @param options - Options for the watch query (optional).
|
|
617
|
+
* @param requestOptions - Per-request options (optional). Aborting `signal` ends this caller's
|
|
618
|
+
* wait (at once if aborted already); the query is cancelled once every waiting caller has
|
|
619
|
+
* aborted. The other options apply only when this call sends the query.
|
|
620
|
+
* @returns The instance to use: this one, or the one that superseded it ({@link supersededBy}).
|
|
776
621
|
*/
|
|
777
|
-
watch(options?: ChannelGetOrCreateRequest): Promise<
|
|
622
|
+
watch(options?: ChannelGetOrCreateRequest, requestOptions?: StreamRequestOptions): Promise<Channel>;
|
|
778
623
|
/**
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
*
|
|
789
|
-
*
|
|
624
|
+
* Sends the query {@link Channel.watch} callers wait for. It is cancelled through an abort
|
|
625
|
+
* controller of its own, once no caller waits any more ({@link leaveWatchQuery}).
|
|
626
|
+
*/
|
|
627
|
+
private sendWatchQuery;
|
|
628
|
+
/** A caller stops waiting; the last one cancels and forgets the query, so the next is new. */
|
|
629
|
+
private leaveWatchQuery;
|
|
630
|
+
/** Stops offering `watchQuery` to {@link Channel.watch} callers. */
|
|
631
|
+
private forgetWatchQuery;
|
|
632
|
+
/**
|
|
633
|
+
* Sends a watch query, watched or not, and places the page it fetched (a page at a cursor or
|
|
634
|
+
* around a message is only stored; `messagePaginator.jumpToMessage()` shows it).
|
|
635
|
+
* `requestOptions.signal` also ends the wait for a live socket.
|
|
636
|
+
*/
|
|
637
|
+
private runWatchQuery;
|
|
638
|
+
/**
|
|
639
|
+
* Re-watches the channel and refreshes its whole loaded message interval (the channel analogue of
|
|
640
|
+
* {@link Thread.reload}). Used on reconnect. Hard deletes reach other clients through no event, so
|
|
641
|
+
* the watch query reconciles the loaded newest messages with the re-queried page
|
|
642
|
+
* (`messagePaginator.reconcileNewestMessages`, against the loaded IDs captured before its await).
|
|
790
643
|
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
* a failed message can be absent from memory and still be the user's unsent work — a cold boot starts
|
|
795
|
-
* with an empty paginator, and an eviction can drop it mid-session. v9 got this from a second, lagging
|
|
796
|
-
* copy of the list (the React SDK's own state); with one reactive source of truth the persisted row is
|
|
797
|
-
* that buffer.
|
|
644
|
+
* Failed (unsent) messages are kept: those loaded or in the offline DB (cold boot, eviction)
|
|
645
|
+
* before the request that are no longer loaded after it are ingested again. The offline DB is
|
|
646
|
+
* read on a best-effort basis.
|
|
798
647
|
*/
|
|
799
648
|
reload(): Promise<void>;
|
|
800
649
|
/**
|
|
@@ -807,83 +656,152 @@ export declare class Channel extends ChannelApi {
|
|
|
807
656
|
*/
|
|
808
657
|
stopWatching(...args: Parameters<ChannelApi['stopWatching']>): Promise<StreamResponse<import(".").Response>>;
|
|
809
658
|
/**
|
|
810
|
-
* Retrieves
|
|
659
|
+
* Retrieves messages of this channel by ID.
|
|
811
660
|
*
|
|
812
|
-
* @param messageIds - The IDs of the messages to retrieve
|
|
661
|
+
* @param messageIds - The IDs of the messages to retrieve.
|
|
813
662
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
814
663
|
* into the request (optional).
|
|
815
|
-
* @returns
|
|
664
|
+
* @returns The server response.
|
|
816
665
|
*/
|
|
817
666
|
getMessagesById(messageIds: string[], requestOptions?: StreamRequestOptions): Promise<StreamResponse<import(".").GetManyMessagesResponse>>;
|
|
818
667
|
/**
|
|
819
|
-
* Returns
|
|
668
|
+
* Returns when the current user last marked the channel read.
|
|
820
669
|
*
|
|
821
|
-
* @returns The last-read
|
|
670
|
+
* @returns The last-read timestamp in unix nanoseconds, `null` if never read, or `undefined` if
|
|
671
|
+
* the user is unset.
|
|
822
672
|
*/
|
|
823
|
-
lastRead():
|
|
673
|
+
lastRead(): TimestampNS | null | undefined;
|
|
824
674
|
_countMessageAsUnread(message: LocalMessage | MessageResponse): boolean;
|
|
825
675
|
/**
|
|
826
|
-
*
|
|
676
|
+
* Counts the unread messages.
|
|
677
|
+
*
|
|
678
|
+
* Counting from `lastRead` counts within the channel's newest messages that are loaded (see
|
|
679
|
+
* {@link newestKnownMessages}).
|
|
680
|
+
*
|
|
681
|
+
* @param lastRead - The time the user read a message, in unix nanoseconds (optional). Defaults to
|
|
682
|
+
* the current user's read state.
|
|
683
|
+
* @returns The unread count.
|
|
684
|
+
*/
|
|
685
|
+
countUnread(lastRead?: TimestampNS | null): number;
|
|
686
|
+
/**
|
|
687
|
+
* The channel's newest messages that are loaded: the interval that reaches the newest message (the
|
|
688
|
+
* paginator's anchored head), or, while that interval is not loaded, the messages received live
|
|
689
|
+
* since. An interval reached by a jump is never part of it, as the messages between it and the
|
|
690
|
+
* newest are unknown.
|
|
691
|
+
*/
|
|
692
|
+
private newestKnownMessages;
|
|
693
|
+
/**
|
|
694
|
+
* Lowers the own unread count by the unread ones among `deletedMessages`, as they were before the
|
|
695
|
+
* delete. The server lowers it for every unread message deleted, except in a soft bulk delete
|
|
696
|
+
* (`user.messages.deleted`), and does not send the new count. Unread messages that are not loaded
|
|
697
|
+
* cannot be counted; the next query brings the server's count.
|
|
827
698
|
*
|
|
828
|
-
* @
|
|
829
|
-
* @returns Unread count.
|
|
699
|
+
* @internal
|
|
830
700
|
*/
|
|
831
|
-
|
|
701
|
+
_lowerUnreadCountForDeletedMessages(deletedMessages: LocalMessage[]): void;
|
|
832
702
|
/**
|
|
833
|
-
*
|
|
703
|
+
* Counts the unread messages that mention the current user, within the channel's newest messages
|
|
704
|
+
* that are loaded (see {@link newestKnownMessages}).
|
|
834
705
|
*
|
|
835
|
-
* @returns
|
|
706
|
+
* @returns The unread mentions count.
|
|
836
707
|
*/
|
|
837
708
|
countUnreadMentions(): number;
|
|
838
709
|
/**
|
|
839
|
-
* Creates
|
|
710
|
+
* Creates the channel without watching it.
|
|
840
711
|
*
|
|
841
712
|
* @param options - Channel query options (optional).
|
|
842
713
|
* @returns The server response.
|
|
843
714
|
*/
|
|
844
|
-
create: (options?: ChannelGetOrCreateRequest) => Promise<StreamResponse<
|
|
715
|
+
create: (options?: ChannelGetOrCreateRequest) => Promise<StreamResponse<ChannelStateResponse>>;
|
|
716
|
+
/**
|
|
717
|
+
* Moves this channel, created without an ID, from its temporary cid to the one the server gave it.
|
|
718
|
+
* If another instance already holds that cid, it stays stored and takes over from this one
|
|
719
|
+
* ({@link ChannelManager.supersedeChannel}).
|
|
720
|
+
*/
|
|
721
|
+
private storeUnderServerCid;
|
|
845
722
|
/**
|
|
846
|
-
* Queries the API
|
|
723
|
+
* Queries the API for messages, members and other channel fields.
|
|
724
|
+
*
|
|
725
|
+
* The returned messages are not added to {@link Channel.messagePaginator}: the paginator loads its
|
|
726
|
+
* own pages, and {@link Channel.watch} / {@link Channel.create} place the page they query.
|
|
847
727
|
*
|
|
848
728
|
* @param options - The query options (optional, defaults to `{}`).
|
|
849
|
-
* @param messageSetToAddToIfDoesNotExist - It's possible to load disjunct sets of a channel's
|
|
850
|
-
* messages into state. Use `current` to load the initial channel state or to extend the
|
|
851
|
-
* currently displayed messages; use `latest` to load/extend the latest messages; `new` is
|
|
852
|
-
* used for loading a specific message and its surroundings (optional, defaults to `'current'`).
|
|
853
729
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
854
730
|
* into the request (optional).
|
|
855
|
-
* @returns
|
|
731
|
+
* @returns The query response.
|
|
856
732
|
*/
|
|
857
|
-
query(options?: ChannelGetOrCreateRequest,
|
|
733
|
+
query(options?: ChannelGetOrCreateRequest, requestOptions?: StreamRequestOptions): Promise<StreamResponse<ChannelStateResponse>>;
|
|
858
734
|
/**
|
|
859
|
-
*
|
|
735
|
+
* The query behind `query()`, `watch()` and `create()`, in three steps: sends the request
|
|
736
|
+
* ({@link requestChannelState}), has the message paginator place the returned page when
|
|
737
|
+
* `placeMessages` is set (a watch query), then applies the rest of the response
|
|
738
|
+
* ({@link applyChannelStateFromResponse}), all as a tracked query ({@link runTrackedQuery}).
|
|
860
739
|
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
863
|
-
*
|
|
740
|
+
* The page is placed before the rest is applied, because the rest reads the loaded messages: read
|
|
741
|
+
* and delivery positions that come without a message id are looked up among them, and the latest
|
|
742
|
+
* message is reported as delivered. A first page then takes the unread snapshot, from the read
|
|
743
|
+
* state the rest brought. The message paginator's own queries keep the same order: they place
|
|
744
|
+
* their page, then apply the rest with {@link applyChannelStateFromResponse}.
|
|
864
745
|
*/
|
|
865
|
-
|
|
746
|
+
private runChannelQuery;
|
|
866
747
|
/**
|
|
867
|
-
*
|
|
868
|
-
*
|
|
748
|
+
* Runs `run`, a query of this channel, as a tracked query: refused for a disposed instance, and
|
|
749
|
+
* the channel counts as being queried until `run` settles ({@link isQueryingChannel}), so the
|
|
750
|
+
* channel store keeps it meanwhile. Used by {@link runChannelQuery} and by the message
|
|
751
|
+
* paginator's own queries.
|
|
869
752
|
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
873
|
-
* @
|
|
753
|
+
* `run` starts synchronously: a paginator query publishes its loading flag before anything is
|
|
754
|
+
* awaited, which keeps a second query in the same tick from starting.
|
|
755
|
+
*
|
|
756
|
+
* @internal
|
|
874
757
|
*/
|
|
875
|
-
|
|
758
|
+
runTrackedQuery<T>(run: () => Promise<T>): Promise<T>;
|
|
876
759
|
/**
|
|
877
|
-
*
|
|
760
|
+
* Sends the channel query and takes in what the response says about the channel itself: its id,
|
|
761
|
+
* the cid it is stored under, its config, and its `last_message_at`, against which the message
|
|
762
|
+
* paginator's head interval is checked before any page is placed (see
|
|
763
|
+
* `MessagePaginator.unmarkStaleHead`). The request of {@link runChannelQuery} and of the message
|
|
764
|
+
* paginator's own queries, which run it as a tracked query ({@link runTrackedQuery}); it does not
|
|
765
|
+
* track the query itself. Refused for a disposed instance, before anything is sent.
|
|
878
766
|
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
767
|
+
* `placesNewestPage`: the caller places the newest page with this response, which brings the
|
|
768
|
+
* newest messages up to date, so the head interval is not checked.
|
|
769
|
+
*
|
|
770
|
+
* @internal
|
|
771
|
+
*/
|
|
772
|
+
requestChannelState(options: ChannelGetOrCreateRequest, requestOptions: StreamRequestOptions | undefined, { placesNewestPage }?: {
|
|
773
|
+
placesNewestPage?: boolean;
|
|
774
|
+
}): Promise<StreamResponse<ChannelStateResponse>>;
|
|
775
|
+
/**
|
|
776
|
+
* Whether nothing but this query brings the head interval up to date, so its `last_message_at` may
|
|
777
|
+
* show the interval stale: the watch was stopped (`NotWatching`), or this query itself watches
|
|
778
|
+
* again after a dropped connection (`WasWatching`), leaving nothing to re-watch with the newest
|
|
779
|
+
* page. While the channel is watched, a message the interval lacks is still on its way; after a
|
|
780
|
+
* dropped connection, the re-watch that follows places the newest page (see
|
|
781
|
+
* `ConnectionRecoveryManager`).
|
|
782
|
+
*/
|
|
783
|
+
private isHeadLeftWithoutRefresh;
|
|
784
|
+
/**
|
|
785
|
+
* Applies a channel query response: watch status, read/members state, polls, reminders, composer,
|
|
786
|
+
* channel data, and the `channels.queried` event and offline write. Called once the response's
|
|
787
|
+
* page of messages, if any, is placed (see {@link runChannelQuery}).
|
|
788
|
+
*
|
|
789
|
+
* @internal
|
|
790
|
+
*/
|
|
791
|
+
applyChannelStateFromResponse(state: ChannelStateResponseFields, { isLatestMessageSet, watch }: {
|
|
792
|
+
isLatestMessageSet: boolean;
|
|
793
|
+
watch?: boolean;
|
|
794
|
+
}): void;
|
|
795
|
+
/**
|
|
796
|
+
* Bans a user from this channel.
|
|
797
|
+
*
|
|
798
|
+
* @param targetUserId - The user to ban.
|
|
799
|
+
* @param options - Ban options.
|
|
882
800
|
* @returns The server response.
|
|
883
801
|
*/
|
|
884
|
-
|
|
802
|
+
banUser(targetUserId: string, options: Omit<BanUserOptions, 'channel_cid'>): Promise<StreamResponse<import(".").ModerationBanResponse>>;
|
|
885
803
|
/**
|
|
886
|
-
* Removes the bans
|
|
804
|
+
* Removes the bans of a user on this channel.
|
|
887
805
|
*
|
|
888
806
|
* @param targetUserId - The user to unban.
|
|
889
807
|
* @param options - Unban options (optional).
|
|
@@ -891,33 +809,27 @@ export declare class Channel extends ChannelApi {
|
|
|
891
809
|
*/
|
|
892
810
|
unbanUser(targetUserId: string, options?: UnBanUserOptions): Promise<import("./types").APIResponse>;
|
|
893
811
|
/**
|
|
894
|
-
* Casts
|
|
812
|
+
* Casts a vote on a poll. `removeVote()` removes one.
|
|
895
813
|
*
|
|
896
|
-
* @param ...args - `[request, requestOptions]`. `
|
|
897
|
-
* and the vote to cast
|
|
898
|
-
* options such as an abort `signal` and is never serialized into the request.
|
|
814
|
+
* @param ...args - `[pathParams, request, requestOptions]`. `pathParams` holds the target
|
|
815
|
+
* `message_id` and `poll_id`; `request` holds the vote to cast; `requestOptions` carries
|
|
816
|
+
* per-request options such as an abort `signal` and is never serialized into the request.
|
|
899
817
|
* @returns The poll vote response.
|
|
900
818
|
*/
|
|
901
819
|
vote(...args: Parameters<ChatApi['castPollVote']>): Promise<StreamResponse<import(".").PollVoteResponse>>;
|
|
902
820
|
removeVote(...args: Parameters<ChatApi['deletePollVote']>): Promise<StreamResponse<import(".").PollVoteResponse>>;
|
|
903
821
|
_createDraft(...args: Parameters<ChannelApi['createDraft']>): Promise<StreamResponse<import(".").CreateDraftResponse>>;
|
|
904
|
-
/**
|
|
905
|
-
* Creates or updates a draft message in a channel. If offline support is enabled, the
|
|
906
|
-
* call is queued so it is replayed on reconnect.
|
|
907
|
-
*/
|
|
822
|
+
/** Creates or updates a draft. With offline support the call is queued and replayed on reconnect. */
|
|
908
823
|
createDraft(...args: Parameters<ChannelApi['createDraft']>): Promise<import(".").CreateDraftResponse & {
|
|
909
824
|
metadata: import("./types").RequestMetadata;
|
|
910
825
|
}>;
|
|
911
826
|
_deleteDraft(...args: Parameters<ChannelApi['deleteDraft']>): Promise<StreamResponse<import(".").Response>>;
|
|
912
|
-
/**
|
|
913
|
-
* Deletes a draft message from a channel or a thread. If offline support is enabled, the
|
|
914
|
-
* call is queued so it is replayed on reconnect.
|
|
915
|
-
*/
|
|
827
|
+
/** Deletes a draft. With offline support the call is queued and replayed on reconnect. */
|
|
916
828
|
deleteDraft(...args: Parameters<ChannelApi['deleteDraft']>): Promise<import(".").Response & {
|
|
917
829
|
metadata: import("./types").RequestMetadata;
|
|
918
830
|
}>;
|
|
919
831
|
/**
|
|
920
|
-
* Listens to events on this channel.
|
|
832
|
+
* Listens to events on this channel. A callback alone listens to all events.
|
|
921
833
|
*
|
|
922
834
|
* @example
|
|
923
835
|
* channel.on('message.new', (event) => {
|
|
@@ -929,48 +841,71 @@ export declare class Channel extends ChannelApi {
|
|
|
929
841
|
* console.log(event.type);
|
|
930
842
|
* });
|
|
931
843
|
*
|
|
932
|
-
* @param
|
|
933
|
-
* @param
|
|
844
|
+
* @param eventType - The event type to listen for.
|
|
845
|
+
* @param callback - Called with each event of that type.
|
|
934
846
|
* @returns An object with an `unsubscribe()` method.
|
|
935
847
|
*/
|
|
936
|
-
on<T extends EventType
|
|
848
|
+
on<T extends EventType>(eventType: T, callback: EventHandler<T>): {
|
|
937
849
|
unsubscribe: () => void;
|
|
938
850
|
};
|
|
851
|
+
/**
|
|
852
|
+
* Listens to all events on this channel.
|
|
853
|
+
*
|
|
854
|
+
* @param callback - Called with every event.
|
|
855
|
+
* @returns An object with an `unsubscribe()` method.
|
|
856
|
+
*/
|
|
939
857
|
on(callback: EventHandler): {
|
|
940
858
|
unsubscribe: () => void;
|
|
941
859
|
};
|
|
942
860
|
/**
|
|
943
|
-
* Removes
|
|
861
|
+
* Removes a listener for one event type.
|
|
944
862
|
*
|
|
945
|
-
* @param
|
|
946
|
-
* @param
|
|
863
|
+
* @param eventType - The event type it listens to.
|
|
864
|
+
* @param callback - The listener to remove.
|
|
865
|
+
*/
|
|
866
|
+
off<T extends EventType>(eventType: T, callback: EventHandler<T>): void;
|
|
867
|
+
/**
|
|
868
|
+
* Removes a listener for all events.
|
|
869
|
+
*
|
|
870
|
+
* @param callback - The listener to remove.
|
|
947
871
|
*/
|
|
948
|
-
off<T extends EventType | string>(eventType: T, callback: EventHandler): void;
|
|
949
872
|
off(callback: EventHandler): void;
|
|
950
873
|
private _patchReadState;
|
|
951
874
|
private _upsertReadState;
|
|
952
875
|
/**
|
|
953
|
-
* Sets the current user's unread count
|
|
954
|
-
* `
|
|
955
|
-
* `state.unreadCount` derives from — so channel-wide resets (`channel.truncated`, "all channels
|
|
956
|
-
* read") must route through here rather than writing a count of their own.
|
|
876
|
+
* Sets the current user's unread count in `read[userId].unread_messages`, the one place it lives
|
|
877
|
+
* (`state.unreadCount` derives from it). Returns whether the count changed.
|
|
957
878
|
*/
|
|
958
|
-
/** @returns whether the count actually changed, so callers can react only to the channels it did. */
|
|
959
879
|
_setOwnUnreadCount(unreadCount: number): boolean;
|
|
960
880
|
_handleChannelEvent(event: Event): void;
|
|
961
|
-
_callChannelListeners: (event:
|
|
881
|
+
_callChannelListeners: (event: Event) => void;
|
|
882
|
+
/**
|
|
883
|
+
* Throws if the channel has no ID (created from members only). Narrows `id` to `string`. Call it
|
|
884
|
+
* before any request that uses `this.cid`: it is a string (possibly temporary) even without an ID,
|
|
885
|
+
* so TypeScript does not flag a missing check.
|
|
886
|
+
*/
|
|
887
|
+
_checkHasId(): asserts this is this & {
|
|
888
|
+
id: string;
|
|
889
|
+
};
|
|
890
|
+
/** Throws unless the channel was queried or populated from the offline DB. */
|
|
962
891
|
_checkInitialized(): void;
|
|
963
892
|
_initializeState(state: ChannelStateResponseFields): void;
|
|
964
893
|
_extendEventWithOwnReactions(event: EventPayload<'message.undeleted' | 'message.updated' | 'message.deleted'>): void;
|
|
965
894
|
_hydrateMembers({ members, overrideCurrentState, }: {
|
|
966
895
|
members: ChannelMemberResponse[];
|
|
967
|
-
/**
|
|
968
|
-
* If set to `true` then `ChannelState.members` will be overriden with the newly
|
|
969
|
-
* provided `members`, setting this property to `false` will merge current `ChannelState.members`
|
|
970
|
-
* object with the newly provided `members`
|
|
971
|
-
* (new members with the same `userId` will replace the old ones).
|
|
972
|
-
*/
|
|
896
|
+
/** `true` replaces `state.members`. `false` merges (a new member replaces one with the same ID). */
|
|
973
897
|
overrideCurrentState?: boolean;
|
|
974
898
|
}): void;
|
|
975
|
-
|
|
899
|
+
/**
|
|
900
|
+
* Ends the instance for good: unsubscribes from the configuration and the server config, stops the
|
|
901
|
+
* receipts tracker and the cooldown timer, disposes both paginators, then sets
|
|
902
|
+
* `pendingDisposal: true` and `watchStatus: NotWatching`. It sends no request, so the server keeps a
|
|
903
|
+
* watch this connection held until the connection ends. Calling it again does nothing.
|
|
904
|
+
*
|
|
905
|
+
* The SDK calls it when a channel ends (deleted, current user removed, logout, released as unused).
|
|
906
|
+
* It does not remove the channel from the channel store. The SDK's own ends remove it; after a
|
|
907
|
+
* direct call it stays until `client.channelManager.releaseUnusedChannels()`, or until `ensure()`
|
|
908
|
+
* for the same cid replaces it.
|
|
909
|
+
*/
|
|
910
|
+
disconnect(): void;
|
|
976
911
|
}
|