@lightdash/cli 1.85.1 → 1.86.1

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.
@@ -18,7 +18,8 @@ Each file contains:
18
18
  - `exploreName` — which explore (dbt model) the query targets
19
19
  - `metricQuery.dimensions` — dimension field IDs used for grouping
20
20
  - `metricQuery.metrics` — metric field IDs used for aggregation
21
- - `metricQuery.filters` — filter rules applied to the query
21
+ - `metricQuery.filters.dimensions` — dimension/WHERE filter rules applied to the query
22
+ - `metricQuery.filters.metrics` — metric/HAVING filter rules applied to the query
22
23
  - `metricQuery.sorts` — sort order
23
24
  - `metricQuery.limit` — row limit
24
25
  - `metricQuery.tableCalculations` — computed columns (may be empty)
@@ -42,7 +43,8 @@ Each file contains:
42
43
  - `chartName` → `query(exploreName).label(chartName)` — **always set the label**
43
44
  - `metricQuery.dimensions` → `.dimensions([...])`
44
45
  - `metricQuery.metrics` → `.metrics([...])`
45
- - `metricQuery.filters` → `.filters([...])`
46
+ - `metricQuery.filters.dimensions` → `.filters([...])`
47
+ - `metricQuery.filters.metrics` → `.metricFilters([...])` — keep these even when the field is absent from `metricQuery.metrics`; filter-only metrics are valid
46
48
  - `metricQuery.sorts` → `.sorts([...])`
47
49
  - `metricQuery.tableCalculations` → `.tableCalculations([...])` — pass through as-is if present
48
50
  4. These are starting points — adapt them based on the user's prompt. You may combine
@@ -76,7 +78,10 @@ Each file has a `linked` boolean and a `chartUuid`:
76
78
  `metricQuery.dimensions` / `metricQuery.metrics`); read the returned `columns`
77
79
  to know what's available. The listing line marks these with "LINKED".
78
80
  - **`linked: false`** — copy as today: build an inline `query(exploreName)...`
79
- from the metricQuery.
81
+ from the metricQuery. Keep filter kinds separate: dimension rules use
82
+ `.filters()` and metric rules use `.metricFilters()`. For each leaf rule, map
83
+ `target.fieldId` to `field` and `values` to `value`; group/rule ids are backend
84
+ metadata, not SDK filter properties.
80
85
 
81
86
  A linked chart stays in sync with Lightdash and appears in the Queries panel
82
87
  like any other query. If it can't be run (deleted / no access), the app should
@@ -135,7 +135,7 @@ query('orders')
135
135
  | Base explore (`orders`) | `'status'` | `orders_status` |
136
136
  | Joined table (`customers`) | `'customers.name'` | `customers_name` |
137
137
 
138
- **This also applies to `.filters()` and `.sorts()`** — any `field` value can use dot notation.
138
+ **This also applies to `.filters()`, `.metricFilters()`, and `.sorts()`** — any `field` value can use dot notation.
139
139
 
140
140
  **Never prefix joined table fields with the base explore name.** `'customers.name'` is correct. `'name'` alone would resolve to `orders_name` which doesn't exist.
141
141
 
@@ -608,9 +608,23 @@ For the action-menu label and clipboard copy on a cell, the same helper applies
608
608
 
609
609
  ### Filters
610
610
 
611
- Filter syntax for the `.filters([...])` builder method. For how filters propagate across the app (global filter context, "Filter by <value>" interactions), see [Global filters](#global-filters).
611
+ Use `.filters([...])` for dimension/WHERE filters and `.metricFilters([...])`
612
+ for metric/HAVING filters. A metric used only in `.metricFilters()` does not
613
+ need to appear in `.metrics()`. Passing a metric to `.filters()` or a dimension
614
+ to `.metricFilters()` fails semantic validation. Both methods use the same rule
615
+ syntax below. For how dimension filters propagate across the app (global filter
616
+ context, "Filter by <value>" interactions), see [Global filters](#global-filters).
612
617
 
613
618
  ```ts
619
+ query('orders')
620
+ .metrics(['total_revenue'])
621
+ .filters([
622
+ { field: 'order_date', operator: 'inThePast', value: 90, unit: 'days' },
623
+ ])
624
+ .metricFilters([
625
+ { field: 'order_count', operator: 'greaterThanOrEqual', value: 2 },
626
+ ]);
627
+
614
628
  type Filter = {
615
629
  field: string;
616
630
  operator: FilterOperator;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "1.85.1",
3
+ "version": "1.86.1",
4
4
  "description": "Lightdash CLI tool",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -41,8 +41,8 @@
41
41
  "unique-names-generator": "4.7.1",
42
42
  "uuid": "11.1.1",
43
43
  "yaml": "2.8.3",
44
- "@lightdash/common": "1.85.1",
45
- "@lightdash/warehouses": "1.85.1"
44
+ "@lightdash/common": "1.86.1",
45
+ "@lightdash/warehouses": "1.86.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/inquirer": "8.2.4",