@erdoai/cli 0.196.0 → 0.198.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 +93 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1324,12 +1324,40 @@ var ErdoClient = class {
|
|
|
1324
1324
|
if (params?.actor_kind) q.set("actor_kind", params.actor_kind);
|
|
1325
1325
|
if (params?.limit) q.set("limit", String(params.limit));
|
|
1326
1326
|
if (params?.offset) q.set("offset", String(params.offset));
|
|
1327
|
+
if (params?.after_seq !== void 0) q.set("after_seq", String(params.after_seq));
|
|
1327
1328
|
const qs = q.toString();
|
|
1328
1329
|
return this.request(
|
|
1329
1330
|
"GET",
|
|
1330
1331
|
`/v1/activity/history${qs ? `?${qs}` : ""}`
|
|
1331
1332
|
);
|
|
1332
1333
|
}
|
|
1334
|
+
// --- outbound webhook subscriptions ---
|
|
1335
|
+
listWebhooks() {
|
|
1336
|
+
return this.request("GET", "/v1/webhooks");
|
|
1337
|
+
}
|
|
1338
|
+
createWebhook(input) {
|
|
1339
|
+
return this.request("POST", "/v1/webhooks", input);
|
|
1340
|
+
}
|
|
1341
|
+
deleteWebhook(id) {
|
|
1342
|
+
return this.request("DELETE", `/v1/webhooks/${encodeURIComponent(id)}`);
|
|
1343
|
+
}
|
|
1344
|
+
listWebhookDeliveries(id, params) {
|
|
1345
|
+
const q = new URLSearchParams();
|
|
1346
|
+
if (params?.status) q.set("status", params.status);
|
|
1347
|
+
if (params?.limit !== void 0) q.set("limit", String(params.limit));
|
|
1348
|
+
if (params?.offset !== void 0) q.set("offset", String(params.offset));
|
|
1349
|
+
const qs = q.toString();
|
|
1350
|
+
return this.request(
|
|
1351
|
+
"GET",
|
|
1352
|
+
`/v1/webhooks/${encodeURIComponent(id)}/deliveries${qs ? `?${qs}` : ""}`
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
retryWebhookDelivery(id, deliveryId) {
|
|
1356
|
+
return this.request(
|
|
1357
|
+
"POST",
|
|
1358
|
+
`/v1/webhooks/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}/retry`
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1333
1361
|
// --- knowledge review queue ---
|
|
1334
1362
|
listReviewItems(params) {
|
|
1335
1363
|
const q = new URLSearchParams();
|
|
@@ -6315,16 +6343,20 @@ function renderHistory(events) {
|
|
|
6315
6343
|
}
|
|
6316
6344
|
}
|
|
6317
6345
|
}
|
|
6318
|
-
program.command("history").description("The org history \u2014 who did what, when, under whose authority").option("--since <when>", "start of the window: a duration (2h, 3d) or RFC3339 (default 24h)"
|
|
6346
|
+
program.command("history").description("The org history \u2014 who did what, when, under whose authority").option("--since <when>", "start of the window: a duration (2h, 3d) or RFC3339 (default 24h; none with --after-seq)").option("--until <when>", "end of the window: a duration or RFC3339 timestamp").option("--actor-kind <kind>", "user | agent | system | api_token | scoped_token").option("--actor <user-id>", "only actions by this user id").option("--resource <type:id>", "only actions on this resource, e.g. page:<id>").option("--verb <v>", "comma-separated verbs, e.g. approval.decided,page.published").option("-n, --limit <n>", "max events (default 50, max 200)", (v) => parseInt(v, 10)).option("--after-seq <n>", "forward cursor: entries after this seq, oldest first (0 = from the start); prints next_after_seq", (v) => parseInt(v, 10)).option("--json", "raw events JSON").action(
|
|
6319
6347
|
async (opts) => {
|
|
6320
6348
|
try {
|
|
6321
6349
|
const params = {};
|
|
6322
|
-
params.since = parseWhen(opts.since || "24h");
|
|
6350
|
+
if (opts.afterSeq === void 0 || opts.since) params.since = parseWhen(opts.since || "24h");
|
|
6323
6351
|
if (opts.until) params.until = parseWhen(opts.until);
|
|
6324
6352
|
if (opts.actorKind) params.actor_kind = opts.actorKind;
|
|
6325
6353
|
if (opts.actor) params.actor_user_id = opts.actor;
|
|
6326
6354
|
if (opts.verb) params.verbs = opts.verb;
|
|
6327
6355
|
if (opts.limit) params.limit = opts.limit;
|
|
6356
|
+
if (opts.afterSeq !== void 0) {
|
|
6357
|
+
if (!Number.isInteger(opts.afterSeq) || opts.afterSeq < 0) throw new Error("--after-seq must be 0 or a next_after_seq value");
|
|
6358
|
+
params.after_seq = opts.afterSeq;
|
|
6359
|
+
}
|
|
6328
6360
|
if (opts.resource) {
|
|
6329
6361
|
const idx = opts.resource.indexOf(":");
|
|
6330
6362
|
if (idx === -1) {
|
|
@@ -6339,6 +6371,11 @@ program.command("history").description("The org history \u2014 who did what, whe
|
|
|
6339
6371
|
return;
|
|
6340
6372
|
}
|
|
6341
6373
|
const events = res.events ?? [];
|
|
6374
|
+
const cursor = opts.afterSeq !== void 0 ? `next_after_seq ${res.next_after_seq ?? opts.afterSeq}` : "";
|
|
6375
|
+
if (events.length === 0 && cursor) {
|
|
6376
|
+
console.log(`No history after seq ${opts.afterSeq} yet; ${cursor}.`);
|
|
6377
|
+
return;
|
|
6378
|
+
}
|
|
6342
6379
|
if (events.length === 0) {
|
|
6343
6380
|
const filters = [
|
|
6344
6381
|
`since ${opts.since || "24h"}`,
|
|
@@ -6356,12 +6393,65 @@ program.command("history").description("The org history \u2014 who did what, whe
|
|
|
6356
6393
|
}
|
|
6357
6394
|
renderHistory(events);
|
|
6358
6395
|
console.log(`
|
|
6359
|
-
${events.length} event${events.length === 1 ? "" : "s"}.`);
|
|
6396
|
+
${events.length} event${events.length === 1 ? "" : "s"}${cursor ? `; ${cursor}` : ""}.`);
|
|
6360
6397
|
} catch (e) {
|
|
6361
6398
|
fail(e);
|
|
6362
6399
|
}
|
|
6363
6400
|
}
|
|
6364
6401
|
);
|
|
6402
|
+
var webhooksCmd = program.command("webhooks").description("Manage outbound webhook subscriptions and inspect deliveries");
|
|
6403
|
+
webhooksCmd.command("list").description("List this org's webhook subscriptions").action(async () => {
|
|
6404
|
+
try {
|
|
6405
|
+
const result = await new ErdoClient().listWebhooks();
|
|
6406
|
+
print(result);
|
|
6407
|
+
} catch (e) {
|
|
6408
|
+
fail(e);
|
|
6409
|
+
}
|
|
6410
|
+
});
|
|
6411
|
+
webhooksCmd.command("create").description("Create a webhook subscription; the signing secret is shown once").requiredOption("--url <https-url>", "public HTTPS receiver URL").requiredOption("--verbs <list>", "comma-separated exact activity ledger verbs").option("--include-managed", "also receive events from currently managed orgs").action(async (opts) => {
|
|
6412
|
+
try {
|
|
6413
|
+
const verbs = opts.verbs.split(",").map((verb) => verb.trim());
|
|
6414
|
+
if (verbs.some((verb) => !verb)) throw new Error("--verbs must contain one or more non-empty verbs");
|
|
6415
|
+
const result = await new ErdoClient().createWebhook({
|
|
6416
|
+
url: opts.url,
|
|
6417
|
+
verbs,
|
|
6418
|
+
include_managed: Boolean(opts.includeManaged)
|
|
6419
|
+
});
|
|
6420
|
+
print(result);
|
|
6421
|
+
} catch (e) {
|
|
6422
|
+
fail(e);
|
|
6423
|
+
}
|
|
6424
|
+
});
|
|
6425
|
+
webhooksCmd.command("delete <id>").description("Deactivate a webhook subscription while retaining delivery history").action(async (id) => {
|
|
6426
|
+
try {
|
|
6427
|
+
print(await new ErdoClient().deleteWebhook(id));
|
|
6428
|
+
} catch (e) {
|
|
6429
|
+
fail(e);
|
|
6430
|
+
}
|
|
6431
|
+
});
|
|
6432
|
+
webhooksCmd.command("deliveries <id>").description("List deliveries for a webhook subscription").option("--status <status>", "pending | delivered | failed").option("-n, --limit <n>", "max rows", (v) => Number(v)).option("--offset <n>", "pagination offset", (v) => Number(v)).action(async (id, opts) => {
|
|
6433
|
+
try {
|
|
6434
|
+
if (opts.status && !["pending", "delivered", "failed"].includes(opts.status)) {
|
|
6435
|
+
throw new Error("--status must be pending, delivered, or failed");
|
|
6436
|
+
}
|
|
6437
|
+
for (const [name, value] of [["limit", opts.limit], ["offset", opts.offset]]) {
|
|
6438
|
+
if (value !== void 0 && (!Number.isSafeInteger(value) || value < (name === "limit" ? 1 : 0))) {
|
|
6439
|
+
throw new Error(`--${name} must be a ${name === "limit" ? "positive" : "non-negative"} integer`);
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
const result = await new ErdoClient().listWebhookDeliveries(id, opts);
|
|
6443
|
+
print(result);
|
|
6444
|
+
} catch (e) {
|
|
6445
|
+
fail(e);
|
|
6446
|
+
}
|
|
6447
|
+
});
|
|
6448
|
+
webhooksCmd.command("retry <id> <delivery-id>").description("Retry a failed webhook delivery").action(async (id, deliveryId) => {
|
|
6449
|
+
try {
|
|
6450
|
+
print(await new ErdoClient().retryWebhookDelivery(id, deliveryId));
|
|
6451
|
+
} catch (e) {
|
|
6452
|
+
fail(e);
|
|
6453
|
+
}
|
|
6454
|
+
});
|
|
6365
6455
|
var reviewsCmd = program.command("reviews").description(
|
|
6366
6456
|
"The Knowledge Review queue \u2014 knowledge patches the critic proposes, investigations, and deduplicated failure signals awaiting a human decision"
|
|
6367
6457
|
);
|