@lightdash/cli 2.167.3 → 2.168.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.
@@ -0,0 +1,50 @@
1
+ {
2
+ "fieldMapping": {
3
+ "category": "orders_status",
4
+ "value": "orders_total_revenue"
5
+ },
6
+ "rows": [
7
+ {
8
+ "orders_status": {
9
+ "value": { "raw": "completed", "formatted": "Completed" }
10
+ },
11
+ "orders_total_revenue": {
12
+ "value": { "raw": 42800, "formatted": "$42,800" }
13
+ }
14
+ },
15
+ {
16
+ "orders_status": {
17
+ "value": { "raw": "shipped", "formatted": "Shipped" }
18
+ },
19
+ "orders_total_revenue": {
20
+ "value": { "raw": 31500, "formatted": "$31,500" }
21
+ }
22
+ },
23
+ {
24
+ "orders_status": {
25
+ "value": { "raw": "placed", "formatted": "Placed" }
26
+ },
27
+ "orders_total_revenue": {
28
+ "value": { "raw": 18200, "formatted": "$18,200" }
29
+ }
30
+ },
31
+ {
32
+ "orders_status": {
33
+ "value": { "raw": "returned", "formatted": "Returned" }
34
+ },
35
+ "orders_total_revenue": {
36
+ "value": { "raw": 6400, "formatted": "$6,400" }
37
+ }
38
+ }
39
+ ],
40
+ "options": {
41
+ "showLabels": true,
42
+ "maxBars": 10
43
+ },
44
+ "colorPalette": ["#7162FF", "#1A9AAA", "#E5A800", "#DA5D2B", "#3B82F6"],
45
+ "seriesColors": {},
46
+ "valueColors": {},
47
+ "pivotDetails": null,
48
+ "underlyingData": { "enabled": false },
49
+ "drillDown": { "enabled": false }
50
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"scaffolding.d.ts","sourceRoot":"","sources":["../../../src/handlers/apps/scaffolding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMzD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAKpE;AA6DD;;;GAG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AM,eAAe,GAAG,KAAK,GAAG,YAAY,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,yBAAyB,SAAU;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,eAAe,CAAC;CAC5B,KAAG,eAAe,EA2FlB,CAAC"}
@@ -135,6 +135,13 @@ const buildStaticAuthoringFiles = (args) => {
135
135
  path: '.claude/skills/developing-chart-types-locally/SKILL.md',
136
136
  contentBase64: (0, fs_1.readFileSync)(path.join(authoringDir, 'developing-chart-types-locally', 'SKILL.md')).toString('base64'),
137
137
  });
138
+ // Starter fixture for the SDK's dev-only preview fallback: open the dev
139
+ // server with `?vizFixture=/viz-fixture.json` to render the chart
140
+ // without the Lightdash host (see developing-chart-types-locally).
141
+ files.push({
142
+ path: 'viz-fixture.json',
143
+ contentBase64: (0, fs_1.readFileSync)(path.join(authoringDir, 'chart-type', 'viz-fixture.json')).toString('base64'),
144
+ });
138
145
  }
139
146
  if (!isChartType) {
140
147
  // skill.md → .claude/skills/lightdash-data-app/SKILL.md
@@ -101,6 +101,28 @@ describe('buildStaticAuthoringFiles', () => {
101
101
  expect(files.every((f) => !f.path.startsWith('src/'))).toBe(true);
102
102
  });
103
103
  });
