@koda-sl/baker-cli 0.364.0-dev.894c59720 → 0.364.0-dev.c9e3bcde2
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 +119 -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
|
@@ -9792,7 +9792,7 @@ import { defineCommand as defineCommand19 } from "citty";
|
|
|
9792
9792
|
function listed(resources) {
|
|
9793
9793
|
return resources.map((resource) => resource.label ? `${resource.id} (${resource.label})` : resource.id).join("; ");
|
|
9794
9794
|
}
|
|
9795
|
-
function connectedResourceHints({ plural, singular, flag, resources }) {
|
|
9795
|
+
function connectedResourceHints({ plural: plural2, singular, flag, resources }) {
|
|
9796
9796
|
if (resources.length === 0) {
|
|
9797
9797
|
return [];
|
|
9798
9798
|
}
|
|
@@ -9800,7 +9800,7 @@ function connectedResourceHints({ plural, singular, flag, resources }) {
|
|
|
9800
9800
|
return [`This company connected one ${singular}: ${listed(resources)}. Commands use it unless you pass ${flag}.`];
|
|
9801
9801
|
}
|
|
9802
9802
|
return [
|
|
9803
|
-
`This company connected ${resources.length} ${
|
|
9803
|
+
`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.`
|
|
9804
9804
|
];
|
|
9805
9805
|
}
|
|
9806
9806
|
|
|
@@ -27019,11 +27019,110 @@ Examples:
|
|
|
27019
27019
|
|
|
27020
27020
|
// src/commands/ads/meta/draft.ts
|
|
27021
27021
|
import { defineCommand as defineCommand65 } from "citty";
|
|
27022
|
-
|
|
27022
|
+
|
|
27023
|
+
// src/commands/ads/meta/draft-status.ts
|
|
27024
|
+
var STATUS_HEADINGS = {
|
|
27025
|
+
active: "staged",
|
|
27026
|
+
publishing: "publishing",
|
|
27027
|
+
applied: "published",
|
|
27028
|
+
partial: "published with failures",
|
|
27029
|
+
discarded: "discarded",
|
|
27030
|
+
none: "none"
|
|
27031
|
+
};
|
|
27032
|
+
function plural(count2, word) {
|
|
27033
|
+
return `${count2} ${word}${count2 === 1 ? "" : "s"}`;
|
|
27034
|
+
}
|
|
27035
|
+
function headingLine(draft) {
|
|
27036
|
+
const heading = STATUS_HEADINGS[draft.status];
|
|
27037
|
+
if (draft.status === "active" || draft.status === "discarded") {
|
|
27038
|
+
return `Meta Ads \u2014 ${plural(draft.count, "change")} ${heading} \xB7 ${draft.mode}`;
|
|
27039
|
+
}
|
|
27040
|
+
const counts = /* @__PURE__ */ new Map();
|
|
27041
|
+
for (const op of draft.ops) {
|
|
27042
|
+
const status = op.result?.status ?? "pending";
|
|
27043
|
+
counts.set(status, (counts.get(status) ?? 0) + 1);
|
|
27044
|
+
}
|
|
27045
|
+
const summary = [...counts].map(([status, count2]) => `${count2} ${status}`).join(", ");
|
|
27046
|
+
return `Meta Ads \u2014 ${heading} \xB7 ${summary} \xB7 ${draft.mode}`;
|
|
27047
|
+
}
|
|
27048
|
+
function resultPart(op) {
|
|
27049
|
+
const result = op.result;
|
|
27050
|
+
if (!result) {
|
|
27051
|
+
return void 0;
|
|
27052
|
+
}
|
|
27053
|
+
if (result.status === "failed") {
|
|
27054
|
+
return `\u2717 failed: ${result.error ?? "no reason recorded"}`;
|
|
27055
|
+
}
|
|
27056
|
+
if (result.status === "skipped") {
|
|
27057
|
+
return `\u2717 skipped: waiting on ${result.skippedBecause ?? "a change that did not apply"}`;
|
|
27058
|
+
}
|
|
27059
|
+
const id = result.id ?? result.hash;
|
|
27060
|
+
const applied = `\u2713 ${result.status}${id ? ` \u2192 ${id}` : ""}`;
|
|
27061
|
+
const verification = result.verification;
|
|
27062
|
+
if (verification && verification.status !== "confirmed") {
|
|
27063
|
+
return `${applied} (read-back ${verification.status}${verification.note ? `: ${verification.note}` : ""})`;
|
|
27064
|
+
}
|
|
27065
|
+
return applied;
|
|
27066
|
+
}
|
|
27067
|
+
function opLine(op, showAccount) {
|
|
27068
|
+
const parts = [op.ref, op.kind, op.summary];
|
|
27069
|
+
if (op.target && op.target !== op.ref) {
|
|
27070
|
+
parts.push(`target ${op.target}`);
|
|
27071
|
+
}
|
|
27072
|
+
if (showAccount) {
|
|
27073
|
+
parts.push(`account ${op.accountId}`);
|
|
27074
|
+
}
|
|
27075
|
+
if (op.dependsOn.length > 0) {
|
|
27076
|
+
parts.push(`after ${op.dependsOn.join(", ")}`);
|
|
27077
|
+
}
|
|
27078
|
+
const result = resultPart(op);
|
|
27079
|
+
if (result) {
|
|
27080
|
+
parts.push(result);
|
|
27081
|
+
}
|
|
27082
|
+
return ` ${parts.join(" \xB7 ")}`;
|
|
27083
|
+
}
|
|
27084
|
+
function renderDraftStatus3(draft) {
|
|
27085
|
+
if (draft.status === "none" || draft.count === 0) {
|
|
27086
|
+
return "No staged Meta changes on this chat.";
|
|
27087
|
+
}
|
|
27088
|
+
const lines = [headingLine(draft)];
|
|
27089
|
+
if (draft.status === "active") {
|
|
27090
|
+
lines.push("Publishing makes every change real on the ad account.");
|
|
27091
|
+
}
|
|
27092
|
+
lines.push("");
|
|
27093
|
+
const showAccount = new Set(draft.ops.map((op) => op.accountId)).size > 1;
|
|
27094
|
+
for (const op of draft.ops) {
|
|
27095
|
+
lines.push(opLine(op, showAccount));
|
|
27096
|
+
}
|
|
27097
|
+
if (draft.advisories.length > 0) {
|
|
27098
|
+
lines.push("", "Advisories");
|
|
27099
|
+
for (const advisory of draft.advisories) {
|
|
27100
|
+
lines.push(` ! ${advisory.ref}: ${advisory.message}`);
|
|
27101
|
+
}
|
|
27102
|
+
}
|
|
27103
|
+
lines.push("", "Full staged payload for one op: baker ads meta draft show <ref> \xB7 raw envelope: --json");
|
|
27104
|
+
return lines.join("\n");
|
|
27105
|
+
}
|
|
27106
|
+
|
|
27107
|
+
// src/commands/ads/meta/draft.ts
|
|
27108
|
+
registerSchema({
|
|
27109
|
+
command: "ads.meta.draft",
|
|
27110
|
+
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.",
|
|
27111
|
+
args: {
|
|
27112
|
+
json: { type: "boolean", description: "Raw JSON envelope instead of the readable list", required: false },
|
|
27113
|
+
chat: { type: "string", description: "Read another chat's draft instead of this one", required: false }
|
|
27114
|
+
}
|
|
27115
|
+
});
|
|
27116
|
+
async function listDraft2(json, chat) {
|
|
27023
27117
|
try {
|
|
27024
27118
|
const chatId = resolveChatId(chat);
|
|
27025
27119
|
const response = await apiPost("/api/ads/meta/draft", { chatId });
|
|
27026
|
-
|
|
27120
|
+
if (json || !response.ok || !response.data) {
|
|
27121
|
+
writeJsonEnvelope(response);
|
|
27122
|
+
return;
|
|
27123
|
+
}
|
|
27124
|
+
process.stdout.write(`${renderDraftStatus3(response.data)}
|
|
27125
|
+
`);
|
|
27027
27126
|
} catch (err) {
|
|
27028
27127
|
handleMetaError(err);
|
|
27029
27128
|
}
|
|
@@ -27031,11 +27130,14 @@ async function listDraft2(chat) {
|
|
|
27031
27130
|
var listCommand10 = defineCommand65({
|
|
27032
27131
|
meta: {
|
|
27033
27132
|
name: "list",
|
|
27034
|
-
description: "Show every Meta write op staged in this chat,
|
|
27133
|
+
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"
|
|
27134
|
+
},
|
|
27135
|
+
args: {
|
|
27136
|
+
json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list" },
|
|
27137
|
+
chat: CHAT_READ_ARG
|
|
27035
27138
|
},
|
|
27036
|
-
args: { chat: CHAT_READ_ARG },
|
|
27037
27139
|
run: async ({ args: args5 }) => {
|
|
27038
|
-
await listDraft2(args5.chat);
|
|
27140
|
+
await listDraft2(args5.json === true, args5.chat);
|
|
27039
27141
|
}
|
|
27040
27142
|
});
|
|
27041
27143
|
var showCommand2 = defineCommand65({
|
|
@@ -27105,7 +27207,10 @@ var metaDraftCommand = defineCommand65({
|
|
|
27105
27207
|
},
|
|
27106
27208
|
// Declared on the parent too: `default: "list"` dispatches the bare `draft --chat <id>` form, and
|
|
27107
27209
|
// citty prints help for a flag the parent does not know instead of forwarding it.
|
|
27108
|
-
args: {
|
|
27210
|
+
args: {
|
|
27211
|
+
json: { type: "boolean", description: "Print the raw JSON envelope instead of the readable list" },
|
|
27212
|
+
chat: CHAT_READ_ARG
|
|
27213
|
+
},
|
|
27109
27214
|
subCommands: { list: listCommand10, show: showCommand2, remove: removeCommand3, clear: clearCommand3 },
|
|
27110
27215
|
// `default` (not `run`) dispatches the bare invocation: citty falls through to `run`
|
|
27111
27216
|
// after dispatching a subcommand, so a `run` here would list the draft a second time
|
|
@@ -28918,7 +29023,7 @@ function renderNode3(node, depth, showAccount, out) {
|
|
|
28918
29023
|
}
|
|
28919
29024
|
}
|
|
28920
29025
|
var NO_CHANGES = "No X Ads changes staged";
|
|
28921
|
-
var
|
|
29026
|
+
var STATUS_HEADINGS2 = {
|
|
28922
29027
|
active: "staged",
|
|
28923
29028
|
publishing: "publishing",
|
|
28924
29029
|
applied: "published",
|
|
@@ -28930,8 +29035,8 @@ function didNotApply(op) {
|
|
|
28930
29035
|
function didApply(op) {
|
|
28931
29036
|
return op.result?.status === "applied" || op.result?.status === "simulated";
|
|
28932
29037
|
}
|
|
28933
|
-
function
|
|
28934
|
-
const heading =
|
|
29038
|
+
function headingLine2(draft) {
|
|
29039
|
+
const heading = STATUS_HEADINGS2[draft.status] ?? draft.status;
|
|
28935
29040
|
if (draft.status !== "applied" && draft.status !== "publishing") {
|
|
28936
29041
|
return `X Ads: ${draft.count} change${draft.count === 1 ? "" : "s"} ${heading}`;
|
|
28937
29042
|
}
|
|
@@ -28945,11 +29050,11 @@ function problemLines(draft) {
|
|
|
28945
29050
|
return `\u2717 ${op.summary} \u2014 failed: ${reason}`;
|
|
28946
29051
|
});
|
|
28947
29052
|
}
|
|
28948
|
-
function
|
|
29053
|
+
function renderDraftStatus4(draft) {
|
|
28949
29054
|
if (draft.status === "none" || draft.count === 0) {
|
|
28950
29055
|
return NO_CHANGES;
|
|
28951
29056
|
}
|
|
28952
|
-
const out = [
|
|
29057
|
+
const out = [headingLine2(draft), ""];
|
|
28953
29058
|
const tree = draft.tree ?? [];
|
|
28954
29059
|
const showAccount = accountsInTree3(tree).size > 1;
|
|
28955
29060
|
for (const node of tree) {
|
|
@@ -28987,7 +29092,7 @@ async function listDraft3(json, chat) {
|
|
|
28987
29092
|
writeJsonEnvelope(response);
|
|
28988
29093
|
return;
|
|
28989
29094
|
}
|
|
28990
|
-
process.stdout.write(`${
|
|
29095
|
+
process.stdout.write(`${renderDraftStatus4(response.data)}
|
|
28991
29096
|
`);
|
|
28992
29097
|
} catch (err) {
|
|
28993
29098
|
handleDraftError(err);
|