@koda-sl/baker-cli 0.339.0 → 0.340.0

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
@@ -1904,6 +1904,32 @@ function lookbackDaysFor(sourcePlatform) {
1904
1904
  }
1905
1905
  return sourcePlatform === "EVENT_PAGES" ? EVENT_LOOKBACK_DAYS : ENGAGEMENT_LOOKBACK_DAYS;
1906
1906
  }
1907
+ var ENGAGEMENT_TRIGGERS_BY_SOURCE_TYPE = {
1908
+ VIDEO_ADS: ["FIRST_QUARTILE", "MIDPOINT", "THIRD_QUARTILE", "FULL_COMPLETE"],
1909
+ LEAD_GEN_FORMS: ["VIEW_FORM", "LEAD_FORM_SUBMIT"],
1910
+ ORGANIZATION_PAGES: ["VIEW", "CTA_CLICK"],
1911
+ SINGLE_IMAGE_ADS: ["ENGAGEMENT", "CLICK"],
1912
+ DOCUMENT_ADS: ["ENGAGEMENT", "CLICK", "DOWNLOAD_CLICK"],
1913
+ CONVERSATION_ADS: ["OPEN", "ANY_CTA_CLICK"],
1914
+ EVENT_PAGES: [
1915
+ "RSVPED",
1916
+ "VIDEO_VIEWED",
1917
+ "FIRST_QUARTILE",
1918
+ "MIDPOINT",
1919
+ "THIRD_QUARTILE",
1920
+ "FULL_COMPLETE",
1921
+ "ENGAGEMENT",
1922
+ "CLICK"
1923
+ ],
1924
+ WEBSITE: ["VISIT"]
1925
+ };
1926
+ var ENGAGEMENT_SOURCE_URN_BY_SOURCE_TYPE = {
1927
+ VIDEO_ADS: "urn:li:sponsoredCampaign",
1928
+ SINGLE_IMAGE_ADS: "urn:li:sponsoredCampaign",
1929
+ DOCUMENT_ADS: "urn:li:sponsoredCampaign",
1930
+ CONVERSATION_ADS: "urn:li:sponsoredCampaign",
1931
+ ORGANIZATION_PAGES: "urn:li:organization"
1932
+ };
1907
1933
  var ENGAGEMENT_TRIGGER_URN = /^urn:li:dmpEngagementTrigger:\(urn:li:dmpEngagementSourceType:([A-Z_]+),([A-Z_]+)\)$/;
1908
1934
  var RETARGETING_EXAMPLE = '{"sourcePlatform":"VIDEO_ADS","type":"USER","engagementRules":[{"engagementSource":"urn:li:sponsoredCampaign:123","engagementTrigger":"urn:li:dmpEngagementTrigger:(urn:li:dmpEngagementSourceType:VIDEO_ADS,FIRST_QUARTILE)","timeFrame":{"timeSpan":{"duration":90,"unit":"DAY"}}}]}';
1909
1935
  var engagementRuleSchema = z3.object({
@@ -1917,6 +1943,22 @@ var engagementRuleSchema = z3.object({
1917
1943
  })
1918
1944
  }).passthrough();
1919
1945
  var engagementRulesSchema = z3.array(engagementRuleSchema).min(1);
1946
+ function ruleProblems(rule, expectedSource) {
1947
+ const [, triggerSource = "", trigger = ""] = ENGAGEMENT_TRIGGER_URN.exec(rule.engagementTrigger) ?? [];
1948
+ if (expectedSource !== void 0 && triggerSource !== expectedSource) {
1949
+ return [`engagementTrigger ${rule.engagementTrigger} is a ${triggerSource} trigger, not ${expectedSource}`];
1950
+ }
1951
+ const problems = [];
1952
+ const offered = ENGAGEMENT_TRIGGERS_BY_SOURCE_TYPE[triggerSource];
1953
+ if (offered && !offered.includes(trigger)) {
1954
+ problems.push(`${triggerSource} has no ${trigger} trigger \u2014 use ${offered.join(", ")}`);
1955
+ }
1956
+ const sourceUrn = ENGAGEMENT_SOURCE_URN_BY_SOURCE_TYPE[triggerSource];
1957
+ if (sourceUrn && !rule.engagementSource.startsWith(`${sourceUrn}:`)) {
1958
+ problems.push(`a ${triggerSource} rule collects from a ${sourceUrn}:\u2026, not ${rule.engagementSource}`);
1959
+ }
1960
+ return problems;
1961
+ }
1920
1962
  function retargetingConfigProblems(raw) {
1921
1963
  const problems = [];
1922
1964
  const sourcePlatform = typeof raw.sourcePlatform === "string" ? raw.sourcePlatform.trim() : "";
@@ -1937,12 +1979,7 @@ function retargetingConfigProblems(raw) {
1937
1979
  const allowed = lookbackDaysFor(sourcePlatform);
1938
1980
  const expectedTriggerSource = TRIGGER_SOURCE_TYPE_BY_PLATFORM[sourcePlatform] ?? sourcePlatform;
1939
1981
  for (const rule of rules.data) {
1940
- const triggerSource = ENGAGEMENT_TRIGGER_URN.exec(rule.engagementTrigger)?.[1];
1941
- if (sourcePlatform && triggerSource !== expectedTriggerSource) {
1942
- problems.push(
1943
- `engagementTrigger ${rule.engagementTrigger} is a ${triggerSource} trigger, not ${expectedTriggerSource}`
1944
- );
1945
- }
1982
+ problems.push(...ruleProblems(rule, sourcePlatform ? expectedTriggerSource : void 0));
1946
1983
  const days = rule.timeFrame.timeSpan.duration;
1947
1984
  if (!allowed.includes(days)) {
1948
1985
  problems.push(`lookback ${days} days is not offered for ${sourcePlatform} \u2014 use ${allowed.join(", ")}`);