@@ -79,7 +79,7 @@ const insertFilterFieldOpValue = (filter: Filter, object: any, key: string) => {
7979 * object with operator style understandable by chassis-srv for later to be used for
8080 * AQL conversion
8181 * @param object converted filter object
82- * @param originalKey operator value
82+ * @param operatorKey operator value
8383 * @param filter object containing field, operation, value and type
8484 * @returns object
8585 */
@@ -167,17 +167,19 @@ export const convertToObject = (input: any, obj?: any, currentOperator?: string)
167167 * @returns json object understandable by chassis-srv for AQL conversion
168168 */
169169export const toObject = ( input : ReadRequest ) => {
170- const filters = input . filters ?? [ ] ;
171- const result : Record < string , any > [ ] = filters . map (
172- filter => {
173- const obj = filter . filters . map ( ( sf ) => convertToObject ( sf , { } ) ) ;
174- const operatorValue = filter ?. operator ?? OperatorType . and ; // defaults to `and`
175- return {
176- [ `$${ operatorValue } ` ] : obj
177- } ;
178- }
179- ) ;
180-
170+ const filters = input ?. filters ?? [ ] ;
171+ const result : Record < string , any > [ ] = filters
172+ . filter ( filter => Array . isArray ( filter ?. filters ) && filter . filters . length > 0 )
173+ . map (
174+ filter => {
175+ const obj = filter . filters . map ( ( sf ) => convertToObject ( sf , { } ) ) ;
176+ const operatorValue = filter ?. operator ?? OperatorType . and ; // defaults to `and`
177+ return {
178+ [ `$${ operatorValue } ` ] : obj
179+ } ;
180+ }
181+ ) ;
182+
181183 return result . length === 1 ? result [ 0 ] : result ;
182184} ;
183185
0 commit comments