@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.
Files changed (102) hide show
  1. package/README.md +3 -1
  2. package/dist/{account-5VOZ4R2X.js → account-LHY6YM6L.js} +2 -2
  3. package/dist/{account-assets-DOHOKM2L.js → account-assets-L6BX4YUQ.js} +46 -54
  4. package/dist/account-assets-L6BX4YUQ.js.map +1 -0
  5. package/dist/{account-level-HLSTNJHR.js → account-level-OX34JQ7C.js} +4 -4
  6. package/dist/{accounts-SNH3LJ2H.js → accounts-LNFU27BU.js} +2 -2
  7. package/dist/{activities-QHDGHXMI.js → activities-LC64DAAK.js} +12 -21
  8. package/dist/activities-LC64DAAK.js.map +1 -0
  9. package/dist/{ads-MYACXO5A.js → ads-U33JFGCR.js} +2 -2
  10. package/dist/{ads-ZDSRE7D6.js → ads-ZR5D7BZT.js} +19 -27
  11. package/dist/ads-ZR5D7BZT.js.map +1 -0
  12. package/dist/{adsets-CZQMTJ2T.js → adsets-3NIYL2GQ.js} +30 -48
  13. package/dist/adsets-3NIYL2GQ.js.map +1 -0
  14. package/dist/{asset-writes-TXYCARXJ.js → asset-writes-5ZKZDPQ4.js} +4 -4
  15. package/dist/{audience-writes-DJG7XTFA.js → audience-writes-NL6NRLLY.js} +15 -29
  16. package/dist/audience-writes-NL6NRLLY.js.map +1 -0
  17. package/dist/{audiences-QHM26I5Y.js → audiences-DL267GNQ.js} +15 -27
  18. package/dist/audiences-DL267GNQ.js.map +1 -0
  19. package/dist/{businesses-ALNQZFB4.js → businesses-RQ6P4DOS.js} +2 -2
  20. package/dist/{campaigns-55VLNVCE.js → campaigns-RXDC5FSQ.js} +18 -29
  21. package/dist/campaigns-RXDC5FSQ.js.map +1 -0
  22. package/dist/{catalogs-B24HAEXZ.js → catalogs-QAZ7ZZ5R.js} +3 -3
  23. package/dist/{chunk-YF57BX3S.js → chunk-DP76WGDV.js} +8 -87
  24. package/dist/chunk-DP76WGDV.js.map +1 -0
  25. package/dist/{chunk-EJ6B5OS5.js → chunk-EGM42UKF.js} +2 -2
  26. package/dist/{chunk-2WHALQOJ.js → chunk-OMJ7DVFJ.js} +2 -2
  27. package/dist/{chunk-VUJPKIJN.js → chunk-UE5ZFTDL.js} +2 -2
  28. package/dist/{chunk-VBIKO56A.js → chunk-WKRVHRWY.js} +3 -14
  29. package/dist/chunk-WKRVHRWY.js.map +1 -0
  30. package/dist/cli.js +2 -2
  31. package/dist/{copy-writes-S4X5XUSK.js → copy-writes-QYN6PBU2.js} +4 -4
  32. package/dist/{creatives-BCTG6PV4.js → creatives-CPLH3KHQ.js} +19 -32
  33. package/dist/creatives-CPLH3KHQ.js.map +1 -0
  34. package/dist/{custom-conversions-56VXFOWV.js → custom-conversions-CTJVAZKC.js} +15 -27
  35. package/dist/custom-conversions-CTJVAZKC.js.map +1 -0
  36. package/dist/{draft-OMGA2NYG.js → draft-UU3F2VMJ.js} +2 -2
  37. package/dist/{gsc-JYP4ZCSH.js → gsc-4UAVQRDJ.js} +2 -2
  38. package/dist/{insights-3SQWIU4E.js → insights-QU5A4XBO.js} +2 -2
  39. package/dist/{instant-experiences-HSRGMQ5T.js → instant-experiences-EJWYFWDT.js} +3 -3
  40. package/dist/{leads-LWWPMZRY.js → leads-FEEWX7OO.js} +3 -3
  41. package/dist/{media-UODVM47L.js → media-PUOLJUN3.js} +3 -3
  42. package/dist/{meta-4IOVQSFF.js → meta-SPPSYRMC.js} +40 -40
  43. package/dist/{page-photos-BCEDWPGX.js → page-photos-ZBMJLL5V.js} +3 -3
  44. package/dist/{pages-TZBFJXNR.js → pages-YZC44QR2.js} +2 -2
  45. package/dist/{pixels-2BG3XMZP.js → pixels-EX6FHVHW.js} +12 -25
  46. package/dist/pixels-EX6FHVHW.js.map +1 -0
  47. package/dist/{preview-WHUVS5JJ.js → preview-4GUQGDBD.js} +2 -2
  48. package/dist/{query-EAZEG4QR.js → query-WDS7AJ4G.js} +14 -5
  49. package/dist/query-WDS7AJ4G.js.map +1 -0
  50. package/dist/{rule-writes-Q5NLSBF5.js → rule-writes-6XP7G35U.js} +3 -3
  51. package/dist/{rules-Z7MMVOZ2.js → rules-BRULCGRV.js} +24 -41
  52. package/dist/rules-BRULCGRV.js.map +1 -0
  53. package/dist/{shared-AXONQS3M.js → shared-64RE42DL.js} +4 -16
  54. package/dist/{studies-HUINRZHD.js → studies-357M2C2K.js} +16 -33
  55. package/dist/studies-357M2C2K.js.map +1 -0
  56. package/dist/{study-writes-SI5QXY7F.js → study-writes-HXUQRPIK.js} +3 -3
  57. package/dist/{targeting-3XK4OLPG.js → targeting-7T7XHBIX.js} +3 -3
  58. package/dist/{videos-C5OCSAIF.js → videos-TJG5CA7N.js} +2 -2
  59. package/dist/{write-commands-T46SVSQ7.js → write-commands-4KI6T2NF.js} +7 -7
  60. package/package.json +1 -1
  61. package/dist/account-assets-DOHOKM2L.js.map +0 -1
  62. package/dist/activities-QHDGHXMI.js.map +0 -1
  63. package/dist/ads-ZDSRE7D6.js.map +0 -1
  64. package/dist/adsets-CZQMTJ2T.js.map +0 -1
  65. package/dist/audience-writes-DJG7XTFA.js.map +0 -1
  66. package/dist/audiences-QHM26I5Y.js.map +0 -1
  67. package/dist/campaigns-55VLNVCE.js.map +0 -1
  68. package/dist/chunk-VBIKO56A.js.map +0 -1
  69. package/dist/chunk-YF57BX3S.js.map +0 -1
  70. package/dist/creatives-BCTG6PV4.js.map +0 -1
  71. package/dist/custom-conversions-56VXFOWV.js.map +0 -1
  72. package/dist/pixels-2BG3XMZP.js.map +0 -1
  73. package/dist/query-EAZEG4QR.js.map +0 -1
  74. package/dist/rules-Z7MMVOZ2.js.map +0 -1
  75. package/dist/studies-HUINRZHD.js.map +0 -1
  76. /package/dist/{account-5VOZ4R2X.js.map → account-LHY6YM6L.js.map} +0 -0
  77. /package/dist/{account-level-HLSTNJHR.js.map → account-level-OX34JQ7C.js.map} +0 -0
  78. /package/dist/{accounts-SNH3LJ2H.js.map → accounts-LNFU27BU.js.map} +0 -0
  79. /package/dist/{ads-MYACXO5A.js.map → ads-U33JFGCR.js.map} +0 -0
  80. /package/dist/{asset-writes-TXYCARXJ.js.map → asset-writes-5ZKZDPQ4.js.map} +0 -0
  81. /package/dist/{businesses-ALNQZFB4.js.map → businesses-RQ6P4DOS.js.map} +0 -0
  82. /package/dist/{catalogs-B24HAEXZ.js.map → catalogs-QAZ7ZZ5R.js.map} +0 -0
  83. /package/dist/{chunk-EJ6B5OS5.js.map → chunk-EGM42UKF.js.map} +0 -0
  84. /package/dist/{chunk-2WHALQOJ.js.map → chunk-OMJ7DVFJ.js.map} +0 -0
  85. /package/dist/{chunk-VUJPKIJN.js.map → chunk-UE5ZFTDL.js.map} +0 -0
  86. /package/dist/{copy-writes-S4X5XUSK.js.map → copy-writes-QYN6PBU2.js.map} +0 -0
  87. /package/dist/{draft-OMGA2NYG.js.map → draft-UU3F2VMJ.js.map} +0 -0
  88. /package/dist/{gsc-JYP4ZCSH.js.map → gsc-4UAVQRDJ.js.map} +0 -0
  89. /package/dist/{insights-3SQWIU4E.js.map → insights-QU5A4XBO.js.map} +0 -0
  90. /package/dist/{instant-experiences-HSRGMQ5T.js.map → instant-experiences-EJWYFWDT.js.map} +0 -0
  91. /package/dist/{leads-LWWPMZRY.js.map → leads-FEEWX7OO.js.map} +0 -0
  92. /package/dist/{media-UODVM47L.js.map → media-PUOLJUN3.js.map} +0 -0
  93. /package/dist/{meta-4IOVQSFF.js.map → meta-SPPSYRMC.js.map} +0 -0
  94. /package/dist/{page-photos-BCEDWPGX.js.map → page-photos-ZBMJLL5V.js.map} +0 -0
  95. /package/dist/{pages-TZBFJXNR.js.map → pages-YZC44QR2.js.map} +0 -0
  96. /package/dist/{preview-WHUVS5JJ.js.map → preview-4GUQGDBD.js.map} +0 -0
  97. /package/dist/{rule-writes-Q5NLSBF5.js.map → rule-writes-6XP7G35U.js.map} +0 -0
  98. /package/dist/{shared-AXONQS3M.js.map → shared-64RE42DL.js.map} +0 -0
  99. /package/dist/{study-writes-SI5QXY7F.js.map → study-writes-HXUQRPIK.js.map} +0 -0
  100. /package/dist/{targeting-3XK4OLPG.js.map → targeting-7T7XHBIX.js.map} +0 -0
  101. /package/dist/{videos-C5OCSAIF.js.map → videos-TJG5CA7N.js.map} +0 -0
  102. /package/dist/{write-commands-T46SVSQ7.js.map → write-commands-4KI6T2NF.js.map} +0 -0
