@erdoai/cli 0.77.0 → 0.78.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.
- package/dist/index.js +24 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -940,8 +940,14 @@ var ErdoClient = class {
|
|
|
940
940
|
}
|
|
941
941
|
// The org's dataset vocabulary: every purpose in use, its description, and
|
|
942
942
|
// the dataset that established it (the canonical write target for that role).
|
|
943
|
-
|
|
944
|
-
|
|
943
|
+
// scope="managed" reads the same across every client organization a manager
|
|
944
|
+
// account operates; each entry then names its organization and its
|
|
945
|
+
// established_by slug is org-qualified, so it can be queried as-is.
|
|
946
|
+
listDatasetPurposes(params) {
|
|
947
|
+
const q = new URLSearchParams();
|
|
948
|
+
if (params?.scope) q.set("scope", params.scope);
|
|
949
|
+
const qs = q.toString();
|
|
950
|
+
return this.request("GET", `/v1/datasets-purposes${qs ? `?${qs}` : ""}`);
|
|
945
951
|
}
|
|
946
952
|
// Correct which dataset carries a purpose. Pass `purpose` to set one,
|
|
947
953
|
// `clear_purpose` to remove it; moving a purpose is clearing it from the old
|
|
@@ -4977,17 +4983,28 @@ datasetsCmd.command("list").description("List datasets").option(
|
|
|
4977
4983
|
});
|
|
4978
4984
|
datasetsCmd.command("purposes").description(
|
|
4979
4985
|
"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
|
-
).
|
|
4986
|
+
).option(
|
|
4987
|
+
"--scope <own|managed>",
|
|
4988
|
+
"whose vocabulary to read: own (default) or managed, which reads every client organization a manager account operates and prints the organization alongside each purpose"
|
|
4989
|
+
).action(async (opts) => {
|
|
4981
4990
|
try {
|
|
4982
|
-
const
|
|
4991
|
+
const scope = opts.scope?.toLowerCase();
|
|
4992
|
+
if (scope && scope !== "own" && scope !== "managed") {
|
|
4993
|
+
fail(new Error("--scope must be own or managed"));
|
|
4994
|
+
return;
|
|
4995
|
+
}
|
|
4996
|
+
const { purposes, message } = await new ErdoClient().listDatasetPurposes({ scope });
|
|
4983
4997
|
if (purposes.length === 0) {
|
|
4984
|
-
console.error("(no dataset purposes established yet)");
|
|
4998
|
+
console.error(message ? `(${message})` : "(no dataset purposes established yet)");
|
|
4985
4999
|
return;
|
|
4986
5000
|
}
|
|
4987
|
-
for (const p of purposes)
|
|
5001
|
+
for (const p of purposes) {
|
|
5002
|
+
const target = p.established_by_dataset_slug ?? p.established_by_dataset_id;
|
|
5003
|
+
const count = `${p.dataset_count} dataset${p.dataset_count === 1 ? "" : "s"}`;
|
|
4988
5004
|
console.log(
|
|
4989
|
-
`${p.
|
|
5005
|
+
scope === "managed" ? `${p.organization_slug ?? "-"} ${p.purpose} ${target} ${count} ${p.description}` : `${p.purpose} ${target} ${count} ${p.description}`
|
|
4990
5006
|
);
|
|
5007
|
+
}
|
|
4991
5008
|
} catch (e) {
|
|
4992
5009
|
fail(e);
|
|
4993
5010
|
}
|