import { DotnetExeName , resolveDotnetRequirement } from "./dotnet" ; import { resolveGenericSystemRequirement } from "./generic" ; import { JavaExeName , resolveJavaRequirement } from "./java" ; import { ExtensionSystemRequirements , SystemRequirementError , SystemRequirement , SystemRequirementResolution , } from "./models" ; import { PythonRequirement , resolvePythonRequirement } from "./python" ; param requirements export const validateExtensionSystemRequirements = async ( requirements ) : Promise < SystemRequirementError [ ] > => { const errors = [ ] ; const results = await resolveSystemRequirements ( requirements ) ; for ( const [ name , requirement ] of Object . entries ( requirements ) ) { const result = results [ name ] ; if ( "error" in result ) { const message = requirement . message ? `${ requirement . message }. ${ result . message }` : result . message ; errors . push ( { ... result , message } ) ; } } return errors ; } ; export type SystemRequirementsResults < T > = { [ key in keyof T ] : SystemRequirementResolution | SystemRequirementError ; } ; param name param requirement returns export const resolveSystemRequirements = async < T extends { [ name ] : SystemRequirement ; } > ( requirements ) : Promise < SystemRequirementsResults < T > > => { const results = { } ; for ( const [ name , requirement ] of Object . entries ( requirements ) ) { results [ name as keyof T ] = await resolveSystemRequirement ( name , requirement ) ; } return results as SystemRequirementsResults < T > ; } ; param name param requirement returns export const resolveSystemRequirement = async ( name , requirement ) : Promise < SystemRequirementResolution | SystemRequirementError > => { switch ( name ) { case DotnetExeName : return resolveDotnetRequirement ( requirement ) ; case JavaExeName : return resolveJavaRequirement ( requirement ) ; case PythonRequirement : return resolvePythonRequirement ( requirement ) ; default : return resolveGenericSystemRequirement ( name ) ; } } ;