@lightdash/cli 1.84.0 → 1.85.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.
- package/README.md +6 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/handlers/apps/validate.d.ts +49 -0
- package/dist/handlers/apps/validate.d.ts.map +1 -0
- package/dist/handlers/apps/validate.js +332 -0
- package/dist/handlers/apps/validate.test.d.ts +2 -0
- package/dist/handlers/apps/validate.test.d.ts.map +1 -0
- package/dist/handlers/apps/validate.test.js +270 -0
- package/dist/index.js +12 -2
- package/dist/vendor/authoring/README.md.tmpl +4 -3
- package/dist/vendor/authoring/developing-data-apps-locally/SKILL.md +3 -2
- package/dist/vendor/template/references/chart-references.md +1 -0
- package/dist/vendor/template/skill.md +6 -2
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const error_1 = require("./error");
|
|
|
10
10
|
const globalState_1 = tslib_1.__importDefault(require("./globalState"));
|
|
11
11
|
const createApp_1 = require("./handlers/apps/createApp");
|
|
12
12
|
const preview_1 = require("./handlers/apps/preview");
|
|
13
|
+
const validate_1 = require("./handlers/apps/validate");
|
|
13
14
|
const compile_1 = require("./handlers/compile");
|
|
14
15
|
const connectSnowflake_1 = require("./handlers/connectSnowflake");
|
|
15
16
|
const refresh_1 = require("./handlers/dbt/refresh");
|
|
@@ -33,7 +34,7 @@ const runChart_1 = require("./handlers/runChart");
|
|
|
33
34
|
const setProject_1 = require("./handlers/setProject");
|
|
34
35
|
const setWarehouse_1 = require("./handlers/setWarehouse");
|
|
35
36
|
const sql_1 = require("./handlers/sql");
|
|
36
|
-
const
|
|
37
|
+
const validate_2 = require("./handlers/validate");
|
|
37
38
|
const warehouseCatalog_1 = require("./handlers/warehouseCatalog");
|
|
38
39
|
const styles = tslib_1.__importStar(require("./styles"));
|
|
39
40
|
// Trigger CLI tests
|
|
@@ -446,6 +447,15 @@ appsProgram
|
|
|
446
447
|
.option('--port <port>', 'port for the app dev server (default: Vite picks one, usually 5173)')
|
|
447
448
|
.option('--verbose', undefined, false)
|
|
448
449
|
.action(preview_1.appsPreviewHandler);
|
|
450
|
+
appsProgram
|
|
451
|
+
.command('validate [paths...]')
|
|
452
|
+
.description('Validate data app source, manifests, dependencies, and semantic-layer references locally.')
|
|
453
|
+
.option('--live', 'Validate against fresh explores from each app project instead of its downloaded semantic-layer snapshot.', false)
|
|
454
|
+
.addOption(new commander_1.Option('--format <format>', 'Output format: human or json')
|
|
455
|
+
.choices(['human', 'json'])
|
|
456
|
+
.default('human'))
|
|
457
|
+
.option('--verbose', undefined, false)
|
|
458
|
+
.action(validate_1.appsValidateHandler);
|
|
449
459
|
commander_1.program
|
|
450
460
|
.command('deploy')
|
|
451
461
|
.description('Compiles and deploys a Lightdash project')
|
|
@@ -529,7 +539,7 @@ commander_1.program
|
|
|
529
539
|
.option('--include-spaces <spaceSlugs...>', 'Only report validation errors for charts and dashboards in these spaces (and their sub-spaces). Spaces must be visible to your credentials')
|
|
530
540
|
.option('--exclude-spaces <spaceSlugs...>', 'Skip validation errors for charts and dashboards in these spaces (and their sub-spaces). Spaces must be visible to your credentials')
|
|
531
541
|
.option('--no-partial-compilation', 'Fail when a field or join cannot be compiled instead of returning a partial explore')
|
|
532
|
-
.action(
|
|
542
|
+
.action(validate_2.validateHandler);
|
|
533
543
|
commander_1.program
|
|
534
544
|
.command('generate')
|
|
535
545
|
.description('Generates a new schema.yml file for model')
|
|
@@ -4,9 +4,10 @@ Created or downloaded with the Lightdash CLI.
|
|
|
4
4
|
|
|
5
5
|
## Edit → build → upload
|
|
6
6
|
1. Edit files under `src/`.
|
|
7
|
-
2.
|
|
8
|
-
3. Optionally,
|
|
9
|
-
4.
|
|
7
|
+
2. Run `lightdash apps validate` to check the source, manifest, dependencies, external-connection aliases, and semantic references against the downloaded context. Use `--live` for fresh project explores or `--format json` in CI.
|
|
8
|
+
3. Optionally, run `npm run build` to check it compiles locally. `lightdash apps create` installs the initial dependencies after asking permission; after `lightdash download`, run `npm install` first if `node_modules` is absent. If the local install or build fails in your environment, treat it as a non-blocking warning and continue to upload. Keep the failure details because they may predict a server build problem, but don't change machine or registry config to force the pre-check to pass — the server build on upload is authoritative and surfaces its result on the app page.
|
|
9
|
+
4. Optionally, preview against real data: `lightdash apps preview` (needs a successful `npm install`).
|
|
10
|
+
5. `lightdash upload --apps <slug>` (the `slug` from `lightdash-app.yml`) — Lightdash rebuilds and serves the app.
|
|
10
11
|
|
|
11
12
|
Local preview uses your existing CLI login through a project- and route-restricted loopback proxy; the credential is not written into this folder or exposed to browser code. It runs local tooling as your OS user (with access to that user's files, including the existing CLI config) and shows data under your own permissions, so preview only source/dependencies you trust. Host-mediated features such as external connections and data-app-viz context still need testing after upload.
|
|
12
13
|
|
|
@@ -28,8 +28,9 @@ You are editing a Lightdash **data app** that was created or downloaded with the
|
|
|
28
28
|
## The edit → build → upload loop
|
|
29
29
|
|
|
30
30
|
1. Edit files under `src/` only.
|
|
31
|
-
2.
|
|
32
|
-
3. `
|
|
31
|
+
2. Run `lightdash apps validate` to check the source, manifest, dependencies, external-connection aliases, and semantic references against the downloaded context. Use `--live` to check against fresh project explores; use `--format json` in CI. A green run reports any call sites it could not fully analyze instead of silently claiming complete coverage.
|
|
32
|
+
3. Optionally, run `npm run build` to check it compiles. Apps made with `lightdash apps create` already have their initial dependencies installed. After `lightdash download`, if you choose to do the local pre-check and `node_modules` is absent, run `npm install` first. This is an **optional local pre-check** — see below.
|
|
33
|
+
4. `lightdash upload --apps <slug>` (the `slug` from this folder's `lightdash-app.yml`) — the **server** rebuilds and serves the app. The server rebuild, not your local build, is what ships.
|
|
33
34
|
|
|
34
35
|
## The local build is optional — never fight a failing install
|
|
35
36
|
|
|
@@ -139,6 +139,7 @@ generation, so author them normally.)
|
|
|
139
139
|
**Important:** The field IDs in metric queries use qualified names (e.g.,
|
|
140
140
|
`orders_total_revenue`). When mapping to SDK calls:
|
|
141
141
|
- **Base explore fields:** Strip the explore name prefix. `orders_total_revenue` → `total_revenue`
|
|
142
|
+
- **Prefix-collision exception:** If the remaining short name still begins with the explore name and an underscore, keep the original qualified ID. For example, `custom_roles_custom_roles_created` must stay fully qualified; shortening it to `custom_roles_created` makes the SDK mistake it for an already-qualified ID.
|
|
142
143
|
- **Joined table fields:** Convert to dot notation. If the explore is `orders` and the field is
|
|
143
144
|
`customers_customer_name`, that's a joined table field — use `customers.customer_name`.
|
|
144
145
|
**Only strip the prefix if it matches the explore name.** If it doesn't match, it's a joined table.
|
|
@@ -226,7 +226,11 @@ export function RevenueBySegment() {
|
|
|
226
226
|
|
|
227
227
|
### Field names
|
|
228
228
|
|
|
229
|
-
Use **short names** like `total_revenue
|
|
229
|
+
Use **short names** like `total_revenue` for base-explore fields; the SDK qualifies them automatically. Already-qualified base field IDs such as `orders_total_revenue` are also accepted.
|
|
230
|
+
|
|
231
|
+
There is one important ambiguity: if a base field's short name already begins with the explore name and an underscore, keep its **fully qualified ID**. For example, the `custom_roles_created` metric on the `custom_roles` explore must be passed as `custom_roles_custom_roles_created`. Passing the short name would be mistaken for an already-qualified ID and sent to the API unchanged. Query result keys match the identifier passed to the builder, so use that same fully qualified ID when reading rows or calling `format`.
|
|
232
|
+
|
|
233
|
+
For joined table fields, use **dot notation** like `customers.name` (see "Joined table fields" above).
|
|
230
234
|
|
|
231
235
|
### Query builder
|
|
232
236
|
|
|
@@ -1182,7 +1186,7 @@ The action-menu example above shows typical `drillDown()` usage. For the full AP
|
|
|
1182
1186
|
| Unused dimensions in `.dimensions()` | Changes GROUP BY → wrong numbers | Only include dimensions you render |
|
|
1183
1187
|
| Querying hidden fields (`customer_id`) | Leaks internal IDs | Skip fields with `hidden: true` |
|
|
1184
1188
|
| Calling `createClient()` in app code | Not needed — client is set up in `main.jsx` | `import { query, useLightdash } from '@lightdash/query-sdk'` |
|
|
1185
|
-
|
|
|
1189
|
+
| Short base field name starts with the explore prefix: `query('custom_roles').metrics(['custom_roles_created'])` | Mistaken for an already-qualified ID → unknown field | Preserve the full ID: `custom_roles_custom_roles_created` |
|
|
1186
1190
|
| Joined table field without dot notation: `customer_name` | Resolves to `orders_customer_name` → unknown field | Use `customers.customer_name` for joined tables |
|
|
1187
1191
|
| `value: '2025'` for a number column | String won't match number | `value: 2025` |
|
|
1188
1192
|
| Not filtering on grain dimensions you don't render | Duplicates, mixed data, wrong totals | Identify the grain, filter dimensions you don't display |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.85.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.
|
|
45
|
-
"@lightdash/warehouses": "1.
|
|
44
|
+
"@lightdash/common": "1.85.0",
|
|
45
|
+
"@lightdash/warehouses": "1.85.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/inquirer": "8.2.4",
|