@erdoai/cli 0.163.0 → 0.165.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 +82 -5
- 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 = [];
|
|
@@ -981,6 +986,20 @@ var ErdoClient = class {
|
|
|
981
986
|
`/v1/workstreams/${encodeURIComponent(slug)}/ledger${qs}`
|
|
982
987
|
);
|
|
983
988
|
}
|
|
989
|
+
async readWorkstreamRecommendations(slug) {
|
|
990
|
+
const ledger = await this.request("GET", `/v1/workstreams/${encodeURIComponent(slug)}/ledger`);
|
|
991
|
+
if (!Array.isArray(ledger.recommendations) || !ledger.recommendation_review) {
|
|
992
|
+
throw new Error("This connection does not expose the Recommendations contract yet.");
|
|
993
|
+
}
|
|
994
|
+
return ledger;
|
|
995
|
+
}
|
|
996
|
+
manageWorkstreamRecommendations(slug, input) {
|
|
997
|
+
return this.request(
|
|
998
|
+
"POST",
|
|
999
|
+
`/v1/workstreams/${encodeURIComponent(slug)}/recommendations`,
|
|
1000
|
+
input
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
984
1003
|
attachWorkstreamResource(slug, input) {
|
|
985
1004
|
return this.request(
|
|
986
1005
|
"POST",
|
|
@@ -1966,6 +1985,7 @@ var ErdoClient = class {
|
|
|
1966
1985
|
listApprovals(opts) {
|
|
1967
1986
|
const params = new URLSearchParams();
|
|
1968
1987
|
if (opts.status) params.set("status", opts.status);
|
|
1988
|
+
if (opts.agent_run_id) params.set("agent_run_id", opts.agent_run_id);
|
|
1969
1989
|
if (opts.limit) params.set("limit", String(opts.limit));
|
|
1970
1990
|
if (opts.workstream_slug) params.set("workstream_slug", opts.workstream_slug);
|
|
1971
1991
|
if (opts.subject_resource_type) params.set("subject_resource_type", opts.subject_resource_type);
|
|
@@ -3728,6 +3748,26 @@ wsCmd.command("ledger <slug>").description(
|
|
|
3728
3748
|
fail(e);
|
|
3729
3749
|
}
|
|
3730
3750
|
});
|
|
3751
|
+
wsCmd.command("recommendations <slug>").description("Read resolved recommendations and review state, or apply an exact JSON mutation").option("--input-file <path>", "JSON file containing the exact ManageRecommendationRequest body").action(async (slug, opts) => {
|
|
3752
|
+
try {
|
|
3753
|
+
const client = new ErdoClient();
|
|
3754
|
+
if (opts.inputFile) {
|
|
3755
|
+
const body = JSON.parse(readFileSync4(opts.inputFile, "utf8"));
|
|
3756
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) {
|
|
3757
|
+
throw new Error("--input-file must contain a JSON object");
|
|
3758
|
+
}
|
|
3759
|
+
print(await client.manageWorkstreamRecommendations(slug, body));
|
|
3760
|
+
return;
|
|
3761
|
+
}
|
|
3762
|
+
const ledger = await client.readWorkstreamRecommendations(slug);
|
|
3763
|
+
print({
|
|
3764
|
+
recommendations: ledger.recommendations,
|
|
3765
|
+
recommendation_review: ledger.recommendation_review
|
|
3766
|
+
});
|
|
3767
|
+
} catch (e) {
|
|
3768
|
+
fail(e);
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3731
3771
|
wsCmd.command("attach <slug>").description("Link a resource (page, dataset, heartbeat, experiment_run, \u2026) to a workstream").requiredOption("--type <resourceType>", "resource type (page, dataset, heartbeat, experiment_run, \u2026)").requiredOption("--id <resourceId>", "the resource's UUID").requiredOption("--rel <relationshipType>", "output | input | evidence | monitoring | subject | parent | child | running").option("--title <title>", "optional label for the link").option("--phase <phaseId>", "optional phase to attach under").action(
|
|
3732
3772
|
async (slug, opts) => {
|
|
3733
3773
|
try {
|
|
@@ -5187,11 +5227,12 @@ var approvalsCmd = program.command("approvals").description("List and decide app
|
|
|
5187
5227
|
approvalsCmd.command("list").description("List approval requests, optionally filtered by status").option("-s, --status <status>", "pending | approved | rejected | expired (default: all)").option("-l, --limit <n>", "max requests", (v) => parseInt(v, 10)).option("--workstream <slug>", "only approvals for this workstream").option(
|
|
5188
5228
|
"--subject-type <type>",
|
|
5189
5229
|
"only approvals whose subject resource is of this type (e.g. paid_media_campaign)"
|
|
5190
|
-
).option("--subject-id <id>", "only approvals whose subject resource has this id").option("--json", "output raw JSON").action(
|
|
5230
|
+
).option("--subject-id <id>", "only approvals whose subject resource has this id").option("--agent-run-id <uuid>", "only approvals for this agent run").option("--json", "output raw JSON").action(
|
|
5191
5231
|
async (opts) => {
|
|
5192
5232
|
try {
|
|
5193
5233
|
const res = await new ErdoClient().listApprovals({
|
|
5194
5234
|
status: opts.status,
|
|
5235
|
+
agent_run_id: opts.agentRunId,
|
|
5195
5236
|
limit: opts.limit,
|
|
5196
5237
|
workstream_slug: opts.workstream,
|
|
5197
5238
|
subject_resource_type: opts.subjectType,
|
|
@@ -8190,6 +8231,9 @@ refreshCmd.command("set <slug>").description(
|
|
|
8190
8231
|
"--schedule <cron>",
|
|
8191
8232
|
"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
8233
|
).option("--timezone <tz>", "IANA timezone the cron expression is read in (default UTC)").option(
|
|
8234
|
+
"--schedule-enabled",
|
|
8235
|
+
"keep the cron trigger enabled (the default); pass --no-schedule-enabled to preserve a disabled cron while replacing a refresh"
|
|
8236
|
+
).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
8237
|
"--script <pyOr@file>",
|
|
8194
8238
|
"Python source for the script strategy, inline or @path; it must call emit_dataset(df) or emit_rows(rows)"
|
|
8195
8239
|
).option("--script-entrypoint <f>", "entrypoint filename for the script strategy (default main.py)").option(
|
|
@@ -8198,7 +8242,10 @@ refreshCmd.command("set <slug>").description(
|
|
|
8198
8242
|
).option("--agent-prompt <textOr@file>", "instructions for the agent_run strategy, inline or @path").option(
|
|
8199
8243
|
"--context-datasets <csv>",
|
|
8200
8244
|
"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(
|
|
8245
|
+
).option("--event-datasets <csv>", "dataset slugs whose writes trigger this refresh (up to 16, comma-separated)").option(
|
|
8246
|
+
"--event-triggers-enabled <csv>",
|
|
8247
|
+
"saved true/false enable policy for each --event-datasets entry, in the same order"
|
|
8248
|
+
).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
8249
|
"--on-view",
|
|
8203
8250
|
"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
8251
|
).option("--no-on-view", "stop page views from triggering this refresh").option(
|
|
@@ -8250,6 +8297,8 @@ refreshCmd.command("set <slug>").description(
|
|
|
8250
8297
|
if (opts.keyColumn) body.key_column = opts.keyColumn;
|
|
8251
8298
|
if (opts.schedule) body.schedule = opts.schedule;
|
|
8252
8299
|
if (opts.timezone) body.timezone = opts.timezone;
|
|
8300
|
+
if (opts.scheduleEnabled !== void 0) body.schedule_enabled = opts.scheduleEnabled;
|
|
8301
|
+
if (opts.jobEnabled !== void 0) body.job_enabled = opts.jobEnabled;
|
|
8253
8302
|
const script = readMaybeFile(opts.script);
|
|
8254
8303
|
if (script !== void 0) body.script = script;
|
|
8255
8304
|
if (opts.scriptEntrypoint) body.script_entrypoint = opts.scriptEntrypoint;
|
|
@@ -8274,6 +8323,18 @@ refreshCmd.command("set <slug>").description(
|
|
|
8274
8323
|
}
|
|
8275
8324
|
body.event_dataset_slugs = eventDatasetSlugs;
|
|
8276
8325
|
}
|
|
8326
|
+
if (opts.eventTriggersEnabled !== void 0) {
|
|
8327
|
+
if (!eventDatasetSlugs?.length) {
|
|
8328
|
+
fail(new Error("--event-triggers-enabled requires non-empty --event-datasets"));
|
|
8329
|
+
return;
|
|
8330
|
+
}
|
|
8331
|
+
const values = opts.eventTriggersEnabled.split(",").map((value) => value.trim());
|
|
8332
|
+
if (values.length !== eventDatasetSlugs.length || values.some((value) => value !== "true" && value !== "false")) {
|
|
8333
|
+
fail(new Error("--event-triggers-enabled must contain one true or false per --event-datasets entry"));
|
|
8334
|
+
return;
|
|
8335
|
+
}
|
|
8336
|
+
body.event_triggers_enabled = values.map((value) => value === "true");
|
|
8337
|
+
}
|
|
8277
8338
|
if (opts.eventDebounce !== void 0) {
|
|
8278
8339
|
const value = Number(opts.eventDebounce);
|
|
8279
8340
|
if (!opts.eventDebounce.trim() || !Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > 3600) {
|
|
@@ -8286,6 +8347,19 @@ refreshCmd.command("set <slug>").description(
|
|
|
8286
8347
|
}
|
|
8287
8348
|
body.event_debounce_seconds = value;
|
|
8288
8349
|
}
|
|
8350
|
+
if (opts.eventDebounceBySource !== void 0) {
|
|
8351
|
+
if (!eventDatasetSlugs?.length) {
|
|
8352
|
+
fail(new Error("--event-debounce-by-source requires non-empty --event-datasets"));
|
|
8353
|
+
return;
|
|
8354
|
+
}
|
|
8355
|
+
const values = opts.eventDebounceBySource.split(",").map((value) => value.trim());
|
|
8356
|
+
const seconds = values.map(Number);
|
|
8357
|
+
if (values.length !== eventDatasetSlugs.length || values.some((value) => !value) || seconds.some((value) => !Number.isInteger(value) || value < 0 || value > 3600)) {
|
|
8358
|
+
fail(new Error("--event-debounce-by-source must contain one integer between 0 and 3600 per --event-datasets entry"));
|
|
8359
|
+
return;
|
|
8360
|
+
}
|
|
8361
|
+
body.event_debounce_seconds_by_source = seconds;
|
|
8362
|
+
}
|
|
8289
8363
|
if (opts.onView !== void 0) body.refresh_on_view_enabled = opts.onView;
|
|
8290
8364
|
if (opts.staleAfter !== void 0) {
|
|
8291
8365
|
body.refresh_on_view_stale_after_seconds = opts.staleAfter;
|
|
@@ -8310,8 +8384,11 @@ refreshCmd.command("set <slug>").description(
|
|
|
8310
8384
|
...res,
|
|
8311
8385
|
event_dataset_ids: res.event_dataset_ids,
|
|
8312
8386
|
event_debounce_seconds: res.event_debounce_seconds ?? body.event_debounce_seconds,
|
|
8387
|
+
event_debounce_seconds_by_source: res.event_debounce_seconds_by_source,
|
|
8313
8388
|
refresh_on_view_enabled: body.refresh_on_view_enabled,
|
|
8314
|
-
test_run_success: res.test_run?.success
|
|
8389
|
+
test_run_success: res.test_run?.success,
|
|
8390
|
+
job_enabled: body.job_enabled,
|
|
8391
|
+
schedule_enabled: body.schedule_enabled
|
|
8315
8392
|
}));
|
|
8316
8393
|
if (res.job_id) console.log(`job: ${res.job_id}`);
|
|
8317
8394
|
if (res.webhook_url) {
|