@lightdash/common 0.2191.1 → 0.2192.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.
@@ -4,6 +4,7 @@
4
4
  "title": "Lightdash Chart as Code",
5
5
  "description": "Schema for defining Lightdash charts in YAML format for version control",
6
6
  "type": "object",
7
+ "additionalProperties": false,
7
8
  "required": [
8
9
  "name",
9
10
  "tableName",
@@ -30,7 +31,7 @@
30
31
  "slug": {
31
32
  "type": "string",
32
33
  "description": "Unique identifier slug for this chart",
33
- "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
34
+ "pattern": "^[a-z0-9-]+$"
34
35
  },
35
36
  "spaceSlug": {
36
37
  "type": "string",
@@ -43,7 +44,7 @@
43
44
  "dashboardSlug": {
44
45
  "type": ["string", "null"],
45
46
  "description": "Optional dashboard slug if this chart is saved within a dashboard",
46
- "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
47
+ "pattern": "^[a-z0-9-]+$"
47
48
  },
48
49
  "updatedAt": {
49
50
  "type": "string",
@@ -58,6 +59,7 @@
58
59
  "metricQuery": {
59
60
  "type": "object",
60
61
  "description": "The query configuration defining what data to fetch",
62
+ "additionalProperties": false,
61
63
  "required": ["exploreName"],
62
64
  "properties": {
63
65
  "exploreName": {
@@ -81,96 +83,178 @@
81
83
  "filters": {
82
84
  "type": "object",
83
85
  "description": "Filter rules to apply to the query using 'and'/'or' filter groups",
86
+ "additionalProperties": false,
84
87
  "properties": {
85
88
  "dimensions": {
86
- "type": "object",
87
- "description": "Dimension filter group",
88
- "properties": {
89
- "and": {
89
+ "oneOf": [
90
+ {
90
91
  "type": "array",
91
- "description": "Array of filters combined with AND logic",
92
- "items": {
93
- "type": "object",
94
- "required": ["target", "operator"],
95
- "properties": {
96
- "target": {
92
+ "description": "Empty dimensions filter array (no filters applied)",
93
+ "maxItems": 0
94
+ },
95
+ {
96
+ "type": "object",
97
+ "description": "Dimension filter group",
98
+ "additionalProperties": false,
99
+ "properties": {
100
+ "id": {
101
+ "type": "string",
102
+ "description": "Optional unique identifier for the filter group"
103
+ },
104
+ "and": {
105
+ "type": "array",
106
+ "description": "Array of filters combined with AND logic",
107
+ "items": {
97
108
  "type": "object",
98
- "required": ["fieldId"],
109
+ "additionalProperties": false,
110
+ "required": [
111
+ "target",
112
+ "operator"
113
+ ],
99
114
  "properties": {
100
- "fieldId": {
115
+ "id": {
116
+ "type": "string",
117
+ "description": "Optional unique identifier for the filter"
118
+ },
119
+ "target": {
120
+ "type": "object",
121
+ "additionalProperties": false,
122
+ "required": ["fieldId"],
123
+ "properties": {
124
+ "fieldId": {
125
+ "type": "string",
126
+ "description": "Field ID to filter on"
127
+ },
128
+ "fieldFilterType": {
129
+ "type": "string",
130
+ "description": "Filter type hint (e.g., 'date' for date fields)"
131
+ }
132
+ }
133
+ },
134
+ "operator": {
101
135
  "type": "string",
102
- "description": "Field ID to filter on"
136
+ "description": "Filter operator",
137
+ "enum": [
138
+ "equals",
139
+ "notEquals",
140
+ "isNull",
141
+ "notNull",
142
+ "startsWith",
143
+ "endsWith",
144
+ "include",
145
+ "doesNotInclude",
146
+ "lessThan",
147
+ "lessThanOrEqual",
148
+ "greaterThan",
149
+ "greaterThanOrEqual",
150
+ "inThePast",
151
+ "notInThePast",
152
+ "inTheNext",
153
+ "inTheCurrent",
154
+ "notInTheCurrent",
155
+ "inBetween",
156
+ "notInBetween"
157
+ ]
158
+ },
159
+ "values": {
160
+ "type": "array",
161
+ "description": "Values to filter by"
162
+ },
163
+ "required": {
164
+ "type": "boolean",
165
+ "description": "Whether this filter is required"
166
+ },
167
+ "settings": {
168
+ "type": "object",
169
+ "description": "Additional settings for date/time filters",
170
+ "additionalProperties": false,
171
+ "properties": {
172
+ "unitOfTime": {
173
+ "type": "string",
174
+ "enum": [
175
+ "milliseconds",
176
+ "seconds",
177
+ "minutes",
178
+ "hours",
179
+ "days",
180
+ "weeks",
181
+ "months",
182
+ "quarters",
183
+ "years"
184
+ ],
185
+ "description": "Time unit for relative date filters"
186
+ },
187
+ "completed": {
188
+ "type": "boolean",
189
+ "description": "For date filters, whether to include completed periods"
190
+ }
191
+ }
103
192
  }
104
193
  }
105
- },
106
- "operator": {
107
- "type": "string",
108
- "description": "Filter operator",
109
- "enum": [
110
- "equals",
111
- "notEquals",
112
- "isNull",
113
- "notNull",
114
- "startsWith",
115
- "endsWith",
116
- "include",
117
- "doesNotInclude",
118
- "lessThan",
119
- "lessThanOrEqual",
120
- "greaterThan",
121
- "greaterThanOrEqual",
122
- "inThePast",
123
- "notInThePast",
124
- "inTheNext",
125
- "inTheCurrent",
126
- "notInTheCurrent",
127
- "inBetween",
128
- "notInBetween"
129
- ]
130
- },
131
- "values": {
132
- "type": "array",
133
- "description": "Values to filter by"
134
- },
135
- "required": {
136
- "type": "boolean",
137
- "description": "Whether this filter is required"
194
+ }
195
+ },
196
+ "or": {
197
+ "type": "array",
198
+ "description": "Array of filters combined with OR logic",
199
+ "items": {
200
+ "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/oneOf/1/properties/and/items"
138
201
  }
139
202
  }
140
203
  }
141
- },
142
- "or": {
143
- "type": "array",
144
- "description": "Array of filters combined with OR logic",
145
- "items": {
146
- "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/properties/and/items"
147
- }
148
204
  }
149
- }
205
+ ]
150
206
  },
151
207
  "metrics": {
152
- "type": "object",
153
- "description": "Metric filter group",
154
- "properties": {
155
- "and": {
156
- "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/properties/and"
208
+ "oneOf": [
209
+ {
210
+ "type": "array",
211
+ "description": "Empty metrics filter array (no filters applied)",
212
+ "maxItems": 0
157
213
  },
158
- "or": {
159
- "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/properties/or"
214
+ {
215
+ "type": "object",
216
+ "description": "Metric filter group",
217
+ "additionalProperties": false,
218
+ "properties": {
219
+ "id": {
220
+ "type": "string",
221
+ "description": "Optional unique identifier for the filter group"
222
+ },
223
+ "and": {
224
+ "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/oneOf/1/properties/and"
225
+ },
226
+ "or": {
227
+ "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/oneOf/1/properties/or"
228
+ }
229
+ }
160
230
  }
161
- }
231
+ ]
162
232
  },
163
233
  "tableCalculations": {
164
- "type": "object",
165
- "description": "Table calculation filter group",
166
- "properties": {
167
- "and": {
168
- "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/properties/and"
234
+ "oneOf": [
235
+ {
236
+ "type": "array",
237
+ "description": "Empty table calculations filter array (no filters applied)",
238
+ "maxItems": 0
169
239
  },
170
- "or": {
171
- "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/properties/or"
240
+ {
241
+ "type": "object",
242
+ "description": "Table calculation filter group",
243
+ "additionalProperties": false,
244
+ "properties": {
245
+ "id": {
246
+ "type": "string",
247
+ "description": "Optional unique identifier for the filter group"
248
+ },
249
+ "and": {
250
+ "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/oneOf/1/properties/and"
251
+ },
252
+ "or": {
253
+ "$ref": "#/properties/metricQuery/properties/filters/properties/dimensions/oneOf/1/properties/or"
254
+ }
255
+ }
172
256
  }
173
- }
257
+ ]
174
258
  }
175
259
  }
176
260
  },
@@ -179,6 +263,7 @@
179
263
  "description": "Sort configuration for query results",
180
264
  "items": {
181
265
  "type": "object",
266
+ "additionalProperties": false,
182
267
  "required": ["fieldId", "descending"],
183
268
  "properties": {
184
269
  "fieldId": {
@@ -202,10 +287,12 @@
202
287
  "description": "Override formatting and display options for existing metrics",
203
288
  "additionalProperties": {
204
289
  "type": "object",
290
+ "additionalProperties": false,
205
291
  "properties": {
206
292
  "formatOptions": {
207
293
  "type": "object",
208
294
  "description": "Formatting configuration for the metric",
295
+ "additionalProperties": false,
209
296
  "properties": {
210
297
  "type": {
211
298
  "type": "string",
@@ -235,8 +322,56 @@
235
322
  "spaceComma"
236
323
  ],
237
324
  "description": "Thousands separator style"
325
+ },
326
+ "suffix": {
327
+ "type": "string",
328
+ "description": "Suffix to append to formatted values"
329
+ },
330
+ "prefix": {
331
+ "type": "string",
332
+ "description": "Prefix to prepend to formatted values"
333
+ },
334
+ "compact": {
335
+ "type": "string",
336
+ "enum": [
337
+ "thousands",
338
+ "millions",
339
+ "billions",
340
+ "trillions",
341
+ "kilobytes",
342
+ "megabytes",
343
+ "gigabytes",
344
+ "terabytes",
345
+ "petabytes",
346
+ "kibibytes",
347
+ "mebibytes",
348
+ "gibibytes",
349
+ "tebibytes",
350
+ "pebibytes"
351
+ ],
352
+ "description": "Compact format for large numbers (K, M, B, T) or byte units"
238
353
  }
239
354
  }
355
+ },
356
+ "round": {
357
+ "type": "number",
358
+ "description": "Number of decimal places (shorthand for formatOptions.round)"
359
+ },
360
+ "format": {
361
+ "type": "string",
362
+ "description": "Format string (legacy format specification)"
363
+ },
364
+ "label": {
365
+ "type": "string",
366
+ "description": "Custom label for the metric"
367
+ },
368
+ "description": {
369
+ "type": "string",
370
+ "description": "Custom description for the metric"
371
+ },
372
+ "uuid": {
373
+ "type": "string",
374
+ "description": "UUID of the metric override"
240
375
  }
241
376
  }
242
377
  }
@@ -246,7 +381,18 @@
246
381
  "description": "Custom calculations to perform on query results (like window functions)",
247
382
  "items": {
248
383
  "type": "object",
249
- "required": ["name", "displayName", "sql"],
384
+ "additionalProperties": false,
385
+ "required": ["name", "displayName"],
386
+ "oneOf": [
387
+ {
388
+ "required": ["sql"],
389
+ "not": { "required": ["template"] }
390
+ },
391
+ {
392
+ "required": ["template"],
393
+ "not": { "required": ["sql"] }
394
+ }
395
+ ],
250
396
  "properties": {
251
397
  "name": {
252
398
  "type": "string",
@@ -268,6 +414,7 @@
268
414
  "format": {
269
415
  "type": "object",
270
416
  "description": "Formatting options for the calculation",
417
+ "additionalProperties": false,
271
418
  "properties": {
272
419
  "type": {
273
420
  "type": "string",
@@ -296,6 +443,135 @@
296
443
  "periodComma",
297
444
  "spaceComma"
298
445
  ]
446
+ },
447
+ "suffix": {
448
+ "type": "string",
449
+ "description": "Suffix to append to formatted values"
450
+ },
451
+ "prefix": {
452
+ "type": "string",
453
+ "description": "Prefix to prepend to formatted values"
454
+ },
455
+ "compact": {
456
+ "type": "string",
457
+ "enum": [
458
+ "thousands",
459
+ "millions",
460
+ "billions",
461
+ "trillions",
462
+ "kilobytes",
463
+ "megabytes",
464
+ "gigabytes",
465
+ "terabytes",
466
+ "petabytes",
467
+ "kibibytes",
468
+ "mebibytes",
469
+ "gibibytes",
470
+ "tebibytes",
471
+ "pebibytes"
472
+ ],
473
+ "description": "Compact format for large numbers (K, M, B, T) or byte units"
474
+ }
475
+ }
476
+ },
477
+ "template": {
478
+ "type": "object",
479
+ "description": "Template-based calculation (alternative to sql)",
480
+ "additionalProperties": false,
481
+ "required": ["type"],
482
+ "properties": {
483
+ "type": {
484
+ "type": "string",
485
+ "enum": [
486
+ "percent_change_from_previous",
487
+ "percent_of_previous_value",
488
+ "percent_of_column_total",
489
+ "rank_in_column",
490
+ "running_total",
491
+ "window_function"
492
+ ],
493
+ "description": "Type of template calculation"
494
+ },
495
+ "fieldId": {
496
+ "type": ["string", "null"],
497
+ "description": "Field ID to apply the template to"
498
+ },
499
+ "orderBy": {
500
+ "type": "array",
501
+ "description": "Fields to order by for window functions",
502
+ "items": {
503
+ "type": "object",
504
+ "additionalProperties": false,
505
+ "required": ["fieldId"],
506
+ "properties": {
507
+ "fieldId": {
508
+ "type": "string",
509
+ "description": "Field ID to order by"
510
+ },
511
+ "order": {
512
+ "type": ["string", "null"],
513
+ "enum": [
514
+ "asc",
515
+ "desc",
516
+ null
517
+ ],
518
+ "description": "Sort direction"
519
+ }
520
+ }
521
+ }
522
+ },
523
+ "partitionBy": {
524
+ "type": "array",
525
+ "description": "Fields to partition by for window functions",
526
+ "items": {
527
+ "type": "string"
528
+ }
529
+ },
530
+ "windowFunction": {
531
+ "type": "string",
532
+ "description": "Window function type (for window_function template)"
533
+ },
534
+ "frame": {
535
+ "type": "object",
536
+ "description": "Frame clause for window functions",
537
+ "additionalProperties": false,
538
+ "properties": {
539
+ "frameType": {
540
+ "type": "string",
541
+ "description": "Type of frame (ROWS or RANGE)"
542
+ },
543
+ "start": {
544
+ "type": "object",
545
+ "description": "Start boundary of the frame",
546
+ "additionalProperties": false,
547
+ "properties": {
548
+ "type": {
549
+ "type": "string",
550
+ "description": "Boundary type"
551
+ },
552
+ "offset": {
553
+ "type": "number",
554
+ "description": "Offset for PRECEDING/FOLLOWING"
555
+ }
556
+ }
557
+ },
558
+ "end": {
559
+ "type": "object",
560
+ "description": "End boundary of the frame",
561
+ "additionalProperties": false,
562
+ "required": ["type"],
563
+ "properties": {
564
+ "type": {
565
+ "type": "string",
566
+ "description": "Boundary type"
567
+ },
568
+ "offset": {
569
+ "type": "number",
570
+ "description": "Offset for PRECEDING/FOLLOWING"
571
+ }
572
+ }
573
+ }
574
+ }
299
575
  }
300
576
  }
301
577
  }
@@ -307,6 +583,7 @@
307
583
  "description": "Custom metrics defined inline (ad-hoc metrics not in the dbt model)",
308
584
  "items": {
309
585
  "type": "object",
586
+ "additionalProperties": false,
310
587
  "required": ["name", "label", "sql", "table", "type"],
311
588
  "properties": {
312
589
  "name": {
@@ -345,9 +622,107 @@
345
622
  "type": "string",
346
623
  "description": "Name of the base dimension/column this metric aggregates"
347
624
  },
625
+ "uuid": {
626
+ "type": ["string", "null"],
627
+ "description": "Unique identifier for the metric (readonly)"
628
+ },
629
+ "hidden": {
630
+ "type": "boolean",
631
+ "description": "Whether the metric is hidden from users"
632
+ },
633
+ "percentile": {
634
+ "type": "number",
635
+ "description": "Percentile value for percentile metrics"
636
+ },
637
+ "index": {
638
+ "type": "number",
639
+ "description": "Display order index"
640
+ },
641
+ "filters": {
642
+ "type": "array",
643
+ "description": "Filters to apply to this metric",
644
+ "items": {
645
+ "type": "object",
646
+ "additionalProperties": false,
647
+ "required": ["target", "operator"],
648
+ "properties": {
649
+ "id": {
650
+ "type": "string",
651
+ "description": "Optional unique identifier for the filter"
652
+ },
653
+ "target": {
654
+ "type": "object",
655
+ "additionalProperties": false,
656
+ "required": ["fieldRef"],
657
+ "properties": {
658
+ "fieldRef": {
659
+ "type": "string",
660
+ "description": "Field reference to filter on (e.g., 'table_name.field_name')"
661
+ }
662
+ }
663
+ },
664
+ "operator": {
665
+ "type": "string",
666
+ "description": "Filter operator",
667
+ "enum": [
668
+ "equals",
669
+ "notEquals",
670
+ "isNull",
671
+ "notNull",
672
+ "startsWith",
673
+ "endsWith",
674
+ "include",
675
+ "doesNotInclude",
676
+ "lessThan",
677
+ "lessThanOrEqual",
678
+ "greaterThan",
679
+ "greaterThanOrEqual",
680
+ "inThePast",
681
+ "notInThePast",
682
+ "inTheNext",
683
+ "inTheCurrent",
684
+ "notInTheCurrent",
685
+ "inBetween",
686
+ "notInBetween"
687
+ ]
688
+ },
689
+ "values": {
690
+ "type": "array",
691
+ "description": "Values to filter by"
692
+ },
693
+ "settings": {
694
+ "type": "object",
695
+ "description": "Additional settings for date/time filters",
696
+ "additionalProperties": false,
697
+ "properties": {
698
+ "unitOfTime": {
699
+ "type": "string",
700
+ "enum": [
701
+ "milliseconds",
702
+ "seconds",
703
+ "minutes",
704
+ "hours",
705
+ "days",
706
+ "weeks",
707
+ "months",
708
+ "quarters",
709
+ "years"
710
+ ],
711
+ "description": "Time unit for relative date filters"
712
+ },
713
+ "completed": {
714
+ "type": "boolean",
715
+ "description": "For date filters, whether to include completed periods"
716
+ }
717
+ }
718
+ }
719
+ }
720
+ }
721
+ },
348
722
  "formatOptions": {
349
723
  "type": "object",
350
724
  "description": "Formatting configuration",
725
+ "additionalProperties": false,
351
726
  "properties": {
352
727
  "type": {
353
728
  "type": "string",
@@ -358,6 +733,14 @@
358
733
  "percent"
359
734
  ]
360
735
  },
736
+ "round": {
737
+ "type": "number",
738
+ "description": "Number of decimal places"
739
+ },
740
+ "currency": {
741
+ "type": "string",
742
+ "description": "Currency code (e.g., USD, GBP, EUR)"
743
+ },
361
744
  "separator": {
362
745
  "type": "string",
363
746
  "enum": [
@@ -367,6 +750,34 @@
367
750
  "periodComma",
368
751
  "spaceComma"
369
752
  ]
753
+ },
754
+ "suffix": {
755
+ "type": "string",
756
+ "description": "Suffix to append to formatted values"
757
+ },
758
+ "prefix": {
759
+ "type": "string",
760
+ "description": "Prefix to prepend to formatted values"
761
+ },
762
+ "compact": {
763
+ "type": "string",
764
+ "enum": [
765
+ "thousands",
766
+ "millions",
767
+ "billions",
768
+ "trillions",
769
+ "kilobytes",
770
+ "megabytes",
771
+ "gigabytes",
772
+ "terabytes",
773
+ "petabytes",
774
+ "kibibytes",
775
+ "mebibytes",
776
+ "gibibytes",
777
+ "tebibytes",
778
+ "pebibytes"
779
+ ],
780
+ "description": "Compact format for large numbers (K, M, B, T) or byte units"
370
781
  }
371
782
  }
372
783
  }
@@ -385,6 +796,7 @@
385
796
  "chartConfig": {
386
797
  "type": "object",
387
798
  "description": "Visualization configuration for the chart",
799
+ "additionalProperties": false,
388
800
  "required": ["type"],
389
801
  "properties": {
390
802
  "type": {
@@ -401,7 +813,7 @@
401
813
  ]
402
814
  },
403
815
  "config": {
404
- "type": "object",
816
+ "type": ["object", "null"],
405
817
  "description": "Chart-specific configuration (varies by chart type)"
406
818
  }
407
819
  }
@@ -409,6 +821,7 @@
409
821
  "tableConfig": {
410
822
  "type": "object",
411
823
  "description": "Table view configuration",
824
+ "additionalProperties": false,
412
825
  "properties": {
413
826
  "columnOrder": {
414
827
  "type": "array",
@@ -422,6 +835,7 @@
422
835
  "pivotConfig": {
423
836
  "type": "object",
424
837
  "description": "Pivot table configuration",
838
+ "additionalProperties": false,
425
839
  "properties": {
426
840
  "columns": {
427
841
  "type": "array",