import { ExportTypesRegistry } from '../lib/export_types_registry' ; import { FeaturesAvailability } from './' ; export function getExportTypesHandler ( exportTypesRegistry ) { return { getJobTypes ( ) { return exportTypesRegistry . getAll ( ) . map ( ( { jobType } ) => jobType ) ; } , getAvailability ( featuresAvailability ) { const exportTypesAvailability = { } ; const xpackInfoAvailable = featuresAvailability && featuresAvailability . isAvailable ( ) ; const licenseType = featuresAvailability . license . getType ( ) ; if ( ! licenseType ) { throw new Error ( 'No license type returned from XPackMainPlugin#info!' ) ; } for ( const exportType of exportTypesRegistry . getAll ( ) ) { exportTypesAvailability [ exportType . jobType ] = xpackInfoAvailable ? exportType . validLicenses . includes ( licenseType ) : false ; } return exportTypesAvailability ; } , getNumExportTypes ( ) { return exportTypesRegistry . getSize ( ) ; } , } ; } export type ExportTypesHandler = ReturnType < typeof getExportTypesHandler > ;