11declare namespace connect {
22 export const ChatSession : ChatSessionObject ;
33
4+ export const ChatJS : ChatJSObject ;
5+
6+ interface ChatJSObject {
7+ readonly version : string ;
8+ readonly name : string ;
9+ readonly source : string ;
10+ readonly repository : string ;
11+ readonly build : {
12+ readonly timestamp : string ;
13+ readonly environment : 'production' | 'development' ;
14+ } ;
15+ }
16+
417 // ==========
518 // Main entry
619 // ==========
@@ -88,7 +101,19 @@ declare namespace connect {
88101 /**
89102 * The `amazon-connect-streams` websocket manager obtained with `connect.core.getWebSocketManager()`.
90103 */
91- readonly websocketManager : any ;
104+ readonly websocketManager : WebSocketManager ;
105+ }
106+
107+ /**
108+ * WebSocketManager interface for the websocket manager from amazon-connect-streams
109+ */
110+ interface WebSocketManager {
111+ onConnectionGain : ( callback : ( event : unknown ) => void ) => void ;
112+ onConnectionLost : ( callback : ( event : unknown ) => void ) => void ;
113+ onMessage : ( callback : ( event : unknown ) => void ) => void ;
114+ sendMessage : ( message : Record < string , unknown > ) => void ;
115+ connect : ( ) => void ;
116+ disconnect : ( ) => void ;
92117 }
93118
94119 // =======
@@ -107,17 +132,46 @@ declare namespace connect {
107132 interface ChatGlobalConfig extends ChatSessionOptions {
108133 /** The logging configuration. */
109134 readonly loggerConfig ?: {
110- /** The logger object. */
111- readonly logger ?: ChatLogger ;
112-
113- /**
114- * The logging level.
115- * @default connect.ChatSession.LogLevel.INFO
116- */
135+ /** Custom logger implementation */
136+ readonly customizedLogger ?: {
137+ /** Debug level logging function */
138+ debug : ( ...msg : any [ ] ) => void ;
139+ /** Info level logging function */
140+ info : ( ...msg : any [ ] ) => void ;
141+ /** Warning level logging function */
142+ warn : ( ...msg : any [ ] ) => void ;
143+ /** Error level logging function */
144+ error : ( ...msg : any [ ] ) => void ;
145+ } ;
146+
147+ /** The logging level */
117148 readonly level ?: ChatLogLevel [ keyof ChatLogLevel ] ;
149+
150+ /** Flag to use default logger */
151+ readonly useDefaultLogger ?: boolean ;
152+ } ;
153+
154+ /** AWS Region for the chat service */
155+ readonly region ?: string ;
156+
157+ /** Feature configurations */
158+ readonly features ?: {
159+ /** Message receipt configuration */
160+ messageReceipts ?: {
161+ /** Enable/disable Read/Delivered receipts */
162+ shouldSendMessageReceipts ?: boolean ;
163+ /** Throttle time in milliseconds before sending Read/Delivered receipt */
164+ throttleTime ?: number ;
165+ } ;
118166 } ;
119- readonly features ?: any ;
167+
168+ /** Custom user agent suffix */
120169 readonly customUserAgentSuffix ?: string ;
170+
171+ /** WebSocket manager configuration for React Native */
172+ readonly webSocketManagerConfig ?: {
173+ isNetworkOnline : ( ) => boolean ;
174+ }
121175 }
122176
123177 interface ChatLogger {
@@ -150,8 +204,37 @@ declare namespace connect {
150204 // Chat session
151205 // ============
152206
207+ /**
208+ * Represents the network connection status
209+ */
210+ interface NetworkLinkStatus {
211+ readonly NeverEstablished : "NeverEstablished" ;
212+ readonly Establishing : "Establishing" ;
213+ readonly Established : "Established" ;
214+ readonly Broken : "Broken" ;
215+ }
216+
217+ /**
218+ * The ChatController interface that handles the core chat functionality
219+ */
220+ interface ChatController {
221+ subscribe ( eventName : string , callback : ( event : unknown ) => void ) : void ;
222+ sendMessage ( args : SendMessageArgs ) : Promise < ParticipantServiceResponse < SendMessageResult > > ;
223+ sendAttachment ( args : SendAttachmentArgs ) : Promise < ParticipantServiceResponse < SendAttachmentResult > > ;
224+ downloadAttachment ( args : DownloadAttachmentArgs ) : Promise < Blob > ;
225+ sendEvent ( args : SendEventArgs ) : Promise < ParticipantServiceResponse < SendEventResult > > ;
226+ getTranscript ( args : GetTranscriptArgs ) : Promise < ParticipantServiceResponse < GetTranscriptResult > > ;
227+ connect ( args ?: ConnectArgs ) : Promise < ConnectChatResult > ;
228+ getChatDetails ( ) : ChatDetails ;
229+ describeView ( args : DescribeViewArgs ) : Promise < ParticipantServiceResponse < DescribeViewResult > > ;
230+ getAuthenticationUrl ( args : GetAuthenticationUrlArgs ) : Promise < ParticipantServiceResponse < GetAuthenticationUrlResult > > ;
231+ cancelParticipantAuthentication ( args : CancelParticipantAuthenticationArgs ) : Promise < ParticipantServiceResponse < void > > ;
232+ cleanUpOnParticipantDisconnect ?( ) : void ;
233+ disconnectParticipant ?( ) : Promise < ParticipantServiceResponse < void > > ;
234+ }
235+
153236 interface ChatSessionInterface {
154- controller : any ;
237+ controller : ChatController ;
155238
156239 /** Gets the chat session details. */
157240 getChatDetails ( ) : ChatDetails ;
@@ -398,7 +481,7 @@ declare namespace connect {
398481 onParticipantInvited ( handler : ( event : ChatMessageEvent ) => void ) : void ;
399482
400483 /**
401- * Subscribes an event handler that triggers whenever a "application/vnd.amazonaws.connect.event.participant.autodisconnection" event is created by any participant.
484+ * Subscribes an event handler that triggers whenever a "application/vnd.amazonaws.connect.event.participant.autodisconnection" event is created by any participant.
402485 * @param handler The event handler.
403486 */
404487 onAutoDisconnection ( handler : ( event : ChatMessageEvent ) => void ) : void ;
@@ -458,9 +541,15 @@ declare namespace connect {
458541 | "application/vnd.amazonaws.connect.event.message.delivered"
459542 | "application/vnd.amazonaws.connect.event.participant.joined"
460543 | "application/vnd.amazonaws.connect.event.participant.left"
544+ | "application/vnd.amazonaws.connect.event.participant.idle"
545+ | "application/vnd.amazonaws.connect.event.participant.returned"
546+ | "application/vnd.amazonaws.connect.event.participant.invited"
547+ | "application/vnd.amazonaws.connect.event.participant.autodisconnection"
461548 | "application/vnd.amazonaws.connect.event.transfer.succeeded"
462549 | "application/vnd.amazonaws.connect.event.transfer.failed"
463550 | "application/vnd.amazonaws.connect.event.chat.ended"
551+ | "application/vnd.amazonaws.connect.event.chat.rehydrated"
552+ | "application/vnd.amazonaws.connect.event.connection.acknowledged"
464553 | "application/vnd.amazonaws.connect.event.authentication.initiated"
465554 | "application/vnd.amazonaws.connect.event.authentication.succeeded"
466555 | "application/vnd.amazonaws.connect.event.authentication.failed"
@@ -473,7 +562,22 @@ declare namespace connect {
473562 type ChatMessageContentType =
474563 | "text/plain"
475564 | "text/markdown"
476- | "application/json" ;
565+ | "text/csv"
566+ | "application/msword"
567+ | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
568+ | "application/json"
569+ | "application/pdf"
570+ | "application/vnd.ms-powerpoint"
571+ | "application/vnd.openxmlformats-officedocument.presentationml.presentation"
572+ | "application/vnd.ms-excel"
573+ | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
574+ | "image/jpeg"
575+ | "image/png"
576+ | "audio/wav"
577+ | "audio/x-wav"
578+ | "audio/vnd.wave"
579+ | "application/vnd.amazonaws.connect.message.interactive"
580+ | "application/vnd.amazonaws.connect.message.interactive.response" ;
477581
478582 type ChatContentType = ChatEventContentType | ChatMessageContentType ;
479583
@@ -804,48 +908,48 @@ declare namespace connect {
804908 readonly Id : string ;
805909 }
806910
807- /**
808- * Represents the response of the Amazon Connect Participant Service `CompleteAttachmentUpload` API.
809- * See: https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CompleteAttachmentUpload.html
810- */
911+ /**
912+ * Represents the response of the Amazon Connect Participant Service `CompleteAttachmentUpload` API.
913+ * See: https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_CompleteAttachmentUpload.html
914+ */
811915 interface SendAttachmentResult {
812916 }
813917
918+ /**
919+ * An object that is transformed to a request of the Amazon Connect Participant Service `SendMessage` API.
920+ * See: https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_SendMessage.html#API_SendMessage_RequestSyntax
921+ */
922+ interface DescribeViewArgs {
814923 /**
815- * An object that is transformed to a request of the Amazon Connect Participant Service `SendMessage` API.
816- * See: https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_SendMessage.html#API_SendMessage_RequestSyntax
817- */
818- interface DescribeViewArgs {
819- /**
820- * The identifier of the Amazon Connect instance. You can find the instanceId in the ARN of
821- * the instance.
822- * @public
823- */
824- InstanceId : string | undefined ;
924+ * The identifier of the Amazon Connect instance. You can find the instanceId in the ARN of
925+ * the instance.
926+ * @public
927+ */
928+ InstanceId : string | undefined ;
825929
826- /**
827- * The ViewId of the view. This must be an ARN for Amazon Web Services managed views.
828- * @public
829- */
830- viewToken : string | undefined ;
831- /**
832- * additional metadata to echo back in response
833- * @public
834- */
835- metadata : any ;
836- }
837-
838930 /**
839- * Represents the response of the Amazon Connect Participant Service `SendMessage` API.
840- * See: https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_SendMessage.html#API_SendMessage_ResponseSyntax
931+ * The ViewId of the view. This must be an ARN for Amazon Web Services managed views.
932+ * @public
933+ */
934+ viewToken : string | undefined ;
935+ /**
936+ * additional metadata to echo back in response
937+ * @public
841938 */
842- interface DescribeViewResult {
843- /**
844- * All view data is contained within the View object.
845- * @public
846- */
847- View ?: View ;
848- }
939+ metadata ?: unknown ;
940+ }
941+
942+ /**
943+ * Represents the response of the Amazon Connect Participant Service `SendMessage` API.
944+ * See: https://docs.aws.amazon.com/connect-participant/latest/APIReference/API_SendMessage.html#API_SendMessage_ResponseSyntax
945+ */
946+ interface DescribeViewResult {
947+ /**
948+ * All view data is contained within the View object.
949+ * @public
950+ */
951+ View ?: View ;
952+ }
849953
850954 // ======
851955 // Events
@@ -888,15 +992,15 @@ declare namespace connect {
888992 interface ChatAuthenticationInitiatedEvent {
889993 readonly chatDetails : ChatDetails ;
890994 readonly data : ChatEventData & {
891- ContentType : string ;
892- content : string ;
995+ ContentType : "application/vnd.amazonaws.connect.event.authentication.initiated" ;
996+ Content : string ; // Contains JSON with SessionId
893997 } ;
894998 }
895999
8961000 interface ChatParticipantDisplayNameUpdatedEvent {
8971001 readonly chatDetails : ChatDetails ;
8981002 readonly data : ChatEventData & {
899- ContentType : string ;
1003+ ContentType : "application/vnd.amazonaws.connect.event.participant.displayname.updated" ;
9001004 DisplayName : string ;
9011005 } ;
9021006 }
@@ -908,48 +1012,51 @@ declare namespace connect {
9081012 } ;
9091013 }
9101014
1015+ /**
1016+ * Client-side metrics service for tracking API metrics (count, latency, error count)
1017+ */
9111018 interface CSMService {
9121019 widgetType : string ;
9131020 logger : {
914- options : any ;
915- debug ( ...args : any [ ] ) : any ;
916- info ( ...args : any [ ] ) : any ;
917- warn ( ...args : any [ ] ) : any ;
918- error ( ...args : any [ ] ) : any ;
919- advancedLog ( ...args : any [ ] ) : any ;
920- _shouldLog ( level : any ) : boolean ;
921- _writeToClientLogger ( level : any , logStatement : any ) : any ;
922- _log ( level : any , args : any ) : any ;
923- _convertToSingleStatement ( args : any ) : string ;
924- _convertToString ( arg : any ) : any ;
1021+ options : Record < string , unknown > ;
1022+ debug ( ...args : unknown [ ] ) : void ;
1023+ info ( ...args : unknown [ ] ) : void ;
1024+ warn ( ...args : unknown [ ] ) : void ;
1025+ error ( ...args : unknown [ ] ) : void ;
1026+ advancedLog ( ...args : unknown [ ] ) : void ;
1027+ _shouldLog ( level : number ) : boolean ;
1028+ _writeToClientLogger ( level : number , logStatement : string ) : void ;
1029+ _log ( level : number , args : unknown [ ] ) : void ;
1030+ _convertToSingleStatement ( args : unknown [ ] ) : string ;
1031+ _convertToString ( arg : unknown ) : string ;
9251032 } ;
9261033 csmInitialized : boolean ;
927- metricsToBePublished : any [ ] ;
928- agentMetricToBePublished : any [ ] ;
1034+ metricsToBePublished : Record < string , unknown > [ ] ;
1035+ agentMetricToBePublished : Record < string , unknown > [ ] ;
9291036 MAX_RETRY : number ;
9301037 loadCsmScriptAndExecute ( ) : void ;
9311038 initializeCSM ( ) : void ;
932- updateCsmConfig ( csmConfig : any ) : void ;
1039+ updateCsmConfig ( csmConfig : Record < string , unknown > ) : void ;
9331040 _hasCSMFailedToImport ( ) : boolean ;
9341041 getDefaultDimensions ( ) : {
9351042 name : string ;
9361043 value : string ;
9371044 } [ ] ;
938- addMetric ( metric : any ) : void ;
939- setDimensions ( metric : any , dimensions : any ) : void ;
940- addLatencyMetric ( method : any , timeDifference : any , category : any , otherDimensions ?: any [ ] ) : void ;
941- addLatencyMetricWithStartTime ( method : any , startTime : any , category : any , otherDimensions ?: any [ ] ) : void ;
942- addCountAndErrorMetric ( method : any , category : any , error : any , otherDimensions ?: any [ ] ) : void ;
943- addCountMetric ( method : any , category : any , otherDimensions ?: any [ ] ) : void ;
944- addAgentCountMetric ( metricName : any , count : any ) : void ;
1045+ addMetric ( metric : Record < string , unknown > ) : void ;
1046+ setDimensions ( metric : Record < string , unknown > , dimensions : Array < { name : string , value : string } > ) : void ;
1047+ addLatencyMetric ( method : string , timeDifference : number , category : string , otherDimensions ?: Array < { name : string , value : string } > ) : void ;
1048+ addLatencyMetricWithStartTime ( method : string , startTime : number , category : string , otherDimensions ?: Array < { name : string , value : string } > ) : void ;
1049+ addCountAndErrorMetric ( method : string , category : string , error : boolean , otherDimensions ?: Array < { name : string , value : string } > ) : void ;
1050+ addCountMetric ( method : string , category : string , otherDimensions ?: Array < { name : string , value : string } > ) : void ;
1051+ addAgentCountMetric ( metricName : string , count : number ) : void ;
9451052 }
9461053
9471054 interface SetFeatureFlag {
948- ( feature : any ) : void
1055+ ( feature : string ) : void
9491056 }
9501057
9511058 interface SetRegionOverride {
952- ( regionOverride : any ) : void
1059+ ( regionOverride : string ) : void
9531060 }
9541061
9551062 interface View {
0 commit comments