stream-chat 8.14.5 → 8.15.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/browser.es.js +843 -613
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +843 -613
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +843 -613
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +843 -613
- package/dist/index.js.map +1 -1
- package/dist/types/channel.d.ts.map +1 -1
- package/dist/types/channel_state.d.ts +1 -0
- package/dist/types/channel_state.d.ts.map +1 -1
- package/dist/types/client.d.ts +108 -27
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/events.d.ts +1 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/types.d.ts +45 -20
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +28 -16
- package/src/channel_state.ts +7 -1
- package/src/client.ts +115 -43
- package/src/events.ts +1 -0
- package/src/types.ts +58 -21
package/src/client.ts
CHANGED
|
@@ -96,6 +96,7 @@ import {
|
|
|
96
96
|
GetMessageAPIResponse,
|
|
97
97
|
GetRateLimitsResponse,
|
|
98
98
|
GetUnreadCountAPIResponse,
|
|
99
|
+
GetUnreadCountBatchAPIResponse,
|
|
99
100
|
ListChannelResponse,
|
|
100
101
|
ListCommandsResponse,
|
|
101
102
|
ListImportsPaginationOptions,
|
|
@@ -123,12 +124,10 @@ import {
|
|
|
123
124
|
PushProviderListResponse,
|
|
124
125
|
PushProviderUpsertResponse,
|
|
125
126
|
QueryChannelsAPIResponse,
|
|
127
|
+
QuerySegmentsOptions,
|
|
126
128
|
ReactionResponse,
|
|
127
129
|
ReactivateUserOptions,
|
|
128
130
|
ReactivateUsersOptions,
|
|
129
|
-
Recipient,
|
|
130
|
-
RecipientFilters,
|
|
131
|
-
RecipientQueryOptions,
|
|
132
131
|
ReservedMessageFields,
|
|
133
132
|
ReviewFlagReportOptions,
|
|
134
133
|
ReviewFlagReportResponse,
|
|
@@ -138,8 +137,7 @@ import {
|
|
|
138
137
|
SearchPayload,
|
|
139
138
|
Segment,
|
|
140
139
|
SegmentData,
|
|
141
|
-
|
|
142
|
-
SegmentQueryOptions,
|
|
140
|
+
SegmentType,
|
|
143
141
|
SendFileAPIResponse,
|
|
144
142
|
StreamChatOptions,
|
|
145
143
|
SyncOptions,
|
|
@@ -159,6 +157,7 @@ import {
|
|
|
159
157
|
UpdatedMessage,
|
|
160
158
|
UpdateMessageAPIResponse,
|
|
161
159
|
UpdateMessageOptions,
|
|
160
|
+
UpdateSegmentData,
|
|
162
161
|
UserCustomEvent,
|
|
163
162
|
UserFilters,
|
|
164
163
|
UserOptions,
|
|
@@ -1688,10 +1687,28 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
1688
1687
|
);
|
|
1689
1688
|
}
|
|
1690
1689
|
|
|
1690
|
+
/**
|
|
1691
|
+
* getUnreadCount - Returns unread counts for a single user
|
|
1692
|
+
*
|
|
1693
|
+
* @param {string} [userID] User ID.
|
|
1694
|
+
*
|
|
1695
|
+
* @return {<GetUnreadCountAPIResponse>}
|
|
1696
|
+
*/
|
|
1691
1697
|
async getUnreadCount(userID?: string) {
|
|
1692
1698
|
return await this.get<GetUnreadCountAPIResponse>(this.baseURL + '/unread', userID ? { user_id: userID } : {});
|
|
1693
1699
|
}
|
|
1694
1700
|
|
|
1701
|
+
/**
|
|
1702
|
+
* getUnreadCountBatch - Returns unread counts for multiple users at once. Only works server side.
|
|
1703
|
+
*
|
|
1704
|
+
* @param {string[]} [userIDs] List of user IDs to fetch unread counts for.
|
|
1705
|
+
*
|
|
1706
|
+
* @return {<GetUnreadCountBatchAPIResponse>}
|
|
1707
|
+
*/
|
|
1708
|
+
async getUnreadCountBatch(userIDs: string[]) {
|
|
1709
|
+
return await this.post<GetUnreadCountBatchAPIResponse>(this.baseURL + '/unread_batch', { user_ids: userIDs });
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1695
1712
|
/**
|
|
1696
1713
|
* removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
|
|
1697
1714
|
*
|
|
@@ -2824,56 +2841,132 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
2824
2841
|
}
|
|
2825
2842
|
|
|
2826
2843
|
/**
|
|
2827
|
-
* createSegment - Creates a
|
|
2844
|
+
* createSegment - Creates a segment
|
|
2828
2845
|
*
|
|
2846
|
+
* @private
|
|
2847
|
+
* @param {SegmentType} type Segment type
|
|
2848
|
+
* @param {string} id Segment ID (valid UUID)
|
|
2849
|
+
* @param {string} name Segment name (valid UUID)
|
|
2829
2850
|
* @param {SegmentData} params Segment data
|
|
2830
2851
|
*
|
|
2831
|
-
* @return {Segment} The
|
|
2852
|
+
* @return {Segment} The created Segment
|
|
2853
|
+
*/
|
|
2854
|
+
private async createSegment(type: SegmentType, id: string, name: string, data?: SegmentData): Promise<Segment> {
|
|
2855
|
+
const body = {
|
|
2856
|
+
id,
|
|
2857
|
+
type,
|
|
2858
|
+
name,
|
|
2859
|
+
data,
|
|
2860
|
+
};
|
|
2861
|
+
const { segment } = await this.post<{ segment: Segment }>(this.baseURL + `/segments`, body);
|
|
2862
|
+
return segment;
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
/**
|
|
2866
|
+
* createUserSegment - Creates a user segment
|
|
2867
|
+
*
|
|
2868
|
+
* @param {string} id Segment ID (valid UUID)
|
|
2869
|
+
* @param {string} name Segment name
|
|
2870
|
+
* @param {SegmentData} data Segment data
|
|
2871
|
+
*
|
|
2872
|
+
* @return {Segment} The created Segment
|
|
2873
|
+
*/
|
|
2874
|
+
async createUserSegment(id: string, name: string, data?: SegmentData): Promise<Segment> {
|
|
2875
|
+
return await this.createSegment('user', id, name, data);
|
|
2876
|
+
}
|
|
2877
|
+
|
|
2878
|
+
/**
|
|
2879
|
+
* createChannelSegment - Creates a channel segment
|
|
2880
|
+
*
|
|
2881
|
+
* @param {string} id Segment ID (valid UUID)
|
|
2882
|
+
* @param {string} name Segment name
|
|
2883
|
+
* @param {SegmentData} data Segment data
|
|
2884
|
+
*
|
|
2885
|
+
* @return {Segment} The created Segment
|
|
2886
|
+
*/
|
|
2887
|
+
async createChannelSegment(id: string, name: string, data?: SegmentData): Promise<Segment> {
|
|
2888
|
+
return await this.createSegment('channel', id, name, data);
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
/**
|
|
2892
|
+
* updateSegment - Update a segment
|
|
2893
|
+
*
|
|
2894
|
+
* @param {string} id Segment ID
|
|
2895
|
+
* @param {Partial<UpdateSegmentData>} data Data to update
|
|
2896
|
+
*
|
|
2897
|
+
* @return {Segment} Updated Segment
|
|
2832
2898
|
*/
|
|
2833
|
-
async
|
|
2834
|
-
const { segment } = await this.
|
|
2899
|
+
async updateSegment(id: string, data: Partial<UpdateSegmentData>) {
|
|
2900
|
+
const { segment } = await this.put<{ segment: Segment }>(this.baseURL + `/segments/${id}`, data);
|
|
2835
2901
|
return segment;
|
|
2836
2902
|
}
|
|
2837
2903
|
|
|
2838
2904
|
/**
|
|
2839
|
-
*
|
|
2905
|
+
* addSegmentTargets - Add targets to a segment
|
|
2906
|
+
*
|
|
2907
|
+
* @param {string} id Segment ID
|
|
2908
|
+
* @param {string[]} targets Targets to add to the segment
|
|
2909
|
+
*
|
|
2910
|
+
* @return {APIResponse} API response
|
|
2911
|
+
*/
|
|
2912
|
+
async addSegmentTargets(id: string, targets: string[]) {
|
|
2913
|
+
const body = { targets };
|
|
2914
|
+
return await this.post<APIResponse>(this.baseURL + `/segments/${id}/addtargets`, body);
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
/**
|
|
2918
|
+
* deleteSegmentTargets - Delete targets from a segment
|
|
2919
|
+
*
|
|
2920
|
+
* @param {string} id Segment ID
|
|
2921
|
+
* @param {string[]} targets Targets to add to the segment
|
|
2922
|
+
*
|
|
2923
|
+
* @return {APIResponse} API response
|
|
2924
|
+
*/
|
|
2925
|
+
async deleteSegmentTargets(id: string, targets: string[]) {
|
|
2926
|
+
const body = { targets };
|
|
2927
|
+
return await this.post<APIResponse>(this.baseURL + `/segments/${id}/deletetargets`, body);
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
/**
|
|
2931
|
+
* querySegments - Query Segments
|
|
2840
2932
|
*
|
|
2933
|
+
* @param {filter} filter MongoDB style filter conditions
|
|
2934
|
+
* @param {QuerySegmentsOptions} options Options for sorting/paginating the results
|
|
2841
2935
|
*
|
|
2842
2936
|
* @return {Segment[]} Segments
|
|
2843
2937
|
*/
|
|
2844
|
-
async querySegments(
|
|
2938
|
+
async querySegments(filter: {}, options: QuerySegmentsOptions = {}) {
|
|
2845
2939
|
return await this.get<{
|
|
2846
2940
|
segments: Segment[];
|
|
2847
2941
|
}>(this.baseURL + `/segments`, {
|
|
2848
2942
|
payload: {
|
|
2849
|
-
|
|
2943
|
+
filter,
|
|
2850
2944
|
...options,
|
|
2851
2945
|
},
|
|
2852
2946
|
});
|
|
2853
2947
|
}
|
|
2854
2948
|
|
|
2855
2949
|
/**
|
|
2856
|
-
*
|
|
2950
|
+
* deleteSegment - Delete a Campaign Segment
|
|
2857
2951
|
*
|
|
2858
2952
|
* @param {string} id Segment ID
|
|
2859
|
-
* @param {Partial<SegmentData>} params Segment data
|
|
2860
2953
|
*
|
|
2861
|
-
* @return {
|
|
2954
|
+
* @return {Promise<APIResponse>} The Server Response
|
|
2862
2955
|
*/
|
|
2863
|
-
async
|
|
2864
|
-
|
|
2865
|
-
return segment;
|
|
2956
|
+
async deleteSegment(id: string) {
|
|
2957
|
+
return await this.delete<APIResponse>(this.baseURL + `/segments/${id}`);
|
|
2866
2958
|
}
|
|
2867
2959
|
|
|
2868
2960
|
/**
|
|
2869
|
-
*
|
|
2961
|
+
* segmentTargetExists - Check if a target exists in a segment
|
|
2870
2962
|
*
|
|
2871
|
-
* @param {string}
|
|
2963
|
+
* @param {string} segmentId Segment ID
|
|
2964
|
+
* @param {string} targetId Target ID
|
|
2872
2965
|
*
|
|
2873
2966
|
* @return {Promise<APIResponse>} The Server Response
|
|
2874
2967
|
*/
|
|
2875
|
-
async
|
|
2876
|
-
return this.
|
|
2968
|
+
async segmentTargetExists(segmentId: string, targetId: string) {
|
|
2969
|
+
return await this.get<APIResponse>(this.baseURL + `/segments/${segmentId}/target/${targetId}`);
|
|
2877
2970
|
}
|
|
2878
2971
|
|
|
2879
2972
|
/**
|
|
@@ -2987,27 +3080,6 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
|
|
|
2987
3080
|
return await this.post<APIResponse & TestCampaignResponse>(this.baseURL + `/campaigns/${id}/test`, { users });
|
|
2988
3081
|
}
|
|
2989
3082
|
|
|
2990
|
-
/**
|
|
2991
|
-
* queryRecipients - Query Campaign Recipient Results
|
|
2992
|
-
*
|
|
2993
|
-
*
|
|
2994
|
-
* @return {Recipient[]} Recipients
|
|
2995
|
-
*/
|
|
2996
|
-
async queryRecipients(filters: RecipientFilters, options: RecipientQueryOptions = {}) {
|
|
2997
|
-
return await this.get<{
|
|
2998
|
-
campaigns: Record<string, Campaign>;
|
|
2999
|
-
recipients: Recipient[];
|
|
3000
|
-
segments: Record<string, Segment>;
|
|
3001
|
-
channels?: Record<string, ChannelResponse<StreamChatGenerics>>;
|
|
3002
|
-
users?: Record<string, UserResponse<StreamChatGenerics>>;
|
|
3003
|
-
}>(this.baseURL + `/recipients`, {
|
|
3004
|
-
payload: {
|
|
3005
|
-
filter_conditions: filters,
|
|
3006
|
-
...options,
|
|
3007
|
-
},
|
|
3008
|
-
});
|
|
3009
|
-
}
|
|
3010
|
-
|
|
3011
3083
|
/**
|
|
3012
3084
|
* enrichURL - Get OpenGraph data of the given link
|
|
3013
3085
|
*
|
package/src/events.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const EVENT_MAP = {
|
|
|
24
24
|
'notification.invite_rejected': true,
|
|
25
25
|
'notification.invited': true,
|
|
26
26
|
'notification.mark_read': true,
|
|
27
|
+
'notification.mark_unread': true,
|
|
27
28
|
'notification.message_new': true,
|
|
28
29
|
'notification.mutes_updated': true,
|
|
29
30
|
'notification.removed_from_channel': true,
|
package/src/types.ts
CHANGED
|
@@ -114,6 +114,10 @@ export type AppSettingsAPIResponse<StreamChatGenerics extends ExtendableGenerics
|
|
|
114
114
|
campaign_enabled?: boolean;
|
|
115
115
|
cdn_expiration_seconds?: number;
|
|
116
116
|
custom_action_handler_url?: string;
|
|
117
|
+
datadog_info?: {
|
|
118
|
+
api_key: string;
|
|
119
|
+
site: string;
|
|
120
|
+
};
|
|
117
121
|
disable_auth_checks?: boolean;
|
|
118
122
|
disable_permissions_checks?: boolean;
|
|
119
123
|
enforce_unique_usernames?: 'no' | 'app' | 'team';
|
|
@@ -247,6 +251,7 @@ export type BannedUsersResponse<StreamChatGenerics extends ExtendableGenerics =
|
|
|
247
251
|
|
|
248
252
|
export type BlockListResponse = BlockList & {
|
|
249
253
|
created_at?: string;
|
|
254
|
+
type?: string;
|
|
250
255
|
updated_at?: string;
|
|
251
256
|
};
|
|
252
257
|
|
|
@@ -508,6 +513,10 @@ export type GetUnreadCountAPIResponse = APIResponse & {
|
|
|
508
513
|
total_unread_count: number;
|
|
509
514
|
};
|
|
510
515
|
|
|
516
|
+
export type GetUnreadCountBatchAPIResponse = APIResponse & {
|
|
517
|
+
counts_by_user: { [userId: string]: GetUnreadCountAPIResponse };
|
|
518
|
+
};
|
|
519
|
+
|
|
511
520
|
export type ListChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
|
|
512
521
|
channel_types: Record<
|
|
513
522
|
string,
|
|
@@ -558,6 +567,7 @@ export type MessageResponseBase<
|
|
|
558
567
|
};
|
|
559
568
|
latest_reactions?: ReactionResponse<StreamChatGenerics>[];
|
|
560
569
|
mentioned_users?: UserResponse<StreamChatGenerics>[];
|
|
570
|
+
moderation_details?: ModerationDetailsResponse;
|
|
561
571
|
own_reactions?: ReactionResponse<StreamChatGenerics>[] | null;
|
|
562
572
|
pin_expires?: string | null;
|
|
563
573
|
pinned_at?: string | null;
|
|
@@ -571,6 +581,18 @@ export type MessageResponseBase<
|
|
|
571
581
|
updated_at?: string;
|
|
572
582
|
};
|
|
573
583
|
|
|
584
|
+
export type ModerationDetailsResponse = {
|
|
585
|
+
action: 'MESSAGE_RESPONSE_ACTION_BOUNCE' | (string & {});
|
|
586
|
+
error_msg: string;
|
|
587
|
+
harms: ModerationHarmResponse[];
|
|
588
|
+
original_text: string;
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
export type ModerationHarmResponse = {
|
|
592
|
+
name: string;
|
|
593
|
+
phrase_list_ids: number[];
|
|
594
|
+
};
|
|
595
|
+
|
|
574
596
|
export type MuteResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
|
|
575
597
|
user: UserResponse<StreamChatGenerics>;
|
|
576
598
|
created_at?: string;
|
|
@@ -1055,8 +1077,13 @@ export type Event<StreamChatGenerics extends ExtendableGenerics = DefaultGeneric
|
|
|
1055
1077
|
cid?: string;
|
|
1056
1078
|
clear_history?: boolean;
|
|
1057
1079
|
connection_id?: string;
|
|
1080
|
+
// event creation timestamp, format Date ISO string
|
|
1058
1081
|
created_at?: string;
|
|
1082
|
+
// id of the message that was marked as unread - all the following messages are considered unread. (notification.mark_unread)
|
|
1083
|
+
first_unread_message_id?: string;
|
|
1059
1084
|
hard_delete?: boolean;
|
|
1085
|
+
// creation date of a message with last_read_message_id, formatted as Date ISO string
|
|
1086
|
+
last_read_at?: string;
|
|
1060
1087
|
last_read_message_id?: string;
|
|
1061
1088
|
mark_messages_deleted?: boolean;
|
|
1062
1089
|
me?: OwnUserResponse<StreamChatGenerics>;
|
|
@@ -1072,9 +1099,14 @@ export type Event<StreamChatGenerics extends ExtendableGenerics = DefaultGeneric
|
|
|
1072
1099
|
reaction?: ReactionResponse<StreamChatGenerics>;
|
|
1073
1100
|
received_at?: string | Date;
|
|
1074
1101
|
team?: string;
|
|
1102
|
+
// @deprecated number of all unread messages across all current user's unread channels, equals unread_count
|
|
1075
1103
|
total_unread_count?: number;
|
|
1104
|
+
// number of all current user's channels with at least one unread message including the channel in this event
|
|
1076
1105
|
unread_channels?: number;
|
|
1106
|
+
// number of all unread messages across all current user's unread channels
|
|
1077
1107
|
unread_count?: number;
|
|
1108
|
+
// number of unread messages in the channel from this event (notification.mark_unread)
|
|
1109
|
+
unread_messages?: number;
|
|
1078
1110
|
user?: UserResponse<StreamChatGenerics>;
|
|
1079
1111
|
user_id?: string;
|
|
1080
1112
|
watcher_count?: number;
|
|
@@ -2390,22 +2422,43 @@ export type DeleteUserOptions = {
|
|
|
2390
2422
|
user?: DeleteType;
|
|
2391
2423
|
};
|
|
2392
2424
|
|
|
2425
|
+
export type SegmentType = 'channel' | 'user';
|
|
2426
|
+
|
|
2393
2427
|
export type SegmentData = {
|
|
2394
2428
|
description: string;
|
|
2395
2429
|
filter: {};
|
|
2396
|
-
name: string;
|
|
2397
|
-
type: 'channel' | 'user';
|
|
2398
2430
|
};
|
|
2399
2431
|
|
|
2400
2432
|
export type Segment = {
|
|
2401
2433
|
created_at: string;
|
|
2434
|
+
deleted_at: string;
|
|
2402
2435
|
id: string;
|
|
2403
|
-
|
|
2436
|
+
locked: boolean;
|
|
2437
|
+
name: string;
|
|
2404
2438
|
size: number;
|
|
2405
|
-
|
|
2439
|
+
type: SegmentType;
|
|
2406
2440
|
updated_at: string;
|
|
2407
2441
|
} & SegmentData;
|
|
2408
2442
|
|
|
2443
|
+
export type UpdateSegmentData = {
|
|
2444
|
+
name: string;
|
|
2445
|
+
} & SegmentData;
|
|
2446
|
+
|
|
2447
|
+
export type SortParam = {
|
|
2448
|
+
field: string;
|
|
2449
|
+
direction?: AscDesc;
|
|
2450
|
+
};
|
|
2451
|
+
|
|
2452
|
+
export type Pager = {
|
|
2453
|
+
limit?: number;
|
|
2454
|
+
next?: string;
|
|
2455
|
+
prev?: string;
|
|
2456
|
+
};
|
|
2457
|
+
|
|
2458
|
+
export type QuerySegmentsOptions = {
|
|
2459
|
+
sort?: SortParam[];
|
|
2460
|
+
} & Pager;
|
|
2461
|
+
|
|
2409
2462
|
export type CampaignSortField = {
|
|
2410
2463
|
field: string;
|
|
2411
2464
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -2423,12 +2476,9 @@ export type CampaignQueryOptions = {
|
|
|
2423
2476
|
};
|
|
2424
2477
|
|
|
2425
2478
|
export type SegmentQueryOptions = CampaignQueryOptions;
|
|
2426
|
-
export type RecipientQueryOptions = CampaignQueryOptions;
|
|
2427
2479
|
|
|
2428
2480
|
// TODO: add better typing
|
|
2429
|
-
export type SegmentFilters = {};
|
|
2430
2481
|
export type CampaignFilters = {};
|
|
2431
|
-
export type RecipientFilters = {};
|
|
2432
2482
|
|
|
2433
2483
|
export type CampaignData = {
|
|
2434
2484
|
attachments: Attachment[];
|
|
@@ -2469,20 +2519,7 @@ export type TestCampaignResponse = {
|
|
|
2469
2519
|
results?: Record<string, string>;
|
|
2470
2520
|
};
|
|
2471
2521
|
|
|
2472
|
-
export type DeleteCampaignOptions = {
|
|
2473
|
-
recipients?: boolean;
|
|
2474
|
-
};
|
|
2475
|
-
|
|
2476
|
-
export type Recipient = {
|
|
2477
|
-
campaign_id: string;
|
|
2478
|
-
channel_cid: string;
|
|
2479
|
-
created_at: string;
|
|
2480
|
-
status: 'pending' | 'sent' | 'failed';
|
|
2481
|
-
updated_at: string;
|
|
2482
|
-
details?: string;
|
|
2483
|
-
message_id?: string;
|
|
2484
|
-
receiver_id?: string;
|
|
2485
|
-
};
|
|
2522
|
+
export type DeleteCampaignOptions = {};
|
|
2486
2523
|
|
|
2487
2524
|
export type TaskStatus = {
|
|
2488
2525
|
created_at: string;
|