@@ -38,8 +38,12 @@ const searchTreeDefinition = `root {
3838 }
3939}` ;
4040
41+ function resolve < T > ( value : T ) {
42+ return new Promise < T > ( ( resolve ) => resolve ( value ) ) ;
43+ }
44+
4145class SearchAgent extends BaseAgent {
42- [ key : string ] : any ;
46+ [ key : string ] : unknown ;
4347 private query : string = "" ;
4448 private results : SearchResult [ ] = [ ] ;
4549 private searchPromises : Map < string , Promise < SearchResult > > = new Map ( ) ;
@@ -59,15 +63,15 @@ class SearchAgent extends BaseAgent {
5963 this . logger . info ( "Reset search state" ) ;
6064 }
6165
62- async InitiateSearch ( ) : Promise < State > {
66+ InitiateSearch ( ) : Promise < State > {
6367 return this . measureStep ( "InitiateSearch" , async ( ) => {
6468 this . resetSearch ( ) ;
6569 this . logger . info ( `Initiated search with query: ${ this . query } ` ) ;
66- return State . SUCCEEDED ;
70+ return await resolve ( State . SUCCEEDED ) ;
6771 } ) ;
6872 }
6973
70- async SearchKeyMatch ( ) : Promise < State > {
74+ SearchKeyMatch ( ) : Promise < State > {
7175 return this . measureStep ( "SearchKeyMatch" , async ( ) => {
7276 if ( ! this . searchPromises . has ( "key-search" ) ) {
7377 this . logger . info ( "Starting key match search" ) ;
@@ -76,11 +80,11 @@ class SearchAgent extends BaseAgent {
7680 scanForKey ( this . query , this . redis , this . logger ) ,
7781 ) ;
7882 }
79- return State . SUCCEEDED ;
83+ return await resolve ( State . SUCCEEDED ) ;
8084 } ) ;
8185 }
8286
83- async SearchTextMatch ( ) : Promise < State > {
87+ SearchTextMatch ( ) : Promise < State > {
8488 return this . measureStep ( "SearchTextMatch" , async ( ) => {
8589 if ( ! this . searchPromises . has ( "text-search" ) ) {
8690 this . logger . info ( "Starting text match search" ) ;
@@ -89,11 +93,11 @@ class SearchAgent extends BaseAgent {
8993 scanForText ( this . query , this . redis , this . logger ) ,
9094 ) ;
9195 }
92- return State . SUCCEEDED ;
96+ return await resolve ( State . SUCCEEDED ) ;
9397 } ) ;
9498 }
9599
96- async SearchSchemaMatch ( ) : Promise < State > {
100+ SearchSchemaMatch ( ) : Promise < State > {
97101 return this . measureStep ( "SearchSchemaMatch" , async ( ) => {
98102 if ( ! this . searchPromises . has ( "schema-match" ) ) {
99103 this . logger . info ( "Starting schema match search" ) ;
@@ -102,14 +106,14 @@ class SearchAgent extends BaseAgent {
102106
103107 this . searchPromises . set (
104108 "schema-match" ,
105- scanBySchema ( this . redis , schema , this . logger ) ,
109+ scanBySchema ( schema , this . redis , this . logger ) ,
106110 ) ;
107111 }
108- return State . SUCCEEDED ;
112+ return await resolve ( State . SUCCEEDED ) ;
109113 } ) ;
110114 }
111115
112- async SearchCollectionMatch ( ) : Promise < State > {
116+ SearchCollectionMatch ( ) : Promise < State > {
113117 return this . measureStep ( "SearchCollectionMatch" , async ( ) => {
114118 if ( ! this . searchPromises . has ( "collection-match" ) ) {
115119 this . logger . info ( "Starting collection match search" ) ;
@@ -118,11 +122,11 @@ class SearchAgent extends BaseAgent {
118122 scanByCollections ( this . query , this . redis , this . logger ) ,
119123 ) ;
120124 }
121- return State . SUCCEEDED ;
125+ return await resolve ( State . SUCCEEDED ) ;
122126 } ) ;
123127 }
124128
125- async CollectResults ( ) : Promise < State > {
129+ CollectResults ( ) : Promise < State > {
126130 return this . measureStep ( "CollectResults" , async ( ) => {
127131 try {
128132 this . logger . info ( "Collecting results from all sources" ) ;
@@ -144,10 +148,10 @@ class SearchAgent extends BaseAgent {
144148 this . logger . info (
145149 `Collected ${ this . results . length } result sets after deduplication` ,
146150 ) ;
147- return State . SUCCEEDED ;
151+ return await resolve ( State . SUCCEEDED ) ;
148152 } catch ( error ) {
149153 this . logger . error ( "Error collecting results:" , error ) ;
150- return State . FAILED ;
154+ return await resolve ( State . FAILED ) ;
151155 }
152156 } ) ;
153157 }
@@ -165,7 +169,7 @@ class SearchAgent extends BaseAgent {
165169 }
166170}
167171
168- export async function performSearch (
172+ export function performSearch (
169173 query : string ,
170174 redis : RedisClientType ,
171175 logger : Logger ,
0 commit comments