@koda-sl/baker-cli 0.869.0-dev.620009099.1 → 0.869.0-dev.c56cd3987
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 +5 -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-Q656G7HG.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 +1 -1
- 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/{insights-3SQWIU4E.js → insights-RXCGFS2V.js} +106 -25
- package/dist/insights-RXCGFS2V.js.map +1 -0
- 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-UK7PZ2J6.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/{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/insights-3SQWIU4E.js.map +0 -1
- package/dist/pixels-2BG3XMZP.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-Q656G7HG.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/{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-UK7PZ2J6.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
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-XXGOWBZR.js";
|
|
4
4
|
import {
|
|
5
5
|
normalizeMetaAccountId
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DP76WGDV.js";
|
|
7
7
|
import "./chunk-QALAJNBG.js";
|
|
8
8
|
import "./chunk-NX4EB2TK.js";
|
|
9
9
|
import {
|
|
@@ -106,47 +106,47 @@ Full guide: __tooling__/docs/tools/baker/ads-meta.md`
|
|
|
106
106
|
normalize: normalizeMetaAccountId
|
|
107
107
|
}),
|
|
108
108
|
subCommands: {
|
|
109
|
-
accounts: () => import("./accounts-
|
|
110
|
-
account: () => import("./account-
|
|
111
|
-
businesses: () => import("./businesses-
|
|
112
|
-
pages: () => import("./pages-
|
|
113
|
-
"lead-forms": () => import("./leads-
|
|
114
|
-
"instant-experiences": () => import("./instant-experiences-
|
|
115
|
-
leads: () => import("./leads-
|
|
116
|
-
campaigns: () => import("./campaigns-
|
|
117
|
-
adsets: () => import("./adsets-
|
|
118
|
-
ads: () => import("./ads-
|
|
119
|
-
creatives: () => import("./creatives-
|
|
120
|
-
audiences: () => import("./audiences-
|
|
121
|
-
"custom-conversions": () => import("./custom-conversions-
|
|
122
|
-
pixels: () => import("./pixels-
|
|
123
|
-
activities: () => import("./activities-
|
|
124
|
-
insights: () => import("./insights-
|
|
125
|
-
preview: () => import("./preview-
|
|
126
|
-
videos: () => import("./videos-
|
|
127
|
-
targeting: () => import("./targeting-
|
|
128
|
-
"instagram-accounts": () => import("./account-assets-
|
|
129
|
-
apps: () => import("./account-assets-
|
|
130
|
-
"dsa-recommendations": () => import("./account-assets-
|
|
131
|
-
images: () => import("./account-assets-
|
|
132
|
-
labels: () => import("./account-assets-
|
|
133
|
-
studies: () => import("./studies-
|
|
134
|
-
catalogs: () => import("./catalogs-
|
|
135
|
-
"page-photos": () => import("./page-photos-
|
|
136
|
-
"page-posts": () => import("./account-level-
|
|
137
|
-
"instagram-media": () => import("./account-level-
|
|
138
|
-
comments: () => import("./account-level-
|
|
139
|
-
"account-settings": () => import("./account-level-
|
|
140
|
-
"account-details": () => import("./account-level-
|
|
141
|
-
"block-lists": () => import("./account-level-
|
|
142
|
-
"reach-frequency": () => import("./account-level-
|
|
143
|
-
"high-demand-periods": () => import("./account-assets-
|
|
144
|
-
rules: () => import("./rules-
|
|
145
|
-
media: () => import("./media-
|
|
146
|
-
draft: () => import("./draft-
|
|
109
|
+
accounts: () => import("./accounts-LNFU27BU.js").then((m) => m.accountsCommand),
|
|
110
|
+
account: () => import("./account-LHY6YM6L.js").then((m) => m.accountCommand),
|
|
111
|
+
businesses: () => import("./businesses-RQ6P4DOS.js").then((m) => m.businessesCommand),
|
|
112
|
+
pages: () => import("./pages-YZC44QR2.js").then((m) => m.pagesCommand),
|
|
113
|
+
"lead-forms": () => import("./leads-FEEWX7OO.js").then((m) => m.leadFormsCommand),
|
|
114
|
+
"instant-experiences": () => import("./instant-experiences-EJWYFWDT.js").then((m) => m.instantExperiencesCommand),
|
|
115
|
+
leads: () => import("./leads-FEEWX7OO.js").then((m) => m.leadsCommand),
|
|
116
|
+
campaigns: () => import("./campaigns-RXDC5FSQ.js").then((m) => m.campaignsCommand),
|
|
117
|
+
adsets: () => import("./adsets-3NIYL2GQ.js").then((m) => m.adsetsCommand),
|
|
118
|
+
ads: () => import("./ads-ZR5D7BZT.js").then((m) => m.adsListCommand),
|
|
119
|
+
creatives: () => import("./creatives-CPLH3KHQ.js").then((m) => m.creativesCommand),
|
|
120
|
+
audiences: () => import("./audiences-DL267GNQ.js").then((m) => m.audiencesCommand),
|
|
121
|
+
"custom-conversions": () => import("./custom-conversions-CTJVAZKC.js").then((m) => m.customConversionsCommand),
|
|
122
|
+
pixels: () => import("./pixels-EX6FHVHW.js").then((m) => m.pixelsCommand),
|
|
123
|
+
activities: () => import("./activities-LC64DAAK.js").then((m) => m.activitiesCommand),
|
|
124
|
+
insights: () => import("./insights-RXCGFS2V.js").then((m) => m.insightsCommand),
|
|
125
|
+
preview: () => import("./preview-4GUQGDBD.js").then((m) => m.previewCommand),
|
|
126
|
+
videos: () => import("./videos-TJG5CA7N.js").then((m) => m.videosCommand),
|
|
127
|
+
targeting: () => import("./targeting-7T7XHBIX.js").then((m) => m.targetingCommand),
|
|
128
|
+
"instagram-accounts": () => import("./account-assets-L6BX4YUQ.js").then((m) => m.instagramAccountsCommand),
|
|
129
|
+
apps: () => import("./account-assets-L6BX4YUQ.js").then((m) => m.appsCommand),
|
|
130
|
+
"dsa-recommendations": () => import("./account-assets-L6BX4YUQ.js").then((m) => m.dsaRecommendationsCommand),
|
|
131
|
+
images: () => import("./account-assets-L6BX4YUQ.js").then((m) => m.imagesCommand),
|
|
132
|
+
labels: () => import("./account-assets-L6BX4YUQ.js").then((m) => m.labelsCommand),
|
|
133
|
+
studies: () => import("./studies-357M2C2K.js").then((m) => m.studiesCommand),
|
|
134
|
+
catalogs: () => import("./catalogs-QAZ7ZZ5R.js").then((m) => m.catalogsCommand),
|
|
135
|
+
"page-photos": () => import("./page-photos-ZBMJLL5V.js").then((m) => m.pagePhotosCommand),
|
|
136
|
+
"page-posts": () => import("./account-level-OX34JQ7C.js").then((m) => m.pagePostsCommand),
|
|
137
|
+
"instagram-media": () => import("./account-level-OX34JQ7C.js").then((m) => m.instagramMediaCommand),
|
|
138
|
+
comments: () => import("./account-level-OX34JQ7C.js").then((m) => m.commentsCommand),
|
|
139
|
+
"account-settings": () => import("./account-level-OX34JQ7C.js").then((m) => m.accountSettingsCommand),
|
|
140
|
+
"account-details": () => import("./account-level-OX34JQ7C.js").then((m) => m.accountDetailsCommand),
|
|
141
|
+
"block-lists": () => import("./account-level-OX34JQ7C.js").then((m) => m.blockListsCommand),
|
|
142
|
+
"reach-frequency": () => import("./account-level-OX34JQ7C.js").then((m) => m.reachFrequencyCommand),
|
|
143
|
+
"high-demand-periods": () => import("./account-assets-L6BX4YUQ.js").then((m) => m.highDemandPeriodsCommand),
|
|
144
|
+
rules: () => import("./rules-BRULCGRV.js").then((m) => m.rulesCommand),
|
|
145
|
+
media: () => import("./media-PUOLJUN3.js").then((m) => m.metaMediaCommand),
|
|
146
|
+
draft: () => import("./draft-UU3F2VMJ.js").then((m) => m.metaDraftCommand)
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
export {
|
|
150
150
|
metaCommand
|
|
151
151
|
};
|
|
152
|
-
//# sourceMappingURL=meta-
|
|
152
|
+
//# sourceMappingURL=meta-UK7PZ2J6.js.map
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
failWriteValidation,
|
|
4
4
|
requireTarget,
|
|
5
5
|
stageOp
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
7
7
|
import "./chunk-3R62EYYX.js";
|
|
8
8
|
import "./chunk-GDFJOCDO.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-DP76WGDV.js";
|
|
10
10
|
import "./chunk-XD7C5OE7.js";
|
|
11
11
|
import "./chunk-UKENQSZ2.js";
|
|
12
12
|
import "./chunk-D5FY4FAK.js";
|
|
@@ -119,4 +119,4 @@ var pagePhotosCommand = defineCommand({
|
|
|
119
119
|
export {
|
|
120
120
|
pagePhotosCommand
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=page-photos-
|
|
122
|
+
//# sourceMappingURL=page-photos-ZBMJLL5V.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
csvOrJson,
|
|
3
3
|
handleMetaError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DP76WGDV.js";
|
|
5
5
|
import "./chunk-QALAJNBG.js";
|
|
6
6
|
import {
|
|
7
7
|
NO_CACHE_ARG
|
|
@@ -64,4 +64,4 @@ export {
|
|
|
64
64
|
pageSelectionHints,
|
|
65
65
|
pagesCommand
|
|
66
66
|
};
|
|
67
|
-
//# sourceMappingURL=pages-
|
|
67
|
+
//# sourceMappingURL=pages-YZC44QR2.js.map
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LISTING_ACCOUNT_ARG,
|
|
3
|
-
accountsInScope,
|
|
4
2
|
csvOrJson,
|
|
5
3
|
daysAgoIso,
|
|
6
4
|
handleMetaError,
|
|
7
|
-
|
|
8
|
-
todayIso
|
|
9
|
-
|
|
10
|
-
} from "./chunk-YF57BX3S.js";
|
|
5
|
+
resolveAccountIdArg,
|
|
6
|
+
todayIso
|
|
7
|
+
} from "./chunk-DP76WGDV.js";
|
|
11
8
|
import "./chunk-QALAJNBG.js";
|
|
12
9
|
import {
|
|
13
10
|
NO_CACHE_ARG
|
|
@@ -41,7 +38,7 @@ Examples:
|
|
|
41
38
|
baker ads meta pixels --pixel-id 9876 --stats --days 30 --by total # each event's count, first and last seen`
|
|
42
39
|
},
|
|
43
40
|
args: {
|
|
44
|
-
"account-id":
|
|
41
|
+
"account-id": { type: "string", description: "Meta ad account ID" },
|
|
45
42
|
"pixel-id": { type: "string", description: "Pixel ID for --stats" },
|
|
46
43
|
stats: { type: "boolean", description: "Fetch firing stats for the pixel" },
|
|
47
44
|
aggregation: {
|
|
@@ -186,16 +183,11 @@ function instant(time) {
|
|
|
186
183
|
return bucketTime(time).toMillis();
|
|
187
184
|
}
|
|
188
185
|
async function runList(args) {
|
|
189
|
-
const
|
|
190
|
-
const params = {};
|
|
186
|
+
const accountId = await resolveAccountIdArg(args);
|
|
187
|
+
const params = { "account-id": accountId };
|
|
191
188
|
if (args["no-cache"]) params["skip-cache"] = "true";
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
const { pixels, restrictedFields } = await apiGet("/api/ads/meta/pixels", { ...params, "account-id": accountId });
|
|
195
|
-
for (const field of restrictedFields) restricted.add(field);
|
|
196
|
-
return pixels;
|
|
197
|
-
});
|
|
198
|
-
emit(withAccountColumn(read.rows, read.accountOf), args, pixelWarnings([...restricted]), read.hints);
|
|
189
|
+
const { pixels, restrictedFields } = await apiGet("/api/ads/meta/pixels", params);
|
|
190
|
+
emit(pixels, args, pixelWarnings(restrictedFields));
|
|
199
191
|
}
|
|
200
192
|
function pixelWarnings(restrictedFields) {
|
|
201
193
|
if (restrictedFields.length === 0) {
|
|
@@ -208,21 +200,16 @@ function pixelWarnings(restrictedFields) {
|
|
|
208
200
|
}
|
|
209
201
|
];
|
|
210
202
|
}
|
|
211
|
-
function emit(data, args, warnings = []
|
|
203
|
+
function emit(data, args, warnings = []) {
|
|
212
204
|
const fmt = csvOrJson(args);
|
|
213
205
|
if (fmt !== "json") {
|
|
214
|
-
writeAdsOutput(data, fmt
|
|
206
|
+
writeAdsOutput(data, fmt);
|
|
215
207
|
return;
|
|
216
208
|
}
|
|
217
|
-
writeAdsJson({
|
|
218
|
-
ok: true,
|
|
219
|
-
data,
|
|
220
|
-
...warnings.length > 0 ? { warnings } : {},
|
|
221
|
-
...hints.length > 0 ? { hints } : {}
|
|
222
|
-
});
|
|
209
|
+
writeAdsJson({ ok: true, data, ...warnings.length > 0 ? { warnings } : {} });
|
|
223
210
|
}
|
|
224
211
|
export {
|
|
225
212
|
pixelWarnings,
|
|
226
213
|
pixelsCommand
|
|
227
214
|
};
|
|
228
|
-
//# sourceMappingURL=pixels-
|
|
215
|
+
//# sourceMappingURL=pixels-EX6FHVHW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/ads/meta/pixels.ts"],"sourcesContent":["import { defineCommand } from \"citty\";\nimport { DateTime } from \"luxon\";\nimport { NO_CACHE_ARG } from \"../../../cache-flag.ts\";\nimport { apiGet } from \"../../../client.ts\";\nimport { writeAdsJson, writeAdsOutput } from \"../output.ts\";\nimport type { AdsWarning } from \"../types.ts\";\nimport { csvOrJson, daysAgoIso, handleMetaError, resolveAccountIdArg, todayIso } from \"./shared.ts\";\n\nexport const pixelsCommand = defineCommand({\n meta: {\n name: \"pixels\",\n description: `List Meta Pixels for an ad account, or count what one pixel received — the firing read, not ad-attributed conversions.\n\n--stats prints one row per day per event (date, weekday, event, count) by default, in the ad account's time zone; --by hour or --by total change the grain, --full returns Meta's raw hourly buckets.\n\nExamples:\n baker ads meta pixels --account-id act_123\n baker ads meta pixels --pixel-id 9876 --stats --days 7 # per day per event\n baker ads meta pixels --pixel-id 9876 --stats --days 7 --event Lead,Purchase # only those events\n baker ads meta pixels --pixel-id 9876 --stats --days 30 --by total # each event's count, first and last seen`,\n },\n args: {\n \"account-id\": { type: \"string\", description: \"Meta ad account ID\" },\n \"pixel-id\": { type: \"string\", description: \"Pixel ID for --stats\" },\n stats: { type: \"boolean\", description: \"Fetch firing stats for the pixel\" },\n aggregation: {\n type: \"string\",\n description: \"stats aggregation: event|browser_type|host|pixel_fire\",\n default: \"event\",\n },\n days: { type: \"string\", description: \"Lookback days for --stats (default 7)\" },\n by: {\n type: \"string\",\n description:\n \"--stats grain: day (default; one row per day per value, with its weekday), hour (one row per hour per value), total (one row per value with first_seen/last_seen)\",\n },\n event: {\n type: \"string\",\n description: \"--stats: keep only these values, comma-separated and exact (e.g. --event Lead,Purchase)\",\n },\n full: { type: \"boolean\", description: \"--stats: Meta's raw hourly buckets, every value, instead of the rows\" },\n \"no-cache\": NO_CACHE_ARG,\n output: { type: \"string\", description: \"Output format: json|csv|jsonl|md\", default: \"json\" },\n },\n run: async ({ args }) => {\n try {\n if (args.stats) {\n await runStats(args);\n return;\n }\n await runList(args);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nasync function runStats(args: Record<string, unknown>): Promise<void> {\n const pixelId = args[\"pixel-id\"] as string | undefined;\n if (!pixelId) {\n handleMetaError(new Error(\"--pixel-id is required when --stats is set\"));\n }\n const days = args.days ? Number(args.days) : 7;\n if (!Number.isInteger(days) || days <= 0 || days > 90) {\n handleMetaError(new Error(\"--days must be a positive integer ≤ 90\"));\n }\n const params: Record<string, string> = {\n \"pixel-id\": pixelId,\n aggregation: (args.aggregation as string) ?? \"event\",\n \"start-time\": daysAgoIso(days),\n \"end-time\": todayIso(),\n };\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const by = (args.by as string | undefined) ?? \"day\";\n if (!isStatsGrain(by)) {\n writeAdsJson({\n ok: false,\n error: { code: \"INVALID_ARGS\", message: `--by must be one of ${STATS_GRAINS.join(\", \")}` },\n });\n process.exit(1);\n }\n const buckets = await apiGet<PixelStatBucket[]>(\"/api/ads/meta/pixel-stats\", params);\n if (args.full) {\n emit(buckets as Array<Record<string, unknown>>, args);\n return;\n }\n const events =\n typeof args.event === \"string\"\n ? args.event\n .split(\",\")\n .map((e) => e.trim())\n .filter(Boolean)\n : [];\n const window = { start: `${params[\"start-time\"]}T00:00:00Z`, end: `${params[\"end-time\"]}T00:00:00Z` };\n const { rows, hints } = rollUpPixelStats(buckets, { aggregation: params.aggregation ?? \"event\", by, events, window });\n writeAdsOutput(rows, csvOrJson(args), undefined, hints);\n}\n\n/** One time bucket as Meta's `/{pixel}/stats` returns it; `start_time` carries the ad account's offset. */\ninterface PixelStatBucket {\n start_time?: string;\n data?: Array<{ value?: string; count?: number }>;\n}\n\nconst STATS_GRAINS = [\"day\", \"hour\", \"total\"] as const;\ntype StatsGrain = (typeof STATS_GRAINS)[number];\n\nfunction isStatsGrain(value: string): value is StatsGrain {\n return (STATS_GRAINS as readonly string[]).includes(value);\n}\n\ninterface RollUp {\n aggregation: string;\n by: StatsGrain;\n events: string[];\n /** The UTC instants the read asked Meta for. */\n window: { start: string; end: string };\n}\n\n/**\n * Meta answers with one bucket per hour, each a nested list of values, so \"how\n * many Leads a day\" was a script over hundreds of rows at every call site. The\n * day is the one Meta wrote on `start_time` — the ad account's own day.\n */\nfunction rollUpPixelStats(\n buckets: PixelStatBucket[],\n { aggregation, by, events, window }: RollUp,\n): { rows: Array<Record<string, string | number>>; hints: string[] } {\n const { folded, seen } = foldBuckets(buckets, by, new Set(events));\n const rows = [...folded.values()]\n .sort((a, b) => a.key.localeCompare(b.key) || b.count - a.count)\n .map((row): Record<string, string | number> => {\n if (by === \"total\") {\n return { [aggregation]: row.value, count: row.count, first_seen: row.first, last_seen: row.last };\n }\n if (by === \"hour\") return { hour: row.key, [aggregation]: row.value, count: row.count };\n return { date: row.key, weekday: accountWeekday(row.first), [aggregation]: row.value, count: row.count };\n });\n const hints: string[] = [];\n const missing = events.filter((event) => !seen.has(event));\n if (missing.length > 0) {\n const received = [...seen].sort().join(\", \") || \"nothing\";\n hints.push(`No ${missing.join(\", \")} received in this window (names are exact). The pixel received: ${received}.`);\n }\n const partialDays = by === \"day\" && rows.length > 0 ? daysCutByWindow(buckets, window) : [];\n if (partialDays.length > 0) {\n hints.push(\n `${partialDays.join(\" and \")} ${partialDays.length === 1 ? \"is a partial day\" : \"are partial days\"}: the read covers ${window.start} → ${window.end}, so compare only the full days between them.`,\n );\n }\n return { rows, hints };\n}\n\ninterface FoldedRow {\n key: string;\n value: string;\n count: number;\n first: string;\n last: string;\n}\n\nconst ROW_KEY: Record<StatsGrain, (time: string) => string> = {\n day: (time) => accountDay(time),\n hour: (time) => time,\n total: () => \"\",\n};\n\nfunction foldBuckets(\n buckets: PixelStatBucket[],\n by: StatsGrain,\n wanted: Set<string>,\n): { folded: Map<string, FoldedRow>; seen: Set<string> } {\n const entries = buckets.flatMap((bucket) =>\n (bucket.data ?? []).map((entry) => ({\n time: bucket.start_time ?? \"\",\n value: entry.value ?? \"(unnamed)\",\n count: entry.count ?? 0,\n })),\n );\n const folded = new Map<string, FoldedRow>();\n for (const { time, value, count } of entries) {\n if (wanted.size > 0 && !wanted.has(value)) continue;\n const key = ROW_KEY[by](time);\n const id = `${key}\\u0000${value}`;\n const row = folded.get(id) ?? { key, value, count: 0, first: time, last: time };\n row.count += count;\n if (instant(time) < instant(row.first)) row.first = time;\n if (instant(time) > instant(row.last)) row.last = time;\n folded.set(id, row);\n }\n return { folded, seen: new Set(entries.map((entry) => entry.value)) };\n}\n\n/** The account-local days the window starts after or ends before, oldest first. */\nfunction daysCutByWindow(buckets: PixelStatBucket[], window: { start: string; end: string }): string[] {\n const cut = new Set<string>();\n for (const { start_time: time } of buckets) {\n if (time && dayOverhangsWindow(time, window)) cut.add(accountDay(time));\n }\n return [...cut].sort();\n}\n\n/** Whether the account-local day `time` falls on starts before or ends after the window read. */\nfunction dayOverhangsWindow(time: string, window: { start: string; end: string }): boolean {\n const dayStart = bucketTime(time).startOf(\"day\");\n if (!dayStart.isValid) return false;\n return dayStart < DateTime.fromISO(window.start) || dayStart.plus({ days: 1 }) > DateTime.fromISO(window.end);\n}\n\n/** A bucket's `start_time` in the offset Meta wrote on it — the ad account's. */\nfunction bucketTime(time: string): DateTime {\n return DateTime.fromISO(time, { setZone: true });\n}\n\nfunction accountDay(time: string): string {\n return bucketTime(time).toISODate() ?? \"\";\n}\n\n/** Written out so a reader never works the weekday out from the date, and gets it wrong. */\nfunction accountWeekday(time: string): string {\n return bucketTime(time).setLocale(\"en-US\").toFormat(\"ccc\");\n}\n\n/** Compared as instants: across a clock change, the same local hour carries two offsets. */\nfunction instant(time: string): number {\n return bucketTime(time).toMillis();\n}\n\nasync function runList(args: Record<string, unknown>): Promise<void> {\n const accountId = await resolveAccountIdArg(args);\n const params: Record<string, string> = { \"account-id\": accountId };\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const { pixels, restrictedFields } = await apiGet<{\n pixels: Array<Record<string, unknown>>;\n restrictedFields: string[];\n }>(\"/api/ads/meta/pixels\", params);\n emit(pixels, args, pixelWarnings(restrictedFields));\n}\n\n/**\n * A listing Meta trimmed is still a listing — IDs, names and firing times are\n * complete. Say which setup fields are missing and how to get them, so the gap\n * reads as a client-side access grant rather than as a pixel that isn't there.\n */\nexport function pixelWarnings(restrictedFields: string[]): AdsWarning[] {\n if (restrictedFields.length === 0) {\n return [];\n }\n return [\n {\n code: \"PIXEL_FIELDS_RESTRICTED\",\n message:\n `Meta withheld ${restrictedFields.join(\", \")} for these pixels — the connected user holds no role in the Business that owns them. ` +\n \"IDs, names, creation and last-fired times are complete; install code and setup details are not. \" +\n \"To get them, the client assigns the pixel to the connected user in Meta Business settings → Data sources → Datasets.\",\n },\n ];\n}\n\nfunction emit(data: Array<Record<string, unknown>>, args: Record<string, unknown>, warnings: AdsWarning[] = []): void {\n const fmt = csvOrJson(args);\n if (fmt !== \"json\") {\n writeAdsOutput(data, fmt);\n return;\n }\n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I,EAAE,SAAS,IAAI,CAAC,EAAG,CAAC;AAC/E;","names":[]}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import "./chunk-GDFJOCDO.js";
|
|
14
14
|
import {
|
|
15
15
|
handleMetaError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-DP76WGDV.js";
|
|
17
17
|
import "./chunk-QALAJNBG.js";
|
|
18
18
|
import {
|
|
19
19
|
NO_CACHE_ARG
|
|
@@ -243,4 +243,4 @@ export {
|
|
|
243
243
|
previewCommand,
|
|
244
244
|
previewFileName
|
|
245
245
|
};
|
|
246
|
-
//# sourceMappingURL=preview-
|
|
246
|
+
//# sourceMappingURL=preview-4GUQGDBD.js.map
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
fileArg,
|
|
8
8
|
requireTarget,
|
|
9
9
|
stageOp
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OMJ7DVFJ.js";
|
|
11
11
|
import "./chunk-3R62EYYX.js";
|
|
12
12
|
import "./chunk-GDFJOCDO.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-DP76WGDV.js";
|
|
14
14
|
import "./chunk-XD7C5OE7.js";
|
|
15
15
|
import "./chunk-UKENQSZ2.js";
|
|
16
16
|
import "./chunk-D5FY4FAK.js";
|
|
@@ -531,4 +531,4 @@ export {
|
|
|
531
531
|
rulesRunCommand,
|
|
532
532
|
rulesUpdateCommand
|
|
533
533
|
};
|
|
534
|
-
//# sourceMappingURL=rule-writes-
|
|
534
|
+
//# sourceMappingURL=rule-writes-6XP7G35U.js.map
|
|
@@ -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,KAA6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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYf;AAAA,EACA,aAAa;AAAA,IACX,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AAAA,IACT,QAAQ,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,kBAAkB;AAAA,IACzE,QAAQ,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,kBAAkB;AAAA,IACzE,QAAQ,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,kBAAkB;AAAA,IACzE,SAAS,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,mBAAmB;AAAA,IAC3E,QAAQ,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,kBAAkB;AAAA,IACzE,KAAK,MAAM,OAAO,2BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,eAAe;AAAA,EACrE;AAAA,EACA,MAAM;AAAA,IACJ,cAAc,EAAE,MAAM,UAAU,aAAa,qBAAqB;AAAA,IAClE,WAAW,EAAE,MAAM,UAAU,aAAa,gBAAgB;AAAA,IAC1D,MAAM,EAAE,MAAM,WAAW,aAAa,mCAAmC;AAAA,EAC3E;AAAA,EACA,SAAS;AACX,CAAC;","names":[]}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
LISTING_ACCOUNT_ARG,
|
|
3
2
|
NAME_CONTAINS_ARG,
|
|
4
|
-
accountsInScope,
|
|
5
3
|
csvOrJson,
|
|
6
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
|