package/README.md CHANGED
@@ -146,7 +146,7 @@ export BAKER_CHAT_ID="<chat-id>"
146
146
  - `BAKER_GOOGLE_ADS_CUSTOMER_ID` — default Google Ads customer ID (10 digits). Used when `--customer-id` is not passed (`--customer-id` takes `386-508-3115` as the UI writes it too). If neither is set and the account has exactly one Google Ads customer, it is auto-selected.
147
147
  - `BAKER_GA4_PROPERTY_ID` — default GA4 property ID. Used when `--property-id` is not passed. If neither is set and exactly one property is connected, it is auto-selected.
148
148
  - `BAKER_GSC_SITE_URL` — default GSC site URL. Used when `--site-url` is not passed. If neither is set and exactly one site is verified, it is auto-selected.
149
- - `BAKER_META_AD_ACCOUNT_ID` / `BAKER_LINKEDIN_AD_ACCOUNT_ID` — default Meta / LinkedIn ad account (Meta: `act_<n>` or the bare number). Used when `--account-id` is not passed. If neither is set and exactly one ad account is selected, it is auto-selected; with several, Meta listings (`campaigns`, `adsets`, `ads`, `audiences`, `creatives`, `activities`, `rules`, `rules history`, `custom-conversions`, `pixels`, `audiences saved`, `instagram-accounts`, `apps`, `images`, `labels`, `studies`) read every account and add `account_id` to each row, `--limit` capping the whole listing, and any other command refuses with `MISSING_ACCOUNT_ID` and lists them; an `--account-id` the company did not select is refused with `UNKNOWN_ACCOUNT`, listing the ones it did.
149
+ - `BAKER_META_AD_ACCOUNT_ID` / `BAKER_LINKEDIN_AD_ACCOUNT_ID` — default Meta / LinkedIn ad account (Meta: `act_<n>` or the bare number). Used when `--account-id` is not passed. If neither is set and exactly one ad account is selected, it is auto-selected; with several, the command refuses with `MISSING_ACCOUNT_ID` and lists them; an `--account-id` the company did not select is refused with `UNKNOWN_ACCOUNT`, listing the ones it did.
150
150
  - `BAKER_X_ADS_ACCOUNT_ID` — default X Ads account ID (base36). Used when `--account-id` is not passed. If neither is set and exactly one X Ads account is connected, it is auto-selected.
