import { schema } from '@kbn/config-schema' ; import { LicenseType , LICENSE_TYPE } from '../../../common/types' ; import { FeatureUsageServiceSetup } from '../../services' ; import { LicensingRouter } from '../../types' ; export function registerRegisterFeatureRoute ( router , featureUsageSetup ) { router . post ( { path : '/internal/licensing/feature_usage/register' , validate : { body : schema . arrayOf ( schema . object ( { featureName : schema . string ( ) , licenseType : schema . string ( { validate : ( value ) => { if ( ! ( value in LICENSE_TYPE ) ) { return `Invalid license type: ${ value }` ; } } , } ) , } ) ) , } , } , async ( context , request , response ) => { const registrations = request . body ; registrations . forEach ( ( { featureName , licenseType } ) => { featureUsageSetup . register ( featureName , licenseType as LicenseType ) ; } ) ; return response . ok ( { body : { success : true , } , } ) ; } ) ; }