stream-chat 9.50.2 → 10.0.0-rc.1
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 +18869 -13986
- package/dist/cjs/index.browser.js.map +4 -4
- package/dist/cjs/index.node.js +18888 -13992
- package/dist/cjs/index.node.js.map +4 -4
- package/dist/esm/index.mjs +18866 -13983
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/ChannelPaginatorsOrchestrator.d.ts +130 -0
- package/dist/types/EventHandlerPipeline.d.ts +104 -0
- package/dist/types/api-client.d.ts +26 -0
- package/dist/types/campaign.d.ts +0 -44
- package/dist/types/channel.d.ts +436 -480
- package/dist/types/channel_batch_updater.d.ts +0 -93
- package/dist/types/channel_manager.d.ts +8 -10
- package/dist/types/channel_state.d.ts +53 -201
- package/dist/types/client.d.ts +440 -1910
- package/dist/types/client_state.d.ts +4 -4
- package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
- package/dist/types/configuration/index.d.ts +1 -0
- package/dist/types/configuration/types.d.ts +53 -0
- package/dist/types/connection.d.ts +49 -41
- package/dist/types/connection_fallback.d.ts +6 -4
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/custom_types.d.ts +2 -0
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
- package/dist/types/gen/chat/ChatApi.d.ts +334 -0
- package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
- package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
- package/dist/types/gen/models/index.d.ts +8836 -0
- package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
- package/dist/types/gen-imports.d.ts +3 -0
- package/dist/types/index.d.ts +5 -5
- package/dist/types/insights.d.ts +7 -6
- package/dist/types/logger.d.ts +9 -0
- package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
- package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
- package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
- package/dist/types/messageComposer/configuration/types.d.ts +11 -11
- package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
- package/dist/types/messageComposer/messageComposer.d.ts +10 -10
- package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
- package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
- package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
- package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
- package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
- package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
- package/dist/types/messageComposer/pollComposer.d.ts +5 -4
- package/dist/types/messageComposer/textComposer.d.ts +8 -3
- package/dist/types/messageComposer/types.d.ts +6 -28
- package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
- package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
- package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
- package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
- package/dist/types/messageOperations/index.d.ts +3 -0
- package/dist/types/messageOperations/types.d.ts +49 -0
- package/dist/types/moderation.d.ts +21 -203
- package/dist/types/notifications/types.d.ts +8 -7
- package/dist/types/offline-support/offline_support_api.d.ts +110 -87
- package/dist/types/offline-support/types.d.ts +19 -23
- package/dist/types/offline-support/util.d.ts +4 -2
- package/dist/types/pagination/FilterBuilder.d.ts +1 -1
- package/dist/types/pagination/ItemIndex.d.ts +82 -0
- package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
- package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
- package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
- package/dist/types/pagination/filterCompiler.d.ts +7 -0
- package/dist/types/pagination/index.d.ts +1 -3
- package/dist/types/pagination/paginators/BasePaginator.d.ts +709 -0
- package/dist/types/pagination/paginators/ChannelPaginator.d.ts +58 -0
- package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +260 -0
- package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
- package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
- package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
- package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
- package/dist/types/pagination/paginators/index.d.ts +7 -0
- package/dist/types/pagination/sortCompiler.d.ts +49 -0
- package/dist/types/pagination/types.normalization.d.ts +11 -0
- package/dist/types/pagination/utility.normalization.d.ts +18 -0
- package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
- package/dist/types/pagination/utility.search.d.ts +13 -0
- package/dist/types/permissions.d.ts +1 -1
- package/dist/types/poll.d.ts +29 -32
- package/dist/types/poll_manager.d.ts +2 -2
- package/dist/types/reminders/Reminder.d.ts +2 -5
- package/dist/types/reminders/ReminderManager.d.ts +2 -9
- package/dist/types/search/MessageSearchSource.d.ts +4 -4
- package/dist/types/search/UserSearchSource.d.ts +1 -1
- package/dist/types/search/types.d.ts +3 -3
- package/dist/types/segment.d.ts +0 -34
- package/dist/types/signing.d.ts +105 -65
- package/dist/types/store.d.ts +1 -0
- package/dist/types/thread.d.ts +51 -34
- package/dist/types/thread_manager.d.ts +3 -3
- package/dist/types/token_manager.d.ts +15 -10
- package/dist/types/types.d.ts +196 -3384
- package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
- package/dist/types/utils/WithSubscriptions.d.ts +2 -1
- package/dist/types/utils/concurrency.d.ts +4 -4
- package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
- package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
- package/dist/types/utils/retryable.d.ts +34 -0
- package/dist/types/utils.d.ts +104 -137
- package/package.json +7 -3
- package/src/ChannelPaginatorsOrchestrator.ts +545 -0
- package/src/CooldownTimer.ts +2 -2
- package/src/EventHandlerPipeline.ts +228 -0
- package/src/LiveLocationManager.ts +12 -11
- package/src/api-client.ts +275 -0
- package/src/campaign.ts +1 -77
- package/src/channel.ts +1262 -1277
- package/src/channel_batch_updater.ts +1 -211
- package/src/channel_manager.ts +92 -88
- package/src/channel_state.ts +144 -1013
- package/src/client.ts +888 -3944
- package/src/client_state.ts +4 -4
- package/src/configuration/InstanceConfigurationService.ts +73 -0
- package/src/configuration/index.ts +1 -0
- package/src/configuration/types.ts +81 -0
- package/src/connection.ts +145 -94
- package/src/connection_fallback.ts +29 -27
- package/src/constants.ts +1 -5
- package/src/custom_types.ts +4 -1
- package/src/errors.ts +2 -2
- package/src/gen/chat/ChannelApi.ts +275 -0
- package/src/gen/chat/ChatApi.ts +2554 -0
- package/src/gen/model-decoders/decoders.ts +2680 -0
- package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
- package/src/gen/models/index.ts +12673 -0
- package/src/gen/moderation/ModerationApi.ts +607 -0
- package/src/gen-imports.ts +3 -0
- package/src/index.ts +5 -10
- package/src/insights.ts +6 -5
- package/src/logger.ts +28 -0
- package/src/messageComposer/LocationComposer.ts +9 -5
- package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
- package/src/messageComposer/attachmentIdentity.ts +16 -9
- package/src/messageComposer/attachmentManager.ts +13 -8
- package/src/messageComposer/configuration/types.ts +11 -11
- package/src/messageComposer/linkPreviewsManager.ts +9 -10
- package/src/messageComposer/messageComposer.ts +57 -53
- package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
- package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
- package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
- package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
- package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
- package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
- package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
- package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
- package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
- package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
- package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
- package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
- package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
- package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
- package/src/messageComposer/middleware/textComposer/types.ts +9 -4
- package/src/messageComposer/pollComposer.ts +6 -8
- package/src/messageComposer/textComposer.ts +27 -2
- package/src/messageComposer/types.ts +6 -28
- package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
- package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
- package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
- package/src/messageOperations/MessageOperations.ts +212 -0
- package/src/messageOperations/index.ts +10 -0
- package/src/messageOperations/types.ts +64 -0
- package/src/moderation.ts +38 -431
- package/src/notifications/types.ts +8 -7
- package/src/offline-support/offline_support_api.ts +198 -132
- package/src/offline-support/offline_sync_manager.ts +17 -7
- package/src/offline-support/types.ts +23 -26
- package/src/offline-support/util.ts +5 -4
- package/src/pagination/FilterBuilder.ts +4 -1
- package/src/pagination/ItemIndex.ts +112 -0
- package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
- package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
- package/src/pagination/cursorDerivation/index.ts +1 -0
- package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
- package/src/pagination/filterCompiler.ts +196 -0
- package/src/pagination/index.ts +1 -3
- package/src/pagination/paginators/BasePaginator.ts +2393 -0
- package/src/pagination/paginators/ChannelPaginator.ts +427 -0
- package/src/pagination/paginators/MessageIntervalPaginator.ts +1073 -0
- package/src/pagination/paginators/MessagePaginator.ts +496 -0
- package/src/pagination/paginators/PinnedMessagePaginator.ts +105 -0
- package/src/pagination/paginators/ReminderPaginator.ts +105 -0
- package/src/pagination/paginators/UserGroupPaginator.ts +125 -0
- package/src/pagination/paginators/index.ts +7 -0
- package/src/pagination/sortCompiler.ts +178 -0
- package/src/pagination/types.normalization.ts +14 -0
- package/src/pagination/utility.normalization.ts +106 -0
- package/src/pagination/utility.queryChannel.ts +84 -0
- package/src/pagination/utility.search.ts +80 -0
- package/src/permissions.ts +7 -8
- package/src/poll.ts +101 -110
- package/src/poll_manager.ts +14 -8
- package/src/reminders/Reminder.ts +2 -5
- package/src/reminders/ReminderManager.ts +19 -21
- package/src/search/BaseSearchSource.ts +0 -3
- package/src/search/ChannelMemberSearchSource.ts +7 -1
- package/src/search/ChannelSearchSource.ts +10 -3
- package/src/search/MessageSearchSource.ts +29 -30
- package/src/search/UserSearchSource.ts +12 -8
- package/src/search/types.ts +3 -4
- package/src/segment.ts +1 -95
- package/src/signing.ts +107 -67
- package/src/store.ts +2 -1
- package/src/thread.ts +439 -236
- package/src/thread_manager.ts +36 -15
- package/src/token_manager.ts +21 -10
- package/src/types.ts +375 -4524
- package/src/uploadManager.ts +8 -0
- package/src/utils/FixedSizeQueueCache.ts +12 -6
- package/src/utils/WithSubscriptions.ts +2 -1
- package/src/utils/concurrency.ts +4 -4
- package/src/utils/mergeWith/mergeWith.ts +3 -3
- package/src/utils/mergeWith/mergeWithCore.ts +140 -164
- package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
- package/src/utils/retryable.ts +117 -0
- package/src/utils.ts +133 -524
- package/dist/types/events.d.ts +0 -72
- package/dist/types/pagination/BasePaginator.d.ts +0 -69
- package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
- package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
- package/src/events.ts +0 -75
- package/src/pagination/BasePaginator.ts +0 -184
- package/src/pagination/ReminderPaginator.ts +0 -56
- package/src/pagination/UserGroupPaginator.ts +0 -93
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { EventHandlerPipeline } from './EventHandlerPipeline';
|
|
2
|
+
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
3
|
+
import type { EventType } from './types';
|
|
4
|
+
import type { ChannelPaginator } from './pagination';
|
|
5
|
+
import type { StreamChat } from './client';
|
|
6
|
+
import type { Unsubscribe } from './store';
|
|
7
|
+
import { StateStore } from './store';
|
|
8
|
+
import type { EventHandlerPipelineHandler, FindEventHandlerParams, InsertEventHandlerPayload, LabeledEventHandler } from './EventHandlerPipeline';
|
|
9
|
+
import type { Channel } from './channel';
|
|
10
|
+
export type ChannelPaginatorsOrchestratorEventHandlerContext = {
|
|
11
|
+
orchestrator: ChannelPaginatorsOrchestrator;
|
|
12
|
+
};
|
|
13
|
+
type EventHandlerContext = ChannelPaginatorsOrchestratorEventHandlerContext;
|
|
14
|
+
type SupportedEventType = EventType | (string & {});
|
|
15
|
+
/**
|
|
16
|
+
* Resolves which paginators should be the "owners" of a channel
|
|
17
|
+
* when the channel matches multiple paginator filters.
|
|
18
|
+
*
|
|
19
|
+
* Return a set of paginator ids that should keep/own the item.
|
|
20
|
+
* Returning an empty set means the channel will be removed everywhere.
|
|
21
|
+
*/
|
|
22
|
+
export type PaginatorOwnershipResolver = (args: {
|
|
23
|
+
channel: Channel;
|
|
24
|
+
matchingPaginators: ChannelPaginator[];
|
|
25
|
+
}) => string[];
|
|
26
|
+
/**
|
|
27
|
+
* Convenience factory for a priority-based ownership resolver.
|
|
28
|
+
* - Provide an ordered list of paginator ids from highest to lowest priority.
|
|
29
|
+
* - If two or more paginators match a channel, the one with the highest priority wins.
|
|
30
|
+
* - If none of the matching paginator ids are in the priority list, all matches are kept (back-compat).
|
|
31
|
+
*/
|
|
32
|
+
export declare const createPriorityOwnershipResolver: (priority?: string[]) => PaginatorOwnershipResolver;
|
|
33
|
+
export declare const ignoreEventsForUnknownChannels: EventHandlerPipelineHandler<EventHandlerContext>;
|
|
34
|
+
export type ChannelPaginatorsOrchestratorState = {
|
|
35
|
+
paginators: ChannelPaginator[];
|
|
36
|
+
};
|
|
37
|
+
export type ChannelPaginatorsOrchestratorEventHandlers = Partial<Record<SupportedEventType, LabeledEventHandler<EventHandlerContext>[]>>;
|
|
38
|
+
export type ChannelPaginatorsOrchestratorOptions = {
|
|
39
|
+
client: StreamChat;
|
|
40
|
+
paginators?: ChannelPaginator[];
|
|
41
|
+
eventHandlers?: ChannelPaginatorsOrchestratorEventHandlers;
|
|
42
|
+
/**
|
|
43
|
+
* Decide which paginator(s) should own a channel when multiple match.
|
|
44
|
+
* Defaults to keeping the channel in all matching paginators.
|
|
45
|
+
* Channels are kept only in the paginators that are listed in the ownershipResolver array.
|
|
46
|
+
* Empty ownershipResolver array means that the channel is kept in all matching paginators.
|
|
47
|
+
*/
|
|
48
|
+
ownershipResolver?: PaginatorOwnershipResolver | string[];
|
|
49
|
+
};
|
|
50
|
+
export declare class ChannelPaginatorsOrchestrator extends WithSubscriptions {
|
|
51
|
+
client: StreamChat;
|
|
52
|
+
state: StateStore<ChannelPaginatorsOrchestratorState>;
|
|
53
|
+
protected _pipelines: Map<SupportedEventType, EventHandlerPipeline<ChannelPaginatorsOrchestratorEventHandlerContext>>;
|
|
54
|
+
protected ownershipResolver?: PaginatorOwnershipResolver;
|
|
55
|
+
/** Track paginators already wrapped with ownership-aware filtering */
|
|
56
|
+
protected ownershipFilterAppliedPaginators: WeakSet<ChannelPaginator>;
|
|
57
|
+
protected static readonly defaultEventHandlers: ChannelPaginatorsOrchestratorEventHandlers;
|
|
58
|
+
constructor({ client, eventHandlers, paginators, ownershipResolver, }: ChannelPaginatorsOrchestratorOptions);
|
|
59
|
+
get paginators(): ChannelPaginator[];
|
|
60
|
+
get pipelines(): Map<SupportedEventType, EventHandlerPipeline<EventHandlerContext>>;
|
|
61
|
+
private get ctx();
|
|
62
|
+
/**
|
|
63
|
+
* Returns deep copy of default handlers mapping.
|
|
64
|
+
* The defaults can be enriched with custom handlers or the custom handlers can be replaced.
|
|
65
|
+
*/
|
|
66
|
+
static getDefaultHandlers(): ChannelPaginatorsOrchestratorEventHandlers;
|
|
67
|
+
/**
|
|
68
|
+
* Which paginators should own the channel among the ones that matched.
|
|
69
|
+
* Default behavior keeps the channel in all matching paginators.
|
|
70
|
+
*/
|
|
71
|
+
resolveOwnership(channel: Channel, matchingPaginators: ChannelPaginator[]): Set<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Route a channel into the paginator(s) that should own it, and remove it from any list it
|
|
74
|
+
* no longer belongs to. Ownership is resolved exactly as for live WS updates — the channel is
|
|
75
|
+
* ingested into every paginator whose filter it matches (or, when an ownership resolver picks
|
|
76
|
+
* winners among several matches, only into the owner(s)).
|
|
77
|
+
*
|
|
78
|
+
* Use this to surface a channel the app just opened — a search result, a freshly created DM —
|
|
79
|
+
* in the list(s) without a full re-query. `ingestItem` dedupes by cid and inserts in sort
|
|
80
|
+
* order, so calling this repeatedly is safe.
|
|
81
|
+
*
|
|
82
|
+
* A channel that matches no paginator is not added anywhere. To have such channels still
|
|
83
|
+
* appear, register a catch-all paginator (empty filter) with the lowest ownership priority as
|
|
84
|
+
* a local fallback list.
|
|
85
|
+
*/
|
|
86
|
+
ingestChannel(channel: Channel): void;
|
|
87
|
+
/**
|
|
88
|
+
* Filter a page of query results for a specific paginator according to ownership rules.
|
|
89
|
+
* If no owners are specified by the resolver, all matching paginators keep the item.
|
|
90
|
+
*/
|
|
91
|
+
protected filterItemsByOwnership({ paginator, items, }: {
|
|
92
|
+
paginator: ChannelPaginator;
|
|
93
|
+
items: Channel[];
|
|
94
|
+
}): Channel[];
|
|
95
|
+
/**
|
|
96
|
+
* Wrap paginator.filterQueryResults so that ownership rules are applied whenever
|
|
97
|
+
* the paginator ingests results from a server query (first page and subsequent pages).
|
|
98
|
+
*/
|
|
99
|
+
protected wrapPaginatorFiltering(paginator: ChannelPaginator): void;
|
|
100
|
+
getPaginatorById(id: string): ChannelPaginator | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* If paginator already exists → remove old, reinsert at new index.
|
|
103
|
+
* If index not provided → append at the end.
|
|
104
|
+
* If index provided → insert (or move) at that index.
|
|
105
|
+
*
|
|
106
|
+
* @param params - The insertion parameters.
|
|
107
|
+
* @param params.paginator - The paginator to insert or move.
|
|
108
|
+
* @param params.index - Target index; when omitted the paginator is appended.
|
|
109
|
+
*/
|
|
110
|
+
insertPaginator({ paginator, index }: {
|
|
111
|
+
paginator: ChannelPaginator;
|
|
112
|
+
index?: number;
|
|
113
|
+
}): void;
|
|
114
|
+
addEventHandler({ eventType, ...payload }: {
|
|
115
|
+
eventType: SupportedEventType;
|
|
116
|
+
} & InsertEventHandlerPayload<EventHandlerContext>): Unsubscribe;
|
|
117
|
+
setEventHandlers({ eventType, handlers, }: {
|
|
118
|
+
eventType: SupportedEventType;
|
|
119
|
+
handlers: LabeledEventHandler<EventHandlerContext>[];
|
|
120
|
+
}): void;
|
|
121
|
+
removeEventHandlers({ eventType, handlers, }: {
|
|
122
|
+
eventType: SupportedEventType;
|
|
123
|
+
handlers: FindEventHandlerParams<EventHandlerContext>[];
|
|
124
|
+
}): void;
|
|
125
|
+
/** Subscribe to WS (and more buses via attachBus) */
|
|
126
|
+
registerSubscriptions(): Unsubscribe;
|
|
127
|
+
ensurePipeline(eventType: SupportedEventType): EventHandlerPipeline<EventHandlerContext>;
|
|
128
|
+
reload: () => Promise<PromiseSettledResult<void>[]>;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ChannelResponse, Event, EventType, MessageResponse, ReactionResponse, UserResponse } from './types';
|
|
2
|
+
import type { Unsubscribe } from './store';
|
|
3
|
+
/**
|
|
4
|
+
* Flat routing view of an event, as seen by pipeline handlers. The public `Event` type is now a
|
|
5
|
+
* discriminated union (each WS event exposes only its own fields) and also admits bare custom-event
|
|
6
|
+
* name strings — neither is convenient for the generic routers here, which only read a bounded set of
|
|
7
|
+
* common optional fields. Dispatched event *values* are always objects, so the pipeline casts to
|
|
8
|
+
* this view at the boundary (see `processOne`).
|
|
9
|
+
*/
|
|
10
|
+
export type PipelineEvent = {
|
|
11
|
+
type: EventType | (string & {});
|
|
12
|
+
channel?: ChannelResponse;
|
|
13
|
+
channel_id?: string;
|
|
14
|
+
channel_type?: string;
|
|
15
|
+
cid?: string;
|
|
16
|
+
created_at?: string | Date;
|
|
17
|
+
hard_delete?: boolean;
|
|
18
|
+
message?: MessageResponse;
|
|
19
|
+
reaction?: ReactionResponse;
|
|
20
|
+
user?: UserResponse;
|
|
21
|
+
};
|
|
22
|
+
type MatchById = {
|
|
23
|
+
id: string | RegExp;
|
|
24
|
+
regexMatch?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type FindEventHandlerParams<CTX extends Record<string, unknown>> = {
|
|
27
|
+
handler?: LabeledEventHandler<CTX> | EventHandlerPipelineHandler<CTX>;
|
|
28
|
+
idMatch?: MatchById;
|
|
29
|
+
};
|
|
30
|
+
export type EventHandlerResult = {
|
|
31
|
+
action: 'stop';
|
|
32
|
+
};
|
|
33
|
+
export type InsertEventHandlerPayload<CTX extends Record<string, unknown>> = {
|
|
34
|
+
handle: EventHandlerPipelineHandler<CTX>;
|
|
35
|
+
index?: number;
|
|
36
|
+
id?: string;
|
|
37
|
+
replace?: boolean;
|
|
38
|
+
revertOnUnsubscribe?: boolean;
|
|
39
|
+
};
|
|
40
|
+
export type EventHandlerPipelineHandler<CTX extends Record<string, unknown>> = (payload: {
|
|
41
|
+
event: PipelineEvent;
|
|
42
|
+
ctx: CTX;
|
|
43
|
+
}) => EventHandlerResult | void | Promise<EventHandlerResult | void>;
|
|
44
|
+
export type LabeledEventHandler<CTX extends Record<string, unknown>> = {
|
|
45
|
+
handle: EventHandlerPipelineHandler<CTX>;
|
|
46
|
+
id?: string;
|
|
47
|
+
};
|
|
48
|
+
export declare class EventHandlerPipeline<CTX extends Record<string, unknown> = {}> {
|
|
49
|
+
id: string;
|
|
50
|
+
protected handlers: LabeledEventHandler<CTX>[];
|
|
51
|
+
private runnerExecutionPromise;
|
|
52
|
+
constructor({ id }: {
|
|
53
|
+
id: string;
|
|
54
|
+
});
|
|
55
|
+
get size(): number;
|
|
56
|
+
findIndex({ handler, idMatch }: FindEventHandlerParams<CTX>): number;
|
|
57
|
+
/**
|
|
58
|
+
* Insert a handler into the pipeline at the given index.
|
|
59
|
+
*
|
|
60
|
+
* - If `replace` is `true` and the index is within bounds, the existing handler
|
|
61
|
+
* at that position will be replaced by the new one.
|
|
62
|
+
* - If `revertOnUnsubscribe` is also `true`, then calling the returned
|
|
63
|
+
* unsubscribe will both remove the inserted handler *and* restore the
|
|
64
|
+
* previously replaced handler at the same index.
|
|
65
|
+
* - If `replace` is `false` (default), the new handler is inserted at the index
|
|
66
|
+
* (or appended if the index is greater than the pipeline size). Unsubscribe
|
|
67
|
+
* will only remove this handler.
|
|
68
|
+
*
|
|
69
|
+
* @param payload - Insertion options.
|
|
70
|
+
* @param payload.handle - The handler function to insert.
|
|
71
|
+
* @param payload.index - Target index in the pipeline (clamped to valid range).
|
|
72
|
+
* @param payload.replace - If true, replace existing handler at index instead of inserting.
|
|
73
|
+
* @param payload.revertOnUnsubscribe - If true, restore the replaced handler when unsubscribing.
|
|
74
|
+
* @returns An unsubscribe function that removes (and optionally restores) the handler.
|
|
75
|
+
*/
|
|
76
|
+
insert({ handle, id, index, replace, revertOnUnsubscribe, }: InsertEventHandlerPayload<CTX>): Unsubscribe;
|
|
77
|
+
/**
|
|
78
|
+
* Remove handler by:
|
|
79
|
+
* - handler function identity or
|
|
80
|
+
* - by id that could be an exact match or
|
|
81
|
+
* - match by regexp.
|
|
82
|
+
*
|
|
83
|
+
* @param params - {FindEventHandlerParams}
|
|
84
|
+
*/
|
|
85
|
+
remove(params: FindEventHandlerParams<CTX>): void;
|
|
86
|
+
replaceAll(handlers: LabeledEventHandler<CTX>[]): void;
|
|
87
|
+
clear(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Queue an event for processing. Events are processed serially, in the order
|
|
90
|
+
* `run` is called. Returns a promise that resolves/rejects for this specific
|
|
91
|
+
* event’s processing, while the internal chain continues (errors won’t break it).
|
|
92
|
+
*/
|
|
93
|
+
run(event: Event, ctx: CTX): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Wait until all queued events have been processed.
|
|
96
|
+
*/
|
|
97
|
+
drain(): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Process a single event through a stable snapshot of handlers to avoid
|
|
100
|
+
* mid-iteration mutations (insert/remove) affecting this run.
|
|
101
|
+
*/
|
|
102
|
+
private processOne;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AxiosRequestConfig, Method } from 'axios';
|
|
2
|
+
import type { RequestMetadata, SendFileAPIResponse, UserResponse } from './types';
|
|
3
|
+
import type { StreamChat } from './client';
|
|
4
|
+
export declare class ApiClient {
|
|
5
|
+
client: StreamChat;
|
|
6
|
+
private nextRequestAbortController;
|
|
7
|
+
constructor(client?: StreamChat);
|
|
8
|
+
_getToken(): string | undefined;
|
|
9
|
+
createAbortControllerForNextRequest(): AbortController;
|
|
10
|
+
sendRequest<T>(method: Method, url: string, pathParams?: Record<string, string>, queryParams?: Record<string, unknown>, body?: unknown, requestContentType?: string): Promise<{
|
|
11
|
+
body: T;
|
|
12
|
+
metadata: RequestMetadata;
|
|
13
|
+
}>;
|
|
14
|
+
doAxiosRequest<T>(type: string, url: string, data?: unknown, options?: AxiosRequestConfig): Promise<T>;
|
|
15
|
+
get<T>(url: string, params?: AxiosRequestConfig['params']): Promise<T>;
|
|
16
|
+
put<T>(url: string, data?: unknown): Promise<T>;
|
|
17
|
+
post<T>(url: string, data?: unknown): Promise<T>;
|
|
18
|
+
patch<T>(url: string, data?: unknown): Promise<T>;
|
|
19
|
+
delete<T>(url: string, params?: AxiosRequestConfig['params']): Promise<T>;
|
|
20
|
+
sendFile(url: string, uri: string | NodeJS.ReadableStream | Buffer | File, name?: string, contentType?: string, user?: UserResponse, axiosRequestConfig?: AxiosRequestConfig): Promise<SendFileAPIResponse>;
|
|
21
|
+
private resolveUrl;
|
|
22
|
+
private getNextAbortSignal;
|
|
23
|
+
populateRequestConfigWithDefaults(additonalConfig: AxiosRequestConfig): AxiosRequestConfig;
|
|
24
|
+
private extractMetadata;
|
|
25
|
+
private _doRequest;
|
|
26
|
+
}
|
package/dist/types/campaign.d.ts
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { StreamChat } from './client';
|
|
2
|
-
import type { CampaignData, GetCampaignOptions } from './types';
|
|
3
|
-
export declare class Campaign {
|
|
4
|
-
id: string | null;
|
|
5
|
-
data?: CampaignData;
|
|
6
|
-
client: StreamChat;
|
|
7
|
-
constructor(client: StreamChat, id: string | null, data?: CampaignData);
|
|
8
|
-
create(): Promise<{
|
|
9
|
-
campaign: import("./types").CampaignResponse;
|
|
10
|
-
users: {
|
|
11
|
-
next?: string;
|
|
12
|
-
prev?: string;
|
|
13
|
-
};
|
|
14
|
-
} & import("./types").APIResponse>;
|
|
15
|
-
verifyCampaignId(): void;
|
|
16
|
-
start(options?: {
|
|
17
|
-
scheduledFor?: string;
|
|
18
|
-
stopAt?: string;
|
|
19
|
-
}): Promise<{
|
|
20
|
-
campaign: import("./types").CampaignResponse;
|
|
21
|
-
users: {
|
|
22
|
-
next?: string;
|
|
23
|
-
prev?: string;
|
|
24
|
-
};
|
|
25
|
-
} & import("./types").APIResponse>;
|
|
26
|
-
update(data: Partial<CampaignData>): Promise<{
|
|
27
|
-
campaign: import("./types").CampaignResponse;
|
|
28
|
-
users: {
|
|
29
|
-
next?: string;
|
|
30
|
-
prev?: string;
|
|
31
|
-
};
|
|
32
|
-
}>;
|
|
33
|
-
delete(): Promise<import("./types").APIResponse>;
|
|
34
|
-
stop(): Promise<{
|
|
35
|
-
campaign: import("./types").CampaignResponse;
|
|
36
|
-
}>;
|
|
37
|
-
get(options?: GetCampaignOptions): Promise<{
|
|
38
|
-
campaign: import("./types").CampaignResponse;
|
|
39
|
-
users: {
|
|
40
|
-
next?: string;
|
|
41
|
-
prev?: string;
|
|
42
|
-
};
|
|
43
|
-
} & import("./types").APIResponse>;
|
|
44
|
-
}
|