stream-chat 10.0.0-rc.21 → 10.0.0-rc.23
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/dist/cjs/index.browser.js +2196 -3902
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +2197 -3902
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +2199 -3905
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +120 -233
- package/dist/types/CooldownTimer.d.ts +8 -23
- package/dist/types/EventHandlerPipeline.d.ts +17 -37
- package/dist/types/LiveLocationManager.d.ts +22 -50
- package/dist/types/api-client.d.ts +9 -14
- package/dist/types/channel.d.ts +253 -448
- package/dist/types/channel_state.d.ts +48 -95
- package/dist/types/client.d.ts +245 -370
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +30 -124
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
- 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 +59 -87
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
- 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 +18 -40
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
- package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
- package/dist/types/connection/networkConnection/types.d.ts +12 -27
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
- package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
- package/dist/types/connection/wsConnection/config.d.ts +8 -28
- package/dist/types/connection/wsConnection/types.d.ts +17 -70
- package/dist/types/entityStore/EntityStore.d.ts +153 -113
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
- package/dist/types/errors.d.ts +7 -19
- package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
- package/dist/types/gen/chat/ChatApi.d.ts +28 -14
- package/dist/types/gen/models/index.d.ts +769 -86
- package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/types/languageNames.d.ts +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
- package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
- package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +29 -56
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
- package/dist/types/messageComposer/messageComposer.d.ts +30 -164
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
- 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/commands.d.ts +9 -0
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -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 +8 -4
- package/dist/types/messageComposer/textComposer.d.ts +3 -9
- package/dist/types/messageComposer/types.d.ts +5 -8
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
- package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
- package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
- package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
- package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
- package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
- package/dist/types/messageOperations/types.d.ts +15 -30
- package/dist/types/middleware.d.ts +7 -5
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +8 -31
- package/dist/types/notifications/types.d.ts +19 -59
- package/dist/types/offline-support/offline_support_api.d.ts +145 -539
- package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
- package/dist/types/offline-support/queueableOperations.d.ts +24 -52
- package/dist/types/offline-support/types.d.ts +24 -187
- 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 +2 -4
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
- 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 +14 -14
- package/dist/types/poll_manager.d.ts +11 -2
- package/dist/types/poll_optimistic_votes.d.ts +10 -14
- package/dist/types/reminders/Reminder.d.ts +4 -4
- package/dist/types/reminders/ReminderManager.d.ts +7 -20
- package/dist/types/search/BaseSearchSource.d.ts +7 -12
- package/dist/types/search/ChannelSearchSource.d.ts +7 -7
- package/dist/types/search/MessageSearchSource.d.ts +7 -9
- package/dist/types/search/SearchController.d.ts +17 -22
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +23 -71
- package/dist/types/thread_manager.d.ts +45 -70
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +64 -125
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +17 -45
- package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
- package/dist/types/utils/WithSubscriptions.d.ts +5 -15
- package/dist/types/utils/concurrency.d.ts +11 -19
- 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 +24 -64
- package/dist/types/utils.d.ts +40 -86
- package/package.json +7 -2
- package/src/ChannelManager.ts +159 -300
- package/src/CooldownTimer.ts +11 -29
- package/src/EventHandlerPipeline.ts +21 -44
- package/src/LiveLocationManager.ts +35 -74
- package/src/api-client.ts +43 -61
- package/src/campaign.ts +1 -1
- package/src/channel.ts +396 -749
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +50 -105
- package/src/client.ts +360 -588
- package/src/client_state.ts +1 -6
- package/src/configuration/ConfigController.ts +41 -157
- package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +67 -70
- package/src/configuration/types.ts +60 -100
- package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
- 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 +20 -49
- package/src/connection/ConnectionRecoveryManager.ts +51 -178
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
- package/src/connection/networkConnection/reporters.ts +9 -36
- package/src/connection/networkConnection/types.ts +12 -27
- package/src/connection/wsConnection/StableWSConnection.ts +73 -193
- package/src/connection/wsConnection/WSConnection.ts +56 -131
- package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
- package/src/connection/wsConnection/config.ts +13 -48
- package/src/connection/wsConnection/types.ts +17 -70
- package/src/constants.ts +4 -4
- package/src/entityStore/EntityStore.ts +162 -167
- package/src/entityStore/StoreBackedItemIndex.ts +14 -47
- package/src/errors.ts +7 -19
- package/src/formatMessageMemo.ts +3 -9
- package/src/gen/chat/ChannelApi.ts +19 -0
- package/src/gen/chat/ChatApi.ts +87 -13
- package/src/gen/models/index.ts +793 -71
- package/src/gen/moderation/ModerationApi.ts +0 -4
- package/src/index.ts +10 -14
- package/src/languageNames.ts +9 -24
- package/src/logger.ts +1 -3
- package/src/messageComposer/LocationComposer.ts +7 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +2 -13
- package/src/messageComposer/attachmentManager.ts +17 -63
- package/src/messageComposer/attachmentUtils.ts +3 -17
- package/src/messageComposer/configuration/configuration.ts +5 -8
- package/src/messageComposer/configuration/types.ts +29 -56
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/linkPreviewsManager.ts +8 -20
- package/src/messageComposer/messageComposer.ts +54 -222
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
- 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 +1 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
- 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 +11 -8
- package/src/messageComposer/textComposer.ts +9 -59
- package/src/messageComposer/types.ts +9 -12
- package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
- package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
- package/src/messageOperations/FailedSendCache.ts +4 -9
- package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
- package/src/messageOperations/MessageOperations.ts +33 -62
- package/src/messageOperations/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +17 -33
- package/src/messageOperations/reflectReactionEvent.ts +5 -13
- package/src/messageOperations/sendOrdering.ts +4 -7
- package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
- package/src/messageOperations/types.ts +15 -30
- package/src/middleware.ts +7 -10
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +11 -35
- package/src/notifications/types.ts +19 -59
- package/src/offline-support/offline_support_api.ts +178 -608
- package/src/offline-support/offline_sync_manager.ts +25 -69
- package/src/offline-support/queueableOperations.ts +31 -84
- package/src/offline-support/types.ts +25 -188
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/paginators/BasePaginator.ts +422 -976
- package/src/pagination/paginators/ChannelPaginator.ts +130 -190
- package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
- package/src/pagination/paginators/MessagePaginator.ts +135 -175
- package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
- package/src/pagination/paginators/ReminderPaginator.ts +12 -15
- package/src/pagination/paginators/ThreadPaginator.ts +16 -26
- package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
- 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 +19 -19
- package/src/poll_manager.ts +16 -20
- package/src/poll_optimistic_votes.ts +17 -22
- package/src/reminders/Reminder.ts +5 -6
- package/src/reminders/ReminderManager.ts +9 -34
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +14 -29
- package/src/search/ChannelSearchSource.ts +8 -8
- package/src/search/MessageSearchSource.ts +19 -25
- package/src/search/SearchController.ts +18 -24
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +72 -173
- package/src/thread_manager.ts +59 -76
- package/src/token_manager.ts +11 -21
- package/src/types.ts +78 -126
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +22 -54
- package/src/utils/FixedSizeQueueCache.ts +13 -21
- package/src/utils/WithSubscriptions.ts +5 -15
- 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 +26 -66
- package/src/utils.ts +72 -128
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
import type { BasePaginatorConfig, ExecuteQueryReturnValue, Interval, PostQueryReconcileParams } from './BasePaginator';
|
|
2
2
|
import { type MessagePaginatorOptions as BaseMessagePaginatorOptions, type JumpToMessageOptions, MessageIntervalPaginator, type MessageQueryShape } from './MessageIntervalPaginator';
|
|
3
|
-
import type { LocalMessage, TimestampNS } from '../../types';
|
|
3
|
+
import type { LocalMessage, TimestampNS, UserResponse } from '../../types';
|
|
4
|
+
import type { EntityStoreChangeBatch } from '../../entityStore/EntityStore';
|
|
4
5
|
import { StateStore } from '@stream-io/state-store';
|
|
5
6
|
export type { JumpToMessageOptions, MergeNewestPageOptions, MessageFocusReason, MessageFocusSignal, MessageFocusSignalState, MessagePaginatorFilter, MessagePaginatorSort, MessagePaginatorState, MessageQueryShape, SeedFirstPageOptions, } from './MessageIntervalPaginator';
|
|
6
7
|
export { MessageIntervalPaginator } from './MessageIntervalPaginator';
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* not a page of it). `lastMessageAt` is effectively `MAX(created_at)` over the channel-relevant
|
|
11
|
-
* messages and is the source of truth for channel-list ordering
|
|
9
|
+
* Whole-collection aggregates, independent of the active pagination window. `lastMessageAt` is the
|
|
10
|
+
* max `created_at` over the channel-relevant messages and orders the channel list
|
|
12
11
|
* (`channel.messagePaginator.lastMessageAt`): seeded from `ChannelResponse.last_message_at`, then
|
|
13
12
|
* advanced monotonically as newer messages are ingested.
|
|
14
13
|
*/
|
|
15
14
|
export type MessagePaginatorAggregateState = {
|
|
16
15
|
/**
|
|
17
|
-
* The newest channel-relevant message, for display (
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
16
|
+
* The newest channel-relevant message, for display (last-message preview, latest-reply avatar). A
|
|
17
|
+
* live reference: it advances to a strictly newer message, is refreshed in place on edit,
|
|
18
|
+
* soft-delete or reaction, and is recomputed when hard-removed. Follows `shouldAdvanceLastMessage`
|
|
19
|
+
* (skips system messages per `skip_last_msg_update_for_system_msgs`, and thread-only replies).
|
|
20
|
+
* `null` until one is ingested.
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
* the head interval while an older window is active
|
|
25
|
-
* active* interval is impacted (see `BasePaginator.ingestItem`), so a `state`-derived latest would
|
|
26
|
-
* go stale in that case.
|
|
22
|
+
* It lives outside pagination `state`, which only emits when the active interval is affected: a
|
|
23
|
+
* message landing in the head interval while an older window is active would go stale there.
|
|
27
24
|
*/
|
|
28
25
|
lastMessage: LocalMessage | null;
|
|
29
26
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* never drift out of sync.
|
|
27
|
+
* `ChannelResponse.last_message_at` floor, for channels whose newest message is not loaded. Kept
|
|
28
|
+
* apart from {@link lastMessage} so it can outrank a stale or absent loaded message for sorting
|
|
29
|
+
* without replacing the display message. {@link MessagePaginator.lastMessageAt} is the max of
|
|
30
|
+
* the two.
|
|
35
31
|
*/
|
|
36
32
|
seededLastMessageAt: TimestampNS | null;
|
|
37
33
|
};
|
|
38
34
|
export type MessagePaginatorOptions = BaseMessagePaginatorOptions & {
|
|
39
35
|
/**
|
|
40
|
-
*
|
|
41
|
-
* state
|
|
42
|
-
*
|
|
43
|
-
* - 'snapshot' (default): retrieve the first unread message id from the unreadStateSnapshot state when jumping to the first unread message
|
|
44
|
-
* - 'read-state-only': retrieve the last read message id from the channel read state when jumping to the first unread message
|
|
36
|
+
* Where `jumpToTheFirstUnreadMessage()` reads the unread reference from: `'snapshot'`
|
|
37
|
+
* prefers `unreadStateSnapshot`, `'read-state-only'` uses only `channel.state.read[...]`.
|
|
38
|
+
* Defaults to `'snapshot'`.
|
|
45
39
|
*/
|
|
46
40
|
unreadReferencePolicy?: 'snapshot' | 'read-state-only';
|
|
47
41
|
};
|
|
@@ -49,160 +43,117 @@ export type UnreadSnapshotState = {
|
|
|
49
43
|
lastReadAt: TimestampNS | null;
|
|
50
44
|
unreadCount: number;
|
|
51
45
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* may mark the channel read immediately on open, while still wanting to render
|
|
55
|
-
* UI indicators that jump to the previously-unread location.
|
|
46
|
+
* First unread message ID. Decoupled from `channel.state.read[...]` because apps may mark the
|
|
47
|
+
* channel read on open yet still want UI that jumps to the previously unread location.
|
|
56
48
|
*/
|
|
57
49
|
firstUnreadMessageId: string | null;
|
|
58
|
-
/**
|
|
59
|
-
* Snapshot of the last read message id for the user (fallback when first unread
|
|
60
|
-
* is not known).
|
|
61
|
-
*/
|
|
50
|
+
/** Last read message ID, a fallback when the first unread is unknown. */
|
|
62
51
|
lastReadMessageId: string | null;
|
|
63
52
|
};
|
|
64
53
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* snapshot bump is skipped), so the "N new" separator/banner never flash for a message the user is
|
|
69
|
-
* already looking at. Defaults to `false` (assume not viewing until the SDK proves otherwise).
|
|
54
|
+
* Set by the owning SDK (the state layer has no viewport): `true` while the user views the latest
|
|
55
|
+
* messages (app foregrounded and newest message on screen). While live, an incoming message does
|
|
56
|
+
* not bump the unread count or snapshot. Defaults to `false`.
|
|
70
57
|
*/
|
|
71
58
|
export type LiveViewState = {
|
|
72
59
|
isViewingLive: boolean;
|
|
73
60
|
};
|
|
74
61
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* the "jump to first unread" navigation built on top of them.
|
|
62
|
+
* Adds the unread snapshot, the UI-driven live-view signal and "jump to first unread" navigation to
|
|
63
|
+
* {@link MessageIntervalPaginator}.
|
|
78
64
|
*/
|
|
79
65
|
export declare class MessagePaginator extends MessageIntervalPaginator {
|
|
80
66
|
protected get holderName(): string;
|
|
81
67
|
private unreadReferencePolicy;
|
|
82
68
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
69
|
+
* Unread reference state, independent of `channel.state.read`. Seeded on each first page;
|
|
70
|
+
* consumers may also set it before `markRead`.
|
|
85
71
|
*/
|
|
86
72
|
readonly unreadStateSnapshot: StateStore<UnreadSnapshotState>;
|
|
87
73
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* this store for reactivity, or read the current boolean directly via the {@link isViewingLive} getter.
|
|
74
|
+
* The "viewing the latest messages" signal ({@link LiveViewState}), set via {@link setViewingLive}
|
|
75
|
+
* and read by the channel to gate the unread bump on `message.new`.
|
|
91
76
|
*/
|
|
92
77
|
readonly liveViewState: StateStore<LiveViewState>;
|
|
93
78
|
/**
|
|
94
|
-
*
|
|
95
|
-
* from `state`
|
|
96
|
-
*
|
|
97
|
-
* emits when the aggregate actually changes (not on every scroll/pagination emission). This is
|
|
98
|
-
* distinct from the base's `intervalViews` interval-projection store.
|
|
79
|
+
* {@link MessagePaginatorAggregateState}, in a store apart from `state` so `lastMessageAt` can
|
|
80
|
+
* advance from inside a `state.next` updater (`ingestPage`) and subscribers only see aggregate
|
|
81
|
+
* changes.
|
|
99
82
|
*/
|
|
100
83
|
readonly aggregateState: StateStore<MessagePaginatorAggregateState>;
|
|
101
84
|
constructor({ unreadReferencePolicy, ...options }: MessagePaginatorOptions, builtInDefaults?: Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>);
|
|
102
85
|
/**
|
|
103
86
|
* Channel-list sort key: the later of the newest loaded message's `created_at` and the server seed.
|
|
104
|
-
*
|
|
105
|
-
* message is ingested.
|
|
87
|
+
* Derived, so it cannot drift from {@link lastMessage}. `null` until seeded or a message arrives.
|
|
106
88
|
*/
|
|
107
89
|
get lastMessageAt(): TimestampNS | null;
|
|
108
90
|
/**
|
|
109
|
-
* The newest channel-relevant message (
|
|
110
|
-
*
|
|
111
|
-
* ingested (a server-only seed advances {@link lastMessageAt} but leaves this `null`).
|
|
91
|
+
* The tracked newest channel-relevant message ({@link aggregateState}), for display. `null` until
|
|
92
|
+
* one is ingested (a server-only seed advances {@link lastMessageAt} but not this).
|
|
112
93
|
*/
|
|
113
94
|
get lastMessage(): LocalMessage | null;
|
|
114
95
|
/**
|
|
115
|
-
*
|
|
116
|
-
* the
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* `Channel._trackLastMessage` skip logic.
|
|
120
|
-
*
|
|
121
|
-
* These exclusions are specific to the MAIN channel list. A reply list (thread paginator, which has
|
|
122
|
-
* a `parentMessageId`) is made ENTIRELY of thread replies — there the newest reply is exactly the
|
|
123
|
-
* "latest message", so the exclusions are skipped and only the base rule applies.
|
|
96
|
+
* Whether `message` may become the "latest message" behind `channel.state.last_message_at`: not
|
|
97
|
+
* shadowed and, in the main list, not a thread-only reply nor (with
|
|
98
|
+
* `skip_last_msg_update_for_system_msgs`) a system message. A reply list (`parentMessageId` set)
|
|
99
|
+
* holds only thread replies, so only the shadow rule applies there.
|
|
124
100
|
*/
|
|
125
101
|
protected shouldAdvanceLastMessage(message: LocalMessage): boolean;
|
|
126
102
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* Called internally on ingest; also public for callers that advance the aggregate without a normal
|
|
133
|
-
* in-window ingest — e.g. offline pending-message replay, where the sent message has not yet been
|
|
134
|
-
* ingested via the `message.new` event.
|
|
103
|
+
* Advances the tracked latest message (and so {@link lastMessageAt}) to `message` when it is newer
|
|
104
|
+
* and {@link shouldAdvanceLastMessage} permits. Writes {@link aggregateState} only, so it is safe
|
|
105
|
+
* inside a `state.next` updater (`ingestPage`). Returns `true` when the value moved. Public for
|
|
106
|
+
* callers that advance it without an in-window ingest, e.g. offline pending-message replay.
|
|
135
107
|
*/
|
|
136
108
|
trackLastMessage(message: LocalMessage): boolean;
|
|
137
109
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* past it (e.g. from ingested messages), so seed order does not matter.
|
|
110
|
+
* Seeds {@link lastMessageAt} from `ChannelResponse.last_message_at`. Monotonic: a value not newer
|
|
111
|
+
* than the current seed is ignored, so seed order does not matter.
|
|
141
112
|
*/
|
|
142
113
|
seedLastMessageAt(value: TimestampNS | null | undefined): void;
|
|
143
114
|
ingestItem(item: LocalMessage): boolean;
|
|
144
115
|
ingestPage(params: Parameters<MessageIntervalPaginator['ingestPage']>[0]): Interval | null;
|
|
116
|
+
onEntitiesChanged(batch: EntityStoreChangeBatch): void;
|
|
117
|
+
reflectUserUpdate(user: UserResponse): void;
|
|
145
118
|
removeItem(params: Parameters<MessageIntervalPaginator['removeItem']>[0]): ReturnType<MessageIntervalPaginator['removeItem']>;
|
|
119
|
+
truncate(params: Parameters<MessageIntervalPaginator['truncate']>[0]): void;
|
|
146
120
|
/**
|
|
147
|
-
* The
|
|
148
|
-
* {@link shouldAdvanceLastMessage}
|
|
149
|
-
*
|
|
150
|
-
* loaded qualifies.
|
|
151
|
-
*
|
|
152
|
-
* "Latest" is defined by `created_at` (matching {@link trackLastMessage}), NOT by the paginator's
|
|
153
|
-
* display order — so this compares timestamps rather than assuming a position, and stays correct
|
|
154
|
-
* whatever `itemOrder` / `requestSort` are configured to.
|
|
121
|
+
* The message in `headItems` with the greatest `created_at` that passes
|
|
122
|
+
* {@link shouldAdvanceLastMessage}, or `null`. It compares timestamps rather than positions, so it
|
|
123
|
+
* holds for any `itemOrder` / `requestSort`.
|
|
155
124
|
*/
|
|
156
125
|
private recomputeLastMessage;
|
|
157
126
|
/**
|
|
158
|
-
* (Re)
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* (re)opened from a cached paginator — where no fresh first-page query runs — so the snapshot
|
|
162
|
-
* reflects the CURRENT read boundary rather than one frozen at the very first open. Without a
|
|
163
|
-
* re-seed the separator position, unread count and "jump to first unread" target all go stale
|
|
164
|
-
* across reopens.
|
|
127
|
+
* (Re)seeds the unread snapshot from the own read state. Runs after the first-page query, and the
|
|
128
|
+
* SDK calls it again when a channel is reopened from a cached paginator (no first-page query), so
|
|
129
|
+
* the separator, unread count and jump target follow the current read boundary.
|
|
165
130
|
*
|
|
166
|
-
* `firstUnreadMessageId` is
|
|
167
|
-
* (
|
|
168
|
-
* here would make the channel look explicitly marked-unread and suppress auto-mark-read.
|
|
131
|
+
* `firstUnreadMessageId` is reset to `null`: it holds only an explicit mark-unread
|
|
132
|
+
* (`notification.mark_unread`), and a computed value would suppress auto-mark-read.
|
|
169
133
|
*/
|
|
170
134
|
seedUnreadSnapshot: () => void;
|
|
171
|
-
/**
|
|
172
|
-
* Invokes super.postQueryReconcile() and takes an unread state snapshot on the first-page query.
|
|
173
|
-
* The snapshot has to be taken immediately after the query as the viewed channel is marked read
|
|
174
|
-
* immediately after opening it. The snapshot can be used to display unread UI indicators.
|
|
175
|
-
*/
|
|
135
|
+
/** Also seeds the unread snapshot on a first page, before the opened channel is marked read. */
|
|
176
136
|
postQueryReconcile(params: PostQueryReconcileParams<LocalMessage, MessageQueryShape>): ExecuteQueryReturnValue<LocalMessage>;
|
|
177
137
|
/**
|
|
178
|
-
* Jumps to the unread reference message.
|
|
179
|
-
*
|
|
180
|
-
* IMPORTANT: This intentionally does *not* rely on `channel.state.read[ownUserId]` only,
|
|
181
|
-
* because apps may mark a channel read immediately after opening it, while still
|
|
182
|
-
* wanting to keep "jump to unread" UI indicators alive (based on a snapshot).
|
|
138
|
+
* Jumps to the unread reference message. It does not rely on `channel.state.read` alone, since
|
|
139
|
+
* apps may mark a channel read on open yet keep "jump to unread" UI alive from the snapshot.
|
|
183
140
|
*
|
|
184
141
|
* Resolution order:
|
|
185
|
-
* 1
|
|
186
|
-
* 2
|
|
187
|
-
*
|
|
188
|
-
* 3
|
|
142
|
+
* 1. an explicit first-unread ID (snapshot or read state): jump to it;
|
|
143
|
+
* 2. the last-read timestamp: infer the first unread message from the loaded window, or from a
|
|
144
|
+
* `created_at_around` query when the window does not straddle the boundary, and jump to it;
|
|
145
|
+
* 3. the last-read ID, when no timestamp is known.
|
|
189
146
|
*
|
|
190
|
-
* The
|
|
191
|
-
*
|
|
192
|
-
* only used as a fallback when we cannot infer an unread boundary. The inference is NOT persisted
|
|
193
|
-
* back into the snapshot (that is reserved for explicit mark-unread).
|
|
147
|
+
* The inference is not written to the snapshot: `firstUnreadMessageId` is reserved for an explicit
|
|
148
|
+
* mark-unread (it would suppress auto-mark-read).
|
|
194
149
|
*/
|
|
195
150
|
jumpToTheFirstUnreadMessage: (options?: JumpToMessageOptions) => Promise<boolean>;
|
|
196
151
|
setUnreadSnapshot: (next: Partial<UnreadSnapshotState>) => UnreadSnapshotState;
|
|
152
|
+
get isViewingLive(): boolean;
|
|
197
153
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* Intentionally NOT reset by `clearStateAndCache` — it is an external input owned by the SDK, not
|
|
202
|
-
* derived pagination state.
|
|
154
|
+
* Sets the live-view signal ({@link LiveViewState}). Not reset by `clearStateAndCache`: it is an
|
|
155
|
+
* external input owned by the SDK.
|
|
203
156
|
*/
|
|
204
|
-
/** Current "viewing the latest messages" boolean (convenience read of {@link liveViewState}). */
|
|
205
|
-
get isViewingLive(): boolean;
|
|
206
157
|
setViewingLive: (isViewingLive: boolean) => void;
|
|
207
158
|
clearUnreadSnapshot: () => void;
|
|
208
159
|
clearStateAndCache(): void;
|
|
@@ -14,40 +14,21 @@ export type PinnedMessagePaginatorOptions = {
|
|
|
14
14
|
paginatorOptions?: PaginatorOptions<LocalMessage, MessageQueryShape>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The channel's pinned messages, ordered by `pinned_at` ascending (oldest-pinned first). Extends
|
|
18
|
+
* {@link MessageIntervalPaginator} rather than {@link MessagePaginator}: pinned messages are a subset
|
|
19
|
+
* of the channel and take no part in read/unread or delivery-receipt tracking.
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* the channel and thread message timelines). By extending the base rather than {@link MessagePaginator}
|
|
22
|
-
* it simply never gets the unread surface.
|
|
23
|
-
*
|
|
24
|
-
* Differences from the main list:
|
|
25
|
-
* - fetches from the `/pinned_messages` endpoint (`channel.getPinnedMessages`) rather than
|
|
26
|
-
* `channel.query({ messages })`;
|
|
27
|
-
* - includes only pinned, non-shadowed messages (`shouldIncludeMessageInInterval`), and filters on
|
|
28
|
-
* `{ cid, pinned: true }` so `ingestItem` auto-adds on pin and auto-removes on unpin;
|
|
29
|
-
* - orders by `pinned_at` ascending (oldest-pinned first), matching the legacy
|
|
30
|
-
* `channel.state.pinnedMessages` order.
|
|
31
|
-
*
|
|
32
|
-
* Navigation (`jumpToMessage` / `jumpToTheLatestMessage`) is inherited and meaningful — the endpoint
|
|
33
|
-
* supports `id_around` — but no unread-coupled navigation exists.
|
|
21
|
+
* Fetches through `channel.getPinnedMessages`, includes only pinned, non-shadowed messages and
|
|
22
|
+
* matches `{ cid, pinned: true }`, so `ingestItem` adds on pin and removes on unpin.
|
|
34
23
|
*/
|
|
35
24
|
export declare class PinnedMessagePaginator extends MessageIntervalPaginator {
|
|
36
25
|
protected get holderName(): string;
|
|
37
26
|
constructor({ channel, id, itemIndex, paginatorOptions, }: PinnedMessagePaginatorOptions);
|
|
38
|
-
/**
|
|
39
|
-
* Memoized for the reason {@link MessageIntervalPaginator}'s overlay is: the base derivation folds
|
|
40
|
-
* this in and skips the publish when nothing moved, which needs stable references. Both close over
|
|
41
|
-
* `this` and over a fixed `pinned_at` sort, so there is nothing to rebuild.
|
|
42
|
-
*/
|
|
27
|
+
/** Memoized: stable references let the base derivation skip a publish when nothing moved. */
|
|
43
28
|
private pinnedBehaviour?;
|
|
44
29
|
private buildPinnedBehaviour;
|
|
45
30
|
private pinnedTiebreaker;
|
|
46
|
-
/**
|
|
47
|
-
* The ordering and request behaviour that makes this a *pinned*-message paginator, contributed to the
|
|
48
|
-
* base derivation so a re-derivation cannot drop it and does not need a second write to restore it.
|
|
49
|
-
* Spread over the interval overlay, so this class's `pinned_at` comparator wins.
|
|
50
|
-
*/
|
|
31
|
+
/** Adds the pinned ordering and request behaviour to the derivation, over the interval overlay. */
|
|
51
32
|
protected getBehaviourOverrides(): Partial<BasePaginatorConfig<LocalMessage, MessageQueryShape>>;
|
|
52
33
|
private installPinnedMessageBehaviour;
|
|
53
34
|
buildMatchFilters: () => PinnedMessagePaginatorFilter;
|
|
@@ -13,7 +13,7 @@ export declare class ReminderPaginator extends BasePaginator<ReminderResponseDat
|
|
|
13
13
|
constructor(client: StreamChat, options?: PaginatorOptions<ReminderResponseData, QueryRemindersRequest>);
|
|
14
14
|
getItemId(item: ReminderResponseData): string;
|
|
15
15
|
private buildSortComparator;
|
|
16
|
-
protected getNextQueryShape(
|
|
17
|
-
query: ({ queryShape, }: PaginationQueryParams<QueryRemindersRequest>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
|
|
16
|
+
protected getNextQueryShape(): QueryRemindersRequest;
|
|
17
|
+
query: ({ direction, queryShape, }: PaginationQueryParams<QueryRemindersRequest>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
|
|
18
18
|
filterQueryResults: (items: ReminderResponseData[]) => ReminderResponseData[];
|
|
19
19
|
}
|
|
@@ -5,53 +5,45 @@ import { EntityStore } from '../../entityStore/EntityStore';
|
|
|
5
5
|
import type { Thread } from '../../thread';
|
|
6
6
|
import type { QueryThreadsRequest } from '../../types';
|
|
7
7
|
export declare const DEFAULT_THREAD_PAGE_SIZE = 25;
|
|
8
|
-
/**
|
|
8
|
+
/** Default query options for every page of the thread list. */
|
|
9
9
|
export declare const DEFAULT_THREAD_QUERY: QueryThreadsRequest;
|
|
10
10
|
export type ThreadPaginatorOptions = {
|
|
11
11
|
client: StreamChat;
|
|
12
|
-
/**
|
|
12
|
+
/** Store holding the list's threads (`client.threads`' thread store). Omitted: a private one. */
|
|
13
13
|
store?: EntityStore<Thread>;
|
|
14
14
|
paginatorOptions?: PaginatorOptions<Thread, QueryThreadsRequest>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* The thread list, in the order `queryThreads` returns it.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* interval storage on every mark-read or reply. Pages append in server order and a reload replaces
|
|
22
|
-
* the list ({@link ThreadPaginator.reload}).
|
|
17
|
+
* The thread list, in the order `queryThreads` returns it. There is no client-side sort: the server
|
|
18
|
+
* order (unread first, then latest reply) depends on state a `Thread` mutates in place, so a
|
|
19
|
+
* comparator would corrupt interval storage. Pages append in server order and
|
|
20
|
+
* {@link ThreadPaginator.reload} replaces the list.
|
|
23
21
|
*/
|
|
24
22
|
export declare class ThreadPaginator extends BasePaginator<Thread, QueryThreadsRequest> {
|
|
25
23
|
private readonly client;
|
|
26
24
|
private readonly store;
|
|
27
25
|
constructor({ client, store, paginatorOptions, }: ThreadPaginatorOptions);
|
|
28
|
-
/**
|
|
29
|
-
* No next page until a load has landed (`master`'s `nextCursor: null`), so `toTail()` is a no-op
|
|
30
|
-
* before the first successful reload, e.g. when an empty list fires `onEndReached` on mount.
|
|
31
|
-
*/
|
|
26
|
+
/** No next page until a load has landed, so `toTail()` is a no-op before the first reload. */
|
|
32
27
|
get initialState(): PaginatorState<Thread>;
|
|
33
28
|
getItemId(thread: Thread): string;
|
|
34
29
|
protected getNextQueryShape({ direction, }: Required<Pick<PaginationQueryParams<QueryThreadsRequest>, 'direction'>>): QueryThreadsRequest;
|
|
35
30
|
query: ({ queryShape, }: PaginationQueryParams<QueryThreadsRequest>) => Promise<PaginationQueryReturnValue<Thread>>;
|
|
36
31
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
32
|
+
* Keeps one instance per ID (the index upserts, so a second one would replace the stored one). A
|
|
33
|
+
* stale stored thread is hydrated from the query unless it is active: it reloads itself, and
|
|
34
|
+
* hydrating would replace the replies on screen.
|
|
40
35
|
*/
|
|
41
36
|
private toStoredInstance;
|
|
42
37
|
filterQueryResults: (threads: Thread[]) => Thread[];
|
|
43
38
|
/**
|
|
44
|
-
* Re-queries the first page and
|
|
45
|
-
* current threads stay until the response lands
|
|
46
|
-
*
|
|
47
|
-
*
|
|
39
|
+
* Re-queries the first page and replaces the list in server order; also the first load. The
|
|
40
|
+
* current threads stay until the response lands. A failed query leaves them and records
|
|
41
|
+
* `lastQueryError`; a success clears it. Only the first load publishes `isLoading` (with items it
|
|
42
|
+
* would mean the next page).
|
|
48
43
|
*/
|
|
49
44
|
reload: ({ limit }?: {
|
|
50
45
|
limit?: number;
|
|
51
46
|
}) => Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Also releases the list's hold on its threads, which the base reset leaves in the index. Released
|
|
54
|
-
* before the base publishes, so a subscriber sees the threads already gone from the registry.
|
|
55
|
-
*/
|
|
47
|
+
/** Also clears the item index (the base reset keeps it), before the base publishes. */
|
|
56
48
|
resetState(): void;
|
|
57
49
|
}
|
|
@@ -3,12 +3,8 @@ import type { PaginationQueryParams, PaginationQueryReturnValue, PaginatorOption
|
|
|
3
3
|
import type { ListUserGroupsOptions, UserGroupResponse } from '../../types';
|
|
4
4
|
import type { StreamChat } from '../../client';
|
|
5
5
|
/**
|
|
6
|
-
* Paginates
|
|
7
|
-
*
|
|
8
|
-
* This entity only supports forward (tailward) cursor pagination via
|
|
9
|
-
* `created_at_gt` and `id_gt`. Backward (headward) pagination is not available
|
|
10
|
-
* because the API does not expose a backward cursor, so the headward cursor is
|
|
11
|
-
* initialized as exhausted (`null`).
|
|
6
|
+
* Paginates `/usergroups` forward (tailward) only, via `created_at_gt` and `id_gt`. The API has no
|
|
7
|
+
* backward cursor, so the headward cursor starts exhausted (`null`).
|
|
12
8
|
*/
|
|
13
9
|
export declare class UserGroupPaginator extends BasePaginator<UserGroupResponse, ListUserGroupsOptions> {
|
|
14
10
|
private client;
|
|
@@ -5,42 +5,31 @@ export type ItemLocation = {
|
|
|
5
5
|
insertionIndex: number;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - a getter `getItemAt(index)` that returns the item (or undefined)
|
|
13
|
-
*
|
|
14
|
-
* It returns:
|
|
15
|
-
* - current: actual index of the item in the array
|
|
16
|
-
* - expected: lower-bound position where the item belongs according to compare function
|
|
8
|
+
* Binary search over an abstract sorted array. Returns the needle's `currentIndex` (`-1` if absent)
|
|
9
|
+
* and the `insertionIndex` where `compare` places it (after items that compare equal). With
|
|
10
|
+
* `plateauScan`, a needle not at the insertion index is looked for by identity, scanning outward
|
|
11
|
+
* from it.
|
|
17
12
|
*/
|
|
18
13
|
export declare function binarySearch<T>({ needle, length, getItemAt, itemIdentityEquals, compare, plateauScan, }: {
|
|
19
|
-
/** Target item in the searched array */
|
|
20
14
|
needle: T;
|
|
21
15
|
length: number;
|
|
22
|
-
/**
|
|
23
|
-
* Therefore, we do not access the array directly but allow to determine, how the item is constructed.
|
|
24
|
-
*/
|
|
16
|
+
/** Reads the item at an index (the array may hold IDs resolved through an index). */
|
|
25
17
|
getItemAt: (index: number) => T | undefined;
|
|
26
|
-
/**
|
|
18
|
+
/** Identity, not equality under the sort order. */
|
|
27
19
|
itemIdentityEquals: (item1: T, item2: T) => boolean;
|
|
28
|
-
/** Used to determine equality from the sort order point of view. */
|
|
29
20
|
compare: Comparator<T>;
|
|
30
21
|
plateauScan?: boolean;
|
|
31
22
|
}): ItemLocation;
|
|
32
23
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* Zero (0) → leave a and b unchanged relative to each other
|
|
36
|
-
* (but they can still move relative to others — sort in JS is not guaranteed stable in older engines, though modern V8/Node/Chrome/Firefox make it stable)
|
|
37
|
-
*
|
|
38
|
-
* Positive number (> 0) → a comes after b
|
|
24
|
+
* Builds a comparator from a sort spec: terms apply in order, then `tiebreaker`.
|
|
25
|
+
* `null`/`undefined` values sort last whatever the direction.
|
|
39
26
|
*
|
|
40
27
|
* @param params - Comparator configuration.
|
|
41
28
|
* @param params.sort - The sort specification defining fields and directions.
|
|
42
29
|
* @param params.resolvePathValue - Resolver used to read a field value from an item.
|
|
43
|
-
* @param params.tiebreaker - Comparator applied when all sort terms are equal.
|
|
30
|
+
* @param params.tiebreaker - Comparator applied when all sort terms are equal. Defaults to
|
|
31
|
+
* comparing `cid`.
|
|
32
|
+
* @returns The comparator.
|
|
44
33
|
*/
|
|
45
34
|
export declare function makeComparator<T>({ sort, resolvePathValue, tiebreaker, }: {
|
|
46
35
|
sort: SortParamRequest[];
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
export declare function asArray(v: any): any[];
|
|
2
2
|
export declare function isISODateString(x: any): x is string;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Nanoseconds rather than milliseconds because the two sides of a comparison come from different
|
|
8
|
-
* places: an item's `created_at` is the wire number, while a filter operand is typed `Date | string`
|
|
9
|
-
* in the generated filter types. Normalizing to ms would have meant halving the pair — a `Date`
|
|
10
|
-
* became ms while a wire number was passed through untouched and *called* ms, so every mixed
|
|
11
|
-
* comparison silently ordered wrong and `normKey` bucketed the two apart.
|
|
12
|
-
*
|
|
13
|
-
* A bare `number` is therefore read as nanoseconds. That is the SDK's unit for a timestamp
|
|
14
|
-
* everywhere else, and it is what a value read off an item will be.
|
|
4
|
+
* Converts a `Date`, ISO string or finite number into unix nanoseconds, the unit item timestamps
|
|
5
|
+
* carry. A bare `number` is read as nanoseconds already. Returns `null` for anything else.
|
|
15
6
|
*/
|
|
16
7
|
export declare function toEpochNanos(x: any): number | null;
|
|
17
8
|
export declare function toNumberLike(x: any): number | null;
|
|
@@ -27,18 +18,9 @@ export declare function normalizeString(s: string): string;
|
|
|
27
18
|
export declare function normalizeStringAccentInsensitive(s: string): string;
|
|
28
19
|
export declare function tokenize(s: string): string[];
|
|
29
20
|
/**
|
|
30
|
-
* Reads `a.b.c` off an item, for the filter and sort compilers.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* instances (a `Reminder`, a `Poll`) — because a filter path legitimately reaches into all three. That is why
|
|
34
|
-
* this is not `getPath` from `src/utils/objectPath.ts`, which deliberately walks plain records only; the two
|
|
35
|
-
* are documented there as non-interchangeable.
|
|
36
|
-
*
|
|
37
|
-
* Stops at `null` / `undefined`, the only values that cannot be indexed. It used to stop at any *falsy*
|
|
38
|
-
* value, which made the result depend on a string's contents rather than on its shape: `name.length`
|
|
39
|
-
* resolved to `2` for `'ab'` and to `undefined` for `''`. A falsy value at the end of a path was never
|
|
40
|
-
* affected — the guard only ever ran against an intermediate — so `{ count: 0 }` on `'count'` has always
|
|
41
|
-
* returned `0`, and sorting and filtering on scalar fields were never wrong.
|
|
21
|
+
* Reads `a.b.c` off an item, for the filter and sort compilers. Descends through anything indexable
|
|
22
|
+
* (plain objects, arrays, class instances such as `Reminder`), unlike `getPath` in
|
|
23
|
+
* `src/utils/objectPath.ts`, which walks plain records only. Stops at `null` / `undefined`.
|
|
42
24
|
*/
|
|
43
25
|
export declare function resolveDotPathValue(obj: any, path: string): unknown;
|
|
44
26
|
export declare function isIterableButNotString(v: unknown): v is Iterable<unknown>;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `true` for the remaining suffix. Returns the first index at which `predicate(index)` holds, or
|
|
6
|
-
* `length` if it never does. O(log length).
|
|
7
|
-
*
|
|
8
|
-
* Unlike `binarySearch`, this locates a *boundary* defined by a predicate rather than a specific
|
|
9
|
-
* item by identity — e.g. "first message at/after a timestamp" over a chronologically sorted array.
|
|
2
|
+
* Lower-bound binary search over `[0, length)`: the first index where `predicate` holds, or `length`.
|
|
3
|
+
* `predicate` must be monotonic (`false` for a prefix, then `true`), e.g. "first item at or
|
|
4
|
+
* after a timestamp" over a sorted array.
|
|
10
5
|
*/
|
|
11
6
|
export declare function lowerBound(length: number, predicate: (index: number) => boolean): number;
|
|
12
7
|
export declare function locateOnPlateauAlternating<T>(items: readonly T[], needle: T, compare: (left: T, right: T) => number, getItemId: (x: T) => string, insertionIndex: number): number;
|
package/dist/types/poll.d.ts
CHANGED
|
@@ -45,20 +45,17 @@ export declare class Poll {
|
|
|
45
45
|
handleVoteChanged: (event: EventPayload<"poll.vote_changed">) => void;
|
|
46
46
|
handleVoteRemoved: (event: EventPayload<"poll.vote_removed">) => void;
|
|
47
47
|
/**
|
|
48
|
-
* Puts an updated user (new name or image) into the votes, answers and creator
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* votes don't contain the user keeps its array, so what renders it doesn't re-render. The offline
|
|
52
|
-
* DB gets the updated poll, as with the other poll events.
|
|
48
|
+
* Puts an updated user (new name or image) into the votes, answers and creator of the poll in one
|
|
49
|
+
* state update, then saves the poll to the offline DB. Does nothing when the poll does not
|
|
50
|
+
* contain the user. Option vote arrays without the user keep their identity.
|
|
53
51
|
*/
|
|
54
52
|
handleUserUpdated: (user: UserResponse) => void;
|
|
55
53
|
query: (id: string) => Promise<PollResponseData>;
|
|
56
54
|
update: (data: Exclude<UpdatePollRequest, "id">) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
57
55
|
partialUpdate: (partialPollObject: PartialPollUpdate) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
58
56
|
/**
|
|
59
|
-
* Closes the poll.
|
|
60
|
-
*
|
|
61
|
-
* Does nothing if the poll is already closed.
|
|
57
|
+
* Closes the poll optimistically. A failed request reverts it, unless the server confirmed the
|
|
58
|
+
* close meanwhile. No-op if the poll is already closed.
|
|
62
59
|
*/
|
|
63
60
|
close: () => Promise<import("./types").StreamResponse<import(".").PollResponse> | undefined>;
|
|
64
61
|
delete: () => Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
@@ -66,15 +63,18 @@ export declare class Poll {
|
|
|
66
63
|
updateOption: (option: UpdatePollOptionRequest) => Promise<import("./types").StreamResponse<import(".").PollOptionResponse>>;
|
|
67
64
|
deleteOption: (option_id: string) => Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
68
65
|
/**
|
|
69
|
-
* Casts a vote
|
|
70
|
-
*
|
|
71
|
-
* If the request fails, the change is reverted.
|
|
66
|
+
* Casts a vote, shown right away as a local placeholder that the server's vote replaces once the
|
|
67
|
+
* WS events of all pending vote changes arrived. A failed request reverts it.
|
|
72
68
|
*/
|
|
73
69
|
castVote: (optionId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
74
70
|
/**
|
|
75
|
-
* Removes a vote
|
|
76
|
-
*
|
|
77
|
-
*
|
|
71
|
+
* Removes a vote right away; a failed request restores it. Vote requests are sent in order, so a
|
|
72
|
+
* vote whose cast is not confirmed yet is removed by the ID from the cast's response (if that
|
|
73
|
+
* cast failed, there is nothing to remove).
|
|
74
|
+
*
|
|
75
|
+
* @param voteId - The ID of the vote to remove.
|
|
76
|
+
* @param messageId - The ID of the poll's message.
|
|
77
|
+
* @returns The delete response, or `undefined` when there was nothing to remove.
|
|
78
78
|
*/
|
|
79
79
|
removeVote: (voteId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
80
80
|
addAnswer: (answerText: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
|