@koda-sl/baker-cli 0.169.0 → 0.169.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -15954,10 +15954,27 @@ var metaMediaCommand = defineCommand64({
15954
15954
 
15955
15955
  // src/commands/ads/meta/pages.ts
15956
15956
  import { defineCommand as defineCommand65 } from "citty";
15957
+ function advertisablePages(data) {
15958
+ return data.filter((p) => Array.isArray(p.tasks) && p.tasks.includes("ADVERTISE"));
15959
+ }
15960
+ function pageSelectionHints(data) {
15961
+ const advertisable = advertisablePages(data);
15962
+ if (advertisable.length > 1) {
15963
+ return [
15964
+ "MULTIPLE Pages can run ads \u2014 do NOT guess. Confirm with the user which Page an ad should run from before passing --page to `creatives create`; a wrong Page publishes the ad under the wrong brand identity and staging will not catch it."
15965
+ ];
15966
+ }
15967
+ if (data.length > 0 && advertisable.length === 0) {
15968
+ return [
15969
+ "NO Page can run ads \u2014 none of the connected user's Pages carry the ADVERTISE task. Ask the user to grant Advertise access to the right Page before creating an ad; a readable-but-non-advertising Page still passes staging and would fail or run under the wrong identity."
15970
+ ];
15971
+ }
15972
+ return [];
15973
+ }
15957
15974
  var pagesCommand = defineCommand65({
15958
15975
  meta: {
15959
15976
  name: "pages",
15960
- description: `List the Facebook Pages the connected user manages. Every Meta ad publishes from a Page, so use this to find the Page id an ad should run from instead of asking the user for it. The 'tasks' field shows what the user can do on each Page (ADVERTISE means it can back ads).
15977
+ description: `List the Facebook Pages the connected user manages. Every Meta ad publishes from a Page, so use this to identify the Page an ad should run from. The 'tasks' field shows what the user can do on each Page (ADVERTISE means it can back ads). If exactly one Page can ADVERTISE, use it; if more than one can, confirm with the user which Page to use; if none can, ask the user to grant Advertise access \u2014 a wrong or non-advertising Page publishes under the wrong brand identity.
15961
15978
 
15962
15979
  Examples:
15963
15980
  baker ads meta pages`
@@ -15976,7 +15993,8 @@ Examples:
15976
15993
  writeAdsOutput(data, fmt);
15977
15994
  return;
15978
15995
  }
15979
- writeAdsJson({ ok: true, data });
15996
+ const hints = pageSelectionHints(data);
15997
+ writeJsonEnvelope(hints.length > 0 ? { ok: true, data, hints } : { ok: true, data });
15980
15998
  } catch (err) {
15981
15999
  handleMetaError(err);
15982
16000
  }