151
151
  - `BAKER_CHAT_ID` — the chat every staging command stages against (ads on every platform, tags, Tag Manager, GA4, Work Actions, Scheduled agents, site, funnel, Shopify, …). `scheduled-agents run` does not require it. When set, it is also sent as an `x-baker-chat-id` header on every request, so library additions that apply immediately (images, videos, followed brands) are listed in that chat's changes as already applied.
152
152
  - `BAKER_THREAD_ID` — set per turn by the sandbox. Sent as an `x-baker-thread-id` header alongside the chat header, so the tools a command reports or changes are those of whoever sent this turn, even while someone else writes in another thread of the same chat.
@@ -2603,6 +2603,7 @@ baker gsc query --list-presets
2603
2603
  # Free-form
2604
2604
  baker gsc query --dimensions "query,page" --days 28
2605
2605
  baker gsc query --dimensions "query" --row-limit 25000 --out keywords.csv
2606
+ baker gsc query --dimensions "query" --filter '{"dimension":"query","operator":"contains","expression":"black"}'
2606
2607
  ```
2607
2608
 
2608
2609
  csv, md and `--out file.csv` print the dimensions in the order asked for, then `clicks,impressions,ctr,position`. JSON rows carry their keys sorted; the envelope's `columns` gives the order.
@@ -2620,6 +2621,7 @@ csv, md and `--out file.csv` print the dimensions in the order asked for, then `
2620
2621
  | `--start-row` | Skip this many rows — the `nextStartRow` a full page returned |
2621
2622
  | `--type` | Search type: web\|image\|video\|news\|discover |
2622
2623
  | `--site-url` | Site URL (auto-resolved if not provided) |
2624
+ | `--filter` | Keep only matching rows: one filter `{"dimension":"query","operator":"contains","expression":"brand"}`, a list of them (all must match), or Search Console filter groups |
2623
2625
  | `--out` | Write to file |
2624
2626
  | `--output` | Format: json\|csv\|jsonl\|md |
2625
2627
  | `--no-cache` | Skip cache |
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleMetaError,
3
3
  resolveAccountIdArg
4
- } from "./chunk-YF57BX3S.js";
4
+ } from "./chunk-DP76WGDV.js";
5
5
  import "./chunk-QALAJNBG.js";
6
6
  import {
7
7
  NO_CACHE_ARG
@@ -136,4 +136,4 @@ export {
136
136
  accountDeliveryHints,
137
137
  accountPermissionHints
138
138
  };
139
- //# sourceMappingURL=account-5VOZ4R2X.js.map
139
+ //# sourceMappingURL=account-LHY6YM6L.js.map
@@ -1,13 +1,8 @@
1
1
  import {
2
- LISTING_ACCOUNT_ARG,
3
- accountsInScope,
4
2
  csvOrJson,
5
3
  handleMetaError,
6
- listingLimit,
7
- readEachAccount,
8
- resolveAccountIdArg,
9
- withAccountColumn
10
- } from "./chunk-YF57BX3S.js";
4
+ resolveAccountIdArg
5
+ } from "./chunk-DP76WGDV.js";
11
6
  import "./chunk-QALAJNBG.js";
