@@ -11,7 +11,14 @@ import Base from './Base';
1111import FileAPI from './File' ;
1212import FolderAPI from './Folder' ;
1313import WebLinkAPI from './WebLink' ;
14- import { CACHE_PREFIX_SEARCH , FIELD_RELEVANCE , SORT_DESC , ERROR_CODE_SEARCH } from '../constants' ;
14+ import {
15+ CACHE_PREFIX_SEARCH ,
16+ FIELD_RELEVANCE ,
17+ FIELD_REPRESENTATIONS ,
18+ X_REP_HINT_HEADER_DIMENSIONS_DEFAULT ,
19+ SORT_DESC ,
20+ ERROR_CODE_SEARCH ,
21+ } from '../constants' ;
1522
1623class Search extends Base {
1724 /**
@@ -185,13 +192,17 @@ class Search extends Base {
185192 /**
186193 * Does the network request
187194 *
195+ * @param {FetchOptions } options - options for request
188196 * @return {void }
189197 */
190- searchRequest ( ) : Promise < void > {
198+ searchRequest ( options : FetchOptions = { } ) : Promise < void > {
191199 if ( this . isDestroyed ( ) ) {
192200 return Promise . reject ( ) ;
193201 }
194202
203+ const { fields } = options ;
204+ const requestFields = fields || FOLDER_FIELDS_TO_FETCH ;
205+
195206 this . errorCode = ERROR_CODE_SEARCH ;
196207 return this . xhr
197208 . get ( {
@@ -201,8 +212,13 @@ class Search extends Base {
201212 query : this . query ,
202213 ancestor_folder_ids : this . id ,
203214 limit : this . limit ,
204- fields : FOLDER_FIELDS_TO_FETCH . toString ( ) ,
215+ fields : requestFields . toString ( ) ,
205216 } ,
217+ headers : requestFields . includes ( FIELD_REPRESENTATIONS )
218+ ? {
219+ 'X-Rep-Hints' : X_REP_HINT_HEADER_DIMENSIONS_DEFAULT ,
220+ }
221+ : { } ,
206222 } )
207223 . then ( this . searchSuccessHandler )
208224 . catch ( this . searchErrorHandler ) ;
@@ -254,7 +270,7 @@ class Search extends Base {
254270 }
255271
256272 // Make the XHR request
257- this . searchRequest ( ) ;
273+ this . searchRequest ( options ) ;
258274 }
259275}
260276
0 commit comments