stream-chat
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
import { TokenManager } from './token_manager'; | ||
import { APIResponse, AppSettings, AppSettingsAPIResponse, BaseDeviceFields, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BlockList, BlockListResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CustomPermissionOptions, DeleteCommandResponse, Device, EndpointName, Event, EventHandler, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, FlagMessageResponse, FlagUserResponse, GetChannelTypeResponse, GetCommandResponse, GetRateLimitsResponse, ListChannelResponse, ListCommandsResponse, LiteralStringForUnion, Logger, MarkAllReadOptions, MessageFilters, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OwnUserResponse, PartialMessageUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, ReactionResponse, SearchOptions, SearchAPIResponse, SendFileAPIResponse, StreamChatOptions, TestPushDataInput, TestSQSDataInput, TokenOrProvider, UnBanUserOptions, UnknownType, UpdateChannelOptions, UpdateChannelResponse, UpdateCommandOptions, UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, SegmentData, Segment, Campaign, CampaignData } from './types'; | ||
import { APIResponse, AppSettings, AppSettingsAPIResponse, BaseDeviceFields, BannedUsersFilters, BannedUsersPaginationOptions, BannedUsersResponse, BannedUsersSort, BanUserOptions, BlockList, BlockListResponse, ChannelAPIResponse, ChannelData, ChannelFilters, ChannelMute, ChannelOptions, ChannelSort, ChannelStateOptions, CheckPushResponse, CheckSQSResponse, Configs, ConnectAPIResponse, CreateChannelOptions, CreateChannelResponse, CreateCommandOptions, CreateCommandResponse, CustomPermissionOptions, DeleteCommandResponse, Device, EndpointName, Event, EventHandler, ExportChannelOptions, ExportChannelRequest, ExportChannelResponse, ExportChannelStatusResponse, MessageFlagsFilters, MessageFlagsPaginationOptions, MessageFlagsResponse, FlagMessageResponse, FlagUserResponse, GetChannelTypeResponse, GetCommandResponse, GetRateLimitsResponse, ListChannelResponse, ListCommandsResponse, LiteralStringForUnion, Logger, MarkAllReadOptions, MessageFilters, MessageResponse, Mute, MuteUserOptions, MuteUserResponse, OwnUserResponse, PartialMessageUpdate, PartialUserUpdate, PermissionAPIResponse, PermissionsAPIResponse, ReactionResponse, SearchOptions, SearchAPIResponse, SendFileAPIResponse, StreamChatOptions, TestPushDataInput, TestSQSDataInput, TokenOrProvider, UnBanUserOptions, UnknownType, UpdateChannelOptions, UpdateChannelResponse, UpdateCommandOptions, UpdateCommandResponse, UpdatedMessage, UpdateMessageAPIResponse, UserCustomEvent, UserFilters, UserOptions, UserResponse, UserSort, SegmentData, Segment, Campaign, CampaignData } from './types'; | ||
export declare class StreamChat<AttachmentType extends UnknownType = UnknownType, ChannelType extends UnknownType = UnknownType, CommandType extends string = LiteralStringForUnion, EventType extends UnknownType = UnknownType, MessageType extends UnknownType = UnknownType, ReactionType extends UnknownType = UnknownType, UserType extends UnknownType = UnknownType> { | ||
@@ -23,3 +23,2 @@ private static _instance?; | ||
configs: Configs<CommandType>; | ||
connecting?: boolean; | ||
connectionID?: string; | ||
@@ -977,4 +976,4 @@ failures?: number; | ||
deleteBlockList(name: string): Promise<APIResponse>; | ||
exportChannels(request: Array<ExportChannelRequest>): Promise<APIResponse & ExportChannelResponse>; | ||
exportChannel(request: ExportChannelRequest): Promise<APIResponse & ExportChannelResponse>; | ||
exportChannels(request: Array<ExportChannelRequest>, options?: ExportChannelOptions): Promise<APIResponse & ExportChannelResponse>; | ||
exportChannel(request: ExportChannelRequest, options?: ExportChannelOptions): Promise<APIResponse & ExportChannelResponse>; | ||
getExportChannelStatus(id: string): Promise<APIResponse & ExportChannelStatusResponse>; | ||
@@ -981,0 +980,0 @@ /** |
@@ -1016,2 +1016,5 @@ import { AxiosRequestConfig } from 'axios'; | ||
}; | ||
export declare type ExportChannelOptions = { | ||
clear_deleted_message_text?: boolean; | ||
}; | ||
export declare type Field = { | ||
@@ -1018,0 +1021,0 @@ short?: boolean; |
{ | ||
"name": "stream-chat", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "JS SDK for the Stream Chat API", | ||
@@ -5,0 +5,0 @@ "author": "GetStream", |
@@ -135,2 +135,4 @@ import WebSocket from 'isomorphic-ws'; | ||
this.isConnecting = false; | ||
/** Boolean that indicates if the connection promise is resolved */ | ||
this.isResolved = false; | ||
/** Boolean that indicates if we have a working connection to the server */ | ||
@@ -167,3 +169,2 @@ this.isHealthy = false; | ||
const healthCheck = await this._connect(); | ||
this.isConnecting = false; | ||
this.consecutiveFailures = 0; | ||
@@ -179,3 +180,2 @@ | ||
} catch (error) { | ||
this.isConnecting = false; | ||
this.isHealthy = false; | ||
@@ -356,19 +356,25 @@ this.consecutiveFailures += 1; | ||
async _connect() { | ||
await this.tokenManager.tokenReady(); | ||
this._setupConnectionPromise(); | ||
const wsURL = this._buildUrl(); | ||
this.ws = new WebSocket(wsURL); | ||
this.ws.onopen = this.onopen.bind(this, this.wsID); | ||
this.ws.onclose = this.onclose.bind(this, this.wsID); | ||
this.ws.onerror = this.onerror.bind(this, this.wsID); | ||
this.ws.onmessage = this.onmessage.bind(this, this.wsID); | ||
const response = await this.connectionOpen; | ||
if (this.isConnecting) return; // simply ignore _connect if it's currently trying to connect | ||
this.isConnecting = true; | ||
if (response) { | ||
this.connectionID = response.connection_id; | ||
try { | ||
await this.tokenManager.tokenReady(); | ||
this._setupConnectionPromise(); | ||
const wsURL = this._buildUrl(); | ||
this.ws = new WebSocket(wsURL); | ||
this.ws.onopen = this.onopen.bind(this, this.wsID); | ||
this.ws.onclose = this.onclose.bind(this, this.wsID); | ||
this.ws.onerror = this.onerror.bind(this, this.wsID); | ||
this.ws.onmessage = this.onmessage.bind(this, this.wsID); | ||
const response = await this.connectionOpen; | ||
this.isConnecting = false; | ||
return response; | ||
if (response) { | ||
this.connectionID = response.connection_id; | ||
return response; | ||
} | ||
} catch (err) { | ||
this.isConnecting = false; | ||
throw err; | ||
} | ||
return undefined; | ||
} | ||
@@ -424,4 +430,2 @@ | ||
this.isConnecting = true; | ||
// cleanup the old connection | ||
@@ -449,6 +453,4 @@ this.logger('info', 'connection:_reconnect() - Destroying current WS connection', { | ||
} | ||
this.isConnecting = false; | ||
this.consecutiveFailures = 0; | ||
} catch (error) { | ||
this.isConnecting = false; | ||
this.isHealthy = false; | ||
@@ -539,2 +541,3 @@ this.consecutiveFailures += 1; | ||
if (!this.isResolved && data) { | ||
this.isResolved = true; | ||
if (data.error != null) { | ||
@@ -545,3 +548,2 @@ this.rejectPromise?.(this._errorFromWSEvent(data, false)); | ||
this.resolvePromise?.(event); | ||
// set healthy.. | ||
this._setHealth(true); | ||
@@ -596,2 +598,3 @@ } | ||
this._setHealth(false); | ||
this.isConnecting = false; | ||
@@ -620,2 +623,3 @@ this.rejectPromise?.(this._errorFromWSEvent(event)); | ||
this._setHealth(false); | ||
this.isConnecting = false; | ||
@@ -622,0 +626,0 @@ this.rejectPromise?.(this._errorFromWSEvent(event)); |
@@ -1800,2 +1800,6 @@ import { AxiosRequestConfig } from 'axios'; | ||
export type ExportChannelOptions = { | ||
clear_deleted_message_text?: boolean; | ||
}; | ||
export type Field = { | ||
@@ -1802,0 +1806,0 @@ short?: boolean; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3811899
43041