@erdoai/cli 0.231.0 → 0.232.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 +81 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1748,6 +1748,24 @@ var ErdoClient = class {
|
|
|
1748
1748
|
deleteDataset(slug) {
|
|
1749
1749
|
return this.request("DELETE", `/v1/datasets/${encodeURIComponent(slug)}`);
|
|
1750
1750
|
}
|
|
1751
|
+
// The /v1 endpoint is a DELETE, whose parameters Encore reads from the query
|
|
1752
|
+
// string, so the keys travel there and never in a body. Not replayed after a
|
|
1753
|
+
// network failure, so rows_affected reports this call's deletions.
|
|
1754
|
+
deleteDatasetRows(slug, input) {
|
|
1755
|
+
const query = new URLSearchParams();
|
|
1756
|
+
if ("delete_all" in input) {
|
|
1757
|
+
query.set("delete_all", "true");
|
|
1758
|
+
} else {
|
|
1759
|
+
query.set("key_column", input.key_column);
|
|
1760
|
+
for (const key of input.keys) query.append("keys", key);
|
|
1761
|
+
}
|
|
1762
|
+
return this.request(
|
|
1763
|
+
"DELETE",
|
|
1764
|
+
`/v1/datasets/${encodeURIComponent(slug)}/rows?${query.toString()}`,
|
|
1765
|
+
void 0,
|
|
1766
|
+
false
|
|
1767
|
+
);
|
|
1768
|
+
}
|
|
1751
1769
|
setDatasetPurpose(slug, input) {
|
|
1752
1770
|
return this.updateDatasetSchema(slug, input);
|
|
1753
1771
|
}
|
|
@@ -4428,7 +4446,7 @@ wsCmd.command("phase-add <slug>").description("Append a new phase to a workstrea
|
|
|
4428
4446
|
}
|
|
4429
4447
|
}
|
|
4430
4448
|
);
|
|
4431
|
-
wsCmd.command("set-state <slug>").description("Update a workstream's status / title / description / phase statuses").option("--status <status>", "active, awaiting_user, blocked, completed").option("--title <title>", "retitle").option("--description <text>", "describe current state / surface a blocker").option(
|
|
4449
|
+
wsCmd.command("set-state <slug>").description("Update a workstream's status / title / description / phase statuses").option("--status <status>", "active, awaiting_user, blocked, completed").option("--title <title>", "retitle").option("--description <text>", "describe current state / surface a blocker").option(
|
|
4432
4450
|
"--token-budget <millicents>",
|
|
4433
4451
|
"spend ceiling in millicents \u2014 100,000 per dollar, so 25000000 = $250; this is how you raise a ceiling a loop has spent through",
|
|
4434
4452
|
(v) => parseInt(v, 10)
|
|
@@ -4454,7 +4472,6 @@ wsCmd.command("set-state <slug>").description("Update a workstream's status / ti
|
|
|
4454
4472
|
status: opts.status,
|
|
4455
4473
|
title: opts.title,
|
|
4456
4474
|
description: opts.description,
|
|
4457
|
-
summary: opts.summary,
|
|
4458
4475
|
token_budget_millicents: opts.tokenBudget,
|
|
4459
4476
|
escalation_budget_per_day: opts.escalationBudget,
|
|
4460
4477
|
phase_updates: phaseUpdates.length > 0 ? phaseUpdates : void 0
|
|
@@ -8758,6 +8775,68 @@ datasetsCmd.command("write <slug>").description(
|
|
|
8758
8775
|
}
|
|
8759
8776
|
}
|
|
8760
8777
|
);
|
|
8778
|
+
var DELETE_ROWS_BATCH = 100;
|
|
8779
|
+
function parseDeleteKeys(raw) {
|
|
8780
|
+
const text = (readMaybeFile(raw) ?? "").trim();
|
|
8781
|
+
let keys;
|
|
8782
|
+
if (text.startsWith("[")) {
|
|
8783
|
+
try {
|
|
8784
|
+
keys = JSON.parse(text);
|
|
8785
|
+
} catch (error) {
|
|
8786
|
+
throw new Error(`--keys JSON must be valid: ${error instanceof Error ? error.message : String(error)}`);
|
|
8787
|
+
}
|
|
8788
|
+
if (!Array.isArray(keys) || keys.some((key) => typeof key !== "string" && typeof key !== "number")) {
|
|
8789
|
+
throw new Error("--keys JSON must be an array of strings");
|
|
8790
|
+
}
|
|
8791
|
+
keys = keys.map(String);
|
|
8792
|
+
} else {
|
|
8793
|
+
keys = text.split("\n");
|
|
8794
|
+
}
|
|
8795
|
+
const cleaned = [...new Set(keys.map((key) => key.trim()).filter(Boolean))];
|
|
8796
|
+
if (cleaned.length === 0) {
|
|
8797
|
+
throw new Error("--keys names no keys");
|
|
8798
|
+
}
|
|
8799
|
+
return cleaned;
|
|
8800
|
+
}
|
|
8801
|
+
datasetsCmd.command("delete-rows <slug>").description(
|
|
8802
|
+
"Permanently delete rows from a dataset (the erdo_delete_dataset_rows MCP tool): every row whose --key-column equals one of --keys, or with --all every row. Deleted rows also leave the change history, so restore-row cannot bring them back: fetch them first if you may want them. Nothing is deleted without --yes"
|
|
8803
|
+
).option("--key-column <column>", "the column to match --keys against").option("--keys <keys-or-@file>", "keys to delete: a JSON array, or one key per line; @path reads a file").option("--all", "delete every row instead of named keys").option("--yes", "confirm the permanent deletion").action(async (slug, opts) => {
|
|
8804
|
+
try {
|
|
8805
|
+
const keyColumn = opts.keyColumn?.trim();
|
|
8806
|
+
if (opts.all && (keyColumn || opts.keys !== void 0)) {
|
|
8807
|
+
throw new Error("--all cannot be combined with --key-column or --keys");
|
|
8808
|
+
}
|
|
8809
|
+
if (!opts.all && (!keyColumn || opts.keys === void 0)) {
|
|
8810
|
+
throw new Error("name the rows to delete with --key-column and --keys, or pass --all to delete every row");
|
|
8811
|
+
}
|
|
8812
|
+
const keys = opts.all ? [] : parseDeleteKeys(opts.keys);
|
|
8813
|
+
if (!opts.yes) {
|
|
8814
|
+
throw new Error(
|
|
8815
|
+
opts.all ? `deleting every row of ${slug} is permanent; rerun with --yes to delete them` : `deleting up to ${keys.length} key(s) from ${slug} is permanent; rerun with --yes to delete them`
|
|
8816
|
+
);
|
|
8817
|
+
}
|
|
8818
|
+
const client = new ErdoClient();
|
|
8819
|
+
if (opts.all) {
|
|
8820
|
+
print(await client.deleteDatasetRows(slug, { delete_all: true }));
|
|
8821
|
+
return;
|
|
8822
|
+
}
|
|
8823
|
+
let rowsAffected = 0;
|
|
8824
|
+
for (let start = 0; start < keys.length; start += DELETE_ROWS_BATCH) {
|
|
8825
|
+
const batch = keys.slice(start, start + DELETE_ROWS_BATCH);
|
|
8826
|
+
try {
|
|
8827
|
+
rowsAffected += (await client.deleteDatasetRows(slug, { key_column: keyColumn, keys: batch })).rows_affected;
|
|
8828
|
+
} catch (error) {
|
|
8829
|
+
if (start > 0) {
|
|
8830
|
+
console.error(`deleted ${rowsAffected} row(s) for the first ${start} of ${keys.length} keys before this failure`);
|
|
8831
|
+
}
|
|
8832
|
+
throw error;
|
|
8833
|
+
}
|
|
8834
|
+
}
|
|
8835
|
+
print({ rows_affected: rowsAffected, keys_requested: keys.length });
|
|
8836
|
+
} catch (e) {
|
|
8837
|
+
fail(e);
|
|
8838
|
+
}
|
|
8839
|
+
});
|
|
8761
8840
|
function readSchemaFile(path) {
|
|
8762
8841
|
const parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
8763
8842
|
const schema = Array.isArray(parsed) ? { columns: parsed } : parsed;
|