type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'TRACE' ; interface IHttpHeader { name : string ; value : string ; } interface IHttpResponse { httpVersion : string ; statusCode : number ; statusMessage : string ; data : any ; headers : Array < IHttpHeader > ; body : Array < number > ; } interface IHttpRequest { method : HttpMethod ; url : string ; headers ? : Array < IHttpHeader > ; body ? : any ; } interface IHttpClient { getRequestTemplateAsync ( ) : Promise < IHttpRequest > ; setRequestTemplateAsync ( template ) : Promise < void > ; getAsync < T > ( url ) : Promise < T > ; postAsync < T > ( url , data ) : Promise < T > ; putAsync < T > ( url , data ) : Promise < T > ; patchAsync < T > ( url , data ) : Promise < T > ; deleteAsync < T > ( url ) : Promise < T > ; headAsync < T > ( url ) : Promise < T > ; optionsAsync < T > ( url , data ) : Promise < T > ; traceAsync < T > ( url , data ) : Promise < T > ; requestAsync ( request ) : Promise < IHttpResponse > ; } declare const sfxModuleManager ; export class StandaloneIntegration { private static iclusterUrl : string = null ; public static isStandalone ( ) { return typeof sfxModuleManager !== 'undefined' && sfxModuleManager !== null ; } public static get clusterUrl ( ) : string { if ( StandaloneIntegration . iclusterUrl == null ) { if ( StandaloneIntegration . isStandalone ( ) ) { StandaloneIntegration . iclusterUrl = StandaloneIntegration . extractQueryItem ( window . location . search , 'targetcluster' ) ; } else { StandaloneIntegration . iclusterUrl = '' ; } } return StandaloneIntegration . iclusterUrl ; } public static getHttpClient ( ) { if ( this . isStandalone ( ) ) { return sfxModuleManager . getComponentAsync < IHttpClient > ( 'http.http-client.service-fabric' ) ; } return undefined ; } private static extractQueryItem ( queryString , name ) { if ( queryString ) { const urlParameters = window . location . search . split ( '?' ) [ 1 ] ; const queryParams = urlParameters . split ( '&' ) ; for ( const q of queryParams ) { const queryParam = q . split ( '=' ) ; if ( queryParam [ 0 ] === name ) { return decodeURIComponent ( queryParam [ 1 ] ) ; } } } return null ; } }