import VsCodeApi from "./vscodeapi" ; export interface ResultSetData { id : number ; statement : string ; columns : string [ ] ; size : number ; rows : RowsData ; } export interface RowsData { result : number ; rows : string [ ] [ ] ; offset : number ; limit : number ; } export class Api { private vscodeApi : VsCodeApi ; constructor ( vscodeApi ? ) { this . vscodeApi = vscodeApi ? vscodeApi : VsCodeApi . acquire ( ) ; } fetchResults ( ) { this . vscodeApi . postMessage ( { type : "FETCH_RESULTS" } ) ; } fetchRows ( result , offset , limit ) { this . vscodeApi . postMessage ( { type : "FETCH_ROWS" , payload : { result , offset , limit } , } ) ; } exportResults ( format , result ? ) { this . vscodeApi . postMessage ( { type : "EXPORT_RESULTS" , payload : { result , format } , } ) ; } onResults ( callback ) { this . vscodeApi . onMessage ( ( message ) => { if ( message . type === "FETCH_RESULTS" ) { callback ( message . payload ) ; } } ) ; } onRows ( callback ) { this . vscodeApi . onMessage ( ( message ) => { if ( message . type === "FETCH_ROWS" ) { callback ( message . payload ) ; } } ) ; } }