[HDX-4003] [HDX-4004] feat(cli): dashboard list/export/create/import and saved-searches commands - #2914
[HDX-4003] [HDX-4004] feat(cli): dashboard list/export/create/import and saved-searches commands#2914wrn14897 wants to merge 3 commits into
Conversation
- hdx dashboards create --file <json>: validates against DashboardWithoutIdSchema locally, auto-generates missing tile ids, and POSTs to /dashboards - hdx saved-searches list/create: list saved searches and create new ones (--name/--source/--where/--where-language/--select/--order-by/--tags), resolving sources by name or id - fix getSavedSearches() to hit /saved-search (the API mounts the singular path; the old /saved-searches always 404'd and was silently swallowed)
🦋 Changeset detectedLatest commit: 2712850 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Greptile SummaryThe PR expands the CLI’s dashboard authoring surface and adds saved-search listing and creation while correcting the saved-search API route.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/cli/src/cli.tsx | Adds dashboard list/export/create/import and saved-search list/create command flows; the previously misleading dashboard input description now points to the full shared schema and a valid export shape. |
| packages/cli/src/api/client.ts | Corrects the saved-search route and adds typed dashboard and saved-search creation requests with bounded response-error details. |
| packages/cli/AGENTS.md | Updates the documented CLI command surface for the new dashboard and saved-search operations. |
| .changeset/cli-create-dashboards-saved-searches.md | Records the user-facing CLI additions and endpoint correction as a minor release. |
Sequence Diagram
sequenceDiagram
participant User
participant CLI as hdx CLI
participant Schema as DashboardWithoutIdSchema
participant API as HyperDX API
User->>CLI: dashboards create/import
CLI->>CLI: Read JSON and generate missing tile IDs
CLI->>Schema: Validate dashboard definition
alt Valid definition
Schema-->>CLI: Parsed dashboard
CLI->>API: POST /dashboards
API-->>CLI: Created dashboard
CLI-->>User: Dashboard details
else Invalid definition
Schema-->>CLI: Validation issues
CLI-->>User: Per-field errors
end
Reviews (3): Last reviewed commit: "feat(cli): dashboard list/export/import ..." | Re-trigger Greptile
Deep Review✅ No critical issues found. The change is additive CLI surface (new 🟡 P2 -- recommended
🔵 P3 nitpicks (6)
Reviewers (6): api-contract, kieran-typescript, reliability, maintainability, testing, project-standards. Testing gaps:
|
E2E Test Results✅ All tests passed • 295 passed • 1 skipped • 1157s
Tests ran across 4 shards in parallel. |
…3, HDX-4004) - hdx dashboards list (default subcommand): --query name filter and --format table|json|csv; --json kept as a back-compat alias - hdx dashboards export --id <id-or-name>: emits a round-trip-safe definition (server-managed fields stripped, re-validated against DashboardWithoutIdSchema so export | import always round-trips) - hdx dashboards create: new inline-chart mode (--name + repeatable --chart / --chart-file with auto grid layout) alongside --file, plus --if-not-exists for idempotent creation - hdx dashboards import --file: recreates exported dashboards with --if-not-exists and --name-override - add 'dashboard' alias for the command group
Why
The
hdxCLI could list dashboards and render tiles, but had no way to create, export, or import dashboards or saved searches — authoring them required the web UI or raw API calls. This implements the dashboard read/write command surface from HDX-4003 and HDX-4004, making the CLI a complete authoring surface for scripted/agent-driven workflows (author a dashboard, create it, then immediately validate every tile withhdx chart -d).What
Dashboards (
hdx dashboards, aliashdx dashboard)list(default subcommand; barehdx dashboardsunchanged) — adds--query <substr>name filtering and--format table|json|csv(--jsonkept as back-compat alias). CSV emitsid,name,tags,createdAt,updatedAt,tileCount. (HDX-4003)export --id <id-or-name>— prints the full dashboard definition (charts, layout, filters) as JSON with server-managed fields stripped, re-validated againstDashboardWithoutIdSchemasoexport | importis guaranteed round-trip compatible. Legacy dashboards that no longer validate are still exported with a stderr warning. (HDX-4003)create— two modes: (HDX-4004)--file <json>(or-for stdin): fullDashboardWithoutIddefinition, validated locally with readable per-issue zod errors; missing tile ids auto-generated with the web'smakeId()pattern--name <name>+ repeatable--chart '<json>'/--chart-file <path>: each chart is a full tile ({x,y,w,h,config}) or a bare chart config — charts without layout auto-flow onto the 24-column grid (12×4, two per row)--if-not-existsskips creation when the name already exists (prints the existing id/URL, exit 0)import --file <json>— recreates an exported dashboard, with--if-not-existsand--name-override. (HDX-4004)Saved searches (
hdx saved-searches)list(default) — human-readable or--jsoncreate --name --source <name-or-id> --where [--where-language lucene|sql] [--select] [--order-by] [--tags]— resolves sources by name or idBug fix
ApiClient.getSavedSearches()requested/saved-searches, but the API mounts the router at the singular/saved-search(packages/api/src/api-app.ts). The call always 404'd and the failure was silently swallowed in the TUI. Now fixed — saved searches load in the TUI source picker again.Notes
hdx dashboard(singular) and-s <url>; this follows the CLI's established conventions (hdx dashboards,-a/--app-url—-salready means--sourceonchart) and adds adashboardalias for the group.packages/cli/AGENTS.md; changeset included (@hyperdx/climinor).Validation
Verified end-to-end against a live deployment with OTel Demo data:
hdx dashboards create --file— all accepted by the server-side schema; every tile renderedstatus: okviahdx chart -d <dashboard> --json.list --query flow --format csv/--format json/ bare--jsonback-compat all verified.export --id "Shop Fleet Overview"→import --name-override "… (copy)"→ all 9 tiles of the copy renderedok→ re-runningimport --if-not-existsskipped with the existing id.create --name "CLI Smoke Test" --chart '…' --chart '…'auto-laid-out both tiles and both renderedok;--if-not-existson the same name skipped. (Test dashboards deleted afterwards.)hdx saved-searches create(lucene + sql filters, tags) and confirmed withhdx saved-searches list.yarn tsc --noEmit,yarn ci:lint, and prettier pass.