stream-chat 9.50.3 → 10.0.0-rc.2
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 +19798 -14472
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +19817 -14482
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +19795 -14469
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +221 -0
- package/dist/types/EventHandlerPipeline.d.ts +104 -0
- package/dist/types/api-client.d.ts +26 -0
- package/dist/types/campaign.d.ts +0 -44
- package/dist/types/channel.d.ts +454 -479
- package/dist/types/channel_batch_updater.d.ts +0 -93
- package/dist/types/channel_state.d.ts +53 -201
- package/dist/types/client.d.ts +451 -1920
- package/dist/types/client_state.d.ts +4 -4
- package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
- package/dist/types/configuration/index.d.ts +1 -0
- package/dist/types/configuration/types.d.ts +53 -0
- package/dist/types/connection.d.ts +49 -41
- package/dist/types/connection_fallback.d.ts +6 -4
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/custom_types.d.ts +2 -0
- package/dist/types/entityStore/EntityStore.d.ts +111 -0
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +60 -0
- package/dist/types/entityStore/applyReactionLocally.d.ts +26 -0
- package/dist/types/entityStore/index.d.ts +2 -0
- package/dist/types/errors.d.ts +10 -2
- package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
- package/dist/types/gen/chat/ChatApi.d.ts +334 -0
- package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
- package/dist/types/gen/models/index.d.ts +8836 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
- package/dist/types/gen-imports.d.ts +3 -0
- package/dist/types/index.d.ts +8 -7
- package/dist/types/insights.d.ts +9 -8
- package/dist/types/logger.d.ts +9 -0
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
- package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
- package/dist/types/messageComposer/configuration/types.d.ts +11 -11
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
- package/dist/types/messageComposer/messageComposer.d.ts +10 -10
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
- package/dist/types/messageComposer/pollComposer.d.ts +5 -4
- package/dist/types/messageComposer/textComposer.d.ts +8 -3
- package/dist/types/messageComposer/types.d.ts +6 -28
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
- package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
- package/dist/types/messageOperations/index.d.ts +3 -0
- package/dist/types/messageOperations/types.d.ts +49 -0
- package/dist/types/moderation.d.ts +21 -203
- package/dist/types/notifications/types.d.ts +8 -7
- package/dist/types/offline-support/offline_support_api.d.ts +111 -87
- package/dist/types/offline-support/offline_sync_manager.d.ts +0 -7
- package/dist/types/offline-support/types.d.ts +19 -23
- package/dist/types/offline-support/util.d.ts +4 -2
- package/dist/types/pagination/FilterBuilder.d.ts +1 -1
- package/dist/types/pagination/ItemIndex.d.ts +25 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
- package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/filterCompiler.d.ts +7 -0
- package/dist/types/pagination/index.d.ts +1 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +848 -0
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +212 -0
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +282 -0
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
- package/dist/types/pagination/paginators/index.d.ts +7 -0
- package/dist/types/pagination/paginators/stateThrottling.d.ts +2 -0
- package/dist/types/pagination/sortCompiler.d.ts +49 -0
- package/dist/types/pagination/types.normalization.d.ts +11 -0
- package/dist/types/pagination/utility.normalization.d.ts +18 -0
- package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
- package/dist/types/pagination/utility.search.d.ts +13 -0
- package/dist/types/permissions.d.ts +1 -1
- package/dist/types/poll.d.ts +29 -32
- package/dist/types/poll_manager.d.ts +2 -2
- package/dist/types/reminders/Reminder.d.ts +2 -5
- package/dist/types/reminders/ReminderManager.d.ts +2 -9
- package/dist/types/search/MessageSearchSource.d.ts +4 -4
- package/dist/types/search/UserSearchSource.d.ts +1 -1
- package/dist/types/search/types.d.ts +3 -3
- package/dist/types/segment.d.ts +0 -34
- package/dist/types/signing.d.ts +105 -65
- package/dist/types/store.d.ts +1 -0
- package/dist/types/thread.d.ts +70 -34
- package/dist/types/thread_manager.d.ts +3 -3
- package/dist/types/token_manager.d.ts +15 -10
- package/dist/types/types.d.ts +197 -3404
- package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
- package/dist/types/utils/WithSubscriptions.d.ts +2 -1
- package/dist/types/utils/concurrency.d.ts +4 -4
- package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
- package/dist/types/utils/retryable.d.ts +34 -0
- package/dist/types/utils/throttling/throttle.d.ts +36 -0
- package/dist/types/utils.d.ts +100 -194
- package/package.json +7 -3
- package/src/ChannelManager.ts +724 -0
- package/src/CooldownTimer.ts +2 -2
- package/src/EventHandlerPipeline.ts +228 -0
- package/src/LiveLocationManager.ts +12 -11
- package/src/api-client.ts +275 -0
- package/src/campaign.ts +1 -77
- package/src/channel.ts +1344 -1282
- package/src/channel_batch_updater.ts +1 -211
- package/src/channel_state.ts +144 -1013
- package/src/client.ts +936 -3995
- package/src/client_state.ts +4 -4
- package/src/configuration/InstanceConfigurationService.ts +73 -0
- package/src/configuration/index.ts +1 -0
- package/src/configuration/types.ts +81 -0
- package/src/connection.ts +145 -94
- package/src/connection_fallback.ts +29 -27
- package/src/constants.ts +1 -5
- package/src/custom_types.ts +4 -1
- package/src/entityStore/EntityStore.ts +208 -0
- package/src/entityStore/StoreBackedItemIndex.ts +115 -0
- package/src/entityStore/applyReactionLocally.ts +113 -0
- package/src/entityStore/index.ts +2 -0
- package/src/errors.ts +14 -2
- package/src/gen/chat/ChannelApi.ts +275 -0
- package/src/gen/chat/ChatApi.ts +2554 -0
- package/src/gen/model-decoders/decoders.ts +2680 -0
- package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
- package/src/gen/models/index.ts +12673 -0
- package/src/gen/moderation/ModerationApi.ts +607 -0
- package/src/gen-imports.ts +3 -0
- package/src/index.ts +11 -12
- package/src/insights.ts +6 -5
- package/src/logger.ts +28 -0
- package/src/messageComposer/LocationComposer.ts +9 -5
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
- package/src/messageComposer/attachmentIdentity.ts +16 -9
- package/src/messageComposer/attachmentManager.ts +13 -8
- package/src/messageComposer/configuration/types.ts +11 -11
- package/src/messageComposer/linkPreviewsManager.ts +9 -10
- package/src/messageComposer/messageComposer.ts +57 -53
- package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
- package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
- package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
- package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
- package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
- package/src/messageComposer/middleware/textComposer/types.ts +9 -4
- package/src/messageComposer/pollComposer.ts +6 -8
- package/src/messageComposer/textComposer.ts +27 -2
- package/src/messageComposer/types.ts +6 -28
- package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
- package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
- package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
- package/src/messageOperations/MessageOperations.ts +212 -0
- package/src/messageOperations/index.ts +10 -0
- package/src/messageOperations/types.ts +64 -0
- package/src/moderation.ts +38 -431
- package/src/notifications/types.ts +8 -7
- package/src/offline-support/offline_support_api.ts +200 -133
- package/src/offline-support/offline_sync_manager.ts +23 -44
- package/src/offline-support/types.ts +23 -26
- package/src/offline-support/util.ts +5 -4
- package/src/pagination/FilterBuilder.ts +4 -1
- package/src/pagination/ItemIndex.ts +25 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
- package/src/pagination/cursorDerivation/index.ts +1 -0
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
- package/src/pagination/filterCompiler.ts +196 -0
- package/src/pagination/index.ts +1 -3
- package/src/pagination/paginators/BasePaginator.ts +2859 -0
- package/src/pagination/paginators/ChannelPaginator.ts +729 -0
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1116 -0
- package/src/pagination/paginators/MessagePaginator.ts +508 -0
- package/src/pagination/paginators/PinnedMessagePaginator.ts +108 -0
- package/src/pagination/paginators/ReminderPaginator.ts +107 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +127 -0
- package/src/pagination/paginators/index.ts +7 -0
- package/src/pagination/paginators/stateThrottling.ts +31 -0
- package/src/pagination/sortCompiler.ts +193 -0
- package/src/pagination/types.normalization.ts +14 -0
- package/src/pagination/utility.normalization.ts +106 -0
- package/src/pagination/utility.queryChannel.ts +84 -0
- package/src/pagination/utility.search.ts +80 -0
- package/src/permissions.ts +7 -8
- package/src/poll.ts +101 -110
- package/src/poll_manager.ts +14 -8
- package/src/reminders/Reminder.ts +2 -5
- package/src/reminders/ReminderManager.ts +19 -21
- package/src/search/BaseSearchSource.ts +0 -3
- package/src/search/ChannelMemberSearchSource.ts +7 -1
- package/src/search/ChannelSearchSource.ts +10 -3
- package/src/search/MessageSearchSource.ts +29 -30
- package/src/search/UserSearchSource.ts +12 -8
- package/src/search/types.ts +3 -4
- package/src/segment.ts +1 -95
- package/src/signing.ts +107 -67
- package/src/store.ts +2 -1
- package/src/thread.ts +562 -238
- package/src/thread_manager.ts +37 -16
- package/src/token_manager.ts +21 -10
- package/src/types.ts +364 -4533
- package/src/uploadManager.ts +8 -0
- package/src/utils/FixedSizeQueueCache.ts +12 -6
- package/src/utils/WithSubscriptions.ts +2 -1
- package/src/utils/concurrency.ts +4 -4
- package/src/utils/mergeWith/mergeWith.ts +3 -3
- package/src/utils/mergeWith/mergeWithCore.ts +140 -164
- package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
- package/src/utils/retryable.ts +117 -0
- package/src/utils/throttling/throttle.ts +130 -0
- package/src/utils.ts +208 -754
- package/dist/types/channel_manager.d.ts +0 -122
- package/dist/types/events.d.ts +0 -72
- package/dist/types/pagination/BasePaginator.d.ts +0 -69
- package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
- package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
- package/src/channel_manager.ts +0 -830
- package/src/events.ts +0 -75
- package/src/pagination/BasePaginator.ts +0 -184
- package/src/pagination/ReminderPaginator.ts +0 -56
- package/src/pagination/UserGroupPaginator.ts +0 -93
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type { ExecuteQueryReturnValue, Interval, PostQueryReconcileParams } from './BasePaginator';
|
|
2
|
+
import { type MessagePaginatorOptions as BaseMessagePaginatorOptions, type JumpToMessageOptions, MessageIntervalPaginator, type MessageQueryShape } from './MessageIntervalPaginator';
|
|
3
|
+
import type { LocalMessage } from '../../types';
|
|
4
|
+
import { StateStore } from '../../store';
|
|
5
|
+
export type { JumpToMessageOptions, MessageFocusReason, MessageFocusSignal, MessageFocusSignalState, MessagePaginatorFilter, MessagePaginatorSort, MessagePaginatorState, MessageQueryShape, } from './MessageIntervalPaginator';
|
|
6
|
+
export { MessageIntervalPaginator } from './MessageIntervalPaginator';
|
|
7
|
+
/**
|
|
8
|
+
* Auxiliary (non-pagination) state for the message paginator: whole-collection aggregates that are
|
|
9
|
+
* independent of the active pagination window (the dual of pagination — values over the entire set,
|
|
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
|
|
12
|
+
* (`channel.messagePaginator.lastMessageAt`): seeded from `ChannelResponse.last_message_at`, then
|
|
13
|
+
* advanced monotonically as newer messages are ingested.
|
|
14
|
+
*/
|
|
15
|
+
export type MessagePaginatorAggregateState = {
|
|
16
|
+
/**
|
|
17
|
+
* The newest channel-relevant message, for display (e.g. a channel/thread list item's last-message
|
|
18
|
+
* preview or latest-reply avatar). A LIVE reference: it advances to a strictly newer message, is
|
|
19
|
+
* refreshed in place when that message is edited/soft-deleted/reacted-to, and is recomputed to the
|
|
20
|
+
* next newest when it is hard-removed. Respects `shouldAdvanceLastMessage` (skips system messages
|
|
21
|
+
* per `skip_last_msg_update_for_system_msgs`, and thread-only replies). `null` until one is ingested.
|
|
22
|
+
*
|
|
23
|
+
* Lives here, NOT derived from pagination `state`, so it stays reactive when a WS message lands in
|
|
24
|
+
* the head interval while an older window is active — the pagination store only emits when the
|
|
25
|
+
* active* interval is impacted (see `BasePaginator.ingestItem`), so a `state`-derived latest would
|
|
26
|
+
* go stale in that case.
|
|
27
|
+
*/
|
|
28
|
+
lastMessage: LocalMessage | null;
|
|
29
|
+
/**
|
|
30
|
+
* Server-provided `ChannelResponse.last_message_at` floor, for channels whose newest message is not
|
|
31
|
+
* loaded (e.g. surfaced by a channel-list query). Kept SEPARATE from {@link lastMessage} so it can
|
|
32
|
+
* outrank a stale/absent loaded message for sorting without overwriting the display message. The
|
|
33
|
+
* sort key {@link MessagePaginator.lastMessageAt} is derived as the max of the two, so the two can
|
|
34
|
+
* never drift out of sync.
|
|
35
|
+
*/
|
|
36
|
+
seededLastMessageAt: Date | null;
|
|
37
|
+
};
|
|
38
|
+
export type MessagePaginatorOptions = BaseMessagePaginatorOptions & {
|
|
39
|
+
/**
|
|
40
|
+
* Controls whether `jumpToTheFirstUnreadMessage()` should prefer the `unreadStateSnapshot`
|
|
41
|
+
* state over `channel.state.read[...]`.
|
|
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
|
|
45
|
+
*/
|
|
46
|
+
unreadReferencePolicy?: 'snapshot' | 'read-state-only';
|
|
47
|
+
};
|
|
48
|
+
export type UnreadSnapshotState = {
|
|
49
|
+
lastReadAt: Date | null;
|
|
50
|
+
unreadCount: number;
|
|
51
|
+
/**
|
|
52
|
+
* Snapshot of the first unread message id for the user.
|
|
53
|
+
* This is intentionally decoupled from `channel.state.read[...]` because apps
|
|
54
|
+
* may mark the channel read immediately on open, while still wanting to render
|
|
55
|
+
* UI indicators that jump to the previously-unread location.
|
|
56
|
+
*/
|
|
57
|
+
firstUnreadMessageId: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Snapshot of the last read message id for the user (fallback when first unread
|
|
60
|
+
* is not known).
|
|
61
|
+
*/
|
|
62
|
+
lastReadMessageId: string | null;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* External, UI-driven signal: `true` while the user is actively viewing the latest messages of
|
|
66
|
+
* this collection (app foregrounded AND the newest message on screen). The owning SDK sets it — the
|
|
67
|
+
* state layer has no viewport. When live, an incoming message is NOT counted as unread (the count /
|
|
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).
|
|
70
|
+
*/
|
|
71
|
+
export type LiveViewState = {
|
|
72
|
+
isViewingLive: boolean;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* MessagePaginator extends {@link MessageIntervalPaginator} with the unread/live-view concern:
|
|
76
|
+
* an independent unread reference snapshot, the UI-driven "viewing the latest messages" signal, and
|
|
77
|
+
* the "jump to first unread" navigation built on top of them.
|
|
78
|
+
*/
|
|
79
|
+
export declare class MessagePaginator extends MessageIntervalPaginator {
|
|
80
|
+
private unreadReferencePolicy;
|
|
81
|
+
/**
|
|
82
|
+
* Independent unread reference state (not tied to `channel.state.read`).
|
|
83
|
+
* Consumers may set this right before calling markRead / when opening a channel.
|
|
84
|
+
*/
|
|
85
|
+
readonly unreadStateSnapshot: StateStore<UnreadSnapshotState>;
|
|
86
|
+
/**
|
|
87
|
+
* UI-driven "viewing the latest messages" signal (see {@link LiveViewState}). Set by the SDK via
|
|
88
|
+
* {@link setViewingLive}; read by the channel to gate the unread bump on `message.new`. Subscribe to
|
|
89
|
+
* this store for reactivity, or read the current boolean directly via the {@link isViewingLive} getter.
|
|
90
|
+
*/
|
|
91
|
+
readonly liveViewState: StateStore<LiveViewState>;
|
|
92
|
+
/**
|
|
93
|
+
* Auxiliary (non-pagination) state — see {@link MessagePaginatorAggregateState}. A store separate
|
|
94
|
+
* from `state` so `lastMessageAt` can be advanced from inside a `state.next` updater
|
|
95
|
+
* (`ingestPage`) without being clobbered, and so consumers subscribe to a quiet signal that only
|
|
96
|
+
* emits when the aggregate actually changes (not on every scroll/pagination emission). This is
|
|
97
|
+
* distinct from the base's `intervalViews` interval-projection store.
|
|
98
|
+
*/
|
|
99
|
+
readonly aggregateState: StateStore<MessagePaginatorAggregateState>;
|
|
100
|
+
constructor({ unreadReferencePolicy, ...options }: MessagePaginatorOptions);
|
|
101
|
+
/**
|
|
102
|
+
* Channel-list sort key: the later of the newest loaded message's `created_at` and the server seed.
|
|
103
|
+
* **Derived** (never stored) so it cannot drift from {@link lastMessage}. `null` until seeded or a
|
|
104
|
+
* message is ingested.
|
|
105
|
+
*/
|
|
106
|
+
get lastMessageAt(): Date | null;
|
|
107
|
+
/**
|
|
108
|
+
* The newest channel-relevant message (the monotonic tracked latest), for display. Convenience read
|
|
109
|
+
* of {@link aggregateState}; subscribe to `aggregateState` for reactivity. `null` until a message is
|
|
110
|
+
* ingested (a server-only seed advances {@link lastMessageAt} but leaves this `null`).
|
|
111
|
+
*/
|
|
112
|
+
get lastMessage(): LocalMessage | null;
|
|
113
|
+
/**
|
|
114
|
+
* The main channel list's notion of "latest message" for `channel.state.last_message_at`: on top of
|
|
115
|
+
* the base rule (not shadowed) this excludes thread-only replies (a reply with a `parent_id` that is
|
|
116
|
+
* not shown in the channel is not part of the channel list) and, when the channel is configured with
|
|
117
|
+
* `skip_last_msg_update_for_system_msgs`, system messages. Mirrors the legacy
|
|
118
|
+
* `Channel._trackLastMessage` skip logic.
|
|
119
|
+
*
|
|
120
|
+
* These exclusions are specific to the MAIN channel list. A reply list (thread paginator, which has
|
|
121
|
+
* a `parentMessageId`) is made ENTIRELY of thread replies — there the newest reply is exactly the
|
|
122
|
+
* "latest message", so the exclusions are skipped and only the base rule applies.
|
|
123
|
+
*/
|
|
124
|
+
protected shouldAdvanceLastMessage(message: LocalMessage): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Monotonically advance {@link lastMessageAt} to `message.created_at` when it is newer than the
|
|
127
|
+
* current value and {@link shouldAdvanceLastMessage} permits it. Writes the dedicated
|
|
128
|
+
* {@link aggregateState} store (not `state`), so it is safe to call from inside a `state.next`
|
|
129
|
+
* updater (`ingestPage`). Returns `true` when the value moved.
|
|
130
|
+
*
|
|
131
|
+
* Called internally on ingest; also public for callers that advance the aggregate without a normal
|
|
132
|
+
* in-window ingest — e.g. offline pending-message replay, where the sent message has not yet been
|
|
133
|
+
* ingested via the `message.new` event.
|
|
134
|
+
*/
|
|
135
|
+
trackLastMessage(message: LocalMessage): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Seed {@link lastMessageAt} from the server-provided `ChannelResponse.last_message_at`, the
|
|
138
|
+
* authoritative whole-channel aggregate. Monotonic: a no-op when the paginator already advanced
|
|
139
|
+
* past it (e.g. from ingested messages), so seed order does not matter.
|
|
140
|
+
*/
|
|
141
|
+
seedLastMessageAt(value: string | Date | null | undefined): void;
|
|
142
|
+
ingestItem(item: LocalMessage): boolean;
|
|
143
|
+
ingestPage(params: Parameters<MessageIntervalPaginator['ingestPage']>[0]): Interval | null;
|
|
144
|
+
removeItem(params: Parameters<MessageIntervalPaginator['removeItem']>[0]): ReturnType<MessageIntervalPaginator['removeItem']>;
|
|
145
|
+
/**
|
|
146
|
+
* The still-loaded message with the greatest `created_at` that passes
|
|
147
|
+
* {@link shouldAdvanceLastMessage} (skips system / thread-only per config), from the newest-loaded
|
|
148
|
+
* window. Used to recompute the tracked latest after the current one is removed. `null` when nothing
|
|
149
|
+
* loaded qualifies.
|
|
150
|
+
*
|
|
151
|
+
* "Latest" is defined by `created_at` (matching {@link trackLastMessage}), NOT by the paginator's
|
|
152
|
+
* display order — so this compares timestamps rather than assuming a position, and stays correct
|
|
153
|
+
* whatever `itemOrder` / `requestSort` are configured to.
|
|
154
|
+
*/
|
|
155
|
+
private recomputeLastMessage;
|
|
156
|
+
/**
|
|
157
|
+
* (Re)seed the unread state snapshot from the current own read state.
|
|
158
|
+
*
|
|
159
|
+
* Called after the first-page query, and can be called again by the SDK whenever a channel is
|
|
160
|
+
* (re)opened from a cached paginator — where no fresh first-page query runs — so the snapshot
|
|
161
|
+
* reflects the CURRENT read boundary rather than one frozen at the very first open. Without a
|
|
162
|
+
* re-seed the separator position, unread count and "jump to first unread" target all go stale
|
|
163
|
+
* across reopens.
|
|
164
|
+
*
|
|
165
|
+
* `firstUnreadMessageId` is intentionally reset to `null`: it represents an EXPLICIT mark-unread
|
|
166
|
+
* (set by `notification.mark_unread`), not a live/computed boundary. Persisting a computed value
|
|
167
|
+
* here would make the channel look explicitly marked-unread and suppress auto-mark-read.
|
|
168
|
+
*/
|
|
169
|
+
seedUnreadSnapshot: () => void;
|
|
170
|
+
/**
|
|
171
|
+
* Invokes super.postQueryReconcile() and takes an unread state snapshot on the first-page query.
|
|
172
|
+
* The snapshot has to be taken immediately after the query as the viewed channel is marked read
|
|
173
|
+
* immediately after opening it. The snapshot can be used to display unread UI indicators.
|
|
174
|
+
*/
|
|
175
|
+
postQueryReconcile(params: PostQueryReconcileParams<LocalMessage, MessageQueryShape>): ExecuteQueryReturnValue<LocalMessage>;
|
|
176
|
+
/**
|
|
177
|
+
* Jumps to the unread reference message.
|
|
178
|
+
*
|
|
179
|
+
* IMPORTANT: This intentionally does *not* rely on `channel.state.read[ownUserId]` only,
|
|
180
|
+
* because apps may mark a channel read immediately after opening it, while still
|
|
181
|
+
* wanting to keep "jump to unread" UI indicators alive (based on a snapshot).
|
|
182
|
+
*
|
|
183
|
+
* Resolution order:
|
|
184
|
+
* 1) explicit first-unread id from snapshot/read-state (mark-unread) — jump straight to it
|
|
185
|
+
* 2) last-read timestamp: infer the FIRST UNREAD message from it — using the already-loaded
|
|
186
|
+
* window when it straddles the boundary, otherwise a `created_at_around` query — and jump there
|
|
187
|
+
* 3) last read id from snapshot/read-state (last-resort fallback when no timestamp is available)
|
|
188
|
+
*
|
|
189
|
+
* The timestamp inference (2) is preferred over jumping to the last-read id so that the jump lands
|
|
190
|
+
* ON (and highlights) the first unread message rather than the last read one. The last-read id is
|
|
191
|
+
* only used as a fallback when we cannot infer an unread boundary. The inference is NOT persisted
|
|
192
|
+
* back into the snapshot (that is reserved for explicit mark-unread).
|
|
193
|
+
*/
|
|
194
|
+
jumpToTheFirstUnreadMessage: (options?: JumpToMessageOptions) => Promise<boolean>;
|
|
195
|
+
setUnreadSnapshot: (next: Partial<UnreadSnapshotState>) => UnreadSnapshotState;
|
|
196
|
+
/**
|
|
197
|
+
* Set the UI-driven "viewing the latest messages" signal (see {@link LiveViewState}). Called by
|
|
198
|
+
* the SDK from its message-list viewability + app-state tracking. No-ops when unchanged.
|
|
199
|
+
*
|
|
200
|
+
* Intentionally NOT reset by `clearStateAndCache` — it is an external input owned by the SDK, not
|
|
201
|
+
* derived pagination state.
|
|
202
|
+
*/
|
|
203
|
+
/** Current "viewing the latest messages" boolean (convenience read of {@link liveViewState}). */
|
|
204
|
+
get isViewingLive(): boolean;
|
|
205
|
+
setViewingLive: (isViewingLive: boolean) => void;
|
|
206
|
+
clearUnreadSnapshot: () => void;
|
|
207
|
+
clearStateAndCache(): void;
|
|
208
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PaginatorOptions } from './BasePaginator';
|
|
2
|
+
import { MessageIntervalPaginator, type MessageQueryShape } from './MessageIntervalPaginator';
|
|
3
|
+
import type { LocalMessage } from '../../types';
|
|
4
|
+
import type { Channel } from '../../channel';
|
|
5
|
+
import type { ItemIndexApi } from '../ItemIndex';
|
|
6
|
+
export type PinnedMessagePaginatorFilter = {
|
|
7
|
+
cid: string;
|
|
8
|
+
pinned: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type PinnedMessagePaginatorOptions = {
|
|
11
|
+
channel: Channel;
|
|
12
|
+
id?: string;
|
|
13
|
+
itemIndex?: ItemIndexApi<LocalMessage>;
|
|
14
|
+
paginatorOptions?: PaginatorOptions<LocalMessage, MessageQueryShape>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Pinned-message list paginator.
|
|
18
|
+
*
|
|
19
|
+
* Extends the unread-free {@link MessageIntervalPaginator} base — pinned messages are a subset of
|
|
20
|
+
* the channel and MUST NOT participate in read/unread or delivery-receipt tracking (that belongs to
|
|
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.
|
|
34
|
+
*/
|
|
35
|
+
export declare class PinnedMessagePaginator extends MessageIntervalPaginator {
|
|
36
|
+
constructor({ channel, id, itemIndex, paginatorOptions, }: PinnedMessagePaginatorOptions);
|
|
37
|
+
buildMatchFilters: () => PinnedMessagePaginatorFilter;
|
|
38
|
+
shouldIncludeMessageInInterval(message: LocalMessage): boolean;
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BasePaginator } from './BasePaginator';
|
|
2
|
+
import type { PaginationQueryParams, PaginationQueryReturnValue, PaginatorOptions } from './BasePaginator';
|
|
3
|
+
import type { QueryRemindersOptions, ReminderFilters, ReminderResponseData, ReminderSort } from '../../types';
|
|
4
|
+
import type { StreamChat } from '../../client';
|
|
5
|
+
export declare class ReminderPaginator extends BasePaginator<ReminderResponseData, QueryRemindersOptions> {
|
|
6
|
+
private client;
|
|
7
|
+
protected _filters: ReminderFilters | undefined;
|
|
8
|
+
protected _sort: ReminderSort | undefined;
|
|
9
|
+
get filters(): ReminderFilters | undefined;
|
|
10
|
+
get sort(): ReminderSort | undefined;
|
|
11
|
+
set filters(filters: ReminderFilters | undefined);
|
|
12
|
+
set sort(sort: ReminderSort | undefined);
|
|
13
|
+
constructor(client: StreamChat, options?: PaginatorOptions<ReminderResponseData, QueryRemindersOptions>);
|
|
14
|
+
getItemId(item: ReminderResponseData): string;
|
|
15
|
+
private buildSortComparator;
|
|
16
|
+
protected getNextQueryShape({ direction, }: Required<Pick<PaginationQueryParams<QueryRemindersOptions>, 'direction'>>): QueryRemindersOptions;
|
|
17
|
+
query: ({ queryShape, }: PaginationQueryParams<QueryRemindersOptions>) => Promise<PaginationQueryReturnValue<ReminderResponseData>>;
|
|
18
|
+
filterQueryResults: (items: ReminderResponseData[]) => ReminderResponseData[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BasePaginator } from './BasePaginator';
|
|
2
|
+
import type { PaginationQueryParams, PaginationQueryReturnValue, PaginatorOptions, PaginatorState } from './BasePaginator';
|
|
3
|
+
import type { ListUserGroupsOptions, UserGroupResponse } from '../../types';
|
|
4
|
+
import type { StreamChat } from '../../client';
|
|
5
|
+
/**
|
|
6
|
+
* Paginates user-group listing through `/usergroups`.
|
|
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`).
|
|
12
|
+
*/
|
|
13
|
+
export declare class UserGroupPaginator extends BasePaginator<UserGroupResponse, ListUserGroupsOptions> {
|
|
14
|
+
private client;
|
|
15
|
+
protected _teamId: string | undefined;
|
|
16
|
+
constructor(client: StreamChat, options?: PaginatorOptions<UserGroupResponse, ListUserGroupsOptions>);
|
|
17
|
+
get initialState(): PaginatorState<UserGroupResponse>;
|
|
18
|
+
get teamId(): string | undefined;
|
|
19
|
+
set teamId(teamId: string | undefined);
|
|
20
|
+
private buildNextCursor;
|
|
21
|
+
protected getNextQueryShape(): ListUserGroupsOptions;
|
|
22
|
+
query: ({ direction, queryShape, }: PaginationQueryParams<ListUserGroupsOptions>) => Promise<PaginationQueryReturnValue<UserGroupResponse>>;
|
|
23
|
+
filterQueryResults: (items: UserGroupResponse[]) => UserGroupResponse[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './BasePaginator';
|
|
2
|
+
export * from './ChannelPaginator';
|
|
3
|
+
export { MessageIntervalPaginator } from './MessageIntervalPaginator';
|
|
4
|
+
export * from './MessagePaginator';
|
|
5
|
+
export * from './PinnedMessagePaginator';
|
|
6
|
+
export * from './ReminderPaginator';
|
|
7
|
+
export * from './UserGroupPaginator';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SortParamRequest } from '../types';
|
|
2
|
+
import type { Comparator, PathResolver } from './types.normalization';
|
|
3
|
+
export type ItemLocation = {
|
|
4
|
+
currentIndex: number;
|
|
5
|
+
insertionIndex: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Generic binary-search + plateau lookup over an abstract sorted array.
|
|
9
|
+
*
|
|
10
|
+
* The array is represented by:
|
|
11
|
+
* - its length
|
|
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
|
|
17
|
+
*/
|
|
18
|
+
export declare function binarySearch<T>({ needle, length, getItemAt, itemIdentityEquals, compare, plateauScan, }: {
|
|
19
|
+
/** Target item in the searched array */
|
|
20
|
+
needle: T;
|
|
21
|
+
length: number;
|
|
22
|
+
/** Retrieves the item from an array. The array could be just an array of reference by id to an index.
|
|
23
|
+
* Therefore, we do not access the array directly but allow to determine, how the item is constructed.
|
|
24
|
+
*/
|
|
25
|
+
getItemAt: (index: number) => T | undefined;
|
|
26
|
+
/** Used to determine identity, not equality based on sort / comparator rules */
|
|
27
|
+
itemIdentityEquals: (item1: T, item2: T) => boolean;
|
|
28
|
+
/** Used to determine equality from the sort order point of view. */
|
|
29
|
+
compare: Comparator<T>;
|
|
30
|
+
plateauScan?: boolean;
|
|
31
|
+
}): ItemLocation;
|
|
32
|
+
/**
|
|
33
|
+
* Negative number (< 0) → a comes before b
|
|
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
|
|
39
|
+
*
|
|
40
|
+
* @param params - Comparator configuration.
|
|
41
|
+
* @param params.sort - The sort specification defining fields and directions.
|
|
42
|
+
* @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.
|
|
44
|
+
*/
|
|
45
|
+
export declare function makeComparator<T>({ sort, resolvePathValue, tiebreaker, }: {
|
|
46
|
+
sort: SortParamRequest[];
|
|
47
|
+
resolvePathValue?: PathResolver<T>;
|
|
48
|
+
tiebreaker?: Comparator<T>;
|
|
49
|
+
}): Comparator<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type PathResolver<DataSource> = (item: DataSource, field: string) => unknown;
|
|
2
|
+
export declare enum ComparisonResult {
|
|
3
|
+
A_PRECEDES_B = -1,
|
|
4
|
+
A_IS_EQUAL_TO_B = 0,
|
|
5
|
+
A_COMES_AFTER_B = 1
|
|
6
|
+
}
|
|
7
|
+
export type Comparator<T> = (left: T, right: T) => ComparisonResult;
|
|
8
|
+
export type FieldToDataResolver<DataSource> = {
|
|
9
|
+
matchesField: (field: string) => boolean;
|
|
10
|
+
resolve: PathResolver<DataSource>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function asArray(v: any): any[];
|
|
2
|
+
export declare function isISODateString(x: any): x is string;
|
|
3
|
+
export declare function toEpochMillis(x: any): number | null;
|
|
4
|
+
export declare function toNumberLike(x: any): number | null;
|
|
5
|
+
export declare function normalizeComparedValues(a: any, b: any): {
|
|
6
|
+
kind: string;
|
|
7
|
+
a: any;
|
|
8
|
+
b: any;
|
|
9
|
+
};
|
|
10
|
+
export declare function normKey(x: unknown): string;
|
|
11
|
+
export declare function compare(a: any, b: any): number;
|
|
12
|
+
export declare function arraysEqualAsSets(aList: unknown[], bList: unknown[]): boolean;
|
|
13
|
+
export declare function normalizeString(s: string): string;
|
|
14
|
+
export declare function normalizeStringAccentInsensitive(s: string): string;
|
|
15
|
+
export declare function tokenize(s: string): string[];
|
|
16
|
+
export declare function resolveDotPathValue(obj: any, path: string): unknown[];
|
|
17
|
+
export declare function isIterableButNotString(v: unknown): v is Iterable<unknown>;
|
|
18
|
+
export declare function toIterableArray(v: unknown): unknown[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ChannelGetOrCreateRequest } from '../types';
|
|
2
|
+
import type { StreamChat } from '../client';
|
|
3
|
+
import type { Channel } from '../channel';
|
|
4
|
+
type GetChannelParams = {
|
|
5
|
+
client: StreamChat;
|
|
6
|
+
channel?: Channel;
|
|
7
|
+
id?: string;
|
|
8
|
+
members?: string[];
|
|
9
|
+
options?: ChannelGetOrCreateRequest;
|
|
10
|
+
type?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Watches a channel, coalescing concurrent invocations for the same CID.
|
|
14
|
+
* If a watch is already in flight, this call waits for it to settle instead of
|
|
15
|
+
* issuing another network request.
|
|
16
|
+
*
|
|
17
|
+
* @param params - The channel query parameters.
|
|
18
|
+
* @param params.client - The chat client instance.
|
|
19
|
+
* @param params.members - Member user ids used to construct or identify the channel.
|
|
20
|
+
* @param params.options - Options forwarded to the underlying channel watch request.
|
|
21
|
+
* @param params.type - The channel type.
|
|
22
|
+
* @param params.id - The channel id.
|
|
23
|
+
* @param params.channel - An existing channel to watch (skips construction from type/id/members).
|
|
24
|
+
*/
|
|
25
|
+
export declare const getChannel: ({ channel, client, id, members, options, type, }: GetChannelParams) => Promise<Channel>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Partition-point ("lower bound") binary search over the index range `[0, length)`.
|
|
3
|
+
*
|
|
4
|
+
* `predicate` must be **monotonic** over the range — `false` for a (possibly empty) prefix, then
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
export declare function lowerBound(length: number, predicate: (index: number) => boolean): number;
|
|
12
|
+
export declare function locateOnPlateauAlternating<T>(items: readonly T[], needle: T, compare: (left: T, right: T) => number, getItemId: (x: T) => string, insertionIndex: number): number;
|
|
13
|
+
export declare function locateOnPlateauScanOneSide<T>(items: readonly T[], needle: T, compare: (left: T, right: T) => number, getItemId: (x: T) => string, insertionIndex: number): number;
|
|
@@ -17,7 +17,7 @@ export declare class Permission {
|
|
|
17
17
|
}
|
|
18
18
|
export declare const AllowAll: Permission;
|
|
19
19
|
export declare const DenyAll: Permission;
|
|
20
|
-
export type
|
|
20
|
+
export type RoleName = 'admin' | 'user' | 'guest' | 'anonymous' | 'channel_member' | 'channel_moderator' | (string & {});
|
|
21
21
|
export declare const BuiltinRoles: {
|
|
22
22
|
Admin: string;
|
|
23
23
|
Anonymous: string;
|
package/dist/types/poll.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { StateStore } from './store';
|
|
2
2
|
import type { StreamChat } from './client';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
3
|
+
import type { EventPayload, PartialPollUpdate, PollEnrichData, PollOptionData, PollResponse_old, PollVoteResponseData, QueryVotesFilters, QueryVotesOptions, RequireLiteral, UpdatePollRequest, VoteSort } from './types';
|
|
4
|
+
import type { PollResponseData as Gen_PollResponseData } from './gen/models';
|
|
5
|
+
export declare const isVoteAnswer: (vote: any | undefined) => vote is RequireLiteral<PollVoteResponseData, "answer_text" | "is_answer">;
|
|
5
6
|
export type PollAnswersQueryParams = {
|
|
6
7
|
filter?: QueryVotesFilters;
|
|
7
8
|
options?: QueryVotesOptions;
|
|
@@ -15,15 +16,15 @@ export type PollOptionVotesQueryParams = {
|
|
|
15
16
|
sort?: VoteSort;
|
|
16
17
|
};
|
|
17
18
|
type OptionId = string;
|
|
18
|
-
export type PollState = Omit<
|
|
19
|
+
export type PollState = Omit<PollResponse_old, 'own_votes' | 'id'> & {
|
|
19
20
|
lastActivityAt: Date;
|
|
20
21
|
maxVotedOptionIds: OptionId[];
|
|
21
|
-
ownVotesByOptionId: Record<OptionId,
|
|
22
|
-
ownAnswer?:
|
|
22
|
+
ownVotesByOptionId: Record<OptionId, PollVoteResponseData>;
|
|
23
|
+
ownAnswer?: PollVoteResponseData;
|
|
23
24
|
};
|
|
24
25
|
type PollInitOptions = {
|
|
25
26
|
client: StreamChat;
|
|
26
|
-
poll:
|
|
27
|
+
poll: Gen_PollResponseData;
|
|
27
28
|
};
|
|
28
29
|
export declare class Poll {
|
|
29
30
|
readonly state: StateStore<PollState>;
|
|
@@ -34,31 +35,27 @@ export declare class Poll {
|
|
|
34
35
|
private upsertOfflineDb;
|
|
35
36
|
reinitializeState: (poll: PollInitOptions["poll"]) => void;
|
|
36
37
|
get data(): PollState;
|
|
37
|
-
handlePollUpdated: (event:
|
|
38
|
-
handlePollClosed: (event:
|
|
39
|
-
handleVoteCasted: (event:
|
|
40
|
-
handleVoteChanged: (event:
|
|
41
|
-
handleVoteRemoved: (event:
|
|
42
|
-
query: (id: string) => Promise<
|
|
43
|
-
update: (data: Exclude<
|
|
44
|
-
partialUpdate: (partialPollObject: PartialPollUpdate) => Promise<import("./types").
|
|
45
|
-
close: () => Promise<import("./types").
|
|
46
|
-
delete: () => Promise<import("./types").
|
|
47
|
-
createOption: (option: PollOptionData) => Promise<import("./types").
|
|
48
|
-
updateOption: (option: PollOptionData) => Promise<import("./types").
|
|
49
|
-
deleteOption: (
|
|
50
|
-
castVote: (optionId: string, messageId: string) => Promise<
|
|
51
|
-
removeVote: (voteId: string, messageId: string) => Promise<import("./types").
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
vote: PollVote;
|
|
57
|
-
}>;
|
|
58
|
-
queryAnswers: (params: PollAnswersQueryParams) => Promise<import("./types").APIResponse & import("./types").PollAnswersAPIResponse>;
|
|
59
|
-
queryOptionVotes: (params: PollOptionVotesQueryParams) => Promise<import("./types").APIResponse & import("./types").PollVotesAPIResponse>;
|
|
38
|
+
handlePollUpdated: (event: EventPayload<"poll.updated">) => void;
|
|
39
|
+
handlePollClosed: (event: EventPayload<"poll.closed">) => void;
|
|
40
|
+
handleVoteCasted: (event: EventPayload<"poll.vote_casted">) => void;
|
|
41
|
+
handleVoteChanged: (event: EventPayload<"poll.vote_changed">) => void;
|
|
42
|
+
handleVoteRemoved: (event: EventPayload<"poll.vote_removed">) => void;
|
|
43
|
+
query: (id: string) => Promise<Gen_PollResponseData>;
|
|
44
|
+
update: (data: Exclude<UpdatePollRequest, "id">) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
45
|
+
partialUpdate: (partialPollObject: PartialPollUpdate) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
46
|
+
close: () => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
47
|
+
delete: () => Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
48
|
+
createOption: (option: PollOptionData) => Promise<import("./types").StreamResponse<import(".").PollOptionResponse>>;
|
|
49
|
+
updateOption: (option: PollOptionData) => Promise<import("./types").StreamResponse<import(".").PollOptionResponse>>;
|
|
50
|
+
deleteOption: (option_id: string) => Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
51
|
+
castVote: (optionId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
52
|
+
removeVote: (voteId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
|
|
53
|
+
addAnswer: (answerText: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
|
|
54
|
+
removeAnswer: (answerId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
|
|
55
|
+
queryAnswers: (params: PollAnswersQueryParams) => Promise<import("./types").StreamResponse<import(".").PollVotesResponse>>;
|
|
56
|
+
queryOptionVotes: (params: PollOptionVotesQueryParams) => Promise<import("./types").StreamResponse<import(".").PollVotesResponse>>;
|
|
60
57
|
}
|
|
61
|
-
export declare function extractPollData(pollResponse:
|
|
62
|
-
export declare function mapPollStateToResponse(poll: Poll):
|
|
63
|
-
export declare function extractPollEnrichedData(pollResponse:
|
|
58
|
+
export declare function extractPollData(pollResponse: Gen_PollResponseData): UpdatePollRequest;
|
|
59
|
+
export declare function mapPollStateToResponse(poll: Poll): PollResponse_old;
|
|
60
|
+
export declare function extractPollEnrichedData(pollResponse: Gen_PollResponseData): Omit<PollEnrichData, 'own_votes' | 'latest_answers'>;
|
|
64
61
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StreamChat } from './client';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreatePollRequest, LocalMessage, MessageResponse, PollSort, QueryPollsFilters, QueryPollsOptions } from './types';
|
|
3
3
|
import { Poll } from './poll';
|
|
4
4
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
5
5
|
export declare class PollManager extends WithSubscriptions {
|
|
@@ -11,7 +11,7 @@ export declare class PollManager extends WithSubscriptions {
|
|
|
11
11
|
get data(): Map<string, Poll>;
|
|
12
12
|
fromState: (id: string) => Poll | undefined;
|
|
13
13
|
registerSubscriptions: () => void;
|
|
14
|
-
createPoll: (poll:
|
|
14
|
+
createPoll: (poll: CreatePollRequest) => Promise<Poll | undefined>;
|
|
15
15
|
getPoll: (id: string) => Promise<Poll | undefined>;
|
|
16
16
|
queryPolls: (filter: QueryPollsFilters, sort?: PollSort, options?: QueryPollsOptions) => Promise<{
|
|
17
17
|
polls: (Poll | undefined)[];
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { ReminderTimer } from './ReminderTimer';
|
|
2
2
|
import { StateStore } from '../store';
|
|
3
3
|
import type { ReminderTimerConfig } from './ReminderTimer';
|
|
4
|
-
import type { MessageResponse,
|
|
4
|
+
import type { MessageResponse, ReminderResponseData, UserResponse } from '../types';
|
|
5
5
|
export declare const timeLeftMs: (remindAt: number) => number;
|
|
6
|
-
export type ReminderResponseBaseOrResponse =
|
|
7
|
-
user?: UserResponse;
|
|
8
|
-
message?: MessageResponse;
|
|
9
|
-
};
|
|
6
|
+
export type ReminderResponseBaseOrResponse = ReminderResponseData;
|
|
10
7
|
export type ReminderState = {
|
|
11
8
|
channel_cid: string;
|
|
12
9
|
created_at: Date;
|
|
@@ -4,17 +4,10 @@ import { ReminderPaginator } from '../pagination';
|
|
|
4
4
|
import { WithSubscriptions } from '../utils/WithSubscriptions';
|
|
5
5
|
import type { ReminderResponseBaseOrResponse } from './Reminder';
|
|
6
6
|
import type { StreamChat } from '../client';
|
|
7
|
-
import type { CreateReminderOptions, Event,
|
|
7
|
+
import type { CreateReminderOptions, Event, EventPayload, LocalMessage, MessageResponse } from '../types';
|
|
8
8
|
export declare const DEFAULT_REMINDER_MANAGER_CONFIG: ReminderManagerConfig;
|
|
9
9
|
type MessageId = string;
|
|
10
|
-
export type ReminderEvent = {
|
|
11
|
-
cid: string;
|
|
12
|
-
created_at: string;
|
|
13
|
-
message_id: MessageId;
|
|
14
|
-
reminder: ReminderResponse;
|
|
15
|
-
type: EventTypes;
|
|
16
|
-
user_id: string;
|
|
17
|
-
};
|
|
10
|
+
export type ReminderEvent = EventPayload<`reminder.${string}` | 'notification.reminder_due'>;
|
|
18
11
|
export type ReminderManagerState = {
|
|
19
12
|
reminders: Map<MessageId, Reminder>;
|
|
20
13
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseSearchSource } from './BaseSearchSource';
|
|
2
|
-
import type { ChannelFilters, ChannelOptions, ChannelSort, MessageFilters, MessageResponse, SearchMessageSort } from '../types';
|
|
2
|
+
import type { ChannelFilters, ChannelOptions, ChannelSort, MessageFilters, MessageResponse, SearchMessageSort, SearchPayload } from '../types';
|
|
3
3
|
import type { StreamChat } from '../client';
|
|
4
4
|
import type { SearchSourceOptions } from './types';
|
|
5
5
|
import { FilterBuilder, type FilterBuilderOptions } from '../pagination';
|
|
@@ -29,13 +29,13 @@ export type MessageSearchSourceFilterBuilderOptions<TContexts extends MessageSea
|
|
|
29
29
|
export declare class MessageSearchSource<TContexts extends MessageSearchSourceContexts = {}> extends BaseSearchSource<MessageResponse> {
|
|
30
30
|
readonly type = "messages";
|
|
31
31
|
private client;
|
|
32
|
-
messageSearchChannelFilters:
|
|
32
|
+
messageSearchChannelFilters: SearchPayload['filter_conditions'] | undefined;
|
|
33
33
|
messageSearchFilters: MessageFilters | undefined;
|
|
34
34
|
messageSearchSort: SearchMessageSort | undefined;
|
|
35
35
|
channelQueryFilters: ChannelFilters | undefined;
|
|
36
36
|
channelQuerySort: ChannelSort | undefined;
|
|
37
37
|
channelQueryOptions: Omit<ChannelOptions, 'limit' | 'offset'> | undefined;
|
|
38
|
-
messageSearchChannelFilterBuilder: FilterBuilder<
|
|
38
|
+
messageSearchChannelFilterBuilder: FilterBuilder<SearchPayload['filter_conditions'], MergeContext<BuiltInContexts['messageSearchChannel'], TContexts['messageSearchChannelContext']>>;
|
|
39
39
|
messageSearchFilterBuilder: FilterBuilder<MessageFilters, MergeContext<BuiltInContexts['messageSearch'], TContexts['messageSearchContext']>>;
|
|
40
40
|
channelQueryFilterBuilder: FilterBuilder<ChannelFilters, MergeContext<BuiltInContexts['channelQuery'], TContexts['channelQueryContext']>>;
|
|
41
41
|
constructor(client: StreamChat, options?: SearchSourceOptions, filterBuilderOptions?: MessageSearchSourceFilterBuilderOptions<TContexts>);
|
|
@@ -43,7 +43,7 @@ export declare class MessageSearchSource<TContexts extends MessageSearchSourceCo
|
|
|
43
43
|
items: never[];
|
|
44
44
|
next?: undefined;
|
|
45
45
|
} | {
|
|
46
|
-
items:
|
|
46
|
+
items: import("..").SearchResultMessage[];
|
|
47
47
|
next: string | undefined;
|
|
48
48
|
}>;
|
|
49
49
|
protected filterQueryResults(items: MessageResponse[]): MessageResponse[];
|
|
@@ -16,7 +16,7 @@ export declare class UserSearchSource<TFilterContext extends CustomContext = Cus
|
|
|
16
16
|
filterBuilder: FilterBuilder<UserFilters, UserSearchSourceFilterBuilderContext<TFilterContext>>;
|
|
17
17
|
constructor(client: StreamChat, options?: SearchSourceOptions, filterBuilderOptions?: FilterBuilderOptions<UserFilters, UserSearchSourceFilterBuilderContext<TFilterContext>>);
|
|
18
18
|
protected query(searchQuery: string): Promise<{
|
|
19
|
-
items:
|
|
19
|
+
items: import("..").FullUserResponse[];
|
|
20
20
|
}>;
|
|
21
21
|
protected filterQueryResults(items: UserResponse[]): UserResponse[];
|
|
22
22
|
}
|