import { ReporterFactory } from 'accessibility-insights-report' ; import axe from 'axe-core' ; import { inject , injectable } from 'inversify' ; import { ReportFormat , CombinedScanResults } from 'storage-documents' ; import { CombinedReportDataConverter , ScanResultData } from 'axe-result-converter' ; import { iocTypeNames } from '../ioc-types' ; import { htmlReportStrings } from './html-report-strings' ; import { AxeResultConverterOptions } from './axe-result-converter' ; @ injectable ( ) export class AxeResultToConsolidatedHtmlConverter { public readonly targetReportFormat : ReportFormat = 'consolidated.html' ; constructor ( @ inject ( CombinedReportDataConverter ) private readonly combinedReportDataConverter , @ inject ( iocTypeNames . ReporterFactory ) private readonly reporterFactoryFunc , private readonly axeCore = axe ) { } public convert ( combinedScanResults , options ) { const reporter = this . reporterFactoryFunc ( ) ; const scanResultData = { baseUrl : options . baseUrl ?? 'n/a' , basePageTitle : '' , scanEngineName : htmlReportStrings . serviceName , axeCoreVersion : this . axeCore . version , browserUserAgent : options . userAgent , browserResolution : options . browserResolution , urlCount : combinedScanResults . urlCount , scanStarted : options . scanStarted , scanEnded : new Date ( ) , } ; const combinedReportData = this . combinedReportDataConverter . convert ( combinedScanResults . axeResults , scanResultData ) ; return reporter . fromCombinedResults ( combinedReportData ) . asHTML ( ) ; } }