@@ -321,7 +321,7 @@ export class DefinitionService {
321321 } else {
322322 result = await this . recomputeHandler . compute ( this , coordinates )
323323 }
324- return this . _trimDefinition ( this . _cast ( result ) , expand )
324+ return this . _trimDefinition ( this . _cast ( result ! ) , expand )
325325 }
326326
327327 /** Get directly from cache or store without any side effect, like compute */
@@ -389,7 +389,7 @@ export class DefinitionService {
389389 }
390390
391391 _cast ( definition : Definition ) : Definition {
392- definition . coordinates = EntityCoordinates . fromObject ( definition . coordinates )
392+ definition . coordinates = EntityCoordinates . fromObject ( definition . coordinates ) !
393393 return definition
394394 }
395395
@@ -428,7 +428,7 @@ export class DefinitionService {
428428 }
429429 const curated = ( await this . curationService . list ( coordinates ) ) . map ( c => c . toString ( ) )
430430 const tools = await this . harvestStore . list ( coordinates )
431- const harvest = tools . map ( tool => EntityCoordinates . fromString ( tool ) . toString ( ) )
431+ const harvest = tools . map ( tool => EntityCoordinates . fromString ( tool ) ! . toString ( ) )
432432 return sortedUniq ( [ ...harvest , ...curated ] )
433433 }
434434
@@ -452,12 +452,12 @@ export class DefinitionService {
452452 }
453453 } )
454454 )
455- const foundDefinitions = flatten ( await Promise . all ( concat ( promises ) ) )
455+ const foundDefinitions = flatten ( await Promise . all ( concat ( promises ) ) ) . filter ( ( x ) : x is string => x !== null )
456456 // Filter only the revisions matching the found definitions
457457 return intersectionWith (
458458 coordinatesList ,
459459 foundDefinitions ,
460- ( a , b ) => a && b && a . toString ( ) . toLowerCase ( ) === b . toString ( ) . toLowerCase ( )
460+ ( a , b ) => a . toString ( ) . toLowerCase ( ) === b . toString ( ) . toLowerCase ( )
461461 )
462462 }
463463
@@ -695,7 +695,7 @@ export class DefinitionService {
695695 for ( const version in raw [ tool ] ) {
696696 const cased = get ( raw [ tool ] [ version ] , '_metadata.links.self.href' )
697697 if ( cased ) {
698- return EntityCoordinates . fromUrn ( cased )
698+ return EntityCoordinates . fromUrn ( cased ) !
699699 }
700700 }
701701 }
@@ -736,8 +736,8 @@ export class DefinitionService {
736736
737737 _ensureFinalScores ( definition : Definition ) : void {
738738 const { described, licensed } = definition
739- set ( definition , 'scores.effective' , Math . floor ( ( described . score . total + licensed . score . total ) / 2 ) )
740- set ( definition , 'scores.tool' , Math . floor ( ( described . toolScore . total + licensed . toolScore . total ) / 2 ) )
739+ set ( definition , 'scores.effective' , Math . floor ( ( described ! . score ! . total + licensed ! . score ! . total ) / 2 ) )
740+ set ( definition , 'scores.tool' , Math . floor ( ( described ! . toolScore ! . total + licensed ! . toolScore ! . total ) / 2 ) )
741741 }
742742
743743 _finalizeDefinition ( coordinates : EntityCoordinates , definition : Definition ) : void {
@@ -847,7 +847,7 @@ export class DefinitionService {
847847
848848 _collectLicenseTexts ( definition : Definition ) : string [ ] {
849849 const result : Set < string > = new Set ( )
850- for ( const file of definition . files . filter ( DefinitionService . _isLicenseFile ) ) {
850+ for ( const file of definition . files ! . filter ( DefinitionService . _isLicenseFile ) ) {
851851 this . _extractLicensesFromExpression ( file . license , result )
852852 }
853853 return Array . from ( result )
@@ -872,7 +872,7 @@ export class DefinitionService {
872872
873873 /** Answer whether or not the given file is a license text file */
874874 static _isLicenseFile ( file : DefinitionFile ) : boolean {
875- return file . token && DefinitionService . _isInCoreFacet ( file ) && ( file . natures || [ ] ) . includes ( 'license' )
875+ return ! ! file . token && DefinitionService . _isInCoreFacet ( file ) && ( file . natures || [ ] ) . includes ( 'license' )
876876 }
877877
878878 /** Suggest a set of definition coordinates that match the given pattern. Only existing definitions are searched. */
@@ -884,20 +884,20 @@ export class DefinitionService {
884884 * Helper method to prime the search store while getting the system up and running.
885885 * Should not be needed in general.
886886 */
887- async reload ( mode : string , coordinatesList : string [ ] | null = null ) : Promise < ( undefined | null ) [ ] > {
887+ async reload ( mode : string , coordinatesList : string [ ] | null = null ) : Promise < ( void | null | undefined ) [ ] > {
888888 const recompute = mode === 'definitions'
889889 const baseList = coordinatesList || ( await this . list ( new EntityCoordinates ( ) , recompute ) )
890- const list = baseList . map ( entry => EntityCoordinates . fromString ( entry ) )
890+ const list = baseList . map ( entry => EntityCoordinates . fromString ( entry ) ! )
891891 return await Promise . all (
892892 list . map (
893893 throat ( 10 , async ( coordinates : EntityCoordinates ) => {
894894 try {
895895 const definition = await this . get ( coordinates , null , recompute )
896896 if ( recompute ) {
897- return Promise . resolve ( null )
897+ return null
898898 }
899899 if ( this . search . store ) {
900- return this . search . store ( definition )
900+ return this . search . store ( definition ! )
901901 }
902902 } catch ( error ) {
903903 this . logger . info ( 'failed to reload in definition service' , {
@@ -984,7 +984,7 @@ export class DefinitionService {
984984
985985 _ensureSourceLocation ( coordinates : EntityCoordinates , definition : Definition ) : void {
986986 if ( get ( definition , 'described.sourceLocation' ) ) {
987- updateSourceLocation ( definition . described . sourceLocation )
987+ updateSourceLocation ( definition . described ! . sourceLocation ! )
988988 return
989989 }
990990 // For source components there may not be an explicit harvested source location (it is self-evident)
@@ -999,7 +999,7 @@ export class DefinitionService {
999999 return
10001000 }
10011001 this . _ensureDescribed ( definition )
1002- definition . described . sourceLocation = { ...coordinates , url }
1002+ definition . described ! . sourceLocation = { ...coordinates , url }
10031003 break
10041004 }
10051005 default :
@@ -1025,7 +1025,7 @@ export class DefinitionService {
10251025 }
10261026
10271027 _getCacheKey ( coordinates : EntityCoordinates ) : string {
1028- return `def_${ EntityCoordinates . fromObject ( coordinates ) . toString ( ) . toLowerCase ( ) } `
1028+ return `def_${ EntityCoordinates . fromObject ( coordinates ) ! . toString ( ) . toLowerCase ( ) } `
10291029 }
10301030}
10311031
0 commit comments