@erdoai/cli 0.139.0 → 0.139.1

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 (2) hide show
  1. package/dist/index.js +33 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1223,6 +1223,9 @@ var ErdoClient = class {
1223
1223
  getDatasetDeclaredSchema(slug) {
1224
1224
  return this.request("POST", `/v1/datasets/${encodeURIComponent(slug)}/fetch`, { view: "declared_schema" });
1225
1225
  }
1226
+ getDatasetResourceSchema(slug) {
1227
+ return this.request("POST", `/v1/datasets/${encodeURIComponent(slug)}/fetch`, { view: "resource_schema" });
1228
+ }
1226
1229
  // Create an empty dataset with its declared columns. The server refuses a
1227
1230
  // create without a schema unless the purpose's columns are platform-defined.
1228
1231
  createDataset(input) {
@@ -7281,7 +7284,7 @@ Read one with: erdo datasets fetch ${res.dataset_slug} --revision <id> --sql "SE
7281
7284
  }
7282
7285
  });
7283
7286
  datasetsCmd.command("schema <slug>").alias("describe").description(
7284
- "Show physical columns by default, or the declared write contract with --declared. Physical columns are 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>'`."
7287
+ "Show physical columns by default, or the declared write contract with --declared. File datasets read the stored `data` table; integration datasets show their discovered resource tables and columns. For an integration dataset, choose a resource/table explicitly when fetching: `datasets fetch <slug> --sql 'SELECT * FROM <table>'`."
7285
7288
  ).option("--json", "print the raw JSON result instead of a table").option("--declared", "read the declared write contract (column names, type hints, required flags, semantic roles) instead of the physical columns").action(async (slug, opts) => {
7286
7289
  try {
7287
7290
  const client = new ErdoClient();
@@ -7310,7 +7313,35 @@ datasetsCmd.command("schema <slug>").alias("describe").description(
7310
7313
  );
7311
7314
  return;
7312
7315
  }
7313
- const res = await client.fetchDatasetContents(slug, { sql_query: "DESCRIBE data" });
7316
+ const res = await client.getDatasetResourceSchema(slug);
7317
+ if (!res || typeof res !== "object" || res.view !== "resource_schema")
7318
+ throw new Error("Invalid dataset schema response: the server did not answer the resource_schema view");
7319
+ if (res.schema_provenance === "resource_catalog") {
7320
+ const resources = res.resources ?? [];
7321
+ if (!Array.isArray(resources) || resources.some((resource) => !resource || !Array.isArray(resource.columns)))
7322
+ throw new Error("Invalid dataset schema response: malformed resource catalog");
7323
+ if (opts.json) {
7324
+ print(res);
7325
+ return;
7326
+ }
7327
+ if (!resources.length) {
7328
+ console.log(`${slug} has no discovered integration resources yet.`);
7329
+ return;
7330
+ }
7331
+ const rows = resources.flatMap(
7332
+ (resource) => resource.columns.length ? resource.columns.map((column) => [
7333
+ resource.table_name || resource.key || resource.name,
7334
+ column.name,
7335
+ column.type || ""
7336
+ ]) : [[resource.table_name || resource.key || resource.name, "", "(columns unavailable)"]]
7337
+ );
7338
+ printAlignedTable(["table", "column", "type"], rows);
7339
+ console.log(`
7340
+ Fetch a selected table with: erdo datasets fetch ${slug} --sql "SELECT * FROM <table>"`);
7341
+ return;
7342
+ }
7343
+ if (res.schema_provenance !== "dataset_storage" || !Array.isArray(res.columns) || !Array.isArray(res.rows))
7344
+ throw new Error("Invalid dataset schema response: malformed physical schema");
7314
7345
  if (opts.json) {
7315
7346
  print(res);
7316
7347
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.139.0",
3
+ "version": "0.139.1",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {