@erdoai/cli 0.27.0 → 0.28.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 +45 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -524,6 +524,21 @@ var ErdoClient = class {
524
524
  timezone
525
525
  });
526
526
  }
527
+ // Fetch rows from a dataset, optionally shaped by a SQL query and/or opting into
528
+ // named saved filters. filter_names are additive on top of the dataset's default
529
+ // filters — they narrow the result, never bypass a default. An unknown name is
530
+ // rejected server-side with the available names.
531
+ fetchDatasetContents(slug, opts) {
532
+ return this.request(
533
+ "POST",
534
+ `/v1/datasets/${encodeURIComponent(slug)}/fetch`,
535
+ {
536
+ sql_query: opts.sql_query,
537
+ limit: opts.limit,
538
+ filter_names: opts.filter_names
539
+ }
540
+ );
541
+ }
527
542
  uploadDatasetFile(body) {
528
543
  return this.request("POST", "/v1/datasets-upload", body);
529
544
  }
@@ -2236,6 +2251,24 @@ datasetsCmd.command("query <slug> <question>").description("Ask a natural-langua
2236
2251
  fail(e);
2237
2252
  }
2238
2253
  });
2254
+ datasetsCmd.command("fetch <slug>").description("Fetch rows from a dataset, optionally shaped by SQL and named filters").option("-q, --sql <query>", "SQL query to filter/transform the rows").option("-l, --limit <n>", "max rows to return", (v) => parseInt(v, 10)).option(
2255
+ "-f, --filter <name>",
2256
+ "opt into a saved filter by name (repeatable); additive on top of the dataset's default filters (see: erdo datasets filter list <slug>)",
2257
+ (v, acc) => acc.concat(v),
2258
+ []
2259
+ ).action(async (slug, opts) => {
2260
+ try {
2261
+ print(
2262
+ await new ErdoClient().fetchDatasetContents(slug, {
2263
+ sql_query: opts.sql,
2264
+ limit: opts.limit,
2265
+ filter_names: opts.filter.length ? opts.filter : void 0
2266
+ })
2267
+ );
2268
+ } catch (e) {
2269
+ fail(e);
2270
+ }
2271
+ });
2239
2272
  var MAX_UPLOAD_BYTES = 20 * 1024 * 1024;
2240
2273
  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) => {
2241
2274
  try {
@@ -2375,15 +2408,24 @@ pipelinesCmd.command("get <slug>").description("Show one event pipeline \u2014 s
2375
2408
  fail(e);
2376
2409
  }
2377
2410
  });
2378
- filterCmd.command("add <slug>").description("Add a default filter to a dataset").requiredOption(
2411
+ filterCmd.command("add <slug>").description("Add a filter to a dataset (default-on unless --no-default)").requiredOption(
2379
2412
  "--where <condition>",
2380
2413
  "a '<column> <operator> <value>' condition (repeatable, AND-combined), e.g. --where 'email contains @example.com'. Operators: " + OPERATORS.join(", ") + " (for 'between' use 'col between 10,100')",
2381
2414
  collect,
2382
2415
  []
2383
- ).option("--name <name>", "optional human-readable label, e.g. 'Exclude test submissions'").action(async (slug, opts) => {
2416
+ ).option("--name <name>", "optional human-readable label, e.g. 'Exclude test submissions'").option(
2417
+ "--no-default",
2418
+ "save as a named view that reads opt into with 'datasets fetch --filter <name>', instead of applying to every read"
2419
+ ).action(async (slug, opts) => {
2384
2420
  try {
2385
2421
  const conditions = opts.where.map(parseCondition);
2386
- print(await new ErdoClient().createDatasetFilter(slug, { name: opts.name, conditions }));
2422
+ print(
2423
+ await new ErdoClient().createDatasetFilter(slug, {
2424
+ name: opts.name,
2425
+ conditions,
2426
+ is_default: opts.default === false ? false : void 0
2427
+ })
2428
+ );
2387
2429
  } catch (e) {
2388
2430
  fail(e);
2389
2431
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {