@adminforth/dashboard 1.8.0 → 1.9.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.
@@ -85,17 +85,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
85
85
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
86
86
  } | {
87
87
  source: "steps";
88
- steps: ({
89
- name: string;
90
- resource: string;
91
- metric: {
92
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
93
- field?: string | undefined;
94
- as: string;
95
- filters?: any;
96
- };
97
- filters?: any;
98
- } | {
88
+ steps: {
99
89
  name: string;
100
90
  resource: string;
101
91
  select: {
@@ -105,7 +95,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
105
95
  filters?: any;
106
96
  }[];
107
97
  filters?: any;
108
- })[];
98
+ }[];
109
99
  calcs?: {
110
100
  calc: string;
111
101
  as: string;
@@ -220,17 +210,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
220
210
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
221
211
  } | {
222
212
  source: "steps";
223
- steps: ({
224
- name: string;
225
- resource: string;
226
- metric: {
227
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
228
- field?: string | undefined;
229
- as: string;
230
- filters?: any;
231
- };
232
- filters?: any;
233
- } | {
213
+ steps: {
234
214
  name: string;
235
215
  resource: string;
236
216
  select: {
@@ -240,7 +220,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
240
220
  filters?: any;
241
221
  }[];
242
222
  filters?: any;
243
- })[];
223
+ }[];
244
224
  calcs?: {
245
225
  calc: string;
246
226
  as: string;
@@ -351,17 +331,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
351
331
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
352
332
  } | {
353
333
  source: "steps";
354
- steps: ({
355
- name: string;
356
- resource: string;
357
- metric: {
358
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
359
- field?: string | undefined;
360
- as: string;
361
- filters?: any;
362
- };
363
- filters?: any;
364
- } | {
334
+ steps: {
365
335
  name: string;
366
336
  resource: string;
367
337
  select: {
@@ -371,7 +341,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
371
341
  filters?: any;
372
342
  }[];
373
343
  filters?: any;
374
- })[];
344
+ }[];
375
345
  calcs?: {
376
346
  calc: string;
377
347
  as: string;
@@ -467,17 +437,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
467
437
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
468
438
  } | {
469
439
  source: "steps";
470
- steps: ({
471
- name: string;
472
- resource: string;
473
- metric: {
474
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
475
- field?: string | undefined;
476
- as: string;
477
- filters?: any;
478
- };
479
- filters?: any;
480
- } | {
440
+ steps: {
481
441
  name: string;
482
442
  resource: string;
483
443
  select: {
@@ -487,7 +447,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
487
447
  filters?: any;
488
448
  }[];
489
449
  filters?: any;
490
- })[];
450
+ }[];
491
451
  calcs?: {
492
452
  calc: string;
493
453
  as: string;
@@ -580,17 +540,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
580
540
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
581
541
  } | {
582
542
  source: "steps";
583
- steps: ({
584
- name: string;
585
- resource: string;
586
- metric: {
587
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
588
- field?: string | undefined;
589
- as: string;
590
- filters?: any;
591
- };
592
- filters?: any;
593
- } | {
543
+ steps: {
594
544
  name: string;
595
545
  resource: string;
596
546
  select: {
@@ -600,7 +550,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
600
550
  filters?: any;
601
551
  }[];
602
552
  filters?: any;
603
- })[];
553
+ }[];
604
554
  calcs?: {
605
555
  calc: string;
606
556
  as: string;
@@ -699,17 +649,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
699
649
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
700
650
  } | {
701
651
  source: "steps";
702
- steps: ({
703
- name: string;
704
- resource: string;
705
- metric: {
706
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
707
- field?: string | undefined;
708
- as: string;
709
- filters?: any;
710
- };
711
- filters?: any;
712
- } | {
652
+ steps: {
713
653
  name: string;
714
654
  resource: string;
715
655
  select: {
@@ -719,7 +659,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
719
659
  filters?: any;
720
660
  }[];
721
661
  filters?: any;
722
- })[];
662
+ }[];
723
663
  calcs?: {
724
664
  calc: string;
725
665
  as: string;
@@ -834,17 +774,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
834
774
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
835
775
  } | {
836
776
  source: "steps";
837
- steps: ({
838
- name: string;
839
- resource: string;
840
- metric: {
841
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
842
- field?: string | undefined;
843
- as: string;
844
- filters?: any;
845
- };
846
- filters?: any;
847
- } | {
777
+ steps: {
848
778
  name: string;
849
779
  resource: string;
850
780
  select: {
@@ -854,7 +784,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
854
784
  filters?: any;
855
785
  }[];
856
786
  filters?: any;
857
- })[];
787
+ }[];
858
788
  calcs?: {
859
789
  calc: string;
860
790
  as: string;
@@ -965,17 +895,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
965
895
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
966
896
  } | {
967
897
  source: "steps";
968
- steps: ({
969
- name: string;
970
- resource: string;
971
- metric: {
972
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
973
- field?: string | undefined;
974
- as: string;
975
- filters?: any;
976
- };
977
- filters?: any;
978
- } | {
898
+ steps: {
979
899
  name: string;
980
900
  resource: string;
981
901
  select: {
@@ -985,7 +905,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
985
905
  filters?: any;
986
906
  }[];
987
907
  filters?: any;
988
- })[];
908
+ }[];
989
909
  calcs?: {
990
910
  calc: string;
991
911
  as: string;
@@ -1081,17 +1001,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
1081
1001
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
1082
1002
  } | {
1083
1003
  source: "steps";
1084
- steps: ({
1085
- name: string;
1086
- resource: string;
1087
- metric: {
1088
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
1089
- field?: string | undefined;
1090
- as: string;
1091
- filters?: any;
1092
- };
1093
- filters?: any;
1094
- } | {
1004
+ steps: {
1095
1005
  name: string;
1096
1006
  resource: string;
1097
1007
  select: {
@@ -1101,7 +1011,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
1101
1011
  filters?: any;
1102
1012
  }[];
1103
1013
  filters?: any;
1104
- })[];
1014
+ }[];
1105
1015
  calcs?: {
1106
1016
  calc: string;
1107
1017
  as: string;
@@ -1194,17 +1104,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
1194
1104
  formatting?: Record<string, import("../model/dashboard.types.js").JsonValue> | undefined;
1195
1105
  } | {
1196
1106
  source: "steps";
1197
- steps: ({
1198
- name: string;
1199
- resource: string;
1200
- metric: {
1201
- agg: import("../model/dashboard.types.js").QueryAggregateOperation;
1202
- field?: string | undefined;
1203
- as: string;
1204
- filters?: any;
1205
- };
1206
- filters?: any;
1207
- } | {
1107
+ steps: {
1208
1108
  name: string;
1209
1109
  resource: string;
1210
1110
  select: {
@@ -1214,7 +1114,7 @@ export declare function useWidgetData(slug: Ref<string>, widgetId: Ref<string>,
1214
1114
  filters?: any;
1215
1115
  }[];
1216
1116
  filters?: any;
1217
- })[];
1117
+ }[];
1218
1118
  calcs?: {
1219
1119
  calc: string;
1220
1120
  as: string;
@@ -169,21 +169,18 @@ query:
169
169
  steps:
170
170
  - name: Leads
171
171
  resource: leads
172
- metric:
173
- agg: count
174
- as: value
172
+ select:
173
+ - agg: count
174
+ as: value
175
175
  - name: Customers
176
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
177
+ select:
178
+ - agg: count_distinct
179
+ field: customer_id
180
+ as: value
185
181
 
186
182
  Do not use bare query.steps without source: steps.
183
+ Do not use metric. Use select even when a step has only one aggregate.
187
184
 
188
185
  ## Date range rules
189
186
 
@@ -224,22 +221,18 @@ select raw token totals:
224
221
  - sum output_tokens as output_tokens
225
222
 
226
223
  then query.calcs:
227
- - calculate total_spend from those aliases and lookup variables
224
+ - calculate total_spend from those aliases with explicit constants
228
225
 
229
226
  For today vs yesterday KPI, use multiple aggregate select items with filters and distinct aliases, then calcs.
230
227
 
231
- ## Calc variables
228
+ ## Calc rules
232
229
 
233
- Use variables for static maps/rates.
234
- Use lookup($variables.some.map, row_field, default_number) in query.calcs.
230
+ Calcs can reference only fields already present in the current row.
231
+ Use explicit constants for rates.
235
232
 
236
233
  Minimal example:
237
234
 
238
- variables:
239
- prices:
240
- gpt-5.4: 2.5
241
-
242
235
  query:
243
236
  calcs:
244
- - calc: tokens / 1000000 * lookup($variables.prices, model, 0)
237
+ - calc: tokens / 1000000 * 2.5
245
238
  as: cost