@erdoai/cli 0.222.0 → 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 +28 -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
  }
@@ -9102,7 +9119,12 @@ datasetsCmd.command("fetch <slug>").description(
9102
9119
  ).option(
9103
9120
  "--revision <id>",
9104
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)"
9105
- ).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(
9106
9128
  async (slug, opts) => {
9107
9129
  try {
9108
9130
  print(
@@ -9110,7 +9132,10 @@ datasetsCmd.command("fetch <slug>").description(
9110
9132
  sql_query: opts.sql,
9111
9133
  limit: opts.limit,
9112
9134
  filter_names: opts.filter.length ? opts.filter : void 0,
9113
- 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
9114
9139
  })
9115
9140
  );
9116
9141
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.222.0",
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": {