33 SaveObjectResponse ,
44 SetSettingsResponse ,
55} from '@algolia/client-search' ;
6+ import { WaitablePromise } from '@algolia/client-common' ;
67import algoliasearch from 'algoliasearch' ;
78
89import clone from 'lib/utils/clone' ;
@@ -15,28 +16,26 @@ export const client = algoliasearch(algoliaId, algoliaKey);
1516export function updateFilterableAttrs (
1617 indexId : string ,
1718 attrs : string [ ]
18- ) : Promise < SetSettingsResponse > {
19+ ) : WaitablePromise < SetSettingsResponse > {
1920 const idx = client . initIndex ( `${ process . env . APP_ENV as string } -${ indexId } ` ) ;
2021 const attributesForFaceting = attrs . map ( ( attr ) => `filterOnly(${ attr } )` ) ;
21- return ( idx . setSettings ( { attributesForFaceting } ) as unknown ) as Promise <
22- SetSettingsResponse
23- > ;
22+ return idx . setSettings ( { attributesForFaceting } ) ;
2423}
2524
2625export function deleteObj (
2726 indexId : string ,
2827 objId : string
29- ) : Promise < DeleteResponse > {
28+ ) : WaitablePromise < DeleteResponse > {
3029 const idx = client . initIndex ( `${ process . env . APP_ENV as string } -${ indexId } ` ) ;
31- return ( idx . deleteObject ( objId ) as unknown ) as Promise < DeleteResponse > ;
30+ return idx . deleteObject ( objId ) ;
3231}
3332
3433export default function index < T extends { toSearchHit : ( ) => object } > (
3534 indexId : string ,
3635 obj : T ,
3736 tags ?: string [ ]
38- ) : Promise < SaveObjectResponse > {
37+ ) : WaitablePromise < SaveObjectResponse > {
3938 const idx = client . initIndex ( `${ process . env . APP_ENV as string } -${ indexId } ` ) ;
4039 const idxObj = clone ( { ...obj . toSearchHit ( ) , _tags : tags } ) ;
41- return ( idx . saveObject ( idxObj ) as unknown ) as Promise < SaveObjectResponse > ;
40+ return idx . saveObject ( idxObj ) ;
4241}
0 commit comments