104
+ describe('buildStaticAuthoringFiles — chart-type flavor', () => {
105
+ const files = (0, scaffolding_1.buildStaticAuthoringFiles)({
106
+ appName: 'Radial gauge',
107
+ sdkVersion: '0.3275.0',
108
+ flavor: 'chart-type',
109
+ });
110
+ const byPath = (p) => files.find((f) => f.path === p);
111
+ const text = (p) => Buffer.from(byPath(p).contentBase64, 'base64').toString('utf-8');
112
+ it('ships the chart-type workflow skill, not the app skills', () => {
113
+ expect(byPath('.claude/skills/developing-chart-types-locally/SKILL.md')).toBeDefined();
114
+ expect(byPath('.claude/skills/lightdash-data-app/SKILL.md')).toBeUndefined();
115
+ });
116
+ it('ships a starter viz fixture for local preview', () => {
117
+ const fixture = JSON.parse(text('viz-fixture.json'));
118
+ expect(fixture.fieldMapping.category).toBeDefined();
119
+ expect(fixture.fieldMapping.value).toBeDefined();
120
+ expect(Array.isArray(fixture.rows)).toBe(true);
121
+ });
122
+ it('documents the fixture preview flow in AGENTS.md', () => {
123
+ expect(text('AGENTS.md')).toContain('vizFixture');
124
+ });
125
+ });
104
126
  describe('loadVendoredBuildScaffold', () => {
105
127
  const files = (0, scaffolding_1.loadVendoredBuildScaffold)('0.3275.0');
106
128
  const byPath = (p) => files.find((file) => file.path === p);
@@ -19,7 +19,7 @@ Run these commands from this folder under `chart-types/<slug>/`. The upload path
19
19
  3. `lightdash upload --chart-types <slug> --path ../..` — the server rebuilds; the chart type then appears in the explorer's chart type picker for that project.
20
20
  4. Verify in Lightdash: open any explore, run a query, pick this chart type, and map its fields.
21
21
 
22
- There is no local preview for a chart type: `useVizContext()` waits for the Lightdash host, so the component renders nothing standalone (`lightdash apps preview` and `npm run dev` show a blank page). Upload and verify in the explorer instead.
22
+ Preview locally with the fixture: `useVizContext()` normally waits for the Lightdash host, but the SDK has a dev-only fallback. Run `lightdash apps preview` (or `npm run dev`) and open the dev URL with `?vizFixture=/viz-fixture.json` — the scaffold's `viz-fixture.json` seeds `useVizContext()` so the chart renders. Edit that file to match your `vizSchema` (fieldMapping, rows as `{ value: { raw, formatted } }` cells, options, colorPalette, pivotDetails). It's fake data for layout/option iteration and never fires in production; the explorer with real data is still the source of truth — upload and verify there before finishing.
23
23
 
24
24
  Build with the template's preinstalled dependency set (see `package.json` — React, Recharts, d3, and more). Do not add npm packages or vendor library source into `src/`; chart types published to the official registry must stay template-deps-only.
25
25
 
@@ -10,7 +10,7 @@ Run these commands from this folder under `chart-types/<slug>/`. The upload path
10
10
  3. `lightdash upload --chart-types <slug> --path ../..` (the `slug` from `lightdash-app.yml`) — Lightdash rebuilds and serves it.
11
11
  4. Open any explore in Lightdash, run a query, and pick this chart type in the chart type picker to see it against real data.
12
12
 
13
- There is no standalone preview: the component waits for the Lightdash host's data, so `npm run dev` shows a blank page. Upload and verify in the explorer.
13
+ Preview locally with the included `viz-fixture.json`: run `lightdash apps preview` (or `npm run dev`) and open the dev URL with `?vizFixture=/viz-fixture.json`. The SDK's dev-only fallback seeds `useVizContext()` from that file so the chart renders without the Lightdash host. Edit the fixture to match your `vizSchema`. It's fake data for layout iteration and never runs in production — the explorer with real data is the source of truth, so upload and verify there too.
14
14
 
15
15
  ## What's read-only
16
16
  Root config (`vite.config.js`, `tsconfig.json`, etc.) is read-only reference — the server rebuilds against a trusted template. Build within the template's fixed dependency set (see `package.json`); chart types published to the official registry must stay template-deps-only.
@@ -0,0 +1,50 @@
1
+ {
2
+ "fieldMapping": {
3
+ "category": "orders_status",
4
+ "value": "orders_total_revenue"
5
+ },
6
+ "rows": [
7
+ {
8
+ "orders_status": {
9
+ "value": { "raw": "completed", "formatted": "Completed" }
10
+ },
11
+ "orders_total_revenue": {
12
+ "value": { "raw": 42800, "formatted": "$42,800" }
13
+ }
14
+ },
15
+ {
16
+ "orders_status": {
17
+ "value": { "raw": "shipped", "formatted": "Shipped" }
18
+ },
19
+ "orders_total_revenue": {
20
+ "value": { "raw": 31500, "formatted": "$31,500" }
21
+ }
22
+ },
23
+ {
24
+ "orders_status": {
25
+ "value": { "raw": "placed", "formatted": "Placed" }
26
+ },
27
+ "orders_total_revenue": {
28
+ "value": { "raw": 18200, "formatted": "$18,200" }
29
+ }
30
+ },
31
+ {
32
+ "orders_status": {
33
+ "value": { "raw": "returned", "formatted": "Returned" }
34
+ },
35
+ "orders_total_revenue": {
36
+ "value": { "raw": 6400, "formatted": "$6,400" }
37
+ }
38
+ }
39
+ ],
40
+ "options": {
41
+ "showLabels": true,
42
+ "maxBars": 10
43
+ },
44
+ "colorPalette": ["#7162FF", "#1A9AAA", "#E5A800", "#DA5D2B", "#3B82F6"],
45
+ "seriesColors": {},
46
+ "valueColors": {},
47
+ "pivotDetails": null,
48
+ "underlyingData": { "enabled": false },
49
+ "drillDown": { "enabled": false }
50
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: developing-chart-types-locally
3
- description: Use when editing a locally created or downloaded Lightdash custom chart type (data_app_viz) — the vizSchema/component lockstep contract, the upload-and-verify loop, why there is no standalone preview, and how a chart type reaches the official registry.
3
+ description: Use when editing a locally created or downloaded Lightdash custom chart type (data_app_viz) — the vizSchema/component lockstep contract, the upload-and-verify loop, the local fixture preview, and how a chart type reaches the official registry.
4
4
  ---
5
5
 
6
6
  # Developing Lightdash Custom Chart Types Locally
@@ -26,10 +26,20 @@ Run these commands from this folder under `chart-types/<slug>/`. The upload path
26
26
  3. `lightdash upload --chart-types <slug> --path ../..` (the `slug` from `lightdash-app.yml`) — the server rebuilds and serves it.
27
27
  4. Verify in Lightdash: open any explore, run a query with at least the required fields' shapes (e.g. a dimension and a metric), pick this chart type in the chart type picker, and map its fields. Check every config option you declared actually changes the chart.
28
28
 
29
- **There is no standalone preview.** `useVizContext()` waits for the Lightdash host to push context, so outside Lightdash the component renders nothing: `npm run dev` and `lightdash apps preview` show a blank page. Do not build a mock harness or feed the hook fake data to work around this — upload and verify in the explorer instead.
30
-
31
29
  Saved charts already using this chart type may pin a version; unpinned charts move to the newly uploaded version right away. While iterating in a shared project, prefer verifying on a throwaway chart.
32
30
 
31
+ ## Preview locally with a fixture (fast layout iteration)
32
+
33
+ `useVizContext()` normally waits for the Lightdash host to push a context, so with no host the component renders nothing. For local iteration the SDK has a **dev-only fixture fallback**: when the app runs top-level (not embedded) and the page URL carries `?vizFixture=<path>`, it fetches that same-origin JSON file and feeds it to `useVizContext()` as the context.
34
+
35
+ The scaffold ships a `viz-fixture.json` at the folder root. To use it:
36
+
37
+ 1. `lightdash apps preview` (or `npm run dev`) to start the dev server.
38
+ 2. Open the dev URL with the param, e.g. `http://localhost:5173/?vizFixture=/viz-fixture.json`. The chart renders from the fixture.
39
+ 3. Edit `viz-fixture.json` to match your declared `vizSchema` — `fieldMapping` (declared field name → any string id), `rows` (each cell is `{ "value": { "raw": ..., "formatted": "..." } }`, keyed by those ids), `options` (declared option name → value), `colorPalette`, and `pivotDetails` (`null` unless you map a `series` field). Reload to see changes.
40
+
41
+ This is for **layout and option iteration only**, and never fires in production (an embedded viz has a real host whose context always wins, and the param must be explicitly present). The fixture is fake data you hand-maintain: colors fall back to the palette (no model or shared-dashboard colors), `pivotDetails` must be shaped by hand, and formatting is whatever you type. **The explorer with real data remains the source of truth for correctness** — still run the upload → verify loop above before finishing, and verify every declared option actually changes the chart there.
42
+
33
43
  ## Dependencies: template-deps-only, strictly
34
44
 
35
45
  Build with the template's preinstalled set (see `package.json` — React, Recharts, d3 and friends). Do not add npm packages and do not vendor library source into `src/`. This is stricter than for data apps: the official chart registry rejects any dependency drift from its template, so a chart type that grows custom dependencies becomes unpublishable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/cli",
3
- "version": "2.167.3",
3
+ "version": "2.168.0",
4
4
  "description": "Lightdash CLI tool",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -45,8 +45,8 @@
45
45
  "unique-names-generator": "4.7.1",
46
46
  "uuid": "11.1.1",
47
47
  "yaml": "2.8.3",
48
- "@lightdash/common": "2.167.3",
49
- "@lightdash/warehouses": "2.167.3"
48
+ "@lightdash/common": "2.168.0",
49
+ "@lightdash/warehouses": "2.168.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/inquirer": "8.2.4",