import { inject , injectable } from 'inversify' ; import { GlobalLogger } from 'logger' ; import { PageScanRunReportProvider } from 'service-library' ; import { OnDemandPageScanReport } from 'storage-documents' ; import { GeneratedReport } from './report-generator' ; @ injectable ( ) export class ReportWriter { public constructor ( @ inject ( PageScanRunReportProvider ) private readonly pageScanRunReportProvider , @ inject ( GlobalLogger ) private readonly logger ) { } public async writeBatch ( reports ) { return Promise . all ( reports . map ( async ( report ) => this . write ( report ) ) ) ; } public async write ( report ) { const href = await this . pageScanRunReportProvider . saveReport ( report . id , report . content ) ; this . logger . logInfo ( `The '${ report . format }' report saved to a blob storage.` , { reportId : report . id , blobUrl : href } ) ; return { format : report . format , href , reportId : report . id , } ; } }