import { http } from '../http_service' ; import { basePath } from './index' ; import type { Filter , FilterStats } from '../../../../common/types/filters' ; export const filters = { filters ( obj ? ) { const filterId = obj && obj . filterId ? `/${ obj . filterId }` : '' ; return http < Filter [ ] > ( { path : `${ basePath ( ) }/filters${ filterId }` , method : 'GET' , } ) ; } , filtersStats ( ) { return http < FilterStats [ ] > ( { path : `${ basePath ( ) }/filters/_stats` , method : 'GET' , } ) ; } , addFilter ( filterId , description , items ) { const body = JSON . stringify ( { filterId , description , items , } ) ; return http < Filter > ( { path : `${ basePath ( ) }/filters` , method : 'PUT' , body , } ) ; } , updateFilter ( filterId , description , addItems , removeItems ) { const body = JSON . stringify ( { ... ( description !== undefined ? { description } : { } ) , ... ( addItems !== undefined ? { addItems } : { } ) , ... ( removeItems !== undefined ? { removeItems } : { } ) , } ) ; return http < Filter > ( { path : `${ basePath ( ) }/filters/${ filterId }` , method : 'PUT' , body , } ) ; } , deleteFilter ( filterId ) { return http < { acknowledged : boolean ; } > ( { path : `${ basePath ( ) }/filters/${ filterId }` , method : 'DELETE' , } ) ; } , } ;