@koda-sl/baker-cli 0.367.0 → 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/cli.js +123 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -943,7 +943,8 @@ baker ads meta creatives create --account-id act_123 --page 555 --instagram-us
|
|
|
943
943
|
baker ads meta ads create --account-id act_123 --name "Ad 1" --adset meta_temp_as --creative meta_temp_cr
|
|
944
944
|
|
|
945
945
|
# review + edit before publish
|
|
946
|
-
baker ads meta draft
|
|
946
|
+
baker ads meta draft # one line per op: ref · kind · summary · after <refs>, then advisories
|
|
947
|
+
baker ads meta draft --json # raw JSON envelope for scripting
|
|
947
948
|
baker ads meta draft show meta_temp_cr # full staged payload — the receipt before publish
|
|
948
949
|
baker ads meta draft remove meta_temp_cr # removing a create cascades to dependents
|
|
949
950
|
baker ads meta draft clear
|
package/dist/cli.js
CHANGED
|
@@ -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);
|