@erdoai/cli 0.198.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 +70 -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";
|
|
@@ -1840,6 +1866,14 @@ var ErdoClient = class {
|
|
|
1840
1866
|
`/v1/datasets/${encodeURIComponent(slug)}/refresh/run`
|
|
1841
1867
|
);
|
|
1842
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
|
+
}
|
|
1843
1877
|
// --- lead identity ---
|
|
1844
1878
|
// Preview or perform a dataset's permanent-lead-identity migration: give every
|
|
1845
1879
|
// pipeline writer the producer contract, backfill the IDs, and publish the
|
|
@@ -2119,8 +2153,8 @@ var ErdoClient = class {
|
|
|
2119
2153
|
return this.request("GET", `/v1/knowledge/${encodeURIComponent(objectID)}/attachments`);
|
|
2120
2154
|
}
|
|
2121
2155
|
// --- automations (heartbeats) ---
|
|
2122
|
-
listHeartbeats() {
|
|
2123
|
-
return this.request("GET", "/v1/heartbeats");
|
|
2156
|
+
listHeartbeats(opts = {}) {
|
|
2157
|
+
return this.request("GET", opts.includeRefresh ? "/v1/heartbeats?include_refresh=true" : "/v1/heartbeats");
|
|
2124
2158
|
}
|
|
2125
2159
|
createHeartbeat(body) {
|
|
2126
2160
|
return this.request("POST", "/v1/heartbeats", body);
|
|
@@ -3825,8 +3859,8 @@ managed.command("performance").description(
|
|
|
3825
3859
|
const cell = (v, digits = 0) => v === null ? "-" : v.toFixed(digits);
|
|
3826
3860
|
const total = (days, pick) => {
|
|
3827
3861
|
let sum = 0;
|
|
3828
|
-
for (const
|
|
3829
|
-
const v = pick(
|
|
3862
|
+
for (const day2 of days) {
|
|
3863
|
+
const v = pick(day2);
|
|
3830
3864
|
if (v === null) return null;
|
|
3831
3865
|
sum += v;
|
|
3832
3866
|
}
|
|
@@ -3835,16 +3869,16 @@ managed.command("performance").description(
|
|
|
3835
3869
|
if (opts.daily) {
|
|
3836
3870
|
const rows = [];
|
|
3837
3871
|
for (const org2 of res.organizations) {
|
|
3838
|
-
for (const
|
|
3872
|
+
for (const day2 of org2.days) {
|
|
3839
3873
|
rows.push([
|
|
3840
3874
|
org2.organization_slug,
|
|
3841
|
-
|
|
3842
|
-
cell(
|
|
3843
|
-
cell(
|
|
3844
|
-
cell(
|
|
3845
|
-
cell(
|
|
3846
|
-
cell(
|
|
3847
|
-
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)
|
|
3848
3882
|
]);
|
|
3849
3883
|
}
|
|
3850
3884
|
}
|
|
@@ -8933,6 +8967,9 @@ refreshCmd.command("show <slug>").description(
|
|
|
8933
8967
|
if (res.experiment_run_id) rows.push(["experiment", res.experiment_run_id]);
|
|
8934
8968
|
rows.push(["writes", describeRefreshWrites(res.strategy, res.refresh_mode, res.key_column, res.live_write_mode)]);
|
|
8935
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"]);
|
|
8936
8973
|
const eventTriggers = describeEventTriggers(res);
|
|
8937
8974
|
if (eventTriggers) rows.push(["event triggers", eventTriggers]);
|
|
8938
8975
|
if (res.schedule) {
|
|
@@ -9212,6 +9249,22 @@ refreshCmd.command("run <slug>").description(
|
|
|
9212
9249
|
fail(e);
|
|
9213
9250
|
}
|
|
9214
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
|
+
});
|
|
9215
9268
|
var analytics = program.command("analytics").description("Page analytics \u2014 what is tracking your published pages, and how they perform with real visitors");
|
|
9216
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) => {
|
|
9217
9270
|
try {
|
|
@@ -10608,10 +10661,13 @@ autoCmd.command("create <name>").description(
|
|
|
10608
10661
|
}
|
|
10609
10662
|
}
|
|
10610
10663
|
);
|
|
10611
|
-
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) => {
|
|
10612
10665
|
try {
|
|
10613
|
-
const { heartbeats } = await new ErdoClient().listHeartbeats();
|
|
10666
|
+
const { heartbeats, refreshes } = await new ErdoClient().listHeartbeats({ includeRefresh: opts.includeRefresh });
|
|
10614
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
|
+
}
|
|
10615
10671
|
} catch (e) {
|
|
10616
10672
|
fail(e);
|
|
10617
10673
|
}
|