@erdoai/cli 0.140.1 → 0.140.2
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 +45 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1217,6 +1217,15 @@ var ErdoClient = class {
|
|
|
1217
1217
|
const qs = q.toString();
|
|
1218
1218
|
return this.request("GET", `/v1/datasets${qs ? `?${qs}` : ""}`);
|
|
1219
1219
|
}
|
|
1220
|
+
getDatasetRowActions(slug, opts) {
|
|
1221
|
+
const q = new URLSearchParams({ dataset: slug });
|
|
1222
|
+
if (opts?.include_receipts) q.set("include_receipts", "true");
|
|
1223
|
+
if (opts?.include_unresolved) q.set("include_unresolved", "true");
|
|
1224
|
+
return this.request("GET", `/v1/dataset-row-actions?${q.toString()}`);
|
|
1225
|
+
}
|
|
1226
|
+
setDatasetRowAction(input) {
|
|
1227
|
+
return this.request("PUT", "/v1/dataset-row-actions", input, false);
|
|
1228
|
+
}
|
|
1220
1229
|
listDatasetUserPermissions(slug) {
|
|
1221
1230
|
return this.request("GET", `/v1/datasets/${encodeURIComponent(slug)}/permissions/users`);
|
|
1222
1231
|
}
|
|
@@ -2450,6 +2459,19 @@ function readJSONObject(file, label) {
|
|
|
2450
2459
|
}
|
|
2451
2460
|
return parsed;
|
|
2452
2461
|
}
|
|
2462
|
+
async function readJSONInput(value, label) {
|
|
2463
|
+
if (value !== "-") return readJSONObject(value, label);
|
|
2464
|
+
let parsed;
|
|
2465
|
+
try {
|
|
2466
|
+
parsed = JSON.parse(await readAllStdin());
|
|
2467
|
+
} catch (error) {
|
|
2468
|
+
throw new Error(`${label} must contain valid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
2469
|
+
}
|
|
2470
|
+
if (parsed === null || Array.isArray(parsed) || typeof parsed !== "object") {
|
|
2471
|
+
throw new Error(`${label} must contain one JSON object`);
|
|
2472
|
+
}
|
|
2473
|
+
return parsed;
|
|
2474
|
+
}
|
|
2453
2475
|
function requireOutreachProject() {
|
|
2454
2476
|
if (!process.env.ERDO_PROJECT?.trim()) {
|
|
2455
2477
|
throw new Error(
|
|
@@ -6961,6 +6983,29 @@ voiceAgentsCmd.command("whatsapp-replies <slug>").description("Turn a voice agen
|
|
|
6961
6983
|
}
|
|
6962
6984
|
});
|
|
6963
6985
|
var datasetsCmd = program.command("datasets").description("Datasets");
|
|
6986
|
+
var datasetRowActionsCmd = datasetsCmd.command("row-actions").description("Read and replace actions triggered by rows arriving in a dataset");
|
|
6987
|
+
datasetRowActionsCmd.command("get <slug>").description("Read the row-action declarations and optional bounded diagnostics for a dataset").option("--include-receipts", "include bounded provider receipt diagnostics").option("--include-unresolved", "include bounded unresolved lookup diagnostics").action(async (slug, opts) => {
|
|
6988
|
+
try {
|
|
6989
|
+
print(await new ErdoClient().getDatasetRowActions(slug, {
|
|
6990
|
+
...opts.includeReceipts ? { include_receipts: true } : {},
|
|
6991
|
+
...opts.includeUnresolved ? { include_unresolved: true } : {}
|
|
6992
|
+
}));
|
|
6993
|
+
} catch (e) {
|
|
6994
|
+
fail(e);
|
|
6995
|
+
}
|
|
6996
|
+
});
|
|
6997
|
+
datasetRowActionsCmd.command("set").description("Replace one row-action declaration from a JSON file, or from stdin with --file -").requiredOption("-f, --file <path>", "one JSON declaration object; use - to read exactly one object from stdin").action(async (opts) => {
|
|
6998
|
+
try {
|
|
6999
|
+
const input = await readJSONInput(opts.file, "--file");
|
|
7000
|
+
const dataset = typeof input.dataset === "string" ? input.dataset.trim() : "";
|
|
7001
|
+
const name = typeof input.name === "string" ? input.name.trim() : "";
|
|
7002
|
+
if (!dataset) throw new Error("--file dataset must be a non-empty string");
|
|
7003
|
+
if (!name) throw new Error("--file name must be a non-empty string");
|
|
7004
|
+
print(await new ErdoClient().setDatasetRowAction(input));
|
|
7005
|
+
} catch (e) {
|
|
7006
|
+
fail(e);
|
|
7007
|
+
}
|
|
7008
|
+
});
|
|
6964
7009
|
var datasetPermissionsCmd = datasetsCmd.command("permissions").description("Manage dataset user permissions");
|
|
6965
7010
|
datasetPermissionsCmd.command("list <slug>").option("--json", "output raw JSON").action(async (slug, opts) => {
|
|
6966
7011
|
try {
|