@@ -23,6 +23,7 @@ import type { Stringable } from '../../_helpers/stringable'
2323import { treeIteratorSymbol } from '../../_helpers/tree'
2424import { escapeUri } from '../../_helpers/uri'
2525import type * as Models from '../../models'
26+ import { ToolRepository } from '../../models/tool'
2627import { LicenseExpression , NamedLicense , SpdxLicense } from '../../models/license'
2728import { NamedLifecycle } from '../../models/lifecycle'
2829import { AffectedSingleVersion , AffectedVersionRange } from '../../models/vulnerability/affect'
@@ -32,6 +33,8 @@ import { Version as SpecVersion } from '../../spec/enums'
3233import type { NormalizerOptions } from '../types'
3334import type { Normalized } from './types'
3435import { JsonSchema } from './types'
36+ import { chainI } from "../../_helpers/iterable" ;
37+ import { Tool } from "../../models" ;
3538
3639export class Factory {
3740 readonly #spec: Spec
@@ -68,6 +71,10 @@ export class Factory {
6871 return new ToolNormalizer ( this )
6972 }
7073
74+ makeForTools ( ) : ToolsNormalizer {
75+ return new ToolsNormalizer ( this )
76+ }
77+
7178 makeForOrganizationalContact ( ) : OrganizationalContactNormalizer {
7279 return new OrganizationalContactNormalizer ( this )
7380 }
@@ -214,7 +221,7 @@ export class MetadataNormalizer extends BaseJsonNormalizer<Models.Metadata> {
214221 ? this . _factory . makeForLifecycle ( ) . normalizeIterable ( data . lifecycles , options )
215222 : undefined ,
216223 tools : data . tools . size > 0
217- ? this . _factory . makeForTool ( ) . normalizeIterable ( data . tools , options )
224+ ? this . _factory . makeForTools ( ) . normalize ( data . tools , options )
218225 : undefined ,
219226 authors : data . authors . size > 0
220227 ? this . _factory . makeForOrganizationalContact ( ) . normalizeIterable ( data . authors , options )
@@ -278,6 +285,23 @@ export class ToolNormalizer extends BaseJsonNormalizer<Models.Tool> {
278285 }
279286}
280287
288+ export class ToolsNormalizer extends BaseJsonNormalizer < Models . Tools > {
289+ normalize ( data : Models . Tools , options : NormalizerOptions ) : Normalized . ToolsType {
290+ if ( data . tools . size > 0 ) {
291+ return this . _factory . makeForTool ( ) . normalizeIterable (
292+ new ToolRepository ( chainI < Models . Tool > (
293+ Array . from ( data . components , Tool . fromComponent ) ,
294+ // TODO services
295+ data . tools ,
296+ ) ) , options )
297+ }
298+ return {
299+ components : this . _factory . makeForComponent ( ) . normalizeIterable ( data . components , options )
300+ // TODO services
301+ }
302+ }
303+ }
304+
281305export class HashNormalizer extends BaseJsonNormalizer < Models . Hash > {
282306 normalize ( [ algorithm , content ] : Models . Hash , options : NormalizerOptions ) : Normalized . Hash | undefined {
283307 const spec = this . _factory . spec
@@ -675,7 +699,7 @@ export class VulnerabilityNormalizer extends BaseJsonNormalizer<Models.Vulnerabi
675699 ? undefined
676700 : this . _factory . makeForVulnerabilityCredits ( ) . normalize ( data . credits , options ) ,
677701 tools : data . tools . size > 0
678- ? this . _factory . makeForTool ( ) . normalizeIterable ( data . tools , options )
702+ ? this . _factory . makeForTools ( ) . normalize ( data . tools , options )
679703 : undefined ,
680704 analysis : data . analysis === undefined
681705 ? undefined
0 commit comments