@erdoai/cli 0.53.0 → 0.54.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.
Files changed (3) hide show
  1. package/README.md +9 -0
  2. package/dist/index.js +34 -11
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -61,6 +61,15 @@ erdo datasets fetch acme.leads --filter <name> # opt into a saved filter
61
61
  The table is named **`data`** — for file datasets (CSV, Excel, and anything
62
62
  written by an event pipeline) that is the name regardless of the dataset's slug
63
63
  or resource key, and it is not guessable, so it is the first thing to get right.
64
+ The columns aren't guessable either, so look before you write SQL:
65
+
66
+ ```bash
67
+ erdo datasets schema acme.leads # column names and types
68
+ ```
69
+
70
+ `datasets schema` reads the stored table itself, so it shows the columns that
71
+ are actually there — the ones `fetch --sql` can reference — rather than a
72
+ declared schema that may lag what recent writes added.
64
73
  Database and warehouse datasets are queried through their real table names, which
65
74
  come from the dataset's schema. The SQL dialect is DuckDB. A dataset's default
66
75
  filters apply on every read; `--filter <name>` adds a saved filter on top, and
package/dist/index.js CHANGED
@@ -1339,6 +1339,14 @@ function timedOutMessage(threadID) {
1339
1339
  function print(value) {
1340
1340
  console.log(JSON.stringify(value, null, 2));
1341
1341
  }
1342
+ function printAlignedTable(columns, rows) {
1343
+ const cell = (v) => v === null || v === void 0 ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
1344
+ const widths = columns.map((c, i) => Math.max(c.length, ...rows.map((r) => cell(r[i]).length), 0));
1345
+ const line = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(" ").trimEnd();
1346
+ console.log(line(columns));
1347
+ console.log(widths.map((w) => "-".repeat(w)).join(" "));
1348
+ for (const r of rows) console.log(line(columns.map((_, i) => cell(r[i]))));
1349
+ }
1342
1350
  var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
1343
1351
  var collect = (v, acc) => {
1344
1352
  acc.push(v);
@@ -3444,7 +3452,7 @@ datasetsCmd.command("fetch <slug>").description(
3444
3452
  "Read rows from a dataset \u2014 the deterministic read, and the one to use for anything mechanical or scripted. Returns {columns, rows, row_count}."
3445
3453
  ).option(
3446
3454
  "-q, --sql <query>",
3447
- "DuckDB SQL shaping the rows. File datasets (including anything an event pipeline writes) are queried as a table named `data`, whatever the dataset's slug; database and warehouse datasets use their real table names from the schema."
3455
+ "DuckDB SQL shaping the rows. File datasets (including anything an event pipeline writes) are queried as a table named `data`, whatever the dataset's slug; database and warehouse datasets use their real table names from the schema. `erdo datasets schema <slug>` lists the columns you can reference."
3448
3456
  ).option("-l, --limit <n>", "max rows to return", (v) => parseInt(v, 10)).option(
3449
3457
  "-f, --filter <name>",
3450
3458
  "opt into a saved filter by name (repeatable); additive on top of the dataset's default filters (see: erdo datasets filter list <slug>)",
@@ -3463,6 +3471,29 @@ datasetsCmd.command("fetch <slug>").description(
3463
3471
  fail(e);
3464
3472
  }
3465
3473
  });
3474
+ datasetsCmd.command("schema <slug>").alias("describe").description(
3475
+ "Show a dataset's physical columns \u2014 the names and types you can reference in `datasets fetch --sql`, read from the stored `data` table itself (DuckDB DESCRIBE) so they are what is actually there, not what was declared. For a database or warehouse dataset, DESCRIBE its real table names instead: `datasets fetch <slug> --sql 'DESCRIBE <table>'`."
3476
+ ).option("--json", "print the raw JSON result instead of a table").action(async (slug, opts) => {
3477
+ try {
3478
+ const res = await new ErdoClient().fetchDatasetContents(slug, { sql_query: "DESCRIBE data" });
3479
+ if (opts.json) {
3480
+ print(res);
3481
+ return;
3482
+ }
3483
+ const nameIdx = res.columns.indexOf("column_name");
3484
+ const typeIdx = res.columns.indexOf("column_type");
3485
+ if (nameIdx === -1 || typeIdx === -1) {
3486
+ printAlignedTable(res.columns, res.rows);
3487
+ return;
3488
+ }
3489
+ printAlignedTable(
3490
+ ["column", "type"],
3491
+ res.rows.map((r) => [r[nameIdx], r[typeIdx]])
3492
+ );
3493
+ } catch (e) {
3494
+ fail(e);
3495
+ }
3496
+ });
3466
3497
  var MAX_UPLOAD_BYTES = 20 * 1024 * 1024;
3467
3498
  datasetsCmd.command("upload <file>").description("Upload a file (CSV, Excel, JSON, ...) and create a dataset from it").option("-n, --name <name>", "display name for the dataset (defaults to the filename)").option("-d, --description <text>", "description shown to agents analyzing the dataset").action(async (file, opts) => {
3468
3499
  try {
@@ -3519,14 +3550,6 @@ datasetsCmd.command("configure-integration <dataset-id>").description("Set an in
3519
3550
  fail(e);
3520
3551
  }
3521
3552
  });
3522
- function printAnalyticsTable(columns, rows) {
3523
- const cell = (v) => v === null || v === void 0 ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
3524
- const widths = columns.map((c, i) => Math.max(c.length, ...rows.map((r) => cell(r[i]).length), 0));
3525
- const line = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(" ").trimEnd();
3526
- console.log(line(columns));
3527
- console.log(widths.map((w) => "-".repeat(w)).join(" "));
3528
- for (const r of rows) console.log(line(columns.map((_, i) => cell(r[i]))));
3529
- }
3530
3553
  var analytics = program.command("analytics").description("Page analytics \u2014 what is tracking your published pages, and how they perform with real visitors");
3531
3554
  analytics.command("query <hogql>").description("Run a read-only HogQL query against this org's page-analytics events").option("--json", "print the raw JSON result instead of a table").action(async (hogql, opts) => {
3532
3555
  try {
@@ -3539,7 +3562,7 @@ analytics.command("query <hogql>").description("Run a read-only HogQL query agai
3539
3562
  console.log("Page analytics is not enabled for this organization \u2014 turn it on in the Erdo app, then query real traffic here.");
3540
3563
  return;
3541
3564
  }
3542
- printAnalyticsTable(res.columns, res.rows);
3565
+ printAlignedTable(res.columns, res.rows);
3543
3566
  if (res.truncated) console.log(`
3544
3567
  (rows truncated at the cap \u2014 aggregate further or add a tighter filter/LIMIT)`);
3545
3568
  } catch (e) {
@@ -3570,7 +3593,7 @@ analytics.command("tracking").description("Show which analytics destinations thi
3570
3593
  rows.push([d.kind, d.enabled ? "on" : "configured, off", d.public_id ?? "", d.provider ?? "", ""]);
3571
3594
  }
3572
3595
  }
3573
- printAnalyticsTable(["kind", "status", "public id", "provider", "what it does"], rows);
3596
+ printAlignedTable(["kind", "status", "public id", "provider", "what it does"], rows);
3574
3597
  console.log(`
3575
3598
  session replay input masking: ${res.mask_inputs ? "on" : "OFF \u2014 form values are recorded"}`);
3576
3599
  console.log(`consent: ${res.consent}${res.consent === "required" ? " (recording waits on a consent banner, so thin volume may be the gate, not the traffic)" : ""}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Erdo CLI — drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {