@lightdash/cli 1.5.1 → 1.7.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.
@@ -184,13 +184,13 @@ const revenueQuery = query('orders')
184
184
  .limit(10);
185
185
 
186
186
  export function RevenueBySegment() {
187
- const { data, format, loading, error } = useLightdash(revenueQuery);
187
+ const { data, format, loading, error, lineage } = useLightdash(revenueQuery);
188
188
 
189
189
  if (loading) return <p className="text-sm text-muted-foreground">Loading...</p>;
190
190
  if (error) return <p className="text-sm text-destructive">Error: {error.message}</p>;
191
191
 
192
192
  return (
193
- <div className="space-y-2">
193
+ <div className="space-y-2" {...lineage}>
194
194
  {data.map((row, i) => (
195
195
  <div key={i} className="flex justify-between">
196
196
  <span>{format(row, 'customer_segment')}</span>
@@ -297,6 +297,7 @@ If the dbt YAML declares a `parameters:` block (under a model's `meta:` / `confi
297
297
  | `totalResults` | `number \| null` | Total rows returned by the loaded source query. Use for export labels/counts. |
298
298
  | `loading` | `boolean` | True while query is in flight. |
299
299
  | `error` | `Error \| null` | Query error. |
300
+ | `lineage` | `LineageProps` | **Spread on the root element of every rendered query block** (`<div {...lineage}>`). Stamps the block so the host's Inspect data button can trace it back to this query — without it that button stays disabled. |
300
301
  | `refetch` | `() => void` | Re-run the query on demand. |
301
302
  | `queryUuid` | `string \| null` | The async Lightdash query UUID for the loaded source query. Rarely needed directly. |
302
303
  | `getUnderlyingData` | `({ row, metric, limit? }) => Promise<{ rows, columns, format, queryUuid }>` | Fetch raw rows behind an aggregated metric value. Call from a user action, never on initial render. |
@@ -717,10 +718,10 @@ import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
717
718
  import { Alert, AlertDescription } from '@/components/ui/alert';
718
719
 
719
720
  export function RevenueCard() {
720
- const { data, format, loading, error } = useLightdash(revenueQuery);
721
+ const { data, format, loading, error, lineage } = useLightdash(revenueQuery);
721
722
 
722
723
  return (
723
- <Card>
724
+ <Card {...lineage}>
724
725
  <CardHeader>
725
726
  <CardTitle>Revenue</CardTitle>
726
727
  </CardHeader>
@@ -792,8 +793,8 @@ export function RevenueBySegment() {
792
793
  () => baseRevenueQuery.filters(filtersFor(EXPLORE)),
793
794
  [filtersFor],
794
795
  );
795
- const { data, format, loading } = useLightdash(q);
796
- // ...
796
+ const { data, format, loading, lineage } = useLightdash(q);
797
+ // ...spread {...lineage} on the block's root element
797
798
  }
798
799
  ```
799
800
 
@@ -1143,6 +1144,8 @@ The action-menu example above shows typical `drillDown()` usage. For the full AP
1143
1144
  | `.limit()` too low | Silently truncates rows — charts end early, tables incomplete | Estimate row count from the grain, set limit above that |
1144
1145
  | Building queries inside render | Infinite re-fetching | Define queries at module scope or memoize them |
1145
1146
  | Forgetting to apply global filters to a query | Chart shows unfiltered data while the rest of the page is filtered → contradictory results | Every `useLightdash()` call must pass `filtersFor(EXPLORE)` into `.filters([...])` via `useMemo` |
1147
+ | Forgetting to spread `lineage` on a query block | The host's Inspect data button stays disabled for that block | Destructure `lineage` from `useLightdash()` and spread it on the block's root element |
1148
+ | Spreading `lineage` onto a component that swallows unknown props | The stamp never reaches the DOM, so the block looks wired but Inspect data still can't trace it | Spread onto a plain element (`<div {...lineage}>`) or a component that forwards rest props to its root element (all `@/components/ui` primitives do) |
1146
1149
  | Calling `addFilter` without an `explore` tag | Filter has no explore → the `filtersFor(otherExplore)` lookup never returns it, or (worse) you broadcast it everywhere → `FieldReferenceError` like `regional_sales_status` not found | Always include `explore: EXPLORE` on every `addFilter` call |
1147
1150
  | Using `filters` (raw) instead of `filtersFor(EXPLORE)` | Sends filters from other explores into this query → SDK qualifies the field name to the wrong explore → `FieldReferenceError` | Always select via `filtersFor(EXPLORE)`; never pass `allFilters` into `.filters()` |
1148
1151
  | Hard-coding the explore string in two places | Chart and its action menu disagree → filter sets but never applies | Define `const EXPLORE = '...'` at the top of the file and reuse it for both `query(EXPLORE)` and `addFilter({ ..., explore: EXPLORE })` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "1.5.1",
3
+ "version": "1.7.0",
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.5.1",
45
- "@lightdash/warehouses": "1.5.1"
44
+ "@lightdash/common": "1.7.0",
45
+ "@lightdash/warehouses": "1.7.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/inquirer": "8.2.4",