/**
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License.
 */ import ClClient , { ClientHeaders } from './client' ; import { AT } from '../types/ActionTypes' ; import { ErrorInjector } from '../Utils/ErrorInjector' ; import { ports , BOT_HOST_NAME } from '../types/const' ; let sdkPort = ports . urlBotPort ; let getClientHeaders = ( ) : ClientHeaders => { console . warn ( `You attempted to use the Conversation Learner Client before its getClientHeaders method was properly configured. Call setClientHeaders to configure` ) ; return { botChecksum : '' , memoryKey : '' } ; } ; export const getInstance = ( actionType ) : ClClient => { const forceError = ( actionType && ErrorInjector . ShouldError ( actionType ) ) ; /**
     * Notice we provide wrapping get functions which invoke the local functions
     * This allows the client to always access the latest of getAccessToken and getClientHeaders without reconstructing a new client
     */ const getBaseUrl = ( ) => `//${ BOT_HOST_NAME }:${ sdkPort }/sdk` ; return new ClClient ( getBaseUrl , ( ) => getClientHeaders ( ) , { } , forceError ) ; } ; export const setPort = ( port ) => { sdkPort = port ; } ; export const setHeaders = ( newGetClientHeaders ) => { getClientHeaders = newGetClientHeaders ; } ;