stream-chat 10.0.0-rc.21 → 10.0.0-rc.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.browser.js +2196 -3902
- package/dist/cjs/index.browser.js.map +3 -3
- package/dist/cjs/index.node.js +2197 -3902
- package/dist/cjs/index.node.js.map +3 -3
- package/dist/esm/index.mjs +2199 -3905
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelManager.d.ts +120 -233
- package/dist/types/CooldownTimer.d.ts +8 -23
- package/dist/types/EventHandlerPipeline.d.ts +17 -37
- package/dist/types/LiveLocationManager.d.ts +22 -50
- package/dist/types/api-client.d.ts +9 -14
- package/dist/types/channel.d.ts +253 -448
- package/dist/types/channel_state.d.ts +48 -95
- package/dist/types/client.d.ts +245 -370
- package/dist/types/client_state.d.ts +1 -3
- package/dist/types/configuration/ConfigController.d.ts +30 -124
- package/dist/types/configuration/InstanceConfigurationRegistry.d.ts +31 -123
- package/dist/types/configuration/keys.d.ts +5 -19
- package/dist/types/configuration/shape.d.ts +12 -29
- package/dist/types/configuration/types.d.ts +59 -87
- package/dist/types/configuration/utils/applyInstanceConfiguration.d.ts +13 -35
- package/dist/types/configuration/utils/copyConfigPatch.d.ts +8 -0
- package/dist/types/configuration/utils/declarativeSlices.d.ts +5 -16
- package/dist/types/configuration/utils/deepFreezeConfig.d.ts +3 -17
- package/dist/types/configuration/utils/serverAuthority.d.ts +9 -29
- package/dist/types/connection/ConnectionIdManager.d.ts +18 -40
- package/dist/types/connection/ConnectionRecoveryManager.d.ts +29 -120
- package/dist/types/connection/networkConnection/NetworkConnectionObserver.d.ts +32 -103
- package/dist/types/connection/networkConnection/reporters.d.ts +9 -32
- package/dist/types/connection/networkConnection/types.d.ts +12 -27
- package/dist/types/connection/wsConnection/StableWSConnection.d.ts +37 -116
- package/dist/types/connection/wsConnection/WSConnection.d.ts +41 -104
- package/dist/types/connection/wsConnection/WSConnectionFallback.d.ts +8 -16
- package/dist/types/connection/wsConnection/config.d.ts +8 -28
- package/dist/types/connection/wsConnection/types.d.ts +17 -70
- package/dist/types/entityStore/EntityStore.d.ts +153 -113
- package/dist/types/entityStore/StoreBackedItemIndex.d.ts +13 -46
- package/dist/types/errors.d.ts +7 -19
- package/dist/types/gen/chat/ChannelApi.d.ts +2 -1
- package/dist/types/gen/chat/ChatApi.d.ts +28 -14
- package/dist/types/gen/models/index.d.ts +769 -86
- package/dist/types/gen/moderation/ModerationApi.d.ts +4 -4
- package/dist/types/index.d.ts +2 -4
- package/dist/types/languageNames.d.ts +9 -24
- package/dist/types/logger.d.ts +1 -3
- package/dist/types/messageComposer/LocationComposer.d.ts +1 -1
- package/dist/types/messageComposer/attachmentIdentity.d.ts +1 -6
- package/dist/types/messageComposer/attachmentManager.d.ts +10 -32
- package/dist/types/messageComposer/attachmentUtils.d.ts +3 -14
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -5
- package/dist/types/messageComposer/configuration/types.d.ts +29 -56
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +6 -9
- package/dist/types/messageComposer/messageComposer.d.ts +30 -164
- package/dist/types/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.d.ts +4 -14
- package/dist/types/messageComposer/middleware/messageComposer/attachments.d.ts +2 -9
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +2 -4
- package/dist/types/messageComposer/middleware/pollComposer/validation.d.ts +7 -19
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +9 -0
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +11 -18
- package/dist/types/messageComposer/middleware/textComposer/textMiddlewareUtils.d.ts +9 -3
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +1 -6
- package/dist/types/messageComposer/pollComposer.d.ts +8 -4
- package/dist/types/messageComposer/textComposer.d.ts +3 -9
- package/dist/types/messageComposer/types.d.ts +5 -8
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +25 -79
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +15 -82
- package/dist/types/messageOperations/FailedSendCache.d.ts +4 -9
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +10 -20
- package/dist/types/messageOperations/MessageOperations.d.ts +20 -40
- package/dist/types/messageOperations/applyReactionLocally.d.ts +5 -22
- package/dist/types/messageOperations/createMessageOperations.d.ts +3 -5
- package/dist/types/messageOperations/reflectReactionEvent.d.ts +5 -13
- package/dist/types/messageOperations/sendOrdering.d.ts +4 -7
- package/dist/types/messageOperations/settlePendingAttachmentUploads.d.ts +7 -15
- package/dist/types/messageOperations/types.d.ts +15 -30
- package/dist/types/middleware.d.ts +7 -5
- package/dist/types/moderation.d.ts +21 -14
- package/dist/types/notifications/NotificationManager.d.ts +8 -31
- package/dist/types/notifications/types.d.ts +19 -59
- package/dist/types/offline-support/offline_support_api.d.ts +145 -539
- package/dist/types/offline-support/offline_sync_manager.d.ts +18 -42
- package/dist/types/offline-support/queueableOperations.d.ts +24 -52
- package/dist/types/offline-support/types.d.ts +24 -187
- package/dist/types/pagination/ItemIndex.d.ts +4 -12
- package/dist/types/pagination/cursorDerivation/aroundPaginationFlags.d.ts +13 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +2 -4
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +2 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +235 -622
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +67 -125
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +133 -292
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +69 -118
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +7 -26
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +2 -2
- package/dist/types/pagination/paginators/ThreadPaginator.d.ts +15 -23
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +2 -6
- package/dist/types/pagination/sortCompiler.d.ts +11 -22
- package/dist/types/pagination/utility.normalization.d.ts +5 -23
- package/dist/types/pagination/utility.search.d.ts +3 -8
- package/dist/types/poll.d.ts +14 -14
- package/dist/types/poll_manager.d.ts +11 -2
- package/dist/types/poll_optimistic_votes.d.ts +10 -14
- package/dist/types/reminders/Reminder.d.ts +4 -4
- package/dist/types/reminders/ReminderManager.d.ts +7 -20
- package/dist/types/search/BaseSearchSource.d.ts +7 -12
- package/dist/types/search/ChannelSearchSource.d.ts +7 -7
- package/dist/types/search/MessageSearchSource.d.ts +7 -9
- package/dist/types/search/SearchController.d.ts +17 -22
- package/dist/types/search/types.d.ts +6 -10
- package/dist/types/signing.d.ts +12 -3
- package/dist/types/thread.d.ts +23 -71
- package/dist/types/thread_manager.d.ts +45 -70
- package/dist/types/token_manager.d.ts +8 -13
- package/dist/types/types.d.ts +64 -125
- package/dist/types/types.utility.d.ts +3 -3
- package/dist/types/upload-utils.d.ts +5 -10
- package/dist/types/uploadManager.d.ts +17 -45
- package/dist/types/utils/FixedSizeQueueCache.d.ts +6 -11
- package/dist/types/utils/WithSubscriptions.d.ts +5 -15
- package/dist/types/utils/concurrency.d.ts +11 -19
- package/dist/types/utils/mergeWith/mergeWith.d.ts +8 -11
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +5 -13
- package/dist/types/utils/mergeWith/mergeWithDiff.d.ts +22 -0
- package/dist/types/utils/objectPath.d.ts +6 -41
- package/dist/types/utils/retryable.d.ts +8 -12
- package/dist/types/utils/throttling/throttle.d.ts +8 -23
- package/dist/types/utils/time.d.ts +24 -64
- package/dist/types/utils.d.ts +40 -86
- package/package.json +7 -2
- package/src/ChannelManager.ts +159 -300
- package/src/CooldownTimer.ts +11 -29
- package/src/EventHandlerPipeline.ts +21 -44
- package/src/LiveLocationManager.ts +35 -74
- package/src/api-client.ts +43 -61
- package/src/campaign.ts +1 -1
- package/src/channel.ts +396 -749
- package/src/channel_batch_updater.ts +1 -1
- package/src/channel_state.ts +50 -105
- package/src/client.ts +360 -588
- package/src/client_state.ts +1 -6
- package/src/configuration/ConfigController.ts +41 -157
- package/src/configuration/InstanceConfigurationRegistry.ts +42 -171
- package/src/configuration/index.ts +1 -1
- package/src/configuration/keys.ts +13 -32
- package/src/configuration/shape.ts +67 -70
- package/src/configuration/types.ts +60 -100
- package/src/configuration/utils/applyInstanceConfiguration.ts +21 -53
- package/src/configuration/utils/copyConfigPatch.ts +11 -32
- package/src/configuration/utils/declarativeSlices.ts +9 -39
- package/src/configuration/utils/deepFreezeConfig.ts +3 -17
- package/src/configuration/utils/index.ts +2 -4
- package/src/configuration/utils/serverAuthority.ts +20 -68
- package/src/connection/ConnectionIdManager.ts +20 -49
- package/src/connection/ConnectionRecoveryManager.ts +51 -178
- package/src/connection/networkConnection/NetworkConnectionObserver.ts +37 -114
- package/src/connection/networkConnection/reporters.ts +9 -36
- package/src/connection/networkConnection/types.ts +12 -27
- package/src/connection/wsConnection/StableWSConnection.ts +73 -193
- package/src/connection/wsConnection/WSConnection.ts +56 -131
- package/src/connection/wsConnection/WSConnectionFallback.ts +22 -31
- package/src/connection/wsConnection/config.ts +13 -48
- package/src/connection/wsConnection/types.ts +17 -70
- package/src/constants.ts +4 -4
- package/src/entityStore/EntityStore.ts +162 -167
- package/src/entityStore/StoreBackedItemIndex.ts +14 -47
- package/src/errors.ts +7 -19
- package/src/formatMessageMemo.ts +3 -9
- package/src/gen/chat/ChannelApi.ts +19 -0
- package/src/gen/chat/ChatApi.ts +87 -13
- package/src/gen/models/index.ts +793 -71
- package/src/gen/moderation/ModerationApi.ts +0 -4
- package/src/index.ts +10 -14
- package/src/languageNames.ts +9 -24
- package/src/logger.ts +1 -3
- package/src/messageComposer/LocationComposer.ts +7 -23
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -2
- package/src/messageComposer/attachmentIdentity.ts +2 -13
- package/src/messageComposer/attachmentManager.ts +17 -63
- package/src/messageComposer/attachmentUtils.ts +3 -17
- package/src/messageComposer/configuration/configuration.ts +5 -8
- package/src/messageComposer/configuration/types.ts +29 -56
- package/src/messageComposer/fileUtils.ts +1 -1
- package/src/messageComposer/linkPreviewsManager.ts +8 -20
- package/src/messageComposer/messageComposer.ts +54 -222
- package/src/messageComposer/middleware/attachmentManager/postUpload/attachmentEnrichment.ts +4 -16
- package/src/messageComposer/middleware/attachmentManager/postUpload/uploadErrorHandler.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/attachments.ts +14 -40
- package/src/messageComposer/middleware/messageComposer/linkPreviews.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +4 -11
- package/src/messageComposer/middleware/pollComposer/state.ts +2 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +2 -4
- package/src/messageComposer/middleware/pollComposer/validation.ts +8 -26
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +1 -6
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +1 -2
- package/src/messageComposer/middleware/textComposer/commands.ts +11 -16
- package/src/messageComposer/middleware/textComposer/mentions.ts +32 -70
- package/src/messageComposer/middleware/textComposer/textMiddlewareUtils.ts +10 -4
- package/src/messageComposer/middleware/textComposer/types.ts +1 -6
- package/src/messageComposer/pollComposer.ts +11 -8
- package/src/messageComposer/textComposer.ts +9 -59
- package/src/messageComposer/types.ts +9 -12
- package/src/messageDelivery/MessageDeliveryReporter.ts +60 -113
- package/src/messageDelivery/MessageReceiptsTracker.ts +21 -105
- package/src/messageOperations/FailedSendCache.ts +4 -9
- package/src/messageOperations/MessageOperationStatePolicy.ts +40 -67
- package/src/messageOperations/MessageOperations.ts +33 -62
- package/src/messageOperations/applyReactionLocally.ts +9 -28
- package/src/messageOperations/createMessageOperations.ts +17 -33
- package/src/messageOperations/reflectReactionEvent.ts +5 -13
- package/src/messageOperations/sendOrdering.ts +4 -7
- package/src/messageOperations/settlePendingAttachmentUploads.ts +10 -21
- package/src/messageOperations/types.ts +15 -30
- package/src/middleware.ts +7 -10
- package/src/moderation.ts +25 -21
- package/src/notifications/NotificationManager.ts +11 -35
- package/src/notifications/types.ts +19 -59
- package/src/offline-support/offline_support_api.ts +178 -608
- package/src/offline-support/offline_sync_manager.ts +25 -69
- package/src/offline-support/queueableOperations.ts +31 -84
- package/src/offline-support/types.ts +25 -188
- package/src/pagination/ItemIndex.ts +4 -12
- package/src/pagination/cursorDerivation/aroundPaginationFlags.ts +29 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +13 -62
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +11 -39
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +4 -6
- package/src/pagination/filterCompiler.ts +11 -25
- package/src/pagination/paginators/BasePaginator.ts +422 -976
- package/src/pagination/paginators/ChannelPaginator.ts +130 -190
- package/src/pagination/paginators/MessageIntervalPaginator.ts +226 -457
- package/src/pagination/paginators/MessagePaginator.ts +135 -175
- package/src/pagination/paginators/PinnedMessagePaginator.ts +13 -38
- package/src/pagination/paginators/ReminderPaginator.ts +12 -15
- package/src/pagination/paginators/ThreadPaginator.ts +16 -26
- package/src/pagination/paginators/UserGroupPaginator.ts +6 -17
- package/src/pagination/paginators/stateThrottling.ts +5 -10
- package/src/pagination/sortCompiler.ts +23 -50
- package/src/pagination/utility.normalization.ts +8 -30
- package/src/pagination/utility.search.ts +4 -11
- package/src/poll.ts +19 -19
- package/src/poll_manager.ts +16 -20
- package/src/poll_optimistic_votes.ts +17 -22
- package/src/reminders/Reminder.ts +5 -6
- package/src/reminders/ReminderManager.ts +9 -34
- package/src/reminders/ReminderTimer.ts +1 -2
- package/src/search/BaseSearchSource.ts +14 -29
- package/src/search/ChannelSearchSource.ts +8 -8
- package/src/search/MessageSearchSource.ts +19 -25
- package/src/search/SearchController.ts +18 -24
- package/src/search/types.ts +6 -10
- package/src/segment.ts +1 -1
- package/src/signing.ts +23 -3
- package/src/thread.ts +72 -173
- package/src/thread_manager.ts +59 -76
- package/src/token_manager.ts +11 -21
- package/src/types.ts +78 -126
- package/src/types.utility.ts +3 -3
- package/src/upload-utils.ts +5 -10
- package/src/uploadManager.ts +22 -54
- package/src/utils/FixedSizeQueueCache.ts +13 -21
- package/src/utils/WithSubscriptions.ts +5 -15
- package/src/utils/concurrency.ts +16 -55
- package/src/utils/mergeWith/mergeWith.ts +10 -13
- package/src/utils/mergeWith/mergeWithCore.ts +24 -81
- package/src/utils/mergeWith/mergeWithDiff.ts +15 -33
- package/src/utils/objectPath.ts +6 -41
- package/src/utils/retryable.ts +10 -14
- package/src/utils/throttling/throttle.ts +9 -25
- package/src/utils/time.ts +26 -66
- package/src/utils.ts +72 -128
|
@@ -46,62 +46,47 @@ export type MessageOperationsHandlers = {
|
|
|
46
46
|
update?: OperationRequestFn<'update'>;
|
|
47
47
|
};
|
|
48
48
|
export type MessageOperationsContext = {
|
|
49
|
-
/**
|
|
50
|
-
* The channel every request and offline-DB row belongs to. A `Thread` passes its parent channel,
|
|
51
|
-
* since a reply is sent, persisted and reacted to against the channel like any other message. It is
|
|
52
|
-
* what lets the reaction operations live here rather than being written once per owner.
|
|
53
|
-
*/
|
|
49
|
+
/** The channel every request and offline-DB row belongs to. A `Thread` passes its parent channel. */
|
|
54
50
|
channel: Channel;
|
|
55
51
|
ingest: (m: LocalMessage) => void;
|
|
56
52
|
get: (id: string) => LocalMessage | undefined;
|
|
57
|
-
/**
|
|
58
|
-
* Drops the message from local state entirely. Needed by the delete lifecycle: a hard delete removes
|
|
59
|
-
* the message rather than marking it `deleted` (mirroring the `message.deleted` WS handler, which
|
|
60
|
-
* branches on `event.hard_delete` the same way).
|
|
61
|
-
*/
|
|
53
|
+
/** Drops the message from local state: a hard delete removes it rather than marking it `deleted`. */
|
|
62
54
|
remove: (id: string) => void;
|
|
63
|
-
/**
|
|
64
|
-
* Mirrors a message into the offline DB. Fire-and-forget: local state is the source of truth, so a
|
|
65
|
-
* failed DB write must never fail the operation.
|
|
66
|
-
*/
|
|
55
|
+
/** Mirrors a message into the offline DB. Fire-and-forget: a failed write never fails the operation. */
|
|
67
56
|
persist: (m: LocalMessage) => void;
|
|
68
57
|
/** Removes a message's offline-DB row (the hard-delete counterpart of {@link persist}). */
|
|
69
58
|
purge: (id: string) => void;
|
|
70
59
|
/**
|
|
71
|
-
* Whether this message's mutation
|
|
72
|
-
*
|
|
73
|
-
* not failed
|
|
74
|
-
* Reactions run the same predicate, which is what keeps the two from drifting.
|
|
60
|
+
* Whether this message's mutation sits in the offline queue waiting to be replayed, read from the
|
|
61
|
+
* queue rather than inferred from the error ({@link isQueuedForReplay}). A queued mutation is pending,
|
|
62
|
+
* not failed: the optimistic state stays as it is. Reactions use the same predicate.
|
|
75
63
|
*/
|
|
76
64
|
isQueued: (messageId: string, types: readonly QueueableType[]) => Promise<boolean>;
|
|
77
65
|
normalizeOutgoingMessage?: (m: MessageRequest) => MessageRequest;
|
|
78
66
|
/** Runs first on every send (not a retry). This is where the typing indicator is stopped. */
|
|
79
67
|
beforeSend?: () => void;
|
|
80
68
|
/**
|
|
81
|
-
* Lets the owner
|
|
82
|
-
*
|
|
83
|
-
* request only; call it once and return its result.
|
|
69
|
+
* Lets the owner serialize requests: the server dates a message on arrival, so a short text sent after
|
|
70
|
+
* a photo would otherwise be dated first. Wraps the request only; call it once and return its result.
|
|
84
71
|
*/
|
|
85
72
|
sequenceRequests?: <T>(kind: OperationKind, request: () => Promise<T>) => Promise<T>;
|
|
86
73
|
/**
|
|
87
|
-
* Resolves any attachment upload still in flight, returning the attachments with their URLs
|
|
88
|
-
*
|
|
89
|
-
* with {@link AttachmentManagerConfig.pendingUploadsEnabled} on.
|
|
74
|
+
* Resolves any attachment upload still in flight, returning the attachments with their URLs written
|
|
75
|
+
* on. Only reachable with {@link AttachmentManagerConfig.pendingUploadsEnabled} on.
|
|
90
76
|
*/
|
|
91
77
|
settlePendingUploads?: (attachments: NonNullable<LocalMessage['attachments']>) => Promise<{
|
|
92
78
|
/**
|
|
93
|
-
* The same list, with each upload
|
|
94
|
-
* `localMetadata` dropped.
|
|
95
|
-
*
|
|
96
|
-
* nothing was pending.
|
|
79
|
+
* The same list, with each resolved upload replaced by its uploaded form (URL written,
|
|
80
|
+
* `localMetadata` dropped). Unresolved ones come back untouched, so on failure this is a mix. The
|
|
81
|
+
* same reference when nothing was pending.
|
|
97
82
|
*/
|
|
98
83
|
attachments: NonNullable<LocalMessage['attachments']>;
|
|
99
84
|
/** Set if any upload failed. The ones that did resolve are still kept above. */
|
|
100
85
|
failureReason?: unknown;
|
|
101
86
|
}>;
|
|
102
87
|
/**
|
|
103
|
-
* The HTTP requests, through the offline queue
|
|
104
|
-
*
|
|
88
|
+
* The HTTP requests, through the offline queue, used when no {@link handlers} entry replaces them.
|
|
89
|
+
* A replaced request still reaches them through its `defaultRequest`.
|
|
105
90
|
*/
|
|
106
91
|
defaults: {
|
|
107
92
|
delete: (id: string, o?: DeleteMessageOptions) => Promise<OperationResponse>;
|
|
@@ -13,6 +13,10 @@ export type MiddlewareExecutionResult<TValue> = {
|
|
|
13
13
|
export type ExecuteParams<TValue> = {
|
|
14
14
|
eventName: string;
|
|
15
15
|
initialValue: TValue;
|
|
16
|
+
/**
|
|
17
|
+
* `cancelable`: a new run cancels the unresolved previous run of the same `eventName`.
|
|
18
|
+
* `concurrent`: every run executes. Defaults to `cancelable`.
|
|
19
|
+
*/
|
|
16
20
|
mode?: 'concurrent' | 'cancelable';
|
|
17
21
|
};
|
|
18
22
|
export type MiddlewareHandlerParams<TValue> = {
|
|
@@ -35,11 +39,9 @@ export declare class MiddlewareExecutor<TValue, THandlers extends string> {
|
|
|
35
39
|
private middleware;
|
|
36
40
|
constructor();
|
|
37
41
|
/**
|
|
38
|
-
* The middleware
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* exists so components can ask what the chain is capable of - a middleware may declare
|
|
42
|
-
* behaviour its host has to account for, and the host has no other way to find out.
|
|
42
|
+
* The installed middleware in execution order, read-only, so a host component can check what the
|
|
43
|
+
* chain contains (by `id`). Change the chain with `use`, `insert`, `replace`, `setOrder` or
|
|
44
|
+
* `remove`.
|
|
43
45
|
*/
|
|
44
46
|
get installedMiddleware(): ReadonlyArray<Middleware<TValue, THandlers>>;
|
|
45
47
|
use(middleware: Middleware<TValue, THandlers> | Middleware<TValue, THandlers>[]): this;
|
|
@@ -5,41 +5,48 @@ export declare const MODERATION_ENTITY_TYPES: {
|
|
|
5
5
|
user: string;
|
|
6
6
|
message: string;
|
|
7
7
|
};
|
|
8
|
+
/** Moderation v2 endpoints. */
|
|
8
9
|
export declare class Moderation extends ModerationApi {
|
|
9
10
|
client: StreamChat;
|
|
10
11
|
constructor(client: StreamChat);
|
|
11
12
|
/**
|
|
12
13
|
* Flags a user.
|
|
13
14
|
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
15
|
+
* @param request - The user to flag, the reason and any other flag option.
|
|
16
|
+
* @param request.user_id - User ID to be flagged.
|
|
17
|
+
* @param request.reason - Reason for flagging the user (optional).
|
|
18
|
+
* @param request.custom - Additional data to be stored with the flag (optional).
|
|
19
|
+
* @param request.entity_creator_id - ID of the user who created the flagged entity.
|
|
19
20
|
* Omitted when not supplied; the server resolves it from the entity (optional).
|
|
20
|
-
* @param
|
|
21
|
+
* @param request.moderation_payload - Content submitted for moderation alongside the
|
|
21
22
|
* flag (optional).
|
|
22
23
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
23
24
|
* into the request (optional).
|
|
24
25
|
* @returns The flag response.
|
|
25
26
|
*/
|
|
26
|
-
flagUser(
|
|
27
|
+
flagUser({ user_id, reason, ...options }: {
|
|
28
|
+
user_id: string;
|
|
29
|
+
reason?: string;
|
|
30
|
+
} & ModerationFlagOptions, requestOptions?: StreamRequestOptions): Promise<import("./types").StreamResponse<import(".").FlagItemResponse>>;
|
|
27
31
|
/**
|
|
28
32
|
* Flags a message.
|
|
29
33
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @param
|
|
34
|
-
* @param
|
|
34
|
+
* @param request - The message to flag, the reason and any other flag option.
|
|
35
|
+
* @param request.message_id - ID of the message to be flagged.
|
|
36
|
+
* @param request.reason - Reason for flagging the message (optional).
|
|
37
|
+
* @param request.custom - Additional data to be stored with the flag (optional).
|
|
38
|
+
* @param request.entity_creator_id - ID of the user who created the flagged entity.
|
|
35
39
|
* Omitted when not supplied; the server resolves it from the entity (optional).
|
|
36
|
-
* @param
|
|
40
|
+
* @param request.moderation_payload - Content submitted for moderation alongside the
|
|
37
41
|
* flag (optional).
|
|
38
42
|
* @param requestOptions - Per-request options such as an abort `signal`. Never serialized
|
|
39
43
|
* into the request (optional).
|
|
40
44
|
* @returns The flag response.
|
|
41
45
|
*/
|
|
42
|
-
flagMessage(
|
|
46
|
+
flagMessage({ message_id, reason, ...options }: {
|
|
47
|
+
message_id: string;
|
|
48
|
+
reason?: string;
|
|
49
|
+
} & ModerationFlagOptions, requestOptions?: StreamRequestOptions): Promise<import("./types").StreamResponse<import(".").FlagItemResponse>>;
|
|
43
50
|
/**
|
|
44
51
|
* Unmutes a user.
|
|
45
52
|
*
|
|
@@ -4,36 +4,21 @@ import type { DeepPartial } from '../types.utility';
|
|
|
4
4
|
export declare class NotificationManager {
|
|
5
5
|
store: StateStore<NotificationState>;
|
|
6
6
|
private timeouts;
|
|
7
|
-
/** The shared configuration machinery — see {@link ConfigController}. */
|
|
8
7
|
private readonly configController;
|
|
9
|
-
/**
|
|
10
|
-
* Resolved configuration, as a store so consumers can react to it — the same shape every configurable
|
|
11
|
-
* class exposes (`configState` for the store, {@link config} for the current value).
|
|
12
|
-
*/
|
|
13
8
|
get configState(): StateStore<NotificationManagerConfig>;
|
|
14
9
|
constructor(config?: Partial<NotificationManagerConfig>);
|
|
10
|
+
get config(): Readonly<NotificationManagerConfig>;
|
|
15
11
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
12
|
+
* Merges a partial configuration into the resolved config.
|
|
13
|
+
*
|
|
14
|
+
* @param config - Fields to merge into the resolved config.
|
|
18
15
|
*/
|
|
19
|
-
get config(): Readonly<NotificationManagerConfig>;
|
|
20
|
-
/** Deep-merges a partial configuration into the resolved config and notifies subscribers. */
|
|
21
16
|
updateConfig(config: Partial<NotificationManagerConfig>): void;
|
|
22
17
|
/**
|
|
23
|
-
* Rebuilds the
|
|
24
|
-
*
|
|
25
|
-
* with `client.config.reset()`.
|
|
18
|
+
* Rebuilds the config from the defaults, `config` and the constructor options instead of merging
|
|
19
|
+
* into the current value, so a `sortComparator` set through `updateConfig` is dropped.
|
|
26
20
|
*
|
|
27
|
-
*
|
|
28
|
-
* {@link updateConfig} deep-merges, and `sortComparator` is optional — so unlike every other field of
|
|
29
|
-
* every other manager config, it has no counterpart in {@link DEFAULT_NOTIFICATION_MANAGER_CONFIG} for
|
|
30
|
-
* a derivation to overwrite it with. Registering one through `client.config` therefore made it
|
|
31
|
-
* permanent: `reset()` re-derived, the merge kept it, and nothing could ever remove it. A merge cannot
|
|
32
|
-
* express a removal; this is the same rule `Channel.initializeConfig` follows for `requestHandlers`.
|
|
33
|
-
*
|
|
34
|
-
* The defaults are copied rather than spread, because a shallow spread would leave `durations`
|
|
35
|
-
* pointing at the module-level object and put it in the store, where a nested write would change the
|
|
36
|
-
* default for every client in the process.
|
|
21
|
+
* @param config - The declarative slice. Defaults to `{}`.
|
|
37
22
|
*/
|
|
38
23
|
initializeConfig(config?: DeepPartial<NotificationManagerConfig>): void;
|
|
39
24
|
get notifications(): Notification[];
|
|
@@ -48,15 +33,7 @@ export declare class NotificationManager {
|
|
|
48
33
|
addSuccess({ message, origin, options }: AddNotificationPayload): string;
|
|
49
34
|
clearTimeout(id: string): void;
|
|
50
35
|
startTimeout(id: string, durationOverride?: number): void;
|
|
51
|
-
/**
|
|
52
|
-
* Starts the notification's auto-dismiss countdown unless one is already running.
|
|
53
|
-
*
|
|
54
|
-
* The counterpart to {@link startTimeout}, which always restarts. Use this wherever the caller
|
|
55
|
-
* cannot know whether the countdown has been started already -- a UI component that remounts and
|
|
56
|
-
* has lost the record, or a second view displaying the same notification. Restarting there is
|
|
57
|
-
* invisible and open-ended: each call hands the notification another full lifetime, so it can
|
|
58
|
-
* outlive its duration indefinitely while looking like it is counting down.
|
|
59
|
-
*/
|
|
36
|
+
/** Like {@link startTimeout}, but a no-op when a countdown is already running. */
|
|
60
37
|
ensureTimeout(id: string, durationOverride?: number): void;
|
|
61
38
|
remove(id: string): void;
|
|
62
39
|
clear(): void;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
/** Represents the severity level of a notification */
|
|
2
1
|
export type NotificationSeverity = 'error' | 'warning' | 'info' | 'success' | (string & {});
|
|
3
|
-
/** Represents an action button for a notification */
|
|
4
2
|
export type NotificationAction = {
|
|
5
|
-
/** Text label for the action button */
|
|
6
3
|
label: string;
|
|
7
|
-
/** Handler function called when action button is clicked */
|
|
8
4
|
handler: () => void;
|
|
9
|
-
/** Optional metadata for styling or other custom properties */
|
|
10
5
|
metadata?: Record<string, unknown>;
|
|
11
6
|
};
|
|
12
7
|
export type NotificationOrigin = {
|
|
@@ -14,22 +9,11 @@ export type NotificationOrigin = {
|
|
|
14
9
|
context?: Record<string, unknown>;
|
|
15
10
|
};
|
|
16
11
|
/**
|
|
17
|
-
*
|
|
12
|
+
* Notification types emitted by `stream-chat`, formatted `domain:entity:operation:result`
|
|
13
|
+
* (e.g. `api:message:send:failed`).
|
|
18
14
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* - `entity` — what was operated on: `attachment`, `poll`, `message`, `command`, `location`
|
|
22
|
-
* - `operation` — what was attempted, lowerCamelCase: `upload`, `create`, `castVote`, `jumpToLatest`
|
|
23
|
-
* - `result` — what happened: `failed`, `blocked`, `invalid`, `missing`, `limit`, `success`,
|
|
24
|
-
* or a short hyphenated state such as `in-progress` / `not-ready`
|
|
25
|
-
*
|
|
26
|
-
* **These values are public API.** UI SDKs key their translation tables on them, so renaming one is
|
|
27
|
-
* a breaking change. Emit them through this map rather than writing the literal inline, so the whole
|
|
28
|
-
* set stays greppable from one place and a typo is a compile error.
|
|
29
|
-
*
|
|
30
|
-
* Consumers translating notifications should switch on {@link Notification.type} rather than matching
|
|
31
|
-
* on {@link Notification.message}, which is untranslated English intended as a developer-facing
|
|
32
|
-
* fallback.
|
|
15
|
+
* **The values are public API**: UI SDKs key their translations on them. Emit them through this
|
|
16
|
+
* map, never as inline literals.
|
|
33
17
|
*/
|
|
34
18
|
export declare const CORE_NOTIFICATION_TYPE: {
|
|
35
19
|
readonly attachmentFileMissing: "validation:attachment:file:missing";
|
|
@@ -41,79 +25,55 @@ export declare const CORE_NOTIFICATION_TYPE: {
|
|
|
41
25
|
readonly commandDisabled: "validation:command:disabled";
|
|
42
26
|
readonly commandNotReady: "validation:command:not-ready";
|
|
43
27
|
readonly locationCreateFailed: "api:location:create:failed";
|
|
44
|
-
/** Jumping to a specific message failed. */
|
|
45
28
|
readonly messageJumpFailed: "api:message:jump:failed";
|
|
46
|
-
/** Jumping to the latest message failed. */
|
|
47
29
|
readonly messageJumpToLatestFailed: "api:message:jumpToLatest:failed";
|
|
48
|
-
/**
|
|
30
|
+
/** The message stays in the list, marked failed. */
|
|
49
31
|
readonly messageSendFailed: "api:message:send:failed";
|
|
50
|
-
/**
|
|
32
|
+
/** The edit is kept on the message, marked failed. */
|
|
51
33
|
readonly messageUpdateFailed: "api:message:update:failed";
|
|
52
34
|
readonly pollCastVoteLimit: "validation:poll:castVote:limit";
|
|
53
35
|
readonly pollCreateFailed: "api:poll:create:failed";
|
|
54
36
|
};
|
|
55
37
|
/** A notification type emitted by `stream-chat` itself. See {@link CORE_NOTIFICATION_TYPE}. */
|
|
56
38
|
export type CoreNotificationType = (typeof CORE_NOTIFICATION_TYPE)[keyof typeof CORE_NOTIFICATION_TYPE];
|
|
57
|
-
/** Represents a single notification message */
|
|
58
39
|
export type Notification = {
|
|
59
|
-
/** Unique identifier for the notification */
|
|
60
40
|
id: string;
|
|
61
41
|
/**
|
|
62
|
-
* Untranslated English text
|
|
63
|
-
*
|
|
64
|
-
* This is a **developer-facing fallback, not display copy.** It is not localized and its exact
|
|
65
|
-
* wording is not part of the public contract — it can be reworded in a minor release. Anything
|
|
66
|
-
* user-facing should resolve {@link Notification.type} to its own copy and fall back to this string
|
|
67
|
-
* only for an identifier it does not recognize.
|
|
42
|
+
* Untranslated English text, a developer-facing fallback rather than display copy. Its wording
|
|
43
|
+
* can change in a minor release: resolve {@link Notification.type} to your own copy instead.
|
|
68
44
|
*/
|
|
69
45
|
message: string;
|
|
70
|
-
/**
|
|
46
|
+
/** Creation time, in ms since epoch. */
|
|
71
47
|
createdAt: number;
|
|
72
|
-
/**
|
|
73
|
-
* Identifier of the notification emitter.
|
|
74
|
-
* The identifier then can be recognized by notification consumers to act upon specific origin values.
|
|
75
|
-
*/
|
|
48
|
+
/** The emitter, which consumers can match to act on specific origins. */
|
|
76
49
|
origin: NotificationOrigin;
|
|
77
|
-
/** Array of action buttons for the notification */
|
|
78
50
|
actions?: NotificationAction[];
|
|
79
|
-
/** The severity level of the notification (defaults to `undefined` unless explicitly provided). */
|
|
80
51
|
severity?: NotificationSeverity;
|
|
81
52
|
/**
|
|
82
|
-
* Stable identifier for what
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* Values emitted by `stream-chat` are enumerated in {@link CORE_NOTIFICATION_TYPE}; those are the
|
|
86
|
-
* ones that autocomplete. The type stays open so SDKs and integrators can emit their own
|
|
87
|
-
* identifiers following the same `domain:entity:operation:result` convention.
|
|
53
|
+
* Stable identifier for what the notification is about, for grouping and for resolving a
|
|
54
|
+
* translation. Values emitted by `stream-chat` are in {@link CORE_NOTIFICATION_TYPE}. Custom
|
|
55
|
+
* identifiers should follow the same `domain:entity:operation:result` format.
|
|
88
56
|
*/
|
|
89
57
|
type?: CoreNotificationType | (string & {});
|
|
90
|
-
/**
|
|
58
|
+
/** Auto-dismiss duration in ms. The countdown starts on `NotificationManager.startTimeout()`. */
|
|
91
59
|
duration?: number;
|
|
92
|
-
/** Optional metadata to attach to the notification */
|
|
93
60
|
metadata?: Record<string, unknown>;
|
|
94
|
-
/**
|
|
61
|
+
/** For routing or grouping (e.g. `target:channel`). */
|
|
95
62
|
tags?: string[];
|
|
96
|
-
/**
|
|
63
|
+
/** The originally thrown error, for error notifications. */
|
|
97
64
|
originalError?: Error;
|
|
98
65
|
};
|
|
99
|
-
/** Configuration options when creating a notification */
|
|
100
66
|
export type NotificationOptions = Partial<Pick<Notification, 'type' | 'severity' | 'actions' | 'metadata' | 'tags' | 'originalError'>> & {
|
|
101
67
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
68
|
+
* Display time in ms. `0` is persistent: dismiss it with `client.notifications.remove(id)`.
|
|
69
|
+
* Defaults to the configured duration of the severity.
|
|
104
70
|
*/
|
|
105
71
|
duration?: number;
|
|
106
72
|
};
|
|
107
|
-
/**
|
|
108
|
-
* State shape for the notification store.
|
|
109
|
-
*
|
|
110
|
-
* @deprecated Use {@link NotificationManagerState} instead.
|
|
111
|
-
*/
|
|
73
|
+
/** @deprecated Use {@link NotificationManagerState} instead. */
|
|
112
74
|
export type NotificationState = {
|
|
113
|
-
/** Array of current notification objects. */
|
|
114
75
|
notifications: Notification[];
|
|
115
76
|
};
|
|
116
|
-
/** State shape for the notification store */
|
|
117
77
|
export type NotificationManagerState = NotificationState;
|
|
118
78
|
export type NotificationSortComparator = (a: Notification, b: Notification) => number;
|
|
119
79
|
export type NotificationManagerConfig = {
|