@erdoai/cli 0.197.0 → 0.199.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 +150 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,6 +14,23 @@ function advertiserVerificationAction(container) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// src/refresh.ts
|
|
17
|
+
function keepRunningCommand(state) {
|
|
18
|
+
return `erdo datasets refresh keep-running ${state.dataset_slug || "<slug>"}`;
|
|
19
|
+
}
|
|
20
|
+
function day(stamp) {
|
|
21
|
+
return stamp ? stamp.slice(0, 10) : void 0;
|
|
22
|
+
}
|
|
23
|
+
function describeAutoPause(state) {
|
|
24
|
+
if (state.job_state !== "auto_paused") return void 0;
|
|
25
|
+
const since = day(state.dormant_since);
|
|
26
|
+
const evidence = since ? `dormant since ${since}${state.days_without_reads !== void 0 ? `, no reads for ${state.days_without_reads} days` : ""}` : "nothing read, opened or ran its data for 14 days";
|
|
27
|
+
return `auto-paused (${evidence}) \u2014 reading the dataset, running it, or \`${keepRunningCommand(state)}\` resumes it`;
|
|
28
|
+
}
|
|
29
|
+
function describePendingPause(state) {
|
|
30
|
+
if (state.job_state !== "active" || state.keep_running || !state.pauses_after) return void 0;
|
|
31
|
+
const since = day(state.dormant_since);
|
|
32
|
+
return `pauses after ${state.pauses_after} unless its data is read or run${since ? ` (unused since ${since})` : ""} \u2014 keep it with \`${keepRunningCommand(state)}\``;
|
|
33
|
+
}
|
|
17
34
|
function describeRefreshTrigger(state) {
|
|
18
35
|
const event = describeEventTriggers(state);
|
|
19
36
|
if (state.disarmed) return event ? `disarmed \u2014 the experiment has settled; ${event}` : "disarmed \u2014 the experiment has settled";
|
|
@@ -21,6 +38,8 @@ function describeRefreshTrigger(state) {
|
|
|
21
38
|
if (state.strategy === "live_native_poll") return event ? `not running \u2014 native polling is unavailable; ${event}` : "not running \u2014 native polling is unavailable; configure script_js with a schedule or live_webhook";
|
|
22
39
|
if (!state.job_id) return event ? `not running \u2014 no linked job; ${event}` : "not running \u2014 no linked job; configure the refresh again";
|
|
23
40
|
if (state.activation_pending) return event ? `not running \u2014 activation pending; retry the complete configuration; ${event}` : "not running \u2014 activation pending; retry the complete configuration";
|
|
41
|
+
const autoPaused = describeAutoPause(state);
|
|
42
|
+
if (state.job_enabled === false && autoPaused) return event ? `not running \u2014 ${autoPaused}; ${event}` : `not running \u2014 ${autoPaused}`;
|
|
24
43
|
if (state.job_enabled === false) return event ? `not running \u2014 the linked job is disabled; ${event}` : "not running \u2014 the linked job is disabled";
|
|
25
44
|
const trigger = state.schedule ? state.schedule_enabled === false ? `cron ${state.schedule} is disabled` : `cron: ${state.schedule}` : state.refresh_on_view_enabled !== false ? "runs on view \u2014 when a bound page is opened and the data is stale" : event ? void 0 : "manual only \u2014 page views do not trigger this refresh";
|
|
26
45
|
return [trigger, event, state.test_run_success === false ? "configuration test failed" : void 0].filter(Boolean).join("; ");
|
|
@@ -53,6 +72,13 @@ function describeRefreshWrites(strategy, mode, key, liveMode) {
|
|
|
53
72
|
if (strategy?.startsWith("live_")) return liveMode === "append" ? "append \u2014 each incoming event adds rows" : "replace \u2014 each incoming event replaces the current rows";
|
|
54
73
|
return mode === "upsert" ? `upsert${key ? ` on ${key}` : ""} \u2014 rows outside what the recipe returns are kept` : "replace \u2014 rows the recipe does not return are deleted";
|
|
55
74
|
}
|
|
75
|
+
function formatRefreshJobRow(r) {
|
|
76
|
+
const notes = [];
|
|
77
|
+
if (r.state === "auto_paused") notes.push(`auto-paused${r.auto_paused_at ? ` since ${r.auto_paused_at.slice(0, 10)}` : ""} for being unread`);
|
|
78
|
+
if (r.state === "active" && r.pauses_after && !r.keep_running) notes.push(`pauses after ${r.pauses_after}`);
|
|
79
|
+
if (r.keep_running) notes.push("keep-running");
|
|
80
|
+
return `${r.id} ${r.state} ${r.name} refresh${notes.length ? ` ${notes.join("; ")}` : ""}`;
|
|
81
|
+
}
|
|
56
82
|
|
|
57
83
|
// src/index.ts
|
|
58
84
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
@@ -1331,6 +1357,33 @@ var ErdoClient = class {
|
|
|
1331
1357
|
`/v1/activity/history${qs ? `?${qs}` : ""}`
|
|
1332
1358
|
);
|
|
1333
1359
|
}
|
|
1360
|
+
// --- outbound webhook subscriptions ---
|
|
1361
|
+
listWebhooks() {
|
|
1362
|
+
return this.request("GET", "/v1/webhooks");
|
|
1363
|
+
}
|
|
1364
|
+
createWebhook(input) {
|
|
1365
|
+
return this.request("POST", "/v1/webhooks", input);
|
|
1366
|
+
}
|
|
1367
|
+
deleteWebhook(id) {
|
|
1368
|
+
return this.request("DELETE", `/v1/webhooks/${encodeURIComponent(id)}`);
|
|
1369
|
+
}
|
|
1370
|
+
listWebhookDeliveries(id, params) {
|
|
1371
|
+
const q = new URLSearchParams();
|
|
1372
|
+
if (params?.status) q.set("status", params.status);
|
|
1373
|
+
if (params?.limit !== void 0) q.set("limit", String(params.limit));
|
|
1374
|
+
if (params?.offset !== void 0) q.set("offset", String(params.offset));
|
|
1375
|
+
const qs = q.toString();
|
|
1376
|
+
return this.request(
|
|
1377
|
+
"GET",
|
|
1378
|
+
`/v1/webhooks/${encodeURIComponent(id)}/deliveries${qs ? `?${qs}` : ""}`
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
retryWebhookDelivery(id, deliveryId) {
|
|
1382
|
+
return this.request(
|
|
1383
|
+
"POST",
|
|
1384
|
+
`/v1/webhooks/${encodeURIComponent(id)}/deliveries/${encodeURIComponent(deliveryId)}/retry`
|
|
1385
|
+
);
|
|
1386
|
+
}
|
|
1334
1387
|
// --- knowledge review queue ---
|
|
1335
1388
|
listReviewItems(params) {
|
|
1336
1389
|
const q = new URLSearchParams();
|
|
@@ -1813,6 +1866,14 @@ var ErdoClient = class {
|
|
|
1813
1866
|
`/v1/datasets/${encodeURIComponent(slug)}/refresh/run`
|
|
1814
1867
|
);
|
|
1815
1868
|
}
|
|
1869
|
+
// Mark the refresh keep-running so the dormancy pause never stands it down,
|
|
1870
|
+
// and resume it if it is already auto-paused. Idempotent.
|
|
1871
|
+
keepDatasetRefreshRunning(slug) {
|
|
1872
|
+
return this.request(
|
|
1873
|
+
"POST",
|
|
1874
|
+
`/v1/datasets/${encodeURIComponent(slug)}/refresh/keep-running`
|
|
1875
|
+
);
|
|
1876
|
+
}
|
|
1816
1877
|
// --- lead identity ---
|
|
1817
1878
|
// Preview or perform a dataset's permanent-lead-identity migration: give every
|
|
1818
1879
|
// pipeline writer the producer contract, backfill the IDs, and publish the
|
|
@@ -2092,8 +2153,8 @@ var ErdoClient = class {
|
|
|
2092
2153
|
return this.request("GET", `/v1/knowledge/${encodeURIComponent(objectID)}/attachments`);
|
|
2093
2154
|
}
|
|
2094
2155
|
// --- automations (heartbeats) ---
|
|
2095
|
-
listHeartbeats() {
|
|
2096
|
-
return this.request("GET", "/v1/heartbeats");
|
|
2156
|
+
listHeartbeats(opts = {}) {
|
|
2157
|
+
return this.request("GET", opts.includeRefresh ? "/v1/heartbeats?include_refresh=true" : "/v1/heartbeats");
|
|
2097
2158
|
}
|
|
2098
2159
|
createHeartbeat(body) {
|
|
2099
2160
|
return this.request("POST", "/v1/heartbeats", body);
|
|
@@ -3798,8 +3859,8 @@ managed.command("performance").description(
|
|
|
3798
3859
|
const cell = (v, digits = 0) => v === null ? "-" : v.toFixed(digits);
|
|
3799
3860
|
const total = (days, pick) => {
|
|
3800
3861
|
let sum = 0;
|
|
3801
|
-
for (const
|
|
3802
|
-
const v = pick(
|
|
3862
|
+
for (const day2 of days) {
|
|
3863
|
+
const v = pick(day2);
|
|
3803
3864
|
if (v === null) return null;
|
|
3804
3865
|
sum += v;
|
|
3805
3866
|
}
|
|
@@ -3808,16 +3869,16 @@ managed.command("performance").description(
|
|
|
3808
3869
|
if (opts.daily) {
|
|
3809
3870
|
const rows = [];
|
|
3810
3871
|
for (const org2 of res.organizations) {
|
|
3811
|
-
for (const
|
|
3872
|
+
for (const day2 of org2.days) {
|
|
3812
3873
|
rows.push([
|
|
3813
3874
|
org2.organization_slug,
|
|
3814
|
-
|
|
3815
|
-
cell(
|
|
3816
|
-
cell(
|
|
3817
|
-
cell(
|
|
3818
|
-
cell(
|
|
3819
|
-
cell(
|
|
3820
|
-
cell(
|
|
3875
|
+
day2.date,
|
|
3876
|
+
cell(day2.spend, 2),
|
|
3877
|
+
cell(day2.clicks),
|
|
3878
|
+
cell(day2.visits),
|
|
3879
|
+
cell(day2.form_starts),
|
|
3880
|
+
cell(day2.leads_on_page),
|
|
3881
|
+
cell(day2.leads_captured)
|
|
3821
3882
|
]);
|
|
3822
3883
|
}
|
|
3823
3884
|
}
|
|
@@ -6372,6 +6433,59 @@ ${events.length} event${events.length === 1 ? "" : "s"}${cursor ? `; ${cursor}`
|
|
|
6372
6433
|
}
|
|
6373
6434
|
}
|
|
6374
6435
|
);
|
|
6436
|
+
var webhooksCmd = program.command("webhooks").description("Manage outbound webhook subscriptions and inspect deliveries");
|
|
6437
|
+
webhooksCmd.command("list").description("List this org's webhook subscriptions").action(async () => {
|
|
6438
|
+
try {
|
|
6439
|
+
const result = await new ErdoClient().listWebhooks();
|
|
6440
|
+
print(result);
|
|
6441
|
+
} catch (e) {
|
|
6442
|
+
fail(e);
|
|
6443
|
+
}
|
|
6444
|
+
});
|
|
6445
|
+
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) => {
|
|
6446
|
+
try {
|
|
6447
|
+
const verbs = opts.verbs.split(",").map((verb) => verb.trim());
|
|
6448
|
+
if (verbs.some((verb) => !verb)) throw new Error("--verbs must contain one or more non-empty verbs");
|
|
6449
|
+
const result = await new ErdoClient().createWebhook({
|
|
6450
|
+
url: opts.url,
|
|
6451
|
+
verbs,
|
|
6452
|
+
include_managed: Boolean(opts.includeManaged)
|
|
6453
|
+
});
|
|
6454
|
+
print(result);
|
|
6455
|
+
} catch (e) {
|
|
6456
|
+
fail(e);
|
|
6457
|
+
}
|
|
6458
|
+
});
|
|
6459
|
+
webhooksCmd.command("delete <id>").description("Deactivate a webhook subscription while retaining delivery history").action(async (id) => {
|
|
6460
|
+
try {
|
|
6461
|
+
print(await new ErdoClient().deleteWebhook(id));
|
|
6462
|
+
} catch (e) {
|
|
6463
|
+
fail(e);
|
|
6464
|
+
}
|
|
6465
|
+
});
|
|
6466
|
+
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) => {
|
|
6467
|
+
try {
|
|
6468
|
+
if (opts.status && !["pending", "delivered", "failed"].includes(opts.status)) {
|
|
6469
|
+
throw new Error("--status must be pending, delivered, or failed");
|
|
6470
|
+
}
|
|
6471
|
+
for (const [name, value] of [["limit", opts.limit], ["offset", opts.offset]]) {
|
|
6472
|
+
if (value !== void 0 && (!Number.isSafeInteger(value) || value < (name === "limit" ? 1 : 0))) {
|
|
6473
|
+
throw new Error(`--${name} must be a ${name === "limit" ? "positive" : "non-negative"} integer`);
|
|
6474
|
+
}
|
|
6475
|
+
}
|
|
6476
|
+
const result = await new ErdoClient().listWebhookDeliveries(id, opts);
|
|
6477
|
+
print(result);
|
|
6478
|
+
} catch (e) {
|
|
6479
|
+
fail(e);
|
|
6480
|
+
}
|
|
6481
|
+
});
|
|
6482
|
+
webhooksCmd.command("retry <id> <delivery-id>").description("Retry a failed webhook delivery").action(async (id, deliveryId) => {
|
|
6483
|
+
try {
|
|
6484
|
+
print(await new ErdoClient().retryWebhookDelivery(id, deliveryId));
|
|
6485
|
+
} catch (e) {
|
|
6486
|
+
fail(e);
|
|
6487
|
+
}
|
|
6488
|
+
});
|
|
6375
6489
|
var reviewsCmd = program.command("reviews").description(
|
|
6376
6490
|
"The Knowledge Review queue \u2014 knowledge patches the critic proposes, investigations, and deduplicated failure signals awaiting a human decision"
|
|
6377
6491
|
);
|
|
@@ -8853,6 +8967,9 @@ refreshCmd.command("show <slug>").description(
|
|
|
8853
8967
|
if (res.experiment_run_id) rows.push(["experiment", res.experiment_run_id]);
|
|
8854
8968
|
rows.push(["writes", describeRefreshWrites(res.strategy, res.refresh_mode, res.key_column, res.live_write_mode)]);
|
|
8855
8969
|
rows.push(["trigger", describeRefreshTrigger(res)]);
|
|
8970
|
+
const pendingPause = describePendingPause(res);
|
|
8971
|
+
if (pendingPause) rows.push(["pause warning", pendingPause]);
|
|
8972
|
+
if (res.keep_running) rows.push(["keep running", "yes \u2014 never paused for being unread"]);
|
|
8856
8973
|
const eventTriggers = describeEventTriggers(res);
|
|
8857
8974
|
if (eventTriggers) rows.push(["event triggers", eventTriggers]);
|
|
8858
8975
|
if (res.schedule) {
|
|
@@ -9132,6 +9249,22 @@ refreshCmd.command("run <slug>").description(
|
|
|
9132
9249
|
fail(e);
|
|
9133
9250
|
}
|
|
9134
9251
|
});
|
|
9252
|
+
refreshCmd.command("keep-running <slug>").description(
|
|
9253
|
+
"Mark a dataset's scheduled refresh keep-running, so Erdo never pauses it for being unread, and resume it now if it was auto-paused. Use it when the data is used somewhere Erdo cannot see. Erdo otherwise pauses a scheduled refresh after 14 days in which nothing read, opened or ran its data, following a 3-day warning."
|
|
9254
|
+
).option("--json", "print the raw JSON result instead of a summary").action(async (slug, opts) => {
|
|
9255
|
+
try {
|
|
9256
|
+
const res = await new ErdoClient().keepDatasetRefreshRunning(slug);
|
|
9257
|
+
if (opts.json) {
|
|
9258
|
+
print(res);
|
|
9259
|
+
return;
|
|
9260
|
+
}
|
|
9261
|
+
console.log(`${res.dataset_slug}: refresh marked keep-running \u2014 it will not be paused for being unread`);
|
|
9262
|
+
if (res.resumed) console.log("It was auto-paused and has been resumed.");
|
|
9263
|
+
console.log(`job: ${res.job_id} (${res.state})`);
|
|
9264
|
+
} catch (e) {
|
|
9265
|
+
fail(e);
|
|
9266
|
+
}
|
|
9267
|
+
});
|
|
9135
9268
|
var analytics = program.command("analytics").description("Page analytics \u2014 what is tracking your published pages, and how they perform with real visitors");
|
|
9136
9269
|
analytics.command("query <hogql>").description("Run a read-only HogQL query against this org's page-analytics events").option("--json", "print the raw JSON result instead of a table").action(async (hogql, opts) => {
|
|
9137
9270
|
try {
|
|
@@ -10528,10 +10661,13 @@ autoCmd.command("create <name>").description(
|
|
|
10528
10661
|
}
|
|
10529
10662
|
}
|
|
10530
10663
|
);
|
|
10531
|
-
autoCmd.command("list").description("List automations").action(async () => {
|
|
10664
|
+
autoCmd.command("list").description("List automations").option("--include-refresh", "Also list dataset refresh jobs with their state, including auto-paused ones and any that will pause soon").action(async (opts) => {
|
|
10532
10665
|
try {
|
|
10533
|
-
const { heartbeats } = await new ErdoClient().listHeartbeats();
|
|
10666
|
+
const { heartbeats, refreshes } = await new ErdoClient().listHeartbeats({ includeRefresh: opts.includeRefresh });
|
|
10534
10667
|
for (const h of heartbeats) console.log(`${h.id} ${h.state} ${h.name} ${h.kind === "script" ? "script" : h.thread_id ? `thread:${h.thread_id}` : h.conversation ?? "new"}${h.persona_id ? ` persona:${h.persona_id}` : ""}${h.model ? ` model:${h.model}` : ""}${heartbeatBounds(h)}`);
|
|
10668
|
+
if (opts.includeRefresh) {
|
|
10669
|
+
for (const r of refreshes ?? []) console.log(formatRefreshJobRow(r));
|
|
10670
|
+
}
|
|
10535
10671
|
} catch (e) {
|
|
10536
10672
|
fail(e);
|
|
10537
10673
|
}
|