stream-chat 9.10.1 → 9.12.0
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.cjs +400 -21
- package/dist/cjs/index.browser.cjs.map +4 -4
- package/dist/cjs/index.node.cjs +413 -28
- package/dist/cjs/index.node.cjs.map +4 -4
- package/dist/esm/index.js +400 -21
- package/dist/esm/index.js.map +4 -4
- package/dist/types/LiveLocationManager.d.ts +54 -0
- package/dist/types/channel.d.ts +5 -9
- package/dist/types/channel_manager.d.ts +5 -1
- package/dist/types/client.d.ts +7 -6
- package/dist/types/events.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/messageComposer/LocationComposer.d.ts +34 -0
- package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -1
- package/dist/types/messageComposer/configuration/configuration.d.ts +2 -1
- package/dist/types/messageComposer/configuration/types.d.ts +11 -0
- package/dist/types/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/messageComposer.d.ts +7 -2
- package/dist/types/messageComposer/middleware/messageComposer/index.d.ts +1 -0
- package/dist/types/messageComposer/middleware/messageComposer/sharedLocation.d.ts +3 -0
- package/dist/types/types.d.ts +52 -5
- package/package.json +1 -1
- package/src/LiveLocationManager.ts +297 -0
- package/src/channel.ts +37 -2
- package/src/channel_manager.ts +15 -2
- package/src/client.ts +14 -5
- package/src/events.ts +2 -0
- package/src/index.ts +1 -0
- package/src/messageComposer/LocationComposer.ts +94 -0
- package/src/messageComposer/attachmentIdentity.ts +8 -1
- package/src/messageComposer/attachmentManager.ts +4 -0
- package/src/messageComposer/configuration/configuration.ts +8 -0
- package/src/messageComposer/configuration/types.ts +14 -0
- package/src/messageComposer/index.ts +1 -0
- package/src/messageComposer/messageComposer.ts +81 -9
- package/src/messageComposer/middleware/messageComposer/MessageComposerMiddlewareExecutor.ts +2 -0
- package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +1 -5
- package/src/messageComposer/middleware/messageComposer/index.ts +1 -0
- package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +42 -0
- package/src/types.ts +55 -5
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RULES:
|
|
3
|
+
*
|
|
4
|
+
* 1. one loc-sharing message per channel per user
|
|
5
|
+
* 2. live location is intended to be per device
|
|
6
|
+
* but created_by_device_id has currently no checks,
|
|
7
|
+
* and user can update the location from another device
|
|
8
|
+
* thus making location sharing based on user and channel
|
|
9
|
+
*/
|
|
10
|
+
import { StateStore } from './store';
|
|
11
|
+
import { WithSubscriptions } from './utils/WithSubscriptions';
|
|
12
|
+
import type { StreamChat } from './client';
|
|
13
|
+
import type { Unsubscribe } from './store';
|
|
14
|
+
import type { SharedLiveLocationResponse } from './types';
|
|
15
|
+
import type { Coords } from './messageComposer';
|
|
16
|
+
export type WatchLocationHandler = (value: Coords) => void;
|
|
17
|
+
export type WatchLocation = (handler: WatchLocationHandler) => Unsubscribe;
|
|
18
|
+
type DeviceIdGenerator = () => string;
|
|
19
|
+
type MessageId = string;
|
|
20
|
+
export type ScheduledLiveLocationSharing = SharedLiveLocationResponse & {
|
|
21
|
+
stopSharingTimeout: ReturnType<typeof setTimeout> | null;
|
|
22
|
+
};
|
|
23
|
+
export type LiveLocationManagerState = {
|
|
24
|
+
ready: boolean;
|
|
25
|
+
messages: Map<MessageId, ScheduledLiveLocationSharing>;
|
|
26
|
+
};
|
|
27
|
+
export type LiveLocationManagerConstructorParameters = {
|
|
28
|
+
client: StreamChat;
|
|
29
|
+
getDeviceId: DeviceIdGenerator;
|
|
30
|
+
watchLocation: WatchLocation;
|
|
31
|
+
};
|
|
32
|
+
export declare const UPDATE_LIVE_LOCATION_REQUEST_MIN_THROTTLE_TIMEOUT = 3000;
|
|
33
|
+
export declare class LiveLocationManager extends WithSubscriptions {
|
|
34
|
+
state: StateStore<LiveLocationManagerState>;
|
|
35
|
+
private client;
|
|
36
|
+
private getDeviceId;
|
|
37
|
+
private _deviceId;
|
|
38
|
+
private watchLocation;
|
|
39
|
+
static symbol: symbol;
|
|
40
|
+
constructor({ client, getDeviceId, watchLocation, }: LiveLocationManagerConstructorParameters);
|
|
41
|
+
init(): Promise<void>;
|
|
42
|
+
registerSubscriptions: () => void;
|
|
43
|
+
unregisterSubscriptions: () => symbol;
|
|
44
|
+
get messages(): Map<string, ScheduledLiveLocationSharing>;
|
|
45
|
+
get stateIsReady(): boolean;
|
|
46
|
+
get deviceId(): string;
|
|
47
|
+
private assureStateInit;
|
|
48
|
+
private subscribeTargetMessagesChange;
|
|
49
|
+
private subscribeWatchLocation;
|
|
50
|
+
private subscribeLiveLocationSharingUpdates;
|
|
51
|
+
private registerMessage;
|
|
52
|
+
private unregisterMessages;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
package/dist/types/channel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChannelState } from './channel_state';
|
|
2
2
|
import type { StreamChat } from './client';
|
|
3
|
-
import type { AIState, APIResponse, AscDesc, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelMemberAPIResponse, ChannelMemberResponse, ChannelQueryOptions, ChannelResponse, ChannelUpdateOptions, CreateDraftResponse, DeleteChannelAPIResponse, DraftMessagePayload, Event, EventAPIResponse, EventHandler, EventTypes, GetDraftResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, LocalMessage, MarkReadOptions, MarkUnreadOptions, MemberFilters, MemberSort, Message, MessageFilters, MessageOptions, MessagePaginationOptions, MessageResponse, MessageSetType, MuteChannelAPIResponse, NewMemberPayload, PartialUpdateChannel, PartialUpdateChannelAPIResponse, PartialUpdateMember, PartialUpdateMemberAPIResponse, PinnedMessagePaginationOptions, PinnedMessagesSort, PollVoteData, PushPreference, QueryChannelAPIResponse, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, SendMessageOptions, TruncateChannelAPIResponse, TruncateOptions, UpdateChannelAPIResponse, UpdateChannelOptions, UserResponse } from './types';
|
|
3
|
+
import type { AIState, APIResponse, AscDesc, BanUserOptions, ChannelAPIResponse, ChannelData, ChannelMemberAPIResponse, ChannelMemberResponse, ChannelQueryOptions, ChannelResponse, ChannelUpdateOptions, CreateDraftResponse, DeleteChannelAPIResponse, DraftMessagePayload, Event, EventAPIResponse, EventHandler, EventTypes, GetDraftResponse, GetMultipleMessagesAPIResponse, GetReactionsAPIResponse, GetRepliesAPIResponse, LiveLocationPayload, LocalMessage, MarkReadOptions, MarkUnreadOptions, MemberFilters, MemberSort, Message, MessageFilters, MessageOptions, MessagePaginationOptions, MessageResponse, MessageSetType, MuteChannelAPIResponse, NewMemberPayload, PartialUpdateChannel, PartialUpdateChannelAPIResponse, PartialUpdateMember, PartialUpdateMemberAPIResponse, PinnedMessagePaginationOptions, PinnedMessagesSort, PollVoteData, PushPreference, QueryChannelAPIResponse, QueryMembersOptions, Reaction, ReactionAPIResponse, SearchAPIResponse, SearchOptions, SendMessageAPIResponse, SendMessageOptions, SendReactionOptions, StaticLocationPayload, TruncateChannelAPIResponse, TruncateOptions, UpdateChannelAPIResponse, UpdateChannelOptions, UpdateLocationPayload, UserResponse } from './types';
|
|
4
4
|
import type { Role } from './permissions';
|
|
5
5
|
import { MessageComposer } from './messageComposer';
|
|
6
6
|
/**
|
|
@@ -147,10 +147,7 @@ export declare class Channel {
|
|
|
147
147
|
*
|
|
148
148
|
* @return {Promise<ReactionAPIResponse>} The Server Response
|
|
149
149
|
*/
|
|
150
|
-
sendReaction(messageID: string, reaction: Reaction, options?:
|
|
151
|
-
enforce_unique?: boolean;
|
|
152
|
-
skip_push?: boolean;
|
|
153
|
-
}): Promise<ReactionAPIResponse>;
|
|
150
|
+
sendReaction(messageID: string, reaction: Reaction, options?: SendReactionOptions): Promise<ReactionAPIResponse>;
|
|
154
151
|
/**
|
|
155
152
|
* sendReaction - Send a reaction about a message
|
|
156
153
|
*
|
|
@@ -160,10 +157,7 @@ export declare class Channel {
|
|
|
160
157
|
*
|
|
161
158
|
* @return {Promise<ReactionAPIResponse>} The Server Response
|
|
162
159
|
*/
|
|
163
|
-
_sendReaction(messageID: string, reaction: Reaction, options?:
|
|
164
|
-
enforce_unique?: boolean;
|
|
165
|
-
skip_push?: boolean;
|
|
166
|
-
}): Promise<ReactionAPIResponse>;
|
|
160
|
+
_sendReaction(messageID: string, reaction: Reaction, options?: SendReactionOptions): Promise<ReactionAPIResponse>;
|
|
167
161
|
deleteReaction(messageID: string, reactionType: string, user_id?: string): Promise<ReactionAPIResponse>;
|
|
168
162
|
/**
|
|
169
163
|
* deleteReaction - Delete a reaction by user and type
|
|
@@ -205,6 +199,8 @@ export declare class Channel {
|
|
|
205
199
|
* @return {Promise<UpdateChannelAPIResponse>} The server response
|
|
206
200
|
*/
|
|
207
201
|
disableSlowMode(): Promise<UpdateChannelAPIResponse>;
|
|
202
|
+
sendSharedLocation(location: StaticLocationPayload | LiveLocationPayload, userId?: string): Promise<SendMessageAPIResponse>;
|
|
203
|
+
stopLiveLocationSharing(payload: UpdateLocationPayload): Promise<void>;
|
|
208
204
|
/**
|
|
209
205
|
* delete - Delete the channel. Messages are permanently removed.
|
|
210
206
|
*
|
|
@@ -64,6 +64,7 @@ export type ChannelManagerOptions = {
|
|
|
64
64
|
*/
|
|
65
65
|
lockChannelOrder?: boolean;
|
|
66
66
|
};
|
|
67
|
+
export type QueryChannelsRequestType = (...params: Parameters<StreamChat['queryChannels']>) => Promise<Channel[]>;
|
|
67
68
|
export declare const DEFAULT_CHANNEL_MANAGER_OPTIONS: {
|
|
68
69
|
abortInFlightQuery: boolean;
|
|
69
70
|
allowNotLoadedChannelPromotionForEvent: {
|
|
@@ -89,16 +90,19 @@ export declare class ChannelManager extends WithSubscriptions {
|
|
|
89
90
|
private client;
|
|
90
91
|
private eventHandlers;
|
|
91
92
|
private eventHandlerOverrides;
|
|
93
|
+
private queryChannelsRequest;
|
|
92
94
|
private options;
|
|
93
95
|
private stateOptions;
|
|
94
96
|
private id;
|
|
95
|
-
constructor({ client, eventHandlerOverrides, options, }: {
|
|
97
|
+
constructor({ client, eventHandlerOverrides, options, queryChannelsOverride, }: {
|
|
96
98
|
client: StreamChat;
|
|
97
99
|
eventHandlerOverrides?: ChannelManagerEventHandlerOverrides;
|
|
98
100
|
options?: ChannelManagerOptions;
|
|
101
|
+
queryChannelsOverride?: QueryChannelsRequestType;
|
|
99
102
|
});
|
|
100
103
|
setChannels: (valueOrFactory: ChannelSetterParameterType) => void;
|
|
101
104
|
setEventHandlerOverrides: (eventHandlerOverrides?: ChannelManagerEventHandlerOverrides) => void;
|
|
105
|
+
setQueryChannelsRequest: (queryChannelsRequest: QueryChannelsRequestType) => void;
|
|
102
106
|
setOptions: (options?: ChannelManagerOptions) => void;
|
|
103
107
|
private executeChannelsQuery;
|
|
104
108
|
queryChannels: (filters: ChannelFilters, sort?: ChannelSort, options?: ChannelOptions, stateOptions?: ChannelStateOptions) => Promise<void>;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -7,14 +7,14 @@ import { TokenManager } from './token_manager';
|
|
|
7
7
|
import { WSConnectionFallback } from './connection_fallback';
|
|
8
8
|
import { Campaign } from './campaign';
|
|
9
9
|
import { Segment } from './segment';
|
|
10
|
-
import type { ActiveLiveLocationsAPIResponse, APIErrorResponse, APIResponse, AppSettings, AppSettingsAPIResponse, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BaseDeviceFields, BlockList, BlockListResponse, BlockUserAPIResponse, CampaignData, CampaignFilters, CampaignQueryOptions, CampaignResponse, CampaignSort, CastVoteAPIResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelResponse, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSNSResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CreateImportOptions, CreateImportResponse, CreateImportURLResponse, CreatePollAPIResponse, CreatePollData, CreatePollOptionAPIResponse, CreateReminderOptions, CustomPermissionOptions, DeactivateUsersOptions, DeleteCommandResponse, DeleteUserOptions, Device, DeviceIdentifier, DraftFilters, DraftSort, EndpointName, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, GetBlockedUsersAPIResponse, GetCampaignOptions, GetChannelTypeResponse, GetCommandResponse, GetImportResponse, GetMessageOptions, GetPollAPIResponse, GetRateLimitsResponse, GetThreadAPIResponse, GetThreadOptions, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, LocalMessage, Logger, MarkChannelsReadOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, Pager, PartialMessageUpdate, PartialPollUpdate, PartialThreadUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PollAnswersAPIResponse, PollData, PollOptionData, PollSort, PollVote, PollVoteData, PollVotesAPIResponse, PushPreference, PushProvider, PushProviderConfig, PushProviderID, PushProviderListResponse, PushProviderUpsertResponse, QueryDraftsResponse, QueryMessageHistoryFilters, QueryMessageHistoryOptions, QueryMessageHistoryResponse, QueryMessageHistorySort, QueryPollsFilters, QueryPollsOptions, QueryPollsResponse, QueryReactionsAPIResponse, QueryReactionsOptions, QueryRemindersOptions, QueryRemindersResponse, QuerySegmentsOptions, QuerySegmentTargetsFilter, QueryThreadsOptions, QueryVotesFilters, QueryVotesOptions, ReactionFilters, ReactionResponse, ReactionSort, ReactivateUserOptions, ReactivateUsersOptions, ReminderAPIResponse, ReviewFlagReportOptions, ReviewFlagReportResponse, SdkIdentifier, SearchAPIResponse, SearchOptions, SegmentData, SegmentResponse, SegmentTargetsResponse, SegmentType, SendFileAPIResponse,
|
|
10
|
+
import type { ActiveLiveLocationsAPIResponse, APIErrorResponse, APIResponse, AppSettings, AppSettingsAPIResponse, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BaseDeviceFields, BlockList, BlockListResponse, BlockUserAPIResponse, CampaignData, CampaignFilters, CampaignQueryOptions, CampaignResponse, CampaignSort, CastVoteAPIResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelResponse, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSNSResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CreateImportOptions, CreateImportResponse, CreateImportURLResponse, CreatePollAPIResponse, CreatePollData, CreatePollOptionAPIResponse, CreateReminderOptions, CustomPermissionOptions, DeactivateUsersOptions, DeleteCommandResponse, DeleteUserOptions, Device, DeviceIdentifier, DraftFilters, DraftSort, EndpointName, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, GetBlockedUsersAPIResponse, GetCampaignOptions, GetChannelTypeResponse, GetCommandResponse, GetImportResponse, GetMessageOptions, GetPollAPIResponse, GetRateLimitsResponse, GetThreadAPIResponse, GetThreadOptions, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, LocalMessage, Logger, MarkChannelsReadOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, Pager, PartialMessageUpdate, PartialPollUpdate, PartialThreadUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PollAnswersAPIResponse, PollData, PollOptionData, PollSort, PollVote, PollVoteData, PollVotesAPIResponse, PushPreference, PushProvider, PushProviderConfig, PushProviderID, PushProviderListResponse, PushProviderUpsertResponse, QueryDraftsResponse, QueryMessageHistoryFilters, QueryMessageHistoryOptions, QueryMessageHistoryResponse, QueryMessageHistorySort, QueryPollsFilters, QueryPollsOptions, QueryPollsResponse, QueryReactionsAPIResponse, QueryReactionsOptions, QueryRemindersOptions, QueryRemindersResponse, QuerySegmentsOptions, QuerySegmentTargetsFilter, QueryThreadsOptions, QueryVotesFilters, QueryVotesOptions, ReactionFilters, ReactionResponse, ReactionSort, ReactivateUserOptions, ReactivateUsersOptions, ReminderAPIResponse, ReviewFlagReportOptions, ReviewFlagReportResponse, SdkIdentifier, SearchAPIResponse, SearchOptions, SegmentData, SegmentResponse, SegmentTargetsResponse, SegmentType, SendFileAPIResponse, SharedLocationResponse, SortParam, StreamChatOptions, SyncOptions, SyncResponse, TaskResponse, TaskStatus, TestPushDataInput, TestSNSDataInput, TestSQSDataInput, TokenOrProvider, TranslateResponse, UnBanUserOptions, UpdateChannelTypeRequest, UpdateChannelTypeResponse, UpdateCommandOptions, UpdateCommandResponse, UpdateLocationPayload, UpdateMessageAPIResponse, UpdateMessageOptions, UpdatePollAPIResponse, UpdateReminderOptions, UpdateSegmentData, UpsertPushPreferencesResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, VoteSort } from './types';
|
|
11
11
|
import { ErrorFromResponse } from './types';
|
|
12
12
|
import { InsightMetrics } from './insights';
|
|
13
13
|
import { Thread } from './thread';
|
|
14
14
|
import { Moderation } from './moderation';
|
|
15
15
|
import { ThreadManager } from './thread_manager';
|
|
16
16
|
import { PollManager } from './poll_manager';
|
|
17
|
-
import type { ChannelManagerEventHandlerOverrides, ChannelManagerOptions } from './channel_manager';
|
|
17
|
+
import type { ChannelManagerEventHandlerOverrides, ChannelManagerOptions, QueryChannelsRequestType } from './channel_manager';
|
|
18
18
|
import { ChannelManager } from './channel_manager';
|
|
19
19
|
import { NotificationManager } from './notifications';
|
|
20
20
|
import { ReminderManager } from './reminders';
|
|
@@ -192,9 +192,10 @@ export declare class StreamChat {
|
|
|
192
192
|
* @param eventHandlerOverrides - the overrides for event handlers to be used
|
|
193
193
|
* @param options - the options used for the channel manager
|
|
194
194
|
*/
|
|
195
|
-
createChannelManager: ({ eventHandlerOverrides, options, }: {
|
|
195
|
+
createChannelManager: ({ eventHandlerOverrides, options, queryChannelsOverride, }: {
|
|
196
196
|
eventHandlerOverrides?: ChannelManagerEventHandlerOverrides;
|
|
197
197
|
options?: ChannelManagerOptions;
|
|
198
|
+
queryChannelsOverride?: QueryChannelsRequestType;
|
|
198
199
|
}) => ChannelManager;
|
|
199
200
|
/**
|
|
200
201
|
* Creates a new WebSocket connection with the current user. Returns empty promise, if there is an active connection
|
|
@@ -1917,11 +1918,11 @@ export declare class StreamChat {
|
|
|
1917
1918
|
/**
|
|
1918
1919
|
* updateLocation - Updates a location
|
|
1919
1920
|
*
|
|
1920
|
-
* @param location
|
|
1921
|
+
* @param location SharedLocationRequest the location data to update
|
|
1921
1922
|
*
|
|
1922
|
-
* @returns {Promise<
|
|
1923
|
+
* @returns {Promise<SharedLocationResponse>} The server response
|
|
1923
1924
|
*/
|
|
1924
|
-
updateLocation(location:
|
|
1925
|
+
updateLocation(location: UpdateLocationPayload): Promise<SharedLocationResponse>;
|
|
1925
1926
|
/**
|
|
1926
1927
|
* uploadFile - Uploads a file to the configured storage (defaults to Stream CDN)
|
|
1927
1928
|
*
|
package/dist/types/events.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export declare const EVENT_MAP: {
|
|
|
60
60
|
'connection.recovered': boolean;
|
|
61
61
|
'transport.changed': boolean;
|
|
62
62
|
'capabilities.changed': boolean;
|
|
63
|
+
'live_location_sharing.started': boolean;
|
|
64
|
+
'live_location_sharing.stopped': boolean;
|
|
63
65
|
'reminder.created': boolean;
|
|
64
66
|
'reminder.updated': boolean;
|
|
65
67
|
'reminder.deleted': boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from './token_manager';
|
|
|
27
27
|
export * from './types';
|
|
28
28
|
export * from './channel_manager';
|
|
29
29
|
export * from './offline-support';
|
|
30
|
+
export * from './LiveLocationManager';
|
|
30
31
|
export type { CustomAttachmentData, CustomChannelData, CustomCommandData, CustomEventData, CustomMemberData, CustomMessageComposerData, CustomMessageData, CustomPollOptionData, CustomPollData, CustomReactionData, CustomUserData, CustomThreadData, } from './custom_types';
|
|
31
32
|
export { isOwnUser, chatCodes, logChatPromiseExecution, localMessageToNewMessagePayload, formatMessage, promoteChannel, } from './utils';
|
|
32
33
|
export { FixedSizeQueueCache } from './utils/FixedSizeQueueCache';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StateStore } from '../store';
|
|
2
|
+
import type { MessageComposer } from './messageComposer';
|
|
3
|
+
import type { DraftMessage, LiveLocationPayload, LocalMessage, StaticLocationPayload } from '../types';
|
|
4
|
+
export type Coords = {
|
|
5
|
+
latitude: number;
|
|
6
|
+
longitude: number;
|
|
7
|
+
};
|
|
8
|
+
export type LocationComposerOptions = {
|
|
9
|
+
composer: MessageComposer;
|
|
10
|
+
message?: DraftMessage | LocalMessage;
|
|
11
|
+
};
|
|
12
|
+
export type StaticLocationPreview = StaticLocationPayload;
|
|
13
|
+
export type LiveLocationPreview = Omit<LiveLocationPayload, 'end_at'> & {
|
|
14
|
+
durationMs?: number;
|
|
15
|
+
};
|
|
16
|
+
export type LocationComposerState = {
|
|
17
|
+
location: StaticLocationPreview | LiveLocationPreview | null;
|
|
18
|
+
};
|
|
19
|
+
export declare class LocationComposer {
|
|
20
|
+
readonly state: StateStore<LocationComposerState>;
|
|
21
|
+
readonly composer: MessageComposer;
|
|
22
|
+
private _deviceId;
|
|
23
|
+
constructor({ composer, message }: LocationComposerOptions);
|
|
24
|
+
get config(): import("..").LocationComposerConfig;
|
|
25
|
+
get deviceId(): string;
|
|
26
|
+
get location(): StaticLocationPayload | LiveLocationPreview | null;
|
|
27
|
+
get validLocation(): StaticLocationPayload | LiveLocationPayload | null;
|
|
28
|
+
initState: ({ message }?: {
|
|
29
|
+
message?: DraftMessage | LocalMessage;
|
|
30
|
+
}) => void;
|
|
31
|
+
setData: (data: {
|
|
32
|
+
durationMs?: number;
|
|
33
|
+
} & Coords) => void;
|
|
34
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attachment } from '../types';
|
|
1
|
+
import type { Attachment, SharedLocationResponse } from '../types';
|
|
2
2
|
import type { AudioAttachment, FileAttachment, ImageAttachment, LocalAttachment, LocalAudioAttachment, LocalFileAttachment, LocalImageAttachment, LocalUploadAttachment, LocalVideoAttachment, LocalVoiceRecordingAttachment, UploadedAttachment, VideoAttachment, VoiceRecordingAttachment } from './types';
|
|
3
3
|
export declare const isScrapedContent: (attachment: Attachment) => boolean;
|
|
4
4
|
export declare const isLocalAttachment: (attachment: unknown) => attachment is LocalAttachment;
|
|
@@ -14,3 +14,4 @@ export declare const isLocalVoiceRecordingAttachment: (attachment: Attachment |
|
|
|
14
14
|
export declare const isVideoAttachment: (attachment: Attachment | LocalAttachment, supportedVideoFormat?: string[]) => attachment is VideoAttachment;
|
|
15
15
|
export declare const isLocalVideoAttachment: (attachment: Attachment | LocalAttachment) => attachment is LocalVideoAttachment;
|
|
16
16
|
export declare const isUploadedAttachment: (attachment: Attachment) => attachment is UploadedAttachment;
|
|
17
|
+
export declare const isSharedLocationResponse: (location: unknown) => location is SharedLocationResponse;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AttachmentManagerConfig, LinkPreviewsManagerConfig, MessageComposerConfig } from './types';
|
|
1
|
+
import type { AttachmentManagerConfig, LinkPreviewsManagerConfig, LocationComposerConfig, MessageComposerConfig } from './types';
|
|
2
2
|
import type { TextComposerConfig } from './types';
|
|
3
3
|
export declare const DEFAULT_LINK_PREVIEW_MANAGER_CONFIG: LinkPreviewsManagerConfig;
|
|
4
4
|
export declare const DEFAULT_ATTACHMENT_MANAGER_CONFIG: AttachmentManagerConfig;
|
|
5
5
|
export declare const DEFAULT_TEXT_COMPOSER_CONFIG: TextComposerConfig;
|
|
6
|
+
export declare const DEFAULT_LOCATION_COMPOSER_CONFIG: LocationComposerConfig;
|
|
6
7
|
export declare const DEFAULT_COMPOSER_CONFIG: MessageComposerConfig;
|
|
@@ -47,6 +47,15 @@ export type LinkPreviewsManagerConfig = {
|
|
|
47
47
|
/** Custom function to react to link preview dismissal */
|
|
48
48
|
onLinkPreviewDismissed?: (linkPreview: LinkPreview) => void;
|
|
49
49
|
};
|
|
50
|
+
export type LocationComposerConfig = {
|
|
51
|
+
/**
|
|
52
|
+
* Allows for toggling the location addition.
|
|
53
|
+
* By default, the feature is enabled but has to be enabled also on channel level config via shared_locations.
|
|
54
|
+
*/
|
|
55
|
+
enabled: boolean;
|
|
56
|
+
/** Function that provides a stable id for a device from which the location is shared */
|
|
57
|
+
getDeviceId: () => string;
|
|
58
|
+
};
|
|
50
59
|
export type MessageComposerConfig = {
|
|
51
60
|
/** If true, enables creating drafts on the server */
|
|
52
61
|
drafts: DraftsConfiguration;
|
|
@@ -54,6 +63,8 @@ export type MessageComposerConfig = {
|
|
|
54
63
|
attachments: AttachmentManagerConfig;
|
|
55
64
|
/** Configuration for the link previews manager */
|
|
56
65
|
linkPreviews: LinkPreviewsManagerConfig;
|
|
66
|
+
/** Configuration for the location composer */
|
|
67
|
+
location: LocationComposerConfig;
|
|
57
68
|
/** Maximum number of characters in a message */
|
|
58
69
|
text: TextComposerConfig;
|
|
59
70
|
};
|
|
@@ -4,6 +4,7 @@ export * from './configuration';
|
|
|
4
4
|
export * from './CustomDataManager';
|
|
5
5
|
export * from './fileUtils';
|
|
6
6
|
export * from './linkPreviewsManager';
|
|
7
|
+
export * from './LocationComposer';
|
|
7
8
|
export * from './messageComposer';
|
|
8
9
|
export * from './middleware';
|
|
9
10
|
export * from './pollComposer';
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { AttachmentManager } from './attachmentManager';
|
|
2
2
|
import { CustomDataManager } from './CustomDataManager';
|
|
3
3
|
import { LinkPreviewsManager } from './linkPreviewsManager';
|
|
4
|
+
import { LocationComposer } from './LocationComposer';
|
|
4
5
|
import { PollComposer } from './pollComposer';
|
|
5
6
|
import { TextComposer } from './textComposer';
|
|
6
7
|
import type { MessageComposerMiddlewareValue } from './middleware';
|
|
7
8
|
import { MessageComposerMiddlewareExecutor, MessageDraftComposerMiddlewareExecutor } from './middleware';
|
|
9
|
+
import type { Unsubscribe } from '../store';
|
|
8
10
|
import { StateStore } from '../store';
|
|
9
11
|
import { generateUUIDv4 } from '../utils';
|
|
10
12
|
import { Channel } from '../channel';
|
|
11
13
|
import { Thread } from '../thread';
|
|
12
14
|
import type { ChannelAPIResponse, DraftResponse, LocalMessage, LocalMessageBase, MessageResponse } from '../types';
|
|
15
|
+
import { WithSubscriptions } from '../utils/WithSubscriptions';
|
|
13
16
|
import type { StreamChat } from '../client';
|
|
14
17
|
import type { MessageComposerConfig } from './configuration/types';
|
|
15
18
|
import type { DeepPartial } from '../types.utility';
|
|
16
|
-
import type { Unsubscribe } from '../store';
|
|
17
|
-
import { WithSubscriptions } from '../utils/WithSubscriptions';
|
|
18
19
|
type UnregisterSubscriptions = Unsubscribe;
|
|
19
20
|
export type LastComposerChange = {
|
|
20
21
|
draftUpdate: number | null;
|
|
@@ -53,6 +54,7 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
53
54
|
linkPreviewsManager: LinkPreviewsManager;
|
|
54
55
|
textComposer: TextComposer;
|
|
55
56
|
pollComposer: PollComposer;
|
|
57
|
+
locationComposer: LocationComposer;
|
|
56
58
|
customDataManager: CustomDataManager;
|
|
57
59
|
constructor({ composition, config, compositionContext, client, }: MessageComposerOptions);
|
|
58
60
|
static evaluateContextType(compositionContext: CompositionContext): "message" | "channel" | "thread" | "legacy_thread";
|
|
@@ -73,6 +75,7 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
73
75
|
get compositionIsEmpty(): boolean;
|
|
74
76
|
get lastChangeOriginIsLocal(): boolean;
|
|
75
77
|
static generateId: typeof generateUUIDv4;
|
|
78
|
+
refreshId: () => void;
|
|
76
79
|
initState: ({ composition, }?: {
|
|
77
80
|
composition?: DraftResponse | MessageResponse | LocalMessage;
|
|
78
81
|
}) => void;
|
|
@@ -89,6 +92,7 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
89
92
|
private subscribeDraftDeleted;
|
|
90
93
|
private subscribeTextComposerStateChanged;
|
|
91
94
|
private subscribeAttachmentManagerStateChanged;
|
|
95
|
+
private subscribeLocationComposerStateChanged;
|
|
92
96
|
private subscribeLinkPreviewsManagerStateChanged;
|
|
93
97
|
private subscribePollComposerStateChanged;
|
|
94
98
|
private subscribeCustomDataManagerStateChanged;
|
|
@@ -104,5 +108,6 @@ export declare class MessageComposer extends WithSubscriptions {
|
|
|
104
108
|
deleteDraft: () => Promise<void>;
|
|
105
109
|
getDraft: () => Promise<void>;
|
|
106
110
|
createPoll: () => Promise<void>;
|
|
111
|
+
sendLocation: () => Promise<void>;
|
|
107
112
|
}
|
|
108
113
|
export {};
|
|
@@ -5,6 +5,7 @@ export * from './compositionValidation';
|
|
|
5
5
|
export * from './linkPreviews';
|
|
6
6
|
export * from './MessageComposerMiddlewareExecutor';
|
|
7
7
|
export * from './messageComposerState';
|
|
8
|
+
export * from './sharedLocation';
|
|
8
9
|
export * from './textComposer';
|
|
9
10
|
export * from './types';
|
|
10
11
|
export * from './commandInjection';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -755,6 +755,7 @@ export type UserResponse = CustomUserData & {
|
|
|
755
755
|
teams_role?: TeamsRole;
|
|
756
756
|
updated_at?: string;
|
|
757
757
|
username?: string;
|
|
758
|
+
avg_response_time?: number;
|
|
758
759
|
};
|
|
759
760
|
export type TeamsRole = {
|
|
760
761
|
[team: string]: string;
|
|
@@ -1738,6 +1739,7 @@ export type AppSettings = {
|
|
|
1738
1739
|
sqs_key?: string;
|
|
1739
1740
|
sqs_secret?: string;
|
|
1740
1741
|
sqs_url?: string;
|
|
1742
|
+
user_response_time_enabled?: boolean;
|
|
1741
1743
|
video_provider?: string;
|
|
1742
1744
|
webhook_events?: Array<string> | null;
|
|
1743
1745
|
webhook_url?: string;
|
|
@@ -1768,7 +1770,6 @@ export type Attachment = CustomAttachmentData & {
|
|
|
1768
1770
|
original_height?: number;
|
|
1769
1771
|
original_width?: number;
|
|
1770
1772
|
pretext?: string;
|
|
1771
|
-
stopped_sharing?: boolean;
|
|
1772
1773
|
text?: string;
|
|
1773
1774
|
thumb_url?: string;
|
|
1774
1775
|
title?: string;
|
|
@@ -1821,6 +1822,7 @@ export type ChannelConfigFields = {
|
|
|
1821
1822
|
read_events?: boolean;
|
|
1822
1823
|
replies?: boolean;
|
|
1823
1824
|
search?: boolean;
|
|
1825
|
+
shared_locations?: boolean;
|
|
1824
1826
|
typing_events?: boolean;
|
|
1825
1827
|
uploads?: boolean;
|
|
1826
1828
|
url_enrichment?: boolean;
|
|
@@ -1994,7 +1996,7 @@ export type LogLevel = 'info' | 'error' | 'warn';
|
|
|
1994
1996
|
export type Logger = (logLevel: LogLevel, message: string, extraData?: Record<string, unknown>) => void;
|
|
1995
1997
|
export type Message = Partial<MessageBase & {
|
|
1996
1998
|
mentioned_users: string[];
|
|
1997
|
-
shared_location?:
|
|
1999
|
+
shared_location?: StaticLocationPayload | LiveLocationPayload;
|
|
1998
2000
|
}>;
|
|
1999
2001
|
export type MessageBase = CustomMessageData & {
|
|
2000
2002
|
id: string;
|
|
@@ -2027,6 +2029,11 @@ export type SendMessageOptions = {
|
|
|
2027
2029
|
};
|
|
2028
2030
|
export type UpdateMessageOptions = {
|
|
2029
2031
|
skip_enrich_url?: boolean;
|
|
2032
|
+
skip_push?: boolean;
|
|
2033
|
+
};
|
|
2034
|
+
export type SendReactionOptions = {
|
|
2035
|
+
enforce_unique?: boolean;
|
|
2036
|
+
skip_push?: boolean;
|
|
2030
2037
|
};
|
|
2031
2038
|
export type GetMessageOptions = {
|
|
2032
2039
|
show_deleted_message?: boolean;
|
|
@@ -2101,6 +2108,7 @@ export type Reaction = CustomReactionData & {
|
|
|
2101
2108
|
score?: number;
|
|
2102
2109
|
user?: UserResponse | null;
|
|
2103
2110
|
user_id?: string;
|
|
2111
|
+
emoji_code?: string;
|
|
2104
2112
|
};
|
|
2105
2113
|
export type Resource = 'AddLinks' | 'BanUser' | 'CreateChannel' | 'CreateMessage' | 'CreateReaction' | 'DeleteAttachment' | 'DeleteChannel' | 'DeleteMessage' | 'DeleteReaction' | 'EditUser' | 'MuteUser' | 'ReadChannel' | 'RunMessageAction' | 'UpdateChannel' | 'UpdateChannelMembers' | 'UpdateMessage' | 'UpdateUser' | 'UploadAttachment';
|
|
2106
2114
|
export type SearchPayload = Omit<SearchOptions, 'sort'> & {
|
|
@@ -2892,12 +2900,13 @@ export type DraftMessage = {
|
|
|
2892
2900
|
parent_id?: string;
|
|
2893
2901
|
poll_id?: string;
|
|
2894
2902
|
quoted_message_id?: string;
|
|
2903
|
+
shared_location?: StaticLocationPayload | LiveLocationPayload;
|
|
2895
2904
|
show_in_channel?: boolean;
|
|
2896
2905
|
silent?: boolean;
|
|
2897
2906
|
type?: MessageLabel;
|
|
2898
2907
|
};
|
|
2899
2908
|
export type ActiveLiveLocationsAPIResponse = APIResponse & {
|
|
2900
|
-
active_live_locations:
|
|
2909
|
+
active_live_locations: SharedLiveLocationResponse[];
|
|
2901
2910
|
};
|
|
2902
2911
|
export type SharedLocationResponse = {
|
|
2903
2912
|
channel_cid: string;
|
|
@@ -2910,11 +2919,49 @@ export type SharedLocationResponse = {
|
|
|
2910
2919
|
updated_at: string;
|
|
2911
2920
|
user_id: string;
|
|
2912
2921
|
};
|
|
2913
|
-
export type
|
|
2922
|
+
export type SharedStaticLocationResponse = {
|
|
2923
|
+
channel_cid: string;
|
|
2924
|
+
created_at: string;
|
|
2925
|
+
created_by_device_id: string;
|
|
2926
|
+
latitude: number;
|
|
2927
|
+
longitude: number;
|
|
2928
|
+
message_id: string;
|
|
2929
|
+
updated_at: string;
|
|
2930
|
+
user_id: string;
|
|
2931
|
+
};
|
|
2932
|
+
export type SharedLiveLocationResponse = {
|
|
2933
|
+
channel_cid: string;
|
|
2934
|
+
created_at: string;
|
|
2914
2935
|
created_by_device_id: string;
|
|
2936
|
+
end_at: string;
|
|
2937
|
+
latitude: number;
|
|
2938
|
+
longitude: number;
|
|
2939
|
+
message_id: string;
|
|
2940
|
+
updated_at: string;
|
|
2941
|
+
user_id: string;
|
|
2942
|
+
};
|
|
2943
|
+
export type UpdateLocationPayload = {
|
|
2944
|
+
message_id: string;
|
|
2945
|
+
created_by_device_id?: string;
|
|
2915
2946
|
end_at?: string;
|
|
2916
2947
|
latitude?: number;
|
|
2917
2948
|
longitude?: number;
|
|
2949
|
+
user?: {
|
|
2950
|
+
id: string;
|
|
2951
|
+
};
|
|
2952
|
+
user_id?: string;
|
|
2953
|
+
};
|
|
2954
|
+
export type StaticLocationPayload = {
|
|
2955
|
+
created_by_device_id: string;
|
|
2956
|
+
latitude: number;
|
|
2957
|
+
longitude: number;
|
|
2958
|
+
message_id: string;
|
|
2959
|
+
};
|
|
2960
|
+
export type LiveLocationPayload = {
|
|
2961
|
+
created_by_device_id: string;
|
|
2962
|
+
end_at: string;
|
|
2963
|
+
latitude: number;
|
|
2964
|
+
longitude: number;
|
|
2918
2965
|
message_id: string;
|
|
2919
2966
|
};
|
|
2920
2967
|
export type ThreadSort = ThreadSortBase | Array<ThreadSortBase>;
|
|
@@ -2949,9 +2996,9 @@ export type ReminderResponseBase = {
|
|
|
2949
2996
|
remind_at?: string;
|
|
2950
2997
|
};
|
|
2951
2998
|
export type ReminderResponse = ReminderResponseBase & {
|
|
2952
|
-
channel: ChannelResponse;
|
|
2953
2999
|
user: UserResponse;
|
|
2954
3000
|
message: MessageResponse;
|
|
3001
|
+
channel?: ChannelResponse;
|
|
2955
3002
|
};
|
|
2956
3003
|
export type ReminderAPIResponse = APIResponse & {
|
|
2957
3004
|
reminder: ReminderResponse;
|