@koda-sl/baker-cli 0.869.0-dev.0631d8a3c → 0.869.0-dev.620009099

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 (107) hide show
  1. package/README.md +1 -3
  2. package/dist/{account-LHY6YM6L.js → account-5VOZ4R2X.js} +2 -2
  3. package/dist/{account-assets-L6BX4YUQ.js → account-assets-DOHOKM2L.js} +54 -46
  4. package/dist/account-assets-DOHOKM2L.js.map +1 -0
  5. package/dist/{account-level-OX34JQ7C.js → account-level-HLSTNJHR.js} +4 -4
  6. package/dist/{accounts-LNFU27BU.js → accounts-SNH3LJ2H.js} +2 -2
  7. package/dist/{activities-LC64DAAK.js → activities-QHDGHXMI.js} +21 -12
  8. package/dist/activities-QHDGHXMI.js.map +1 -0
  9. package/dist/{ads-VSU53JN3.js → ads-MYACXO5A.js} +3 -3
  10. package/dist/{ads-ZR5D7BZT.js → ads-ZDSRE7D6.js} +27 -19
  11. package/dist/ads-ZDSRE7D6.js.map +1 -0
  12. package/dist/{adsets-3NIYL2GQ.js → adsets-CZQMTJ2T.js} +48 -30
  13. package/dist/adsets-CZQMTJ2T.js.map +1 -0
  14. package/dist/{asset-writes-5ZKZDPQ4.js → asset-writes-TXYCARXJ.js} +4 -4
  15. package/dist/{audience-writes-NL6NRLLY.js → audience-writes-DJG7XTFA.js} +29 -15
  16. package/dist/audience-writes-DJG7XTFA.js.map +1 -0
  17. package/dist/{audiences-DL267GNQ.js → audiences-QHM26I5Y.js} +27 -15
  18. package/dist/audiences-QHM26I5Y.js.map +1 -0
  19. package/dist/{businesses-RQ6P4DOS.js → businesses-ALNQZFB4.js} +2 -2
  20. package/dist/{campaigns-RXDC5FSQ.js → campaigns-55VLNVCE.js} +29 -18
  21. package/dist/campaigns-55VLNVCE.js.map +1 -0
  22. package/dist/{catalogs-QAZ7ZZ5R.js → catalogs-B24HAEXZ.js} +3 -3
  23. package/dist/{chunk-OMJ7DVFJ.js → chunk-2WHALQOJ.js} +2 -2
  24. package/dist/{chunk-XFTN3ARP.js → chunk-BPIHAIWB.js} +13 -22
  25. package/dist/chunk-BPIHAIWB.js.map +1 -0
  26. package/dist/{chunk-EGM42UKF.js → chunk-EJ6B5OS5.js} +2 -2
  27. package/dist/{chunk-WKRVHRWY.js → chunk-VBIKO56A.js} +14 -3
  28. package/dist/chunk-VBIKO56A.js.map +1 -0
  29. package/dist/{chunk-UE5ZFTDL.js → chunk-VUJPKIJN.js} +2 -2
  30. package/dist/{chunk-DP76WGDV.js → chunk-YF57BX3S.js} +87 -8
  31. package/dist/chunk-YF57BX3S.js.map +1 -0
  32. package/dist/cli.js +1 -1
  33. package/dist/{copy-writes-QYN6PBU2.js → copy-writes-S4X5XUSK.js} +4 -4
  34. package/dist/{creatives-CPLH3KHQ.js → creatives-BCTG6PV4.js} +32 -19
  35. package/dist/creatives-BCTG6PV4.js.map +1 -0
  36. package/dist/{custom-conversions-CTJVAZKC.js → custom-conversions-56VXFOWV.js} +27 -15
  37. package/dist/custom-conversions-56VXFOWV.js.map +1 -0
  38. package/dist/{draft-UU3F2VMJ.js → draft-OMGA2NYG.js} +2 -2
  39. package/dist/{insights-QU5A4XBO.js → insights-3SQWIU4E.js} +2 -2
  40. package/dist/{instant-experiences-EJWYFWDT.js → instant-experiences-HSRGMQ5T.js} +3 -3
  41. package/dist/{leads-FEEWX7OO.js → leads-LWWPMZRY.js} +3 -3
  42. package/dist/{linkedin-RMZMQ2ZA.js → linkedin-EBOTX37R.js} +4 -8
  43. package/dist/{linkedin-RMZMQ2ZA.js.map → linkedin-EBOTX37R.js.map} +1 -1
  44. package/dist/{media-PUOLJUN3.js → media-UODVM47L.js} +3 -3
  45. package/dist/{meta-HOFABFAK.js → meta-4IOVQSFF.js} +40 -40
  46. package/dist/{page-photos-ZBMJLL5V.js → page-photos-BCEDWPGX.js} +3 -3
  47. package/dist/{pages-YZC44QR2.js → pages-TZBFJXNR.js} +2 -2
  48. package/dist/{pixels-EX6FHVHW.js → pixels-2BG3XMZP.js} +25 -12
  49. package/dist/pixels-2BG3XMZP.js.map +1 -0
  50. package/dist/preview-HD3QAR53.js +104 -0
  51. package/dist/preview-HD3QAR53.js.map +1 -0
  52. package/dist/{preview-XXQ5AHXP.js → preview-WHUVS5JJ.js} +43 -135
  53. package/dist/preview-WHUVS5JJ.js.map +1 -0
  54. package/dist/{rule-writes-6XP7G35U.js → rule-writes-Q5NLSBF5.js} +3 -3
  55. package/dist/{rules-BRULCGRV.js → rules-Z7MMVOZ2.js} +41 -24
  56. package/dist/rules-Z7MMVOZ2.js.map +1 -0
  57. package/dist/{shared-64RE42DL.js → shared-AXONQS3M.js} +16 -4
  58. package/dist/{studies-357M2C2K.js → studies-HUINRZHD.js} +33 -16
  59. package/dist/studies-HUINRZHD.js.map +1 -0
  60. package/dist/{study-writes-HXUQRPIK.js → study-writes-SI5QXY7F.js} +3 -3
  61. package/dist/{targeting-7T7XHBIX.js → targeting-3XK4OLPG.js} +3 -3
  62. package/dist/{videos-TJG5CA7N.js → videos-C5OCSAIF.js} +2 -2
  63. package/dist/{write-commands-4KI6T2NF.js → write-commands-T46SVSQ7.js} +7 -7
  64. package/package.json +1 -1
  65. package/dist/account-assets-L6BX4YUQ.js.map +0 -1
  66. package/dist/activities-LC64DAAK.js.map +0 -1
  67. package/dist/ads-ZR5D7BZT.js.map +0 -1
  68. package/dist/adsets-3NIYL2GQ.js.map +0 -1
  69. package/dist/audience-writes-NL6NRLLY.js.map +0 -1
  70. package/dist/audiences-DL267GNQ.js.map +0 -1
  71. package/dist/campaigns-RXDC5FSQ.js.map +0 -1
  72. package/dist/chunk-DP76WGDV.js.map +0 -1
  73. package/dist/chunk-WKRVHRWY.js.map +0 -1
  74. package/dist/chunk-XFTN3ARP.js.map +0 -1
  75. package/dist/creatives-CPLH3KHQ.js.map +0 -1
  76. package/dist/custom-conversions-CTJVAZKC.js.map +0 -1
  77. package/dist/pixels-EX6FHVHW.js.map +0 -1
  78. package/dist/preview-4DDR337D.js +0 -151
  79. package/dist/preview-4DDR337D.js.map +0 -1
  80. package/dist/preview-XXQ5AHXP.js.map +0 -1
  81. package/dist/rules-BRULCGRV.js.map +0 -1
  82. package/dist/studies-357M2C2K.js.map +0 -1
  83. /package/dist/{account-LHY6YM6L.js.map → account-5VOZ4R2X.js.map} +0 -0
  84. /package/dist/{account-level-OX34JQ7C.js.map → account-level-HLSTNJHR.js.map} +0 -0
  85. /package/dist/{accounts-LNFU27BU.js.map → accounts-SNH3LJ2H.js.map} +0 -0
  86. /package/dist/{ads-VSU53JN3.js.map → ads-MYACXO5A.js.map} +0 -0
  87. /package/dist/{asset-writes-5ZKZDPQ4.js.map → asset-writes-TXYCARXJ.js.map} +0 -0
  88. /package/dist/{businesses-RQ6P4DOS.js.map → businesses-ALNQZFB4.js.map} +0 -0
  89. /package/dist/{catalogs-QAZ7ZZ5R.js.map → catalogs-B24HAEXZ.js.map} +0 -0
  90. /package/dist/{chunk-OMJ7DVFJ.js.map → chunk-2WHALQOJ.js.map} +0 -0
  91. /package/dist/{chunk-EGM42UKF.js.map → chunk-EJ6B5OS5.js.map} +0 -0
  92. /package/dist/{chunk-UE5ZFTDL.js.map → chunk-VUJPKIJN.js.map} +0 -0
  93. /package/dist/{copy-writes-QYN6PBU2.js.map → copy-writes-S4X5XUSK.js.map} +0 -0
  94. /package/dist/{draft-UU3F2VMJ.js.map → draft-OMGA2NYG.js.map} +0 -0
  95. /package/dist/{insights-QU5A4XBO.js.map → insights-3SQWIU4E.js.map} +0 -0
  96. /package/dist/{instant-experiences-EJWYFWDT.js.map → instant-experiences-HSRGMQ5T.js.map} +0 -0
  97. /package/dist/{leads-FEEWX7OO.js.map → leads-LWWPMZRY.js.map} +0 -0
  98. /package/dist/{media-PUOLJUN3.js.map → media-UODVM47L.js.map} +0 -0
  99. /package/dist/{meta-HOFABFAK.js.map → meta-4IOVQSFF.js.map} +0 -0
  100. /package/dist/{page-photos-ZBMJLL5V.js.map → page-photos-BCEDWPGX.js.map} +0 -0
  101. /package/dist/{pages-YZC44QR2.js.map → pages-TZBFJXNR.js.map} +0 -0
  102. /package/dist/{rule-writes-6XP7G35U.js.map → rule-writes-Q5NLSBF5.js.map} +0 -0
  103. /package/dist/{shared-64RE42DL.js.map → shared-AXONQS3M.js.map} +0 -0
  104. /package/dist/{study-writes-HXUQRPIK.js.map → study-writes-SI5QXY7F.js.map} +0 -0
  105. /package/dist/{targeting-7T7XHBIX.js.map → targeting-3XK4OLPG.js.map} +0 -0
  106. /package/dist/{videos-TJG5CA7N.js.map → videos-C5OCSAIF.js.map} +0 -0
  107. /package/dist/{write-commands-4KI6T2NF.js.map → write-commands-T46SVSQ7.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, 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.
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.
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.
@@ -1491,7 +1491,6 @@ baker ads meta insights --object 9988 --level ad --intent video \
1491
1491
  --breakdowns publisher_platform,platform_position --date-preset last_30d # one ad only: hints flag placements playing far below the ad's own rate
1492
1492
  baker ads meta preview --creative-id 9988 --placement facebook_reels_overlay --platform facebook
1493
1493
  baker ads meta preview --list-formats # ad_format values + placement mappings
1494
- baker ads meta preview --creative-id 9988,9989 --ad-format MOBILE_FEED_STANDARD,INSTAGRAM_REELS # every creative × format pair in one call, drawn in parallel (at most 24)
1495
1494
  baker ads meta videos --ad-id 9988,9989 # download the ads' video files (MP4) to /tmp/meta-ad-videos; --url-only for the addresses
1496
1495
 
1497
1496
  # "What audience is this targeting?"
@@ -1817,7 +1816,6 @@ baker ads linkedin campaigns --account-id 503001492 --targeting
1817
1816
  # "What does this ad actually show?" — LinkedIn's own feed rendering, desktop + mobile:
1818
1817
  # data.previews[].shownText (the text displayed, in order) and .image (a picture)
1819
1818
  baker ads linkedin preview 1611562694 --account-id 503001492
1820
- baker ads linkedin preview 1611562694 1611562695 --placement mobile # several ads in one call, drawn in parallel
1821
1819
 
1822
1820
  # "Top companies seeing this campaign" (ABM feedback loop) — org names auto-resolved
1823
1821
  baker ads linkedin top-companies --campaign-id 1234 --last-days 30
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  handleMetaError,
3
3
  resolveAccountIdArg
4
- } from "./chunk-DP76WGDV.js";
4
+ } from "./chunk-YF57BX3S.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-LHY6YM6L.js.map
139
+ //# sourceMappingURL=account-5VOZ4R2X.js.map
@@ -1,8 +1,13 @@
1
1
  import {
2
+ LISTING_ACCOUNT_ARG,
3
+ accountsInScope,
2
4
  csvOrJson,
3
5
  handleMetaError,
4
- resolveAccountIdArg
5
- } from "./chunk-DP76WGDV.js";
6
+ listingLimit,
7
+ readEachAccount,
8
+ resolveAccountIdArg,
9
+ withAccountColumn
10
+ } from "./chunk-YF57BX3S.js";
6
11
  import "./chunk-QALAJNBG.js";
