@koda-sl/baker-cli 0.367.0-dev.e10535428 → 0.368.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/README.md +2 -1
- package/dist/{chunk-K2IKLMCM.js → chunk-AI4HWQVN.js} +4 -4
- package/dist/chunk-AI4HWQVN.js.map +1 -0
- package/dist/cli.js +152 -22
- package/dist/cli.js.map +1 -1
- package/dist/engine/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-K2IKLMCM.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
validateCanvasDeep,
|
|
70
70
|
withoutCastName,
|
|
71
71
|
ytDlpBlockSignal
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-AI4HWQVN.js";
|
|
73
73
|
import {
|
|
74
74
|
csvOrJson,
|
|
75
75
|
daysAgoIso,
|
|
@@ -9829,7 +9829,7 @@ import { defineCommand as defineCommand19 } from "citty";
|
|
|
9829
9829
|
function listed(resources) {
|
|
9830
9830
|
return resources.map((resource) => resource.label ? `${resource.id} (${resource.label})` : resource.id).join("; ");
|
|
9831
9831
|
}
|
|
9832
|
-
function connectedResourceHints({ plural, singular, flag, resources }) {
|
|
9832
|
+
function connectedResourceHints({ plural: plural2, singular, flag, resources }) {
|
|
9833
9833
|
if (resources.length === 0) {
|
|
9834
9834
|
return [];
|
|
9835
9835
|
}
|
|
@@ -9837,7 +9837,7 @@ function connectedResourceHints({ plural, singular, flag, resources }) {
|
|
|
9837
9837
|
return [`This company connected one ${singular}: ${listed(resources)}. Commands use it unless you pass ${flag}.`];
|
|
9838
9838
|
}
|
|
9839
9839
|
return [
|
|
9840
|
-
`This company connected ${resources.length} ${
|
|
9840
|
+
`This company connected ${resources.length} ${plural2}: ${listed(resources)}. Each command works on one, so pass ${flag} \u2014 nothing is picked for you. A question about the whole business covers all ${resources.length}: answering from one and reporting it as the total is wrong.`
|
|
9841
9841
|
];
|
|
9842
9842
|
}
|
|
9843
9843
|
|
|
@@ -27041,11 +27041,114 @@ Examples:
|
|
|
27041
27041
|
|
|
27042
27042
|
// src/commands/ads/meta/draft.ts
|
|
27043
27043
|
import { defineCommand as defineCommand65 } from "citty";
|
|
27044
|
-
|
|
27044
|
+
|
|
27045
|
+
// src/commands/ads/meta/draft-status.ts
|
|
27046
|
+
var STATUS_HEADINGS = {
|
|
27047
|
+
active: "staged",
|
|
27048
|
+
publishing: "publishing",
|
|
27049
|
+
applied: "published",
|
|
27050
|
+
partial: "published with failures",
|
|
27051
|
+
discarded: "discarded",
|
|
27052
|
+
none: "none"
|
|
27053
|
+
};
|
|
27054
|
+
function plural(count2, word) {
|
|
27055
|
+
return `${count2} ${word}${count2 === 1 ? "" : "s"}`;
|
|
27056
|
+
}
|
|
27057
|
+
function headingLine(draft) {
|
|
27058
|
+
const heading = STATUS_HEADINGS[draft.status];
|
|
27059
|
+
if (draft.status === "active" || draft.status === "discarded") {
|
|
27060
|
+
return `Meta Ads \u2014 ${plural(draft.count, "change")} ${heading} \xB7 ${draft.mode}`;
|
|
27061
|
+
}
|
|
27062
|
+
const counts = /* @__PURE__ */ new Map();
|
|
27063
|
+
for (const op of draft.ops) {
|
|
27064
|
+
const status = op.result?.status ?? "pending";
|
|
27065
|
+
counts.set(status, (counts.get(status) ?? 0) + 1);
|
|
27066
|
+
}
|
|
27067
|
+
const summary = [...counts].map(([status, count2]) => `${count2} ${status}`).join(", ");
|
|
27068
|
+
return `Meta Ads \u2014 ${heading} \xB7 ${summary} \xB7 ${draft.mode}`;
|
|
27069
|
+
}
|
|
27070
|
+
function resultPart(op) {
|
|
27071
|
+
const result = op.result;
|
|
27072
|
+
if (!result) {
|
|
27073
|
+
return void 0;
|
|
27074
|
+
}
|
|
27075
|
+
if (result.status === "failed") {
|
|
27076
|
+
return `\u2717 failed: ${result.error ?? "no reason recorded"}`;
|
|
27077
|
+
}
|
|
27078
|
+
if (result.status === "skipped") {
|
|
27079
|
+
const because = result.skippedBecause;
|
|
27080
|
+
if (because && op.dependsOn.includes(because)) {
|
|
27081
|
+
return `\u2717 skipped: ${because} did not apply`;
|
|
27082
|
+
}
|
|
27083
|
+
return `\u2717 skipped: ${because ?? "a change it needs did not apply"}`;
|
|
27084
|
+
}
|
|
27085
|
+
const id = result.id ?? result.hash;
|
|
27086
|
+
const applied = `\u2713 ${result.status}${id ? ` \u2192 ${id}` : ""}`;
|
|
27087
|
+
const verification = result.verification;
|
|
27088
|
+
if (verification && verification.status !== "confirmed") {
|
|
27089
|
+
return `${applied} (read-back ${verification.status}${verification.note ? `: ${verification.note}` : ""})`;
|
|
27090
|
+
}
|
|
27091
|
+
return applied;
|
|
27092
|
+
}
|
|
27093
|
+
function opLine(op, showAccount) {
|
|
27094
|
+
const parts = [op.ref, op.kind, op.summary];
|
|
27095
|
+
if (op.target && op.target !== op.ref) {
|
|
27096
|
+
parts.push(`target ${op.target}`);
|
|
27097
|
+
}
|
|
27098
|
+
if (showAccount) {
|
|
27099
|
+
parts.push(`account ${op.accountId}`);
|
|
27100
|
+
}
|
|
27101
|
+
if (op.dependsOn.length > 0) {
|
|
27102
|
+
parts.push(`after ${op.dependsOn.join(", ")}`);
|
|
27103
|
+
}
|
|
27104
|
+
const result = resultPart(op);
|
|
27105
|
+
if (result) {
|
|
27106
|
+
parts.push(result);
|
|
27107
|
+
}
|
|
27108
|
+
return ` ${parts.join(" \xB7 ").replace(/[\r\n]+/g, " ")}`;
|
|
27109
|
+
}
|
|
27110
|
+
function renderDraftStatus3(draft) {
|
|
27111
|
+
if (draft.status === "none" || draft.count === 0) {
|
|
27112
|
+
return "No staged Meta changes on this chat.";
|
|
27113
|
+
}
|
|
27114
|
+
const lines = [headingLine(draft)];
|
|
27115
|
+
if (draft.status === "active") {
|
|
27116
|
+
lines.push("Publishing makes every change real on the ad account.");
|
|
27117
|
+
}
|
|
27118
|
+
lines.push("");
|
|
27119
|
+
const showAccount = new Set(draft.ops.map((op) => op.accountId)).size > 1;
|
|
27120
|
+
for (const op of draft.ops) {
|
|
27121
|
+
lines.push(opLine(op, showAccount));
|
|
27122
|
+
}
|
|
27123
|
+
if (draft.advisories.length > 0) {
|
|
27124
|
+
lines.push("", "Advisories");
|
|
27125
|
+
for (const advisory of draft.advisories) {
|
|
27126
|
+
lines.push(` ! ${advisory.ref}: ${advisory.message}`);
|
|
27127
|
+
}
|
|
27128
|
+
}
|
|
27129
|
+
lines.push("", "Full staged payload for one op: baker ads meta draft show <ref> \xB7 raw envelope: --json");
|
|
27130
|
+
return lines.join("\n");
|
|
27131
|
+
}
|
|
27132
|
+
|
|
27133
|
+
// src/commands/ads/meta/draft.ts
|
|
27134
|
+
registerSchema({
|
|
27135
|
+
command: "ads.meta.draft",
|
|
27136
|
+
description: "Review every Meta op staged on this chat, one line each: ref \xB7 kind \xB7 summary \xB7 what it waits on, and after a publish \u2713 applied \u2192 id or \u2717 failed: <error>. `draft show <ref>` prints one op's full payload.",
|
|
27137
|
+
args: {
|
|
27138
|
+
json: { type: "boolean", description: "Raw JSON envelope instead of the readable list", required: false },
|
|
27139
|
+
chat: { type: "string", description: "Read another chat's draft instead of this one", required: false }
|
|
27140
|
+
}
|
|
27141
|
+
});
|
|
27142
|
+
async function listDraft2(json, chat) {
|
|
27045
27143
|
try {
|
|
27046
27144
|
const chatId = resolveChatId(chat);
|
|
27047
27145
|
const response = await apiPost("/api/ads/meta/draft", { chatId });
|
|
27048
|
-
|
|
27146
|
+
if (json || !response.ok || !response.data) {
|
|
27147
|
+
writeJsonEnvelope(response);
|
|
27148
|
+
return;
|
|
27149
|
+
}
|
|
27150
|
+
process.stdout.write(`${renderDraftStatus3(response.data)}
|
|
27151
|
+
`);
|
|
27049
27152
|
} catch (err) {
|
|
27050
27153
|
handleMetaError(err);
|
|
27051
27154
|
}
|
|
@@ -27053,11 +27156,14 @@ async function listDraft2(chat) {
|
|
|
27053
27156
|
var listCommand10 = defineCommand65({
|
|
27054
27157
|
meta: {
|
|
27055
27158
|
name: "list",
|
|
27056
|
-
description: "Show every Meta write op staged in this chat,
|
|
27159
|
+
description: "Show every Meta write op staged in this chat, one line each (ref \xB7 kind \xB7 summary \xB7 dependencies \xB7 post-publish result); --json for the raw envelope. Publishing reaches the real ad account, so review this before you finish. Example: baker ads meta draft"
|
|
27160
|
+
},
|
|
27161
|
+
args: {
|
|
27162
|
+
json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list" },
|
|
27163
|
+
chat: CHAT_READ_ARG
|
|
27057
27164
|
},
|
|
27058
|
-
args: { chat: CHAT_READ_ARG },
|
|
27059
27165
|
run: async ({ args: args5 }) => {
|
|
27060
|
-
await listDraft2(args5.chat);
|
|
27166
|
+
await listDraft2(args5.json === true, args5.chat);
|
|
27061
27167
|
}
|
|
27062
27168
|
});
|
|
27063
27169
|
var showCommand2 = defineCommand65({
|
|
@@ -27127,7 +27233,10 @@ var metaDraftCommand = defineCommand65({
|
|
|
27127
27233
|
},
|
|
27128
27234
|
// Declared on the parent too: `default: "list"` dispatches the bare `draft --chat <id>` form, and
|
|
27129
27235
|
// citty prints help for a flag the parent does not know instead of forwarding it.
|
|
27130
|
-
args: {
|
|
27236
|
+
args: {
|
|
27237
|
+
json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list" },
|
|
27238
|
+
chat: CHAT_READ_ARG
|
|
27239
|
+
},
|
|
27131
27240
|
subCommands: { list: listCommand10, show: showCommand2, remove: removeCommand3, clear: clearCommand3 },
|
|
27132
27241
|
// `default` (not `run`) dispatches the bare invocation: citty falls through to `run`
|
|
27133
27242
|
// after dispatching a subcommand, so a `run` here would list the draft a second time
|
|
@@ -28940,7 +29049,7 @@ function renderNode3(node, depth, showAccount, out) {
|
|
|
28940
29049
|
}
|
|
28941
29050
|
}
|
|
28942
29051
|
var NO_CHANGES = "No X Ads changes staged";
|
|
28943
|
-
var
|
|
29052
|
+
var STATUS_HEADINGS2 = {
|
|
28944
29053
|
active: "staged",
|
|
28945
29054
|
publishing: "publishing",
|
|
28946
29055
|
applied: "published",
|
|
@@ -28952,8 +29061,8 @@ function didNotApply(op) {
|
|
|
28952
29061
|
function didApply(op) {
|
|
28953
29062
|
return op.result?.status === "applied" || op.result?.status === "simulated";
|
|
28954
29063
|
}
|
|
28955
|
-
function
|
|
28956
|
-
const heading =
|
|
29064
|
+
function headingLine2(draft) {
|
|
29065
|
+
const heading = STATUS_HEADINGS2[draft.status] ?? draft.status;
|
|
28957
29066
|
if (draft.status !== "applied" && draft.status !== "publishing") {
|
|
28958
29067
|
return `X Ads: ${draft.count} change${draft.count === 1 ? "" : "s"} ${heading}`;
|
|
28959
29068
|
}
|
|
@@ -28967,11 +29076,11 @@ function problemLines(draft) {
|
|
|
28967
29076
|
return `\u2717 ${op.summary} \u2014 failed: ${reason}`;
|
|
28968
29077
|
});
|
|
28969
29078
|
}
|
|
28970
|
-
function
|
|
29079
|
+
function renderDraftStatus4(draft) {
|
|
28971
29080
|
if (draft.status === "none" || draft.count === 0) {
|
|
28972
29081
|
return NO_CHANGES;
|
|
28973
29082
|
}
|
|
28974
|
-
const out = [
|
|
29083
|
+
const out = [headingLine2(draft), ""];
|
|
28975
29084
|
const tree = draft.tree ?? [];
|
|
28976
29085
|
const showAccount = accountsInTree3(tree).size > 1;
|
|
28977
29086
|
for (const node of tree) {
|
|
@@ -29009,7 +29118,7 @@ async function listDraft3(json, chat) {
|
|
|
29009
29118
|
writeJsonEnvelope(response);
|
|
29010
29119
|
return;
|
|
29011
29120
|
}
|
|
29012
|
-
process.stdout.write(`${
|
|
29121
|
+
process.stdout.write(`${renderDraftStatus4(response.data)}
|
|
29013
29122
|
`);
|
|
29014
29123
|
} catch (err) {
|
|
29015
29124
|
handleDraftError(err);
|
|
@@ -64311,9 +64420,26 @@ function matchesTrigger(kind, query) {
|
|
|
64311
64420
|
const family = query.replace(/\.?\*?$/, "");
|
|
64312
64421
|
return kind === query || kind.startsWith(`${family}.`);
|
|
64313
64422
|
}
|
|
64314
|
-
function shapeTriggerCatalog(
|
|
64423
|
+
function shapeTriggerCatalog(response, filter) {
|
|
64315
64424
|
const { trigger, group } = filter;
|
|
64316
|
-
|
|
64425
|
+
const unfiltered = trigger === void 0 && group === void 0;
|
|
64426
|
+
if (unfiltered && filter.full) return { ok: true, data: response };
|
|
64427
|
+
const parsed = triggerCatalogSchema.safeParse(response);
|
|
64428
|
+
if (!parsed.success) {
|
|
64429
|
+
return {
|
|
64430
|
+
ok: false,
|
|
64431
|
+
error: {
|
|
64432
|
+
code: "INTERNAL_ERROR",
|
|
64433
|
+
message: "The trigger list came back in a shape this version of the CLI cannot read.",
|
|
64434
|
+
fix: {
|
|
64435
|
+
action: "run `baker scheduled-agents triggers --full`",
|
|
64436
|
+
explanation: "--full prints the whole list as the server sent it, without reading it."
|
|
64437
|
+
}
|
|
64438
|
+
}
|
|
64439
|
+
};
|
|
64440
|
+
}
|
|
64441
|
+
const catalog = parsed.data;
|
|
64442
|
+
if (unfiltered) {
|
|
64317
64443
|
return {
|
|
64318
64444
|
ok: true,
|
|
64319
64445
|
data: {
|
|
@@ -64328,12 +64454,17 @@ function shapeTriggerCatalog(catalog, filter) {
|
|
|
64328
64454
|
]
|
|
64329
64455
|
};
|
|
64330
64456
|
}
|
|
64331
|
-
const groups = catalog.groups.filter((entry) =>
|
|
64457
|
+
const groups = catalog.groups.filter((entry) => group === void 0 || entry.group === group).map((entry) => ({
|
|
64332
64458
|
...entry,
|
|
64333
|
-
triggers: entry.triggers.filter(
|
|
64459
|
+
triggers: entry.triggers.filter(
|
|
64460
|
+
(t) => trigger === void 0 || matchesTrigger(t.kind, trigger)
|
|
64461
|
+
)
|
|
64334
64462
|
})).filter((entry) => entry.triggers.length > 0);
|
|
64335
64463
|
if (groups.length === 0) {
|
|
64336
|
-
const asked = [
|
|
64464
|
+
const asked = [
|
|
64465
|
+
trigger === void 0 ? null : `--trigger "${trigger}"`,
|
|
64466
|
+
group === void 0 ? null : `--group "${group}"`
|
|
64467
|
+
].filter(Boolean);
|
|
64337
64468
|
return {
|
|
64338
64469
|
ok: false,
|
|
64339
64470
|
error: {
|
|
@@ -64368,8 +64499,7 @@ Full guide: __tooling__/docs/tools/baker/scheduled-agents.md`
|
|
|
64368
64499
|
run: async ({ args: args5 }) => {
|
|
64369
64500
|
try {
|
|
64370
64501
|
const response = await apiPost("/api/scheduled-agents/triggers", {});
|
|
64371
|
-
const
|
|
64372
|
-
const shaped = shapeTriggerCatalog(catalog, { trigger: args5.trigger, group: args5.group, full: args5.full });
|
|
64502
|
+
const shaped = shapeTriggerCatalog(response.data, { trigger: args5.trigger, group: args5.group, full: args5.full });
|
|
64373
64503
|
writeJson(shaped);
|
|
64374
64504
|
if (!shaped.ok) process.exit(1);
|
|
64375
64505
|
} catch (err) {
|