@koda-sl/baker-cli 0.869.0-dev.620009099 → 0.869.0-dev.a640d8c12
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 +3 -1
- package/dist/{account-5VOZ4R2X.js → account-LHY6YM6L.js} +2 -2
- package/dist/{account-assets-DOHOKM2L.js → account-assets-L6BX4YUQ.js} +46 -54
- package/dist/account-assets-L6BX4YUQ.js.map +1 -0
- package/dist/{account-level-HLSTNJHR.js → account-level-OX34JQ7C.js} +4 -4
- package/dist/{accounts-SNH3LJ2H.js → accounts-LNFU27BU.js} +2 -2
- package/dist/{activities-QHDGHXMI.js → activities-LC64DAAK.js} +12 -21
- package/dist/activities-LC64DAAK.js.map +1 -0
- package/dist/{ads-MYACXO5A.js → ads-U33JFGCR.js} +2 -2
- package/dist/{ads-ZDSRE7D6.js → ads-ZR5D7BZT.js} +19 -27
- package/dist/ads-ZR5D7BZT.js.map +1 -0
- package/dist/{adsets-CZQMTJ2T.js → adsets-3NIYL2GQ.js} +30 -48
- package/dist/adsets-3NIYL2GQ.js.map +1 -0
- package/dist/{asset-writes-TXYCARXJ.js → asset-writes-5ZKZDPQ4.js} +4 -4
- package/dist/{audience-writes-DJG7XTFA.js → audience-writes-NL6NRLLY.js} +15 -29
- package/dist/audience-writes-NL6NRLLY.js.map +1 -0
- package/dist/{audiences-QHM26I5Y.js → audiences-DL267GNQ.js} +15 -27
- package/dist/audiences-DL267GNQ.js.map +1 -0
- package/dist/{businesses-ALNQZFB4.js → businesses-RQ6P4DOS.js} +2 -2
- package/dist/{campaigns-55VLNVCE.js → campaigns-RXDC5FSQ.js} +18 -29
- package/dist/campaigns-RXDC5FSQ.js.map +1 -0
- package/dist/{catalogs-B24HAEXZ.js → catalogs-QAZ7ZZ5R.js} +3 -3
- package/dist/{chunk-YF57BX3S.js → chunk-DP76WGDV.js} +8 -87
- package/dist/chunk-DP76WGDV.js.map +1 -0
- package/dist/{chunk-EJ6B5OS5.js → chunk-EGM42UKF.js} +2 -2
- package/dist/{chunk-2WHALQOJ.js → chunk-OMJ7DVFJ.js} +2 -2
- package/dist/{chunk-VUJPKIJN.js → chunk-UE5ZFTDL.js} +2 -2
- package/dist/{chunk-VBIKO56A.js → chunk-WKRVHRWY.js} +3 -14
- package/dist/chunk-WKRVHRWY.js.map +1 -0
- package/dist/cli.js +2 -2
- package/dist/{copy-writes-S4X5XUSK.js → copy-writes-QYN6PBU2.js} +4 -4
- package/dist/{creatives-BCTG6PV4.js → creatives-CPLH3KHQ.js} +19 -32
- package/dist/creatives-CPLH3KHQ.js.map +1 -0
- package/dist/{custom-conversions-56VXFOWV.js → custom-conversions-CTJVAZKC.js} +15 -27
- package/dist/custom-conversions-CTJVAZKC.js.map +1 -0
- package/dist/{draft-OMGA2NYG.js → draft-UU3F2VMJ.js} +2 -2
- package/dist/{gsc-JYP4ZCSH.js → gsc-4UAVQRDJ.js} +2 -2
- package/dist/{insights-3SQWIU4E.js → insights-QU5A4XBO.js} +2 -2
- package/dist/{instant-experiences-HSRGMQ5T.js → instant-experiences-EJWYFWDT.js} +3 -3
- package/dist/{leads-LWWPMZRY.js → leads-FEEWX7OO.js} +3 -3
- package/dist/{media-UODVM47L.js → media-PUOLJUN3.js} +3 -3
- package/dist/{meta-4IOVQSFF.js → meta-SPPSYRMC.js} +40 -40
- package/dist/{page-photos-BCEDWPGX.js → page-photos-ZBMJLL5V.js} +3 -3
- package/dist/{pages-TZBFJXNR.js → pages-YZC44QR2.js} +2 -2
- package/dist/{pixels-2BG3XMZP.js → pixels-EX6FHVHW.js} +12 -25
- package/dist/pixels-EX6FHVHW.js.map +1 -0
- package/dist/{preview-WHUVS5JJ.js → preview-4GUQGDBD.js} +2 -2
- package/dist/{query-EAZEG4QR.js → query-WDS7AJ4G.js} +14 -5
- package/dist/query-WDS7AJ4G.js.map +1 -0
- package/dist/{rule-writes-Q5NLSBF5.js → rule-writes-6XP7G35U.js} +3 -3
- package/dist/{rules-Z7MMVOZ2.js → rules-BRULCGRV.js} +24 -41
- package/dist/rules-BRULCGRV.js.map +1 -0
- package/dist/{shared-AXONQS3M.js → shared-64RE42DL.js} +4 -16
- package/dist/{studies-HUINRZHD.js → studies-357M2C2K.js} +16 -33
- package/dist/studies-357M2C2K.js.map +1 -0
- package/dist/{study-writes-SI5QXY7F.js → study-writes-HXUQRPIK.js} +3 -3
- package/dist/{targeting-3XK4OLPG.js → targeting-7T7XHBIX.js} +3 -3
- package/dist/{videos-C5OCSAIF.js → videos-TJG5CA7N.js} +2 -2
- package/dist/{write-commands-T46SVSQ7.js → write-commands-4KI6T2NF.js} +7 -7
- package/package.json +1 -1
- package/dist/account-assets-DOHOKM2L.js.map +0 -1
- package/dist/activities-QHDGHXMI.js.map +0 -1
- package/dist/ads-ZDSRE7D6.js.map +0 -1
- package/dist/adsets-CZQMTJ2T.js.map +0 -1
- package/dist/audience-writes-DJG7XTFA.js.map +0 -1
- package/dist/audiences-QHM26I5Y.js.map +0 -1
- package/dist/campaigns-55VLNVCE.js.map +0 -1
- package/dist/chunk-VBIKO56A.js.map +0 -1
- package/dist/chunk-YF57BX3S.js.map +0 -1
- package/dist/creatives-BCTG6PV4.js.map +0 -1
- package/dist/custom-conversions-56VXFOWV.js.map +0 -1
- package/dist/pixels-2BG3XMZP.js.map +0 -1
- package/dist/query-EAZEG4QR.js.map +0 -1
- package/dist/rules-Z7MMVOZ2.js.map +0 -1
- package/dist/studies-HUINRZHD.js.map +0 -1
- /package/dist/{account-5VOZ4R2X.js.map → account-LHY6YM6L.js.map} +0 -0
- /package/dist/{account-level-HLSTNJHR.js.map → account-level-OX34JQ7C.js.map} +0 -0
- /package/dist/{accounts-SNH3LJ2H.js.map → accounts-LNFU27BU.js.map} +0 -0
- /package/dist/{ads-MYACXO5A.js.map → ads-U33JFGCR.js.map} +0 -0
- /package/dist/{asset-writes-TXYCARXJ.js.map → asset-writes-5ZKZDPQ4.js.map} +0 -0
- /package/dist/{businesses-ALNQZFB4.js.map → businesses-RQ6P4DOS.js.map} +0 -0
- /package/dist/{catalogs-B24HAEXZ.js.map → catalogs-QAZ7ZZ5R.js.map} +0 -0
- /package/dist/{chunk-EJ6B5OS5.js.map → chunk-EGM42UKF.js.map} +0 -0
- /package/dist/{chunk-2WHALQOJ.js.map → chunk-OMJ7DVFJ.js.map} +0 -0
- /package/dist/{chunk-VUJPKIJN.js.map → chunk-UE5ZFTDL.js.map} +0 -0
- /package/dist/{copy-writes-S4X5XUSK.js.map → copy-writes-QYN6PBU2.js.map} +0 -0
- /package/dist/{draft-OMGA2NYG.js.map → draft-UU3F2VMJ.js.map} +0 -0
- /package/dist/{gsc-JYP4ZCSH.js.map → gsc-4UAVQRDJ.js.map} +0 -0
- /package/dist/{insights-3SQWIU4E.js.map → insights-QU5A4XBO.js.map} +0 -0
- /package/dist/{instant-experiences-HSRGMQ5T.js.map → instant-experiences-EJWYFWDT.js.map} +0 -0
- /package/dist/{leads-LWWPMZRY.js.map → leads-FEEWX7OO.js.map} +0 -0
- /package/dist/{media-UODVM47L.js.map → media-PUOLJUN3.js.map} +0 -0
- /package/dist/{meta-4IOVQSFF.js.map → meta-SPPSYRMC.js.map} +0 -0
- /package/dist/{page-photos-BCEDWPGX.js.map → page-photos-ZBMJLL5V.js.map} +0 -0
- /package/dist/{pages-TZBFJXNR.js.map → pages-YZC44QR2.js.map} +0 -0
- /package/dist/{preview-WHUVS5JJ.js.map → preview-4GUQGDBD.js.map} +0 -0
- /package/dist/{rule-writes-Q5NLSBF5.js.map → rule-writes-6XP7G35U.js.map} +0 -0
- /package/dist/{shared-AXONQS3M.js.map → shared-64RE42DL.js.map} +0 -0
- /package/dist/{study-writes-SI5QXY7F.js.map → study-writes-HXUQRPIK.js.map} +0 -0
- /package/dist/{targeting-3XK4OLPG.js.map → targeting-7T7XHBIX.js.map} +0 -0
- /package/dist/{videos-C5OCSAIF.js.map → videos-TJG5CA7N.js.map} +0 -0
- /package/dist/{write-commands-T46SVSQ7.js.map → write-commands-4KI6T2NF.js.map} +0 -0
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LISTING_ACCOUNT_ARG,
|
|
3
|
-
accountsInScope,
|
|
4
2
|
handleMetaError,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readEachAccount,
|
|
8
|
-
resolveAccountIdArg,
|
|
9
|
-
withAccountColumn
|
|
10
|
-
} from "./chunk-YF57BX3S.js";
|
|
3
|
+
resolveAccountIdArg
|
|
4
|
+
} from "./chunk-DP76WGDV.js";
|
|
11
5
|
import "./chunk-QALAJNBG.js";
|
|
12
6
|
import {
|
|
13
7
|
writeJsonEnvelope
|
|
@@ -56,9 +50,9 @@ function ruleListHints(rows) {
|
|
|
56
50
|
}
|
|
57
51
|
registerSchema({
|
|
58
52
|
command: "ads.meta.rules",
|
|
59
|
-
description: "List the automated rules on a Meta ad account (Ads Manager \u2192 Automated rules): each rule's status and what it does, in words. --rule-id reads one; --full adds its evaluation_spec, execution_spec and schedule_spec in the shape `rules update --file` takes (money in major units of the account currency).
|
|
53
|
+
description: "List the automated rules on a Meta ad account (Ads Manager \u2192 Automated rules): each rule's status and what it does, in words. --rule-id reads one; --full adds its evaluation_spec, execution_spec and schedule_spec in the shape `rules update --file` takes (money in major units of the account currency).",
|
|
60
54
|
args: {
|
|
61
|
-
"account-id": {
|
|
55
|
+
"account-id": { type: "string", description: "Meta ad account ID (act_123)", required: false },
|
|
62
56
|
"rule-id": { type: "string", description: "Read one rule", required: false },
|
|
63
57
|
full: { type: "boolean", description: "Include the specs and timestamps", required: false }
|
|
64
58
|
}
|
|
@@ -69,23 +63,18 @@ var listCommand = defineCommand({
|
|
|
69
63
|
description: "List automated rules. Runs by default. Example: baker ads meta rules --account-id act_123 \xB7 one rule in full: baker ads meta rules --rule-id 1132635173044914 --full"
|
|
70
64
|
},
|
|
71
65
|
args: {
|
|
72
|
-
"account-id":
|
|
66
|
+
"account-id": { type: "string", description: "Meta ad account ID" },
|
|
73
67
|
"rule-id": { type: "string", description: "Read one rule" },
|
|
74
68
|
full: { type: "boolean", description: "Include the specs and timestamps" }
|
|
75
69
|
},
|
|
76
70
|
run: async ({ args }) => {
|
|
77
|
-
const
|
|
71
|
+
const accountId = await resolveAccountIdArg(args);
|
|
78
72
|
try {
|
|
79
|
-
const params = {};
|
|
73
|
+
const params = { "account-id": accountId };
|
|
80
74
|
if (args["rule-id"]) params["rule-id"] = String(args["rule-id"]);
|
|
81
|
-
const
|
|
82
|
-
accounts,
|
|
83
|
-
(accountId) => apiGet("/api/ads/meta/rules", { ...params, "account-id": accountId })
|
|
84
|
-
);
|
|
85
|
-
const rows = read.rows;
|
|
75
|
+
const rows = await apiGet("/api/ads/meta/rules", params);
|
|
86
76
|
const full = Boolean(args.full) || Boolean(args["rule-id"]);
|
|
87
|
-
|
|
88
|
-
writeJsonEnvelope({ ok: true, data, hints: [...read.hints, ...ruleListHints(rows)] });
|
|
77
|
+
writeJsonEnvelope({ ok: true, data: full ? rows : rows.map(compactRule), hints: ruleListHints(rows) });
|
|
89
78
|
} catch (err) {
|
|
90
79
|
handleMetaError(err);
|
|
91
80
|
}
|
|
@@ -111,9 +100,9 @@ function compactHistory(row) {
|
|
|
111
100
|
}
|
|
112
101
|
registerSchema({
|
|
113
102
|
command: "ads.meta.rules.history",
|
|
114
|
-
description: "What automated rules did and when: each run with the objects it changed (PAUSED, CHANGED_BUDGET, \u2026, old \u2192 new value). Without --rule-id, every rule on the account, newest first.
|
|
103
|
+
description: "What automated rules did and when: each run with the objects it changed (PAUSED, CHANGED_BUDGET, \u2026, old \u2192 new value). Without --rule-id, every rule on the account, newest first.",
|
|
115
104
|
args: {
|
|
116
|
-
"account-id": {
|
|
105
|
+
"account-id": { type: "string", description: "Meta ad account ID (act_123)", required: false },
|
|
117
106
|
"rule-id": { type: "string", description: "One rule's runs", required: false },
|
|
118
107
|
"object-id": { type: "string", description: "Only runs that touched this ad, ad set or campaign", required: false },
|
|
119
108
|
action: { type: "string", description: "Only this action, e.g. PAUSED, CHANGED_BUDGET", required: false },
|
|
@@ -128,7 +117,7 @@ var historyCommand = defineCommand({
|
|
|
128
117
|
description: "What rules did and when. Example: baker ads meta rules history --rule-id 1132635173044914 --hide-no-changes \xB7 every rule: baker ads meta rules history --account-id act_123"
|
|
129
118
|
},
|
|
130
119
|
args: {
|
|
131
|
-
"account-id":
|
|
120
|
+
"account-id": { type: "string", description: "Meta ad account ID" },
|
|
132
121
|
"rule-id": { type: "string", description: "One rule's runs" },
|
|
133
122
|
"object-id": { type: "string", description: "Only runs that touched this object" },
|
|
134
123
|
action: { type: "string", description: "Only this action (PAUSED, CHANGED_BUDGET, \u2026)" },
|
|
@@ -137,24 +126,18 @@ var historyCommand = defineCommand({
|
|
|
137
126
|
full: { type: "boolean", description: "Include the rule's specs at each run" }
|
|
138
127
|
},
|
|
139
128
|
run: async ({ args }) => {
|
|
140
|
-
const
|
|
129
|
+
const accountId = await resolveAccountIdArg(args);
|
|
141
130
|
try {
|
|
142
|
-
const params = {};
|
|
131
|
+
const params = { "account-id": accountId };
|
|
143
132
|
for (const key of ["rule-id", "object-id", "action", "limit"]) {
|
|
144
133
|
if (args[key]) params[key] = String(args[key]);
|
|
145
134
|
}
|
|
146
135
|
if (args["hide-no-changes"]) params["hide-no-changes"] = "true";
|
|
147
|
-
const
|
|
148
|
-
accounts,
|
|
149
|
-
(accountId) => apiGet("/api/ads/meta/rules/history", { ...params, "account-id": accountId }),
|
|
150
|
-
{ limit: listingLimit(args, 50), time: (row) => loggedAt(row.timestamp) }
|
|
151
|
-
);
|
|
152
|
-
const rows = read.rows;
|
|
136
|
+
const rows = await apiGet("/api/ads/meta/rules/history", params);
|
|
153
137
|
const hints = rows.length === 0 ? [
|
|
154
138
|
"No runs recorded. A daily rule first runs just after midnight in the ad account's time zone; a switched-off rule never runs."
|
|
155
139
|
] : [];
|
|
156
|
-
|
|
157
|
-
writeJsonEnvelope({ ok: true, data, hints: [...read.hints, ...hints] });
|
|
140
|
+
writeJsonEnvelope({ ok: true, data: args.full ? rows : rows.map(compactHistory), hints });
|
|
158
141
|
} catch (err) {
|
|
159
142
|
handleMetaError(err);
|
|
160
143
|
}
|
|
@@ -211,15 +194,15 @@ Examples:
|
|
|
211
194
|
list: listCommand,
|
|
212
195
|
history: historyCommand,
|
|
213
196
|
preview: previewCommand,
|
|
214
|
-
create: () => import("./rule-writes-
|
|
215
|
-
update: () => import("./rule-writes-
|
|
216
|
-
enable: () => import("./rule-writes-
|
|
217
|
-
disable: () => import("./rule-writes-
|
|
218
|
-
delete: () => import("./rule-writes-
|
|
219
|
-
run: () => import("./rule-writes-
|
|
197
|
+
create: () => import("./rule-writes-6XP7G35U.js").then((m) => m.rulesCreateCommand),
|
|
198
|
+
update: () => import("./rule-writes-6XP7G35U.js").then((m) => m.rulesUpdateCommand),
|
|
199
|
+
enable: () => import("./rule-writes-6XP7G35U.js").then((m) => m.rulesEnableCommand),
|
|
200
|
+
disable: () => import("./rule-writes-6XP7G35U.js").then((m) => m.rulesDisableCommand),
|
|
201
|
+
delete: () => import("./rule-writes-6XP7G35U.js").then((m) => m.rulesDeleteCommand),
|
|
202
|
+
run: () => import("./rule-writes-6XP7G35U.js").then((m) => m.rulesRunCommand)
|
|
220
203
|
},
|
|
221
204
|
args: {
|
|
222
|
-
"account-id":
|
|
205
|
+
"account-id": { type: "string", description: "Meta ad account ID" },
|
|
223
206
|
"rule-id": { type: "string", description: "Read one rule" },
|
|
224
207
|
full: { type: "boolean", description: "Include the specs and timestamps" }
|
|
225
208
|
},
|
|
@@ -231,4 +214,4 @@ export {
|
|
|
231
214
|
ruleListHints,
|
|
232
215
|
rulesCommand
|
|
233
216
|
};
|
|
234
|
-
//# sourceMappingURL=rules-
|
|
217
|
+
//# sourceMappingURL=rules-BRULCGRV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/meta/rules.ts"],"sourcesContent":["import type { MetaAdRuleHistoryRow, MetaAdRuleRow } from \"@baker/api/ads-meta/adRules\";\nimport { defineCommand } from \"citty\";\nimport { apiGet } from \"../../../client.ts\";\nimport { registerSchema } from \"../../../schemas.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\n/**\n * Meta automated rules — reads. A rule is Meta's own automation: it runs on\n * Meta, on Meta's schedule, with no Baker involvement once created. Writes\n * (create / update / enable / disable / delete) stage like every Meta change\n * and live in `rule-writes.ts`.\n */\n\n/** What an agent needs to pick a rule and know what it does. Specs sit behind --full. */\nexport function compactRule(row: MetaAdRuleRow): Record<string, unknown> {\n return {\n id: row.id,\n name: row.name,\n status: row.status,\n does: row.description,\n ...(row.disable_error_code ? { disable_error_code: row.disable_error_code } : {}),\n updated_time: row.updated_time,\n };\n}\n\nexport function ruleListHints(rows: readonly MetaAdRuleRow[]): string[] {\n const hints: string[] = [];\n if (rows.length === 0) {\n hints.push(\n 'No automated rules on this account. Stage one with `baker ads meta rules create --name … --apply-to ad --when \"cost_per_result>20\" --action pause`.',\n );\n }\n const issues = rows.filter((row) => row.status === \"HAS_ISSUES\");\n if (issues.length > 0) {\n hints.push(\n `${issues.map((row) => row.name ?? row.id).join(\", \")} ${issues.length === 1 ? \"has\" : \"have\"} been stopped by Meta (HAS_ISSUES) — read it with --rule-id and fix the spec with \\`rules update\\`.`,\n );\n }\n if (rows.length > 0) {\n hints.push(\n \"`rules history --rule-id <id>` shows what a rule did and when; `rules preview <id>` what it would act on now.\",\n );\n }\n return hints;\n}\n\nregisterSchema({\n command: \"ads.meta.rules\",\n description:\n \"List the automated rules on a Meta ad account (Ads Manager → Automated rules): each rule's status and what it does, in words. --rule-id reads one; --full adds its evaluation_spec, execution_spec and schedule_spec in the shape `rules update --file` takes (money in major units of the account currency).\",\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID (act_123)\", required: false },\n \"rule-id\": { type: \"string\", description: \"Read one rule\", required: false },\n full: { type: \"boolean\", description: \"Include the specs and timestamps\", required: false },\n },\n});\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List automated rules. Runs by default. Example: baker ads meta rules --account-id act_123 · one rule in full: baker ads meta rules --rule-id 1132635173044914 --full\",\n },\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n \"rule-id\": { type: \"string\", description: \"Read one rule\" },\n full: { type: \"boolean\", description: \"Include the specs and timestamps\" },\n },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const params: Record<string, string> = { \"account-id\": accountId };\n if (args[\"rule-id\"]) params[\"rule-id\"] = String(args[\"rule-id\"]);\n const rows = await apiGet<MetaAdRuleRow[]>(\"/api/ads/meta/rules\", params);\n const full = Boolean(args.full) || Boolean(args[\"rule-id\"]);\n writeJsonEnvelope({ ok: true, data: full ? rows : rows.map(compactRule), hints: ruleListHints(rows) });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n/** A run in a line an agent can read: when, which rule, and what it changed. */\nexport function compactHistory(row: MetaAdRuleHistoryRow): Record<string, unknown> {\n const changes = (row.results ?? []).flatMap((result) =>\n (result.actions ?? []).map((action) => ({\n object_id: result.object_id,\n action: action.action,\n ...(action.field ? { field: action.field } : {}),\n ...(action.old_value !== undefined ? { from: action.old_value } : {}),\n ...(action.new_value !== undefined ? { to: action.new_value } : {}),\n })),\n );\n return {\n timestamp: row.timestamp,\n rule_id: row.rule_id,\n ...(row.is_manual ? { manual: true } : {}),\n changes,\n ...(row.exception_message ? { error: row.exception_message } : {}),\n };\n}\n\nregisterSchema({\n command: \"ads.meta.rules.history\",\n description:\n \"What automated rules did and when: each run with the objects it changed (PAUSED, CHANGED_BUDGET, …, old → new value). Without --rule-id, every rule on the account, newest first.\",\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID (act_123)\", required: false },\n \"rule-id\": { type: \"string\", description: \"One rule's runs\", required: false },\n \"object-id\": { type: \"string\", description: \"Only runs that touched this ad, ad set or campaign\", required: false },\n action: { type: \"string\", description: \"Only this action, e.g. PAUSED, CHANGED_BUDGET\", required: false },\n \"hide-no-changes\": { type: \"boolean\", description: \"Drop runs that changed nothing\", required: false },\n limit: { type: \"string\", description: \"Max runs (default 50)\", required: false },\n full: { type: \"boolean\", description: \"Include the rule's specs at each run\", required: false },\n },\n});\n\nconst historyCommand = defineCommand({\n meta: {\n name: \"history\",\n description:\n \"What rules did and when. Example: baker ads meta rules history --rule-id 1132635173044914 --hide-no-changes · every rule: baker ads meta rules history --account-id act_123\",\n },\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n \"rule-id\": { type: \"string\", description: \"One rule's runs\" },\n \"object-id\": { type: \"string\", description: \"Only runs that touched this object\" },\n action: { type: \"string\", description: \"Only this action (PAUSED, CHANGED_BUDGET, …)\" },\n \"hide-no-changes\": { type: \"boolean\", description: \"Drop runs that changed nothing\" },\n limit: { type: \"string\", description: \"Max runs (default 50)\" },\n full: { type: \"boolean\", description: \"Include the rule's specs at each run\" },\n },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const params: Record<string, string> = { \"account-id\": accountId };\n for (const key of [\"rule-id\", \"object-id\", \"action\", \"limit\"] as const) {\n if (args[key]) params[key] = String(args[key]);\n }\n if (args[\"hide-no-changes\"]) params[\"hide-no-changes\"] = \"true\";\n const rows = await apiGet<MetaAdRuleHistoryRow[]>(\"/api/ads/meta/rules/history\", params);\n const hints =\n rows.length === 0\n ? [\n \"No runs recorded. A daily rule first runs just after midnight in the ad account's time zone; a switched-off rule never runs.\",\n ]\n : [];\n writeJsonEnvelope({ ok: true, data: args.full ? rows : rows.map(compactHistory), hints });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nregisterSchema({\n command: \"ads.meta.rules.preview\",\n description:\n \"Which ads, ad sets or campaigns a live schedule rule would act on right now, by Meta's own evaluation. Changes nothing.\",\n args: {\n id: { type: \"positional\", description: \"Rule id\", required: true },\n \"account-id\": { type: \"string\", description: \"Meta ad account ID (act_123)\", required: false },\n },\n});\n\nconst previewCommand = defineCommand({\n meta: {\n name: \"preview\",\n description:\n \"What a rule would act on right now (changes nothing). Example: baker ads meta rules preview 1132635173044914\",\n },\n args: {\n id: { type: \"positional\", description: \"Rule id\", required: true },\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const data = await apiGet<{ ruleId: string; matched: unknown[] }>(\"/api/ads/meta/rules/preview\", {\n \"account-id\": accountId,\n \"rule-id\": String(args.id),\n });\n const hints =\n data.matched.length === 0 ? [\"Nothing matches right now — the rule would change nothing if it ran now.\"] : [];\n writeJsonEnvelope({ ok: true, data, hints });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const rulesCommand = defineCommand({\n meta: {\n name: \"rules\",\n description: `Meta automated rules — Meta's own automation, which runs on Meta with no Baker involvement once created.\nUse one for a standing \"if this metric crosses that line, do X\" that needs no judgement; use a Baker scheduled agent when the call needs reasoning.\n\nExamples:\n baker ads meta rules --account-id act_123 # every rule, what it does\n baker ads meta rules --rule-id 1132635173044914 # one rule with its specs\n baker ads meta rules history --rule-id 1132635173044914 --hide-no-changes # what it did\n baker ads meta rules preview 1132635173044914 # what it would act on now\n baker ads meta rules create --name \"Stop expensive ads\" --apply-to ad --when \"cost_per_result>20\" --action pause\n baker ads meta rules update 1132635173044914 --name \"Stop very expensive ads\"\n baker ads meta rules disable|enable|delete 1132635173044914\n baker ads meta rules run 1132635173044914 # run it once, at publish`,\n },\n subCommands: {\n list: listCommand,\n history: historyCommand,\n preview: previewCommand,\n create: () => import(\"./rule-writes.ts\").then((m) => m.rulesCreateCommand),\n update: () => import(\"./rule-writes.ts\").then((m) => m.rulesUpdateCommand),\n enable: () => import(\"./rule-writes.ts\").then((m) => m.rulesEnableCommand),\n disable: () => import(\"./rule-writes.ts\").then((m) => m.rulesDisableCommand),\n delete: () => import(\"./rule-writes.ts\").then((m) => m.rulesDeleteCommand),\n run: () => import(\"./rule-writes.ts\").then((m) => m.rulesRunCommand),\n },\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n \"rule-id\": { type: \"string\", description: \"Read one rule\" },\n full: { type: \"boolean\", description: \"Include the specs and timestamps\" },\n },\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,SAAS,qBAAqB;AAcvB,SAAS,YAAY,KAA6C;AACvE,SAAO;AAAA,IACL,IAAI,IAAI;AAAA,IACR,MAAM,IAAI;AAAA,IACV,QAAQ,IAAI;AAAA,IACZ,MAAM,IAAI;AAAA,IACV,GAAI,IAAI,qBAAqB,EAAE,oBAAoB,IAAI,mBAAmB,IAAI,CAAC;AAAA,IAC/E,cAAc,IAAI;AAAA,EACpB;AACF;AAEO,SAAS,cAAc,MAA0C;AACtE,QAAM,QAAkB,CAAC;AACzB,MAAI,KAAK,WAAW,GAAG;AACrB,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACA,QAAM,SAAS,KAAK,OAAO,CAAC,QAAQ,IAAI,WAAW,YAAY;AAC/D,MAAI,OAAO,SAAS,GAAG;AACrB,UAAM;AAAA,MACJ,GAAG,OAAO,IAAI,CAAC,QAAQ,IAAI,QAAQ,IAAI,EAAE,EAAE,KAAK,IAAI,CAAC,IAAI,OAAO,WAAW,IAAI,QAAQ,MAAM;AAAA,IAC/F;AAAA,EACF;AACA,MAAI,KAAK,SAAS,GAAG;AACnB,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aACE;AAAA,EACF,MAAM;AAAA,IACJ,cAAc,EAAE,MAAM,UAAU,aAAa,gCAAgC,UAAU,MAAM;AAAA,IAC7F,WAAW,EAAE,MAAM,UAAU,aAAa,iBAAiB,UAAU,MAAM;AAAA,IAC3E,MAAM,EAAE,MAAM,WAAW,aAAa,oCAAoC,UAAU,MAAM;AAAA,EAC5F;AACF,CAAC;AAED,IAAM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
4
|
daysAgoIso,
|
|
7
5
|
getDateRange,
|
|
8
6
|
handleMetaError,
|
|
9
|
-
listingLimit,
|
|
10
|
-
loggedAt,
|
|
11
7
|
metaForbiddenFix,
|
|
12
8
|
normalizeMetaAccountId,
|
|
13
|
-
readEachAccount,
|
|
14
9
|
resolveAccountIdArg,
|
|
15
10
|
resolveEffectiveStatus,
|
|
16
11
|
statusFilterHints,
|
|
17
|
-
todayIso
|
|
18
|
-
|
|
19
|
-
} from "./chunk-YF57BX3S.js";
|
|
12
|
+
todayIso
|
|
13
|
+
} from "./chunk-DP76WGDV.js";
|
|
20
14
|
import "./chunk-QALAJNBG.js";
|
|
21
15
|
import "./chunk-NX4EB2TK.js";
|
|
22
16
|
import "./chunk-EHEPW3O2.js";
|
|
@@ -25,22 +19,16 @@ import "./chunk-RNSC5JPH.js";
|
|
|
25
19
|
import "./chunk-2RTB2DDO.js";
|
|
26
20
|
import "./chunk-YQSBHWOI.js";
|
|
27
21
|
export {
|
|
28
|
-
LISTING_ACCOUNT_ARG,
|
|
29
22
|
NAME_CONTAINS_ARG,
|
|
30
|
-
accountsInScope,
|
|
31
23
|
csvOrJson,
|
|
32
24
|
daysAgoIso,
|
|
33
25
|
getDateRange,
|
|
34
26
|
handleMetaError,
|
|
35
|
-
listingLimit,
|
|
36
|
-
loggedAt,
|
|
37
27
|
metaForbiddenFix,
|
|
38
28
|
normalizeMetaAccountId,
|
|
39
|
-
readEachAccount,
|
|
40
29
|
resolveAccountIdArg,
|
|
41
30
|
resolveEffectiveStatus,
|
|
42
31
|
statusFilterHints,
|
|
43
|
-
todayIso
|
|
44
|
-
withAccountColumn
|
|
32
|
+
todayIso
|
|
45
33
|
};
|
|
46
|
-
//# sourceMappingURL=shared-
|
|
34
|
+
//# sourceMappingURL=shared-64RE42DL.js.map
|
|
@@ -4,12 +4,9 @@ import {
|
|
|
4
4
|
unixSeconds
|
|
5
5
|
} from "./chunk-GDFJOCDO.js";
|
|
6
6
|
import {
|
|
7
|
-
LISTING_ACCOUNT_ARG,
|
|
8
|
-
accountsInScope,
|
|
9
7
|
handleMetaError,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "./chunk-YF57BX3S.js";
|
|
8
|
+
resolveAccountIdArg
|
|
9
|
+
} from "./chunk-DP76WGDV.js";
|
|
13
10
|
import "./chunk-QALAJNBG.js";
|
|
14
11
|
import {
|
|
15
12
|
NO_CACHE_ARG
|
|
@@ -170,9 +167,9 @@ function studyHints(detail) {
|
|
|
170
167
|
}
|
|
171
168
|
registerSchema({
|
|
172
169
|
command: "ads.meta.studies",
|
|
173
|
-
description: "Meta A/B tests (ad studies) whose versions run in an ad account \u2014 what each compares, when it runs and its state (scheduled, running, ended). --study-id reads one: every version with its cell id and share, and each measure with Meta's results. --business-id lists every test on a Business. Stage new ones with `studies create`.
|
|
170
|
+
description: "Meta A/B tests (ad studies) whose versions run in an ad account \u2014 what each compares, when it runs and its state (scheduled, running, ended). --study-id reads one: every version with its cell id and share, and each measure with Meta's results. --business-id lists every test on a Business. Stage new ones with `studies create`.",
|
|
174
171
|
args: {
|
|
175
|
-
"account-id": {
|
|
172
|
+
"account-id": { type: "string", description: "Meta ad account ID (act_123)", required: false },
|
|
176
173
|
"business-id": { type: "string", description: "List every test on this Business instead", required: false },
|
|
177
174
|
"study-id": { type: "string", description: "One test: its versions and results", required: false },
|
|
178
175
|
full: { type: "boolean", description: "The tests as Meta returns them", required: false },
|
|
@@ -180,7 +177,7 @@ registerSchema({
|
|
|
180
177
|
}
|
|
181
178
|
});
|
|
182
179
|
var listArgs = {
|
|
183
|
-
"account-id":
|
|
180
|
+
"account-id": { type: "string", description: "Meta ad account ID" },
|
|
184
181
|
"business-id": { type: "string", description: "List every test on this Business instead" },
|
|
185
182
|
"study-id": { type: "string", description: "Read one test: versions, cell ids, results" },
|
|
186
183
|
full: { type: "boolean", description: "The tests as Meta returns them" },
|
|
@@ -209,26 +206,12 @@ var listCommand = defineCommand({
|
|
|
209
206
|
writeJsonEnvelope({ ok: true, data: args.full ? row : detail, hints: studyHints(detail) });
|
|
210
207
|
return;
|
|
211
208
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
hints: []
|
|
219
|
-
} : await readEachAccount(
|
|
220
|
-
await accountsInScope(args),
|
|
221
|
-
(accountId) => read("/api/ads/meta/studies", { "account-id": accountId }, args["no-cache"])
|
|
222
|
-
);
|
|
223
|
-
const { rows } = listed;
|
|
224
|
-
const hints = [
|
|
225
|
-
...listed.hints,
|
|
226
|
-
...rows.length === 0 ? [
|
|
227
|
-
"No A/B tests. To set one up: duplicate the ad set (`adsets duplicate`), change ONE thing on the copy, then `studies create --adsets <original>,<copy>`."
|
|
228
|
-
] : ["`studies --study-id <id>` reads one test's versions and results."]
|
|
229
|
-
];
|
|
230
|
-
const data = withAccountColumn(args.full ? rows : rows.map((row) => compactStudy(row, now)), listed.accountOf);
|
|
231
|
-
writeJsonEnvelope({ ok: true, data, hints });
|
|
209
|
+
const params = args["business-id"] ? { "business-id": String(args["business-id"]) } : { "account-id": await resolveAccountIdArg(args) };
|
|
210
|
+
const rows = await read("/api/ads/meta/studies", params, args["no-cache"]);
|
|
211
|
+
const hints = rows.length === 0 ? [
|
|
212
|
+
"No A/B tests. To set one up: duplicate the ad set (`adsets duplicate`), change ONE thing on the copy, then `studies create --adsets <original>,<copy>`."
|
|
213
|
+
] : ["`studies --study-id <id>` reads one test's versions and results."];
|
|
214
|
+
writeJsonEnvelope({ ok: true, data: args.full ? rows : rows.map((row) => compactStudy(row, now)), hints });
|
|
232
215
|
} catch (err) {
|
|
233
216
|
handleMetaError(err);
|
|
234
217
|
}
|
|
@@ -249,10 +232,10 @@ Examples:
|
|
|
249
232
|
},
|
|
250
233
|
subCommands: {
|
|
251
234
|
list: listCommand,
|
|
252
|
-
create: () => import("./study-writes-
|
|
253
|
-
update: () => import("./study-writes-
|
|
254
|
-
end: () => import("./study-writes-
|
|
255
|
-
delete: () => import("./study-writes-
|
|
235
|
+
create: () => import("./study-writes-HXUQRPIK.js").then((m) => m.studiesCreateCommand),
|
|
236
|
+
update: () => import("./study-writes-HXUQRPIK.js").then((m) => m.studiesUpdateCommand),
|
|
237
|
+
end: () => import("./study-writes-HXUQRPIK.js").then((m) => m.studiesEndCommand),
|
|
238
|
+
delete: () => import("./study-writes-HXUQRPIK.js").then((m) => m.studiesDeleteCommand)
|
|
256
239
|
},
|
|
257
240
|
args: listArgs,
|
|
258
241
|
default: "list"
|
|
@@ -264,4 +247,4 @@ export {
|
|
|
264
247
|
studyHints,
|
|
265
248
|
studyState
|
|
266
249
|
};
|
|
267
|
-
//# sourceMappingURL=studies-
|
|
250
|
+
//# sourceMappingURL=studies-357M2C2K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../api/src/ads-meta/adStudyDescription.ts","../src/commands/ads/meta/studies.ts"],"sourcesContent":["/**\n * A Meta A/B test in words — the one reading shared by the staged summary, the\n * draft review rows and the CLI, so all three say the same thing: what each\n * version runs and how much of the audience it gets, what decides the winner,\n * for how long, and how sure Meta has to be.\n */\nimport type { AdStudyCell, AdStudyObjective } from \"./adStudies\";\n\nexport interface AdStudyWordsInput {\n type?: string;\n start_time?: number;\n end_time?: number;\n confidence_level?: number;\n cells?: readonly Pick<\n AdStudyCell,\n \"name\" | \"treatment_percentage\" | \"control_percentage\" | \"adsets\" | \"campaigns\" | \"ads\"\n >[];\n objectives?: readonly AdStudyObjective[];\n}\n\nexport interface AdStudyWords {\n sentence: string;\n versions?: string;\n measuring: string;\n /** The measures besides the primary one, by name. */\n alsoMeasured?: string;\n schedule?: string;\n confidence?: string;\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nexport function adStudyTime(seconds: number): string {\n const date = new Date(seconds * 1000);\n const hh = String(date.getUTCHours()).padStart(2, \"0\");\n const mm = String(date.getUTCMinutes()).padStart(2, \"0\");\n return `${date.getUTCDate()} ${MONTHS[date.getUTCMonth()]} ${date.getUTCFullYear()}, ${hh}:${mm} UTC`;\n}\n\nfunction daysLabel(seconds: number): string {\n const days = Math.round((seconds / 86_400) * 10) / 10;\n return `${days} ${days === 1 ? \"day\" : \"days\"}`;\n}\n\nfunction quoted(id: string, names: Record<string, string>): string {\n const name = names[id];\n return name ? `\"${name}\"` : id;\n}\n\nfunction cellWords(\n cell: Pick<AdStudyCell, \"name\" | \"treatment_percentage\" | \"control_percentage\" | \"adsets\" | \"campaigns\" | \"ads\">,\n names: Record<string, string>,\n): string {\n const [noun, ids] = cell.ads\n ? [\"ad\", cell.ads]\n : cell.adsets\n ? [\"ad set\", cell.adsets]\n : [\"campaign\", cell.campaigns ?? []];\n const plural = ids.length > 1 ? `${noun}s` : noun;\n const runs = ids.length > 0 ? ` (${plural} ${ids.map((id) => quoted(id, names)).join(\", \")})` : \"\";\n const share =\n cell.control_percentage === undefined\n ? `${cell.treatment_percentage}%`\n : `${cell.treatment_percentage}% see the ads, ${cell.control_percentage}% held out`;\n return `${cell.name}${runs} ${share}`;\n}\n\nconst STUDY_KIND: Record<string, string> = {\n SPLIT_TEST: \"Split test\",\n LIFT: \"Lift study\",\n SPLIT_TEST_V2: \"Creative test\",\n};\n\nfunction primaryObjective(objectives: readonly AdStudyObjective[] | undefined): AdStudyObjective | undefined {\n if (!objectives || objectives.length === 0) {\n return undefined;\n }\n return objectives.find((objective) => objective.is_primary === true) ?? objectives[0];\n}\n\nconst SOURCE_NOUN: Record<\"adspixels\" | \"applications\" | \"offsite_datasets\", string> = {\n adspixels: \"pixel\",\n applications: \"app\",\n offsite_datasets: \"dataset\",\n};\n\n/** \"Lead on pixel \"Site\"\", one per event source. */\nfunction sourceWords(objective: AdStudyObjective, names: Record<string, string>): string[] {\n const words: string[] = [];\n for (const key of [\"adspixels\", \"applications\", \"offsite_datasets\"] as const) {\n for (const source of objective[key] ?? []) {\n const events = source.event_names?.join(\" or \") ?? \"any event\";\n words.push(`${events} on ${SOURCE_NOUN[key]} ${quoted(source.id, names)}`);\n }\n }\n for (const source of objective.customconversions ?? []) {\n words.push(`custom conversion ${quoted(source.id, names)}`);\n }\n return words;\n}\n\n/** What decides the winner. Meta's split test compares cost per result of the primary measure. */\nfunction measuringWords(objectives: readonly AdStudyObjective[] | undefined, names: Record<string, string>): string {\n const primary = primaryObjective(objectives);\n if (!primary) {\n return \"cost per result on the campaigns' objective\";\n }\n const sources = sourceWords(primary, names);\n return `cost per \"${primary.name}\"${sources.length > 0 ? ` (${sources.join(\", \")})` : \"\"}`;\n}\n\n/** What the sentence says the study measures: a lift study reads the lift, a test the cost per result. */\nfunction measuringPhrase(type: string | undefined, primary: AdStudyObjective | undefined, measuring: string): string {\n if (type === \"LIFT\") return `measuring the lift in ${primary ? `\"${primary.name}\"` : \"results\"}`;\n return `measuring ${primary ? `cost per \"${primary.name}\"` : measuring}`;\n}\n\nexport function describeAdStudy(\n study: AdStudyWordsInput,\n { names = {} }: { names?: Record<string, string> } = {},\n): AdStudyWords {\n const versions =\n study.cells && study.cells.length > 0 ? study.cells.map((cell) => cellWords(cell, names)).join(\" vs \") : undefined;\n const measuring = measuringWords(study.objectives, names);\n const primary = primaryObjective(study.objectives);\n const others = (study.objectives ?? []).filter((objective) => objective !== primary);\n const alsoMeasured = others.length > 0 ? others.map((objective) => `\"${objective.name}\"`).join(\", \") : undefined;\n const hasSchedule = study.start_time !== undefined && study.end_time !== undefined;\n const length = hasSchedule ? daysLabel((study.end_time ?? 0) - (study.start_time ?? 0)) : undefined;\n const schedule = hasSchedule\n ? `${adStudyTime(study.start_time ?? 0)} → ${adStudyTime(study.end_time ?? 0)} · ${length}`\n : undefined;\n const confidence = study.confidence_level !== undefined ? `${Math.round(study.confidence_level * 100)}%` : undefined;\n const parts = [\n versions,\n measuringPhrase(study.type, primary, measuring),\n length,\n confidence ? `${confidence} confidence` : undefined,\n ].filter((part): part is string => part !== undefined);\n const kind = STUDY_KIND[study.type ?? \"SPLIT_TEST\"] ?? \"Split test\";\n return { sentence: `${kind}: ${parts.join(\", \")}`, versions, measuring, alsoMeasured, schedule, confidence };\n}\n","import { adStudyFromWire, cellObjects, unixSeconds } from \"@baker/api/ads-meta/adStudies\";\nimport { adStudyTime, describeAdStudy } from \"@baker/api/ads-meta/adStudyDescription\";\nimport { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { registerSchema } from \"../../../schemas.ts\";\nimport { writeJsonEnvelope } from \"../output.ts\";\nimport { handleMetaError, resolveAccountIdArg } from \"./shared.ts\";\n\n/**\n * Meta A/B tests (ad studies) — reads. A test splits one audience between\n * versions (ad sets, campaigns, or a creative test's ads) so each person sees one, and Meta calls the\n * winner. Writes (create / update / end / delete) stage like every Meta change\n * and live in `study-writes.ts`.\n */\n\ntype Row = Record<string, unknown>;\n\nexport type StudyState = \"scheduled\" | \"running\" | \"ended\" | \"cancelled\";\n\nexport function studyState(row: Row, nowSeconds: number): StudyState {\n if (row.canceled_time) return \"cancelled\";\n const start = unixSeconds(row.start_time) ?? 0;\n const end = unixSeconds(row.end_time) ?? Number.POSITIVE_INFINITY;\n if (nowSeconds < start) return \"scheduled\";\n return nowSeconds < end ? \"running\" : \"ended\";\n}\n\n/** What an agent needs to pick a test and know what it compares. The raw node sits behind --full. */\nexport function compactStudy(row: Row, nowSeconds: number): Row {\n const study = adStudyFromWire(row);\n const words = describeAdStudy(study, { names: study.names });\n return {\n id: study.id,\n name: study.name,\n state: studyState(row, nowSeconds),\n compares: words.versions,\n ...(study.start_time !== undefined ? { starts: adStudyTime(study.start_time) } : {}),\n ...(study.end_time !== undefined ? { ends: adStudyTime(study.end_time) } : {}),\n ...(row.results_first_available_date ? { results_from: row.results_first_available_date } : {}),\n };\n}\n\n/** One test in full: each version with its cell id (what `studies update --split` names), each measure with Meta's results. */\nexport function studyDetail(row: Row, nowSeconds: number): Row {\n const study = adStudyFromWire(row);\n const measures = ((row.objectives as { data?: Row[] } | undefined)?.data ?? []).map((objective) => ({\n id: objective.id,\n name: objective.name,\n primary: objective.is_primary === true,\n ...(objective.results !== undefined ? { results: objective.results } : {}),\n }));\n return {\n ...compactStudy(row, nowSeconds),\n ...(study.description ? { description: study.description } : {}),\n versions: study.cells.map((cell) => ({\n cell_id: cell.id,\n name: cell.name,\n share: `${cell.treatment_percentage}%`,\n runs: cellObjects(cell).map((id) => ({ id, name: study.names[id] })),\n level: cell.ads ? \"ad\" : cell.adsets ? \"ad set\" : \"campaign\",\n })),\n measures,\n };\n}\n\nexport function studyHints(detail: Row): string[] {\n const state = detail.state as StudyState;\n if (state === \"scheduled\") {\n return [\n \"Not started: it can still be re-timed, re-split (`studies update --split <cell_id>=60 …`) or deleted. Results appear once it runs.\",\n ];\n }\n const measures = (detail.measures as Row[] | undefined) ?? [];\n const hasResults = measures.some((measure) => measure.results !== undefined);\n return [\n hasResults\n ? \"Meta's verdict is in each measure's results, with its confidence. Report a winner only when Meta names one at the test's confidence level; otherwise say the versions performed alike.\"\n : \"No results yet — Meta publishes them once the test has gathered enough. Compare per-version delivery meanwhile with `baker ads meta insights --object <ad set or campaign id>`, and do not call a winner from it.\",\n state === \"running\"\n ? \"Running: its split and start are fixed; it can be renamed, its end moved, ended now (`studies end`) or deleted (results and all).\"\n : \"Over. Read the per-version numbers with `baker ads meta insights --object <id>` for the period it ran.\",\n ];\n}\n\nregisterSchema({\n command: \"ads.meta.studies\",\n description:\n \"Meta A/B tests (ad studies) whose versions run in an ad account — what each compares, when it runs and its state (scheduled, running, ended). --study-id reads one: every version with its cell id and share, and each measure with Meta's results. --business-id lists every test on a Business. Stage new ones with `studies create`.\",\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID (act_123)\", required: false },\n \"business-id\": { type: \"string\", description: \"List every test on this Business instead\", required: false },\n \"study-id\": { type: \"string\", description: \"One test: its versions and results\", required: false },\n full: { type: \"boolean\", description: \"The tests as Meta returns them\", required: false },\n \"no-cache\": { type: \"boolean\", description: \"Bypass the cache\", required: false },\n },\n});\n\nconst listArgs = {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n \"business-id\": { type: \"string\", description: \"List every test on this Business instead\" },\n \"study-id\": { type: \"string\", description: \"Read one test: versions, cell ids, results\" },\n full: { type: \"boolean\", description: \"The tests as Meta returns them\" },\n \"no-cache\": NO_CACHE_ARG,\n} as const;\n\nasync function read<T>(path: string, params: Record<string, string>, noCache: unknown): Promise<T> {\n if (noCache) params[\"skip-cache\"] = \"true\";\n return await apiGet<T>(path, params);\n}\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description:\n \"List A/B tests. Runs by default. Example: baker ads meta studies --account-id act_123 · one test: baker ads meta studies --study-id 6123\",\n },\n args: listArgs,\n run: async ({ args }) => {\n const now = Math.floor(Date.now() / 1000);\n try {\n if (args[\"study-id\"]) {\n const row = await read<Row>(\n \"/api/ads/meta/study-results\",\n { \"study-id\": String(args[\"study-id\"]) },\n args[\"no-cache\"],\n );\n const detail = studyDetail(row, now);\n writeJsonEnvelope({ ok: true, data: args.full ? row : detail, hints: studyHints(detail) });\n return;\n }\n const params: Record<string, string> = args[\"business-id\"]\n ? { \"business-id\": String(args[\"business-id\"]) }\n : { \"account-id\": await resolveAccountIdArg(args) };\n const rows = await read<Row[]>(\"/api/ads/meta/studies\", params, args[\"no-cache\"]);\n const hints =\n rows.length === 0\n ? [\n \"No A/B tests. To set one up: duplicate the ad set (`adsets duplicate`), change ONE thing on the copy, then `studies create --adsets <original>,<copy>`.\",\n ]\n : [\"`studies --study-id <id>` reads one test's versions and results.\"];\n writeJsonEnvelope({ ok: true, data: args.full ? rows : rows.map((row) => compactStudy(row, now)), hints });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const studiesCommand = defineCommand({\n meta: {\n name: \"studies\",\n description: `Meta A/B tests (ad studies): Meta splits one audience between versions — ad sets or campaigns — so each person sees one, and calls the winner.\nNot Baker's own page experiments (\\`baker experiment\\`), which test landing pages.\n\nExamples:\n baker ads meta studies --account-id act_123 # tests on this account and their state\n baker ads meta studies --study-id 6123 # versions, cell ids, Meta's results\n baker ads meta studies create --name \"Broad vs lookalike\" --adsets 6123,6124 --start 2026-10-20T08:00Z --days 14 --confidence 90\n baker ads meta studies update 6123 --end 2026-11-10T08:00Z\n baker ads meta studies end 6123 | delete 6123`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./study-writes.ts\").then((m) => m.studiesCreateCommand),\n update: () => import(\"./study-writes.ts\").then((m) => m.studiesUpdateCommand),\n end: () => import(\"./study-writes.ts\").then((m) => m.studiesEndCommand),\n delete: () => import(\"./study-writes.ts\").then((m) => m.studiesDeleteCommand),\n },\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAM,SAAS,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAE3F,SAAS,YAAY,SAAyB;AACnD,QAAM,OAAO,IAAI,KAAK,UAAU,GAAI;AACpC,QAAM,KAAK,OAAO,KAAK,YAAY,CAAC,EAAE,SAAS,GAAG,GAAG;AACrD,QAAM,KAAK,OAAO,KAAK,cAAc,CAAC,EAAE,SAAS,GAAG,GAAG;AACvD,SAAO,GAAG,KAAK,WAAW,CAAC,IAAI,OAAO,KAAK,YAAY,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE;AACjG;AAEA,SAAS,UAAU,SAAyB;AAC1C,QAAM,OAAO,KAAK,MAAO,UAAU,QAAU,EAAE,IAAI;AACnD,SAAO,GAAG,IAAI,IAAI,SAAS,IAAI,QAAQ,MAAM;AAC/C;AAEA,SAAS,OAAO,IAAY,OAAuC;AACjE,QAAM,OAAO,MAAM,EAAE;AACrB,SAAO,OAAO,IAAI,IAAI,MAAM;AA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C;AAChF,YAAM,QACJ,KAAK,WAAW,IACZ;AAAA,QACE;AAAA,MACF,IACA,CAAC,kEAAkE;AACzE,wBAAkB,EAAE,IAAI,MAAM,MAAM,KAAK,OAAO,OAAO,KAAK,IAAI,CAAC,QAAQ,aAAa,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC;AAAA,IAC3G,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;AAEM,IAAM,iBAAiB,cAAc;AAAA,EAC1C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASf;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,QAAQ,MAAM,OAAO,4BAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,oBAAoB;AAAA,IAC5E,QAAQ,MAAM,OAAO,4BAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,oBAAoB;AAAA,IAC5E,KAAK,MAAM,OAAO,4BAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,iBAAiB;AAAA,IACtE,QAAQ,MAAM,OAAO,4BAAmB,EAAE,KAAK,CAAC,MAAM,EAAE,oBAAoB;AAAA,EAC9E;AAAA,EACA,MAAM;AAAA,EACN,SAAS;AACX,CAAC;","names":[]}
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
loadJsonFileArg,
|
|
6
6
|
requireTarget,
|
|
7
7
|
stageOp
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
9
9
|
import "./chunk-3R62EYYX.js";
|
|
10
10
|
import "./chunk-GDFJOCDO.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-DP76WGDV.js";
|
|
12
12
|
import "./chunk-XD7C5OE7.js";
|
|
13
13
|
import "./chunk-UKENQSZ2.js";
|
|
14
14
|
import "./chunk-D5FY4FAK.js";
|
|
@@ -472,4 +472,4 @@ export {
|
|
|
472
472
|
studiesUpdateCommand,
|
|
473
473
|
studyFlagsFromArgs
|
|
474
474
|
};
|
|
475
|
-
//# sourceMappingURL=study-writes-
|
|
475
|
+
//# sourceMappingURL=study-writes-HXUQRPIK.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-PRPSV4VB.js";
|
|
5
5
|
import {
|
|
6
6
|
loadJsonFileArg
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
8
8
|
import {
|
|
9
9
|
metaTargetingSchema
|
|
10
10
|
} from "./chunk-3R62EYYX.js";
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
csvOrJson,
|
|
14
14
|
handleMetaError,
|
|
15
15
|
resolveAccountIdArg
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-DP76WGDV.js";
|
|
17
17
|
import "./chunk-XD7C5OE7.js";
|
|
18
18
|
import "./chunk-UKENQSZ2.js";
|
|
19
19
|
import "./chunk-D5FY4FAK.js";
|
|
@@ -774,4 +774,4 @@ Start here before writing interests, behaviors, places or languages into an ad s
|
|
|
774
774
|
export {
|
|
775
775
|
targetingCommand
|
|
776
776
|
};
|
|
777
|
-
//# sourceMappingURL=targeting-
|
|
777
|
+
//# sourceMappingURL=targeting-7T7XHBIX.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleMetaError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DP76WGDV.js";
|
|
4
4
|
import "./chunk-QALAJNBG.js";
|
|
5
5
|
import {
|
|
6
6
|
writeJsonEnvelope
|
|
@@ -143,4 +143,4 @@ export {
|
|
|
143
143
|
downloadHints,
|
|
144
144
|
videosCommand
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=videos-
|
|
146
|
+
//# sourceMappingURL=videos-TJG5CA7N.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
budgetBoostsFromFlags,
|
|
8
8
|
clearArg,
|
|
9
9
|
clearFromFlags
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-EGM42UKF.js";
|
|
11
11
|
import {
|
|
12
12
|
bareAccountId,
|
|
13
13
|
failWriteValidation,
|
|
@@ -25,14 +25,14 @@ import {
|
|
|
25
25
|
stageOp,
|
|
26
26
|
stageStatusChange,
|
|
27
27
|
upper
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
29
29
|
import {
|
|
30
30
|
buildCustomConversionRule
|
|
31
31
|
} from "./chunk-3R62EYYX.js";
|
|
32
32
|
import {
|
|
33
33
|
VISUAL_ENHANCEMENT_FEATURES
|
|
34
34
|
} from "./chunk-GDFJOCDO.js";
|
|
35
|
-
import "./chunk-
|
|
35
|
+
import "./chunk-DP76WGDV.js";
|
|
36
36
|
import "./chunk-XD7C5OE7.js";
|
|
37
37
|
import "./chunk-UKENQSZ2.js";
|
|
38
38
|
import "./chunk-D5FY4FAK.js";
|
|
@@ -481,7 +481,7 @@ Example: baker ads meta adsets create --campaign 6123 --name "Reach ES" --optimi
|
|
|
481
481
|
const file = loadJsonFileArg(args.file);
|
|
482
482
|
const payload = mergePayload(file, adSetPayloadFromFlags(args, rawArgs, file));
|
|
483
483
|
if (args["saved-audience"]) {
|
|
484
|
-
const { savedAudienceTargeting, targetingFromSavedAudience } = await import("./audience-writes-
|
|
484
|
+
const { savedAudienceTargeting, targetingFromSavedAudience } = await import("./audience-writes-NL6NRLLY.js");
|
|
485
485
|
const saved = await savedAudienceTargeting(accountId, String(args["saved-audience"]));
|
|
486
486
|
const merged = targetingFromSavedAudience(saved, payload.targeting);
|
|
487
487
|
if ("refusal" in merged) failWriteValidation(merged.refusal);
|
|
@@ -945,7 +945,7 @@ Example: baker ads meta ads retag 120252158038400247 --url-tags "utm_source={{si
|
|
|
945
945
|
const { apiPost } = await import("./client-T7LLEL5L.js");
|
|
946
946
|
const { requireChatId } = await import("./env-Q5OHLIQU.js");
|
|
947
947
|
const { writeJsonEnvelope } = await import("./output-CYHSMLZ6.js");
|
|
948
|
-
const { handleMetaError } = await import("./shared-
|
|
948
|
+
const { handleMetaError } = await import("./shared-64RE42DL.js");
|
|
949
949
|
try {
|
|
950
950
|
const accountId = await bareAccountId(args);
|
|
951
951
|
const urlTags = typeof args["url-tags"] === "string" ? args["url-tags"] : void 0;
|
|
@@ -1183,7 +1183,7 @@ function duplicateCommand(entity, label) {
|
|
|
1183
1183
|
const { apiPost } = await import("./client-T7LLEL5L.js");
|
|
1184
1184
|
const { requireChatId } = await import("./env-Q5OHLIQU.js");
|
|
1185
1185
|
const { writeJsonEnvelope } = await import("./output-CYHSMLZ6.js");
|
|
1186
|
-
const { handleMetaError } = await import("./shared-
|
|
1186
|
+
const { handleMetaError } = await import("./shared-64RE42DL.js");
|
|
1187
1187
|
try {
|
|
1188
1188
|
const accountId = await bareAccountId(args);
|
|
1189
1189
|
const chatId = requireChatId();
|
|
@@ -1258,4 +1258,4 @@ export {
|
|
|
1258
1258
|
retagSetPairs,
|
|
1259
1259
|
targetingFromFlags
|
|
1260
1260
|
};
|
|
1261
|
-
//# sourceMappingURL=write-commands-
|
|
1261
|
+
//# sourceMappingURL=write-commands-4KI6T2NF.js.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/meta/account-assets.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { registerSchema } from \"../../../schemas.ts\";\nimport { writeAdsOutput, writeJsonEnvelope } from \"../output.ts\";\nimport {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n LISTING_ACCOUNT_ARG,\n listingLimit,\n type ReadEachAccountOptions,\n readEachAccount,\n resolveAccountIdArg,\n withAccountColumn,\n} from \"./shared.ts\";\n\n/**\n * The account's identities and libraries an ad is built from — reads that used\n * to exist only as backend routes. They were left off the CLI as \"rarely\n * needed in isolation\", but each answers a question staging otherwise answers\n * with a refusal: which Instagram account an ad can run as, which apps it can\n * promote, whom an EU ad names, what an image hash or label id is, which\n * product sets a catalog ad can use, what an A/B test found.\n */\n\ntype Row = Record<string, unknown>;\ntype Args = Record<string, unknown>;\n\nfunction emit(rows: Row[], args: Args, hints: string[]): void {\n const fmt = csvOrJson(args);\n if (fmt !== \"json\") {\n writeAdsOutput(rows, fmt, undefined, hints);\n return;\n }\n writeJsonEnvelope(hints.length > 0 ? { ok: true, data: rows, hints } : { ok: true, data: rows });\n}\n\nasync function read<T>(path: string, params: Record<string, string>, args: Args): Promise<T> {\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n return await apiGet<T>(path, params);\n}\n\n/** An account listing: the named account, else every connected one with each row's account_id. */\nasync function readAccounts<T>(\n path: string,\n params: Record<string, string>,\n args: Args,\n options: ReadEachAccountOptions<T> = {},\n): Promise<{ rows: T[]; tag: <R extends object>(rows: R[]) => R[]; hints: string[] }> {\n const accounts = await accountsInScope(args);\n const listed = await readEachAccount(\n accounts,\n (accountId) => read<T[]>(path, { ...params, \"account-id\": accountId }, args),\n options,\n );\n return { rows: listed.rows, tag: (rows) => withAccountColumn(rows, listed.accountOf), hints: listed.hints };\n}\n\nconst outputArg = { type: \"string\", description: \"json|csv|jsonl|md\", default: \"json\" } as const;\nconst accountArg = { type: \"string\", description: \"Meta ad account ID (act_...)\" } as const;\nconst schemaAccount = { type: \"string\", description: \"Meta ad account ID (act_123)\", required: false };\nconst schemaListingAccount = { ...LISTING_ACCOUNT_ARG, required: false };\nconst schemaNoCache = { type: \"boolean\", description: \"Bypass the cache\", required: false };\nconst schemaOutput = { type: \"string\", description: \"json|csv|jsonl|md\", required: false, default: \"json\" };\n\n// --- Instagram identities ---\n\nexport interface MetaInstagramIdentity {\n id: string;\n username?: string;\n sources: Array<\"ad_account\" | \"connected\" | \"page\" | \"page_backed\">;\n pageId?: string;\n pageName?: string;\n}\n\nexport function instagramIdentityHints(rows: readonly MetaInstagramIdentity[]): string[] {\n if (rows.length === 0) {\n return [\n \"No Instagram account is linked to this ad account or its Pages. A creative without --instagram-user cannot run in Instagram feeds, Stories or Reels — the account owner links one in Meta Business settings (Accounts → Instagram accounts) and assigns it to the ad account.\",\n ];\n }\n const listed = rows.filter((row) => row.sources.includes(\"ad_account\") || row.sources.includes(\"connected\"));\n const hints = [\"Pass the id as `creatives create --instagram-user <id>`.\"];\n if (listed.length > 0 && listed.length < rows.length) {\n hints.push(\n `Use one listed on the ad account (${listed.map((row) => row.username ?? row.id).join(\", \")}): when the account lists any, staging refuses an identity it does not list.`,\n );\n } else if (listed.length === 0) {\n hints.push(\n \"Only Page identities are listed (page = the Page's linked Instagram account, page_backed = an Instagram presence Meta made for a Page with none). Meta accepts either as --instagram-user; a page_backed one shows the Page's name and picture on Instagram.\",\n );\n }\n if (new Set(rows.map((row) => row.pageId).filter(Boolean)).size > 1) {\n hints.push(\"Several Pages are involved — use the identity of the Page the creative runs from (--page).\");\n }\n return hints;\n}\n\nregisterSchema({\n command: \"ads.meta.instagram-accounts\",\n description:\n \"The Instagram accounts an ad on this account can run as — the id `creatives create --instagram-user` takes. Lists accounts assigned or connected to the ad account and each promotable Page's linked or page-backed one. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: {\n \"account-id\": schemaListingAccount,\n \"no-cache\": schemaNoCache,\n output: { type: \"string\", description: \"json|csv\", required: false, default: \"json\" },\n },\n});\n\nexport const instagramAccountsCommand = defineCommand({\n meta: {\n name: \"instagram-accounts\",\n description:\n \"Instagram identities an ad can run as (the --instagram-user id). Start here before creatives create: baker ads meta instagram-accounts --account-id act_123\",\n },\n args: { \"account-id\": LISTING_ACCOUNT_ARG, \"no-cache\": NO_CACHE_ARG, output: outputArg },\n run: async ({ args }) => {\n try {\n const { rows, tag, hints } = await readAccounts<MetaInstagramIdentity>(\n \"/api/ads/meta/instagram-accounts\",\n {},\n args,\n );\n emit(tag(rows.map((row) => ({ ...row, sources: row.sources.join(\",\") }))), args, [\n ...hints,\n ...instagramIdentityHints(rows),\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- Apps ---\n\nregisterSchema({\n command: \"ads.meta.apps\",\n description:\n \"The apps this ad account can promote (app installs / app engagement), with their store URLs — the application_id and object_store_url an app ad set's promoted_object takes. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: { \"account-id\": schemaListingAccount, \"no-cache\": schemaNoCache, output: schemaOutput },\n});\n\nexport const appsCommand = defineCommand({\n meta: {\n name: \"apps\",\n description:\n \"Apps the ad account can promote, for an app ad set's promoted_object. Example: baker ads meta apps --account-id act_123\",\n },\n args: { \"account-id\": LISTING_ACCOUNT_ARG, \"no-cache\": NO_CACHE_ARG, output: outputArg },\n run: async ({ args }) => {\n try {\n const { rows, tag, hints } = await readAccounts<{\n id: string;\n name?: string;\n object_store_urls?: Record<string, string>;\n }>(\"/api/ads/meta/apps\", {}, args);\n emit(tag(rows.map((row) => ({ ...row }))), args, [\n ...hints,\n ...(rows.length > 0\n ? [\n 'An app ad set promotes one: promoted_object {\"application_id\":\"<id>\",\"object_store_url\":\"<store url>\"}. Use a real store URL (itunes / google_play); fb_canvas and instant_game are not app stores.',\n ]\n : [\n \"No promotable apps. The app has to be registered in Meta for Developers and its owner has to add this ad account under the app's Advanced settings → Advertising accounts.\",\n ]),\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- DSA ---\n\nregisterSchema({\n command: \"ads.meta.dsa-recommendations\",\n description:\n \"Names Meta suggests for the EU Digital Services Act disclosure (who benefits from and who pays for an ad) on this account.\",\n args: { \"account-id\": schemaAccount, \"no-cache\": schemaNoCache },\n});\n\nexport const dsaRecommendationsCommand = defineCommand({\n meta: {\n name: \"dsa-recommendations\",\n description:\n \"Meta's suggested DSA beneficiary/payor names for EU ad sets. Example: baker ads meta dsa-recommendations --account-id act_123\",\n },\n args: { \"account-id\": accountArg, \"no-cache\": NO_CACHE_ARG },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const names = await read<string[]>(\"/api/ads/meta/dsa-recommendations\", { \"account-id\": accountId }, args);\n writeJsonEnvelope({\n ok: true,\n data: names,\n hints: [\n \"An ad set reaching the EU needs dsa_beneficiary and dsa_payor. When they are missing Baker fills both from the ad account's saved EU advertiser and payer, else the first of these, else the business name; pass one of these instead when the user names someone else (an agency paying for a client).\",\n ],\n });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- Images and labels ---\n\nfunction compactImage(row: Row): Row {\n return {\n hash: row.hash,\n name: row.name,\n width: row.width,\n height: row.height,\n status: row.status,\n created_time: row.created_time,\n };\n}\n\nregisterSchema({\n command: \"ads.meta.images\",\n description:\n \"The ad account's image library — each image_hash a creative can reuse without uploading again. --hash looks one up. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: {\n \"account-id\": schemaListingAccount,\n hash: { type: \"string\", description: \"One image hash\", required: false },\n limit: { type: \"string\", description: \"Max rows (default 500)\", required: false },\n full: { type: \"boolean\", description: \"URLs, permalink and which creatives use it\", required: false },\n \"no-cache\": schemaNoCache,\n output: schemaOutput,\n },\n});\n\nexport const imagesCommand = defineCommand({\n meta: {\n name: \"images\",\n description:\n \"Image library of the ad account (image hashes). Example: baker ads meta images --account-id act_123 --limit 20; --hash <hash> for one\",\n },\n args: {\n \"account-id\": LISTING_ACCOUNT_ARG,\n hash: { type: \"string\", description: \"Look up one image hash\" },\n limit: { type: \"string\", description: \"Max rows (default 500)\" },\n full: { type: \"boolean\", description: \"Every field: url, permalink_url, creatives\" },\n \"no-cache\": NO_CACHE_ARG,\n output: outputArg,\n },\n run: async ({ args }) => {\n const params: Record<string, string> = {};\n if (args.hash) params.hash = args.hash as string;\n if (args.limit) params.limit = args.limit as string;\n try {\n const { rows, tag, hints } = await readAccounts<Row>(\"/api/ads/meta/images\", params, args, {\n limit: listingLimit(args, 500),\n });\n emit(tag(args.full ? rows : rows.map(compactImage)), args, [\n ...hints,\n \"A creative reuses one with its hash (the `image_hash` of a creative file). To push a Baker-library image, stage `media upload` instead.\",\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nregisterSchema({\n command: \"ads.meta.labels\",\n description:\n \"Ad labels defined on the account (Meta's tags for campaigns, ad sets, ads and creatives). With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: { \"account-id\": schemaListingAccount, \"no-cache\": schemaNoCache, output: schemaOutput },\n});\n\nconst labelsListArgs = { \"account-id\": LISTING_ACCOUNT_ARG, \"no-cache\": NO_CACHE_ARG, output: outputArg };\n\nexport const labelsCommand = defineCommand({\n meta: {\n name: \"labels\",\n description: `Ad labels on the account (list), or stage label writes: create, rename, delete, attach (file campaigns/ad sets/ads/creatives under one), detach.\n baker ads meta labels --account-id act_123\n baker ads meta labels create --name \"Q4 launch\"\n baker ads meta labels attach <labelId|meta_temp_…> --campaigns 6123,6124 --ads 6125`,\n },\n subCommands: {\n list: () => labelsListCommand,\n create: () => import(\"./asset-writes.ts\").then((m) => m.labelsCreateCommand),\n rename: () => import(\"./asset-writes.ts\").then((m) => m.labelsRenameCommand),\n delete: () => import(\"./asset-writes.ts\").then((m) => m.labelsDeleteCommand),\n attach: () => import(\"./asset-writes.ts\").then((m) => m.labelsAttachCommand),\n detach: () => import(\"./asset-writes.ts\").then((m) => m.labelsDetachCommand),\n },\n args: labelsListArgs,\n default: \"list\",\n});\n\nconst labelsListCommand = defineCommand({\n meta: {\n name: \"list\",\n description: \"Ad labels on the account. Runs by default. Example: baker ads meta labels --account-id act_123\",\n },\n args: labelsListArgs,\n run: async ({ args }) => {\n try {\n const { rows, tag, hints } = await readAccounts<Row>(\"/api/ads/meta/labels\", {}, args);\n emit(tag(rows), args, [...hints, ...(rows.length === 0 ? [\"This account has no ad labels.\"] : [])]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- High-demand periods ---\n\nregisterSchema({\n command: \"ads.meta.high-demand-periods\",\n description: \"The budget boosts (high-demand periods) set on a campaign or ad set: when each runs and by how much.\",\n args: {\n \"campaign-id\": { type: \"string\", description: \"Campaign or ad set ID\", required: true },\n \"no-cache\": schemaNoCache,\n output: schemaOutput,\n },\n});\n\nexport const highDemandPeriodsCommand = defineCommand({\n meta: {\n name: \"high-demand-periods\",\n description:\n \"Budget boosts on a campaign or ad set. Example: baker ads meta high-demand-periods --campaign-id 6123 (stage new ones with --budget-boost on campaigns or adsets create|update)\",\n },\n args: {\n \"campaign-id\": { type: \"string\", description: \"Campaign (or ad set) ID\", required: true },\n \"no-cache\": NO_CACHE_ARG,\n output: outputArg,\n },\n run: async ({ args }) => {\n try {\n const rows = await read<Row[]>(\n \"/api/ads/meta/high-demand-periods\",\n { \"campaign-id\": args[\"campaign-id\"] as string },\n args,\n );\n emit(rows, args, rows.length === 0 ? [\"No budget boosts on this campaign.\"] : []);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AA6B9B,SAAS,KAAK,MAAa,MAAY,OAAuB;AAC5D,QAAM,MAAM,UAAU,IAAI;AAC1B,MAAI,QAAQ,QAAQ;AAClB,mBAAe,MAAM,KAAK,QAAW,KAAK;AAC1C;AAAA,EACF;AACA,oBAAkB,MAAM,SAAS,IAAI,EAAE,IAAI,MAAM,MAAM,MAAM,MAAM,IAAI,EAAE,IAAI,MAAM,MAAM,KAAK,CAAC;AACjG;AAEA,eAAe,KAAQ,MAAc,QAAgC,MAAwB;AAC3F,MAAI,KAAK,UAAU,EAAG,QAAO,YAAY,IAAI;AAC7C,SAAO,MAAM,OAAU,MAAM,MAAM;AACrC;AAGA,eAAe,aACb,MACA,QACA,MACA,UAAqC,CAAC,GAC8C;AACpF,QAAM,WAAW,MAAM,gBAAgB,IAAI;AAC3C,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA,CAAC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AK;AAAA,IACxF,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AAAA,EACA,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,QAAI;AACF,YAAM,OAAO,MAAM;AAAA,QACjB;AAAA,QACA,EAAE,eAAe,KAAK,aAAa,EAAY;AAAA,QAC/C;AAAA,MACF;AACA,WAAK,MAAM,MAAM,KAAK,WAAW,IAAI,CAAC,oCAAoC,IAAI,CAAC,CAAC;AAAA,IAClF,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/meta/activities.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { META_LIST_SHAPE_ARGS, registerMetaListSchema, shapeMetaListRows, writeMetaListRows } from \"./list-rows.ts\";\nimport {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n LISTING_ACCOUNT_ARG,\n loggedAt,\n readEachAccount,\n} from \"./shared.ts\";\n\n/** Events printed unless --limit names another number: a busy month printed 96 KB the agent cut with head (BAKER-1222). */\nconst SHOWN_EVENTS = 50;\n\n/** The most events one read returns (the activities route's cap): a read that reaches it may have left older ones out. */\nconst READ_CAP = 5000;\n\nconst listArgs = {\n \"account-id\": LISTING_ACCOUNT_ARG,\n days: { type: \"string\", description: \"Lookback days (default 7)\" },\n limit: {\n type: \"string\",\n description: `Events to print, newest first (default ${SHOWN_EVENTS}); a hint says when there are more`,\n },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"activities\",\n \"Account change log, as a table by default, one row per event: event_time, event_type, actor_name, object_type, object_name, object_id, and change ('old → new' when the change is a single value). Prints the 50 newest events; a hint says when there are more (--limit <n>). Start here: baker ads meta activities --account-id act_123 --days 2. --fields event_time,object_name,extra_data or --full for the raw change payload; --output json returns the rows in the envelope. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n listArgs,\n);\n\nexport const activitiesCommand = defineCommand({\n meta: {\n name: \"activities\",\n description: `Audit log of recent ad-account changes (created, paused, edited). Default lookback 7 days,\n~90 day retention server-side. Prints the 50 newest events (--limit for more); a hint says when there are more.\n\nA table by default, one row per event: event_time, event_type, actor_name, object_type,\nobject_name, object_id, and change (\"old → new\" when the change is a single value: status,\nname, budget, goal). --fields takes dotted paths (extra_data holds the raw change); --full returns\nevery field Meta sent; --output json returns the rows as JSON.\n\nExamples:\n baker ads meta activities --account-id act_123 --days 14\n baker ads meta activities --account-id act_123 --days 2 --output json\n baker ads meta activities --account-id act_123 --fields event_time,object_name,extra_data`,\n },\n args: listArgs,\n run: async ({ args }) => {\n const accounts = await accountsInScope(args);\n try {\n const params: Record<string, string> = {};\n if (args.days) params.days = args.days as string;\n const shown = Number(args.limit ?? SHOWN_EVENTS);\n if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error(\"--limit must be a whole number of events\"));\n // One event past the ones printed says whether there are more, without reading them all.\n params.limit = String(Math.min(shown + 1, READ_CAP));\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const read = await readEachAccount(\n accounts,\n (accountId) =>\n apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/activities\", { ...params, \"account-id\": accountId }),\n { time: (row) => loggedAt(row.event_time) },\n );\n const { rows: data, accountOf } = read;\n // Each account read stops at READ_CAP, so the merged log is newest-first only that far.\n const window = Math.min(shown, READ_CAP);\n const shaped = shapeMetaListRows(\"activities\", data.slice(0, window), args, accountOf?.slice(0, window));\n const more =\n data.length > window && window === shown\n ? [`Showing the ${shown} newest events; there are more. --limit <n> prints more, or narrow --days.`]\n : data.length >= READ_CAP\n ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`]\n : [];\n writeMetaListRows(\"activities\", shaped, csvOrJson(args), [...read.hints, ...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OAAO,QAAQ;AACvC,YAAM,SAAS,kBAAkB,cAAc,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,WAAW,MAAM,GAAG,MAAM,CAAC;AACvG,YAAM,OACJ,KAAK,SAAS,UAAU,WAAW,QAC/B,CAAC,eAAe,KAAK,4EAA4E,IACjG,KAAK,UAAU,WACb,CAAC,eAAe,QAAQ,8EAA8E,IACtG,CAAC;AACT,wBAAkB,cAAc,QAAQ,UAAU,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,GAAG,IAAI,CAAC;AAAA,IACnF,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/ads-ZDSRE7D6.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/ads/meta/ads.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport {\n IDS_ARG,\n largeListingHints,\n META_LIST_SHAPE_ARGS,\n metaListFields,\n registerMetaListSchema,\n shapeMetaListRows,\n writeMetaListRows,\n} from \"./list-rows.ts\";\nimport {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n listingLimit,\n NAME_CONTAINS_ARG,\n readEachAccount,\n resolveEffectiveStatus,\n statusFilterHints,\n} from \"./shared.ts\";\n\nconst ACCOUNT_SELECTION =\n \"Account: --account-id, else BAKER_META_AD_ACCOUNT_ID, else every connected Meta ad account — with several, the list reads each and adds account_id to every row (--adset-id or --campaign-id is read once). Writes still name one.\";\n\nconst listArgs = {\n \"account-id\": {\n type: \"string\",\n description:\n \"Meta ad account ID (act_123). Without it the listing reads every connected account, each row tagged with its account_id.\",\n },\n \"adset-id\": { type: \"string\", alias: \"adset\", description: \"Filter to one adset\" },\n \"campaign-id\": { type: \"string\", alias: \"campaign\", description: \"Filter to one campaign\" },\n \"effective-status\": { type: \"string\", description: \"Comma-separated effective_status filter (overrides default)\" },\n \"all-statuses\": { type: \"boolean\", description: \"Drop the default ACTIVE filter\" },\n \"name-contains\": NAME_CONTAINS_ARG,\n ids: IDS_ARG,\n \"lead-form\": {\n type: \"string\",\n description:\n \"Only the ads whose button opens this instant form (a form id from `baker ads meta lead-forms`). Add --all-statuses to count paused ones too. Example: --lead-form 1290001 --all-statuses\",\n },\n limit: { type: \"string\", description: \"Max rows (default 1000)\" },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"ads\",\n `List ads in a Meta ad account, as a table by default: id, name, adset_id, campaign_id, effective_status, creative_id, issues (why an ad is WITH_ISSUES), created_time, plus each creative's link (destination), lead_form_id (the instant form its button opens) and url_tags — audit live ads' tracking in this one call, not a creatives call per ad. Which ads use a form: --lead-form <id> --all-statuses. Start here: baker ads meta ads --adset-id 6123. --fields takes dotted paths (e.g. id,tracking_specs); --full returns every field Meta sent; --output json returns the rows in the envelope. ${ACCOUNT_SELECTION}`,\n listArgs,\n);\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description: `List ads in a Meta ad account. Runs by default when no subcommand is given. ${ACCOUNT_SELECTION} Example: baker ads meta ads --account-id act_123`,\n },\n args: listArgs,\n run: async ({ args }) => {\n const accounts = await accountsInScope(args);\n const effectiveStatus = resolveEffectiveStatus(args);\n try {\n const params: Record<string, string> = {};\n if (args[\"adset-id\"]) params[\"adset-id\"] = args[\"adset-id\"] as string;\n if (args[\"campaign-id\"]) params[\"campaign-id\"] = args[\"campaign-id\"] as string;\n if (effectiveStatus) params[\"effective-status\"] = effectiveStatus;\n if (args[\"name-contains\"]) params[\"name-contains\"] = args[\"name-contains\"] as string;\n if (args.ids) params.ids = args.ids as string;\n if (args[\"lead-form\"]) params[\"lead-form\"] = args[\"lead-form\"] as string;\n const fields = metaListFields(\"ads\", args);\n if (fields) params.fields = fields;\n if (args.limit) params.limit = args.limit as string;\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const read = await readEachAccount(\n accounts,\n (accountId) =>\n apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/ads\", { ...params, \"account-id\": accountId }),\n { byParent: Boolean(args[\"adset-id\"] || args[\"campaign-id\"]), limit: listingLimit(args, 1000) },\n );\n const data = read.rows;\n const shaped = shapeMetaListRows(\"ads\", data, args, read.accountOf);\n writeMetaListRows(\"ads\", shaped, csvOrJson(args), [\n ...read.hints,\n ...statusFilterHints(data, effectiveStatus, \"ads\"),\n ...largeListingHints(\"ads\", data.length),\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const adsListCommand = defineCommand({\n meta: {\n name: \"ads\",\n description: `List ads in a Meta ad account, or stage writes (create/update/pause/resume/archive/delete/duplicate/copy/retag).\nDefaults to ACTIVE only — pass --all-statuses to widen. Write subcommands stage ops on this chat's draft.\n${ACCOUNT_SELECTION}\n\nThe dashboard shows effective_status (e.g. WITH_ISSUES, PENDING_REVIEW, DISAPPROVED, ADSET_PAUSED), not status.\n\nListings print a table by default: id, name, adset_id, campaign_id, effective_status, creative_id, issues\n(why an ad is WITH_ISSUES), created_time, and the creative's link (destination), lead_form_id (the instant form it opens)\nand url_tags. --fields takes dotted paths (e.g. tracking_specs,\npreview_shareable_link); --full returns every field; --output json returns the rows as JSON.\n\nExamples:\n baker ads meta ads --account-id act_123\n baker ads meta ads --adset-id 6123\n baker ads meta ads --account-id act_123 --all-statuses --name-contains octubre --fields id,name,adset_id,creative_id — find one ad by name\n baker ads meta ads --adset-id 6123 --fields id,name,preview_shareable_link\n baker ads meta ads --ids 6123,6124 — the ads you have ids for, any status\n baker ads meta ads --account-id act_123 --lead-form 1290001 --all-statuses — the ads that open one instant form\n baker ads meta ads create --name \"Ad 1\" --adset meta_temp_as01 --creative meta_temp_cr01\n baker ads meta ads pause 6123 --account-id act_123\n baker ads meta ads retag 6123 --set \"utm_medium=paid-social\" — fix tracking on a LIVE ad, keeping everything else`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./write-commands.ts\").then((m) => m.adsCreateCommand),\n update: () => import(\"./write-commands.ts\").then((m) => m.adsUpdateCommand),\n pause: () => import(\"./write-commands.ts\").then((m) => m.adsPauseCommand),\n resume: () => import(\"./write-commands.ts\").then((m) => m.adsResumeCommand),\n archive: () => import(\"./write-commands.ts\").then((m) => m.adsArchiveCommand),\n delete: () => import(\"./write-commands.ts\").then((m) => m.adsDeleteCommand),\n duplicate: () => import(\"./write-commands.ts\").then((m) => m.adsDuplicateCommand),\n copy: () => import(\"./copy-writes.ts\").then((m) => m.adsCopyCommand),\n retag: () => import(\"./write-commands.ts\").then((m) => m.adsRetagCommand),\n },\n // `args` stays even though the parent has no `run`: citty scans rawArgs for the\n // subcommand name using THIS command's arg defs, so without them `--account-id act_1`\n // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare\n // invocation — citty falls through to `run` after a subcommand, double-executing it.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAuB9B,IAAM,oBACJ;AAEF,IAAM,WAAW;AAAA,EACf,cAAc;AAAA,IACZ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,YAAY,EAAE,MAAM,UAAU,OAAO,SAAS,aAAa,sBAAsB;AAAA,EACjF,eAAe,EAAE,MAAM,UAAU,OAAO,YAAY,aAAa,yBAAyB;AAAA,EAC1F,oBAAoB,EAAE,MAAM,UAAU,aAAa,8DAA8D;AAAA,EACjH,gBAAgB,EAAE,MAAM,WAAW,aAAa,iCAAiC;AAAA,EACjF,iBAAiB;AAAA,EACjB,KAAK;AAAA,EACL,aAAa;AAAA,IACX,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,OAAO,EAAE,MAAM,UAAU,aAAa,0BAA0B;AAAA,EAChE,YAAY;AAAA,EACZ,GAAG;AACL;AAEA;AAAA,EACE;AAAA,EACA,mlBA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