stream-chat 10.0.0-rc.9 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/cjs/index.browser.js +21653 -19788
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +21693 -19796
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +21651 -19786
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +216 -135
- package/dist/types/CooldownTimer.d.ts +13 -27
- package/dist/types/EventHandlerPipeline.d.ts +18 -38
- package/dist/types/LiveLocationManager.d.ts +24 -52
- package/dist/types/api-client.d.ts +17 -5
- package/dist/types/channel.d.ts +432 -470
- package/dist/types/channel_state.d.ts +68 -112
- package/dist/types/client.d.ts +321 -435
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +31 -125
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +32 -124
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +64 -79
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +14 -36
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +45 -0
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +84 -0
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +82 -0
- package/dist/types/connection/networkConnection/index.d.ts +3 -0
- package/dist/types/connection/networkConnection/reporters.d.ts +20 -0
- package/dist/types/connection/networkConnection/types.d.ts +40 -0
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +137 -0
- package/dist/types/connection/wsConnection/WSConnection.d.ts +105 -0
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +47 -0
- package/dist/types/connection/wsConnection/config.d.ts +31 -0
- package/dist/types/connection/wsConnection/index.d.ts +4 -0
- package/dist/types/connection/wsConnection/types.d.ts +46 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/custom_types.d.ts +0 -2
- package/dist/types/entityStore/EntityStore.d.ts +226 -65
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +19 -33
- package/dist/types/entityStore/index.d.ts +0 -1
- package/dist/types/errors.d.ts +16 -19
- package/dist/types/formatMessageMemo.d.ts +5 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +5 -1
- package/dist/types/gen/chat/ChatApi.d.ts +149 -105
- package/dist/types/gen/models/index.d.ts +2528 -690
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +33 -14
- package/dist/types/index.d.ts +10 -6
- package/dist/types/{i18n/languageNames.d.ts → languageNames.d.ts} +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +24 -0
- package/dist/types/messageComposer/attachmentManager.d.ts +52 -24
- package/dist/types/messageComposer/attachmentUtils.d.ts +23 -0
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +38 -50
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +12 -9
- package/dist/types/messageComposer/messageComposer.d.ts +60 -128
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +10 -1
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +4 -0
- package/dist/types/messageComposer/middleware/messageComposer/commandInjection.d.ts +5 -0
- package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +2 -0
- package/dist/types/messageComposer/middleware/messageComposer/pollOnly.d.ts +6 -0
- package/dist/types/messageComposer/middleware/messageComposer/userDataInjection.d.ts +5 -0
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +4 -0
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +11 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +19 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +15 -5
- package/dist/types/messageComposer/textComposer.d.ts +14 -7
- package/dist/types/messageComposer/types.d.ts +27 -7
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +27 -80
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +40 -73
- package/dist/types/messageOperations/FailedSendCache.d.ts +29 -0
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +16 -22
- package/dist/types/messageOperations/MessageOperations.d.ts +63 -34
- package/dist/types/messageOperations/applyReactionLocally.d.ts +15 -0
- package/dist/types/messageOperations/createMessageOperations.d.ts +9 -0
- package/dist/types/messageOperations/index.d.ts +6 -4
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +16 -0
- package/dist/types/messageOperations/sendOrdering.d.ts +14 -0
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +20 -0
- package/dist/types/messageOperations/types.d.ts +43 -14
- package/dist/types/middleware.d.ts +10 -0
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +10 -23
- package/dist/types/notifications/types.d.ts +21 -57
- package/dist/types/offline-support/offline_support_api.d.ts +150 -528
- package/dist/types/offline-support/offline_sync_manager.d.ts +21 -42
- package/dist/types/offline-support/queueableOperations.d.ts +35 -37
- package/dist/types/offline-support/types.d.ts +40 -186
- package/dist/types/pagination/FilterBuilder.d.ts +1 -18
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +4 -5
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +19 -5
- package/dist/types/pagination/index.d.ts +1 -0
- package/dist/types/pagination/paginators/BasePaginator.d.ts +604 -550
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +123 -106
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +576 -334
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +239 -131
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +15 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +4 -3
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +44 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +5 -8
- package/dist/types/pagination/paginators/index.d.ts +1 -0
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +34 -8
- package/dist/types/poll_manager.d.ts +12 -2
- package/dist/types/poll_optimistic_votes.d.ts +57 -0
- package/dist/types/reminders/Reminder.d.ts +11 -11
- package/dist/types/reminders/ReminderManager.d.ts +13 -25
- package/dist/types/search/BaseSearchSource.d.ts +10 -8
- package/dist/types/search/ChannelSearchSource.d.ts +16 -0
- package/dist/types/search/MessageSearchSource.d.ts +17 -0
- package/dist/types/search/SearchController.d.ts +26 -28
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +63 -129
- package/dist/types/thread_manager.d.ts +95 -66
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +81 -199
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +31 -11
- package/dist/types/utils/FixedSizeQueueCache.d.ts +8 -11
- package/dist/types/utils/WithSubscriptions.d.ts +6 -16
- package/dist/types/utils/abort.d.ts +17 -0
- package/dist/types/utils/concurrency.d.ts +12 -20
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +33 -57
- package/dist/types/utils.d.ts +72 -91
- package/package.json +14 -40
- package/src/ChannelManager.ts +494 -303
- package/src/CooldownTimer.ts +28 -38
- package/src/EventHandlerPipeline.ts +22 -45
- package/src/LiveLocationManager.ts +37 -76
- package/src/api-client.ts +113 -50
- package/src/campaign.ts +1 -1
- package/src/channel.ts +1067 -1276
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +73 -168
- package/src/client.ts +744 -974
- package/src/client_state.ts +3 -8
- package/src/configuration/ConfigController.ts +42 -158
- package/src/configuration/InstanceConfigurationRegistry.ts +43 -172
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +169 -59
- package/src/configuration/types.ts +69 -92
- package/src/configuration/utils/applyInstanceConfiguration.ts +22 -54
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +111 -0
- package/src/connection/ConnectionRecoveryManager.ts +257 -0
- package/src/connection/index.ts +4 -0
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +204 -0
- package/src/connection/networkConnection/index.ts +3 -0
- package/src/connection/networkConnection/reporters.ts +58 -0
- package/src/connection/networkConnection/types.ts +45 -0
- package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +230 -232
- package/src/connection/wsConnection/WSConnection.ts +270 -0
- package/src/connection/wsConnection/WSConnectionFallback.ts +250 -0
- package/src/connection/wsConnection/config.ts +73 -0
- package/src/connection/wsConnection/index.ts +4 -0
- package/src/connection/wsConnection/types.ts +48 -0
- package/src/constants.ts +6 -5
- package/src/custom_types.ts +0 -1
- package/src/entityStore/EntityStore.ts +415 -79
- package/src/entityStore/StoreBackedItemIndex.ts +37 -41
- package/src/entityStore/index.ts +0 -1
- package/src/errors.ts +39 -20
- package/src/formatMessageMemo.ts +17 -0
- package/src/gen/chat/ChannelApi.ts +122 -36
- package/src/gen/chat/ChatApi.ts +578 -1540
- package/src/gen/models/index.ts +2498 -3383
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +170 -367
- package/src/index.ts +22 -10
- package/src/languageNames.ts +88 -0
- package/src/logger.ts +1 -3
- package/src/messageComposer/CustomDataManager.ts +19 -6
- package/src/messageComposer/LocationComposer.ts +19 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +54 -0
- package/src/messageComposer/attachmentManager.ts +170 -185
- package/src/messageComposer/attachmentUtils.ts +44 -0
- package/src/messageComposer/configuration/configuration.ts +15 -8
- package/src/messageComposer/configuration/types.ts +38 -50
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/linkPreviewsManager.ts +18 -21
- package/src/messageComposer/messageComposer.ts +223 -174
- package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +46 -33
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +4 -1
- package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +6 -0
- package/src/messageComposer/middleware/messageComposer/attachments.ts +76 -5
- package/src/messageComposer/middleware/messageComposer/commandInjection.ts +10 -4
- package/src/messageComposer/middleware/messageComposer/customData.ts +17 -5
- package/src/messageComposer/middleware/messageComposer/index.ts +2 -0
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +22 -12
- package/src/messageComposer/middleware/messageComposer/pollOnly.ts +9 -1
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +12 -12
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +8 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +10 -3
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +21 -9
- package/src/messageComposer/textComposer.ts +37 -57
- package/src/messageComposer/types.ts +39 -11
- package/src/messageDelivery/MessageDeliveryReporter.ts +86 -125
- package/src/messageDelivery/MessageReceiptsTracker.ts +88 -101
- package/src/messageOperations/FailedSendCache.ts +85 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +121 -112
- package/src/messageOperations/MessageOperations.ts +297 -175
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +176 -0
- package/src/messageOperations/index.ts +6 -14
- package/src/messageOperations/reflectReactionEvent.ts +43 -0
- package/src/messageOperations/sendOrdering.ts +25 -0
- package/src/messageOperations/settlePendingAttachmentUploads.ts +98 -0
- package/src/messageOperations/types.ts +51 -13
- package/src/middleware.ts +13 -5
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +19 -28
- package/src/notifications/types.ts +21 -57
- package/src/offline-support/offline_support_api.ts +226 -669
- package/src/offline-support/offline_sync_manager.ts +51 -80
- package/src/offline-support/queueableOperations.ts +98 -73
- package/src/offline-support/types.ts +43 -186
- package/src/pagination/FilterBuilder.ts +1 -22
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +15 -63
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +53 -33
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/index.ts +1 -0
- package/src/pagination/paginators/BasePaginator.ts +1415 -1041
- package/src/pagination/paginators/ChannelPaginator.ts +479 -217
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1351 -772
- package/src/pagination/paginators/MessagePaginator.ts +518 -233
- package/src/pagination/paginators/PinnedMessagePaginator.ts +32 -40
- package/src/pagination/paginators/ReminderPaginator.ts +21 -16
- package/src/pagination/paginators/ThreadPaginator.ts +170 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +16 -19
- package/src/pagination/paginators/index.ts +1 -0
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +177 -98
- package/src/poll_manager.ts +24 -22
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +16 -12
- package/src/reminders/ReminderManager.ts +22 -55
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +19 -25
- package/src/search/ChannelSearchSource.ts +43 -1
- package/src/search/MessageSearchSource.ts +77 -13
- package/src/search/SearchController.ts +39 -36
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +418 -703
- package/src/thread_manager.ts +300 -234
- package/src/token_manager.ts +12 -22
- package/src/types.ts +102 -216
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +64 -18
- package/src/utils/FixedSizeQueueCache.ts +18 -21
- package/src/utils/WithSubscriptions.ts +6 -16
- package/src/utils/abort.ts +45 -0
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +40 -60
- package/src/utils.ts +181 -174
- package/codegen/i18n/callSites.ts +0 -126
- package/codegen/i18n/generate.ts +0 -226
- package/codegen/i18n/guards.ts +0 -178
- package/codegen/i18n/index.ts +0 -29
- package/codegen/i18n/stringMaps.ts +0 -91
- package/codegen/i18n/types.ts +0 -100
- package/dist/cjs/i18n.browser.js +0 -1131
- package/dist/cjs/i18n.browser.js.map +0 -7
- package/dist/cjs/i18n.node.js +0 -1160
- package/dist/cjs/i18n.node.js.map +0 -7
- package/dist/esm/i18n-codegen.mjs +0 -409
- package/dist/esm/i18n-codegen.mjs.map +0 -7
- package/dist/esm/i18n.mjs +0 -1098
- package/dist/esm/i18n.mjs.map +0 -7
- package/dist/types/ConnectionRecoveryManager.d.ts +0 -156
- package/dist/types/connection.d.ts +0 -139
- package/dist/types/entityStore/applyReactionLocally.d.ts +0 -32
- package/dist/types/i18n/Streami18n.d.ts +0 -168
- package/dist/types/i18n/TranslationBuilder.d.ts +0 -70
- package/dist/types/i18n/TranslationStore.d.ts +0 -57
- package/dist/types/i18n/dayjs.d.ts +0 -104
- package/dist/types/i18n/formatters.d.ts +0 -91
- package/dist/types/i18n/index.d.ts +0 -15
- package/dist/types/i18n/translator.d.ts +0 -29
- package/dist/types/i18n/types.d.ts +0 -262
- package/dist/types/i18n-codegen/callSites.d.ts +0 -10
- package/dist/types/i18n-codegen/generate.d.ts +0 -15
- package/dist/types/i18n-codegen/guards.d.ts +0 -61
- package/dist/types/i18n-codegen/index.d.ts +0 -29
- package/dist/types/i18n-codegen/stringMaps.d.ts +0 -14
- package/dist/types/i18n-codegen/types.d.ts +0 -94
- package/dist/types/insights.d.ts +0 -56
- package/dist/types/messageOperations/optimistic.d.ts +0 -118
- package/dist/types/messageOperations/persistence.d.ts +0 -21
- package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
- package/dist/types/store.d.ts +0 -125
- package/src/ConnectionRecoveryManager.ts +0 -293
- package/src/i18n/Streami18n.ts +0 -520
- package/src/i18n/TranslationBuilder.ts +0 -176
- package/src/i18n/TranslationStore.ts +0 -96
- package/src/i18n/dayjs.ts +0 -228
- package/src/i18n/formatters.ts +0 -461
- package/src/i18n/index.ts +0 -15
- package/src/i18n/languageNames.ts +0 -103
- package/src/i18n/translator.ts +0 -76
- package/src/i18n/types.ts +0 -375
- package/src/insights.ts +0 -82
- package/src/messageOperations/optimistic.ts +0 -257
- package/src/messageOperations/persistence.ts +0 -40
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/store.ts +0 -304
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { BasePaginatorConfig, PaginationDirection, PaginationQueryParams, PaginatorState } from './BasePaginator';
|
|
1
|
+
import type { BasePaginatorConfig, DoRequestResponse, ExecuteQueryReturnValue, Interval, PaginationDirection, PaginationQueryParams, PaginatorState, QueryPagePlacement } from './BasePaginator';
|
|
2
2
|
import { BasePaginator, type PaginationQueryReturnValue, type PaginatorOptions } from './BasePaginator';
|
|
3
|
-
import type { LocalMessage, MessagePaginationParams,
|
|
3
|
+
import type { ChannelStateResponse, GetRepliesResponse, LocalMessage, MessagePaginationParams, PinnedMessagePaginationOptions, SortParamRequest, StreamResponse, TimestampNS, UserResponse } from '../../types';
|
|
4
4
|
import type { Channel } from '../../channel';
|
|
5
|
-
import {
|
|
5
|
+
import type { Thread } from '../../thread';
|
|
6
|
+
import { StateStore } from '@stream-io/state-store';
|
|
6
7
|
import type { ItemIndexApi } from '../ItemIndex';
|
|
7
8
|
import type { EntityStoreChangeBatch } from '../../entityStore/EntityStore';
|
|
8
9
|
export type MessageFocusReason = 'jump-to-message' | 'jump-to-first-unread' | 'jump-to-latest';
|
|
@@ -18,20 +19,19 @@ export type MessageFocusSignalState = {
|
|
|
18
19
|
};
|
|
19
20
|
export type JumpToMessageOptions = {
|
|
20
21
|
pageSize?: number;
|
|
21
|
-
/**
|
|
22
|
-
* Optional reason attached to emitted focus signal.
|
|
23
|
-
* Defaults to `jump-to-message`.
|
|
24
|
-
*/
|
|
22
|
+
/** Reason attached to the emitted focus signal. Defaults to `jump-to-message`. */
|
|
25
23
|
focusReason?: MessageFocusReason;
|
|
26
|
-
/**
|
|
27
|
-
* TTL for the emitted focus signal in milliseconds.
|
|
28
|
-
* Defaults to `3000`.
|
|
29
|
-
*/
|
|
24
|
+
/** TTL of the emitted focus signal in milliseconds. Defaults to `3000`. */
|
|
30
25
|
focusSignalTtlMs?: number;
|
|
26
|
+
/** Suppresses the focus signal after a successful jump. */
|
|
27
|
+
suppressFocusSignal?: boolean;
|
|
31
28
|
/**
|
|
32
|
-
*
|
|
29
|
+
* Also watches the channel (so it receives events) when it is not watched yet. The request that
|
|
30
|
+
* loads the interval around the message asks to watch too, so it stays one request, and a message
|
|
31
|
+
* already loaded is loaded again. Ignored for a thread's reply list (its request cannot watch)
|
|
32
|
+
* and when the paginator's `doRequest` loads the messages.
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
watchChannel?: boolean;
|
|
35
35
|
};
|
|
36
36
|
export type MessagePaginatorSort = SortParamRequest[];
|
|
37
37
|
export type MessagePaginatorFilter = {
|
|
@@ -40,164 +40,177 @@ export type MessagePaginatorFilter = {
|
|
|
40
40
|
};
|
|
41
41
|
export type MessagePaginatorState = PaginatorState<LocalMessage>;
|
|
42
42
|
export type MessageQueryShape = MessagePaginationParams | PinnedMessagePaginationOptions;
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
* is absent or not a finite number.
|
|
46
|
-
*
|
|
47
|
-
* Accepts `null`/`undefined` so callers holding an optional message (e.g.
|
|
48
|
-
* `MessagePaginator.lastMessage`) do not each repeat the guard.
|
|
49
|
-
*/
|
|
50
|
-
export declare const getMessageCreatedAtTimestamp: (message: LocalMessage | null | undefined) => number | null;
|
|
43
|
+
/** A message's `created_at` (unix nanoseconds), or `null` when absent or not finite. */
|
|
44
|
+
export declare const getMessageCreatedAtTimestamp: (message: LocalMessage | null | undefined) => TimestampNS | null;
|
|
51
45
|
export type MessagePaginatorOptions = {
|
|
52
46
|
channel: Channel;
|
|
53
47
|
id?: string;
|
|
54
48
|
itemIndex?: ItemIndexApi<LocalMessage>;
|
|
55
49
|
parentMessageId?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Sort passed to backend message/replies query.
|
|
58
|
-
* Does not affect in-memory item ordering.
|
|
59
|
-
*/
|
|
50
|
+
/** Sort sent to the backend messages/replies query. Does not affect in-memory ordering. */
|
|
60
51
|
requestSort?: MessagePaginatorSort;
|
|
61
52
|
/**
|
|
62
53
|
* @deprecated Use `requestSort` instead.
|
|
63
54
|
*/
|
|
64
55
|
sort?: MessagePaginatorSort;
|
|
65
|
-
/**
|
|
66
|
-
* In-memory ordering for items exposed by paginator state.
|
|
67
|
-
*/
|
|
56
|
+
/** In-memory ordering of the items exposed by paginator state. */
|
|
68
57
|
itemOrder?: MessagePaginatorSort;
|
|
58
|
+
/** The thread whose replies this paginator lists; without it, it lists the channel's messages. */
|
|
59
|
+
thread?: Thread;
|
|
69
60
|
paginatorOptions?: PaginatorOptions<LocalMessage, MessageQueryShape>;
|
|
70
61
|
};
|
|
71
62
|
/**
|
|
72
|
-
* Options for {@link MessageIntervalPaginator.
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* newest / oldest message" are its bounds by `created_at`. With NO options, `mergeNewestPage` prunes
|
|
79
|
-
* any loaded message that falls WITHIN `page`'s `created_at` span but is absent from it —
|
|
80
|
-
* unconditionally safe (a message that arrived live during the caller's fetch is always strictly
|
|
81
|
-
* newer than `page`'s newest message, so it can never fall in that span). `candidateIds` widens the
|
|
82
|
-
* reconcilable window at the TOP edge; `requestedLimit` only tunes the `hasMoreTail` affordance and
|
|
83
|
-
* can never remove a message:
|
|
63
|
+
* Options for {@link MessageIntervalPaginator.reconcileNewestMessages} that enable reconciling
|
|
64
|
+
* messages hard-deleted while the client received no events (no event reaches other clients). With
|
|
65
|
+
* no options it prunes loaded messages inside `page`'s `created_at` span that are absent from it,
|
|
66
|
+
* which is always safe: a live arrival is newer than `page`'s newest message.
|
|
67
|
+
* `headIntervalItemIdsAtRequest` widens reconciliation at the top edge; `requestedLimit` says
|
|
68
|
+
* whether the page reached the channel start.
|
|
84
69
|
*/
|
|
85
|
-
export type
|
|
86
|
-
/**
|
|
87
|
-
* The `limit` the caller passed to the query that produced `page`.
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* {@link MessageIntervalPaginator.
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* start.
|
|
70
|
+
export type ReconcileNewestMessagesOptions = {
|
|
71
|
+
/**
|
|
72
|
+
* The `limit` the caller passed to the query that produced `page`. Compared to `page.length`, it
|
|
73
|
+
* says whether `page` reached the channel start (see
|
|
74
|
+
* {@link MessageIntervalPaginator.pageReachedChannelStart}, which ignores a limit above
|
|
75
|
+
* `pageSize`), deciding `hasMoreTail`, whether `page` can be separated from the head interval by
|
|
76
|
+
* a gap, and whether a reload asks the server about messages deleted below the page (see
|
|
77
|
+
* {@link MessageIntervalPaginator.removeIdsTailwardOfPageIfNothingOlder}). On its own it never
|
|
78
|
+
* removes a message. Pass the limit actually sent: a larger one makes a short page look like the
|
|
79
|
+
* channel start, welding it to the head interval across a real gap.
|
|
96
80
|
*/
|
|
97
81
|
requestedLimit?: number;
|
|
98
82
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
83
|
+
* The IDs of the head interval's server-confirmed items when the request for `page` went out,
|
|
84
|
+
* taken with {@link MessageIntervalPaginator.getHeadIntervalItemIdsAtRequest} before the request
|
|
85
|
+
* is awaited. Only these prove what `page` says about the head interval:
|
|
86
|
+
*
|
|
87
|
+
* - deletion: at or above `page`'s newest message, and for an empty `page`, only this snapshot
|
|
88
|
+
* tells a just-deleted message from one that arrived live, or was sent, during the request;
|
|
89
|
+
* - contiguity: `page` starts inside the head interval only if its oldest message the head
|
|
90
|
+
* interval could hold is in this snapshot (see `isSeparatedFromHeadByGap`).
|
|
91
|
+
*
|
|
92
|
+
* Only the head interval receives live messages, so only its IDs are needed.
|
|
105
93
|
*/
|
|
106
|
-
|
|
94
|
+
headIntervalItemIdsAtRequest?: ReadonlySet<string>;
|
|
95
|
+
};
|
|
96
|
+
/** An external query prepared by {@link MessageIntervalPaginator.prepareExternalQuery}. */
|
|
97
|
+
export type PreparedExternalQuery = {
|
|
98
|
+
messagePaginationParams: MessagePaginationParams;
|
|
99
|
+
isNewestPage: boolean;
|
|
100
|
+
placePage: (page: LocalMessage[]) => boolean;
|
|
107
101
|
};
|
|
108
102
|
/**
|
|
109
|
-
*
|
|
103
|
+
* What one of the message paginator's own queries got back, before its page is extracted (see
|
|
104
|
+
* {@link MessageIntervalPaginator.fetchQueryResponse}), by where it came from.
|
|
110
105
|
*/
|
|
111
|
-
export type
|
|
112
|
-
/**
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
* {@link reconcile} is set and a window is already loaded.
|
|
126
|
-
*/
|
|
127
|
-
candidateIds?: ReadonlySet<string>;
|
|
106
|
+
export type MessageQueryResponse = {
|
|
107
|
+
/** what a custom `doRequest` returned: the page, used as is */
|
|
108
|
+
doRequestResponse: DoRequestResponse<LocalMessage>;
|
|
109
|
+
source: 'doRequest';
|
|
110
|
+
} | {
|
|
111
|
+
/** the replies endpoint's response for a thread's reply list */
|
|
112
|
+
repliesResponse: GetRepliesResponse;
|
|
113
|
+
source: 'replies';
|
|
114
|
+
} | {
|
|
115
|
+
/** the response of a channel query: its messages, and the rest, applied once they are placed */
|
|
116
|
+
channelResponse: StreamResponse<ChannelStateResponse>;
|
|
117
|
+
source: 'channel';
|
|
118
|
+
/** whether the query watched the channel, which applying the response records */
|
|
119
|
+
watch: boolean;
|
|
128
120
|
};
|
|
129
121
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
122
|
+
* A message list with a configurable backend request sort and a stable in-memory item order.
|
|
123
|
+
* Ingested items are filtered only by local predicates (`filterQueryResults`).
|
|
132
124
|
*/
|
|
133
|
-
export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage, MessageQueryShape> {
|
|
125
|
+
export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage, MessageQueryShape, MessageQueryResponse> {
|
|
126
|
+
/**
|
|
127
|
+
* Holder name of this list's index in the message store. A getter, so a subclass's value is in
|
|
128
|
+
* place while the base constructor builds the index.
|
|
129
|
+
*/
|
|
130
|
+
protected get holderName(): string;
|
|
134
131
|
state: StateStore<MessagePaginatorState>;
|
|
135
132
|
private readonly _id;
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
/** The channel this list belongs to. A thread's reply list holds its parent channel. */
|
|
134
|
+
readonly channel: Channel;
|
|
135
|
+
/** See {@link MessagePaginatorOptions.thread}. */
|
|
136
|
+
readonly thread?: Thread;
|
|
137
|
+
/** Set when this is a thread's reply list, to the parent message's ID. */
|
|
138
|
+
readonly parentMessageId?: string;
|
|
138
139
|
readonly messageFocusSignal: StateStore<MessageFocusSignalState>;
|
|
139
140
|
private clearMessageFocusSignalTimeoutId;
|
|
140
141
|
private messageFocusSignalToken;
|
|
141
142
|
protected _requestSort: MessagePaginatorSort;
|
|
142
143
|
protected _itemOrder: MessagePaginatorSort;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
/** The pending {@link removeIdsTailwardOfPageIfNothingOlder} (kept so tests can await it). */
|
|
145
|
+
private _pendingTailwardOfPageRemoval?;
|
|
146
|
+
/**
|
|
147
|
+
* The ID of the newest server-confirmed message of the interval whose head mark was cleared last
|
|
148
|
+
* (see {@link unmarkedHeadInterval}). Forgotten once a newest page is reconciled with no head
|
|
149
|
+
* interval loaded, and when the loaded intervals are cleared.
|
|
150
|
+
*/
|
|
151
|
+
private unmarkedHeadEdgeId;
|
|
146
152
|
sortComparator: (a: LocalMessage, b: LocalMessage) => number;
|
|
147
153
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
154
|
+
* Whether a message belongs in intervals and state. Keep it consistent with `filterQueryResults`
|
|
155
|
+
* and with the page the linear cursor flag derivation reads (see {@link deriveCursorFromPage}).
|
|
150
156
|
*/
|
|
151
157
|
shouldIncludeMessageInInterval(message: LocalMessage): boolean;
|
|
152
158
|
/**
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
159
|
+
* Reconciles the held messages that changed in the entity store.
|
|
160
|
+
*
|
|
161
|
+
* @internal
|
|
162
|
+
* @param batch - The change batch from the store.
|
|
163
|
+
* @param batch.changedIds - IDs of the watched messages that changed.
|
|
158
164
|
*/
|
|
159
165
|
onEntitiesChanged({ changedIds }: EntityStoreChangeBatch): void;
|
|
160
166
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
167
|
+
* Drops a message from this paginator's intervals after the entity store removed it.
|
|
168
|
+
*
|
|
169
|
+
* @internal
|
|
170
|
+
* @param id - ID of the removed message.
|
|
171
|
+
* @param message - The removed message.
|
|
164
172
|
*/
|
|
173
|
+
onEntityRemoved(id: string, message: unknown): void;
|
|
174
|
+
/** Entity-store subscriber flush after an optimistic (local-user) write: skips the throttle. */
|
|
165
175
|
flushState(): void;
|
|
176
|
+
/** UI-driven "hold off on pruning" signal ({@link setPruningSuspended}). Off by default. */
|
|
177
|
+
protected get isPruningSuspended(): boolean;
|
|
178
|
+
private _pruningSuspended;
|
|
179
|
+
/**
|
|
180
|
+
* Holds off dropping the oldest loaded messages, so pruning does not pull content from under a user
|
|
181
|
+
* reading near them: the interval may grow past `maxLoadedItems` until they scroll back. A plain
|
|
182
|
+
* field, not a `StateStore`: nothing observes it and a scroll-driven signal must not cost a render.
|
|
183
|
+
*/
|
|
184
|
+
setPruningSuspended: (suspended: boolean) => void;
|
|
185
|
+
/**
|
|
186
|
+
* A message anchors pagination once the server has acknowledged it. This keeps an unsent message
|
|
187
|
+
* out of both halves of a prune and stops its ID from becoming the tailward cursor (`id_lt`).
|
|
188
|
+
*/
|
|
189
|
+
protected isPaginationAnchorable(item: LocalMessage | undefined): boolean;
|
|
166
190
|
protected get intervalItemIdsAreHeadFirst(): boolean;
|
|
167
191
|
protected get intervalSortDirection(): 'asc' | 'desc';
|
|
168
|
-
constructor({ channel, id, itemIndex, parentMessageId, requestSort, sort, itemOrder, paginatorOptions, }: MessagePaginatorOptions, builtInDefaults?: Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>);
|
|
192
|
+
constructor({ channel, id, itemIndex, parentMessageId, requestSort, sort, itemOrder, paginatorOptions, thread, }: MessagePaginatorOptions, builtInDefaults?: Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>);
|
|
169
193
|
/**
|
|
170
|
-
* Memoized
|
|
171
|
-
*
|
|
172
|
-
* are stable.
|
|
173
|
-
*
|
|
174
|
-
* Safe to build once: both close over `this` and read `_itemOrder`, which is assigned in the
|
|
175
|
-
* constructor and has no setter.
|
|
194
|
+
* Memoized: `initializeConfig` folds it in and skips the publish when nothing moved, which needs
|
|
195
|
+
* stable references. Safe to build once: `_itemOrder` is set in the constructor, with no setter.
|
|
176
196
|
*/
|
|
177
197
|
private intervalBehaviour?;
|
|
178
198
|
private buildIntervalBehaviour;
|
|
179
199
|
/**
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* Contributed to the base derivation rather than written after it — see
|
|
184
|
-
* {@link BasePaginator.getBehaviourOverrides}. That is what keeps one re-derivation to one publish,
|
|
185
|
-
* and stops the intermediate publish that had these two stripped.
|
|
200
|
+
* Installs cursor derivation and item ordering on `config` through the base derivation
|
|
201
|
+
* ({@link BasePaginator.getBehaviourOverrides}), so one re-derivation is one publish.
|
|
186
202
|
*/
|
|
187
203
|
protected getBehaviourOverrides(): Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>;
|
|
188
204
|
/**
|
|
189
|
-
* The constructor's route to the same overlay.
|
|
190
|
-
*
|
|
191
|
-
* own fields were initialized.
|
|
205
|
+
* The constructor's route to the same overlay. It calls the private builder, not the overridable
|
|
206
|
+
* hook, which would run a subclass override before its fields are initialized.
|
|
192
207
|
*/
|
|
193
208
|
protected installIntervalBehaviour(): void;
|
|
194
209
|
get id(): string;
|
|
195
210
|
get sort(): MessagePaginatorSort;
|
|
196
211
|
get requestSort(): MessagePaginatorSort;
|
|
197
212
|
get itemOrder(): MessagePaginatorSort;
|
|
198
|
-
/**
|
|
199
|
-
* Even though we do not send filters object to the server, we need to have filters for client-side item ingestion logic.
|
|
200
|
-
*/
|
|
213
|
+
/** Not sent to the server: drives client-side item ingestion. */
|
|
201
214
|
buildMatchFilters: () => MessagePaginatorFilter;
|
|
202
215
|
protected getNextQueryShape({ direction, }: Omit<PaginationQueryParams<MessageQueryShape>, 'isFirstPageQuery'>): MessageQueryShape;
|
|
203
216
|
getCursorFromQueryResults: ({ direction, items, }: {
|
|
@@ -207,168 +220,430 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
|
|
|
207
220
|
tailward: string | undefined;
|
|
208
221
|
headward: string | undefined;
|
|
209
222
|
};
|
|
210
|
-
query: ({ direction, }: PaginationQueryParams<MessageQueryShape>) => Promise<PaginationQueryReturnValue<LocalMessage>>;
|
|
211
223
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
224
|
+
* Runs the query pipeline (see `BasePaginator.executeQuery`). A query that goes to the channel —
|
|
225
|
+
* not a thread's reply list, not a custom `doRequest` — runs as a tracked query of the channel
|
|
226
|
+
* (`Channel.runTrackedQuery`), so the channel store keeps the channel until the query ends. A
|
|
227
|
+
* disposed channel's query is not tracked: its fetch step is refused, and fails as any failed
|
|
228
|
+
* request does.
|
|
229
|
+
*/
|
|
230
|
+
executeQuery(params?: PaginationQueryParams<MessageQueryShape>): Promise<ExecuteQueryReturnValue<LocalMessage> | void>;
|
|
231
|
+
/**
|
|
232
|
+
* The fetching step of the query pipeline: requests a page through a custom `doRequest`, the
|
|
233
|
+
* replies endpoint for a thread's reply list, or the channel query otherwise, which takes in what
|
|
234
|
+
* the response says about the channel itself and leaves the rest for the last step (see
|
|
235
|
+
* `Channel.requestChannelState`). Reads `requestOptions.watch`: `true` also watches the channel
|
|
236
|
+
* with the request. Ignored for a thread's reply list and with `doRequest`.
|
|
237
|
+
*/
|
|
238
|
+
protected fetchQueryResponse: ({ direction, queryShape, requestOptions, }: PaginationQueryParams<MessageQueryShape>) => Promise<MessageQueryResponse>;
|
|
239
|
+
/**
|
|
240
|
+
* The extracting step of the query pipeline: the messages in item order and their cursors, which
|
|
241
|
+
* a custom `doRequest` reports and which are derived from the messages otherwise.
|
|
242
|
+
*/
|
|
243
|
+
protected extractQueryPage(response: MessageQueryResponse, { direction }: PaginationQueryParams<MessageQueryShape>): PaginationQueryReturnValue<LocalMessage>;
|
|
244
|
+
/**
|
|
245
|
+
* The last step of the query pipeline: the rest of a channel query's response, applied once its
|
|
246
|
+
* page is placed (see `Channel.applyChannelStateFromResponse`). The other sources return nothing
|
|
247
|
+
* else.
|
|
248
|
+
*/
|
|
249
|
+
protected applyQueryResponseRest(response: MessageQueryResponse, _placeParams: QueryPagePlacement<MessageQueryShape>): void;
|
|
250
|
+
/**
|
|
251
|
+
* Whether this paginator is active: the thread it lists is active (see `Thread.activate()`), or,
|
|
252
|
+
* without a thread, its channel is (see `Channel.activate()`). A page from a query an active
|
|
253
|
+
* paginator did not run leaves its active interval active; an inactive paginator shows a fresh
|
|
254
|
+
* newest page instead, also one separated from the loaded messages by a gap (see
|
|
255
|
+
* {@link reconcileNewestMessages}).
|
|
256
|
+
*/
|
|
257
|
+
private isActivePaginator;
|
|
258
|
+
/**
|
|
259
|
+
* Places a page from an external query — one this paginator did not run, whose page the caller
|
|
260
|
+
* chose — in the intervals it belongs to, never removing anything loaded. Bringing the loaded
|
|
261
|
+
* newest messages up to date with a fresh newest page, removals included, is
|
|
262
|
+
* {@link reconcileNewestMessages}'s job instead.
|
|
263
|
+
*
|
|
264
|
+
* External queries are a channel query (`watch()`, see {@link prepareExternalQuery}), the
|
|
265
|
+
* channel list's query (`client.hydrateChannels`), and the channel state the pinned list's first
|
|
266
|
+
* page comes with. `messagePaginationParams` are the
|
|
267
|
+
* options the page was queried with; they decide where it goes:
|
|
268
|
+
*
|
|
269
|
+
* - The newest page: when no interval is active yet (nothing loaded, or only live messages), its
|
|
270
|
+
* interval becomes the active one, as the channel's first page. When the active interval is the
|
|
271
|
+
* newest interval, the page lands in it.
|
|
272
|
+
* - Any other page — a page at a cursor or around a message, or the newest page while an older
|
|
273
|
+
* interval is active — is only stored, as a separate interval merged only with an interval it
|
|
274
|
+
* overlaps.
|
|
275
|
+
*
|
|
276
|
+
* The active interval stays active: changing it is this paginator's own methods' job
|
|
277
|
+
* (`jumpToMessage()` and the like). The exception is an inactive paginator (see
|
|
278
|
+
* {@link isActivePaginator}), where the newest page is shown as when no interval is
|
|
279
|
+
* active. A newest
|
|
280
|
+
* page for loaded messages goes to {@link reconcileNewestMessages} instead
|
|
281
|
+
* (`prepareExternalQuery`, the channel list's query). When a page lands in the active interval,
|
|
282
|
+
* overlaps it, or takes in an active interval of live messages only, that interval is shown again
|
|
283
|
+
* with the page. The paginator's own queries are left alone too: a running one keeps its loading
|
|
284
|
+
* flag, and its last query error and query shape stay.
|
|
285
|
+
*
|
|
286
|
+
* It runs synchronously, so a caller can apply the rest of the response right after with the page
|
|
287
|
+
* in place, as it has to: read and delivery positions that come without a message id are looked
|
|
288
|
+
* up among the loaded messages.
|
|
289
|
+
*
|
|
290
|
+
* Returns whether it showed the page as a first page.
|
|
291
|
+
*/
|
|
292
|
+
placeExternalQueryPage(page: LocalMessage[], requestedPageSize: number, messagePaginationParams?: MessagePaginationParams): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Whether messages are loaded for {@link reconcileNewestMessages} to bring up to date. A list
|
|
295
|
+
* loaded empty has none (no interval, not even live messages), so a fresh newest page is placed
|
|
296
|
+
* as a first page instead ({@link placeExternalQueryPage}); reconciling would find nothing to
|
|
297
|
+
* merge it into and drop it.
|
|
298
|
+
*/
|
|
299
|
+
get canReconcileNewestMessages(): boolean;
|
|
300
|
+
/**
|
|
301
|
+
* The snapshot a newest page is reconciled against (see
|
|
302
|
+
* {@link ReconcileNewestMessagesOptions.headIntervalItemIdsAtRequest}): the IDs of the head
|
|
303
|
+
* interval's server-confirmed messages. Take it right before the request goes out. Unsent messages
|
|
304
|
+
* are left out: one confirmed during the request proves neither that the page connects to the
|
|
305
|
+
* head interval nor, when the page lacks it, that it was deleted. `undefined` while no head
|
|
306
|
+
* interval is loaded.
|
|
307
|
+
*
|
|
308
|
+
* @internal
|
|
309
|
+
*/
|
|
310
|
+
getHeadIntervalItemIdsAtRequest(): ReadonlySet<string> | undefined;
|
|
311
|
+
/**
|
|
312
|
+
* Whether the loaded message with this ID is server-confirmed
|
|
313
|
+
* (see {@link isServerConfirmedMessage}).
|
|
314
|
+
*/
|
|
315
|
+
private isServerConfirmedItemId;
|
|
316
|
+
/**
|
|
317
|
+
* Prepares an external query for a page of these messages: the watch query the channel sends
|
|
318
|
+
* (`channel.watch()`, `channel.reload()`) with the `messages` options its caller gave. Call it
|
|
319
|
+
* before sending the query, and place the returned page with `placePage` before the response's
|
|
320
|
+
* read state is applied: the read state is resolved against the loaded messages.
|
|
214
321
|
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
322
|
+
* - `messagePaginationParams`: the options to send as the query's `messages`, with `limit` set to
|
|
323
|
+
* the page size when not given.
|
|
324
|
+
* - `isNewestPage`: whether the query asks for the newest page — no cursor, not around a message,
|
|
325
|
+
* and some messages.
|
|
326
|
+
* - `placePage`: places the returned page. The newest page goes to
|
|
327
|
+
* {@link placeExternalNewestPage}, reconciled against the messages loaded when the query was
|
|
328
|
+
* prepared; any other page is placed by {@link placeExternalQueryPage}. A query for no messages
|
|
329
|
+
* (`limit: 0`) places nothing. Returns whether it showed a first page.
|
|
330
|
+
*/
|
|
331
|
+
prepareExternalQuery(messages?: MessagePaginationParams): PreparedExternalQuery;
|
|
332
|
+
/**
|
|
333
|
+
* Places the newest page of an external query (a channel query, the channel list's query): it
|
|
334
|
+
* reconciles the loaded newest messages ({@link reconcileNewestMessages}), or is placed as a
|
|
335
|
+
* first page when none are loaded ({@link placeExternalQueryPage}). A query for no messages
|
|
336
|
+
* (`requestedLimit: 0`) places nothing. Returns whether it showed a first page.
|
|
221
337
|
*
|
|
222
|
-
*
|
|
223
|
-
* (`messages: { id_around }` / `{ created_at_around }`), so the original pagination options are
|
|
224
|
-
* threaded through as the query shape. For an around/jump open this lets `postQueryReconcile`
|
|
225
|
-
* apply jump semantics (no forced head/tail; cursor flags derived from the around position)
|
|
226
|
-
* instead of wrongly flagging the window as the head (newest) page.
|
|
338
|
+
* @internal
|
|
227
339
|
*/
|
|
228
|
-
|
|
340
|
+
placeExternalNewestPage(page: LocalMessage[], { headIntervalItemIdsAtRequest, requestedLimit, }: ReconcileNewestMessagesOptions & {
|
|
341
|
+
requestedLimit: number;
|
|
342
|
+
}): boolean;
|
|
229
343
|
isJumpQueryShape(queryShape: MessageQueryShape): boolean;
|
|
230
|
-
|
|
344
|
+
/** Only a query without a cursor and not around a message returns the newest page. */
|
|
345
|
+
protected isHeadPageQueryShape(queryShape: MessageQueryShape | undefined): boolean;
|
|
346
|
+
/** A jump sends its own `limit`: head/tail flags are derived against it, not `pageSize`. */
|
|
347
|
+
protected getRequestedPageSize(queryShape: MessageQueryShape | undefined): number;
|
|
348
|
+
/**
|
|
349
|
+
* Makes the interval holding the message the active one, querying the page around it when it is
|
|
350
|
+
* not loaded. Resolves `false` when the message cannot be shown, or when a later claim on the
|
|
351
|
+
* active interval (see `claimActiveInterval`) was made before the page arrived.
|
|
352
|
+
*/
|
|
353
|
+
jumpToMessage: (messageId: string, { focusReason, focusSignalTtlMs, pageSize, suppressFocusSignal, watchChannel, }?: JumpToMessageOptions) => Promise<boolean>;
|
|
354
|
+
/**
|
|
355
|
+
* Shows a loaded interval as it is: its items, its own pagination flags and the cursor continuing
|
|
356
|
+
* it. Claiming the active interval is the caller's choice (see `claimActiveInterval`).
|
|
357
|
+
*/
|
|
358
|
+
protected showLoadedInterval(interval: Interval): void;
|
|
359
|
+
/** Makes `interval` the active interval and publishes `state` for it in one update. */
|
|
360
|
+
private showInterval;
|
|
361
|
+
/**
|
|
362
|
+
* Shows the interval holding the latest message and jumps to that message. Without a loaded head
|
|
363
|
+
* interval (see {@link latestHeadInterval}), the newest page is queried first: no cursor, so it
|
|
364
|
+
* holds the latest message however many pages are missing. The page merges with an interval it
|
|
365
|
+
* overlaps and is an interval of its own otherwise, and is shown either way. Resolves `false` when
|
|
366
|
+
* the latest message cannot be shown, or when a later claim on the active interval (see
|
|
367
|
+
* `claimActiveInterval`) was made before the page arrived: that page is then only stored.
|
|
368
|
+
*/
|
|
231
369
|
jumpToTheLatestMessage: (options?: JumpToMessageOptions) => Promise<boolean>;
|
|
232
370
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* the
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
* `
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
|
|
281
|
-
|
|
371
|
+
* The head interval when it is the newest loaded interval, so its newest message is the latest
|
|
372
|
+
* one; `undefined` while no head interval is loaded or live messages newer than it are.
|
|
373
|
+
*/
|
|
374
|
+
private get latestHeadInterval();
|
|
375
|
+
/**
|
|
376
|
+
* Reconciles the loaded newest messages with a fresh newest page, without issuing a query: they
|
|
377
|
+
* are brought up to date in place — messages added and updated, those the page proves were
|
|
378
|
+
* hard-deleted removed — rather than blanked and reloaded. The page comes from an external query
|
|
379
|
+
* (a reload, a channel-list query, connection recovery). In an active paginator (see
|
|
380
|
+
* {@link isActivePaginator}) the active interval stays active, the head interval included
|
|
381
|
+
* (changing it is `jumpToTheLatestMessage()`'s job); in an inactive one, the head interval is
|
|
382
|
+
* shown.
|
|
383
|
+
*
|
|
384
|
+
* Where the page goes depends on the head interval, the loaded interval reaching the newest
|
|
385
|
+
* message:
|
|
386
|
+
*
|
|
387
|
+
* 1. NO HEAD INTERVAL (only live messages, a jumped-to interval, or a cleared head mark, see
|
|
388
|
+
* {@link unmarkHead}) - the page becomes the head interval, merging with the intervals it
|
|
389
|
+
* overlaps, live messages included, minus what it proves was hard-deleted. It is shown if the
|
|
390
|
+
* live messages it absorbed were active; an active interval that it overlaps grows. A
|
|
391
|
+
* page separated by a gap from the interval whose head mark was cleared is placed as in 2.
|
|
392
|
+
*
|
|
393
|
+
* 2. SEPARATED BY A GAP (see {@link isSeparatedFromHeadByGap}) - merging would weld the two
|
|
394
|
+
* across the gap, hiding the messages in between, so the page takes the place of the head
|
|
395
|
+
* interval (see {@link placeNewestPageAcrossGap}): stored beside the active interval when that
|
|
396
|
+
* is an older interval, shown in place of the loaded intervals otherwise.
|
|
397
|
+
*
|
|
398
|
+
* 3. OTHERWISE - the page merges into the head interval, which keeps every loaded message and
|
|
399
|
+
* drops what the page proves was hard-deleted (see {@link reconcileHeadAgainstPage}). An
|
|
400
|
+
* active head interval gets its tail boundary from the page (see {@link showHeadInterval});
|
|
401
|
+
* otherwise the active interval stays active, and grows into the head interval if the page
|
|
402
|
+
* overlaps it.
|
|
403
|
+
*
|
|
404
|
+
* Only a gap drops loaded intervals, never an older active interval, and with nothing loaded it
|
|
405
|
+
* does nothing: placing a first page is {@link placeQueryPage}'s job. An empty page changes
|
|
406
|
+
* nothing on its own but, given a pre-fetch snapshot (`options.headIntervalItemIdsAtRequest`), is
|
|
407
|
+
* reconciled as "the channel has no messages": every server-confirmed message of the head interval
|
|
408
|
+
* is removed.
|
|
409
|
+
*
|
|
410
|
+
* The query shape of the loaded interval is recorded on every exit (see
|
|
411
|
+
* `recordLoadedIntervalQueryShape`): an interval left without one loses itself on the next
|
|
412
|
+
* pagination.
|
|
413
|
+
*
|
|
414
|
+
* @param page - The fetched newest interval (may be empty). `created_at` order is normalized on
|
|
415
|
+
* ingest.
|
|
416
|
+
* @param options - See {@link ReconcileNewestMessagesOptions}. Omit to prune only within the
|
|
417
|
+
* page's own span.
|
|
418
|
+
*/
|
|
419
|
+
reconcileNewestMessages: (page: LocalMessage[], options?: ReconcileNewestMessagesOptions) => void;
|
|
420
|
+
private _reconcileNewestMessages;
|
|
421
|
+
/**
|
|
422
|
+
* Shows the head interval a fresh newest page merged into, with no newer messages to load. It has
|
|
423
|
+
* older ones unless the page reached the channel start (see {@link pageReachedChannelStart});
|
|
424
|
+
* `isTail` follows, which also clears a stale offline-DB `isTail: true` that would let
|
|
425
|
+
* `intervalsOverlap` weld a far page across a gap.
|
|
426
|
+
*/
|
|
427
|
+
private showHeadInterval;
|
|
428
|
+
/**
|
|
429
|
+
* Whether a fresh newest page and the head interval (or the interval whose head mark was cleared,
|
|
430
|
+
* see {@link unmarkedHeadInterval}) are separated by a gap, with messages between them possibly
|
|
431
|
+
* not loaded. They are not when the two together form one unbroken stretch of the channel:
|
|
432
|
+
*
|
|
433
|
+
* - the page starts inside the head interval (see {@link pageStartsInsideHead});
|
|
434
|
+
* - the page covers the head interval (see {@link pageCoversHead});
|
|
435
|
+
* - the page reached the channel start (see {@link pageReachedChannelStart}), so nothing older
|
|
436
|
+
* than it exists to be missing.
|
|
437
|
+
*
|
|
438
|
+
* Sharing a message is not enough on its own: a message the user sent while offline is confirmed
|
|
439
|
+
* by the server before the reconnect's newest page is requested, so it sits at the top of the
|
|
440
|
+
* head interval and in the page, with the messages missed below it in neither. For example, the
|
|
441
|
+
* interval holds m1–m100 and the user's queued "hello"; the server got m101–m210 meanwhile. A page
|
|
442
|
+
* of 25 holds m187–m210 and "hello": it does not start inside the interval (m187 was never loaded)
|
|
443
|
+
* nor cover it (m1 is not in it), so it is past a gap. When the user wrote the last 10 loaded
|
|
444
|
+
* messages and others sent 20 since, a page of 25 holds the user's last 5 and the 20 new ones:
|
|
445
|
+
* its oldest was loaded, so it starts inside the interval.
|
|
446
|
+
*
|
|
447
|
+
* A message missed while the socket was down comes with connection recovery's newest page.
|
|
448
|
+
*/
|
|
449
|
+
private isSeparatedFromHeadByGap;
|
|
450
|
+
/**
|
|
451
|
+
* Whether the page's oldest message the head interval could hold (see
|
|
452
|
+
* {@link getPageOldestHoldableMessage}) was in the head interval when the request went out. The
|
|
453
|
+
* page runs unbroken from that message to the newest and the interval is taken to run unbroken
|
|
454
|
+
* below it, so nothing between them is missing.
|
|
455
|
+
*
|
|
456
|
+
* With a snapshot of the request (`options.headIntervalItemIdsAtRequest`), the message must be
|
|
457
|
+
* in it and held by no interval other than the head interval: a message that reached the interval
|
|
458
|
+
* during the request, live or as a send confirmed meanwhile, may sit above messages the interval
|
|
459
|
+
* never loaded. One no longer loaded at all still counts: if the head interval holds messages
|
|
460
|
+
* older than it, the interval ran unbroken through it and it was removed (e.g. hard-deleted);
|
|
461
|
+
* if not, the page covers the interval anyway. Without a snapshot, the message must be in the
|
|
462
|
+
* head interval and server-confirmed now.
|
|
463
|
+
*
|
|
464
|
+
* The interval is not unbroken below a send the server confirmed while the channel received no
|
|
465
|
+
* events, such as one replayed from the offline queue before the reconnect's newest page is
|
|
466
|
+
* requested. If that send is exactly the page's oldest (as many newer messages as the page has
|
|
467
|
+
* room for were sent after it), the page is taken to start inside the interval although messages
|
|
468
|
+
* below the send were missed. The page and the interval cannot tell this apart from a send
|
|
469
|
+
* confirmed while events were arriving.
|
|
470
|
+
*/
|
|
471
|
+
private pageStartsInsideHead;
|
|
472
|
+
/**
|
|
473
|
+
* Whether the page spans the whole head interval: the interval holds no server-confirmed message
|
|
474
|
+
* older than the page. What the interval holds beyond the page is newer (it arrived as an event
|
|
475
|
+
* after the page was produced) or unsent (it carries the device's clock).
|
|
476
|
+
*/
|
|
477
|
+
private pageCoversHead;
|
|
478
|
+
/**
|
|
479
|
+
* The page's oldest message that the head interval could have loaded: server-confirmed and kept
|
|
480
|
+
* in intervals (see {@link filterQueryResults}). A message the interval filters out, such as a
|
|
481
|
+
* shadowed one, would never be found in it. {@link pageCoversHead} compares with the page's
|
|
482
|
+
* oldest message of any kind instead: it only needs the page's span.
|
|
483
|
+
*/
|
|
484
|
+
private getPageOldestHoldableMessage;
|
|
485
|
+
/**
|
|
486
|
+
* The interval whose head mark was cleared last (see {@link unmarkHead}), while it is still
|
|
487
|
+
* loaded. It reached the newest message until then, so a newest page is judged against it while
|
|
488
|
+
* no head interval is loaded.
|
|
489
|
+
*/
|
|
490
|
+
private get unmarkedHeadInterval();
|
|
491
|
+
/**
|
|
492
|
+
* Remembers the interval by a message that stays in it: a server-confirmed one, as an unsent one
|
|
493
|
+
* may be deleted or retried; the raw newest item only when the interval holds none.
|
|
494
|
+
*/
|
|
495
|
+
protected unmarkHead(interval: Interval): void;
|
|
496
|
+
protected clearItemStorage(): void;
|
|
497
|
+
resetState(): void;
|
|
498
|
+
private getPageOldestMessage;
|
|
499
|
+
/**
|
|
500
|
+
* Places a fresh newest page separated by a gap from `headInterval` (the head interval, or the
|
|
501
|
+
* interval whose head mark was cleared, see {@link isSeparatedFromHeadByGap}). The page becomes
|
|
502
|
+
* the head interval either way, and the intervals nothing brought up to date are dropped, as a
|
|
503
|
+
* message deleted meanwhile would come back with them:
|
|
504
|
+
*
|
|
505
|
+
* - an active interval other than the head interval (see {@link getActiveIntervalApartFromHead})
|
|
506
|
+
* stays active, and the page is stored beside it (see
|
|
507
|
+
* {@link storeNewestPageBesideActiveInterval});
|
|
508
|
+
* - otherwise the page replaces the loaded intervals and is shown (see
|
|
509
|
+
* {@link replaceIntervalsWithNewestPage}).
|
|
510
|
+
*/
|
|
511
|
+
private placeNewestPageAcrossGap;
|
|
512
|
+
/**
|
|
513
|
+
* The active loaded interval when it is not `headInterval`, such as an interval jumped to;
|
|
514
|
+
* `undefined` when `headInterval` or live messages only are active, and in an inactive paginator
|
|
515
|
+
* (see {@link isActivePaginator}).
|
|
516
|
+
*/
|
|
517
|
+
private getActiveIntervalApartFromHead;
|
|
518
|
+
/**
|
|
519
|
+
* Replaces the loaded intervals with a fresh newest page separated from the head interval by a gap
|
|
520
|
+
* (see {@link placeNewestPageAcrossGap}) and shows it. The page's interval keeps the loaded
|
|
521
|
+
* messages that must not be lost (see {@link getMessagesKeptAcrossGap}) and has older messages
|
|
522
|
+
* to load.
|
|
523
|
+
*/
|
|
524
|
+
private replaceIntervalsWithNewestPage;
|
|
525
|
+
/**
|
|
526
|
+
* Stores a fresh newest page separated from the head interval by a gap (see
|
|
527
|
+
* {@link placeNewestPageAcrossGap}) as the head interval, beside `activeInterval`, which stays
|
|
528
|
+
* active and shown as it is. Every other loaded interval is dropped and loads again on
|
|
529
|
+
* demand. The page's interval keeps the messages of the dropped intervals that must not be lost
|
|
530
|
+
* (see {@link getMessagesKeptAcrossGap}) and has older messages to load.
|
|
531
|
+
*
|
|
532
|
+
* The active interval keeps all its messages, unsent ones included, so nothing moves in the
|
|
533
|
+
* shown list, and it is not brought up to date: a message deleted or edited meanwhile stays as it was
|
|
534
|
+
* loaded. It can load newer messages, up to the head interval it then joins.
|
|
535
|
+
*/
|
|
536
|
+
private storeNewestPageBesideActiveInterval;
|
|
537
|
+
/**
|
|
538
|
+
* Ingests a fresh newest page placed across a gap, with `keptMessages`, as the head interval,
|
|
539
|
+
* which has older messages to load, and removes from it what the page proves was hard-deleted (see
|
|
540
|
+
* {@link reconcileHeadAgainstPage}). Returns the interval the page landed in.
|
|
541
|
+
*/
|
|
542
|
+
private ingestPageAsHeadInterval;
|
|
543
|
+
/**
|
|
544
|
+
* Drops `intervals` from storage and releases their messages, except those with `keepingIds`,
|
|
545
|
+
* which the caller ingests again.
|
|
546
|
+
*/
|
|
547
|
+
private dropIntervals;
|
|
548
|
+
/**
|
|
549
|
+
* Marks the active interval, which does not reach the newest message, as able to load newer
|
|
550
|
+
* messages. Publishes the flag and cursor only when they changed, so the interval shown stays as
|
|
551
|
+
* it is.
|
|
552
|
+
*/
|
|
553
|
+
private markActiveIntervalBelowHead;
|
|
554
|
+
/**
|
|
555
|
+
* The messages of `intervals`, missing from a newest page placed across a gap, that the page's
|
|
556
|
+
* interval keeps:
|
|
557
|
+
*
|
|
558
|
+
* - unsent messages (see {@link isServerConfirmedMessage});
|
|
559
|
+
* - messages from the page's oldest on: those that arrived during the request stay, and
|
|
560
|
+
* reconciling removes those the page proves were hard-deleted.
|
|
561
|
+
*/
|
|
562
|
+
private getMessagesKeptAcrossGap;
|
|
563
|
+
/**
|
|
564
|
+
* Merges a fresh newest page, not separated by a gap, into the head interval while another
|
|
565
|
+
* interval is shown. That interval stays active and grows into the head interval if the page
|
|
566
|
+
* overlaps it. In an inactive paginator (see {@link isActivePaginator}), the head interval is
|
|
567
|
+
* shown instead.
|
|
568
|
+
*/
|
|
569
|
+
private mergePageIntoInactiveHead;
|
|
570
|
+
/** Publishes the active interval once a newest page grew it into the head interval. */
|
|
571
|
+
private publishActiveIntervalGrownIntoHead;
|
|
572
|
+
/**
|
|
573
|
+
* Whether `page` proves it reached the channel's oldest message: the request was bounded by this
|
|
574
|
+
* paginator's own `pageSize` and `page` came back shorter. A larger over-request (e.g.
|
|
575
|
+
* `channel.reload`) may have been server-capped and never proves it. Gates `hasMoreTail` and the
|
|
576
|
+
* gap rule ({@link isSeparatedFromHeadByGap}), never removing a message.
|
|
282
577
|
*/
|
|
283
578
|
private pageReachedChannelStart;
|
|
284
579
|
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* older than `
|
|
289
|
-
*
|
|
290
|
-
*
|
|
580
|
+
* Settles the loaded messages {@link reconcileHeadAgainstPage} found tailward of the page (older
|
|
581
|
+
* than `pageTailId`, the page's oldest, and absent from it): from the page alone a hard-deleted
|
|
582
|
+
* oldest message looks like one the page was too short to include. It asks the server whether
|
|
583
|
+
* anything is older than `pageTailId`. When nothing is, those messages were deleted: they are
|
|
584
|
+
* removed and the head interval becomes the tail. A failed request, or a head interval replaced
|
|
585
|
+
* while waiting, keeps them. The caller decides when this runs.
|
|
291
586
|
*/
|
|
292
|
-
private
|
|
587
|
+
private removeIdsTailwardOfPageIfNothingOlder;
|
|
293
588
|
/** One `limit: 1` fetch of messages older than `id` (channel main list or thread replies). */
|
|
294
589
|
private hasMessagesOlderThan;
|
|
295
590
|
/**
|
|
296
|
-
* Whether a loaded message is server-confirmed
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* so a legitimately-unsent message is never mistaken for a hard delete.
|
|
591
|
+
* Whether a loaded message is server-confirmed, so it may be reconciled away when absent from an
|
|
592
|
+
* authoritative page. Optimistic (`sending`), `failed` and client-side `error` messages are not, so
|
|
593
|
+
* an unsent message is never mistaken for a hard delete.
|
|
300
594
|
*/
|
|
301
595
|
protected isServerConfirmedMessage(message: LocalMessage): boolean;
|
|
302
596
|
/**
|
|
303
|
-
*
|
|
304
|
-
* `
|
|
305
|
-
* the merge is additive, so they would otherwise linger forever).
|
|
306
|
-
*
|
|
307
|
-
* Here `page` is the freshly-fetched newest window the server returned for the query that produced
|
|
308
|
-
* it. Its two bounds are its NEWEST message (`page`'s last item by `created_at`) and its OLDEST
|
|
309
|
-
* message (`page`'s first item). Reconciliation removes ONLY messages `page` actually covers — no
|
|
310
|
-
* hardcoded page size is involved — in two regions, by a loaded message's `created_at`:
|
|
311
|
-
*
|
|
312
|
-
* - WITHIN `page` (strictly between `page`'s oldest and newest message): a server-confirmed loaded
|
|
313
|
-
* message absent from `page` was hard-deleted. Safe with no snapshot — a message that arrived live
|
|
314
|
-
* during the caller's fetch is always strictly newer than `page`'s newest message, so it can never
|
|
315
|
-
* fall in this span.
|
|
316
|
-
* - AT/ABOVE `page`'s newest message (a hard-deleted newest message), and the empty-`page` case:
|
|
317
|
-
* only reconcilable with a pre-fetch `candidateIds` snapshot, which alone tells a just-deleted
|
|
318
|
-
* message from one that arrived live during the fetch at that top edge.
|
|
319
|
-
*
|
|
320
|
-
* A loaded message BELOW `page`'s oldest is NOT removed here (window-only) — from the page alone a
|
|
321
|
-
* hard-deleted oldest is indistinguishable from a server-capped over-request. Those messages are
|
|
322
|
-
* instead RETURNED (the below-window leftovers) so {@link pruneBelowWindowIfReachedStart} can settle
|
|
323
|
-
* them with a `limit: 1` "anything older?" probe — the only cap-free proof — and remove them only if
|
|
324
|
-
* the server confirms nothing older exists. Absent that proof they are kept (a later cold/fresh query
|
|
325
|
-
* omits any real delete).
|
|
326
|
-
*
|
|
327
|
-
* Removal goes through {@link removeItem} (batched) so the item index, intervals, shared message
|
|
328
|
-
* store and — via the {@link MessagePaginator} override — the tracked last message all stay correct;
|
|
329
|
-
* the active window is then re-emitted once.
|
|
330
|
-
*
|
|
331
|
-
* @returns the below-window leftover ids (loaded, server-confirmed, older than `page`'s oldest, absent
|
|
332
|
-
* from it) for the caller's reached-start probe. Empty for the no-head / empty-page paths.
|
|
333
|
-
*/
|
|
334
|
-
protected reconcileHeadAgainstPage(page: LocalMessage[], options?: MergeNewestPageOptions): string[];
|
|
335
|
-
/**
|
|
336
|
-
* Remove a set of reconciled (hard-deleted) ids from this paginator's loaded state in one coalesced
|
|
337
|
-
* batch. Each id goes through {@link removeItem}, which drops it from THREE places — not a single
|
|
338
|
-
* interval:
|
|
339
|
-
*
|
|
340
|
-
* 1. the item index — unlinks this paginator's membership from the shared entity store (GC'ing the
|
|
341
|
-
* content if this was the last holder);
|
|
342
|
-
* 2. the interval that holds it — located by id, so it is NOT head-specific in general; in practice
|
|
343
|
-
* it is always the head interval, because the sole caller ({@link reconcileHeadAgainstPage})
|
|
344
|
-
* sources these ids from `headInterval.itemIds` and an item has single-interval membership;
|
|
345
|
-
* 3. the active window (`state.items`) if visible — blanking to `[]` when the window empties, per
|
|
346
|
-
* {@link flushWindowPublish}.
|
|
347
|
-
*
|
|
348
|
-
* The coalesced batch collapses all of that into a single `state.items` publish. Then mirror the
|
|
349
|
-
* removal into the offline DB (see {@link purgeReconciledFromOfflineDb}) so a cold start does not
|
|
350
|
-
* re-seed the ghosts from SQLite. No-op for an empty set, so an unaffected merge does not touch
|
|
351
|
-
* state a second time.
|
|
597
|
+
* Whether this list holds `message`: it passes the filter and, in a channel's main list (no
|
|
598
|
+
* `parentMessageId`), is not a reply only its thread lists (see `isThreadOnlyReply`).
|
|
352
599
|
*/
|
|
353
|
-
private
|
|
600
|
+
private isListedMessage;
|
|
354
601
|
/**
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
602
|
+
* The failed messages a reload restores with {@link restoreFailedMessages}: those of the shown
|
|
603
|
+
* interval and the head interval, and those of `persisted` (e.g. the offline database's rows of
|
|
604
|
+
* the channel) this list holds (see {@link isListedMessage}). The loaded copy wins, as it is at
|
|
605
|
+
* least as fresh. Take them before the reload's request.
|
|
606
|
+
*
|
|
607
|
+
* @internal
|
|
608
|
+
*/
|
|
609
|
+
getFailedMessagesToRestore(persisted?: LocalMessage[]): LocalMessage[];
|
|
610
|
+
/**
|
|
611
|
+
* Ingests again each failed message taken before a reload (see
|
|
612
|
+
* {@link getFailedMessagesToRestore}) that no interval holds after it, so a reload never loses the
|
|
613
|
+
* user's unsent work. One an interval holds is left as it is: it may have been resent.
|
|
614
|
+
*
|
|
615
|
+
* @internal
|
|
616
|
+
*/
|
|
617
|
+
restoreFailedMessages(failedMessages: LocalMessage[]): void;
|
|
618
|
+
/**
|
|
619
|
+
* Destructive half of {@link reconcileNewestMessages}: removes loaded head-interval messages
|
|
620
|
+
* that `page` (the fresh newest interval) proves were hard-deleted while the client received no
|
|
621
|
+
* events, by `created_at`:
|
|
622
|
+
*
|
|
623
|
+
* - within `page`'s span: a server-confirmed message absent from `page` was deleted (a live
|
|
624
|
+
* arrival is newer than `page`'s newest, so this needs no snapshot);
|
|
625
|
+
* - at or above `page`'s newest, and for an empty `page`: only IDs in the pre-fetch
|
|
626
|
+
* `headIntervalItemIdsAtRequest` snapshot, which tells a just-deleted message from a live
|
|
627
|
+
* arrival or a send confirmed during the request.
|
|
628
|
+
*
|
|
629
|
+
* Messages below `page`'s oldest are kept (a hard-deleted oldest looks like a server-capped
|
|
630
|
+
* over-request) and returned for {@link removeIdsTailwardOfPageIfNothingOlder}. Removal goes through
|
|
631
|
+
* {@link removeItem}, so the index, intervals, message store and any subclass bookkeeping (e.g.
|
|
632
|
+
* the latest message of {@link MessagePaginator}) stay correct.
|
|
360
633
|
*
|
|
361
|
-
*
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
*
|
|
634
|
+
* @returns The below-interval leftover IDs. Empty for the no-head and empty-page paths.
|
|
635
|
+
*/
|
|
636
|
+
protected reconcileHeadAgainstPage(page: LocalMessage[], options?: ReconcileNewestMessagesOptions): string[];
|
|
637
|
+
/** Removes reconciled IDs in one coalesced batch (one publish), then mirrors it offline. */
|
|
638
|
+
private removeReconciledItems;
|
|
639
|
+
/**
|
|
640
|
+
* Mirrors a reconciliation into the offline DB: a hard delete done while offline reaches it via no
|
|
641
|
+
* event and the reconnect query upserts (never removing absent rows), so a cold start would re-seed
|
|
642
|
+
* the ghosts. Fire-and-forget, no-op without offline support.
|
|
368
643
|
*/
|
|
369
644
|
private purgeReconciledFromOfflineDb;
|
|
370
645
|
protected resolveUnreadBoundaryIdsByTimestamp: ({ lastReadAt, messages, }: {
|
|
371
|
-
lastReadAt:
|
|
646
|
+
lastReadAt: TimestampNS;
|
|
372
647
|
messages: LocalMessage[];
|
|
373
648
|
}) => {
|
|
374
649
|
firstUnreadMessageId: string | null;
|
|
@@ -380,10 +655,9 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
|
|
|
380
655
|
ttlMs?: number;
|
|
381
656
|
}) => MessageFocusSignal;
|
|
382
657
|
/**
|
|
383
|
-
* Starts the auto-
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* signal has already been cleared or superseded (guarded by `token`).
|
|
658
|
+
* Starts the auto-dismiss countdown for the active focus signal. Call it once the focused message
|
|
659
|
+
* is viewed, so the highlight lasts from when the user could see it. No-op if the signal was
|
|
660
|
+
* cleared or superseded (guarded by `token`).
|
|
387
661
|
*/
|
|
388
662
|
scheduleMessageFocusSignalClear: ({ token, ttlMs, }?: {
|
|
389
663
|
token?: number;
|
|
@@ -394,92 +668,60 @@ export declare class MessageIntervalPaginator extends BasePaginator<LocalMessage
|
|
|
394
668
|
}) => void;
|
|
395
669
|
clearStateAndCache(): void;
|
|
396
670
|
/**
|
|
397
|
-
* Partial truncation for `channel.truncated`
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
671
|
+
* Partial truncation for `channel.truncated` with a `truncated_at`: drops every loaded message
|
|
672
|
+
* strictly older than the cutoff across all intervals (a full truncation uses
|
|
673
|
+
* {@link MessageIntervalPaginator.clearStateAndCache}). Only the interval straddling the cutoff is
|
|
674
|
+
* scanned member by member and becomes the new global tail; intervals entirely newer keep their
|
|
675
|
+
* flags, since unloaded older messages may sit between them and the cutoff. The active interval is
|
|
676
|
+
* re-emitted once.
|
|
677
|
+
*/
|
|
678
|
+
truncate({ truncatedAt }: {
|
|
679
|
+
truncatedAt: TimestampNS;
|
|
680
|
+
}): void;
|
|
681
|
+
/**
|
|
682
|
+
* Deletes `userId`'s loaded messages (removes them on a hard delete) and marks the quotes of them
|
|
683
|
+
* as deleted. Returns the messages it deleted, as they were before.
|
|
408
684
|
*/
|
|
409
|
-
truncate: ({ truncatedAt }: {
|
|
410
|
-
truncatedAt: number;
|
|
411
|
-
}) => void;
|
|
412
685
|
applyMessageDeletionForUser: ({ userId, hardDelete, deletedAt, }: {
|
|
413
686
|
userId: string;
|
|
414
687
|
hardDelete?: boolean;
|
|
415
|
-
deletedAt:
|
|
416
|
-
}) =>
|
|
688
|
+
deletedAt: TimestampNS;
|
|
689
|
+
}) => LocalMessage[];
|
|
690
|
+
/** Updates the quoted-message snapshot of every cached message that quotes `message`. */
|
|
691
|
+
reflectQuotedMessageUpdate: (message: LocalMessage) => void;
|
|
417
692
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
* Scans cached messages and updates any item where `quoted_message_id`
|
|
422
|
-
* matches `message.id`.
|
|
693
|
+
* Reflects an updated `user` onto every cached message authored by that user (not
|
|
694
|
+
* `quoted_message.user`). Patches the shared item index in one batch and re-emits the active
|
|
695
|
+
* interval once, if it held an affected message.
|
|
423
696
|
*/
|
|
424
|
-
|
|
697
|
+
reflectUserUpdate(user: UserResponse): void;
|
|
425
698
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
*
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
*/
|
|
434
|
-
reflectUserUpdate: (user: UserResponse) => void;
|
|
435
|
-
/**
|
|
436
|
-
* Apply a reaction WS event (`reaction.new` / `reaction.updated` / `reaction.deleted`) to the
|
|
437
|
-
* cached message. The event's `message` already carries the server-updated
|
|
438
|
-
* `reaction_groups` / `latest_reactions`; only `own_reactions` needs local preservation so a
|
|
439
|
-
* cross-user reaction does not wipe the current user's reactions. This re-homes what
|
|
440
|
-
* `ChannelState.addReaction` / `removeReaction` used to do off the now-removed
|
|
441
|
-
* `channel.state.messages` / `channel.state.threads` caches (the same logic backs the thread
|
|
442
|
-
* paginator via `Thread.messagePaginator`).
|
|
443
|
-
*
|
|
444
|
-
* `own_reactions` is seeded from the currently cached item (so another user's reaction keeps ours),
|
|
445
|
-
* falling back to the event's own_reactions when the message is not loaded — matching the legacy
|
|
446
|
-
* behavior where `_updateMessage` only mutated a message that existed locally.
|
|
447
|
-
*
|
|
448
|
-
* @param params - The reaction event payload.
|
|
449
|
-
* @param params.message - The reaction event's message, carrying the
|
|
450
|
-
* server-computed `reaction_groups` / `latest_reactions`. Ingested as-is except for `own_reactions`.
|
|
451
|
-
* @param params.reaction - The reaction from the event. Only added to/removed from
|
|
452
|
-
* `own_reactions` when its `user_id` is the current user; otherwise the current user's
|
|
453
|
-
* `own_reactions` are left untouched.
|
|
454
|
-
* @param [params.removed=false] - `true` for `reaction.deleted` (remove the reaction from
|
|
455
|
-
* `own_reactions`); `false` for `reaction.new` / `reaction.updated` (add it).
|
|
456
|
-
* @param [params.enforceUnique=false] - When adding, first clear the current user's existing
|
|
457
|
-
* `own_reactions` so only the incoming one remains (used by `reaction.updated`, where a user's
|
|
458
|
-
* reaction replaces their previous one).
|
|
459
|
-
*
|
|
460
|
-
* TODO(reactive-store): reflect reactions ONCE at the store level, not per-paginator. Both the
|
|
461
|
-
* channel handler (channel.ts) and the thread handler (thread.ts) call this on every reaction.*
|
|
462
|
-
* event, so a message held in more than one collection (a show_in_channel reply, or the thread
|
|
463
|
-
* parent) is reflected TWICE: two writes to the same canonical slot, each fanning out to the
|
|
464
|
-
* other holder (double re-projection) and minting a fresh ref that defeats the reconcile
|
|
465
|
-
* ref-equality bail. Idempotent (counts come wholesale from the event) so the result is correct,
|
|
466
|
-
* just wasteful. The store already fans out to every holder, so reflect once (by id, if held) and
|
|
467
|
-
* retire the per-collection reflect calls + parent path + enforce_unique branch.
|
|
468
|
-
*/
|
|
469
|
-
reflectReaction: ({ enforceUnique, message, reaction, removed, }: {
|
|
470
|
-
message: MessageResponse | LocalMessage;
|
|
471
|
-
reaction: ReactionResponse;
|
|
472
|
-
enforceUnique?: boolean;
|
|
473
|
-
removed?: boolean;
|
|
474
|
-
}) => void;
|
|
699
|
+
* The last loaded message created at or before `timestamp` (a floor), or `null` when it precedes
|
|
700
|
+
* every loaded message. With `exactTsMatch`, only a message created exactly at `timestamp` matches.
|
|
701
|
+
* Searches the loaded intervals from the head down (each already sorted, O(log n) per interval):
|
|
702
|
+
* the first holding a message at or before `timestamp` holds the answer. Used by the receipts
|
|
703
|
+
* tracker to resolve read/delivered cursors.
|
|
704
|
+
*/
|
|
705
|
+
findItemByTimestamp: (timestamp: TimestampNS, exactTsMatch?: boolean) => LocalMessage | null;
|
|
475
706
|
/**
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
* lower-bound search), or the newest loaded message when the timestamp is beyond it. Used by the
|
|
479
|
-
* receipts tracker to resolve read/delivered cursors. Searches the newest loaded window — where
|
|
480
|
-
* read cursors live — which is already sorted, so this is O(log n) with no re-sort.
|
|
707
|
+
* {@link findItemByTimestamp} within one interval (`items` ascending by `created_at`). `undefined`
|
|
708
|
+
* when every item is newer than `timestamp`, so an older interval has to be searched.
|
|
481
709
|
*/
|
|
482
|
-
|
|
483
|
-
filterQueryResults
|
|
710
|
+
private findItemByTimestampIn;
|
|
711
|
+
filterQueryResults(items: LocalMessage[]): LocalMessage[];
|
|
712
|
+
/**
|
|
713
|
+
* The sort of a replies request. A page newer than a cursor (`id_gt`, `created_at_after`, ...)
|
|
714
|
+
* must hold the replies right after the cursor, so it is requested oldest first: newest first
|
|
715
|
+
* returns the newest replies and skips the ones in between. The page is put in item order
|
|
716
|
+
* afterwards, so the request sort only decides which replies the page holds.
|
|
717
|
+
*/
|
|
718
|
+
private getRepliesRequestSort;
|
|
484
719
|
private getCanonicalQueryItems;
|
|
720
|
+
/**
|
|
721
|
+
* The cursor and more-messages flags after a page is placed (`deriveCursor`). A page around a
|
|
722
|
+
* point counts the messages the server returned on each side of it. Any other page is compared
|
|
723
|
+
* with the interval's outermost server-known messages (see {@link getServerKnownEdges}): a page
|
|
724
|
+
* never holds an unsent message, so one at an edge must not hide that the page reached the edge.
|
|
725
|
+
*/
|
|
726
|
+
private deriveCursorFromPage;
|
|
485
727
|
}
|