@erdoai/cli 0.263.0 → 0.265.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 +78 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2472,6 +2472,23 @@ var ErdoClient = class {
2472
2472
  listKnowledgeAssets(objectID) {
2473
2473
  return this.request("GET", `/v1/knowledge/${encodeURIComponent(objectID)}/attachments`);
2474
2474
  }
2475
+ uploadFile(input) {
2476
+ return this.request("POST", "/v1/files", input);
2477
+ }
2478
+ listFiles(options) {
2479
+ const params = new URLSearchParams();
2480
+ for (const key of ["limit", "offset", "source", "media_type", "query"]) {
2481
+ const value = options?.[key];
2482
+ if (value !== void 0 && value !== "") params.set(key, String(value));
2483
+ }
2484
+ return this.request("GET", `/v1/files${params.size ? `?${params}` : ""}`);
2485
+ }
2486
+ getFile(id) {
2487
+ return this.request("GET", `/v1/files/${encodeURIComponent(id)}`);
2488
+ }
2489
+ deleteFile(id) {
2490
+ return this.request("DELETE", `/v1/files/${encodeURIComponent(id)}`);
2491
+ }
2475
2492
  // --- automations ---
2476
2493
  listHeartbeats(opts = {}) {
2477
2494
  const params = new URLSearchParams();
@@ -9242,8 +9259,8 @@ function readSchemaFile(path) {
9242
9259
  return schema;
9243
9260
  }
9244
9261
  datasetsCmd.command("create <name>").description(
9245
- "Create an empty dataset with its columns declared up front. Every write is checked against the schema, which is set now rather than taken from the first rows. --schema is required unless the purpose is one whose columns Erdo defines (page events, widget events, widget leads)."
9246
- ).option("--schema <file>", "JSON file containing { columns: [...] } or a columns array").option("--purpose <purpose>", "the dataset's role in the org vocabulary, e.g. leads (see `erdo datasets purposes`)").option("--purpose-description <text>", "what writes and reads this purpose").option("--description <text>", "what the dataset holds").option("--separate", "deliberately create a second dataset for a purpose the org already has").action(async (name, opts) => {
9262
+ "Create an empty dataset with its columns declared up front. Every write is checked against the schema, which is set now rather than taken from the first rows. Schema columns support allowed_values, integer, and minimum; constraints support immutable_groups, required_together, server stamps, and less_or_equal numeric pairs. --schema is required unless the purpose is one whose columns Erdo defines (page events, widget events, widget leads)."
9263
+ ).option("--schema <file>", "JSON columns array or { columns, constraints } schema object").option("--purpose <purpose>", "the dataset's role in the org vocabulary, e.g. leads (see `erdo datasets purposes`)").option("--purpose-description <text>", "what writes and reads this purpose").option("--description <text>", "what the dataset holds").option("--separate", "deliberately create a second dataset for a purpose the org already has").action(async (name, opts) => {
9247
9264
  try {
9248
9265
  const result = await new ErdoClient().createDataset({
9249
9266
  name,
@@ -9276,8 +9293,8 @@ datasetViewCmd.command("create <source>").description(
9276
9293
  }
9277
9294
  });
9278
9295
  datasetsCmd.command("ensure <purpose>").description(
9279
- "Create or reuse the one dataset for a purpose and verify its declared producer contract. Refuses legacy splits and incompatible populated datasets instead of choosing silently."
9280
- ).requiredOption("--schema <file>", "JSON file containing { columns: [...] } or a columns array").option("--name <name>", "dataset name when creation is required").option("--description <text>", "dataset description when creation is required").option("--purpose-description <text>", "what writes and reads this purpose").option("--preferred-dataset <slug>", "existing bound dataset slug or id to adopt").option("--reviewed-optional-addition <name>", "producer-reviewed optional column to add atomically; repeat for multiple columns", (value, previous = []) => [...previous, value], []).option("--email-column <name>", "for a leads purpose: which declared column holds the email (default email)").option("--phone-column <name>", "for a leads purpose: which declared column holds the phone (default phone)").action(async (purpose, opts) => {
9296
+ "Create or reuse the one dataset for a purpose and verify its declared producer contract. Schema columns support allowed_values, integer, and minimum; constraints support immutable_groups, required_together, server stamps, and less_or_equal numeric pairs. Refuses legacy splits and incompatible populated datasets instead of choosing silently."
9297
+ ).requiredOption("--schema <file>", "JSON columns array or { columns, constraints } schema object").option("--name <name>", "dataset name when creation is required").option("--description <text>", "dataset description when creation is required").option("--purpose-description <text>", "what writes and reads this purpose").option("--preferred-dataset <slug>", "existing bound dataset slug or id to adopt").option("--reviewed-optional-addition <name>", "producer-reviewed optional column to add atomically; repeat for multiple columns", (value, previous = []) => [...previous, value], []).option("--email-column <name>", "for a leads purpose: which declared column holds the email (default email)").option("--phone-column <name>", "for a leads purpose: which declared column holds the phone (default phone)").action(async (purpose, opts) => {
9281
9298
  try {
9282
9299
  const declaredSchema = readSchemaFile(opts.schema);
9283
9300
  const result = await new ErdoClient().ensureDataset({
@@ -9296,7 +9313,7 @@ datasetsCmd.command("ensure <purpose>").description(
9296
9313
  fail(e);
9297
9314
  }
9298
9315
  });
9299
- datasetsCmd.command("update-schema <slug>").description("Evolve an existing dataset's column contract. For populated lead-identity datasets, use add_column operations only; existing rows and lead ids are preserved.").requiredOption("--input <file>", "JSON request containing operations and optional class/purpose/owner/record/provenance changes").action(async (slug, opts) => {
9316
+ datasetsCmd.command("update-schema <slug>").description("Evolve an existing dataset's column contract. declare_schema columns support allowed_values, integer, and minimum; constraints support immutable_groups, required_together, server stamps, and less_or_equal numeric pairs. For populated lead-identity datasets, use add_column operations only; existing rows and lead ids are preserved.").requiredOption("--input <file>", "JSON request containing operations and optional class/purpose/owner/record/provenance changes").action(async (slug, opts) => {
9300
9317
  try {
9301
9318
  const input = JSON.parse(readFileSync5(opts.input, "utf8"));
9302
9319
  if (!input || typeof input !== "object" || Array.isArray(input)) {
@@ -11573,6 +11590,62 @@ declarationsCmd.command("upsert").description("Write one declaration. The same n
11573
11590
  }
11574
11591
  });
11575
11592
  var knowledgeCmd = program.command("knowledge").description("Knowledge objects");
11593
+ var filesCmd = program.command("files").description("Organization files");
11594
+ filesCmd.command("upload [path]").description("Upload a local file or download a public URL into the selected organization").option("--url <url>", "HTTP(S) source URL (downloaded by the service)").option("--filename <name>", "filename for a URL download").option("--source-ref <ref>", "stable retry target; the same bytes and ref return the existing file").option("--source <source>", "provenance: upload, download, generated, screenshot, code_output, email, or attachment_backfill").option("--access <access>", "org or private", "org").action(async (path, opts) => {
11595
+ try {
11596
+ if (Boolean(opts.url) === Boolean(path)) throw new Error("provide exactly one local path or --url");
11597
+ if (!(opts.access === "org" || opts.access === "private")) throw new Error("--access must be org or private");
11598
+ let input;
11599
+ if (opts.url) {
11600
+ const sourceURL = new URL(opts.url);
11601
+ if (!["http:", "https:"].includes(sourceURL.protocol) || sourceURL.username || sourceURL.password) throw new Error("--url must be an HTTP(S) URL without credentials");
11602
+ let filename = opts.filename;
11603
+ if (!filename) {
11604
+ try {
11605
+ filename = basename2(decodeURIComponent(sourceURL.pathname));
11606
+ } catch {
11607
+ filename = basename2(sourceURL.pathname);
11608
+ }
11609
+ }
11610
+ if (!filename || filename === "/") throw new Error("provide --filename when the URL has no filename");
11611
+ input = { filename: basename2(filename), source_url: opts.url, source: opts.source ?? "download", access: opts.access };
11612
+ } else {
11613
+ if (!path) throw new Error("provide a local path or --url");
11614
+ if (statSync2(path).size > 50 * 1024 * 1024) throw new Error("file exceeds the 50 MiB limit");
11615
+ const bytes = readFileSync5(path);
11616
+ if (!bytes.length) throw new Error("file is empty");
11617
+ if (bytes.length > 50 * 1024 * 1024) throw new Error("file exceeds the 50 MiB limit");
11618
+ input = { filename: basename2(path), content_base64: bytes.toString("base64"), source: opts.source ?? "upload", access: opts.access };
11619
+ }
11620
+ if (opts.sourceRef) input.source_ref = opts.sourceRef;
11621
+ print(await new ErdoClient().uploadFile(input));
11622
+ } catch (e) {
11623
+ fail(e);
11624
+ }
11625
+ });
11626
+ filesCmd.command("list").description("List files in the selected organization").option("--limit <n>", "page size (default 50, maximum 100)", (v) => parseInt(v, 10)).option("--offset <n>", "page offset", (v) => parseInt(v, 10)).option("--source <source>", "filter by source").option("--media-type <type>", "filter by media type").option("--query <text>", "search filenames").action(async (opts) => {
11627
+ try {
11628
+ if (opts.limit !== void 0 && (!Number.isInteger(opts.limit) || opts.limit < 1 || opts.limit > 100)) throw new Error("--limit must be an integer from 1 to 100");
11629
+ if (opts.offset !== void 0 && (!Number.isInteger(opts.offset) || opts.offset < 0)) throw new Error("--offset must be a non-negative integer");
11630
+ print(await new ErdoClient().listFiles({ limit: opts.limit, offset: opts.offset, source: opts.source, media_type: opts.mediaType, query: opts.query }));
11631
+ } catch (e) {
11632
+ fail(e);
11633
+ }
11634
+ });
11635
+ filesCmd.command("get <id>").description("Get file metadata and a short-lived signed URL").action(async (id) => {
11636
+ try {
11637
+ print(await new ErdoClient().getFile(id));
11638
+ } catch (e) {
11639
+ fail(e);
11640
+ }
11641
+ });
11642
+ filesCmd.command("delete <id>").description("Delete a file and its bytes").action(async (id) => {
11643
+ try {
11644
+ print(await new ErdoClient().deleteFile(id));
11645
+ } catch (e) {
11646
+ fail(e);
11647
+ }
11648
+ });
11576
11649
  knowledgeCmd.command("create").description("Create a Knowledge object").requiredOption("--title <title>", "title").requiredOption("--body <body>", "body text, or @file").option("--description <description>", "short description").option(
11577
11650
  "--type <type>",
11578
11651
  "snippet (durable context), skill (reusable instructions), dataset_note, or integration_model (a dated provider/API fact: needs --provider, --source-url, --verified-at and --stale-after)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.263.0",
3
+ "version": "0.265.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {