@erdoai/cli 0.163.0 → 0.164.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 +45 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,17 +20,22 @@ function describeRefreshTrigger(state) {
|
|
|
20
20
|
if (state.strategy === "live_webhook") return event ? `incoming webhook events \u2014 page views do not trigger this feed; ${event}` : "incoming webhook events \u2014 page views do not trigger this feed";
|
|
21
21
|
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
22
|
if (!state.job_id) return event ? `not running \u2014 no linked job; ${event}` : "not running \u2014 no linked job; configure the refresh again";
|
|
23
|
-
if (state.
|
|
23
|
+
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";
|
|
24
|
+
if (state.job_enabled === false) return event ? `not running \u2014 the linked job is disabled; ${event}` : "not running \u2014 the linked job is disabled";
|
|
24
25
|
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";
|
|
25
26
|
return [trigger, event, state.test_run_success === false ? "configuration test failed" : void 0].filter(Boolean).join("; ");
|
|
26
27
|
}
|
|
27
28
|
function describeEventTriggers(state) {
|
|
28
29
|
if (!state.event_triggers?.length) {
|
|
29
30
|
if (!state.event_dataset_ids?.length) return void 0;
|
|
31
|
+
if (state.event_debounce_seconds_by_source?.length === state.event_dataset_ids.length) {
|
|
32
|
+
const sources = state.event_dataset_ids.map((id, index) => `${id} (debounce ${state.event_debounce_seconds_by_source[index]}s)`);
|
|
33
|
+
return `event-driven \u2014 configured for ${sources.join(", ")}`;
|
|
34
|
+
}
|
|
30
35
|
return `event-driven \u2014 configured for ${state.event_dataset_ids.join(", ")} (debounce ${state.event_debounce_seconds ?? 0}s)`;
|
|
31
36
|
}
|
|
32
37
|
const triggers = state.event_triggers;
|
|
33
|
-
const ownerActive = !!state.job_id && state.disarmed !== true && state.job_enabled !== false;
|
|
38
|
+
const ownerActive = !state.activation_pending && !!state.job_id && state.disarmed !== true && state.job_enabled !== false;
|
|
34
39
|
const enabled = ownerActive ? triggers.filter((trigger) => trigger.enabled) : [];
|
|
35
40
|
const disabled = ownerActive ? triggers.filter((trigger) => !trigger.enabled) : triggers;
|
|
36
41
|
const parts = [];
|
|
@@ -8190,6 +8195,9 @@ refreshCmd.command("set <slug>").description(
|
|
|
8190
8195
|
"--schedule <cron>",
|
|
8191
8196
|
"a cron expression to run the refresh on a fixed cadence. Omit it and the refresh runs on view instead \u2014 cheaper, because it never runs while nobody is looking"
|
|
8192
8197
|
).option("--timezone <tz>", "IANA timezone the cron expression is read in (default UTC)").option(
|
|
8198
|
+
"--schedule-enabled",
|
|
8199
|
+
"keep the cron trigger enabled (the default); pass --no-schedule-enabled to preserve a disabled cron while replacing a refresh"
|
|
8200
|
+
).option("--no-schedule-enabled", "save the cron trigger disabled").option("--job-enabled", "enable the replacement parent job (default when omitted)").option("--no-job-enabled", "keep the replacement parent job paused while preserving its trigger policies").option(
|
|
8193
8201
|
"--script <pyOr@file>",
|
|
8194
8202
|
"Python source for the script strategy, inline or @path; it must call emit_dataset(df) or emit_rows(rows)"
|
|
8195
8203
|
).option("--script-entrypoint <f>", "entrypoint filename for the script strategy (default main.py)").option(
|
|
@@ -8198,7 +8206,10 @@ refreshCmd.command("set <slug>").description(
|
|
|
8198
8206
|
).option("--agent-prompt <textOr@file>", "instructions for the agent_run strategy, inline or @path").option(
|
|
8199
8207
|
"--context-datasets <csv>",
|
|
8200
8208
|
"slugs of other datasets the recipe reads besides the one it writes"
|
|
8201
|
-
).option("--event-datasets <csv>", "dataset slugs whose writes trigger this refresh (up to 16, comma-separated)").option(
|
|
8209
|
+
).option("--event-datasets <csv>", "dataset slugs whose writes trigger this refresh (up to 16, comma-separated)").option(
|
|
8210
|
+
"--event-triggers-enabled <csv>",
|
|
8211
|
+
"saved true/false enable policy for each --event-datasets entry, in the same order"
|
|
8212
|
+
).option("--event-debounce-by-source <csv>", "one debounce integer (0\u20133600) per --event-datasets entry; overrides --event-debounce").option("--event-debounce <seconds>", "wait after the first source write to coalesce a burst (integer 0\u20133600 seconds)").option(
|
|
8202
8213
|
"--on-view",
|
|
8203
8214
|
"let a page view trigger this refresh (the platform default); pass --no-on-view to turn it off. Sent only when you pass one of the two"
|
|
8204
8215
|
).option("--no-on-view", "stop page views from triggering this refresh").option(
|
|
@@ -8250,6 +8261,8 @@ refreshCmd.command("set <slug>").description(
|
|
|
8250
8261
|
if (opts.keyColumn) body.key_column = opts.keyColumn;
|
|
8251
8262
|
if (opts.schedule) body.schedule = opts.schedule;
|
|
8252
8263
|
if (opts.timezone) body.timezone = opts.timezone;
|
|
8264
|
+
if (opts.scheduleEnabled !== void 0) body.schedule_enabled = opts.scheduleEnabled;
|
|
8265
|
+
if (opts.jobEnabled !== void 0) body.job_enabled = opts.jobEnabled;
|
|
8253
8266
|
const script = readMaybeFile(opts.script);
|
|
8254
8267
|
if (script !== void 0) body.script = script;
|
|
8255
8268
|
if (opts.scriptEntrypoint) body.script_entrypoint = opts.scriptEntrypoint;
|
|
@@ -8274,6 +8287,18 @@ refreshCmd.command("set <slug>").description(
|
|
|
8274
8287
|
}
|
|
8275
8288
|
body.event_dataset_slugs = eventDatasetSlugs;
|
|
8276
8289
|
}
|
|
8290
|
+
if (opts.eventTriggersEnabled !== void 0) {
|
|
8291
|
+
if (!eventDatasetSlugs?.length) {
|
|
8292
|
+
fail(new Error("--event-triggers-enabled requires non-empty --event-datasets"));
|
|
8293
|
+
return;
|
|
8294
|
+
}
|
|
8295
|
+
const values = opts.eventTriggersEnabled.split(",").map((value) => value.trim());
|
|
8296
|
+
if (values.length !== eventDatasetSlugs.length || values.some((value) => value !== "true" && value !== "false")) {
|
|
8297
|
+
fail(new Error("--event-triggers-enabled must contain one true or false per --event-datasets entry"));
|
|
8298
|
+
return;
|
|
8299
|
+
}
|
|
8300
|
+
body.event_triggers_enabled = values.map((value) => value === "true");
|
|
8301
|
+
}
|
|
8277
8302
|
if (opts.eventDebounce !== void 0) {
|
|
8278
8303
|
const value = Number(opts.eventDebounce);
|
|
8279
8304
|
if (!opts.eventDebounce.trim() || !Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > 3600) {
|
|
@@ -8286,6 +8311,19 @@ refreshCmd.command("set <slug>").description(
|
|
|
8286
8311
|
}
|
|
8287
8312
|
body.event_debounce_seconds = value;
|
|
8288
8313
|
}
|
|
8314
|
+
if (opts.eventDebounceBySource !== void 0) {
|
|
8315
|
+
if (!eventDatasetSlugs?.length) {
|
|
8316
|
+
fail(new Error("--event-debounce-by-source requires non-empty --event-datasets"));
|
|
8317
|
+
return;
|
|
8318
|
+
}
|
|
8319
|
+
const values = opts.eventDebounceBySource.split(",").map((value) => value.trim());
|
|
8320
|
+
const seconds = values.map(Number);
|
|
8321
|
+
if (values.length !== eventDatasetSlugs.length || values.some((value) => !value) || seconds.some((value) => !Number.isInteger(value) || value < 0 || value > 3600)) {
|
|
8322
|
+
fail(new Error("--event-debounce-by-source must contain one integer between 0 and 3600 per --event-datasets entry"));
|
|
8323
|
+
return;
|
|
8324
|
+
}
|
|
8325
|
+
body.event_debounce_seconds_by_source = seconds;
|
|
8326
|
+
}
|
|
8289
8327
|
if (opts.onView !== void 0) body.refresh_on_view_enabled = opts.onView;
|
|
8290
8328
|
if (opts.staleAfter !== void 0) {
|
|
8291
8329
|
body.refresh_on_view_stale_after_seconds = opts.staleAfter;
|
|
@@ -8310,8 +8348,11 @@ refreshCmd.command("set <slug>").description(
|
|
|
8310
8348
|
...res,
|
|
8311
8349
|
event_dataset_ids: res.event_dataset_ids,
|
|
8312
8350
|
event_debounce_seconds: res.event_debounce_seconds ?? body.event_debounce_seconds,
|
|
8351
|
+
event_debounce_seconds_by_source: res.event_debounce_seconds_by_source,
|
|
8313
8352
|
refresh_on_view_enabled: body.refresh_on_view_enabled,
|
|
8314
|
-
test_run_success: res.test_run?.success
|
|
8353
|
+
test_run_success: res.test_run?.success,
|
|
8354
|
+
job_enabled: body.job_enabled,
|
|
8355
|
+
schedule_enabled: body.schedule_enabled
|
|
8315
8356
|
}));
|
|
8316
8357
|
if (res.job_id) console.log(`job: ${res.job_id}`);
|
|
8317
8358
|
if (res.webhook_url) {
|