@@ -106,18 +106,26 @@ const querySchema = object({
106106 . default ( undefined )
107107 . noUnknown ( true )
108108 . strict ( ) ,
109- groupBy : object ( {
110- type : string ( ) . oneOf ( groupByTypes ) . min ( 1 ) . required ( ) ,
109+ groupBys : array ( )
110+ . of (
111+ object ( {
112+ type : string ( ) . oneOf ( groupByTypes ) . min ( 1 ) . required ( ) ,
113+ value : string ( ) . min ( 1 ) . required ( ) ,
114+ } )
115+ . noUnknown ( true )
116+ . strict ( ) ,
117+ )
118+ . optional ( ) ,
119+ orderBy : object ( {
111120 value : string ( ) . min ( 1 ) . required ( ) ,
112- orderBy : string ( ) . min ( 1 ) . optional ( ) ,
113- limit : number ( ) . min ( 1 ) . optional ( ) ,
114121 order : string ( ) . oneOf ( [ "ASC" , "DESC" ] ) . optional ( ) ,
115122 } )
116123 . nullable ( )
117124 . optional ( )
118125 . default ( undefined )
119126 . noUnknown ( true )
120127 . strict ( ) ,
128+ limit : number ( ) . min ( 1 ) . optional ( ) ,
121129 } )
122130 . noUnknown ( true )
123131 . required ( )
@@ -350,7 +358,7 @@ function validateQueries(queries: any[] = []) {
350358 const res = await querySchema . validate ( item ) ;
351359 const filters = res . properties . parameters . filters ;
352360 const calculations = res . properties . parameters . calculations ;
353- const groupBy = res . properties . parameters . groupBy ;
361+ const orderBy = res . properties . parameters . orderBy ;
354362
355363 filters ?. forEach ( ( filter ) => {
356364 parseFilter ( filter ) ;
@@ -364,8 +372,8 @@ function validateQueries(queries: any[] = []) {
364372 throw new Error ( "Aliases must me unique across all calculation / visualisation ." ) ;
365373 }
366374
367- if ( groupBy ?. orderBy && ! calcs ?. some ( ( c ) => getCalculationAlias ( c ) === groupBy ?. orderBy ) ) {
368- throw new Error ( "The orderBy field of the groupBy must be present in the calculations / visualisations." ) ;
375+ if ( orderBy ?. value && ! calcs ?. some ( ( c ) => getCalculationAlias ( c ) === orderBy ?. value ) ) {
376+ throw new Error ( "The orderBy must be present in the visualisations." ) ;
369377 }
370378 } catch ( error ) {
371379 const message = `query: ${ item . id } : ${ error } ` ;
0 commit comments