@@ -4,6 +4,7 @@ import { ValueOf } from 'type-fest';
4
4
import { ID , NotFoundException , ServerException , Session } from '~/common' ;
5
5
import { ResourceMap , ResourceResolver , ResourcesHost } from '~/core' ;
6
6
import { Privileges } from '../authorization' ;
7
+ import { LanguageService } from '../language' ;
7
8
import { PartnerService } from '../partner' ;
8
9
import {
9
10
SearchableMap ,
@@ -37,6 +38,10 @@ export class SearchService {
37
38
...( await this . partners . readOnePartnerByOrgId ( ...args ) ) ,
38
39
__typename : 'Partner' ,
39
40
} ) ,
41
+ LanguageByEth : async ( ...args ) => ( {
42
+ ...( await this . languages . readOneByEthId ( ...args ) ) ,
43
+ __typename : 'Language' ,
44
+ } ) ,
40
45
} ;
41
46
/* eslint-enable @typescript-eslint/naming-convention */
42
47
@@ -45,6 +50,7 @@ export class SearchService {
45
50
private readonly resources : ResourceResolver ,
46
51
private readonly privileges : Privileges ,
47
52
private readonly partners : PartnerService ,
53
+ private readonly languages : LanguageService ,
48
54
private readonly repo : SearchRepository ,
49
55
) { }
50
56
@@ -55,6 +61,7 @@ export class SearchService {
55
61
const types = new Set < keyof ResourceMap > ( inputTypes ) ;
56
62
// Include dependency types for types that have identifiers in sub-resources.
57
63
inputTypes . has ( 'Partner' ) && types . add ( 'Organization' ) ;
64
+ inputTypes . has ( 'Language' ) && types . add ( 'EthnologueLanguage' ) ;
58
65
59
66
// Search for nodes based on input, only returning their id and "type"
60
67
// which is based on their first valid search label.
@@ -89,6 +96,13 @@ export class SearchService {
89
96
: [ ] ) ,
90
97
] ;
91
98
}
99
+ if ( result . type === 'EthnologueLanguage' ) {
100
+ return {
101
+ type : 'LanguageByEth' ,
102
+ id : result . id ,
103
+ matchedProps : [ 'ethnologue' ] ,
104
+ } as const ;
105
+ }
92
106
93
107
return setHas ( inputTypes , result . type )
94
108
? ( result as Extract < typeof result , { type : keyof SearchableMap } > )
0 commit comments