7
12
  import {
8
13
  NO_CACHE_ARG
@@ -35,9 +40,19 @@ async function read(path, params, args) {
35
40
  if (args["no-cache"]) params["skip-cache"] = "true";
36
41
  return await apiGet(path, params);
37
42
  }
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
+ }
38
52
  var outputArg = { type: "string", description: "json|csv|jsonl|md", default: "json" };
39
53
  var accountArg = { type: "string", description: "Meta ad account ID (act_...)" };
40
54
  var schemaAccount = { type: "string", description: "Meta ad account ID (act_123)", required: false };
55
+ var schemaListingAccount = { ...LISTING_ACCOUNT_ARG, required: false };
41
56
  var schemaNoCache = { type: "boolean", description: "Bypass the cache", required: false };
42
57
  var schemaOutput = { type: "string", description: "json|csv|jsonl|md", required: false, default: "json" };
43
58
  function instagramIdentityHints(rows) {
@@ -64,9 +79,9 @@ function instagramIdentityHints(rows) {
64
79
  }
65
80
  registerSchema({
66
81
  command: "ads.meta.instagram-accounts",
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.",
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.",
68
83
  args: {
69
- "account-id": schemaAccount,
84
+ "account-id": schemaListingAccount,
70
85
  "no-cache": schemaNoCache,
71
86
  output: { type: "string", description: "json|csv", required: false, default: "json" }
72
87
  }
@@ -76,20 +91,18 @@ var instagramAccountsCommand = defineCommand({
76
91
  name: "instagram-accounts",
77
92
  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"
78
93
  },
79
- args: { "account-id": accountArg, "no-cache": NO_CACHE_ARG, output: outputArg },
94
+ args: { "account-id": LISTING_ACCOUNT_ARG, "no-cache": NO_CACHE_ARG, output: outputArg },
80
95
  run: async ({ args }) => {
81
- const accountId = await resolveAccountIdArg(args);
82
96
  try {
83
- const rows = await read(
97
+ const { rows, tag, hints } = await readAccounts(
84
98
  "/api/ads/meta/instagram-accounts",
85
- { "account-id": accountId },
99
+ {},
86
100
  args
87
101
  );
88
- emit(
89
- rows.map((row) => ({ ...row, sources: row.sources.join(",") })),
90
- args,
91
- instagramIdentityHints(rows)
92
- );
102
+ emit(tag(rows.map((row) => ({ ...row, sources: row.sources.join(",") }))), args, [
103
+ ...hints,
104
+ ...instagramIdentityHints(rows)
105
+ ]);
93
106
  } catch (err) {
94
107
  handleMetaError(err);
95
108
  }
@@ -97,32 +110,26 @@ var instagramAccountsCommand = defineCommand({
97
110
  });
98
111
  registerSchema({
99
112
  command: "ads.meta.apps",
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 }
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 }
102
115
  });
103
116
  var appsCommand = defineCommand({
104
117
  meta: {
105
118
  name: "apps",
106
119
  description: "Apps the ad account can promote, for an app ad set's promoted_object. Example: baker ads meta apps --account-id act_123"
107
120
  },
108
- args: { "account-id": accountArg, "no-cache": NO_CACHE_ARG, output: outputArg },
121
+ args: { "account-id": LISTING_ACCOUNT_ARG, "no-cache": NO_CACHE_ARG, output: outputArg },
109
122
  run: async ({ args }) => {
110
- const accountId = await resolveAccountIdArg(args);
111
123
  try {
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 ? [
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 ? [
121
128
  '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.'
122
129
  ] : [
123
130
  "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."
124
131
  ]
125
- );
132
+ ]);
126
133
  } catch (err) {
127
134
  handleMetaError(err);
128
135
  }
@@ -167,9 +174,9 @@ function compactImage(row) {
167
174
  }
168
175
  registerSchema({
169
176
  command: "ads.meta.images",
170
- description: "The ad account's image library \u2014 each image_hash a creative can reuse without uploading again. --hash looks one up.",
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.",
171
178
  args: {
172
- "account-id": schemaAccount,
179
+ "account-id": schemaListingAccount,
173
180
  hash: { type: "string", description: "One image hash", required: false },
174
181
  limit: { type: "string", description: "Max rows (default 500)", required: false },
175
182
  full: { type: "boolean", description: "URLs, permalink and which creatives use it", required: false },
@@ -183,7 +190,7 @@ var imagesCommand = defineCommand({
183
190
  description: "Image library of the ad account (image hashes). Example: baker ads meta images --account-id act_123 --limit 20; --hash <hash> for one"
184
191
  },
185
192
  args: {
186
- "account-id": accountArg,
193
+ "account-id": LISTING_ACCOUNT_ARG,
187
194
  hash: { type: "string", description: "Look up one image hash" },
188
195
  limit: { type: "string", description: "Max rows (default 500)" },
189
196
  full: { type: "boolean", description: "Every field: url, permalink_url, creatives" },
@@ -191,13 +198,15 @@ var imagesCommand = defineCommand({
191
198
  output: outputArg
192
199
  },
193
200
  run: async ({ args }) => {
194
- const accountId = await resolveAccountIdArg(args);
195
- const params = { "account-id": accountId };
201
+ const params = {};
196
202
  if (args.hash) params.hash = args.hash;
197
203
  if (args.limit) params.limit = args.limit;
198
204
  try {
199
- const rows = await read("/api/ads/meta/images", params, args);
200
- emit(args.full ? rows : rows.map(compactImage), args, [
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,
201
210
  "A creative reuses one with its hash (the `image_hash` of a creative file). To push a Baker-library image, stage `media upload` instead."
202
211
  ]);
203
212
  } catch (err) {
@@ -207,10 +216,10 @@ var imagesCommand = defineCommand({
207
216
  });
208
217
  registerSchema({
209
218
  command: "ads.meta.labels",
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 }
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 }
212
221
  });
213
- var labelsListArgs = { "account-id": accountArg, "no-cache": NO_CACHE_ARG, output: outputArg };
222
+ var labelsListArgs = { "account-id": LISTING_ACCOUNT_ARG, "no-cache": NO_CACHE_ARG, output: outputArg };
214
223
  var labelsCommand = defineCommand({
215
224
  meta: {
216
225
  name: "labels",
@@ -221,11 +230,11 @@ var labelsCommand = defineCommand({
221
230
  },
222
231
  subCommands: {
223
232
  list: () => labelsListCommand,
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)
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)
229
238
  },
230
239
  args: labelsListArgs,
231
240
  default: "list"
@@ -237,10 +246,9 @@ var labelsListCommand = defineCommand({
237
246
  },
238
247
  args: labelsListArgs,
239
248
  run: async ({ args }) => {
240
- const accountId = await resolveAccountIdArg(args);
241
249
  try {
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."] : []);
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."] : []]);
244
252
  } catch (err) {
245
253
  handleMetaError(err);
246
254
  }
@@ -287,4 +295,4 @@ export {
287
295
  instagramIdentityHints,
288
296
  labelsCommand
289
297
  };
290
- //# sourceMappingURL=account-assets-L6BX4YUQ.js.map
298
+ //# sourceMappingURL=account-assets-DOHOKM2L.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 {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n LISTING_ACCOUNT_ARG,\n listingLimit,\n type ReadEachAccountOptions,\n readEachAccount,\n resolveAccountIdArg,\n withAccountColumn,\n} from \"./shared.ts\";\n\n/**\n * The account's identities and libraries an ad is built from — reads that used\n * to exist only as backend routes. They were left off the CLI as \"rarely\n * needed in isolation\", but each answers a question staging otherwise answers\n * with a refusal: which Instagram account an ad can run as, which apps it can\n * promote, whom an EU ad names, what an image hash or label id is, which\n * product sets a catalog ad can use, what an A/B test found.\n */\n\ntype Row = Record<string, unknown>;\ntype Args = Record<string, unknown>;\n\nfunction emit(rows: Row[], args: Args, hints: string[]): void {\n const fmt = csvOrJson(args);\n if (fmt !== \"json\") {\n writeAdsOutput(rows, fmt, undefined, hints);\n return;\n }\n writeJsonEnvelope(hints.length > 0 ? { ok: true, data: rows, hints } : { ok: true, data: rows });\n}\n\nasync function read<T>(path: string, params: Record<string, string>, args: Args): Promise<T> {\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n return await apiGet<T>(path, params);\n}\n\n/** An account listing: the named account, else every connected one with each row's account_id. */\nasync function readAccounts<T>(\n path: string,\n params: Record<string, string>,\n args: Args,\n options: ReadEachAccountOptions<T> = {},\n): Promise<{ rows: T[]; tag: <R extends object>(rows: R[]) => R[]; hints: string[] }> {\n const accounts = await accountsInScope(args);\n const listed = await readEachAccount(\n accounts,\n (accountId) => read<T[]>(path, { ...params, \"account-id\": accountId }, args),\n options,\n );\n return { rows: listed.rows, tag: (rows) => withAccountColumn(rows, listed.accountOf), hints: listed.hints };\n}\n\nconst outputArg = { type: \"string\", description: \"json|csv|jsonl|md\", default: \"json\" } as const;\nconst accountArg = { type: \"string\", description: \"Meta ad account ID (act_...)\" } as const;\nconst schemaAccount = { type: \"string\", description: \"Meta ad account ID (act_123)\", required: false };\nconst schemaListingAccount = { ...LISTING_ACCOUNT_ARG, required: false };\nconst schemaNoCache = { type: \"boolean\", description: \"Bypass the cache\", required: false };\nconst schemaOutput = { type: \"string\", description: \"json|csv|jsonl|md\", required: false, default: \"json\" };\n\n// --- Instagram identities ---\n\nexport interface MetaInstagramIdentity {\n id: string;\n username?: string;\n sources: Array<\"ad_account\" | \"connected\" | \"page\" | \"page_backed\">;\n pageId?: string;\n pageName?: string;\n}\n\nexport function instagramIdentityHints(rows: readonly MetaInstagramIdentity[]): string[] {\n if (rows.length === 0) {\n return [\n \"No Instagram account is linked to this ad account or its Pages. A creative without --instagram-user cannot run in Instagram feeds, Stories or Reels — the account owner links one in Meta Business settings (Accounts → Instagram accounts) and assigns it to the ad account.\",\n ];\n }\n const listed = rows.filter((row) => row.sources.includes(\"ad_account\") || row.sources.includes(\"connected\"));\n const hints = [\"Pass the id as `creatives create --instagram-user <id>`.\"];\n if (listed.length > 0 && listed.length < rows.length) {\n hints.push(\n `Use one listed on the ad account (${listed.map((row) => row.username ?? row.id).join(\", \")}): when the account lists any, staging refuses an identity it does not list.`,\n );\n } else if (listed.length === 0) {\n hints.push(\n \"Only Page identities are listed (page = the Page's linked Instagram account, page_backed = an Instagram presence Meta made for a Page with none). Meta accepts either as --instagram-user; a page_backed one shows the Page's name and picture on Instagram.\",\n );\n }\n if (new Set(rows.map((row) => row.pageId).filter(Boolean)).size > 1) {\n hints.push(\"Several Pages are involved — use the identity of the Page the creative runs from (--page).\");\n }\n return hints;\n}\n\nregisterSchema({\n command: \"ads.meta.instagram-accounts\",\n description:\n \"The Instagram accounts an ad on this account can run as — the id `creatives create --instagram-user` takes. Lists accounts assigned or connected to the ad account and each promotable Page's linked or page-backed one. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: {\n \"account-id\": schemaListingAccount,\n \"no-cache\": schemaNoCache,\n output: { type: \"string\", description: \"json|csv\", required: false, default: \"json\" },\n },\n});\n\nexport const instagramAccountsCommand = defineCommand({\n meta: {\n name: \"instagram-accounts\",\n description:\n \"Instagram identities an ad can run as (the --instagram-user id). Start here before creatives create: baker ads meta instagram-accounts --account-id act_123\",\n },\n args: { \"account-id\": LISTING_ACCOUNT_ARG, \"no-cache\": NO_CACHE_ARG, output: outputArg },\n run: async ({ args }) => {\n try {\n const { rows, tag, hints } = await readAccounts<MetaInstagramIdentity>(\n \"/api/ads/meta/instagram-accounts\",\n {},\n args,\n );\n emit(tag(rows.map((row) => ({ ...row, sources: row.sources.join(\",\") }))), args, [\n ...hints,\n ...instagramIdentityHints(rows),\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- Apps ---\n\nregisterSchema({\n command: \"ads.meta.apps\",\n description:\n \"The apps this ad account can promote (app installs / app engagement), with their store URLs — the application_id and object_store_url an app ad set's promoted_object takes. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: { \"account-id\": schemaListingAccount, \"no-cache\": schemaNoCache, output: schemaOutput },\n});\n\nexport const appsCommand = defineCommand({\n meta: {\n name: \"apps\",\n description:\n \"Apps the ad account can promote, for an app ad set's promoted_object. Example: baker ads meta apps --account-id act_123\",\n },\n args: { \"account-id\": LISTING_ACCOUNT_ARG, \"no-cache\": NO_CACHE_ARG, output: outputArg },\n run: async ({ args }) => {\n try {\n const { rows, tag, hints } = await readAccounts<{\n id: string;\n name?: string;\n object_store_urls?: Record<string, string>;\n }>(\"/api/ads/meta/apps\", {}, args);\n emit(tag(rows.map((row) => ({ ...row }))), args, [\n ...hints,\n ...(rows.length > 0\n ? [\n 'An app ad set promotes one: promoted_object {\"application_id\":\"<id>\",\"object_store_url\":\"<store url>\"}. Use a real store URL (itunes / google_play); fb_canvas and instant_game are not app stores.',\n ]\n : [\n \"No promotable apps. The app has to be registered in Meta for Developers and its owner has to add this ad account under the app's Advanced settings → Advertising accounts.\",\n ]),\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- DSA ---\n\nregisterSchema({\n command: \"ads.meta.dsa-recommendations\",\n description:\n \"Names Meta suggests for the EU Digital Services Act disclosure (who benefits from and who pays for an ad) on this account.\",\n args: { \"account-id\": schemaAccount, \"no-cache\": schemaNoCache },\n});\n\nexport const dsaRecommendationsCommand = defineCommand({\n meta: {\n name: \"dsa-recommendations\",\n description:\n \"Meta's suggested DSA beneficiary/payor names for EU ad sets. Example: baker ads meta dsa-recommendations --account-id act_123\",\n },\n args: { \"account-id\": accountArg, \"no-cache\": NO_CACHE_ARG },\n run: async ({ args }) => {\n const accountId = await resolveAccountIdArg(args);\n try {\n const names = await read<string[]>(\"/api/ads/meta/dsa-recommendations\", { \"account-id\": accountId }, args);\n writeJsonEnvelope({\n ok: true,\n data: names,\n hints: [\n \"An ad set reaching the EU needs dsa_beneficiary and dsa_payor. When they are missing Baker fills both from the ad account's saved EU advertiser and payer, else the first of these, else the business name; pass one of these instead when the user names someone else (an agency paying for a client).\",\n ],\n });\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- Images and labels ---\n\nfunction compactImage(row: Row): Row {\n return {\n hash: row.hash,\n name: row.name,\n width: row.width,\n height: row.height,\n status: row.status,\n created_time: row.created_time,\n };\n}\n\nregisterSchema({\n command: \"ads.meta.images\",\n description:\n \"The ad account's image library — each image_hash a creative can reuse without uploading again. --hash looks one up. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: {\n \"account-id\": schemaListingAccount,\n hash: { type: \"string\", description: \"One image hash\", required: false },\n limit: { type: \"string\", description: \"Max rows (default 500)\", required: false },\n full: { type: \"boolean\", description: \"URLs, permalink and which creatives use it\", required: false },\n \"no-cache\": schemaNoCache,\n output: schemaOutput,\n },\n});\n\nexport const imagesCommand = defineCommand({\n meta: {\n name: \"images\",\n description:\n \"Image library of the ad account (image hashes). Example: baker ads meta images --account-id act_123 --limit 20; --hash <hash> for one\",\n },\n args: {\n \"account-id\": LISTING_ACCOUNT_ARG,\n hash: { type: \"string\", description: \"Look up one image hash\" },\n limit: { type: \"string\", description: \"Max rows (default 500)\" },\n full: { type: \"boolean\", description: \"Every field: url, permalink_url, creatives\" },\n \"no-cache\": NO_CACHE_ARG,\n output: outputArg,\n },\n run: async ({ args }) => {\n const params: Record<string, string> = {};\n if (args.hash) params.hash = args.hash as string;\n if (args.limit) params.limit = args.limit as string;\n try {\n const { rows, tag, hints } = await readAccounts<Row>(\"/api/ads/meta/images\", params, args, {\n limit: listingLimit(args, 500),\n });\n emit(tag(args.full ? rows : rows.map(compactImage)), args, [\n ...hints,\n \"A creative reuses one with its hash (the `image_hash` of a creative file). To push a Baker-library image, stage `media upload` instead.\",\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nregisterSchema({\n command: \"ads.meta.labels\",\n description:\n \"Ad labels defined on the account (Meta's tags for campaigns, ad sets, ads and creatives). With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n args: { \"account-id\": schemaListingAccount, \"no-cache\": schemaNoCache, output: schemaOutput },\n});\n\nconst labelsListArgs = { \"account-id\": LISTING_ACCOUNT_ARG, \"no-cache\": NO_CACHE_ARG, output: outputArg };\n\nexport const labelsCommand = defineCommand({\n meta: {\n name: \"labels\",\n description: `Ad labels on the account (list), or stage label writes: create, rename, delete, attach (file campaigns/ad sets/ads/creatives under one), detach.\n baker ads meta labels --account-id act_123\n baker ads meta labels create --name \"Q4 launch\"\n baker ads meta labels attach <labelId|meta_temp_…> --campaigns 6123,6124 --ads 6125`,\n },\n subCommands: {\n list: () => labelsListCommand,\n create: () => import(\"./asset-writes.ts\").then((m) => m.labelsCreateCommand),\n rename: () => import(\"./asset-writes.ts\").then((m) => m.labelsRenameCommand),\n delete: () => import(\"./asset-writes.ts\").then((m) => m.labelsDeleteCommand),\n attach: () => import(\"./asset-writes.ts\").then((m) => m.labelsAttachCommand),\n detach: () => import(\"./asset-writes.ts\").then((m) => m.labelsDetachCommand),\n },\n args: labelsListArgs,\n default: \"list\",\n});\n\nconst labelsListCommand = defineCommand({\n meta: {\n name: \"list\",\n description: \"Ad labels on the account. Runs by default. Example: baker ads meta labels --account-id act_123\",\n },\n args: labelsListArgs,\n run: async ({ args }) => {\n try {\n const { rows, tag, hints } = await readAccounts<Row>(\"/api/ads/meta/labels\", {}, args);\n emit(tag(rows), args, [...hints, ...(rows.length === 0 ? [\"This account has no ad labels.\"] : [])]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\n// --- High-demand periods ---\n\nregisterSchema({\n command: \"ads.meta.high-demand-periods\",\n description: \"The budget boosts (high-demand periods) set on a campaign or ad set: when each runs and by how much.\",\n args: {\n \"campaign-id\": { type: \"string\", description: \"Campaign or ad set ID\", required: true },\n \"no-cache\": schemaNoCache,\n output: schemaOutput,\n },\n});\n\nexport const highDemandPeriodsCommand = defineCommand({\n meta: {\n name: \"high-demand-periods\",\n description:\n \"Budget boosts on a campaign or ad set. Example: baker ads meta high-demand-periods --campaign-id 6123 (stage new ones with --budget-boost on campaigns or adsets create|update)\",\n },\n args: {\n \"campaign-id\": { type: \"string\", description: \"Campaign (or ad set) ID\", required: true },\n \"no-cache\": NO_CACHE_ARG,\n output: outputArg,\n },\n run: async ({ args }) => {\n try {\n const rows = await read<Row[]>(\n \"/api/ads/meta/high-demand-periods\",\n { \"campaign-id\": args[\"campaign-id\"] as string },\n args,\n );\n emit(rows, args, rows.length === 0 ? [\"No budget boosts on this campaign.\"] : []);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AA6B9B,SAAS,KAAK,MAAa,MAAY,OAAuB;AAC5D,QAAM,MAAM,UAAU,IAAI;AAC1B,MAAI,QAAQ,QAAQ;AAClB,mBAAe,MAAM,KAAK,QAAW,KAAK;AAC1C;AAAA,EACF;AACA,oBAAkB,MAAM,SAAS,IAAI,EAAE,IAAI,MAAM,MAAM,MAAM,MAAM,IAAI,EAAE,IAAI,MAAM,MAAM,KAAK,CAAC;AACjG;AAEA,eAAe,KAAQ,MAAc,QAAgC,MAAwB;AAC3F,MAAI,KAAK,UAAU,EAAG,QAAO,YAAY,IAAI;AAC7C,SAAO,MAAM,OAAU,MAAM,MAAM;AACrC;AAGA,eAAe,aACb,MACA,QACA,MACA,UAAqC,CAAC,GAC8C;AACpF,QAAM,WAAW,MAAM,gBAAgB,IAAI;AAC3C,QAAM,SAAS,MAAM;AAAA,IACnB;AAAA,IACA,CAAC,cAAc,KAAU,MAAM,EAAE,GAAG,QAAQ,cAAc,UAAU,GAAG,IAAI;AAAA,IAC3E;AAAA,EACF;AACA,SAAO,EAAE,MAAM,OAAO,MAAM,KAAK,CAAC,SAAS,kBAAkB,MAAM,OAAO,SAAS,GAAG,OAAO,OAAO,MAAM;AAC5G;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,uBAAuB,EAAE,GAAG,qBAAqB,UAAU,MAAM;AACvE,IAAM,gBAAgB,EAAE,M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6B5OS5.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-OMJ7DVFJ.js";
11
+ } from "./chunk-2WHALQOJ.js";
12
12
  import "./chunk-3R62EYYX.js";
13
13
  import "./chunk-GDFJOCDO.js";
14
14
  import {
15
15
  handleMetaError
16
- } from "./chunk-DP76WGDV.js";
16
+ } from "./chunk-YF57BX3S.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-OX34JQ7C.js.map
615
+ //# sourceMappingURL=account-level-HLSTNJHR.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  csvOrJson,
3
3
  handleMetaError
4
- } from "./chunk-DP76WGDV.js";
4
+ } from "./chunk-YF57BX3S.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-LNFU27BU.js.map
79
+ //# sourceMappingURL=accounts-SNH3LJ2H.js.map
@@ -3,13 +3,16 @@ import {
3
3
  registerMetaListSchema,
4
4
  shapeMetaListRows,
5
5
  writeMetaListRows
6
- } from "./chunk-WKRVHRWY.js";
6
+ } from "./chunk-VBIKO56A.js";
7
7
  import "./chunk-PRPSV4VB.js";
8
8
  import {
9
+ LISTING_ACCOUNT_ARG,
10
+ accountsInScope,
9
11
  csvOrJson,
10
12
  handleMetaError,
11
- resolveAccountIdArg
12
- } from "./chunk-DP76WGDV.js";
13
+ loggedAt,
14
+ readEachAccount
15
+ } from "./chunk-YF57BX3S.js";
13
16
  import "./chunk-QALAJNBG.js";
14
17
  import {
15
18
  NO_CACHE_ARG
@@ -29,7 +32,7 @@ import { defineCommand } from "citty";
29
32
  var SHOWN_EVENTS = 50;
30
33
  var READ_CAP = 5e3;
31
34
  var listArgs = {
32
- "account-id": { type: "string", description: "Meta ad account ID" },
35
+ "account-id": LISTING_ACCOUNT_ARG,
33
36
  days: { type: "string", description: "Lookback days (default 7)" },
34
37
  limit: {
35
38
  type: "string",
@@ -40,7 +43,7 @@ var listArgs = {
40
43
  };
41
44
  registerMetaListSchema(
42
45
  "activities",
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.",
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.",
44
47
  listArgs
45
48
  );
46
49
  var activitiesCommand = defineCommand({
@@ -61,18 +64,24 @@ Examples:
61
64
  },
62
65
  args: listArgs,
63
66
  run: async ({ args }) => {
64
- const accountId = await resolveAccountIdArg(args);
67
+ const accounts = await accountsInScope(args);
65
68
  try {
66
- const params = { "account-id": accountId };
69
+ const params = {};
67
70
  if (args.days) params.days = args.days;
68
71
  const shown = Number(args.limit ?? SHOWN_EVENTS);
69
72
  if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error("--limit must be a whole number of events"));
70
73
  params.limit = String(Math.min(shown + 1, READ_CAP));
71
74
  if (args["no-cache"]) params["skip-cache"] = "true";
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);
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]);
76
85
  } catch (err) {
77
86
  handleMetaError(err);
78
87
  }
@@ -81,4 +90,4 @@ Examples:
81
90
  export {
82
91
  activitiesCommand
83
92
  };
84
- //# sourceMappingURL=activities-LC64DAAK.js.map
93
+ //# sourceMappingURL=activities-QHDGHXMI.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 {\n accountsInScope,\n csvOrJson,\n handleMetaError,\n LISTING_ACCOUNT_ARG,\n loggedAt,\n readEachAccount,\n} from \"./shared.ts\";\n\n/** Events printed unless --limit names another number: a busy month printed 96 KB the agent cut with head (BAKER-1222). */\nconst SHOWN_EVENTS = 50;\n\n/** The most events one read returns (the activities route's cap): a read that reaches it may have left older ones out. */\nconst READ_CAP = 5000;\n\nconst listArgs = {\n \"account-id\": LISTING_ACCOUNT_ARG,\n days: { type: \"string\", description: \"Lookback days (default 7)\" },\n limit: {\n type: \"string\",\n description: `Events to print, newest first (default ${SHOWN_EVENTS}); a hint says when there are more`,\n },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"activities\",\n \"Account change log, as a table by default, one row per event: event_time, event_type, actor_name, object_type, object_name, object_id, and change ('old → new' when the change is a single value). Prints the 50 newest events; a hint says when there are more (--limit <n>). Start here: baker ads meta activities --account-id act_123 --days 2. --fields event_time,object_name,extra_data or --full for the raw change payload; --output json returns the rows in the envelope. With no --account-id and several accounts connected, every account is read and each row leads with its account_id.\",\n listArgs,\n);\n\nexport const activitiesCommand = defineCommand({\n meta: {\n name: \"activities\",\n description: `Audit log of recent ad-account changes (created, paused, edited). Default lookback 7 days,\n~90 day retention server-side. Prints the 50 newest events (--limit for more); a hint says when there are more.\n\nA table by default, one row per event: event_time, event_type, actor_name, object_type,\nobject_name, object_id, and change (\"old → new\" when the change is a single value: status,\nname, budget, goal). --fields takes dotted paths (extra_data holds the raw change); --full returns\nevery field Meta sent; --output json returns the rows as JSON.\n\nExamples:\n baker ads meta activities --account-id act_123 --days 14\n baker ads meta activities --account-id act_123 --days 2 --output json\n baker ads meta activities --account-id act_123 --fields event_time,object_name,extra_data`,\n },\n args: listArgs,\n run: async ({ args }) => {\n const accounts = await accountsInScope(args);\n try {\n const params: Record<string, string> = {};\n if (args.days) params.days = args.days as string;\n const shown = Number(args.limit ?? SHOWN_EVENTS);\n if (!Number.isInteger(shown) || shown < 1) handleMetaError(new Error(\"--limit must be a whole number of events\"));\n // One event past the ones printed says whether there are more, without reading them all.\n params.limit = String(Math.min(shown + 1, READ_CAP));\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const read = await readEachAccount(\n accounts,\n (accountId) =>\n apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/activities\", { ...params, \"account-id\": accountId }),\n { time: (row) => loggedAt(row.event_time) },\n );\n const { rows: data, accountOf } = read;\n // Each account read stops at READ_CAP, so the merged log is newest-first only that far.\n const window = Math.min(shown, READ_CAP);\n const shaped = shapeMetaListRows(\"activities\", data.slice(0, window), args, accountOf?.slice(0, window));\n const more =\n data.length > window && window === shown\n ? [`Showing the ${shown} newest events; there are more. --limit <n> prints more, or narrow --days.`]\n : data.length >= READ_CAP\n ? [`Showing the ${READ_CAP} newest events, the most one read returns; there may be more. Narrow --days.`]\n : [];\n writeMetaListRows(\"activities\", shaped, csvOrJson(args), [...read.hints, ...more]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAc9B,IAAM,eAAe;AAGrB,IAAM,WAAW;AAEjB,IAAM,WAAW;AAAA,EACf,cAAc;AAAA,EACd,MAAM,EAAE,MAAM,UAAU,aAAa,4BAA4B;AAAA,EACjE,OAAO;AAAA,IACL,MAAM;AAAA,IACN,aAAa,0CAA0C,YAAY;AAAA,EACrE;AAAA,EACA,YAAY;AAAA,EACZ,GAAG;AACL;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,oBAAoB,cAAc;AAAA,EAC7C,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYf;AAAA,EACA,MAAM;AAAA,EACN,KAAK,OAAO,EAAE,KAAK,MAAM;AACvB,UAAM,WAAW,MAAM,gBAAgB,IAAI;AAC3C,QAAI;AACF,YAAM,SAAiC,CAAC;AACxC,UAAI,KAAK,KAAM,QAAO,OAAO,KAAK;AAClC,YAAM,QAAQ,OAAO,KAAK,SAAS,YAAY;AAC/C,UAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,EAAG,iBAAgB,IAAI,MAAM,0CAA0C,CAAC;AAEhH,aAAO,QAAQ,OAAO,KAAK,IAAI,QAAQ,GAAG,QAAQ,CAAC;AACnD,UAAI,KAAK,UAAU,EAAG,QAAO,YAAY,IAAI;AAC7C,YAAM,OAAO,MAAM;AAAA,QACjB;AAAA,QACA,CAAC,cACC,OAAuC,4BAA4B,EAAE,GAAG,QAAQ,cAAc,UAAU,CAAC;AAAA,QAC3G,EAAE,MAAM,CAAC,QAAQ,SAAS,IAAI,UAAU,EAAE;AAAA,MAC5C;AACA,YAAM,EAAE,MAAM,MAAM,UAAU,IAAI;AAElC,YAAM,SAAS,KAAK,IAAI,OAAO,QAAQ;AACvC,YAAM,SAAS,kBAAkB,cAAc,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,WAAW,MAAM,GAAG,MAAM,CAAC;AACvG,YAAM,OACJ,KAAK,SAAS,UAAU,WAAW,QAC/B,CAAC,eAAe,KAAK,4EAA4E,IACjG,KAAK,UAAU,WACb,CAAC,eAAe,QAAQ,8EAA8E,IACtG,CAAC;AACT,wBAAkB,cAAc,QAAQ,UAAU,IAAI,GAAG,CAAC,GAAG,KAAK,OAAO,GAAG,IAAI,CAAC;AAAA,IACnF,SAAS,KAAK;AACZ,sBAAgB,GAAG;AAAA,IACrB;AAAA,EACF;AACF,CAAC;","names":[]}
@@ -34,8 +34,8 @@ 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-HOFABFAK.js").then((m) => m.metaCommand),
38
- linkedin: () => import("./linkedin-RMZMQ2ZA.js").then((m) => m.linkedinCommand),
37
+ meta: () => import("./meta-4IOVQSFF.js").then((m) => m.metaCommand),
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),
41
41
  performance: () => import("./performance-Y2S5FDGI.js").then((m) => m.performanceCommand),
@@ -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-VSU53JN3.js.map
48
+ //# sourceMappingURL=ads-MYACXO5A.js.map
@@ -6,16 +6,18 @@ import {
6
6
  registerMetaListSchema,
7
7
  shapeMetaListRows,
8
8
  writeMetaListRows
9
- } from "./chunk-WKRVHRWY.js";
9
+ } from "./chunk-VBIKO56A.js";
10
10
  import "./chunk-PRPSV4VB.js";
11
11
  import {
12
12
  NAME_CONTAINS_ARG,
13
+ accountsInScope,
13
14
  csvOrJson,
14
15
  handleMetaError,
15
- resolveAccountIdArg,
16
+ listingLimit,
17
+ readEachAccount,
16
18
  resolveEffectiveStatus,
17
19
  statusFilterHints
18
- } from "./chunk-DP76WGDV.js";
20
+ } from "./chunk-YF57BX3S.js";
19
21
  import "./chunk-QALAJNBG.js";
20
22
  import {
21
23
  NO_CACHE_ARG
@@ -32,11 +34,11 @@ import "./chunk-YQSBHWOI.js";
32
34
 
33
35
  // src/commands/ads/meta/ads.ts
34
36
  import { defineCommand } from "citty";
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.";
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.";
36
38
  var listArgs = {
37
39
  "account-id": {
38
40
  type: "string",
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."
41
+ description: "Meta ad account ID (act_123). Without it the listing reads every connected account, each row tagged with its account_id."
40
42
  },
41
43
  "adset-id": { type: "string", alias: "adset", description: "Filter to one adset" },
42
44
  "campaign-id": { type: "string", alias: "campaign", description: "Filter to one campaign" },
@@ -64,10 +66,10 @@ var listCommand = defineCommand({
64
66
  },
65
67
  args: listArgs,
66
68
  run: async ({ args }) => {
67
- const accountId = await resolveAccountIdArg(args);
69
+ const accounts = await accountsInScope(args);
68
70
  const effectiveStatus = resolveEffectiveStatus(args);
69
71
  try {
70
- const params = { "account-id": accountId };
72
+ const params = {};
71
73
  if (args["adset-id"]) params["adset-id"] = args["adset-id"];
72
74
  if (args["campaign-id"]) params["campaign-id"] = args["campaign-id"];
73
75
  if (effectiveStatus) params["effective-status"] = effectiveStatus;
@@ -78,9 +80,15 @@ var listCommand = defineCommand({
78
80
  if (fields) params.fields = fields;
79
81
  if (args.limit) params.limit = args.limit;
80
82
  if (args["no-cache"]) params["skip-cache"] = "true";
81
- const data = await apiGet("/api/ads/meta/ads", params);
82
- const shaped = shapeMetaListRows("ads", data, args);
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);
83
90
  writeMetaListRows("ads", shaped, csvOrJson(args), [
91
+ ...read.hints,
84
92
  ...statusFilterHints(data, effectiveStatus, "ads"),
85
93
  ...largeListingHints("ads", data.length)
86
94
  ]);
@@ -116,15 +124,15 @@ Examples:
116
124
  },
117
125
  subCommands: {
118
126
  list: listCommand,
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)
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)
128
136
  },
129
137
  // `args` stays even though the parent has no `run`: citty scans rawArgs for the
130
138
  // subcommand name using THIS command's arg defs, so without them `--account-id act_1`
@@ -136,4 +144,4 @@ Examples:
136
144
  export {
137
145
  adsListCommand
138
146
  };
139
- //# sourceMappingURL=ads-ZR5D7BZT.js.map
147
+ //# sourceMappingURL=ads-ZDSRE7D6.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 accountsInScope,\n csvOrJson,\n handleMetaError,\n listingLimit,\n NAME_CONTAINS_ARG,\n readEachAccount,\n resolveEffectiveStatus,\n statusFilterHints,\n} from \"./shared.ts\";\n\nconst ACCOUNT_SELECTION =\n \"Account: --account-id, else BAKER_META_AD_ACCOUNT_ID, else every connected Meta ad account — with several, the list reads each and adds account_id to every row (--adset-id or --campaign-id is read once). Writes still name one.\";\n\nconst listArgs = {\n \"account-id\": {\n type: \"string\",\n description:\n \"Meta ad account ID (act_123). Without it the listing reads every connected account, each row tagged with its account_id.\",\n },\n \"adset-id\": { type: \"string\", alias: \"adset\", description: \"Filter to one adset\" },\n \"campaign-id\": { type: \"string\", alias: \"campaign\", description: \"Filter to one campaign\" },\n \"effective-status\": { type: \"string\", description: \"Comma-separated effective_status filter (overrides default)\" },\n \"all-statuses\": { type: \"boolean\", description: \"Drop the default ACTIVE filter\" },\n \"name-contains\": NAME_CONTAINS_ARG,\n ids: IDS_ARG,\n \"lead-form\": {\n type: \"string\",\n description:\n \"Only the ads whose button opens this instant form (a form id from `baker ads meta lead-forms`). Add --all-statuses to count paused ones too. Example: --lead-form 1290001 --all-statuses\",\n },\n limit: { type: \"string\", description: \"Max rows (default 1000)\" },\n \"no-cache\": NO_CACHE_ARG,\n ...META_LIST_SHAPE_ARGS,\n} as const;\n\nregisterMetaListSchema(\n \"ads\",\n `List ads in a Meta ad account, as a table by default: id, name, adset_id, campaign_id, effective_status, creative_id, issues (why an ad is WITH_ISSUES), created_time, plus each creative's link (destination), lead_form_id (the instant form its button opens) and url_tags — audit live ads' tracking in this one call, not a creatives call per ad. Which ads use a form: --lead-form <id> --all-statuses. Start here: baker ads meta ads --adset-id 6123. --fields takes dotted paths (e.g. id,tracking_specs); --full returns every field Meta sent; --output json returns the rows in the envelope. ${ACCOUNT_SELECTION}`,\n listArgs,\n);\n\nconst listCommand = defineCommand({\n meta: {\n name: \"list\",\n description: `List ads in a Meta ad account. Runs by default when no subcommand is given. ${ACCOUNT_SELECTION} Example: baker ads meta ads --account-id act_123`,\n },\n args: listArgs,\n run: async ({ args }) => {\n const accounts = await accountsInScope(args);\n const effectiveStatus = resolveEffectiveStatus(args);\n try {\n const params: Record<string, string> = {};\n if (args[\"adset-id\"]) params[\"adset-id\"] = args[\"adset-id\"] as string;\n if (args[\"campaign-id\"]) params[\"campaign-id\"] = args[\"campaign-id\"] as string;\n if (effectiveStatus) params[\"effective-status\"] = effectiveStatus;\n if (args[\"name-contains\"]) params[\"name-contains\"] = args[\"name-contains\"] as string;\n if (args.ids) params.ids = args.ids as string;\n if (args[\"lead-form\"]) params[\"lead-form\"] = args[\"lead-form\"] as string;\n const fields = metaListFields(\"ads\", args);\n if (fields) params.fields = fields;\n if (args.limit) params.limit = args.limit as string;\n if (args[\"no-cache\"]) params[\"skip-cache\"] = \"true\";\n const read = await readEachAccount(\n accounts,\n (accountId) =>\n apiGet<Array<Record<string, unknown>>>(\"/api/ads/meta/ads\", { ...params, \"account-id\": accountId }),\n { byParent: Boolean(args[\"adset-id\"] || args[\"campaign-id\"]), limit: listingLimit(args, 1000) },\n );\n const data = read.rows;\n const shaped = shapeMetaListRows(\"ads\", data, args, read.accountOf);\n writeMetaListRows(\"ads\", shaped, csvOrJson(args), [\n ...read.hints,\n ...statusFilterHints(data, effectiveStatus, \"ads\"),\n ...largeListingHints(\"ads\", data.length),\n ]);\n } catch (err) {\n handleMetaError(err);\n }\n },\n});\n\nexport const adsListCommand = defineCommand({\n meta: {\n name: \"ads\",\n description: `List ads in a Meta ad account, or stage writes (create/update/pause/resume/archive/delete/duplicate/copy/retag).\nDefaults to ACTIVE only — pass --all-statuses to widen. Write subcommands stage ops on this chat's draft.\n${ACCOUNT_SELECTION}\n\nThe dashboard shows effective_status (e.g. WITH_ISSUES, PENDING_REVIEW, DISAPPROVED, ADSET_PAUSED), not status.\n\nListings print a table by default: id, name, adset_id, campaign_id, effective_status, creative_id, issues\n(why an ad is WITH_ISSUES), created_time, and the creative's link (destination), lead_form_id (the instant form it opens)\nand url_tags. --fields takes dotted paths (e.g. tracking_specs,\npreview_shareable_link); --full returns every field; --output json returns the rows as JSON.\n\nExamples:\n baker ads meta ads --account-id act_123\n baker ads meta ads --adset-id 6123\n baker ads meta ads --account-id act_123 --all-statuses --name-contains octubre --fields id,name,adset_id,creative_id — find one ad by name\n baker ads meta ads --adset-id 6123 --fields id,name,preview_shareable_link\n baker ads meta ads --ids 6123,6124 — the ads you have ids for, any status\n baker ads meta ads --account-id act_123 --lead-form 1290001 --all-statuses — the ads that open one instant form\n baker ads meta ads create --name \"Ad 1\" --adset meta_temp_as01 --creative meta_temp_cr01\n baker ads meta ads pause 6123 --account-id act_123\n baker ads meta ads retag 6123 --set \"utm_medium=paid-social\" — fix tracking on a LIVE ad, keeping everything else`,\n },\n subCommands: {\n list: listCommand,\n create: () => import(\"./write-commands.ts\").then((m) => m.adsCreateCommand),\n update: () => import(\"./write-commands.ts\").then((m) => m.adsUpdateCommand),\n pause: () => import(\"./write-commands.ts\").then((m) => m.adsPauseCommand),\n resume: () => import(\"./write-commands.ts\").then((m) => m.adsResumeCommand),\n archive: () => import(\"./write-commands.ts\").then((m) => m.adsArchiveCommand),\n delete: () => import(\"./write-commands.ts\").then((m) => m.adsDeleteCommand),\n duplicate: () => import(\"./write-commands.ts\").then((m) => m.adsDuplicateCommand),\n copy: () => import(\"./copy-writes.ts\").then((m) => m.adsCopyCommand),\n retag: () => import(\"./write-commands.ts\").then((m) => m.adsRetagCommand),\n },\n // `args` stays even though the parent has no `run`: citty scans rawArgs for the\n // subcommand name using THIS command's arg defs, so without them `--account-id act_1`\n // would read `act_1` as a subcommand. `default` (not `run`) dispatches the bare\n // invocation — citty falls through to `run` after a subcommand, double-executing it.\n args: listArgs,\n default: \"list\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,qBAAqB;AAuB9B,IAAM,oBACJ;AAEF,IAAM,WAAW;AAAA,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