stream-chat 9.26.0 → 9.26.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.
@@ -7,7 +7,7 @@ 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, DeleteMessageOptions, DeleteUserOptions, Device, DeviceIdentifier, DraftFilters, DraftSort, EndpointName, Event, EventAPIResponse, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, GetBlockedUsersAPIResponse, GetCampaignOptions, GetChannelTypeResponse, GetCommandResponse, GetHookEventsResponse, GetImportResponse, GetMessageOptions, GetPollAPIResponse, GetRateLimitsResponse, GetThreadAPIResponse, GetThreadOptions, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, LocalMessage, Logger, MarkChannelsReadOptions, MarkDeliveredOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, Pager, PartialMessageUpdate, PartialPollUpdate, PartialThreadUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PollAnswersAPIResponse, PollData, PollOptionData, PollSort, PollVote, PollVoteData, PollVotesAPIResponse, Product, 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';
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, DeleteMessageOptions, DeleteUserOptions, Device, DeviceIdentifier, DraftFilters, DraftSort, EndpointName, Event, EventAPIResponse, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, ExportUsersRequest, ExportUsersResponse, FlagMessageResponse, FlagReportsFilters, FlagReportsPaginationOptions, FlagReportsResponse, FlagsFilters, FlagsPaginationOptions, FlagsResponse, FlagUserResponse, GetBlockedUsersAPIResponse, GetCampaignOptions, GetChannelTypeResponse, GetCommandResponse, GetHookEventsResponse, GetImportResponse, GetMessageOptions, GetPollAPIResponse, GetRateLimitsResponse, GetThreadAPIResponse, GetThreadOptions, GetUnreadCountAPIResponse, GetUnreadCountBatchAPIResponse, ListChannelResponse, ListCommandsResponse, ListImportsPaginationOptions, ListImportsResponse, LocalMessage, Logger, MarkChannelsReadOptions, MarkDeliveredOptions, MessageFilters, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OGAttachment, OwnUserResponse, Pager, PartialMessageUpdate, PartialPollUpdate, PartialThreadUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, PollAnswersAPIResponse, PollData, PollOptionData, PollSort, PollVote, PollVoteData, PollVotesAPIResponse, Product, 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, UpdateUsersAPIResponse, 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';
@@ -262,19 +262,11 @@ export declare class StreamChat {
262
262
  /**
263
263
  * Revokes token for a user issued before given time
264
264
  */
265
- revokeUserToken(userID: string, before?: Date | string | null): Promise<APIResponse & {
266
- users: {
267
- [key: string]: UserResponse;
268
- };
269
- }>;
265
+ revokeUserToken(userID: string, before?: Date | string | null): Promise<UpdateUsersAPIResponse>;
270
266
  /**
271
267
  * Revokes tokens for a list of users issued before given time
272
268
  */
273
- revokeUsersToken(userIDs: string[], before?: Date | string | null): Promise<APIResponse & {
274
- users: {
275
- [key: string]: UserResponse;
276
- };
277
- }>;
269
+ revokeUsersToken(userIDs: string[], before?: Date | string | null): Promise<UpdateUsersAPIResponse>;
278
270
  /**
279
271
  * getAppSettings - retrieves application settings
280
272
  */
@@ -510,7 +502,7 @@ export declare class StreamChat {
510
502
  *
511
503
  * @return {Promise<Array<ChannelAPIResponse>>} search channels response
512
504
  */
513
- queryChannelsRequest(filterConditions: ChannelFilters, sort?: ChannelSort, options?: ChannelOptions): Promise<Omit<ChannelAPIResponse, "duration">[]>;
505
+ queryChannelsRequest(filterConditions: ChannelFilters, sort?: ChannelSort, options?: ChannelOptions): Promise<Omit<ChannelAPIResponse, keyof APIResponse>[]>;
514
506
  /**
515
507
  * queryChannels - Query channels
516
508
  *
@@ -687,11 +679,7 @@ export declare class StreamChat {
687
679
  *
688
680
  * @return {Promise<{ users: { [key: string]: UserResponse } }>} list of updated users
689
681
  */
690
- partialUpdateUser(partialUserObject: PartialUserUpdate): Promise<APIResponse & {
691
- users: {
692
- [key: string]: UserResponse;
693
- };
694
- }>;
682
+ partialUpdateUser(partialUserObject: PartialUserUpdate): Promise<UpdateUsersAPIResponse>;
695
683
  /**
696
684
  * upsertUsers - Batch upsert the list of users
697
685
  *
@@ -699,11 +687,7 @@ export declare class StreamChat {
699
687
  *
700
688
  * @return {Promise<{ users: { [key: string]: UserResponse } }>}
701
689
  */
702
- upsertUsers(users: UserResponse[]): Promise<APIResponse & {
703
- users: {
704
- [key: string]: UserResponse;
705
- };
706
- }>;
690
+ upsertUsers(users: UserResponse[]): Promise<UpdateUsersAPIResponse>;
707
691
  /**
708
692
  * @deprecated Please use upsertUsers() function instead.
709
693
  *
@@ -712,11 +696,7 @@ export declare class StreamChat {
712
696
  * @param {UserResponse[]} users list of users
713
697
  * @return {Promise<{ users: { [key: string]: UserResponse } }>}
714
698
  */
715
- updateUsers: (users: UserResponse[]) => Promise<APIResponse & {
716
- users: {
717
- [key: string]: UserResponse;
718
- };
719
- }>;
699
+ updateUsers: (users: UserResponse[]) => Promise<UpdateUsersAPIResponse>;
720
700
  /**
721
701
  * upsertUser - Update or Create the given user object
722
702
  *
@@ -724,11 +704,7 @@ export declare class StreamChat {
724
704
  *
725
705
  * @return {Promise<{ users: { [key: string]: UserResponse } }>}
726
706
  */
727
- upsertUser(userObject: UserResponse): Promise<APIResponse & {
728
- users: {
729
- [key: string]: UserResponse;
730
- };
731
- }>;
707
+ upsertUser(userObject: UserResponse): Promise<UpdateUsersAPIResponse>;
732
708
  /**
733
709
  * @deprecated Please use upsertUser() function instead.
734
710
  *
@@ -737,11 +713,7 @@ export declare class StreamChat {
737
713
  * @param {UserResponse} userObject user object, the only required field is the user id. IE {id: "myuser"} is valid
738
714
  * @return {Promise<{ users: { [key: string]: UserResponse } }>}
739
715
  */
740
- updateUser: (userObject: UserResponse) => Promise<APIResponse & {
741
- users: {
742
- [key: string]: UserResponse;
743
- };
744
- }>;
716
+ updateUser: (userObject: UserResponse) => Promise<UpdateUsersAPIResponse>;
745
717
  /**
746
718
  * partialUpdateUsers - Batch partial update of users
747
719
  *
@@ -749,11 +721,7 @@ export declare class StreamChat {
749
721
  *
750
722
  * @return {Promise<{ users: { [key: string]: UserResponse } }>}
751
723
  */
752
- partialUpdateUsers(users: PartialUserUpdate[]): Promise<APIResponse & {
753
- users: {
754
- [key: string]: UserResponse;
755
- };
756
- }>;
724
+ partialUpdateUsers(users: PartialUserUpdate[]): Promise<UpdateUsersAPIResponse>;
757
725
  deleteUser(userID: string, params?: {
758
726
  delete_conversation_channels?: boolean;
759
727
  hard_delete?: boolean;
@@ -1,4 +1,4 @@
1
- import type { AttachmentManagerConfig, UploadRequestFn } from './configuration';
1
+ import type { AttachmentManagerConfig, MinimumUploadRequestResult, UploadRequestFn } from './configuration';
2
2
  import { AttachmentPostUploadMiddlewareExecutor, AttachmentPreUploadMiddlewareExecutor } from './middleware/attachmentManager';
3
3
  import { StateStore } from '../store';
4
4
  import type { AttachmentLoadingState, FileLike, FileReference, LocalAttachment, LocalUploadAttachment, UploadPermissionCheckResult } from './types';
@@ -58,13 +58,15 @@ export declare class AttachmentManager {
58
58
  * to prevent recursive calls
59
59
  */
60
60
  doDefaultUploadRequest: (fileLike: FileReference | FileLike) => Promise<{
61
+ blocklist?: import("..").BlockListResponse;
61
62
  file: string;
62
63
  thumb_url?: string;
63
64
  }>;
64
65
  /**
65
66
  * todo: docs how to customize the image and file upload by overriding do
66
67
  */
67
- doUploadRequest: (fileLike: FileReference | FileLike) => Promise<{
68
+ doUploadRequest: (fileLike: FileReference | FileLike) => Promise<MinimumUploadRequestResult | {
69
+ blocklist?: import("..").BlockListResponse;
68
70
  file: string;
69
71
  thumb_url?: string;
70
72
  }>;
@@ -1,3 +1,4 @@
1
+ export * from './attachmentManager';
1
2
  export * from './messageComposer';
2
3
  export * from './pollComposer';
3
4
  export * from './textComposer';
@@ -14,11 +14,16 @@ export declare class MessageDeliveryReporter {
14
14
  protected nextDeliveryReportCandidates: Map<ChannelThreadCompositeId, MessageId>;
15
15
  protected markDeliveredRequestPromise: Promise<EventAPIResponse | void> | null;
16
16
  protected markDeliveredTimeout: ReturnType<typeof setTimeout> | null;
17
+ protected requestTimeoutMs: number;
18
+ protected requestRetryCount: number;
17
19
  constructor({ client }: MessageDeliveryReporterOptions);
18
20
  private get markDeliveredRequestInFlight();
19
21
  private get hasTimer();
20
22
  private get hasDeliveryCandidates();
23
+ private get canExecuteRequest();
21
24
  private static hasPermissionToReportDeliveryFor;
25
+ private increaseBackOff;
26
+ private resetBackOff;
22
27
  /**
23
28
  * Build latest_delivered_messages payload from an arbitrary buffer (deliveryReportCandidates / nextDeliveryReportCandidates)
24
29
  */
@@ -39,6 +39,7 @@ export type Unpacked<T> = T extends (infer U)[] ? U : T extends (...args: any[])
39
39
  */
40
40
  export type APIResponse = {
41
41
  duration: string;
42
+ blocklist?: BlockListResponse;
42
43
  };
43
44
  export type TranslateResponse = {
44
45
  language: string;
@@ -46,6 +47,8 @@ export type TranslateResponse = {
46
47
  };
47
48
  export type AppSettingsAPIResponse = APIResponse & {
48
49
  app?: {
50
+ id?: string | number;
51
+ allow_multi_user_devices?: boolean;
49
52
  call_types: any;
50
53
  channel_configs: Record<string, {
51
54
  reminders: boolean;
@@ -70,6 +73,9 @@ export type AppSettingsAPIResponse = APIResponse & {
70
73
  read_events?: boolean;
71
74
  replies?: boolean;
72
75
  search?: boolean;
76
+ shared_locations?: boolean;
77
+ skip_last_msg_update_for_system_msgs?: boolean;
78
+ count_messages?: boolean;
73
79
  typing_events?: boolean;
74
80
  updated_at?: string;
75
81
  uploads?: boolean;
@@ -101,12 +107,28 @@ export type AppSettingsAPIResponse = APIResponse & {
101
107
  type: string;
102
108
  }>;
103
109
  grants?: Record<string, string[]>;
110
+ guest_user_creation_disabled?: boolean;
104
111
  image_moderation_enabled?: boolean;
112
+ image_moderation_labels?: string[];
105
113
  image_upload_config?: FileUploadConfig;
114
+ allowed_flag_reasons?: string[];
115
+ max_aggregated_activities_length?: number;
116
+ moderation_bulk_submit_action_enabled?: boolean;
117
+ moderation_dashboard_preferences?: Record<string, unknown> | null;
118
+ moderation_enabled?: boolean;
119
+ moderation_llm_configurability_enabled?: boolean;
120
+ moderation_multitenant_blocklist_enabled?: boolean;
121
+ moderation_webhook_url?: string;
106
122
  multi_tenant_enabled?: boolean;
107
123
  name?: string;
108
124
  organization?: string;
109
125
  permission_version?: string;
126
+ /**
127
+ * The placement of the app in the form of `${region}.${shard}`.
128
+ * Examples: "us-east.c1", "dublin.c3", "singapore.c2"
129
+ * Note: The backend may add/remove regions or shards occasionally.
130
+ */
131
+ placement?: string;
110
132
  policies?: Record<string, Policy[]>;
111
133
  poll_enabled?: boolean;
112
134
  push_notifications?: {
@@ -128,6 +150,8 @@ export type AppSettingsAPIResponse = APIResponse & {
128
150
  sqs_url?: string;
129
151
  suspended?: boolean;
130
152
  suspended_explanation?: string;
153
+ use_hook_v2?: boolean;
154
+ user_response_time_enabled?: boolean;
131
155
  user_search_disallowed_roles?: string[] | null;
132
156
  video_provider?: string;
133
157
  webhook_events?: Array<string>;
@@ -670,6 +694,7 @@ export type OwnUserBase = {
670
694
  privacy_settings?: PrivacySettings;
671
695
  push_preferences?: PushPreference;
672
696
  roles?: string[];
697
+ total_unread_count_by_team?: Record<string, number> | null;
673
698
  };
674
699
  export type OwnUserResponse = UserResponse & OwnUserBase;
675
700
  export type PartialUpdateChannelAPIResponse = APIResponse & {
@@ -748,11 +773,13 @@ export type UpdateMessageAPIResponse = APIResponse & {
748
773
  };
749
774
  export type UsersAPIResponse = APIResponse & {
750
775
  users: Array<UserResponse>;
776
+ membership_deletion_task_id?: string;
751
777
  };
752
778
  export type UpdateUsersAPIResponse = APIResponse & {
753
779
  users: {
754
780
  [key: string]: UserResponse;
755
781
  };
782
+ membership_deletion_task_id?: string;
756
783
  };
757
784
  export type UserResponse = CustomUserData & {
758
785
  id: string;
@@ -774,7 +801,7 @@ export type UserResponse = CustomUserData & {
774
801
  role?: string;
775
802
  shadow_banned?: boolean;
776
803
  teams?: string[];
777
- teams_role?: TeamsRole;
804
+ teams_role?: TeamsRole | null;
778
805
  updated_at?: string;
779
806
  username?: string;
780
807
  avg_response_time?: number;
@@ -883,11 +910,13 @@ export type CreateChannelOptions = {
883
910
  reminders?: boolean;
884
911
  replies?: boolean;
885
912
  search?: boolean;
913
+ shared_locations?: boolean;
886
914
  skip_last_msg_update_for_system_msgs?: boolean;
887
915
  typing_events?: boolean;
888
916
  uploads?: boolean;
889
917
  url_enrichment?: boolean;
890
918
  user_message_reminders?: boolean;
919
+ count_messages?: boolean;
891
920
  };
892
921
  export type CreateCommandOptions = {
893
922
  description: string;
@@ -909,10 +938,10 @@ export type DeactivateUsersOptions = {
909
938
  mark_messages_deleted?: boolean;
910
939
  };
911
940
  export type NewMemberPayload = CustomMemberData & Pick<ChannelMemberResponse, 'user_id' | 'channel_role'>;
912
- export type Thresholds = Record<'explicit' | 'spam' | 'toxic', Partial<{
941
+ export type Thresholds = Partial<Record<'explicit' | 'spam' | 'toxic', Partial<{
913
942
  block: number;
914
943
  flag: number;
915
- }>>;
944
+ }>>>;
916
945
  export type BlockListOptions = {
917
946
  behavior: BlocklistBehavior;
918
947
  blocklist: string;
@@ -1008,6 +1037,7 @@ export type UpdateChannelTypeResponse = {
1008
1037
  reminders: boolean;
1009
1038
  replies: boolean;
1010
1039
  search: boolean;
1040
+ shared_locations: boolean;
1011
1041
  skip_last_msg_update_for_system_msgs: boolean;
1012
1042
  typing_events: boolean;
1013
1043
  updated_at: string;
@@ -1018,9 +1048,11 @@ export type UpdateChannelTypeResponse = {
1018
1048
  blocklist?: string;
1019
1049
  blocklist_behavior?: BlocklistBehavior;
1020
1050
  blocklists?: BlockListOptions[];
1051
+ message_retention?: string;
1021
1052
  partition_size?: number;
1022
1053
  partition_ttl?: string;
1023
1054
  count_messages?: boolean;
1055
+ user_message_reminders?: boolean;
1024
1056
  };
1025
1057
  export type GetChannelTypeResponse = {
1026
1058
  automod: Automod;
@@ -1045,6 +1077,7 @@ export type GetChannelTypeResponse = {
1045
1077
  reminders: boolean;
1046
1078
  replies: boolean;
1047
1079
  search: boolean;
1080
+ shared_locations: boolean;
1048
1081
  skip_last_msg_update_for_system_msgs: boolean;
1049
1082
  typing_events: boolean;
1050
1083
  updated_at: string;
@@ -1055,9 +1088,11 @@ export type GetChannelTypeResponse = {
1055
1088
  blocklist?: string;
1056
1089
  blocklist_behavior?: BlocklistBehavior;
1057
1090
  blocklists?: BlockListOptions[];
1091
+ message_retention?: string;
1058
1092
  partition_size?: number;
1059
1093
  partition_ttl?: string;
1060
1094
  count_messages?: boolean;
1095
+ user_message_reminders?: boolean;
1061
1096
  };
1062
1097
  export type UpdateChannelOptions = Partial<{
1063
1098
  accept_invite: boolean;
@@ -1569,7 +1604,7 @@ export type UserFilters = QueryFilters<ContainsOperator<CustomUserData> & {
1569
1604
  } & {
1570
1605
  [Key in keyof Omit<UserResponse, 'id' | 'name' | 'teams' | 'username' | keyof CustomUserData>]?: RequireOnlyOne<QueryFilter<UserResponse[Key]>> | PrimitiveFilter<UserResponse[Key]>;
1571
1606
  }>;
1572
- export type InviteStatus = 'pending' | 'accepted' | 'rejected';
1607
+ export type InviteStatus = 'pending' | 'accepted' | 'rejected' | 'member';
1573
1608
  export type MemberFilters = QueryFilters<{
1574
1609
  banned?: {
1575
1610
  $eq?: ChannelMemberResponse['banned'];
@@ -1847,6 +1882,8 @@ export type BlockList = {
1847
1882
  team?: string;
1848
1883
  type?: string;
1849
1884
  validate?: boolean;
1885
+ is_leet_check_enabled?: boolean;
1886
+ is_plural_check_enabled?: boolean;
1850
1887
  };
1851
1888
  export type ChannelConfig = ChannelConfigFields & CreatedAtUpdatedAt & {
1852
1889
  commands?: CommandVariants[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.26.0",
3
+ "version": "9.26.1",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -55,7 +55,7 @@
55
55
  "base64-js": "^1.5.1",
56
56
  "form-data": "^4.0.4",
57
57
  "isomorphic-ws": "^5.0.0",
58
- "jsonwebtoken": "^9.0.2",
58
+ "jsonwebtoken": "^9.0.3",
59
59
  "linkifyjs": "^4.3.2",
60
60
  "ws": "^8.18.1"
61
61
  },
@@ -97,7 +97,9 @@
97
97
  "eslint-fix": "yarn run eslint --fix",
98
98
  "test": "yarn test-unit",
99
99
  "testwatch": "NODE_ENV=test nodemon ./node_modules/.bin/mocha --timeout 20000 --require test-entry.js test/test.js",
100
- "test-types": "node test/typescript/index.js && tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
100
+ "test-types": "yarn run-test-types && yarn run-types-gen",
101
+ "run-test-types": "node test/typescript/index.js",
102
+ "run-types-gen": "tsc --esModuleInterop true --noEmit true --strictNullChecks true --noImplicitAny true --strict true test/typescript/*.ts",
101
103
  "test-unit": "vitest",
102
104
  "test-coverage": "vitest run --coverage",
103
105
  "fix-staged": "lint-staged --config .lintstagedrc.fix.json --concurrent 1",
package/src/client.ts CHANGED
@@ -220,6 +220,7 @@ import type {
220
220
  UpdatePollOptionAPIResponse,
221
221
  UpdateReminderOptions,
222
222
  UpdateSegmentData,
223
+ UpdateUsersAPIResponse,
223
224
  UpsertPushPreferencesResponse,
224
225
  UserCustomEvent,
225
226
  UserFilters,
@@ -2396,11 +2397,9 @@ export class StreamChat {
2396
2397
  userMap[userObject.id] = userObject;
2397
2398
  }
2398
2399
 
2399
- return await this.post<
2400
- APIResponse & {
2401
- users: { [key: string]: UserResponse };
2402
- }
2403
- >(this.baseURL + '/users', { users: userMap });
2400
+ return await this.post<UpdateUsersAPIResponse>(this.baseURL + '/users', {
2401
+ users: userMap,
2402
+ });
2404
2403
  }
2405
2404
 
2406
2405
  /**
@@ -2448,11 +2447,7 @@ export class StreamChat {
2448
2447
  }
2449
2448
  }
2450
2449
 
2451
- return await this.patch<
2452
- APIResponse & {
2453
- users: { [key: string]: UserResponse };
2454
- }
2455
- >(this.baseURL + '/users', { users });
2450
+ return await this.patch<UpdateUsersAPIResponse>(this.baseURL + '/users', { users });
2456
2451
  }
2457
2452
 
2458
2453
  async deleteUser(
@@ -1,3 +1,4 @@
1
+ export * from './attachmentManager';
1
2
  export * from './messageComposer';
2
3
  export * from './pollComposer';
3
4
  export * from './textComposer';
@@ -3,16 +3,20 @@ import { Channel } from '../channel';
3
3
  import type { ThreadUserReadState } from '../thread';
4
4
  import { Thread } from '../thread';
5
5
  import type {
6
+ ErrorFromResponse,
6
7
  EventAPIResponse,
7
8
  LocalMessage,
8
9
  MarkDeliveredOptions,
9
10
  MarkReadOptions,
10
11
  } from '../types';
12
+ import { type APIErrorResponse } from '../types';
11
13
  import { throttle } from '../utils';
14
+ import { isAPIError, isErrorRetryable } from '../errors';
12
15
 
13
16
  const MAX_DELIVERED_MESSAGE_COUNT_IN_PAYLOAD = 100 as const;
14
17
  const MARK_AS_DELIVERED_BUFFER_TIMEOUT = 1000 as const;
15
18
  const MARK_AS_READ_THROTTLE_TIMEOUT = 1000 as const;
19
+ const RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE = 3 as const;
16
20
 
17
21
  const isChannel = (item: Channel | Thread): item is Channel => item instanceof Channel;
18
22
  const isThread = (item: Channel | Thread): item is Thread => item instanceof Thread;
@@ -40,6 +44,10 @@ export class MessageDeliveryReporter {
40
44
  protected markDeliveredRequestPromise: Promise<EventAPIResponse | void> | null = null;
41
45
  protected markDeliveredTimeout: ReturnType<typeof setTimeout> | null = null;
42
46
 
47
+ protected requestTimeoutMs: number = MARK_AS_DELIVERED_BUFFER_TIMEOUT;
48
+ // increased up to RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE
49
+ protected requestRetryCount: number = 0;
50
+
43
51
  constructor({ client }: MessageDeliveryReporterOptions) {
44
52
  this.client = client;
45
53
  }
@@ -47,18 +55,35 @@ export class MessageDeliveryReporter {
47
55
  private get markDeliveredRequestInFlight() {
48
56
  return this.markDeliveredRequestPromise !== null;
49
57
  }
58
+
50
59
  private get hasTimer() {
51
60
  return this.markDeliveredTimeout !== null;
52
61
  }
62
+
53
63
  private get hasDeliveryCandidates() {
54
64
  return this.deliveryReportCandidates.size > 0;
55
65
  }
56
66
 
67
+ private get canExecuteRequest() {
68
+ return !this.markDeliveredRequestInFlight && this.hasDeliveryCandidates;
69
+ }
70
+
57
71
  private static hasPermissionToReportDeliveryFor(collection: Channel | Thread) {
58
72
  if (isChannel(collection)) return !!collection.getConfig()?.delivery_events;
59
73
  if (isThread(collection)) return !!collection.channel.getConfig()?.delivery_events;
60
74
  }
61
75
 
76
+ private increaseBackOff() {
77
+ if (this.requestRetryCount >= RETRY_COUNT_LIMIT_FOR_TIMEOUT_INCREASE) return;
78
+ this.requestRetryCount = this.requestRetryCount + 1;
79
+ this.requestTimeoutMs = this.requestTimeoutMs * 2;
80
+ }
81
+
82
+ private resetBackOff() {
83
+ this.requestTimeoutMs = MARK_AS_DELIVERED_BUFFER_TIMEOUT;
84
+ this.requestRetryCount = 0;
85
+ }
86
+
62
87
  /**
63
88
  * Build latest_delivered_messages payload from an arbitrary buffer (deliveryReportCandidates / nextDeliveryReportCandidates)
64
89
  */
@@ -186,7 +211,7 @@ export class MessageDeliveryReporter {
186
211
  * @param options
187
212
  */
188
213
  public announceDelivery = (options?: AnnounceDeliveryOptions) => {
189
- if (this.markDeliveredRequestInFlight || !this.hasDeliveryCandidates) return;
214
+ if (!this.canExecuteRequest) return;
190
215
 
191
216
  const { latest_delivered_messages, sendBuffer } =
192
217
  this.confirmationsFromDeliveryReportCandidates();
@@ -194,7 +219,9 @@ export class MessageDeliveryReporter {
194
219
 
195
220
  const payload = { ...options, latest_delivered_messages };
196
221
 
197
- const postFlightReconcile = () => {
222
+ const postFlightReconcile = ({
223
+ preventSchedulingRetry,
224
+ }: { preventSchedulingRetry?: boolean } = {}) => {
198
225
  this.markDeliveredRequestPromise = null;
199
226
 
200
227
  // promote anything that arrived during request
@@ -203,32 +230,47 @@ export class MessageDeliveryReporter {
203
230
  }
204
231
  this.nextDeliveryReportCandidates = new Map();
205
232
 
233
+ if (preventSchedulingRetry) return;
206
234
  // checks internally whether there are candidates to announce
207
235
  this.announceDeliveryBuffered(options);
208
236
  };
209
237
 
210
- const handleError = () => {
211
- // repopulate relevant candidates for the next report
212
- for (const [k, v] of Object.entries(sendBuffer)) {
213
- if (!this.deliveryReportCandidates.has(k)) {
214
- this.deliveryReportCandidates.set(k, v);
215
- }
216
- }
238
+ const handleSuccess = () => {
239
+ this.resetBackOff();
217
240
  postFlightReconcile();
218
241
  };
219
242
 
243
+ const handleError = (error: ErrorFromResponse<APIErrorResponse> | Error) => {
244
+ // re-populate relevant candidates for the next report
245
+ // but make sure to keep the items that failed to be reported the first next time
246
+ const newDeliveryReportCandidates = new Map(sendBuffer);
247
+ for (const [k, v] of this.deliveryReportCandidates.entries()) {
248
+ newDeliveryReportCandidates.set(k, v);
249
+ }
250
+ this.deliveryReportCandidates = newDeliveryReportCandidates;
251
+
252
+ if (
253
+ (isAPIError(error) && isErrorRetryable(error)) ||
254
+ (error as ErrorFromResponse<APIErrorResponse>).status >= 500
255
+ ) {
256
+ this.increaseBackOff();
257
+ postFlightReconcile();
258
+ } else {
259
+ postFlightReconcile({ preventSchedulingRetry: true });
260
+ }
261
+ };
262
+
220
263
  this.markDeliveredRequestPromise = this.client
221
264
  .markChannelsDelivered(payload)
222
- .then(postFlightReconcile, handleError);
265
+ .then(handleSuccess, handleError);
223
266
  };
224
267
 
225
268
  public announceDeliveryBuffered = (options?: AnnounceDeliveryOptions) => {
226
- if (this.hasTimer || this.markDeliveredRequestInFlight || !this.hasDeliveryCandidates)
227
- return;
269
+ if (this.hasTimer || !this.canExecuteRequest) return;
228
270
  this.markDeliveredTimeout = setTimeout(() => {
229
271
  this.markDeliveredTimeout = null;
230
272
  this.announceDelivery(options);
231
- }, MARK_AS_DELIVERED_BUFFER_TIMEOUT);
273
+ }, this.requestTimeoutMs);
232
274
  };
233
275
 
234
276
  /**