import axios , { Canceler } from 'axios' ; export { Canceler } ; example export type Extension = { publisher : { publisherId : string ; publisherName : string ; displayName : string ; flags : string ; } ; extensionId : string ; extensionName : string ; displayName : string ; flags : string ; lastUpdated : string ; publishedDate : string ; releaseDate : string ; shortDescription : string ; deploymentType : number ; } ; export type SearchRequest = { cancel : Canceler ; request : Promise < Extension [ ] | void > ; } ; export function search ( value ) { const { token , cancel } = axios . CancelToken . source ( ) ; const options = { cancelToken : token , url : 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery' , method : 'post' , headers : { accept : 'application/json;api-version=5.0-preview.1;excludeUrls=true' } , data : { filters : [ { criteria : [ { filterType : 8 , value : 'Microsoft.VisualStudio.Code' } , { filterType : 10 , value } ] , pageSize : 10 , pageNumber : 1 } ] } } ; const request = axios ( options ) . then ( ( { data } ) => data . results [ 0 ] . extensions as Extension [ ] ) . catch ( ( error ) => { if ( ! axios . isCancel ( error ) ) { throw error ; } } ) ; return { request , cancel } ; }