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,4 +1,4 @@
|
|
|
1
|
-
import { StateStore } from '
|
|
1
|
+
import { StateStore } from '@stream-io/state-store';
|
|
2
2
|
import type { DebouncedFunc } from '../utils';
|
|
3
3
|
import type { DraftMessage, LocalMessage, OGAttachment } from '../types';
|
|
4
4
|
import type { LinkPreviewsManagerConfig } from './configuration/types';
|
|
@@ -60,6 +60,12 @@ export declare class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
60
60
|
initState: ({ message }?: {
|
|
61
61
|
message?: DraftMessage | LocalMessage;
|
|
62
62
|
}) => void;
|
|
63
|
+
/**
|
|
64
|
+
* Takes over `source`'s link previews.
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
takeOver: (source: LinkPreviewsManager) => void;
|
|
63
69
|
getSnapshot: () => LinkPreviewsManagerSnapshot;
|
|
64
70
|
restoreSnapshot: (snapshot: LinkPreviewsManagerSnapshot) => void;
|
|
65
71
|
private _findAndEnrichUrls;
|
|
@@ -77,12 +83,13 @@ export declare class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
77
83
|
static previewIsFailed: (preview: LinkPreview) => boolean;
|
|
78
84
|
static previewIsPending: (preview: LinkPreview) => boolean;
|
|
79
85
|
static getPreviewData: (preview: LinkPreview) => {
|
|
80
|
-
custom: import("..").CustomAttachmentData;
|
|
81
86
|
type?: string | undefined;
|
|
87
|
+
actions?: Array<import("..").Action> | undefined;
|
|
88
|
+
custom: import("..").CustomAttachmentData;
|
|
82
89
|
text?: string | undefined;
|
|
83
90
|
giphy?: import("..").Images | undefined;
|
|
84
|
-
actions?: Array<import("..").Action> | undefined;
|
|
85
91
|
title?: string | undefined;
|
|
92
|
+
fields?: Array<import("..").Field> | undefined;
|
|
86
93
|
thumb_url?: string | undefined;
|
|
87
94
|
asset_url?: string | undefined;
|
|
88
95
|
author_icon?: string | undefined;
|
|
@@ -97,7 +104,6 @@ export declare class LinkPreviewsManager implements ILinkPreviewsManager {
|
|
|
97
104
|
original_width?: number | undefined;
|
|
98
105
|
pretext?: string | undefined;
|
|
99
106
|
title_link?: string | undefined;
|
|
100
|
-
fields?: Array<import("..").Field> | undefined;
|
|
101
107
|
og_scrape_url: string;
|
|
102
108
|
};
|
|
103
109
|
}
|
|
@@ -6,12 +6,12 @@ import { PollComposer } from './pollComposer';
|
|
|
6
6
|
import { TextComposer } from './textComposer';
|
|
7
7
|
import type { MessageComposerMiddlewareValue } from './middleware';
|
|
8
8
|
import { MessageComposerMiddlewareExecutor, MessageDraftComposerMiddlewareExecutor } from './middleware';
|
|
9
|
-
import type { Unsubscribe } from '
|
|
10
|
-
import { StateStore } from '
|
|
9
|
+
import type { Unsubscribe } from '@stream-io/state-store';
|
|
10
|
+
import { StateStore } from '@stream-io/state-store';
|
|
11
11
|
import { generateUUIDv4 } from '../utils';
|
|
12
12
|
import { Channel } from '../channel';
|
|
13
13
|
import { Thread } from '../thread';
|
|
14
|
-
import type { ChannelStateResponseFields, Command, DraftResponse, LocalMessage, MessageResponse } from '../types';
|
|
14
|
+
import type { ChannelStateResponseFields, Command, DraftResponse, LocalMessage, MessageResponse, TimestampNS } from '../types';
|
|
15
15
|
import { WithSubscriptions } from '../utils/WithSubscriptions';
|
|
16
16
|
import type { StreamChat } from '../client';
|
|
17
17
|
import type { CommandSendability, MessageComposerConfig } from './configuration/types';
|
|
@@ -24,9 +24,14 @@ import type { PollComposerSnapshot } from './pollComposer';
|
|
|
24
24
|
import type { TextComposerSnapshot } from './textComposer';
|
|
25
25
|
import type { DeepPartial } from '../types.utility';
|
|
26
26
|
type UnregisterSubscriptions = Unsubscribe;
|
|
27
|
+
/**
|
|
28
|
+
* Composer edit-audit clock. Both values are unix nanoseconds, so a locally stamped change and a
|
|
29
|
+
* server-derived `created_at` / `updated_at` are directly comparable — which is the whole point of
|
|
30
|
+
* this state.
|
|
31
|
+
*/
|
|
27
32
|
export type LastComposerChange = {
|
|
28
|
-
draftUpdate:
|
|
29
|
-
stateUpdate:
|
|
33
|
+
draftUpdate: TimestampNS | null;
|
|
34
|
+
stateUpdate: TimestampNS;
|
|
30
35
|
};
|
|
31
36
|
export type EditingAuditState = {
|
|
32
37
|
lastChange: LastComposerChange;
|
|
@@ -47,10 +52,22 @@ export type MessageComposerSnapshot = {
|
|
|
47
52
|
pollComposer: PollComposerSnapshot;
|
|
48
53
|
textComposer: TextComposerSnapshot;
|
|
49
54
|
};
|
|
50
|
-
export type
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
export type CompositionContext = Channel | Thread | LocalMessage;
|
|
56
|
+
/**
|
|
57
|
+
* What a submit did, and by implication where the content now is.
|
|
58
|
+
*
|
|
59
|
+
* - `sent` - it went out.
|
|
60
|
+
* - `nothing-to-send` - there was nothing to compose, or a middleware discarded the composition
|
|
61
|
+
* (a command that is not ready, one disabled by the quoted or edited message, an upload still
|
|
62
|
+
* running). **The composer keeps its contents**, and the reason has already been reported through
|
|
63
|
+
* `client.notifications`.
|
|
64
|
+
* - `failed` - the request failed. **The composer has been released**; the content is in the
|
|
65
|
+
* message list marked `failed`, where the user retries it.
|
|
66
|
+
*
|
|
67
|
+
* The distinction matters because the last two leave the composer in opposite states, so a caller
|
|
68
|
+
* that reopens or restores UI has to tell them apart.
|
|
69
|
+
*/
|
|
70
|
+
export type MessageComposerSubmitResult = 'sent' | 'nothing-to-send' | 'failed';
|
|
54
71
|
export type MessageComposerState = {
|
|
55
72
|
id: string;
|
|
56
73
|
draftId: string | null;
|
|
@@ -73,7 +90,12 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
73
90
|
readonly channel: Channel;
|
|
74
91
|
readonly state: StateStore<MessageComposerState>;
|
|
75
92
|
readonly editingAuditState: StateStore<EditingAuditState>;
|
|
76
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Resolved configuration, as a store — the shape every configurable class exposes
|
|
95
|
+
* (`configState` / `config` / `updateConfig`). Delegates rather than holding a copy, so the field and
|
|
96
|
+
* the controller's store cannot drift.
|
|
97
|
+
*/
|
|
98
|
+
get configState(): StateStore<MessageComposerConfig>;
|
|
77
99
|
readonly compositionContext: CompositionContext;
|
|
78
100
|
readonly compositionMiddlewareExecutor: MessageComposerMiddlewareExecutor;
|
|
79
101
|
readonly draftCompositionMiddlewareExecutor: MessageDraftComposerMiddlewareExecutor;
|
|
@@ -85,16 +107,35 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
85
107
|
customDataManager: CustomDataManager;
|
|
86
108
|
private snapshots;
|
|
87
109
|
private effectHandlers;
|
|
110
|
+
/**
|
|
111
|
+
* The shared configuration machinery, with the three hooks this entity is the only one to need:
|
|
112
|
+
* `retainPatches` so an `updateConfig` request is *retained* and re-applied rather than written
|
|
113
|
+
* into the result (**DV-18**), and `applyAuthority` for the server's last word.
|
|
114
|
+
*
|
|
115
|
+
* A third hook, `finalizeRequest`, was added here for `commands.sendValidator` and then removed: the
|
|
116
|
+
* deep merge assigns function values directly and skips `undefined`, so the override it called reached
|
|
117
|
+
* the same answer on every layer shape — a later layer that stays silent cannot erase an earlier
|
|
118
|
+
* choice, because a merge only writes keys that are present.
|
|
119
|
+
*/
|
|
120
|
+
private readonly configController;
|
|
88
121
|
constructor({ composition, config, compositionContext, client, }: MessageComposerOptions);
|
|
89
|
-
static evaluateContextType(compositionContext: CompositionContext): "
|
|
122
|
+
static evaluateContextType(compositionContext: CompositionContext): "message" | "channel" | "thread";
|
|
90
123
|
static constructTag(compositionContext: CompositionContext): `${ReturnType<typeof MessageComposer.evaluateContextType>}_${string}`;
|
|
91
124
|
static generateId: typeof generateUUIDv4;
|
|
92
|
-
|
|
125
|
+
/**
|
|
126
|
+
* The current resolved configuration.
|
|
127
|
+
*
|
|
128
|
+
* `Readonly` for the same reason every other configurable class's getter is: the value is the store's
|
|
129
|
+
* live object, so assigning to a field would change state while notifying nobody. Use
|
|
130
|
+
* {@link updateConfig}. `Readonly` is shallow, so nested writes are caught at runtime instead — the
|
|
131
|
+
* whole resolution is deep-frozen by {@link resolvedConfig}, not only the untouched defaults.
|
|
132
|
+
*/
|
|
133
|
+
get config(): Readonly<MessageComposerConfig>;
|
|
93
134
|
get editedMessage(): LocalMessage | undefined;
|
|
94
135
|
set editedMessage(editedMessage: LocalMessage | undefined);
|
|
95
136
|
setEditedMessage: (editedMessage: LocalMessage | null | undefined) => void;
|
|
96
|
-
get contextType(): "
|
|
97
|
-
get tag(): `
|
|
137
|
+
get contextType(): "message" | "channel" | "thread";
|
|
138
|
+
get tag(): `message_${string}` | `channel_${string}` | `thread_${string}`;
|
|
98
139
|
get threadId(): string | null;
|
|
99
140
|
get client(): StreamChat;
|
|
100
141
|
get id(): string;
|
|
@@ -107,11 +148,124 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
107
148
|
isCommandDisabled: (command: Command) => boolean;
|
|
108
149
|
validateCommandSendability: (command: Command, text?: string) => CommandSendability;
|
|
109
150
|
get isCommandSendable(): boolean;
|
|
151
|
+
/**
|
|
152
|
+
* Whether a message may be sent while its attachments are still uploading — see
|
|
153
|
+
* {@link AttachmentManagerConfig.pendingUploadsEnabled}.
|
|
154
|
+
*/
|
|
155
|
+
get allowsPendingUploads(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Where a composed message goes: the thread when this composer belongs to one, the channel
|
|
158
|
+
* otherwise.
|
|
159
|
+
*
|
|
160
|
+
* Thread replies live in `thread.messagePaginator`, which is independent of the channel's, so
|
|
161
|
+
* dispatching to the wrong one leaves the reply invisible where it was written. An edit composer
|
|
162
|
+
* is built from the message rather than from its thread, so it finds the thread only when
|
|
163
|
+
* `client.threads` has it registered — listed, or active (open somewhere).
|
|
164
|
+
*/
|
|
165
|
+
get defaultSubmitTarget(): Channel | Thread;
|
|
166
|
+
/**
|
|
167
|
+
* Whether submitting keeps the composer's contents rather than clearing them - see
|
|
168
|
+
* {@link MessageComposerConfig.retainCompositionOnSubmit}.
|
|
169
|
+
*
|
|
170
|
+
* Read by the attachments composition step too: content the composer keeps must not also ride
|
|
171
|
+
* along on the submitted message, or one `localMetadata.id` ends up owned in two places.
|
|
172
|
+
*/
|
|
173
|
+
get retainsCompositionOnSubmit(): boolean;
|
|
110
174
|
get hasSendableData(): boolean;
|
|
111
175
|
get compositionIsEmpty(): boolean;
|
|
112
176
|
get contentIsEmpty(): boolean;
|
|
113
177
|
get lastChangeOriginIsLocal(): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Records a configuration change as something *you* asked for, then republishes.
|
|
180
|
+
*
|
|
181
|
+
* The patch is kept — see {@link imperativeConfig} — rather than merged into the published result and
|
|
182
|
+
* forgotten. That is what makes the request survive a later re-resolution, including one triggered by
|
|
183
|
+
* the server changing its mind.
|
|
184
|
+
*/
|
|
114
185
|
updateConfig(config: DeepPartial<MessageComposerConfig>): void;
|
|
186
|
+
/**
|
|
187
|
+
* What this composer has been **asked** for, before the server has any say — stages 1 to 5 of
|
|
188
|
+
* `docs/instance-configuration.md` §3.
|
|
189
|
+
*
|
|
190
|
+
* Available on every entity that retains its patches, not just this one: it is the controller's, and
|
|
191
|
+
* the split it exposes is what **FU-35** would extend elsewhere by switching on `retainPatches`.
|
|
192
|
+
*/
|
|
193
|
+
get requestedConfig(): Readonly<MessageComposerConfig>;
|
|
194
|
+
/** The declarative slice for this composer, re-read live so a change is picked up. */
|
|
195
|
+
private get declarativeConfig();
|
|
196
|
+
/**
|
|
197
|
+
* The configuration fields this composer's channel decides server-side.
|
|
198
|
+
*
|
|
199
|
+
* Reading them is the composer's job rather than the shared helper's: only the composer knows that
|
|
200
|
+
* `location.enabled` is gated on `shared_locations`, and only an existing composer has a channel to
|
|
201
|
+
* ask. `serverConfig` is re-read on every call, so a restriction that changes mid-session is picked up
|
|
202
|
+
* rather than captured once.
|
|
203
|
+
*
|
|
204
|
+
* Every entry here is a boolean gate, so `mergeServerRestrictions` ANDs it with what was requested and
|
|
205
|
+
* either side may switch the feature off — a client asking for less than the server grants is always
|
|
206
|
+
* legitimate. That is the whole point of mirroring these flags into configuration rather than leaving
|
|
207
|
+
* consumers to read `serverConfig` themselves: a raw server flag answers only the server's half, so a UI
|
|
208
|
+
* reading it offers features the composer has already disabled and would refuse to compose.
|
|
209
|
+
*
|
|
210
|
+
* `commands` is deliberately absent. The server sends a *list* of commands rather than a gate, so there
|
|
211
|
+
* is nothing to AND and no integrator intent to mirror; consumers read it from the channel's config.
|
|
212
|
+
*
|
|
213
|
+
* Takes the requested configuration because one restriction is conditional — see `uploads` below.
|
|
214
|
+
*/
|
|
215
|
+
private serverRestrictionsFor;
|
|
216
|
+
/**
|
|
217
|
+
* Ceilings this composer's channel imposes server-side.
|
|
218
|
+
*
|
|
219
|
+
* `max_message_length` caps both length limits rather than setting them: a composer asking for something
|
|
220
|
+
* shorter keeps its own number, and one asking for nothing at all inherits the server's — which is the
|
|
221
|
+
* default, and the case worth having. Left unlimited, the composer happily accepts text the send endpoint
|
|
222
|
+
* then rejects, so the limit is enforced late and as an API error instead of in the editor.
|
|
223
|
+
*/
|
|
224
|
+
private get serverUpperBounds();
|
|
225
|
+
/**
|
|
226
|
+
* Resolves the configuration and publishes it, unless the result is deep-equal to what is already there.
|
|
227
|
+
*
|
|
228
|
+
* The guard is needed because `StateStore.next`'s own `===` no-op can never apply here: every resolution
|
|
229
|
+
* allocates a new object, so without a comparison *every* publish notifies, whether or not any value
|
|
230
|
+
* moved.
|
|
231
|
+
*
|
|
232
|
+
* Worth the walk: `isEqual` over a resolved composer config measures ~1.7µs, against a resolution at
|
|
233
|
+
* ~3.5µs plus every subscriber's work. The dominant source of no-op publishes is fixed upstream in
|
|
234
|
+
* `StreamChat._addChannelConfig`, which stops a repeated channel query from waking that channel's
|
|
235
|
+
* composer at all; this
|
|
236
|
+
* catches the rest — re-registering a declarative value that has not changed, a `reset` with nothing
|
|
237
|
+
* registered, an empty `updateConfig({})`.
|
|
238
|
+
*/
|
|
239
|
+
private publishConfig;
|
|
240
|
+
/**
|
|
241
|
+
* Rebuilds the configuration from its inputs and **discards imperative changes** — every
|
|
242
|
+
* {@link updateConfig} patch, including those made through a sub-composer setter such as
|
|
243
|
+
* `textComposer.defaultValue` or `attachmentManager.maxNumberOfFilesPerMessage`.
|
|
244
|
+
*
|
|
245
|
+
* Called by the constructor and by `client.config.reset()`, where dropping them is the point: a reset
|
|
246
|
+
* means "back to what is registered". Anything that merely needs the configuration re-resolved — the
|
|
247
|
+
* server's answer arriving, a declarative change — must use {@link publishConfig} or
|
|
248
|
+
* {@link applyServerRestrictions}, which keep them.
|
|
249
|
+
*/
|
|
250
|
+
initializeConfig: () => void;
|
|
251
|
+
/**
|
|
252
|
+
* Re-resolves the configuration against the channel's current server-side restrictions.
|
|
253
|
+
*
|
|
254
|
+
* Call this when the server's answer may have changed — its config has just arrived, or it was updated.
|
|
255
|
+
* Safe in both directions, which is the whole reason it exists: a feature you disabled stays disabled
|
|
256
|
+
* when the server permits it, and a feature the server *stops* restricting goes back to whatever you
|
|
257
|
+
* asked for, because the restriction is applied to your request rather than to the previous result.
|
|
258
|
+
*
|
|
259
|
+
* Reachable rather than public: `Channel.query` is the only caller, covering a composer that has not
|
|
260
|
+
* registered subscriptions and so cannot hear the answer change through
|
|
261
|
+
* {@link subscribeChannelConfigChanged}. Nothing outside this package needs it — registering subscriptions
|
|
262
|
+
* is the supported way to stay current, and a composer that has done so is already covered. Marked
|
|
263
|
+
* `@internal` so it is not read as a supported extension point; the name is kept because what it does
|
|
264
|
+
* is* re-assert the server's restrictions, even though the whole resolution is what performs that.
|
|
265
|
+
*
|
|
266
|
+
* @internal
|
|
267
|
+
*/
|
|
268
|
+
applyServerRestrictions: () => void;
|
|
115
269
|
refreshId: () => void;
|
|
116
270
|
initState: ({ composition, }?: {
|
|
117
271
|
composition?: DraftResponse | MessageResponse | LocalMessage;
|
|
@@ -121,6 +275,15 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
121
275
|
clearSnapshots: () => void;
|
|
122
276
|
getSnapshot: () => MessageComposerSnapshot;
|
|
123
277
|
restoreSnapshot: (snapshot: MessageComposerSnapshot) => void;
|
|
278
|
+
/**
|
|
279
|
+
* Moves this composition into `target`, replacing what `target` held, and clears this composer
|
|
280
|
+
* locally: the text, attachments, poll, location, link previews, custom data, quoted message and
|
|
281
|
+
* reply-in-channel choice. An upload still running keeps running and its result lands in `target`
|
|
282
|
+
* (see {@link AttachmentManager.takeOver}). Nothing is sent.
|
|
283
|
+
*
|
|
284
|
+
* @internal
|
|
285
|
+
*/
|
|
286
|
+
transferTo: (target: MessageComposer) => void;
|
|
124
287
|
captureSnapshot: (snapshot?: MessageComposerSnapshot) => void;
|
|
125
288
|
popSnapshot: () => MessageComposerSnapshot | undefined;
|
|
126
289
|
registerEffectHandler: <T extends {
|
|
@@ -135,6 +298,17 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
135
298
|
registerSubscriptions: () => UnregisterSubscriptions;
|
|
136
299
|
private subscribeMessageUpdated;
|
|
137
300
|
private subscribeMessageComposerSetupStateChange;
|
|
301
|
+
/**
|
|
302
|
+
* The channel's server-side config (`client.channelServerConfigs[cid]`) is populated by `query`/`watch`,
|
|
303
|
+
* which for a channel opened via `client.channelManager.ensure({ type, id })` happens *after* this composer was
|
|
304
|
+
* constructed. Left unwatched, the composer would keep the defaults it derived when `serverConfig` was
|
|
305
|
+
* still undefined — so `location.enabled` would stay `true` for an app that disables `shared_locations`
|
|
306
|
+
* server-side. Re-deriving when the config lands keeps the server authoritative.
|
|
307
|
+
*
|
|
308
|
+
* Selected by cid, matching the store's key space: `shared_locations` and `max_message_length` are both
|
|
309
|
+
* overridable per channel, so a sibling channel's config is not this composer's answer.
|
|
310
|
+
*/
|
|
311
|
+
private subscribeChannelConfigChanged;
|
|
138
312
|
private subscribeMessageDeleted;
|
|
139
313
|
private subscribeDraftUpdated;
|
|
140
314
|
private subscribeDraftDeleted;
|
|
@@ -156,6 +330,28 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
156
330
|
deleteDraft: () => Promise<void>;
|
|
157
331
|
getDraft: () => Promise<void>;
|
|
158
332
|
createPoll: () => Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Lets go of what the submitted message took with it.
|
|
335
|
+
*
|
|
336
|
+
* A poll message carries no text or attachments of its own, so the composer keeps whatever else
|
|
337
|
+
* was drafted and releases only the poll. Everything else is a full clear.
|
|
338
|
+
*/
|
|
339
|
+
private releaseSubmittedComposition;
|
|
340
|
+
private reportSubmitFailure;
|
|
341
|
+
/**
|
|
342
|
+
* Composes the message and sends it, releasing the composer as it goes.
|
|
343
|
+
*
|
|
344
|
+
* Never rejects - see {@link MessageComposerSubmitResult} for what each outcome means and where
|
|
345
|
+
* the content ends up. A failure is reported through `client.notifications`, and the message
|
|
346
|
+
* stays in the list marked `failed`, which is where the user retries it. Callers rendering their
|
|
347
|
+
* own post-send feedback have to check the result.
|
|
348
|
+
*/
|
|
349
|
+
send: () => Promise<MessageComposerSubmitResult>;
|
|
350
|
+
/**
|
|
351
|
+
* Composes the edit and saves it, on the same terms as {@link send} - including releasing the
|
|
352
|
+
* composer before the request rather than after it.
|
|
353
|
+
*/
|
|
354
|
+
update: () => Promise<MessageComposerSubmitResult>;
|
|
159
355
|
sendLocation: () => Promise<void>;
|
|
160
356
|
}
|
|
161
357
|
export {};
|
package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts
CHANGED
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
import type { AttachmentPostUploadMiddleware } from '../types';
|
|
2
|
-
|
|
2
|
+
import type { MessageComposer } from '../../../messageComposer';
|
|
3
|
+
/**
|
|
4
|
+
* Writes the uploaded URL onto the attachment and releases its local preview.
|
|
5
|
+
*
|
|
6
|
+
* The preview is a blob URL the composer created for the file. Releasing it once the CDN URL is
|
|
7
|
+
* in is what keeps the browser from holding the file in memory.
|
|
8
|
+
*
|
|
9
|
+
* Pass `composer` and the preview is released only while the attachment is still one of the
|
|
10
|
+
* composer's own — still listed in `attachmentManager.attachments`, i.e. still shown above the
|
|
11
|
+
* input, waiting to be sent.
|
|
12
|
+
*
|
|
13
|
+
* This runs when an upload finishes, which can be after the composer was cleared: `uploadFile`
|
|
14
|
+
* executes this chain before the (by then no-op) `updateAttachment`. If the attachment is gone
|
|
15
|
+
* from the composer, a message is rendering from the preview instead, and releasing it would
|
|
16
|
+
* blank that message out. A message can be sent with uploads still running — see
|
|
17
|
+
* {@link AttachmentManagerConfig.pendingUploadsEnabled}.
|
|
18
|
+
*
|
|
19
|
+
* Omit `composer` and the preview is always released.
|
|
20
|
+
*/
|
|
21
|
+
export declare const createPostUploadAttachmentEnrichmentMiddleware: (composer?: MessageComposer) => AttachmentPostUploadMiddleware;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { MessageComposer } from '../../messageComposer';
|
|
2
2
|
import type { MessageCompositionMiddleware, MessageDraftCompositionMiddleware } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Composes the message's attachments.
|
|
5
|
+
*
|
|
6
|
+
* By default an upload still in flight blocks the send: the chain warns and discards the
|
|
7
|
+
* composition. With {@link AttachmentManagerConfig.pendingUploadsEnabled} on it composes
|
|
8
|
+
* anyway, leaving `message.attachments` without the unresolved ones — `MessageOperations` awaits
|
|
9
|
+
* those uploads and fills in the URLs before the request goes out.
|
|
10
|
+
*
|
|
11
|
+
* The config is read per composition rather than at construction, so `updateConfig` takes effect
|
|
12
|
+
* on the next send with no need to reinstall anything.
|
|
13
|
+
*/
|
|
3
14
|
export declare const createAttachmentsCompositionMiddleware: (composer: MessageComposer) => MessageCompositionMiddleware;
|
|
4
15
|
export declare const createDraftAttachmentsCompositionMiddleware: (composer: MessageComposer) => MessageDraftCompositionMiddleware;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Middleware, MiddlewareExecutionResult } from '../../../middleware';
|
|
2
|
-
import type { LocalMessage, MessageRequest, SendMessageOptions
|
|
2
|
+
import type { LocalMessage, MessageRequest, SendMessageOptions } from '../../../types';
|
|
3
3
|
import type { MessageComposer } from '../../messageComposer';
|
|
4
4
|
export type MessageComposerMiddlewareState = {
|
|
5
|
-
message: MessageRequest
|
|
5
|
+
message: MessageRequest;
|
|
6
6
|
localMessage: LocalMessage;
|
|
7
7
|
sendOptions: SendMessageOptions;
|
|
8
8
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Middleware } from '../../../middleware';
|
|
2
2
|
import type { PollComposerFieldErrors, PollComposerState, PollComposerStateChangeMiddlewareValue, TargetedPollOptionTextUpdate } from './types';
|
|
3
|
+
import type { PollComposerValidationError } from './validation';
|
|
3
4
|
export declare const VALID_MAX_VOTES_VALUE_REGEX: RegExp;
|
|
4
5
|
export declare const MAX_POLL_OPTIONS: 100;
|
|
5
|
-
export type PollStateValidationOutput = Partial<Omit<Record<keyof PollComposerState['data'],
|
|
6
|
-
options?: Record<string,
|
|
6
|
+
export type PollStateValidationOutput = Partial<Omit<Record<keyof PollComposerState['data'], PollComposerValidationError>, 'options'> & {
|
|
7
|
+
options?: Record<string, PollComposerValidationError>;
|
|
7
8
|
}>;
|
|
8
9
|
export type PollStateChangeValidator = (params: {
|
|
9
10
|
data: PollComposerState['data'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MiddlewareExecutionResult } from '../../../middleware';
|
|
2
2
|
import type { CreatePollRequest, VotingVisibility } from '../../../types';
|
|
3
|
+
import type { PollComposerValidationError } from './validation';
|
|
3
4
|
export type PollComposerOption = {
|
|
4
5
|
id: string;
|
|
5
6
|
text: string;
|
|
@@ -12,8 +13,14 @@ export type PollComposerOptionUpdate = PollComposerOption[] | TargetedPollOption
|
|
|
12
13
|
export type UpdateFieldsData = Partial<Omit<PollComposerState['data'], 'options'>> & {
|
|
13
14
|
options?: PollComposerOptionUpdate;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Field validation errors, keyed by field. `options` errors are keyed by option id.
|
|
18
|
+
*
|
|
19
|
+
* Values carry a stable {@link PollComposerValidationError.code} rather than being bare English, so a UI can
|
|
20
|
+
* localize them; see {@link POLL_COMPOSER_VALIDATION_CODE}.
|
|
21
|
+
*/
|
|
22
|
+
export type PollComposerFieldErrors = Partial<Omit<Record<keyof CreatePollRequest, PollComposerValidationError>, 'options'> & {
|
|
23
|
+
options?: Record<string, PollComposerValidationError>;
|
|
17
24
|
}>;
|
|
18
25
|
export type PollComposerState = {
|
|
19
26
|
data: {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable identifiers for poll-composer field validation failures.
|
|
3
|
+
*
|
|
4
|
+
* **Not notifications, despite the shared `domain:entity:operation:result` shape.** These are *field*
|
|
5
|
+
* errors, rendered inline beside the input that produced them, and they never reach
|
|
6
|
+
* `NotificationManager` — routing them there would raise a toast per keystroke. `CORE_NOTIFICATION_TYPE`
|
|
7
|
+
* is the notification counterpart; the two sets are disjoint and neither substitutes for the other.
|
|
8
|
+
*
|
|
9
|
+
* **These values are public API.** UI SDKs key their translation tables on them, so renaming one is a
|
|
10
|
+
* breaking change.
|
|
11
|
+
*/
|
|
12
|
+
export declare const POLL_COMPOSER_VALIDATION_CODE: {
|
|
13
|
+
readonly maxVotesNotNumeric: "validation:poll:maxVotes:notNumeric";
|
|
14
|
+
readonly maxVotesOutOfRange: "validation:poll:maxVotes:outOfRange";
|
|
15
|
+
readonly maxVotesUniqueVoteEnforced: "validation:poll:maxVotes:uniqueVoteEnforced";
|
|
16
|
+
readonly nameRequired: "validation:poll:name:required";
|
|
17
|
+
readonly optionDuplicate: "validation:poll:option:duplicate";
|
|
18
|
+
readonly optionEmpty: "validation:poll:option:empty";
|
|
19
|
+
};
|
|
20
|
+
export type PollComposerValidationCode = (typeof POLL_COMPOSER_VALIDATION_CODE)[keyof typeof POLL_COMPOSER_VALIDATION_CODE];
|
|
21
|
+
/**
|
|
22
|
+
* A poll-composer field validation failure.
|
|
23
|
+
*
|
|
24
|
+
* `code` is the stable identifier to resolve localized copy from. `message` carries untranslated
|
|
25
|
+
* English alongside it so a consumer with no i18n layer still renders something, and so an
|
|
26
|
+
* identifier a consumer does not recognize degrades to readable text instead of a blank field.
|
|
27
|
+
*/
|
|
28
|
+
export type PollComposerValidationError = {
|
|
29
|
+
/** Stable identifier. See {@link POLL_COMPOSER_VALIDATION_CODE}. */
|
|
30
|
+
code: PollComposerValidationCode;
|
|
31
|
+
/** Untranslated English fallback. Not part of the public contract. */
|
|
32
|
+
message: string;
|
|
33
|
+
/** Extra context for interpolation, e.g. the offending value. */
|
|
34
|
+
metadata?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
/** Builds a {@link PollComposerValidationError}, filling in the English fallback for `code`. */
|
|
37
|
+
export declare const pollComposerValidationError: (code: PollComposerValidationCode, metadata?: Record<string, unknown>) => PollComposerValidationError;
|
|
38
|
+
/**
|
|
39
|
+
* Narrows a field's error to a single failure.
|
|
40
|
+
*
|
|
41
|
+
* `options` errors are keyed by option id, so a field error is either one `PollComposerValidationError` or a
|
|
42
|
+
* record of them; this distinguishes the two.
|
|
43
|
+
*/
|
|
44
|
+
export declare const isPollComposerValidationError: (value: unknown) => value is PollComposerValidationError;
|
|
@@ -27,8 +27,8 @@ export declare class CommandSearchSource extends BaseSearchSourceSync<CommandSug
|
|
|
27
27
|
description: string;
|
|
28
28
|
name: string;
|
|
29
29
|
set: string;
|
|
30
|
-
created_at?:
|
|
31
|
-
updated_at?:
|
|
30
|
+
created_at?: import("../../..").TimestampNS;
|
|
31
|
+
updated_at?: import("../../..").TimestampNS;
|
|
32
32
|
}[];
|
|
33
33
|
next: null;
|
|
34
34
|
};
|