@adminforth/dashboard 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,7 +117,8 @@ export type QueryOrderByItem = {
117
117
  direction?: 'asc' | 'desc'
118
118
  }
119
119
 
120
- export type QueryConfig = {
120
+ export type ResourceQueryConfig = {
121
+ source?: 'resource'
121
122
  resource: string
122
123
  select?: QuerySelectItem[]
123
124
  sparkline?: {
@@ -139,17 +140,31 @@ export type QueryConfig = {
139
140
  formatting?: Record<string, JsonValue>
140
141
  }
141
142
 
142
- export type FunnelQueryConfig = {
143
- steps: FunnelQueryStep[]
143
+ export type StepsQueryStepConfig =
144
+ | {
145
+ name: string
146
+ resource: string
147
+ metric: QueryAggregateSelectItem
148
+ filters?: FilterExpression
149
+ }
150
+ | {
151
+ name: string
152
+ resource: string
153
+ select: QueryAggregateSelectItem[]
154
+ filters?: FilterExpression
155
+ }
156
+
157
+ export type StepsQueryConfig = {
158
+ source: 'steps'
159
+ steps: StepsQueryStepConfig[]
144
160
  calcs?: QueryCalcSelectItem[]
161
+ order_by?: QueryOrderByItem[]
162
+ limit?: number
163
+ offset?: number
164
+ formatting?: Record<string, JsonValue>
145
165
  }
146
166
 
147
- export type FunnelQueryStep = {
148
- name: string
149
- resource: string
150
- metric: QueryAggregateSelectItem
151
- filters?: FilterExpression
152
- }
167
+ export type QueryConfig = ResourceQueryConfig | StepsQueryConfig
153
168
 
154
169
  export type FieldRef = string | {
155
170
  field: string
@@ -246,7 +261,7 @@ export type TableWidgetConfig = WidgetBaseConfig & {
246
261
  export type ChartDashboardWidgetConfig = WidgetBaseConfig & {
247
262
  target: 'chart'
248
263
  chart: ChartWidgetConfig
249
- query: QueryConfig | FunnelQueryConfig
264
+ query: QueryConfig
250
265
  }
251
266
 
252
267
  export type KpiCardWidgetConfig = WidgetBaseConfig & {
@@ -151,8 +151,8 @@ Use resource, not resourceId.
151
151
 
152
152
  ## Query shape rules
153
153
 
154
- Use dashboard_configure_funnel_chart_widget for funnel charts and set query.steps.
155
- Do not use query.steps for kpi_card, gauge_card, table, pivot_table, line, bar, stacked bar, pie, or histogram charts.
154
+ All chart widgets, including funnel charts, use the same query shape.
155
+ Use a single-resource query by default.
156
156
 
157
157
  For kpi_card and normal charts, use:
158
158
  - query.resource
@@ -162,6 +162,29 @@ For kpi_card and normal charts, use:
162
162
  - optional query.order_by
163
163
  - optional query.calcs
164
164
 
165
+ For multi-resource charts or widgets, use the general steps source:
166
+
167
+ query:
168
+ source: steps
169
+ steps:
170
+ - name: Leads
171
+ resource: leads
172
+ metric:
173
+ agg: count
174
+ as: value
175
+ - name: Customers
176
+ resource: orders
177
+ metric:
178
+ agg: count_distinct
179
+ field: customer_id
180
+ as: value
181
+
182
+ Each step may use either:
183
+ - metric for one aggregate
184
+ - select for multiple aggregate fields
185
+
186
+ Do not use bare query.steps without source: steps.
187
+
165
188
  ## Date range rules
166
189
 
167
190
  Use only query.filters for time ranges.
@@ -203,7 +226,7 @@ select raw token totals:
203
226
  then query.calcs:
204
227
  - calculate total_spend from those aliases and lookup variables
205
228
 
206
- For today vs yesterday KPI, use multiple aggregate select items with filters and distinct aliases, then calcs. Do not use query.steps.
229
+ For today vs yesterday KPI, use multiple aggregate select items with filters and distinct aliases, then calcs.
207
230
 
208
231
  ## Calc variables
209
232
 
@@ -87,7 +87,8 @@ export type QueryOrderByItem = {
87
87
  field: string;
88
88
  direction?: 'asc' | 'desc';
89
89
  };
90
- export type QueryConfig = {
90
+ export type ResourceQueryConfig = {
91
+ source?: 'resource';
91
92
  resource: string;
92
93
  select?: QuerySelectItem[];
93
94
  sparkline?: {
@@ -112,16 +113,27 @@ export type QueryConfig = {
112
113
  calcs?: QueryCalcSelectItem[];
113
114
  formatting?: Record<string, JsonValue>;
114
115
  };
115
- export type FunnelQueryConfig = {
116
- steps: FunnelQueryStep[];
117
- calcs?: QueryCalcSelectItem[];
118
- };
119
- export type FunnelQueryStep = {
116
+ export type StepsQueryStepConfig = {
120
117
  name: string;
121
118
  resource: string;
122
119
  metric: QueryAggregateSelectItem;
123
120
  filters?: FilterExpression;
121
+ } | {
122
+ name: string;
123
+ resource: string;
124
+ select: QueryAggregateSelectItem[];
125
+ filters?: FilterExpression;
124
126
  };
127
+ export type StepsQueryConfig = {
128
+ source: 'steps';
129
+ steps: StepsQueryStepConfig[];
130
+ calcs?: QueryCalcSelectItem[];
131
+ order_by?: QueryOrderByItem[];
132
+ limit?: number;
133
+ offset?: number;
134
+ formatting?: Record<string, JsonValue>;
135
+ };
136
+ export type QueryConfig = ResourceQueryConfig | StepsQueryConfig;
125
137
  export type FieldRef = string | {
126
138
  field: string;
127
139
  label?: string;
@@ -210,7 +222,7 @@ export type TableWidgetConfig = WidgetBaseConfig & {
210
222
  export type ChartDashboardWidgetConfig = WidgetBaseConfig & {
211
223
  target: 'chart';
212
224
  chart: ChartWidgetConfig;
213
- query: QueryConfig | FunnelQueryConfig;
225
+ query: QueryConfig;
214
226
  };
215
227
  export type KpiCardWidgetConfig = WidgetBaseConfig & {
216
228
  target: 'kpi_card';
@@ -117,7 +117,8 @@ export type QueryOrderByItem = {
117
117
  direction?: 'asc' | 'desc'
118
118
  }
119
119
 
120
- export type QueryConfig = {
120
+ export type ResourceQueryConfig = {
121
+ source?: 'resource'
121
122
  resource: string
122
123
  select?: QuerySelectItem[]
123
124
  sparkline?: {
@@ -139,17 +140,31 @@ export type QueryConfig = {
139
140
  formatting?: Record<string, JsonValue>
140
141
  }
141
142
 
142
- export type FunnelQueryConfig = {
143
- steps: FunnelQueryStep[]
143
+ export type StepsQueryStepConfig =
144
+ | {
145
+ name: string
146
+ resource: string
147
+ metric: QueryAggregateSelectItem
148
+ filters?: FilterExpression
149
+ }
150
+ | {
151
+ name: string
152
+ resource: string
153
+ select: QueryAggregateSelectItem[]
154
+ filters?: FilterExpression
155
+ }
156
+
157
+ export type StepsQueryConfig = {
158
+ source: 'steps'
159
+ steps: StepsQueryStepConfig[]
144
160
  calcs?: QueryCalcSelectItem[]
161
+ order_by?: QueryOrderByItem[]
162
+ limit?: number
163
+ offset?: number
164
+ formatting?: Record<string, JsonValue>
145
165
  }
146
166
 
147
- export type FunnelQueryStep = {
148
- name: string
149
- resource: string
150
- metric: QueryAggregateSelectItem
151
- filters?: FilterExpression
152
- }
167
+ export type QueryConfig = ResourceQueryConfig | StepsQueryConfig
153
168
 
154
169
  export type FieldRef = string | {
155
170
  field: string
@@ -246,7 +261,7 @@ export type TableWidgetConfig = WidgetBaseConfig & {
246
261
  export type ChartDashboardWidgetConfig = WidgetBaseConfig & {
247
262
  target: 'chart'
248
263
  chart: ChartWidgetConfig
249
- query: QueryConfig | FunnelQueryConfig
264
+ query: QueryConfig
250
265
  }
251
266
 
252
267
  export type KpiCardWidgetConfig = WidgetBaseConfig & {