@koda-sl/baker-cli 0.352.0-dev.0d2112628 → 0.352.0-dev.fabc18041

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
@@ -11035,6 +11035,41 @@ function adCopyHints(payload) {
11035
11035
  return tells.slice(0, MAX_HINTS).map(hintFor);
11036
11036
  }
11037
11037
 
11038
+ // src/commands/ads/google/copy-list-usage.ts
11039
+ var AD_COPY_LIST_USAGE = `repeat the flag once per item, or pass one comma-separated list and wrap an item that contains a comma in double quotes: '"Fast, free quotes",Book today'. A flag given once is read as a list, so a lone item with a comma needs its double quotes too: '"Fast, free quotes"'`;
11040
+ var COPY_LIST_FLAG = {
11041
+ headlines: "--headlines",
11042
+ descriptions: "--descriptions",
11043
+ longHeadlines: "--long-headlines"
11044
+ };
11045
+ function valueAt(root, path48) {
11046
+ let node = root;
11047
+ for (const key of path48) {
11048
+ if (node === null || typeof node !== "object") return void 0;
11049
+ node = node[key];
11050
+ }
11051
+ return node;
11052
+ }
11053
+ function countRefusal(op, issue) {
11054
+ if (issue.code !== "too_big" && issue.code !== "too_small" || issue.origin !== "array") return void 0;
11055
+ const flag = COPY_LIST_FLAG[String(issue.path.at(-1))];
11056
+ if (!flag) return void 0;
11057
+ const value = valueAt(op, issue.path);
11058
+ const count2 = Array.isArray(value) ? value.length : void 0;
11059
+ return issue.code === "too_big" ? { flag, count: count2, bound: `at most ${issue.maximum}`, tooMany: true } : { flag, count: count2, bound: `at least ${issue.minimum}`, tooMany: false };
11060
+ }
11061
+ function copyListCountFix(op, issues) {
11062
+ const refusals = issues.map((issue) => countRefusal(op, issue));
11063
+ if (refusals.length === 0 || refusals.some((refusal) => refusal === void 0)) return void 0;
11064
+ const counted = refusals.filter((refusal) => refusal !== void 0);
11065
+ const limits = counted.map(({ flag, count: count2, bound }) => `${flag} has ${count2 ?? "the wrong number of"} items; this ad takes ${bound}.`).join(" ");
11066
+ const commaCause = counted.some((refusal) => refusal.tooMany) ? ` If you meant fewer items, the copy was cut at its commas: a flag given once is read as a comma-separated list, so an item with a comma in it ("Fast, free quotes", a decimal like "4,5/5") becomes two. To keep a comma, ${AD_COPY_LIST_USAGE} \u2014 or put the content in --file as JSON.` : "";
11067
+ return {
11068
+ action: "fix_copy_list_count",
11069
+ explanation: `${limits}${commaCause} ${commaCause ? "Otherwise add" : "Add"} or drop items to fit the limit, then stage again; the field names are right.`
11070
+ };
11071
+ }
11072
+
11038
11073
  // src/commands/ads/google/draft-status.ts
11039
11074
  var OPERATION_LABELS = {
11040
11075
  create: "Creating",
@@ -11355,7 +11390,7 @@ async function stageGoogleOp(raw, hints2) {
11355
11390
  code: "VALIDATION_ERROR",
11356
11391
  message: fields.map((f) => f.path ? `${f.path}: ${f.message}` : f.message).join("; "),
11357
11392
  fields,
11358
- fix: capabilityFix("google-ads")
11393
+ fix: copyListCountFix(raw, preflight.error.issues) ?? capabilityFix("google-ads")
11359
11394
  }
11360
11395
  });
11361
11396
  process.exit(1);
@@ -11391,7 +11426,7 @@ async function stageGoogleOps(rawOps, hints2) {
11391
11426
  code: "VALIDATION_ERROR",
11392
11427
  message: fields.map((f) => `${f.path}: ${f.message}`).join("; "),
11393
11428
  fields,
11394
- fix: capabilityFix("google-ads")
11429
+ fix: copyListCountFix(raw, preflight.error.issues) ?? capabilityFix("google-ads")
11395
11430
  }
11396
11431
  });
11397
11432
  process.exit(1);
@@ -16798,7 +16833,6 @@ import { defineCommand as defineCommand31 } from "citty";
16798
16833
 
16799
16834
  // src/commands/ads/google/ad-copy-flags.ts
16800
16835
  var AD_COPY_LIST_FLAGS = ["headlines", "descriptions", "long-headlines"];
16801
- var AD_COPY_LIST_USAGE = `repeat the flag once per item, or pass one comma-separated list and wrap an item that contains a comma in double quotes: '"Fast, free quotes",Book today'. A flag given once is read as a list, so a lone item with a comma needs its double quotes too: '"Fast, free quotes"'`;
16802
16836
  function skipBlanks(value, at) {
16803
16837
  let i = at;
16804
16838
  while (value[i] === " " || value[i] === " ") i++;