stream-chat 10.0.0-rc.2 → 10.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -8
- package/dist/cjs/index.browser.js +15397 -12090
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +15349 -11991
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +15164 -11880
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +246 -6
- package/dist/types/CooldownTimer.d.ts +22 -8
- package/dist/types/EventHandlerPipeline.d.ts +12 -16
- package/dist/types/LiveLocationManager.d.ts +69 -6
- package/dist/types/api-client.d.ts +22 -9
- package/dist/types/channel.d.ts +550 -300
- package/dist/types/channel_state.d.ts +167 -22
- package/dist/types/client.d.ts +325 -305
- package/dist/types/configuration/ConfigController.d.ts +172 -0
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +192 -0
- package/dist/types/configuration/index.d.ts +3 -0
- package/dist/types/configuration/keys.d.ts +31 -0
- package/dist/types/configuration/shape.d.ts +58 -0
- package/dist/types/configuration/types.d.ts +206 -50
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +59 -0
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +1 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +24 -0
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +22 -0
- package/dist/types/configuration/utils/index.d.ts +1 -0
- package/dist/types/configuration/utils/serverAuthority.d.ts +49 -0
- package/dist/types/connection/ConnectionIdManager.d.ts +67 -0
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +164 -0
- package/dist/types/connection/index.d.ts +4 -0
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +153 -0
- package/dist/types/connection/networkConnection/index.d.ts +3 -0
- package/dist/types/connection/networkConnection/reporters.d.ts +43 -0
- package/dist/types/connection/networkConnection/types.d.ts +55 -0
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +204 -0
- package/dist/types/connection/wsConnection/WSConnection.d.ts +168 -0
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +55 -0
- package/dist/types/connection/wsConnection/config.d.ts +51 -0
- package/dist/types/connection/wsConnection/index.d.ts +4 -0
- package/dist/types/connection/wsConnection/types.d.ts +99 -0
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/entityStore/EntityStore.d.ts +160 -40
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +48 -29
- package/dist/types/entityStore/index.d.ts +0 -1
- package/dist/types/errors.d.ts +24 -4
- package/dist/types/formatMessageMemo.d.ts +5 -0
- package/dist/types/gen/chat/ChannelApi.d.ts +51 -23
- package/dist/types/gen/chat/ChatApi.d.ts +215 -168
- package/dist/types/gen/models/index.d.ts +2164 -557
- package/dist/types/gen/models/timestamp-guard.d.ts +22 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +39 -32
- package/dist/types/gen-imports.d.ts +1 -0
- package/dist/types/index.d.ts +20 -7
- package/dist/types/languageNames.d.ts +97 -0
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/messageComposer/CustomDataManager.d.ts +7 -1
- package/dist/types/messageComposer/LocationComposer.d.ts +10 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +11 -0
- package/dist/types/messageComposer/attachmentManager.d.ts +48 -10
- package/dist/types/messageComposer/attachmentUtils.d.ts +34 -0
- package/dist/types/messageComposer/configuration/commands.configuration.d.ts +1 -3
- package/dist/types/messageComposer/configuration/configuration.d.ts +9 -1
- package/dist/types/messageComposer/configuration/index.d.ts +0 -1
- package/dist/types/messageComposer/configuration/types.d.ts +57 -1
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +10 -4
- package/dist/types/messageComposer/messageComposer.d.ts +210 -14
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +20 -1
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +11 -0
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +2 -2
- package/dist/types/messageComposer/middleware/pollComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/middleware/pollComposer/state.d.ts +3 -2
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +9 -2
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +44 -0
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +2 -2
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +94 -229
- package/dist/types/messageComposer/pollComposer.d.ts +8 -3
- package/dist/types/messageComposer/textComposer.d.ts +9 -1
- package/dist/types/messageComposer/types.d.ts +7 -3
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +64 -8
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +48 -11
- package/dist/types/messageOperations/FailedSendCache.d.ts +34 -0
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +52 -6
- package/dist/types/messageOperations/MessageOperations.d.ts +94 -11
- package/dist/types/{entityStore → messageOperations}/applyReactionLocally.d.ts +8 -2
- package/dist/types/messageOperations/createMessageOperations.d.ts +11 -0
- package/dist/types/messageOperations/index.d.ts +7 -1
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +24 -0
- package/dist/types/messageOperations/sendOrdering.d.ts +17 -0
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +28 -0
- package/dist/types/messageOperations/types.d.ts +66 -1
- package/dist/types/middleware.d.ts +8 -0
- package/dist/types/moderation.d.ts +18 -4
- package/dist/types/notifications/NotificationManager.d.ts +43 -2
- package/dist/types/notifications/types.d.ts +55 -42
- package/dist/types/offline-support/offline_support_api.d.ts +128 -12
- package/dist/types/offline-support/offline_sync_manager.d.ts +26 -5
- package/dist/types/offline-support/queueableOperations.d.ts +106 -0
- package/dist/types/offline-support/types.d.ts +77 -28
- package/dist/types/pagination/FilterBuilder.d.ts +1 -18
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -1
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +21 -3
- package/dist/types/pagination/filterCompiler.d.ts +5 -0
- package/dist/types/pagination/paginators/BasePaginator.d.ts +331 -7
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +54 -11
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +283 -66
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +10 -9
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +17 -1
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +8 -8
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +57 -0
- package/dist/types/pagination/paginators/index.d.ts +1 -0
- package/dist/types/pagination/utility.normalization.d.ts +29 -2
- package/dist/types/poll.d.ts +41 -14
- package/dist/types/poll_manager.d.ts +3 -2
- package/dist/types/poll_optimistic_votes.d.ts +61 -0
- package/dist/types/reminders/Reminder.d.ts +17 -7
- package/dist/types/reminders/ReminderManager.d.ts +34 -6
- package/dist/types/search/BaseSearchSource.d.ts +50 -25
- package/dist/types/search/ChannelMemberSearchSource.d.ts +11 -6
- package/dist/types/search/ChannelSearchSource.d.ts +27 -5
- package/dist/types/search/MessageSearchSource.d.ts +36 -6
- package/dist/types/search/SearchController.d.ts +44 -11
- package/dist/types/search/UserSearchSource.d.ts +11 -5
- package/dist/types/search/types.d.ts +14 -1
- package/dist/types/signing.d.ts +0 -157
- package/dist/types/thread.d.ts +118 -62
- package/dist/types/thread_manager.d.ts +124 -35
- package/dist/types/token_manager.d.ts +5 -8
- package/dist/types/types.d.ts +138 -562
- package/dist/types/types.utility.d.ts +8 -0
- package/dist/types/upload-utils.d.ts +20 -0
- package/dist/types/uploadManager.d.ts +50 -2
- package/dist/types/utils/FixedSizeQueueCache.d.ts +2 -0
- package/dist/types/utils/WithSubscriptions.d.ts +1 -1
- package/dist/types/utils/objectPath.d.ts +49 -0
- package/dist/types/utils/time.d.ts +85 -0
- package/dist/types/utils.d.ts +63 -40
- package/package.json +22 -33
- package/src/ChannelManager.ts +561 -109
- package/src/CooldownTimer.ts +55 -45
- package/src/EventHandlerPipeline.ts +13 -23
- package/src/LiveLocationManager.ts +191 -37
- package/src/api-client.ts +144 -53
- package/src/channel.ts +1573 -1050
- package/src/channel_state.ts +239 -129
- package/src/client.ts +843 -892
- package/src/client_state.ts +2 -2
- package/src/configuration/ConfigController.ts +298 -0
- package/src/configuration/InstanceConfigurationRegistry.ts +430 -0
- package/src/configuration/index.ts +7 -0
- package/src/configuration/keys.ts +86 -0
- package/src/configuration/shape.ts +776 -0
- package/src/configuration/types.ts +218 -60
- package/src/configuration/utils/applyInstanceConfiguration.ts +184 -0
- package/src/configuration/utils/copyConfigPatch.ts +61 -0
- package/src/configuration/utils/declarativeSlices.ts +81 -0
- package/src/configuration/utils/deepFreezeConfig.ts +33 -0
- package/src/configuration/utils/index.ts +5 -0
- package/src/configuration/utils/serverAuthority.ts +146 -0
- package/src/connection/ConnectionIdManager.ts +153 -0
- package/src/connection/ConnectionRecoveryManager.ts +371 -0
- package/src/connection/index.ts +4 -0
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +281 -0
- package/src/connection/networkConnection/index.ts +3 -0
- package/src/connection/networkConnection/reporters.ts +85 -0
- package/src/connection/networkConnection/types.ts +60 -0
- package/src/{connection.ts → connection/wsConnection/StableWSConnection.ts} +242 -151
- package/src/connection/wsConnection/WSConnection.ts +345 -0
- package/src/connection/wsConnection/WSConnectionFallback.ts +259 -0
- package/src/connection/wsConnection/config.ts +108 -0
- package/src/connection/wsConnection/index.ts +4 -0
- package/src/connection/wsConnection/types.ts +101 -0
- package/src/constants.ts +5 -3
- package/src/entityStore/EntityStore.ts +350 -10
- package/src/entityStore/StoreBackedItemIndex.ts +66 -37
- package/src/entityStore/index.ts +0 -1
- package/src/errors.ts +40 -7
- package/src/formatMessageMemo.ts +23 -0
- package/src/gen/chat/ChannelApi.ts +230 -44
- package/src/gen/chat/ChatApi.ts +1047 -1745
- package/src/gen/models/index.ts +2378 -3721
- package/src/gen/models/timestamp-guard.ts +27 -0
- package/src/gen/moderation/ModerationApi.ts +218 -388
- package/src/gen-imports.ts +1 -0
- package/src/index.ts +82 -6
- package/src/languageNames.ts +103 -0
- package/src/logger.ts +1 -1
- package/src/messageComposer/CustomDataManager.ts +10 -1
- package/src/messageComposer/LocationComposer.ts +68 -20
- package/src/messageComposer/attachmentIdentity.ts +39 -0
- package/src/messageComposer/attachmentManager.ts +191 -68
- package/src/messageComposer/attachmentUtils.ts +58 -0
- package/src/messageComposer/configuration/commands.configuration.ts +1 -26
- package/src/messageComposer/configuration/configuration.ts +22 -3
- package/src/messageComposer/configuration/index.ts +0 -1
- package/src/messageComposer/configuration/types.ts +58 -1
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/linkPreviewsManager.ts +16 -10
- package/src/messageComposer/messageComposer.ts +487 -98
- package/src/messageComposer/middleware/attachmentManager/postUpload/AttachmentPostUploadMiddlewareExecutor.ts +1 -1
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +58 -33
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +7 -2
- package/src/messageComposer/middleware/attachmentManager/preUpload/blockedUploadNotification.ts +3 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +98 -1
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +20 -10
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +7 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +2 -7
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +11 -6
- package/src/messageComposer/middleware/pollComposer/index.ts +1 -0
- package/src/messageComposer/middleware/pollComposer/state.ts +43 -11
- package/src/messageComposer/middleware/pollComposer/types.ts +9 -2
- package/src/messageComposer/middleware/pollComposer/validation.ts +76 -0
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +1 -2
- package/src/messageComposer/middleware/textComposer/mentions.ts +91 -39
- package/src/messageComposer/pollComposer.ts +11 -3
- package/src/messageComposer/textComposer.ts +36 -4
- package/src/messageComposer/types.ts +19 -14
- package/src/messageDelivery/MessageDeliveryReporter.ts +154 -53
- package/src/messageDelivery/MessageReceiptsTracker.ts +136 -64
- package/src/messageOperations/FailedSendCache.ts +90 -0
- package/src/messageOperations/MessageOperationStatePolicy.ts +269 -27
- package/src/messageOperations/MessageOperations.ts +340 -136
- package/src/{entityStore → messageOperations}/applyReactionLocally.ts +10 -3
- package/src/messageOperations/createMessageOperations.ts +192 -0
- package/src/messageOperations/index.ts +7 -0
- package/src/messageOperations/reflectReactionEvent.ts +51 -0
- package/src/messageOperations/sendOrdering.ts +28 -0
- package/src/messageOperations/settlePendingAttachmentUploads.ts +110 -0
- package/src/messageOperations/types.ts +74 -0
- package/src/middleware.ts +11 -0
- package/src/moderation.ts +47 -24
- package/src/notifications/NotificationManager.ts +73 -3
- package/src/notifications/configuration.ts +10 -8
- package/src/notifications/types.ts +58 -42
- package/src/offline-support/offline_support_api.ts +380 -197
- package/src/offline-support/offline_sync_manager.ts +105 -32
- package/src/offline-support/queueableOperations.ts +270 -0
- package/src/offline-support/types.ts +85 -39
- package/src/pagination/FilterBuilder.ts +1 -22
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +11 -7
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +25 -7
- package/src/pagination/filterCompiler.ts +17 -0
- package/src/pagination/paginators/BasePaginator.ts +731 -81
- package/src/pagination/paginators/ChannelPaginator.ts +210 -102
- package/src/pagination/paginators/MessageIntervalPaginator.ts +703 -193
- package/src/pagination/paginators/MessagePaginator.ts +45 -36
- package/src/pagination/paginators/PinnedMessagePaginator.ts +74 -28
- package/src/pagination/paginators/ReminderPaginator.ts +15 -13
- package/src/pagination/paginators/ThreadPaginator.ts +181 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +8 -1
- package/src/pagination/paginators/index.ts +1 -0
- package/src/pagination/utility.normalization.ts +37 -9
- package/src/poll.ts +189 -112
- package/src/poll_manager.ts +14 -8
- package/src/poll_optimistic_votes.ts +335 -0
- package/src/reminders/Reminder.ts +34 -16
- package/src/reminders/ReminderManager.ts +68 -41
- package/src/reminders/ReminderTimer.ts +7 -6
- package/src/search/BaseSearchSource.ts +133 -40
- package/src/search/ChannelMemberSearchSource.ts +27 -18
- package/src/search/ChannelSearchSource.ts +61 -7
- package/src/search/MessageSearchSource.ts +133 -28
- package/src/search/SearchController.ts +93 -16
- package/src/search/UserSearchSource.ts +27 -13
- package/src/search/types.ts +14 -1
- package/src/signing.ts +1 -315
- package/src/thread.ts +503 -511
- package/src/thread_manager.ts +339 -204
- package/src/token_manager.ts +12 -32
- package/src/types.ts +159 -780
- package/src/types.utility.ts +14 -0
- package/src/upload-utils.ts +53 -0
- package/src/uploadManager.ts +85 -7
- package/src/utils/FixedSizeQueueCache.ts +5 -0
- package/src/utils/WithSubscriptions.ts +1 -1
- package/src/utils/objectPath.ts +67 -0
- package/src/utils/time.ts +104 -0
- package/src/utils.ts +209 -157
- package/dist/types/base64.d.ts +0 -2
- package/dist/types/configuration/InstanceConfigurationService.d.ts +0 -26
- package/dist/types/connection.d.ts +0 -146
- package/dist/types/connection_fallback.d.ts +0 -42
- package/dist/types/gen/model-decoders/decoders.d.ts +0 -3
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +0 -6
- package/dist/types/insights.d.ts +0 -58
- package/dist/types/pagination/utility.queryChannel.d.ts +0 -26
- package/dist/types/permissions.d.ts +0 -55
- package/dist/types/store.d.ts +0 -125
- package/src/base64.ts +0 -78
- package/src/configuration/InstanceConfigurationService.ts +0 -73
- package/src/connection_fallback.ts +0 -215
- package/src/gen/model-decoders/decoders.ts +0 -2680
- package/src/gen/model-decoders/event-decoder-mapping.ts +0 -198
- package/src/insights.ts +0 -83
- package/src/pagination/utility.queryChannel.ts +0 -84
- package/src/permissions.ts +0 -102
- package/src/store.ts +0 -304
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export declare function asArray(v: any): any[];
|
|
2
2
|
export declare function isISODateString(x: any): x is string;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Brings anything date-shaped into unix **nanoseconds**, the unit item fields carry, so a filter or
|
|
5
|
+
* sort can compare an operand against a value.
|
|
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.
|
|
15
|
+
*/
|
|
16
|
+
export declare function toEpochNanos(x: any): number | null;
|
|
4
17
|
export declare function toNumberLike(x: any): number | null;
|
|
5
18
|
export declare function normalizeComparedValues(a: any, b: any): {
|
|
6
19
|
kind: string;
|
|
@@ -13,6 +26,20 @@ export declare function arraysEqualAsSets(aList: unknown[], bList: unknown[]): b
|
|
|
13
26
|
export declare function normalizeString(s: string): string;
|
|
14
27
|
export declare function normalizeStringAccentInsensitive(s: string): string;
|
|
15
28
|
export declare function tokenize(s: string): string[];
|
|
16
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Reads `a.b.c` off an item, for the filter and sort compilers.
|
|
31
|
+
*
|
|
32
|
+
* Descends through **anything indexable** — plain objects, arrays (`items.0.id`, `items.length`) and class
|
|
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.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveDotPathValue(obj: any, path: string): unknown;
|
|
17
44
|
export declare function isIterableButNotString(v: unknown): v is Iterable<unknown>;
|
|
18
45
|
export declare function toIterableArray(v: unknown): unknown[];
|
package/dist/types/poll.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
2
|
import type { StreamChat } from './client';
|
|
3
|
-
import type { EventPayload, PartialPollUpdate,
|
|
4
|
-
import type { PollResponseData as Gen_PollResponseData } from './gen/models';
|
|
3
|
+
import type { CreatePollOptionRequest, EventPayload, PartialPollUpdate, PollResponseData, PollVoteResponseData, QueryVotesFilters, QueryVotesOptions, RequireLiteral, SortParamRequest, UpdatePollOptionRequest, UpdatePollRequest, UserResponse } from './types';
|
|
4
|
+
import type { PollResponseData as Gen_PollResponseData, TimestampNS } from './gen/models';
|
|
5
5
|
export declare const isVoteAnswer: (vote: any | undefined) => vote is RequireLiteral<PollVoteResponseData, "answer_text" | "is_answer">;
|
|
6
6
|
export type PollAnswersQueryParams = {
|
|
7
7
|
filter?: QueryVotesFilters;
|
|
8
8
|
options?: QueryVotesOptions;
|
|
9
|
-
sort?:
|
|
9
|
+
sort?: SortParamRequest[];
|
|
10
10
|
};
|
|
11
11
|
export type PollOptionVotesQueryParams = {
|
|
12
12
|
filter: {
|
|
13
13
|
option_id: string;
|
|
14
14
|
} & QueryVotesFilters;
|
|
15
15
|
options?: QueryVotesOptions;
|
|
16
|
-
sort?:
|
|
16
|
+
sort?: SortParamRequest[];
|
|
17
17
|
};
|
|
18
18
|
type OptionId = string;
|
|
19
|
-
export type PollState = Omit<
|
|
20
|
-
|
|
19
|
+
export type PollState = Omit<PollResponseData, 'own_votes' | 'id'> & {
|
|
20
|
+
/** Unix nanoseconds, matching every API timestamp. */
|
|
21
|
+
lastActivityAt: TimestampNS;
|
|
21
22
|
maxVotedOptionIds: OptionId[];
|
|
22
23
|
ownVotesByOptionId: Record<OptionId, PollVoteResponseData>;
|
|
23
24
|
ownAnswer?: PollVoteResponseData;
|
|
@@ -30,32 +31,58 @@ export declare class Poll {
|
|
|
30
31
|
readonly state: StateStore<PollState>;
|
|
31
32
|
id: string;
|
|
32
33
|
private client;
|
|
34
|
+
private optimisticVotes;
|
|
35
|
+
private closeConfirmed;
|
|
33
36
|
constructor({ client, poll }: PollInitOptions);
|
|
34
37
|
private getInitialStateFromPollResponse;
|
|
35
38
|
private upsertOfflineDb;
|
|
36
39
|
reinitializeState: (poll: PollInitOptions["poll"]) => void;
|
|
40
|
+
private updateFromVoteEvent;
|
|
37
41
|
get data(): PollState;
|
|
38
42
|
handlePollUpdated: (event: EventPayload<"poll.updated">) => void;
|
|
39
43
|
handlePollClosed: (event: EventPayload<"poll.closed">) => void;
|
|
40
44
|
handleVoteCasted: (event: EventPayload<"poll.vote_casted">) => void;
|
|
41
45
|
handleVoteChanged: (event: EventPayload<"poll.vote_changed">) => void;
|
|
42
46
|
handleVoteRemoved: (event: EventPayload<"poll.vote_removed">) => void;
|
|
43
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Puts an updated user (new name or image) into the votes, answers and creator this poll keeps,
|
|
49
|
+
* so voter avatars show it. Each vote is replaced, not edited in place, and everything goes out in
|
|
50
|
+
* one state update; nothing is published when the poll doesn't contain the user. An option whose
|
|
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.
|
|
53
|
+
*/
|
|
54
|
+
handleUserUpdated: (user: UserResponse) => void;
|
|
55
|
+
query: (id: string) => Promise<PollResponseData>;
|
|
44
56
|
update: (data: Exclude<UpdatePollRequest, "id">) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
45
57
|
partialUpdate: (partialPollObject: PartialPollUpdate) => Promise<import("./types").StreamResponse<import(".").PollResponse>>;
|
|
46
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Closes the poll. The poll is marked as closed optimistically and the change is
|
|
60
|
+
* reverted if the request fails, unless the server confirmed the close meanwhile.
|
|
61
|
+
* Does nothing if the poll is already closed.
|
|
62
|
+
*/
|
|
63
|
+
close: () => Promise<import("./types").StreamResponse<import(".").PollResponse> | undefined>;
|
|
47
64
|
delete: () => Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
48
|
-
createOption: (option:
|
|
49
|
-
updateOption: (option:
|
|
65
|
+
createOption: (option: CreatePollOptionRequest) => Promise<import("./types").StreamResponse<import(".").PollOptionResponse>>;
|
|
66
|
+
updateOption: (option: UpdatePollOptionRequest) => Promise<import("./types").StreamResponse<import(".").PollOptionResponse>>;
|
|
50
67
|
deleteOption: (option_id: string) => Promise<import("./types").StreamResponse<import(".").Response>>;
|
|
68
|
+
/**
|
|
69
|
+
* Casts a vote for an option. The vote is shown right away through a local placeholder vote,
|
|
70
|
+
* which the server's vote replaces once the WS events of all pending vote changes arrived.
|
|
71
|
+
* If the request fails, the change is reverted.
|
|
72
|
+
*/
|
|
51
73
|
castVote: (optionId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
52
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Removes a vote. The vote is removed right away and restored if the request fails. Vote
|
|
76
|
+
* requests are sent in order, so removing a vote whose cast is not confirmed yet uses the vote
|
|
77
|
+
* id from the cast's response; if that cast failed, there is nothing to remove.
|
|
78
|
+
*/
|
|
79
|
+
removeVote: (voteId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
53
80
|
addAnswer: (answerText: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
|
|
54
81
|
removeAnswer: (answerId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse>>;
|
|
55
82
|
queryAnswers: (params: PollAnswersQueryParams) => Promise<import("./types").StreamResponse<import(".").PollVotesResponse>>;
|
|
56
83
|
queryOptionVotes: (params: PollOptionVotesQueryParams) => Promise<import("./types").StreamResponse<import(".").PollVotesResponse>>;
|
|
57
84
|
}
|
|
58
85
|
export declare function extractPollData(pollResponse: Gen_PollResponseData): UpdatePollRequest;
|
|
59
|
-
export declare function mapPollStateToResponse(poll: Poll):
|
|
60
|
-
export declare function extractPollEnrichedData(pollResponse: Gen_PollResponseData):
|
|
86
|
+
export declare function mapPollStateToResponse(poll: Poll, state?: PollState): PollResponseData;
|
|
87
|
+
export declare function extractPollEnrichedData(pollResponse: Gen_PollResponseData): Pick<Gen_PollResponseData, 'answers_count' | 'latest_votes_by_option' | 'vote_count' | 'vote_counts_by_option'>;
|
|
61
88
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StreamChat } from './client';
|
|
2
|
-
import type { CreatePollRequest, LocalMessage, MessageResponse,
|
|
2
|
+
import type { CreatePollRequest, LocalMessage, MessageResponse, QueryPollsFilters, QueryPollsOptions, SortParamRequest } from './types';
|
|
3
3
|
import { Poll } from './poll';
|
|
4
4
|
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
5
5
|
export declare class PollManager extends WithSubscriptions {
|
|
@@ -13,7 +13,7 @@ export declare class PollManager extends WithSubscriptions {
|
|
|
13
13
|
registerSubscriptions: () => void;
|
|
14
14
|
createPoll: (poll: CreatePollRequest) => Promise<Poll | undefined>;
|
|
15
15
|
getPoll: (id: string) => Promise<Poll | undefined>;
|
|
16
|
-
queryPolls: (filter: QueryPollsFilters, sort?:
|
|
16
|
+
queryPolls: (filter: QueryPollsFilters, sort?: SortParamRequest[], options?: QueryPollsOptions) => Promise<{
|
|
17
17
|
polls: (Poll | undefined)[];
|
|
18
18
|
next: string | undefined;
|
|
19
19
|
}>;
|
|
@@ -24,5 +24,6 @@ export declare class PollManager extends WithSubscriptions {
|
|
|
24
24
|
private subscribeVoteCasted;
|
|
25
25
|
private subscribeVoteChanged;
|
|
26
26
|
private subscribeVoteRemoved;
|
|
27
|
+
private subscribeUserUpdated;
|
|
27
28
|
private subscribeMessageNew;
|
|
28
29
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { StreamChat } from './client';
|
|
2
|
+
import type { Poll, PollState } from './poll';
|
|
3
|
+
import type { PollResponseData, PollVoteResponseData } from './types';
|
|
4
|
+
type OptionId = string;
|
|
5
|
+
/**
|
|
6
|
+
* Optimistic updates for the current user's votes on a poll. Vote changes are shown right away.
|
|
7
|
+
* While any of them is not confirmed by its WS event, vote events are only stored, as the server
|
|
8
|
+
* state they carry does not contain the pending changes yet. Once all are confirmed (a failed
|
|
9
|
+
* request counts as confirmed), the server's vote state is shown, which also reverts failed changes.
|
|
10
|
+
* Vote requests are sent one after another, so the server applies them in the order they were made.
|
|
11
|
+
* A lost WS event is recovered from after CATCH_UP_TIMEOUT_MS (see applySucceededChanges).
|
|
12
|
+
*/
|
|
13
|
+
export declare class OptimisticPollVotes {
|
|
14
|
+
private serverVoteState;
|
|
15
|
+
private pendingCount;
|
|
16
|
+
private succeededChanges;
|
|
17
|
+
private readonly requestTag;
|
|
18
|
+
private catchUpTimeout?;
|
|
19
|
+
private readonly client;
|
|
20
|
+
private readonly poll;
|
|
21
|
+
constructor({ client, poll }: {
|
|
22
|
+
client: StreamChat;
|
|
23
|
+
poll: Poll;
|
|
24
|
+
});
|
|
25
|
+
get serverOwnVotes(): Record<string, PollVoteResponseData>;
|
|
26
|
+
withServerVotes: (pollState: PollState) => PollState;
|
|
27
|
+
/**
|
|
28
|
+
* Casts a vote for an option, shown right away through a placeholder vote. In polls with unique
|
|
29
|
+
* votes, it replaces the existing own votes.
|
|
30
|
+
*/
|
|
31
|
+
castVote: (optionId: OptionId, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
32
|
+
removeVote: (voteId: string, messageId: string) => Promise<import("./types").StreamResponse<import(".").PollVoteResponse> | undefined>;
|
|
33
|
+
private send;
|
|
34
|
+
handleVoteEvent: (poll: PollResponseData, { confirmsOwnVote, ownVotesByOptionId, }: {
|
|
35
|
+
confirmsOwnVote: boolean;
|
|
36
|
+
ownVotesByOptionId: Record<OptionId, PollVoteResponseData>;
|
|
37
|
+
}) => Partial<PollState>;
|
|
38
|
+
reset: (pollState: PollState) => void;
|
|
39
|
+
private track;
|
|
40
|
+
private settleWithoutEvent;
|
|
41
|
+
private createPlaceholderVote;
|
|
42
|
+
/**
|
|
43
|
+
* The server id of a vote to remove, once everything sent before the removal has finished. Casts
|
|
44
|
+
* and removals of an option alternate, so the option's last succeeded change tells: a cast is the
|
|
45
|
+
* vote being removed (e.g. a placeholder), a removal means the cast in between failed. Without
|
|
46
|
+
* one, the server's own vote of the option is the vote being removed.
|
|
47
|
+
*/
|
|
48
|
+
private getServerVoteId;
|
|
49
|
+
private takeServerVoteState;
|
|
50
|
+
private scheduleCatchUp;
|
|
51
|
+
/**
|
|
52
|
+
* A WS event of an own vote change got lost, so the server's own votes are stale. All requests
|
|
53
|
+
* have finished (the timeout starts once nothing is left to send and a new request cancels it),
|
|
54
|
+
* so applying the succeeded changes in order gives the server's own votes (changes whose events
|
|
55
|
+
* did arrive end up the same). They are shown with the vote counts of the last WS event, which
|
|
56
|
+
* contain the other users' votes too.
|
|
57
|
+
*/
|
|
58
|
+
private applySucceededChanges;
|
|
59
|
+
}
|
|
60
|
+
export declare function getMaxVotedOptionIds(voteCountsByOption: PollResponseData['vote_counts_by_option']): string[];
|
|
61
|
+
export {};
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
import { ReminderTimer } from './ReminderTimer';
|
|
2
|
-
import { StateStore } from '
|
|
2
|
+
import { StateStore } from '@stream-io/state-store';
|
|
3
3
|
import type { ReminderTimerConfig } from './ReminderTimer';
|
|
4
|
-
import type { MessageResponse, ReminderResponseData, UserResponse } from '../types';
|
|
5
|
-
|
|
4
|
+
import type { MessageResponse, ReminderResponseData, TimestampNS, UserResponse } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Milliseconds until `remindAt`, negative once it has passed.
|
|
7
|
+
*
|
|
8
|
+
* @param remindAt - Unix nanoseconds, as the API sends it. The subtraction happens in the wire unit
|
|
9
|
+
* and is converted once, so the returned duration stays in the milliseconds `setTimeout` speaks.
|
|
10
|
+
*/
|
|
11
|
+
export declare const timeLeftMs: (remindAt: TimestampNS) => number;
|
|
6
12
|
export type ReminderResponseBaseOrResponse = ReminderResponseData;
|
|
7
13
|
export type ReminderState = {
|
|
8
14
|
channel_cid: string;
|
|
9
|
-
|
|
15
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
16
|
+
created_at: TimestampNS;
|
|
10
17
|
message: MessageResponse | null;
|
|
11
18
|
message_id: string;
|
|
12
|
-
|
|
19
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
20
|
+
remind_at: TimestampNS | null;
|
|
21
|
+
/** A duration, so milliseconds — see {@link timeLeftMs}. */
|
|
13
22
|
timeLeftMs: number | null;
|
|
14
|
-
|
|
23
|
+
/** Unix nanoseconds, as the API sends it. */
|
|
24
|
+
updated_at: TimestampNS;
|
|
15
25
|
user: UserResponse | null;
|
|
16
26
|
user_id: string;
|
|
17
27
|
};
|
|
@@ -25,7 +35,7 @@ export declare class Reminder {
|
|
|
25
35
|
constructor({ data, config }: ReminderOptions);
|
|
26
36
|
static toStateValue: (data: ReminderResponseBaseOrResponse) => ReminderState;
|
|
27
37
|
get id(): string;
|
|
28
|
-
get remindAt():
|
|
38
|
+
get remindAt(): TimestampNS | null;
|
|
29
39
|
get timeLeftMs(): number | null;
|
|
30
40
|
setState: (data: ReminderResponseBaseOrResponse) => void;
|
|
31
41
|
refreshTimeLeft: () => void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Reminder } from './Reminder';
|
|
2
|
-
import { StateStore } from '
|
|
2
|
+
import { StateStore } from '@stream-io/state-store';
|
|
3
3
|
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 {
|
|
7
|
+
import type { ChatApi } from '../gen/chat/ChatApi';
|
|
8
|
+
import type { Event, EventPayload, LocalMessage, MessageResponse } from '../types';
|
|
8
9
|
export declare const DEFAULT_REMINDER_MANAGER_CONFIG: ReminderManagerConfig;
|
|
9
10
|
type MessageId = string;
|
|
10
11
|
export type ReminderEvent = EventPayload<`reminder.${string}` | 'notification.reminder_due'>;
|
|
@@ -21,11 +22,38 @@ export type ReminderManagerOptions = {
|
|
|
21
22
|
};
|
|
22
23
|
export declare class ReminderManager extends WithSubscriptions {
|
|
23
24
|
private client;
|
|
24
|
-
|
|
25
|
+
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
26
|
+
private readonly configController;
|
|
27
|
+
/**
|
|
28
|
+
* Resolved configuration, as a store — the shape every configurable class exposes
|
|
29
|
+
* (`configState` / `config` / `updateConfig`). Delegates rather than holding a copy, so the field and
|
|
30
|
+
* the controller's store cannot drift.
|
|
31
|
+
*/
|
|
32
|
+
get configState(): StateStore<ReminderManagerConfig>;
|
|
25
33
|
state: StateStore<ReminderManagerState>;
|
|
26
34
|
paginator: ReminderPaginator;
|
|
27
35
|
constructor({ client, config }: ReminderManagerOptions);
|
|
36
|
+
/**
|
|
37
|
+
* The current resolved configuration. `Readonly` because the value is the store's live object —
|
|
38
|
+
* assigning to a field of it would change state without notifying anyone. Use {@link updateConfig}.
|
|
39
|
+
*/
|
|
40
|
+
get config(): Readonly<ReminderManagerConfig>;
|
|
28
41
|
updateConfig(config: Partial<ReminderManagerConfig>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Rebuilds the resolved configuration from package defaults plus the declarative slice.
|
|
44
|
+
*
|
|
45
|
+
* The derivation entry point every configurable entity exposes, so the owner routes a slice here and
|
|
46
|
+
* knows nothing about ReminderManager's defaults or merge semantics. This logic used to live in the owner,
|
|
47
|
+
* which is how `reset()` became a no-op for the client key (F4) and how a registered
|
|
48
|
+
* `notifications.sortComparator` became unremovable (G8) — an owner writing another object's
|
|
49
|
+
* derivation gets that object's rules wrong sooner or later.
|
|
50
|
+
*
|
|
51
|
+
* Routed through {@link updateConfig} rather than replacing the store, which is exact here because
|
|
52
|
+
* every field of `ReminderManagerConfig` is required and present in the defaults, so a patch naming all of
|
|
53
|
+
* them amounts to a replacement. `NotificationManager` cannot do this — its `sortComparator` is
|
|
54
|
+
* optional with no default, so a patch can never remove one — which is why it replaces outright.
|
|
55
|
+
*/
|
|
56
|
+
initializeConfig(config?: Partial<ReminderManagerConfig>): void;
|
|
29
57
|
get stopTimerRefreshBoundaryMs(): number;
|
|
30
58
|
get scheduledOffsetsMs(): number[];
|
|
31
59
|
get reminders(): Map<string, Reminder>;
|
|
@@ -48,9 +76,9 @@ export declare class ReminderManager extends WithSubscriptions {
|
|
|
48
76
|
private subscribeNotificationReminderDue;
|
|
49
77
|
private subscribePaginatorStateUpdated;
|
|
50
78
|
private subscribeConfigStateUpdated;
|
|
51
|
-
upsertReminder: (
|
|
52
|
-
createReminder: (
|
|
53
|
-
updateReminder: (
|
|
79
|
+
upsertReminder: (...args: Parameters<ChatApi["createReminder"]>) => Promise<Reminder | undefined>;
|
|
80
|
+
createReminder: (...args: Parameters<ChatApi["createReminder"]>) => Promise<Reminder | undefined>;
|
|
81
|
+
updateReminder: (...args: Parameters<ChatApi["updateReminder"]>) => Promise<Reminder | undefined>;
|
|
54
82
|
deleteReminder: (messageId: MessageId) => Promise<void>;
|
|
55
83
|
queryNextReminders: () => Promise<void>;
|
|
56
84
|
queryPreviousReminders: () => Promise<void>;
|
|
@@ -1,14 +1,32 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
2
|
import { type DebouncedFunc } from '../utils';
|
|
3
3
|
import type { QueryReturnValue, SearchSourceOptions, SearchSourceState, SearchSourceType } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Passed to a search source's `query()`. Carries a cancellation handle and makes no
|
|
6
|
+
* claim that the query performs a request: a source may resolve from local data and
|
|
7
|
+
* ignore the signal. Where a source does issue requests, forward this straight through
|
|
8
|
+
* as the request options.
|
|
9
|
+
*/
|
|
10
|
+
export type SearchQueryOptions = {
|
|
11
|
+
/** Aborted once a newer query supersedes this one. */
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
};
|
|
4
14
|
export type DebounceOptions = {
|
|
5
|
-
|
|
15
|
+
/** Applies to both short and long queries unless overridden by the options below. */
|
|
16
|
+
debounceMs?: number;
|
|
17
|
+
shortQueryDebounceMs?: number;
|
|
18
|
+
longQueryDebounceMs?: number;
|
|
19
|
+
shortQueryMaxLength?: number;
|
|
6
20
|
};
|
|
7
|
-
type DebouncedExecQueryFunction = DebouncedFunc<(searchString?: string) => Promise<void>>;
|
|
8
21
|
interface ISearchSource<T = any> {
|
|
9
22
|
activate(): void;
|
|
10
23
|
canExecuteQuery(newSearchString?: string): boolean;
|
|
11
24
|
deactivate(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Releases what the source holds outside itself. Optional; a source that holds nothing outside
|
|
27
|
+
* itself leaves it out.
|
|
28
|
+
*/
|
|
29
|
+
dispose?(): void;
|
|
12
30
|
readonly hasNext: boolean;
|
|
13
31
|
readonly hasResults: boolean;
|
|
14
32
|
readonly initialState: SearchSourceState<T>;
|
|
@@ -18,6 +36,8 @@ interface ISearchSource<T = any> {
|
|
|
18
36
|
readonly lastQueryError: Error | undefined;
|
|
19
37
|
readonly next: string | undefined | null;
|
|
20
38
|
readonly offset: number | undefined;
|
|
39
|
+
/** Takes again what {@link ISearchSource.dispose} released. Optional, like `dispose`. */
|
|
40
|
+
registerSubscriptions?(): void;
|
|
21
41
|
resetState(): void;
|
|
22
42
|
readonly searchQuery: string;
|
|
23
43
|
readonly state: StateStore<SearchSourceState<T>>;
|
|
@@ -33,28 +53,36 @@ export interface SearchSourceSync<T = any> extends ISearchSource<T> {
|
|
|
33
53
|
setDebounceOptions(options: DebounceOptions): void;
|
|
34
54
|
search(text?: string): void;
|
|
35
55
|
}
|
|
36
|
-
declare abstract class BaseSearchSourceBase<T
|
|
56
|
+
declare abstract class BaseSearchSourceBase<T, R extends void | Promise<void>> implements ISearchSource<T> {
|
|
37
57
|
state: StateStore<SearchSourceState<T>>;
|
|
38
58
|
pageSize: number;
|
|
39
59
|
protected allowEmptySearchString: boolean;
|
|
40
60
|
protected resetOnNewSearchQuery: boolean;
|
|
61
|
+
protected shortQueryDebounceMs: number;
|
|
62
|
+
protected longQueryDebounceMs: number;
|
|
63
|
+
protected shortQueryMaxLength: number;
|
|
64
|
+
protected searchDebounced: DebouncedFunc<(searchString?: string) => R>;
|
|
41
65
|
abstract readonly type: SearchSourceType;
|
|
42
66
|
protected constructor(options?: SearchSourceOptions);
|
|
67
|
+
abstract executeQuery(newSearchString?: string): R;
|
|
68
|
+
setDebounceOptions: (options?: DebounceOptions) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Short queries match too much and are slow server-side, so they get a longer debounce.
|
|
71
|
+
* Resolved per call, which is what lets the interval switch as the user keeps typing.
|
|
72
|
+
*/
|
|
73
|
+
protected getDebounceMs: (searchString?: string) => number;
|
|
74
|
+
/**
|
|
75
|
+
* A new search query preempts an in-flight one; pagination waits for it to finish
|
|
76
|
+
* and needs a next page to fetch.
|
|
77
|
+
*/
|
|
78
|
+
protected canDispatchQuery(hasNewSearchQuery: boolean): boolean;
|
|
79
|
+
search: (searchQuery?: string) => R | undefined;
|
|
43
80
|
get lastQueryError(): Error | undefined;
|
|
44
81
|
get hasNext(): boolean;
|
|
45
82
|
get hasResults(): boolean;
|
|
46
83
|
get isActive(): boolean;
|
|
47
84
|
get isLoading(): boolean;
|
|
48
|
-
get initialState():
|
|
49
|
-
hasNext: boolean;
|
|
50
|
-
isActive: boolean;
|
|
51
|
-
isLoading: boolean;
|
|
52
|
-
items: undefined;
|
|
53
|
-
lastQueryError: undefined;
|
|
54
|
-
next: undefined;
|
|
55
|
-
offset: number;
|
|
56
|
-
searchQuery: string;
|
|
57
|
-
};
|
|
85
|
+
get initialState(): SearchSourceState<T>;
|
|
58
86
|
get items(): T[] | undefined;
|
|
59
87
|
get next(): string | null | undefined;
|
|
60
88
|
get offset(): number | undefined;
|
|
@@ -72,24 +100,21 @@ declare abstract class BaseSearchSourceBase<T> implements ISearchSource<T> {
|
|
|
72
100
|
resetState(): void;
|
|
73
101
|
resetStateAndActivate(): void;
|
|
74
102
|
}
|
|
75
|
-
export declare abstract class BaseSearchSource<T> extends BaseSearchSourceBase<T
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
protected abstract query(searchQuery: string): Promise<QueryReturnValue<T>>;
|
|
103
|
+
export declare abstract class BaseSearchSource<T> extends BaseSearchSourceBase<T, Promise<void>> implements SearchSource<T> {
|
|
104
|
+
/** Aborts the in-flight request, if any, once a newer query is dispatched. */
|
|
105
|
+
protected queryAbortController: AbortController | null;
|
|
106
|
+
protected abstract query(searchQuery: string, options?: SearchQueryOptions): Promise<QueryReturnValue<T>>;
|
|
79
107
|
protected abstract filterQueryResults(items: T[]): T[] | Promise<T[]>;
|
|
80
|
-
|
|
108
|
+
/** Aborts the in-flight request, if any. Returns true when one was aborted. */
|
|
109
|
+
protected abortInFlightQuery(): boolean;
|
|
110
|
+
resetState(): void;
|
|
81
111
|
executeQuery(newSearchString?: string): Promise<void>;
|
|
82
|
-
search: (searchQuery?: string) => Promise<void> | undefined;
|
|
83
112
|
cancelScheduledQuery(): void;
|
|
84
113
|
}
|
|
85
|
-
export declare abstract class BaseSearchSourceSync<T> extends BaseSearchSourceBase<T> implements SearchSourceSync<T> {
|
|
86
|
-
protected searchDebounced: DebouncedExecQueryFunction;
|
|
87
|
-
constructor(options?: SearchSourceOptions);
|
|
114
|
+
export declare abstract class BaseSearchSourceSync<T> extends BaseSearchSourceBase<T, void> implements SearchSourceSync<T> {
|
|
88
115
|
protected abstract query(searchQuery: string): QueryReturnValue<T>;
|
|
89
116
|
protected abstract filterQueryResults(items: T[]): T[];
|
|
90
|
-
setDebounceOptions: ({ debounceMs }: DebounceOptions) => void;
|
|
91
117
|
executeQuery(newSearchString?: string): void;
|
|
92
|
-
search: (searchQuery?: string) => Promise<void> | undefined;
|
|
93
118
|
cancelScheduledQuery(): void;
|
|
94
119
|
}
|
|
95
120
|
export {};
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import { BaseSearchSource } from './BaseSearchSource';
|
|
1
|
+
import { BaseSearchSource, type SearchQueryOptions } from './BaseSearchSource';
|
|
2
2
|
import { FilterBuilder, type FilterBuilderOptions } from '../pagination';
|
|
3
3
|
import type { Channel } from '../channel';
|
|
4
|
-
import type { ChannelMemberResponse, MemberFilters,
|
|
4
|
+
import type { ChannelMemberResponse, MemberFilters, QueryMembersOptions, SortParamRequest } from '../types';
|
|
5
5
|
import type { SearchSourceOptions } from './types';
|
|
6
6
|
type CustomContext = Record<string, unknown>;
|
|
7
7
|
export type ChannelMemberSearchSourceFilterBuilderContext<C extends CustomContext = CustomContext> = {
|
|
8
8
|
searchQuery?: string;
|
|
9
9
|
} & C;
|
|
10
|
+
export type ChannelMemberSearchSourceOptions = SearchSourceOptions & {
|
|
11
|
+
/** Static base filters merged under the dynamically generated ones. */
|
|
12
|
+
filters?: MemberFilters;
|
|
13
|
+
sort?: SortParamRequest[];
|
|
14
|
+
searchOptions?: Omit<QueryMembersOptions, 'limit' | 'offset'>;
|
|
15
|
+
};
|
|
10
16
|
export declare class ChannelMemberSearchSource<TFilterContext extends CustomContext = CustomContext> extends BaseSearchSource<ChannelMemberResponse> {
|
|
11
17
|
readonly type = "members";
|
|
12
18
|
channel: Channel;
|
|
13
19
|
filters: MemberFilters | undefined;
|
|
14
|
-
sort:
|
|
20
|
+
sort: SortParamRequest[] | undefined;
|
|
15
21
|
searchOptions: Omit<QueryMembersOptions, 'limit' | 'offset'> | undefined;
|
|
16
22
|
filterBuilder: FilterBuilder<MemberFilters, ChannelMemberSearchSourceFilterBuilderContext<TFilterContext>>;
|
|
17
|
-
constructor(channel: Channel, options?:
|
|
18
|
-
|
|
19
|
-
protected query(searchQuery: string): Promise<{
|
|
23
|
+
constructor(channel: Channel, options?: ChannelMemberSearchSourceOptions, filterBuilderOptions?: FilterBuilderOptions<MemberFilters, ChannelMemberSearchSourceFilterBuilderContext<TFilterContext>>);
|
|
24
|
+
protected query(searchQuery: string, queryOptions?: SearchQueryOptions): Promise<{
|
|
20
25
|
items: ChannelMemberResponse[];
|
|
21
26
|
}>;
|
|
22
27
|
protected filterQueryResults(items: ChannelMemberResponse[]): ChannelMemberResponse[];
|
|
@@ -1,23 +1,45 @@
|
|
|
1
|
-
import { BaseSearchSource } from './BaseSearchSource';
|
|
1
|
+
import { BaseSearchSource, type SearchQueryOptions } from './BaseSearchSource';
|
|
2
2
|
import type { FilterBuilderOptions } from '../pagination';
|
|
3
3
|
import { FilterBuilder } from '../pagination';
|
|
4
4
|
import type { Channel } from '../channel';
|
|
5
5
|
import type { StreamChat } from '../client';
|
|
6
|
-
import type { ChannelFilters, ChannelOptions,
|
|
6
|
+
import type { ChannelFilters, ChannelOptions, SortParamRequest } from '../types';
|
|
7
7
|
import type { SearchSourceOptions } from './types';
|
|
8
8
|
type CustomContext = Record<string, unknown>;
|
|
9
9
|
export type ChannelSearchSourceFilterBuilderContext<C extends CustomContext = CustomContext> = {
|
|
10
10
|
searchQuery?: string;
|
|
11
11
|
} & C;
|
|
12
|
+
export type ChannelSearchSourceOptions = SearchSourceOptions & {
|
|
13
|
+
/** Static base filters merged under the dynamically generated ones. */
|
|
14
|
+
filters?: ChannelFilters;
|
|
15
|
+
sort?: SortParamRequest[];
|
|
16
|
+
/**
|
|
17
|
+
* Query options. Results are not watched unless `watch: true` is passed: not watched channels serve as a preview,
|
|
18
|
+
* and opening one is what watches it.
|
|
19
|
+
*/
|
|
20
|
+
searchOptions?: Omit<ChannelOptions, 'limit' | 'offset'>;
|
|
21
|
+
};
|
|
12
22
|
export declare class ChannelSearchSource<TFilterContext extends CustomContext = CustomContext> extends BaseSearchSource<Channel> {
|
|
13
23
|
readonly type = "channels";
|
|
14
24
|
client: StreamChat;
|
|
15
25
|
filters: ChannelFilters | undefined;
|
|
16
|
-
sort:
|
|
26
|
+
sort: SortParamRequest[] | undefined;
|
|
17
27
|
searchOptions: Omit<ChannelOptions, 'limit' | 'offset'> | undefined;
|
|
18
28
|
filterBuilder: FilterBuilder<ChannelFilters, ChannelSearchSourceFilterBuilderContext<TFilterContext>>;
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
private removeClaim?;
|
|
30
|
+
constructor(client: StreamChat, options?: ChannelSearchSourceOptions, filterBuilderOptions?: FilterBuilderOptions<ChannelFilters, ChannelSearchSourceFilterBuilderContext<TFilterContext>>);
|
|
31
|
+
/**
|
|
32
|
+
* While the search is active its results are on screen, so they count as used in the channel store
|
|
33
|
+
* (see `EntityStore.addClaim`). Follows `isActive`; also called by
|
|
34
|
+
* `SearchController.registerSubscriptions()` to take the registration again after `dispose()`.
|
|
35
|
+
*/
|
|
36
|
+
registerSubscriptions(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Removes the registration that keeps the results in the channel store, so a source that is
|
|
39
|
+
* dropped while active doesn't keep them, or itself, alive. A later activation registers again.
|
|
40
|
+
*/
|
|
41
|
+
dispose(): void;
|
|
42
|
+
protected query(searchQuery: string, queryOptions?: SearchQueryOptions): Promise<{
|
|
21
43
|
items: Channel[];
|
|
22
44
|
}>;
|
|
23
45
|
protected filterQueryResults(items: Channel[]): Channel[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseSearchSource } from './BaseSearchSource';
|
|
2
|
-
import type { ChannelFilters, ChannelOptions,
|
|
1
|
+
import { BaseSearchSource, type SearchQueryOptions } from './BaseSearchSource';
|
|
2
|
+
import type { ChannelFilters, ChannelOptions, MessageFilters, MessageResponse, SearchPayload, SortParamRequest } from '../types';
|
|
3
3
|
import type { StreamChat } from '../client';
|
|
4
4
|
import type { SearchSourceOptions } from './types';
|
|
5
5
|
import { FilterBuilder, type FilterBuilderOptions } from '../pagination';
|
|
@@ -26,20 +26,50 @@ export type MessageSearchSourceFilterBuilderOptions<TContexts extends MessageSea
|
|
|
26
26
|
messageSearch: FilterBuilderOptions<MessageFilters, MergeContext<BuiltInContexts['messageSearch'], TContexts['messageSearchContext']>>;
|
|
27
27
|
channelQuery: FilterBuilderOptions<ChannelFilters, MergeContext<BuiltInContexts['channelQuery'], TContexts['channelQueryContext']>>;
|
|
28
28
|
}>;
|
|
29
|
+
export type MessageSearchSourceOptions = SearchSourceOptions & {
|
|
30
|
+
/** Static base filters for the channel scope of the message search. */
|
|
31
|
+
messageSearchChannelFilters?: ChannelFilters;
|
|
32
|
+
/** Static base filters for the message search itself. */
|
|
33
|
+
messageSearchFilters?: MessageFilters;
|
|
34
|
+
messageSearchSort?: SortParamRequest[];
|
|
35
|
+
/** Static base filters for the follow-up query that hydrates unknown channels. */
|
|
36
|
+
channelQueryFilters?: ChannelFilters;
|
|
37
|
+
channelQuerySort?: SortParamRequest[];
|
|
38
|
+
/**
|
|
39
|
+
* Options for the follow-up query that hydrates unknown channels. Those channels are not watched
|
|
40
|
+
* unless `watch: true` is passed: a result is a preview, and opening one is what watches its
|
|
41
|
+
* channel.
|
|
42
|
+
*/
|
|
43
|
+
channelQueryOptions?: Omit<ChannelOptions, 'limit' | 'offset'>;
|
|
44
|
+
};
|
|
29
45
|
export declare class MessageSearchSource<TContexts extends MessageSearchSourceContexts = {}> extends BaseSearchSource<MessageResponse> {
|
|
30
46
|
readonly type = "messages";
|
|
31
47
|
private client;
|
|
32
48
|
messageSearchChannelFilters: SearchPayload['filter_conditions'] | undefined;
|
|
33
49
|
messageSearchFilters: MessageFilters | undefined;
|
|
34
|
-
messageSearchSort:
|
|
50
|
+
messageSearchSort: SortParamRequest[] | undefined;
|
|
35
51
|
channelQueryFilters: ChannelFilters | undefined;
|
|
36
|
-
channelQuerySort:
|
|
52
|
+
channelQuerySort: SortParamRequest[] | undefined;
|
|
37
53
|
channelQueryOptions: Omit<ChannelOptions, 'limit' | 'offset'> | undefined;
|
|
38
54
|
messageSearchChannelFilterBuilder: FilterBuilder<SearchPayload['filter_conditions'], MergeContext<BuiltInContexts['messageSearchChannel'], TContexts['messageSearchChannelContext']>>;
|
|
39
55
|
messageSearchFilterBuilder: FilterBuilder<MessageFilters, MergeContext<BuiltInContexts['messageSearch'], TContexts['messageSearchContext']>>;
|
|
40
56
|
channelQueryFilterBuilder: FilterBuilder<ChannelFilters, MergeContext<BuiltInContexts['channelQuery'], TContexts['channelQueryContext']>>;
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
private removeClaim?;
|
|
58
|
+
constructor(client: StreamChat, options?: MessageSearchSourceOptions, filterBuilderOptions?: MessageSearchSourceFilterBuilderOptions<TContexts>);
|
|
59
|
+
/**
|
|
60
|
+
* While the search is active its results are on screen, so the channels they were found in count
|
|
61
|
+
* as used in the channel store (see `EntityStore.addClaim`), and stay the instances the results
|
|
62
|
+
* open. Follows `isActive`; also called by `SearchController.registerSubscriptions()` to take the
|
|
63
|
+
* registration again after `dispose()`.
|
|
64
|
+
*/
|
|
65
|
+
registerSubscriptions(): void;
|
|
66
|
+
/**
|
|
67
|
+
* Removes the registration that keeps the results' channels in the channel store, so a source that
|
|
68
|
+
* is dropped while active doesn't keep them, or itself, alive. A later activation registers again.
|
|
69
|
+
*/
|
|
70
|
+
dispose(): void;
|
|
71
|
+
private resultChannels;
|
|
72
|
+
protected query(searchQuery: string, queryOptions?: SearchQueryOptions): Promise<{
|
|
43
73
|
items: never[];
|
|
44
74
|
next?: undefined;
|
|
45
75
|
} | {
|