import { IMineMeldAPIService , IMineMeldAPIResource } from './minemeldapi' ; export interface IMineMeldExtension { name : string ; version : string ; author : string ; author_email : string ; description : string ; installed : boolean ; activated : boolean ; path : string ; running_job : string ; entry_points ? : { [ epgroup ] : any ; } ; } export interface IMineMeldExtensionsService { list ( cancellable ? ) : angular . IPromise < IMineMeldExtension [ ] > ; activate ( name , version , path ) : angular . IPromise < any > ; deactivate ( name , version , path ) : angular . IPromise < any > ; uninstall ( name , version , path ) : angular . IPromise < any > ; gitRefs ( endpoint ) : angular . IPromise < string [ ] > ; gitInstall ( endpoint , ref ) : angular . IPromise < string > ; } interface IMineMeldExtensionsResource extends IMineMeldAPIResource { put ( params , nodeconfig ) ; del ( params ) ; post ( params , postdata ) ; } export class MineMeldExtensionsService implements IMineMeldExtensionsService { MineMeldAPIService : IMineMeldAPIService ; constructor ( $state , MineMeldAPIService ) { this . MineMeldAPIService = MineMeldAPIService ; } list ( cancellable ? ) { var api ; if ( typeof cancellable === 'undefined' ) { cancellable = true ; } api = this . MineMeldAPIService . getAPIResource ( '/extensions' , { } , { get : { method : 'GET' } } , cancellable ) ; return api . get ( ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return new Array ( ) ; } ) ; } activate ( name , version , path ) { var api ; var params = { extension : name } ; var data = { version : version , path : path } ; api = < IMineMeldExtensionsResource > this . MineMeldAPIService . getAPIResource ( '/extensions/:extension/activate' , { } , { post : { method : 'POST' } } , false ) ; return api . post ( params , JSON . stringify ( data ) ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return undefined ; } ) ; } deactivate ( name , version , path ) { var api ; var params = { extension : name } ; var data = { version : version , path : path } ; api = < IMineMeldExtensionsResource > this . MineMeldAPIService . getAPIResource ( '/extensions/:extension/deactivate' , { } , { post : { method : 'POST' } } , false ) ; return api . post ( params , JSON . stringify ( data ) ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return undefined ; } ) ; } uninstall ( name , version , path ) { var api ; var params = { extension : name } ; var data = { version : version , path : path } ; api = < IMineMeldExtensionsResource > this . MineMeldAPIService . getAPIResource ( '/extensions/:extension/uninstall' , { } , { post : { method : 'POST' } } , false ) ; return api . post ( params , JSON . stringify ( data ) ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return undefined ; } ) ; } gitInstall ( endpoint , ref ) { var api ; var data = { ep : endpoint , ref : ref } ; api = < IMineMeldExtensionsResource > this . MineMeldAPIService . getAPIResource ( '/extensions/git-install' , { } , { post : { method : 'POST' } } , false ) ; return api . post ( { } , JSON . stringify ( data ) ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return undefined ; } ) ; } gitRefs ( endpoint ) { var api ; api = < IMineMeldExtensionsResource > this . MineMeldAPIService . getAPIResource ( '/extensions/git-refs' , { } , { get : { method : 'GET' } } ) ; return api . get ( { ep : endpoint } ) . $promise . then ( ( result ) => { if ( 'result' in result ) { return result . result ; } return [ ] ; } ) ; } }