@koda-sl/baker-cli 0.306.7 → 0.306.8

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
@@ -22665,6 +22665,20 @@ var lookalikeSpecSchema = z30.object({
22665
22665
  ratio: z30.number().min(0.01).max(0.2).optional(),
22666
22666
  country: z30.string().length(2).optional()
22667
22667
  });
22668
+ function valuesOfKey(node, key) {
22669
+ if (Array.isArray(node)) return node.flatMap((entry) => valuesOfKey(entry, key));
22670
+ if (!node || typeof node !== "object") return [];
22671
+ const record = node;
22672
+ return [
22673
+ ...key in record ? [record[key]] : [],
22674
+ ...Object.values(record).flatMap((value) => valuesOfKey(value, key))
22675
+ ];
22676
+ }
22677
+ function mixedEventSourceTypes(rule) {
22678
+ const types = valuesOfKey(rule, "event_sources").flatMap((sources) => Array.isArray(sources) ? sources : []).map((source) => source?.type).filter((type) => typeof type === "string");
22679
+ const distinct = [...new Set(types)].sort();
22680
+ return distinct.length > 1 ? distinct : [];
22681
+ }
22668
22682
  var customAudienceCreateSchema = z30.object({
22669
22683
  name: z30.string().min(1).max(META_LIMITS.audience.nameMax),
22670
22684
  subtype: z30.enum(CUSTOM_AUDIENCE_SUBTYPES),
@@ -22681,6 +22695,21 @@ var customAudienceCreateSchema = z30.object({
22681
22695
  if ((p.subtype === "WEBSITE" || p.subtype === "ENGAGEMENT") && !p.rule) {
22682
22696
  ctx.addIssue({ code: "custom", path: ["rule"], message: `${p.subtype} audiences need a rule (use --file)` });
22683
22697
  }
22698
+ if (p.rule && p.retention_days !== void 0) {
22699
+ ctx.addIssue({
22700
+ code: "custom",
22701
+ path: ["retention_days"],
22702
+ message: "a rule carries its own window in retention_seconds, so drop retention_days \u2014 Meta takes it only on a customer-file audience, and sending both leaves the review showing a window the audience will not have"
22703
+ });
22704
+ }
22705
+ const mixed = mixedEventSourceTypes(p.rule);
22706
+ if (mixed.length > 0) {
22707
+ ctx.addIssue({
22708
+ code: "custom",
22709
+ path: ["rule"],
22710
+ message: `one audience covers one kind of source, but this rule mixes ${mixed.join(" and ")} \u2014 split it into one audience per source`
22711
+ });
22712
+ }
22684
22713
  });
22685
22714
  var customAudienceUpdateSchema = z30.object({
22686
22715
  name: z30.string().min(1).max(META_LIMITS.audience.nameMax).optional(),
@@ -23421,6 +23450,7 @@ var audiencesCreateCommand2 = defineCommand57({
23421
23450
  name: "create",
23422
23451
  description: `Stage a new custom audience shell. ${STAGED_NOTE2}
23423
23452
  LOOKALIKE/WEBSITE/ENGAGEMENT specifics go via --file (lookalike_spec / rule). Member-list upload is not staged in v1.
23453
+ A WEBSITE/ENGAGEMENT rule carries its own window in retention_seconds, so --retention-days is refused next to one, and one audience covers one kind of event source (a Page and an Instagram profile are two audiences).
23424
23454
  Example: baker ads meta audiences create --name "Site visitors 30d" --subtype WEBSITE --file rule.json`
23425
23455
  },
23426
23456
  args: {
@@ -23428,7 +23458,10 @@ Example: baker ads meta audiences create --name "Site visitors 30d" --subtype WE
23428
23458
  name: { type: "string", description: "Audience name" },
23429
23459
  subtype: { type: "string", description: "CUSTOM|WEBSITE|ENGAGEMENT|LOOKALIKE" },
23430
23460
  description: { type: "string", description: "Description" },
23431
- "retention-days": { type: "string", description: "Retention window in days" },
23461
+ "retention-days": {
23462
+ type: "string",
23463
+ description: "Retention window in days \u2014 customer-file audiences only; a rule carries its own retention_seconds"
23464
+ },
23432
23465
  file: { type: "string", description: "JSON file with lookalike_spec / rule / full payload" }
23433
23466
  },
23434
23467
  run: async ({ args }) => {