import { InvocationType , Invocation , InvocationWrapper } from '../../models/invocation' ; export class ServerResolver { private map : Map < InvocationType , ( invocation : Invocation ) => Promise < string > > = new Map ( ) ; constructor ( private fromHardwareTypeFn , private fromExecutionFn ) { this . map . set ( InvocationType . StartExecution , fromHardwareTypeFn ) ; this . map . set ( InvocationType . StopExecution , fromExecutionFn ) ; } getServer ( invocationWrapper ) { if ( ! invocationWrapper || ! invocationWrapper . common || ! invocationWrapper . common . data ) { return Promise . resolve ( null ) ; } const fn = this . map . get ( invocationWrapper . common . type ) ; return fn ? fn ( invocationWrapper . common ) : Promise . resolve ( null ) ; } }