@erdoai/cli 0.217.1 → 0.223.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 (2) hide show
  1. package/dist/index.js +39 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -192,6 +192,16 @@ function parseCSV(text) {
192
192
  return rows;
193
193
  }
194
194
 
195
+ // src/order-by.ts
196
+ function parseOrderByOption(value) {
197
+ const match = /^(.*):(asc|desc)$/i.exec(value);
198
+ const column = (match ? match[1] : value).trim();
199
+ if (!column) {
200
+ throw new Error(`--order-by needs a column name, got "${value}"`);
201
+ }
202
+ return match ? { column, direction: match[2].toLowerCase() } : { column };
203
+ }
204
+
195
205
  // src/knowledge-freshness.ts
196
206
  function knowledgeFreshnessFromOptions(opts) {
197
207
  const out = {};
@@ -1811,6 +1821,10 @@ var ErdoClient = class {
1811
1821
  //
1812
1822
  // revision_id runs the same read against a superseded storage revision instead
1813
1823
  // of the dataset's live contents — the ids come from listDatasetRevisions.
1824
+ //
1825
+ // order_by, offset and include_total_rows page a read without SQL: the storage
1826
+ // engine sorts and slices, and total_rows is the matched-row count when counted
1827
+ // or proven by a short last page. They do not combine with sql_query.
1814
1828
  fetchDatasetContents(slug, opts) {
1815
1829
  return this.request(
1816
1830
  "POST",
@@ -1819,7 +1833,10 @@ var ErdoClient = class {
1819
1833
  sql_query: opts.sql_query,
1820
1834
  limit: opts.limit,
1821
1835
  filter_names: opts.filter_names,
1822
- revision_id: opts.revision_id
1836
+ revision_id: opts.revision_id,
1837
+ order_by: opts.order_by,
1838
+ offset: opts.offset,
1839
+ include_total_rows: opts.include_total_rows
1823
1840
  }
1824
1841
  );
1825
1842
  }
@@ -2298,6 +2315,9 @@ var ErdoClient = class {
2298
2315
  if (limit) params.set("limit", String(limit));
2299
2316
  return this.request("GET", `/v1/knowledge-search?${params.toString()}`);
2300
2317
  }
2318
+ deleteKnowledge(id) {
2319
+ return this.request("DELETE", `/v1/knowledge/${encodeURIComponent(id)}`);
2320
+ }
2301
2321
  setKnowledgeVisibility(id, visibility) {
2302
2322
  return this.request("PATCH", `/v1/knowledge/${id}/visibility`, { visibility });
2303
2323
  }
@@ -9099,7 +9119,12 @@ datasetsCmd.command("fetch <slug>").description(
9099
9119
  ).option(
9100
9120
  "--revision <id>",
9101
9121
  "read a superseded storage revision instead of the live table \u2014 the same SQL runs against the contents this id names, so a version that was overwritten is still queryable (see: erdo datasets revisions <slug> for the ids)"
9102
- ).action(
9122
+ ).option(
9123
+ "--order-by <column[:desc]>",
9124
+ "sort without SQL by a column of the dataset, ascending unless suffixed :desc (repeatable; later keys break ties). Not with --sql.",
9125
+ (v, acc) => acc.concat(v),
9126
+ []
9127
+ ).option("--offset <n>", "skip this many sorted rows; with --limit it is a page. Not with --sql.", (v) => parseInt(v, 10)).option("--total", "also return total_rows, the count of every row the read matches. Not with --sql.").action(
9103
9128
  async (slug, opts) => {
9104
9129
  try {
9105
9130
  print(
@@ -9107,7 +9132,10 @@ datasetsCmd.command("fetch <slug>").description(
9107
9132
  sql_query: opts.sql,
9108
9133
  limit: opts.limit,
9109
9134
  filter_names: opts.filter.length ? opts.filter : void 0,
9110
- revision_id: opts.revision
9135
+ revision_id: opts.revision,
9136
+ order_by: opts.orderBy.length ? opts.orderBy.map(parseOrderByOption) : void 0,
9137
+ offset: opts.offset,
9138
+ include_total_rows: opts.total || void 0
9111
9139
  })
9112
9140
  );
9113
9141
  } catch (e) {
@@ -10985,6 +11013,14 @@ knowledgeCmd.command("visibility <id> <visibility>").description(
10985
11013
  fail(e);
10986
11014
  }
10987
11015
  });
11016
+ knowledgeCmd.command("delete <id>").description("Delete a Knowledge object you can manage (same as the erdo_delete_knowledge MCP tool)").action(async (id) => {
11017
+ try {
11018
+ await new ErdoClient().deleteKnowledge(id);
11019
+ print({ deleted: id });
11020
+ } catch (e) {
11021
+ fail(e);
11022
+ }
11023
+ });
10988
11024
  knowledgeCmd.command("attach <objectId> <file>").description(
10989
11025
  "Attach an image or other small binary to a knowledge object as an org-hosted asset, and print its asset id \u2014 the value a page's assetId field takes. Pass a local path, or --url to have the service download it (the only path for video)."
10990
11026
  ).option("--url <sourceUrl>", "download from this URL instead of reading a local file").option(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.217.1",
3
+ "version": "0.223.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {