@@ -93,7 +93,7 @@ const schemaUrl: ReadonlyMap<SpecVersion, string> = new Map([
93
93
interface Normalizer {
94
94
normalize : ( data : object , options : NormalizerOptions ) => object | undefined
95
95
96
- normalizeIter ?: ( data : Iterable < object > , options : NormalizerOptions ) => object [ ]
96
+ normalizeRepository ?: ( data : Iterable < object > , options : NormalizerOptions ) => object [ ]
97
97
}
98
98
99
99
abstract class Base implements Normalizer {
@@ -120,7 +120,7 @@ export class BomNormalizer extends Base {
120
120
serialNumber : data . serialNumber ,
121
121
metadata : this . _factory . makeForMetadata ( ) . normalize ( data . metadata , options ) ,
122
122
components : data . components . size > 0
123
- ? this . _factory . makeForComponent ( ) . normalizeIter ( data . components , options )
123
+ ? this . _factory . makeForComponent ( ) . normalizeRepository ( data . components , options )
124
124
// spec < 1.4 requires `component` to be array
125
125
: [ ] ,
126
126
dependencies : this . _factory . spec . supportsDependencyGraph
@@ -136,10 +136,10 @@ export class MetadataNormalizer extends Base {
136
136
return {
137
137
timestamp : data . timestamp ?. toISOString ( ) ,
138
138
tools : data . tools . size > 0
139
- ? this . _factory . makeForTool ( ) . normalizeIter ( data . tools , options )
139
+ ? this . _factory . makeForTool ( ) . normalizeRepository ( data . tools , options )
140
140
: undefined ,
141
141
authors : data . authors . size > 0
142
- ? this . _factory . makeForOrganizationalContact ( ) . normalizeIter ( data . authors , options )
142
+ ? this . _factory . makeForOrganizationalContact ( ) . normalizeRepository ( data . authors , options )
143
143
: undefined ,
144
144
component : data . component === undefined
145
145
? undefined
@@ -161,20 +161,20 @@ export class ToolNormalizer extends Base {
161
161
name : data . name || undefined ,
162
162
version : data . version || undefined ,
163
163
hashes : data . hashes . size > 0
164
- ? this . _factory . makeForHash ( ) . normalizeIter ( data . hashes , options )
164
+ ? this . _factory . makeForHash ( ) . normalizeRepository ( data . hashes , options )
165
165
: undefined ,
166
166
externalReferences : this . _factory . spec . supportsToolReferences && data . externalReferences . size > 0
167
- ? this . _factory . makeForExternalReference ( ) . normalizeIter ( data . externalReferences , options )
167
+ ? this . _factory . makeForExternalReference ( ) . normalizeRepository ( data . externalReferences , options )
168
168
: undefined
169
169
}
170
170
}
171
171
172
- normalizeIter ( data : Iterable < Models . Tool > , options : NormalizerOptions ) : Normalized . Tool [ ] {
173
- const tools = Array . from ( data )
174
- if ( options . sortLists ?? false ) {
175
- tools . sort ( Models . ToolRepository . compareItems )
176
- }
177
- return tools . map ( t => this . normalize ( t , options ) )
172
+ normalizeRepository ( data : Models . ToolRepository , options : NormalizerOptions ) : Normalized . Tool [ ] {
173
+ return (
174
+ options . sortLists ?? false
175
+ ? data . sorted ( )
176
+ : Array . from ( data )
177
+ ) . map ( t => this . normalize ( t , options ) )
178
178
}
179
179
}
180
180
@@ -189,13 +189,13 @@ export class HashNormalizer extends Base {
189
189
: undefined
190
190
}
191
191
192
- normalizeIter ( data : Iterable < Models . Hash > , options : NormalizerOptions ) : Normalized . Hash [ ] {
193
- const hashes = Array . from ( data )
194
- if ( options . sortLists ?? false ) {
195
- hashes . sort ( Models . HashRepository . compareItems )
196
- }
197
- return hashes . map ( h => this . normalize ( h , options ) )
198
- . filter ( isNotUndefined )
192
+ normalizeRepository ( data : Models . HashRepository , options : NormalizerOptions ) : Normalized . Hash [ ] {
193
+ return (
194
+ options . sortLists ?? false
195
+ ? data . sorted ( )
196
+ : Array . from ( data )
197
+ ) . map ( h => this . normalize ( h , options )
198
+ ) . filter ( isNotUndefined )
199
199
}
200
200
}
201
201
@@ -210,12 +210,12 @@ export class OrganizationalContactNormalizer extends Base {
210
210
}
211
211
}
212
212
213
- normalizeIter ( data : Iterable < Models . OrganizationalContact > , options : NormalizerOptions ) : Normalized . OrganizationalContact [ ] {
214
- const contacts = Array . from ( data )
215
- if ( options . sortLists ?? false ) {
216
- contacts . sort ( Models . OrganizationalContactRepository . compareItems )
217
- }
218
- return contacts . map ( c => this . normalize ( c , options ) )
213
+ normalizeRepository ( data : Models . OrganizationalContactRepository , options : NormalizerOptions ) : Normalized . OrganizationalContact [ ] {
214
+ return (
215
+ options . sortLists ?? false
216
+ ? data . sorted ( )
217
+ : Array . from ( data )
218
+ ) . map ( c => this . normalize ( c , options ) )
219
219
}
220
220
}
221
221
@@ -230,7 +230,7 @@ export class OrganizationalEntityNormalizer extends Base {
230
230
? urls
231
231
: undefined ,
232
232
contact : data . contact . size > 0
233
- ? this . _factory . makeForOrganizationalContact ( ) . normalizeIter ( data . contact , options )
233
+ ? this . _factory . makeForOrganizationalContact ( ) . normalizeRepository ( data . contact , options )
234
234
: undefined
235
235
}
236
236
}
@@ -254,10 +254,10 @@ export class ComponentNormalizer extends Base {
254
254
description : data . description || undefined ,
255
255
scope : data . scope ,
256
256
hashes : data . hashes . size > 0
257
- ? this . _factory . makeForHash ( ) . normalizeIter ( data . hashes , options )
257
+ ? this . _factory . makeForHash ( ) . normalizeRepository ( data . hashes , options )
258
258
: undefined ,
259
259
licenses : data . licenses . size > 0
260
- ? this . _factory . makeForLicense ( ) . normalizeIter ( data . licenses , options )
260
+ ? this . _factory . makeForLicense ( ) . normalizeRepository ( data . licenses , options )
261
261
: undefined ,
262
262
copyright : data . copyright || undefined ,
263
263
cpe : data . cpe || undefined ,
@@ -266,19 +266,19 @@ export class ComponentNormalizer extends Base {
266
266
? undefined
267
267
: this . _factory . makeForSWID ( ) . normalize ( data . swid , options ) ,
268
268
externalReferences : data . externalReferences . size > 0
269
- ? this . _factory . makeForExternalReference ( ) . normalizeIter ( data . externalReferences , options )
269
+ ? this . _factory . makeForExternalReference ( ) . normalizeRepository ( data . externalReferences , options )
270
270
: undefined
271
271
}
272
272
: undefined
273
273
}
274
274
275
- normalizeIter ( data : Iterable < Models . Component > , options : NormalizerOptions ) : Normalized . Component [ ] {
276
- const components = Array . from ( data )
277
- if ( options . sortLists ?? false ) {
278
- components . sort ( Models . ComponentRepository . compareItems )
279
- }
280
- return components . map ( c => this . normalize ( c , options ) )
281
- . filter ( isNotUndefined )
275
+ normalizeRepository ( data : Models . ComponentRepository , options : NormalizerOptions ) : Normalized . Component [ ] {
276
+ return (
277
+ options . sortLists ?? false
278
+ ? data . sorted ( )
279
+ : Array . from ( data )
280
+ ) . map ( c => this . normalize ( c , options )
281
+ ) . filter ( isNotUndefined )
282
282
}
283
283
}
284
284
@@ -327,12 +327,12 @@ export class LicenseNormalizer extends Base {
327
327
}
328
328
}
329
329
330
- normalizeIter ( data : Iterable < Models . License > , options : NormalizerOptions ) : Normalized . License [ ] {
331
- const licenses = Array . from ( data )
332
- if ( options . sortLists ?? false ) {
333
- licenses . sort ( Models . LicenseRepository . compareItems )
334
- }
335
- return licenses . map ( c => this . normalize ( c , options ) )
330
+ normalizeRepository ( data : Models . LicenseRepository , options : NormalizerOptions ) : Normalized . License [ ] {
331
+ return (
332
+ options . sortLists ?? false
333
+ ? data . sorted ( )
334
+ : Array . from ( data )
335
+ ) . map ( c => this . normalize ( c , options ) )
336
336
}
337
337
}
338
338
@@ -366,13 +366,13 @@ export class ExternalReferenceNormalizer extends Base {
366
366
: undefined
367
367
}
368
368
369
- normalizeIter ( data : Iterable < Models . ExternalReference > , options : NormalizerOptions ) : Normalized . ExternalReference [ ] {
370
- const refs = Array . from ( data )
371
- if ( options . sortLists ?? false ) {
372
- refs . sort ( Models . ExternalReferenceRepository . compareItems )
373
- }
374
- return refs . map ( r => this . normalize ( r , options ) )
375
- . filter ( isNotUndefined )
369
+ normalizeRepository ( data : Models . ExternalReferenceRepository , options : NormalizerOptions ) : Normalized . ExternalReference [ ] {
370
+ return (
371
+ options . sortLists ?? false
372
+ ? data . sorted ( )
373
+ : Array . from ( data )
374
+ ) . map ( r => this . normalize ( r , options )
375
+ ) . filter ( isNotUndefined )
376
376
}
377
377
}
378
378
0 commit comments