@@ -140,7 +140,8 @@ export const QueryCalcItemSchema = z.object({
140140 as : z . string ( ) ,
141141} ) . strict ( )
142142
143- export const QueryConfigSchema = z . object ( {
143+ const ResourceQueryConfigSchema = z . object ( {
144+ source : z . literal ( 'resource' ) . optional ( ) ,
144145 resource : z . string ( ) ,
145146 select : z . array ( QuerySelectItemSchema ) . optional ( ) ,
146147 sparkline : z . object ( {
@@ -159,18 +160,36 @@ export const QueryConfigSchema = z.object({
159160 formatting : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
160161} ) . strict ( )
161162
162- const FunnelQueryStepSchema = z . object ( {
163+ const StepsQueryMetricStepSchema = z . object ( {
163164 name : z . string ( ) ,
164165 resource : z . string ( ) ,
165166 metric : QueryAggregateSelectItemSchema ,
166167 filters : FilterExpressionSchema . optional ( ) ,
167168} ) . strict ( )
168169
169- export const FunnelQueryConfigSchema = z . object ( {
170- steps : z . array ( FunnelQueryStepSchema ) . min ( 1 ) ,
171- calcs : z . array ( QueryCalcItemSchema ) . optional ( ) ,
170+ const StepsQuerySelectStepSchema = z . object ( {
171+ name : z . string ( ) ,
172+ resource : z . string ( ) ,
173+ select : z . array ( QueryAggregateSelectItemSchema ) . min ( 1 ) ,
174+ filters : FilterExpressionSchema . optional ( ) ,
172175} ) . strict ( )
173176
177+ export const QueryConfigSchema = z . union ( [
178+ ResourceQueryConfigSchema ,
179+ z . object ( {
180+ source : z . literal ( 'steps' ) ,
181+ steps : z . array ( z . union ( [
182+ StepsQueryMetricStepSchema ,
183+ StepsQuerySelectStepSchema ,
184+ ] ) ) . min ( 1 ) ,
185+ calcs : z . array ( QueryCalcItemSchema ) . optional ( ) ,
186+ order_by : z . array ( QueryOrderByItemSchema ) . optional ( ) ,
187+ limit : z . number ( ) . int ( ) . positive ( ) . optional ( ) ,
188+ offset : z . number ( ) . int ( ) . nonnegative ( ) . optional ( ) ,
189+ formatting : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
190+ } ) . strict ( ) ,
191+ ] )
192+
174193export const WidgetPersistedFieldsSchema = z . object ( {
175194 id : z . string ( ) ,
176195 group_id : z . string ( ) ,
0 commit comments