@erdoai/cli 0.77.0 → 0.79.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 +50 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -689,6 +689,16 @@ var ErdoClient = class {
689
689
  input
690
690
  );
691
691
  }
692
+ // The reverse of attachWorkstreamResource. The API reads a DELETE's fields
693
+ // from the query string, so these ride there rather than in a body. Omitting
694
+ // relationship_type removes every link the workstream holds to the resource.
695
+ detachWorkstreamResource(slug, input) {
696
+ const q = new URLSearchParams();
697
+ q.set("resource_type", input.resource_type);
698
+ q.set("resource_id", input.resource_id);
699
+ if (input.relationship_type) q.set("relationship_type", input.relationship_type);
700
+ return this.request("DELETE", `/v1/workstreams/${encodeURIComponent(slug)}/resources?${q.toString()}`);
701
+ }
692
702
  // --- experiments ---
693
703
  listExperiments(params) {
694
704
  const q = new URLSearchParams();
@@ -940,8 +950,14 @@ var ErdoClient = class {
940
950
  }
941
951
  // The org's dataset vocabulary: every purpose in use, its description, and
942
952
  // the dataset that established it (the canonical write target for that role).
943
- listDatasetPurposes() {
944
- return this.request("GET", `/v1/datasets-purposes`);
953
+ // scope="managed" reads the same across every client organization a manager
954
+ // account operates; each entry then names its organization and its
955
+ // established_by slug is org-qualified, so it can be queried as-is.
956
+ listDatasetPurposes(params) {
957
+ const q = new URLSearchParams();
958
+ if (params?.scope) q.set("scope", params.scope);
959
+ const qs = q.toString();
960
+ return this.request("GET", `/v1/datasets-purposes${qs ? `?${qs}` : ""}`);
945
961
  }
946
962
  // Correct which dataset carries a purpose. Pass `purpose` to set one,
947
963
  // `clear_purpose` to remove it; moving a purpose is clearing it from the old
@@ -2434,6 +2450,22 @@ wsCmd.command("attach <slug>").description("Link a resource (page, dataset, hear
2434
2450
  }
2435
2451
  }
2436
2452
  );
2453
+ wsCmd.command("detach <slug>").description("Unlink a resource from a workstream (the reverse of attach)").requiredOption("--type <resourceType>", "resource type (page, dataset, heartbeat, experiment_run, \u2026)").requiredOption("--id <resourceId>", "the resource's UUID").option(
2454
+ "--rel <relationshipType>",
2455
+ "which link to remove: output | input | evidence | monitoring | subject | parent | child | running. Omit to remove every link to this resource"
2456
+ ).action(async (slug, opts) => {
2457
+ try {
2458
+ print(
2459
+ await new ErdoClient().detachWorkstreamResource(slug, {
2460
+ resource_type: opts.type,
2461
+ resource_id: opts.id,
2462
+ relationship_type: opts.rel
2463
+ })
2464
+ );
2465
+ } catch (e) {
2466
+ fail(e);
2467
+ }
2468
+ });
2437
2469
  var VARIANT_SPEC_KEYS = /* @__PURE__ */ new Set([
2438
2470
  "key",
2439
2471
  "label",
@@ -4977,17 +5009,28 @@ datasetsCmd.command("list").description("List datasets").option(
4977
5009
  });
4978
5010
  datasetsCmd.command("purposes").description(
4979
5011
  "List the org's dataset purposes \u2014 the vocabulary of dataset roles in use (e.g. leads, page events). The established_by slug is the canonical dataset for that role: write there rather than creating a sibling (one purpose = one dataset per org)."
4980
- ).action(async () => {
5012
+ ).option(
5013
+ "--scope <own|managed>",
5014
+ "whose vocabulary to read: own (default) or managed, which reads every client organization a manager account operates and prints the organization alongside each purpose"
5015
+ ).action(async (opts) => {
4981
5016
  try {
4982
- const { purposes } = await new ErdoClient().listDatasetPurposes();
5017
+ const scope = opts.scope?.toLowerCase();
5018
+ if (scope && scope !== "own" && scope !== "managed") {
5019
+ fail(new Error("--scope must be own or managed"));
5020
+ return;
5021
+ }
5022
+ const { purposes, message } = await new ErdoClient().listDatasetPurposes({ scope });
4983
5023
  if (purposes.length === 0) {
4984
- console.error("(no dataset purposes established yet)");
5024
+ console.error(message ? `(${message})` : "(no dataset purposes established yet)");
4985
5025
  return;
4986
5026
  }
4987
- for (const p of purposes)
5027
+ for (const p of purposes) {
5028
+ const target = p.established_by_dataset_slug ?? p.established_by_dataset_id;
5029
+ const count = `${p.dataset_count} dataset${p.dataset_count === 1 ? "" : "s"}`;
4988
5030
  console.log(
4989
- `${p.purpose} ${p.established_by_dataset_slug ?? p.established_by_dataset_id} ${p.dataset_count} dataset${p.dataset_count === 1 ? "" : "s"} ${p.description}`
5031
+ scope === "managed" ? `${p.organization_slug ?? "-"} ${p.purpose} ${target} ${count} ${p.description}` : `${p.purpose} ${target} ${count} ${p.description}`
4990
5032
  );
5033
+ }
4991
5034
  } catch (e) {
4992
5035
  fail(e);
4993
5036
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.77.0",
3
+ "version": "0.79.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {