@@ -146,20 +146,34 @@ const normalizeQueryOrder = order => {
146146 return result ;
147147} ;
148148
149- export const preAggsJobsRequestSchema = Joi . object ( ) . keys ( {
149+ export const preAggsJobsRequestSchema = Joi . object ( {
150150 action : Joi . string ( ) . valid ( 'post' , 'get' ) . required ( ) ,
151- selector : Joi . object ( ) . keys ( {
152- contexts : Joi . array ( ) . items (
153- Joi . object ( ) . keys ( {
154- securityContext : Joi . required ( ) ,
155- } )
156- ) . min ( 1 ) . required ( ) ,
157- timezones : Joi . array ( ) . items ( Joi . string ( ) ) . min ( 1 ) . required ( ) ,
158- dataSources : Joi . array ( ) . items ( Joi . string ( ) ) ,
159- cubes : Joi . array ( ) . items ( Joi . string ( ) ) ,
160- preAggregations : Joi . array ( ) . items ( Joi . string ( ) ) ,
161- dateRange : Joi . array ( ) . length ( 2 ) . items ( Joi . string ( ) ) ,
162- } ) . optional ( ) ,
151+ selector : Joi . when ( 'action' , {
152+ is : 'post' ,
153+ then : Joi . object ( {
154+ contexts : Joi . array ( ) . items (
155+ Joi . object ( {
156+ securityContext : Joi . required ( ) ,
157+ } )
158+ ) . min ( 1 ) . required ( ) ,
159+ timezones : Joi . array ( ) . items ( Joi . string ( ) ) . min ( 1 ) . required ( ) ,
160+ dataSources : Joi . array ( ) . items ( Joi . string ( ) ) ,
161+ cubes : Joi . array ( ) . items ( Joi . string ( ) ) ,
162+ preAggregations : Joi . array ( ) . items ( Joi . string ( ) ) ,
163+ dateRange : Joi . array ( ) . length ( 2 ) . items ( Joi . string ( ) ) ,
164+ } ) . optional ( ) ,
165+ otherwise : Joi . forbidden ( ) ,
166+ } ) ,
167+ tokens : Joi . when ( 'action' , {
168+ is : 'get' ,
169+ then : Joi . array ( ) . items ( Joi . string ( ) ) . min ( 1 ) . required ( ) ,
170+ otherwise : Joi . forbidden ( ) ,
171+ } ) ,
172+ resType : Joi . when ( 'action' , {
173+ is : 'get' ,
174+ then : Joi . string ( ) . valid ( 'object' ) . optional ( ) ,
175+ otherwise : Joi . forbidden ( ) ,
176+ } ) ,
163177} ) ;
164178
165179const DateRegex = / ^ \d \d \d \d - \d \d - \d \d $ / ;
0 commit comments