12
7
  import {
13
8
  NO_CACHE_ARG
@@ -40,19 +35,9 @@ async function read(path, params, args) {
40
35
  if (args["no-cache"]) params["skip-cache"] = "true";
41
36
  return await apiGet(path, params);
42
37
  }
43
- async function readAccounts(path, params, args, options = {}) {
44
- const accounts = await accountsInScope(args);
45
- const listed = await readEachAccount(
46
- accounts,
47
- (accountId) => read(path, { ...params, "account-id": accountId }, args),
48
- options
49
- );
50
- return { rows: listed.rows, tag: (rows) => withAccountColumn(rows, listed.accountOf), hints: listed.hints };
51
- }
52
38
  var outputArg = { type: "string", description: "json|csv|jsonl|md", default: "json" };
53
39
  var accountArg = { type: "string", description: "Meta ad account ID (act_...)" };
54
40
  var schemaAccount = { type: "string", description: "Meta ad account ID (act_123)", required: false };
55
- var schemaListingAccount = { ...LISTING_ACCOUNT_ARG, required: false };
56
41
  var schemaNoCache = { type: "boolean", description: "Bypass the cache", required: false };
57
42
  var schemaOutput = { type: "string", description: "json|csv|jsonl|md", required: false, default: "json" };
58
43
  function instagramIdentityHints(rows) {
@@ -79,9 +64,9 @@ function instagramIdentityHints(rows) {
79
64
  }
80
65
  registerSchema({
81
66
  command: "ads.meta.instagram-accounts",
82
- description: "The Instagram accounts an ad on this account can run as \u2014 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.",
67
+ description: "The Instagram accounts an ad on this account can run as \u2014 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.",
83
68
  args: {
84
- "account-id": schemaListingAccount,
69
+ "account-id": schemaAccount,
85
70
  "no-cache": schemaNoCache,
86
71
  output: { type: "string", description: "json|csv", required: false, default: "json" }
87
72
  }
@@ -91,18 +76,20 @@ var instagramAccountsCommand = defineCommand({
91
76
  name: "instagram-accounts",
92
77
  description: "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"
93
78
  },
94
- args: { "account-id": LISTING_ACCOUNT_ARG, "no-cache": NO_CACHE_ARG, output: outputArg },
79
+ args: { "account-id": accountArg, "no-cache": NO_CACHE_ARG, output: outputArg },
95
80
  run: async ({ args }) => {
81
+ const accountId = await resolveAccountIdArg(args);
96
82
  try {
97
- const { rows, tag, hints } = await readAccounts(
83
+ const rows = await read(
98
84
  "/api/ads/meta/instagram-accounts",
99
- {},
85
+ { "account-id": accountId },
100
86
  args
101
87
  );
102
- emit(tag(rows.map((row) => ({ ...row, sources: row.sources.join(",") }))), args, [
103
- ...hints,
104
- ...instagramIdentityHints(rows)
105
- ]);
88
+ emit(
89
+ rows.map((row) => ({ ...row, sources: row.sources.join(",") })),
90
+ args,
91
+ instagramIdentityHints(rows)
92
+ );
106
93
  } catch (err) {
107
94
  handleMetaError(err);
108
95
  }
@@ -110,26 +97,32 @@ var instagramAccountsCommand = defineCommand({
110
97
  });
111
98
  registerSchema({
112
99
  command: "ads.meta.apps",
113
- description: "The apps this ad account can promote (app installs / app engagement), with their store URLs \u2014 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.",
114
- args: { "account-id": schemaListingAccount, "no-cache": schemaNoCache, output: schemaOutput }
100
+ description: "The apps this ad account can promote (app installs / app engagement), with their store URLs \u2014 the application_id and object_store_url an app ad set's promoted_object takes.",
101
+ args: { "account-id": schemaAccount, "no-cache": schemaNoCache, output: schemaOutput }
115
102
  });
116
103
  var appsCommand = defineCommand({
117
104
  meta: {
118
105
  name: "apps",
119
106
  description: "Apps the ad account can promote, for an app ad set's promoted_object. Example: baker ads meta apps --account-id act_123"
120
107
  },
121
- args: { "account-id": LISTING_ACCOUNT_ARG, "no-cache": NO_CACHE_ARG, output: outputArg },
108
+ args: { "account-id": accountArg, "no-cache": NO_CACHE_ARG, output: outputArg },
122
109
  run: async ({ args }) => {
110
+ const accountId = await resolveAccountIdArg(args);
123
111
  try {
124
- const { rows, tag, hints } = await readAccounts("/api/ads/meta/apps", {}, args);
125
- emit(tag(rows.map((row) => ({ ...row }))), args, [
126
- ...hints,
127
- ...rows.length > 0 ? [
112
+ const rows = await read(
113
+ "/api/ads/meta/apps",
114
+ { "account-id": accountId },
115
+ args
116
+ );
117
+ emit(
118
+ rows.map((row) => ({ ...row })),
119
+ args,
120
+ rows.length > 0 ? [
128
121
  '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.'
129
122
  ] : [
130
123
  "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 \u2192 Advertising accounts."
131
124
  ]
132
- ]);
125
+ );
133
126
  } catch (err) {
134
127
  handleMetaError(err);
135
128
  }
@@ -174,9 +167,9 @@ function compactImage(row) {
174
167
  }
175
168
  registerSchema({
176
169
  command: "ads.meta.images",
177
- description: "The ad account's image library \u2014 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.",
170
+ description: "The ad account's image library \u2014 each image_hash a creative can reuse without uploading again. --hash looks one up.",
178
171
  args: {
179
- "account-id": schemaListingAccount,
172
+ "account-id": schemaAccount,
180
173
  hash: { type: "string", description: "One image hash", required: false },
181
174
  limit: { type: "string", description: "Max rows (default 500)", required: false },
182
175
  full: { type: "boolean", description: "URLs, permalink and which creatives use it", required: false },
@@ -190,7 +183,7 @@ var imagesCommand = defineCommand({
190
183
  description: "Image library of the ad account (image hashes). Example: baker ads meta images --account-id act_123 --limit 20; --hash <hash> for one"
191
184
  },
192
185
  args: {
193
- "account-id": LISTING_ACCOUNT_ARG,
186
+ "account-id": accountArg,
194
187
  hash: { type: "string", description: "Look up one image hash" },
195
188
  limit: { type: "string", description: "Max rows (default 500)" },
196
189
  full: { type: "boolean", description: "Every field: url, permalink_url, creatives" },
@@ -198,15 +191,13 @@ var imagesCommand = defineCommand({
198
191
  output: outputArg
199
192
  },
200
193
  run: async ({ args }) => {
201
- const params = {};
194
+ const accountId = await resolveAccountIdArg(args);
195
+ const params = { "account-id": accountId };
202
196
  if (args.hash) params.hash = args.hash;
203
197
  if (args.limit) params.limit = args.limit;
204
198
  try {
205
- const { rows, tag, hints } = await readAccounts("/api/ads/meta/images", params, args, {
206
- limit: listingLimit(args, 500)
207
- });
208
- emit(tag(args.full ? rows : rows.map(compactImage)), args, [
209
- ...hints,
199
+ const rows = await read("/api/ads/meta/images", params, args);
200
+ emit(args.full ? rows : rows.map(compactImage), args, [
210
201
  "A creative reuses one with its hash (the `image_hash` of a creative file). To push a Baker-library image, stage `media upload` instead."
211
202
  ]);
212
203
  } catch (err) {
@@ -216,10 +207,10 @@ var imagesCommand = defineCommand({
216
207
  });
217
208
  registerSchema({
218
209
  command: "ads.meta.labels",
219
- description: "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.",
220
- args: { "account-id": schemaListingAccount, "no-cache": schemaNoCache, output: schemaOutput }
210
+ description: "Ad labels defined on the account (Meta's tags for campaigns, ad sets, ads and creatives).",
211
+ args: { "account-id": schemaAccount, "no-cache": schemaNoCache, output: schemaOutput }
221
212
  });
222
- var labelsListArgs = { "account-id": LISTING_ACCOUNT_ARG, "no-cache": NO_CACHE_ARG, output: outputArg };
213
+ var labelsListArgs = { "account-id": accountArg, "no-cache": NO_CACHE_ARG, output: outputArg };
223
214
  var labelsCommand = defineCommand({
224
215
  meta: {
225
216
  name: "labels",
@@ -230,11 +221,11 @@ var labelsCommand = defineCommand({
230
221
  },
231
222
  subCommands: {
232
223
  list: () => labelsListCommand,
233
- create: () => import("./asset-writes-TXYCARXJ.js").then((m) => m.labelsCreateCommand),
234
- rename: () => import("./asset-writes-TXYCARXJ.js").then((m) => m.labelsRenameCommand),
235
- delete: () => import("./asset-writes-TXYCARXJ.js").then((m) => m.labelsDeleteCommand),
236
- attach: () => import("./asset-writes-TXYCARXJ.js").then((m) => m.labelsAttachCommand),
237
- detach: () => import("./asset-writes-TXYCARXJ.js").then((m) => m.labelsDetachCommand)
224
+ create: () => import("./asset-writes-5ZKZDPQ4.js").then((m) => m.labelsCreateCommand),
225
+ rename: () => import("./asset-writes-5ZKZDPQ4.js").then((m) => m.labelsRenameCommand),
226
+ delete: () => import("./asset-writes-5ZKZDPQ4.js").then((m) => m.labelsDeleteCommand),
227
+ attach: () => import("./asset-writes-5ZKZDPQ4.js").then((m) => m.labelsAttachCommand),
228
+ detach: () => import("./asset-writes-5ZKZDPQ4.js").then((m) => m.labelsDetachCommand)
238
229
  },
239
230
  args: labelsListArgs,
240
231
  default: "list"
@@ -246,9 +237,10 @@ var labelsListCommand = defineCommand({
246
237
  },
247
238
  args: labelsListArgs,
248
239
  run: async ({ args }) => {
240
+ const accountId = await resolveAccountIdArg(args);
249
241
  try {
250
- const { rows, tag, hints } = await readAccounts("/api/ads/meta/labels", {}, args);
251
- emit(tag(rows), args, [...hints, ...rows.length === 0 ? ["This account has no ad labels."] : []]);
242
+ const rows = await read("/api/ads/meta/labels", { "account-id": accountId }, args);
243
+ emit(rows, args, rows.length === 0 ? ["This account has no ad labels."] : []);
252
244
  } catch (err) {
253
245
  handleMetaError(err);
254
246
  }
@@ -295,4 +287,4 @@ export {
295
287
  instagramIdentityHints,
296
288
  labelsCommand
297
289
  };
298
- //# sourceMappingURL=account-assets-DOHOKM2L.js.map
290
+ //# sourceMappingURL=account-assets-L6BX4YUQ.js.map
@@ -0,0 +1 @@
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 { csvOrJson, handleMetaError, resolveAccountIdArg } 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\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 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.\",\n args: {\n \"account-id\": schemaAccount,\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\": accountArg, \"no-cache\": NO_CACHE_ARG, output: outputArg },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const rows = await read<MetaInstagramIdentity[]>(\n \"/api/ads/meta/instagram-accounts\",\n { \"account-id\": accountId },\n args,\n );\n emit(\n rows.map((row) => ({ ...row, sources: row.sources.join(\",\") })),\n args,\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.\",\n args: { \"account-id\": schemaAccount, \"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\": accountArg, \"no-cache\": NO_CACHE_ARG, output: outputArg },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const rows = await read<Array<{ id: string; name?: string; object_store_urls?: Record<string, string> }>>(\n \"/api/ads/meta/apps\",\n { \"account-id\": accountId },\n args,\n );\n emit(\n rows.map((row) => ({ ...row })),\n args,\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.\",\n args: {\n \"account-id\": schemaAccount,\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\": accountArg,\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 accountId = await resolveAccountIdArg(args);\n const params: Record<string, string> = { \"account-id\": accountId };\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 = await read<Row[]>(\"/api/ads/meta/images\", params, args);\n emit(args.full ? rows : rows.map(compactImage), args, [\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: \"Ad labels defined on the account (Meta's tags for campaigns, ad sets, ads and creatives).\",\n args: { \"account-id\": schemaAccount, \"no-cache\": schemaNoCache, output: schemaOutput },\n});\n\nconst labelsListArgs = { \"account-id\": accountArg, \"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 const accountId = await resolveAccountIdArg(args);\n try {\n const rows = await read<Row[]>(\"/api/ads/meta/labels\", { \"account-id\": accountId }, args);\n emit(rows, args, 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;AAmB9B,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;AAEA,IAAM,YAAY,EAAE,MAAM,UAAU,aAAa,qBAAqB,SAAS,OAAO;AACtF,IAAM,aAAa,EAAE,MAAM,UAAU,aAAa,+BAA+B;AACjF,IAAM,gBAAgB,EAAE,MAAM,UAAU,aAAa,gCAAgC,UAAU,MAAM;AACrG,IAAM,gBAAgB,EAAE,MAAM,WAAW,aAAa,oBAAoB,UAAU,MAAM;AAC1F,IAAM,eAAe,EAAE,MAAM,UAAU,aAAa,q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YAAY,MAAM,oBAAoB,IAAI;AAChD,QAAI;AACF,YAAM,OAAO,MAAM,KAAY,wBAAwB,EAAE,cAAc,UAAU,GAAG,IAAI;AACxF,WAAK,MAAM,MAAM,KAAK,WAAW,IAAI,CAAC,gCAAgC,IAAI,CAAC,CAAC;AAAA,IAC9E,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;AAID,eAAe;AAAA,EACb,SAAS;AAAA,EACT,aAAa;AAAA,EACb,MAAM;AAAA,IACJ,eAAe,EAAE,MAAM,UAAU,aAAa,yBAAyB,UAAU,KAAK;AAAA,IACtF,YAAY;AAAA,IACZ,QAAQ;AAAA,EACV;AACF,CAAC;AAEM,IAAM,2BAA2B,cAAc;AAAA,EACpD,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aACE;AAAA,EACJ;AAAA,EACA,MAAM;AAAA,IACJ,eAAe,EAAE,MAAM,UAAU,aAAa,2BAA2B,UAAU,KAAK;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,6 +1,6 @@
1
1
  import {
2
2
  dayPartingFromFlags
3
- } from "./chunk-EJ6B5OS5.js";
3
+ } from "./chunk-EGM42UKF.js";
4
4
  import {
5
5
  bareAccountId,
6
6
  failWriteValidation,
@@ -8,12 +8,12 @@ import {
8
8
  numberFlag,
9
9
  requireTarget,
10
10
  stageOp
11
- } from "./chunk-2WHALQOJ.js";
11
+ } from "./chunk-OMJ7DVFJ.js";
12
12
  import "./chunk-3R62EYYX.js";
13
13
  import "./chunk-GDFJOCDO.js";
14
14
  import {
15
15
  handleMetaError
16
- } from "./chunk-YF57BX3S.js";
16
+ } from "./chunk-DP76WGDV.js";
17
17
  import "./chunk-XD7C5OE7.js";
18
18
  import "./chunk-UKENQSZ2.js";
19
19
  import "./chunk-D5FY4FAK.js";
@@ -612,4 +612,4 @@ export {
612
612
  pagePostsCommand,
613
613
  reachFrequencyCommand
614
614
  };
615
- //# sourceMappingURL=account-level-HLSTNJHR.js.map
615
+ //# sourceMappingURL=account-level-OX34JQ7C.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  csvOrJson,
3
3
  handleMetaError
4
- } from "./chunk-YF57BX3S.js";
4
+ } from "./chunk-DP76WGDV.js";
5
5
  import {
6
6
  connectedResourceHints
7
7
  } from "./chunk-P4NSJS54.js";
@@ -76,4 +76,4 @@ withEffect({ effect: "read", routes: ["GET /api/ads/meta/accounts"] }, accountsC
76
76
  export {
77
77
  accountsCommand
78
78
  };
79
- //# sourceMappingURL=accounts-SNH3LJ2H.js.map
79
+ //# sourceMappingURL=accounts-LNFU27BU.js.map
@@ -3,16 +3,13 @@ import {
3
3
  registerMetaListSchema,
4
4
  shapeMetaListRows,
5
5
  writeMetaListRows
6
- } from "./chunk-VBIKO56A.js";
6
+ } from "./chunk-WKRVHRWY.js";
7
7
  import "./chunk-PRPSV4VB.js";
8
8
  import {
9
- LISTING_ACCOUNT_ARG,
10
- accountsInScope,
11
9
  csvOrJson,
12
10
  handleMetaError,
13
- loggedAt,
14
- readEachAccount
15
- } from "./chunk-YF57BX3S.js";
11
+ resolveAccountIdArg
12
+ } from "./chunk-DP76WGDV.js";
16
13
  import "./chunk-QALAJNBG.js";
17
14
  import {
18
15
  NO_CACHE_ARG
@@ -32,7 +29,7 @@ import { defineCommand } from "citty";
32
29
  var SHOWN_EVENTS = 50;
33
30
  var READ_CAP = 5e3;
34
31
  var listArgs = {
35
- "account-id": LISTING_ACCOUNT_ARG,
32
+ "account-id": { type: "string", description: "Meta ad account ID" },
36
33
  days: { type: "string", description: "Lookback days (default 7)" },
37
34
  limit: {
38
35
  type: "string",
@@ -43,7 +40,7 @@ var listArgs = {
43
40
  };
44
41
  registerMetaListSchema(
45
42
  "activities",
46
- "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 \u2192 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.",
43
+ "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 \u2192 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.",
47
44
  listArgs
48
45
  );
49
46
  var activitiesCommand = defineCommand({
@@ -64,24 +61,18 @@ Examples:
64
61
  },
65
62
  args: listArgs,
66
63
  run: async ({ args }) => {
67
- const accounts = await accountsInScope(args);
64
+ const accountId = await resolveAccountIdArg(args);
68
65
  try {
69
- const params = {};
66
+ const params = { "account-id": accountId };
70
67
  if (args.days) params.days = args.days;
71
68
  const shown = Number(args.limit ?? SHOWN_EVENTS);
72
69
  if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error("--limit must be a whole number of events"));
73
70
  params.limit = String(Math.min(shown + 1, READ_CAP));
74
71
  if (args["no-cache"]) params["skip-cache"] = "true";
75
- const read = await readEachAccount(
76
- accounts,
77
- (accountId) => apiGet("/api/ads/meta/activities", { ...params, "account-id": accountId }),
78
- { time: (row) => loggedAt(row.event_time) }
79
- );
80
- const { rows: data, accountOf } = read;
81
- const window = Math.min(shown, READ_CAP);
82
- const shaped = shapeMetaListRows("activities", data.slice(0, window), args, accountOf?.slice(0, window));
83
- const more = data.length > window && window === shown ? [`Showing the ${shown} newest events; there are more. --limit <n> prints more, or narrow --days.`] : data.length >= READ_CAP ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`] : [];
84
- writeMetaListRows("activities", shaped, csvOrJson(args), [...read.hints, ...more]);
72
+ const data = await apiGet("/api/ads/meta/activities", params);
73
+ const shaped = shapeMetaListRows("activities", data.slice(0, shown), args);
74
+ const more = data.length > shown ? [`Showing the ${shown} newest events; there are more. --limit <n> prints more, or narrow --days.`] : data.length >= READ_CAP ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`] : [];
75
+ writeMetaListRows("activities", shaped, csvOrJson(args), more);
85
76
  } catch (err) {
86
77
  handleMetaError(err);
87
78
  }
@@ -90,4 +81,4 @@ Examples:
90
81
  export {
91
82
  activitiesCommand
92
83
  };
93
- //# sourceMappingURL=activities-QHDGHXMI.js.map
84
+ //# sourceMappingURL=activities-LC64DAAK.js.map
@@ -0,0 +1 @@
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 { csvOrJson, handleMetaError, resolveAccountIdArg } 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\": { type: \"string\", description: \"Meta ad account ID\" },\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.\",\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 accountId = await resolveAccountIdArg(args);\n try {\n const params: Record<string, string> = { \"account-id\": accountId };\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 data = await apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/activities\", params);\n const shaped = shapeMetaListRows(\"activities\", data.slice(0, shown), args);\n const more =\n data.length > 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), more);\n } catch (err) {\n handleMetaError(err);\n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AAkB,cAAc,QAAQ,UAAU,IAAI,GAAG,IAAI;AAAA,IAC/D,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -34,7 +34,7 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
34
34
  },
35
35
  subCommands: {
36
36
  google: () => import("./google-HHKFDH7I.js").then((m) => m.googleCommand),
37
- meta: () => import("./meta-4IOVQSFF.js").then((m) => m.metaCommand),
37
+ meta: () => import("./meta-SPPSYRMC.js").then((m) => m.metaCommand),
38
38
  linkedin: () => import("./linkedin-EBOTX37R.js").then((m) => m.linkedinCommand),
39
39
  x: () => import("./x-JU6LF2MM.js").then((m) => m.xCommand),
40
40
  chatgpt: () => import("./chatgpt-FV4PVN4W.js").then((m) => m.chatgptCommand),
@@ -45,4 +45,4 @@ Full guides: __tooling__/docs/tools/baker/ads-<platform>.md (google|meta|linkedi
45
45
  export {
46
46
  adsCommand
47
47
  };
48
- //# sourceMappingURL=ads-MYACXO5A.js.map
48
+ //# sourceMappingURL=ads-U33JFGCR.js.map
@@ -6,18 +6,16 @@ import {
6
6
  registerMetaListSchema,
7
7
  shapeMetaListRows,
8
8
  writeMetaListRows
9
- } from "./chunk-VBIKO56A.js";
9
+ } from "./chunk-WKRVHRWY.js";
10
10
  import "./chunk-PRPSV4VB.js";
11
11
  import {
12
12
  NAME_CONTAINS_ARG,
13
- accountsInScope,
14
13
  csvOrJson,
15
14
  handleMetaError,
16
- listingLimit,
17
- readEachAccount,
15
+ resolveAccountIdArg,
18
16
  resolveEffectiveStatus,
19
17
  statusFilterHints
20
- } from "./chunk-YF57BX3S.js";
18
+ } from "./chunk-DP76WGDV.js";
21
19
  import "./chunk-QALAJNBG.js";
22
20
  import {
23
21
  NO_CACHE_ARG
@@ -34,11 +32,11 @@ import "./chunk-YQSBHWOI.js";
34
32
 
35
33
  // src/commands/ads/meta/ads.ts
36
34
  import { defineCommand } from "citty";
37
- var ACCOUNT_SELECTION = "Account: --account-id, else BAKER_META_AD_ACCOUNT_ID, else every connected Meta ad account \u2014 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.";
35
+ var ACCOUNT_SELECTION = "Account: --account-id, else BAKER_META_AD_ACCOUNT_ID, else the company's only connected Meta ad account. With several connected it refuses with MISSING_ACCOUNT_ID listing each \u2014 re-run naming one.";
38
36
  var listArgs = {
39
37
  "account-id": {
40
38
  type: "string",
41
- description: "Meta ad account ID (act_123). Without it the listing reads every connected account, each row tagged with its account_id."
39
+ description: "Meta ad account ID (act_123). Optional when the company connected only one account (or BAKER_META_AD_ACCOUNT_ID is set); required when several are connected."
42
40
  },
43
41
  "adset-id": { type: "string", alias: "adset", description: "Filter to one adset" },
44
42
  "campaign-id": { type: "string", alias: "campaign", description: "Filter to one campaign" },
@@ -66,10 +64,10 @@ var listCommand = defineCommand({
66
64
  },
67
65
  args: listArgs,
68
66
  run: async ({ args }) => {
69
- const accounts = await accountsInScope(args);
67
+ const accountId = await resolveAccountIdArg(args);
70
68
  const effectiveStatus = resolveEffectiveStatus(args);
71
69
  try {
72
- const params = {};
70
+ const params = { "account-id": accountId };
73
71
  if (args["adset-id"]) params["adset-id"] = args["adset-id"];
74
72
  if (args["campaign-id"]) params["campaign-id"] = args["campaign-id"];
75
73
  if (effectiveStatus) params["effective-status"] = effectiveStatus;
@@ -80,15 +78,9 @@ var listCommand = defineCommand({
80
78
  if (fields) params.fields = fields;
81
79
  if (args.limit) params.limit = args.limit;
82
80
  if (args["no-cache"]) params["skip-cache"] = "true";
83
- const read = await readEachAccount(
84
- accounts,
85
- (accountId) => apiGet("/api/ads/meta/ads", { ...params, "account-id": accountId }),
86
- { byParent: Boolean(args["adset-id"] || args["campaign-id"]), limit: listingLimit(args, 1e3) }
87
- );
88
- const data = read.rows;
89
- const shaped = shapeMetaListRows("ads", data, args, read.accountOf);
81
+ const data = await apiGet("/api/ads/meta/ads", params);
82
+ const shaped = shapeMetaListRows("ads", data, args);
90
83
  writeMetaListRows("ads", shaped, csvOrJson(args), [
91
- ...read.hints,
92
84
  ...statusFilterHints(data, effectiveStatus, "ads"),
93
85
  ...largeListingHints("ads", data.length)
94
86
  ]);
@@ -124,15 +116,15 @@ Examples:
124
116
  },
125
117
  subCommands: {
126
118
  list: listCommand,
127
- create: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsCreateCommand),
128
- update: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsUpdateCommand),
129
- pause: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsPauseCommand),
130
- resume: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsResumeCommand),
131
- archive: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsArchiveCommand),
132
- delete: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsDeleteCommand),
133
- duplicate: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsDuplicateCommand),
134
- copy: () => import("./copy-writes-S4X5XUSK.js").then((m) => m.adsCopyCommand),
135
- retag: () => import("./write-commands-T46SVSQ7.js").then((m) => m.adsRetagCommand)
119
+ create: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsCreateCommand),
120
+ update: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsUpdateCommand),
121
+ pause: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsPauseCommand),
122
+ resume: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsResumeCommand),
123
+ archive: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsArchiveCommand),
124
+ delete: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsDeleteCommand),
125
+ duplicate: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsDuplicateCommand),
126
+ copy: () => import("./copy-writes-QYN6PBU2.js").then((m) => m.adsCopyCommand),
127
+ retag: () => import("./write-commands-4KI6T2NF.js").then((m) => m.adsRetagCommand)
136
128
  },
137
129
  // `args` stays even though the parent has no `run`: citty scans rawArgs for the
138
130
  // subcommand name using THIS command's arg defs, so without them `--account-id act_1`
@@ -144,4 +136,4 @@ Examples:
144
136
  export {
145
137
  adsListCommand
146
138
  };
147
- //# sourceMappingURL=ads-ZDSRE7D6.js.map
139
+ //# sourceMappingURL=ads-ZR5D7BZT.js.map
@@ -0,0 +1 @@
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 csvOrJson,\n handleMetaError,\n NAME_CONTAINS_ARG,\n resolveAccountIdArg,\n resolveEffectiveStatus,\n statusFilterHints,\n} from \"./shared.ts\";\n\nconst ACCOUNT_SELECTION =\n \"Account: --account-id, else BAKER_META_AD_ACCOUNT_ID, else the company's only connected Meta ad account. With several connected it refuses with MISSING_ACCOUNT_ID listing each — re-run naming one.\";\n\nconst listArgs = {\n \"account-id\": {\n type: \"string\",\n description:\n \"Meta ad account ID (act_123). Optional when the company connected only one account (or BAKER_META_AD_ACCOUNT_ID is set); required when several are connected.\",\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 accountId = await resolveAccountIdArg(args);\n const effectiveStatus = resolveEffectiveStatus(args);\n try {\n const params: Record<string, string> = { \"account-id\": accountId };\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 data = await apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/ads\", params);\n const shaped = shapeMetaListRows(\"ads\", data, args);\n writeMetaListRows(\"ads\", shaped, csvOrJson(args), [\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;AAqB9B,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,mlBAA8kB,iBAAiB;AAAA,EAC/lB;AACF;AAEA,IAAM,cAAc,cAAc;AAAA,EAChC,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa,+EAA+E,iBAAiB;AAAA,EAC/G;AAAA,EACA,MAAM;AAAA,EACN,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,UAAM,YAAY,MAAM,oBAAoB,IAAI;AAChD,UAAM,kBAAkB,uBAAuB,IAAI;AACnD,QAAI;AACF,YAAM,SAAiC,EAAE,cAAc,UAAU;AACjE,UAAI,KAAK,UAAU,EAAG,QAAO,UAAU,IAAI,KAAK,UAAU;AAC1D,UAAI,KAAK,aAAa,EAAG,QAAO,aAAa,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