@@ -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
@@ -72,6 +75,10 @@ export class Factory {
7275 return new ToolNormalizer ( this )
7376 }
7477
78+ makeForTools ( ) : ToolsNormalizer {
79+ return new ToolsNormalizer ( this )
80+ }
81+
7582 makeForOrganizationalContact ( ) : OrganizationalContactNormalizer {
7683 return new OrganizationalContactNormalizer ( this )
7784 }
@@ -221,7 +228,7 @@ export class MetadataNormalizer extends BaseJsonNormalizer<Models.Metadata> {
221228 ? this . _factory . makeForLifecycle ( ) . normalizeIterable ( data . lifecycles , options )
222229 : undefined ,
223230 tools : data . tools . size > 0
224- ? this . _factory . makeForTool ( ) . normalizeIterable ( data . tools , options )
231+ ? this . _factory . makeForTools ( ) . normalize ( data . tools , options )
225232 : undefined ,
226233 authors : data . authors . size > 0
227234 ? this . _factory . makeForOrganizationalContact ( ) . normalizeIterable ( data . authors , options )
@@ -285,6 +292,23 @@ export class ToolNormalizer extends BaseJsonNormalizer<Models.Tool> {
285292 }
286293}
287294
295+ export class ToolsNormalizer extends BaseJsonNormalizer < Models . Tools > {
296+ normalize ( data : Models . Tools , options : NormalizerOptions ) : Normalized . ToolsType {
297+ if ( data . tools . size > 0 ) {
298+ return this . _factory . makeForTool ( ) . normalizeIterable (
299+ new ToolRepository ( chainI < Models . Tool > (
300+ Array . from ( data . components , Tool . fromComponent ) ,
301+ // TODO services
302+ data . tools ,
303+ ) ) , options )
304+ }
305+ return {
306+ components : this . _factory . makeForComponent ( ) . normalizeIterable ( data . components , options )
307+ // TODO services
308+ }
309+ }
310+ }
311+
288312export class HashNormalizer extends BaseJsonNormalizer < Models . Hash > {
289313 normalize ( [ algorithm , content ] : Models . Hash , options : NormalizerOptions ) : Normalized . Hash | undefined {
290314 const spec = this . _factory . spec
@@ -723,7 +747,7 @@ export class VulnerabilityNormalizer extends BaseJsonNormalizer<Models.Vulnerabi
723747 ? undefined
724748 : this . _factory . makeForVulnerabilityCredits ( ) . normalize ( data . credits , options ) ,
725749 tools : data . tools . size > 0
726- ? this . _factory . makeForTool ( ) . normalizeIterable ( data . tools , options )
750+ ? this . _factory . makeForTools ( ) . normalize ( data . tools , options )
727751 : undefined ,
728752 analysis : data . analysis === undefined
729753 ? undefined
0 commit comments