@adkit/cli 1.12.15 → 1.12.17

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 (2) hide show
  1. package/dist/cli.js +63 -23
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1815,10 +1815,11 @@ var ASSET_CREATE_FLAGS = ["type", "text", "sitelink", "header", "value", "descri
1815
1815
  var ASSET_LINK_FLAGS = ["type", "scope", "scope-id", "status"];
1816
1816
  var MEDIA_UPLOAD_FLAGS = ["file", "url", "base64", "adkit-media", "filename", "content-type", "name"];
1817
1817
  var CAMPAIGN_LIST_FLAGS = ["status", "limit", "offset"];
1818
- var CAMPAIGN_FLAGS2 = ["name", "status", "budget-daily", "campaign-type", "bid-strategy", "search-partners", "display-network", "tracking-url-suffix", "countries"];
1818
+ var CAMPAIGN_CREATE_FLAGS = ["name", "status", "budget-daily", "campaign-type", "bid-strategy", "search-partners", "display-network", "tracking-url-suffix", "countries"];
1819
+ var CAMPAIGN_UPDATE_FLAGS = ["name", "status", "budget-daily", "bid-strategy", "search-partners", "display-network", "tracking-url-suffix", "countries"];
1819
1820
  var AD_GROUP_LIST_FLAGS = ["campaign", "status", "limit", "offset"];
1820
1821
  var AD_GROUP_FLAGS = ["campaign", "name", "status", "cpc-bid"];
1821
- var AD_LIST_FLAGS = ["ad-group", "status", "limit", "offset"];
1822
+ var AD_LIST_FLAGS = ["ad-group", "status", "policy-status", "limit", "offset"];
1822
1823
  var AD_FLAGS2 = ["headline", "headline-1", "headline-2", "headline-3", "description", "description-1", "description-2", "callout", "sitelink", "final-url", "path", "ad-group", "status"];
1823
1824
  var KEYWORD_LIST_FLAGS = ["ad-group", "campaign", "status", "limit", "offset"];
1824
1825
  var KEYWORD_FLAGS = ["ad-group", "text", "match-type", "cpc-bid", "status"];
@@ -1860,16 +1861,23 @@ function resolveGoogleAdGroupId(body, flags) {
1860
1861
  function buildGoogleListQuery(flags, extra = {}) {
1861
1862
  const accountId = typeof flags.account === "string" ? flags.account : void 0;
1862
1863
  const status2 = typeof flags.status === "string" ? flags.status : void 0;
1864
+ const policyStatus = typeof flags["policy-status"] === "string" ? flags["policy-status"] : void 0;
1863
1865
  const limit = typeof flags.limit === "string" ? flags.limit : void 0;
1864
1866
  const offset = typeof flags.offset === "string" ? flags.offset : void 0;
1865
1867
  const raw = flags.raw === true ? "true" : void 0;
1866
- return queryString({ accountId, status: status2, limit, offset, raw, ...extra });
1868
+ return queryString({ accountId, status: status2, policyStatus, limit, offset, raw, ...extra });
1867
1869
  }
1868
1870
  function buildGoogleMutationQuery(flags, body, extra = {}) {
1869
1871
  const accountId = resolveGoogleAccountId(body, flags);
1870
1872
  const publish = flags.publish === true ? "true" : void 0;
1871
1873
  return queryString({ accountId, publish, ...extra });
1872
1874
  }
1875
+ function removeQueryOnlyBodyKeys(body, keys) {
1876
+ if (typeof body !== "object" || body === null || Array.isArray(body)) return body;
1877
+ const dropKeys = new Set(keys);
1878
+ const bodyEntries = Object.entries(body).filter(([key]) => !dropKeys.has(key));
1879
+ return Object.fromEntries(bodyEntries);
1880
+ }
1873
1881
  function buildGoogleAssetQuery(flags, extra = {}) {
1874
1882
  const accountId = typeof flags.account === "string" ? flags.account : void 0;
1875
1883
  const type = typeof flags.type === "string" ? flags.type : void 0;
@@ -1969,11 +1977,30 @@ function buildCampaignPayload2(flags) {
1969
1977
  if (flags["search-partners"] === true) payload.searchPartners = true;
1970
1978
  if (flags["display-network"] === true) payload.displayNetwork = true;
1971
1979
  if (typeof flags["tracking-url-suffix"] === "string") payload.trackingUrlSuffix = flags["tracking-url-suffix"];
1980
+ if (typeof flags.countries === "string") payload.countries = parseCampaignCountries(flags.countries);
1981
+ return payload;
1982
+ }
1983
+ function parseCampaignCountries(value) {
1984
+ const countryParts = value.split(",");
1985
+ const normalizedCountries = countryParts.map((country) => country.trim().toUpperCase());
1986
+ return normalizedCountries.filter(Boolean);
1987
+ }
1988
+ function buildCampaignUpdatePayloadFromFlags(flags) {
1989
+ const payload = {};
1990
+ if (typeof flags.name === "string") payload.name = flags.name;
1991
+ if (typeof flags.status === "string") payload.status = flags.status;
1992
+ if (typeof flags["budget-daily"] === "string") payload.budget = { daily: Number.parseFloat(flags["budget-daily"]) };
1993
+ if (typeof flags["bid-strategy"] === "string") payload.bidStrategy = flags["bid-strategy"];
1994
+ if (flags["search-partners"] === true) payload.searchPartners = true;
1995
+ if (flags["display-network"] === true) payload.displayNetwork = true;
1996
+ if (typeof flags["tracking-url-suffix"] === "string") payload.trackingUrlSuffix = flags["tracking-url-suffix"];
1972
1997
  if (typeof flags.countries === "string") {
1973
- payload.countries = flags.countries.split(",").map((country) => {
1974
- const normalizedCountry = country.trim();
1975
- return normalizedCountry.toUpperCase();
1976
- });
1998
+ const countries = parseCampaignCountries(flags.countries);
1999
+ payload.targeting = {
2000
+ geoLocations: {
2001
+ include: countries.map((country) => ({ type: "country", country }))
2002
+ }
2003
+ };
1977
2004
  }
1978
2005
  return payload;
1979
2006
  }
@@ -2283,7 +2310,7 @@ async function getCampaign2(client, args, flags) {
2283
2310
  return client.get(path3);
2284
2311
  }
2285
2312
  async function createCampaign2(client, _args, flags) {
2286
- validateFlags(flags, CAMPAIGN_FLAGS2, "manage google campaigns create");
2313
+ validateFlags(flags, CAMPAIGN_CREATE_FLAGS, "manage google campaigns create");
2287
2314
  if (typeof flags.data === "string") {
2288
2315
  const body2 = parseDataFlag(flags, "Check JSON syntax in --data");
2289
2316
  const qs2 = buildGoogleMutationQuery(flags, body2);
@@ -2299,15 +2326,17 @@ async function createCampaign2(client, _args, flags) {
2299
2326
  }
2300
2327
  async function updateCampaign2(client, args, flags) {
2301
2328
  const id = requireArg(args, 0, "campaign-id", "Run: adkit manage google campaigns update <campaign-id> --status paused");
2302
- validateFlags(flags, CAMPAIGN_FLAGS2, "manage google campaigns update");
2329
+ validateFlags(flags, CAMPAIGN_UPDATE_FLAGS, "manage google campaigns update");
2303
2330
  if (typeof flags.data === "string") {
2304
- const body = parseDataFlag(flags, "Check JSON syntax in --data");
2305
- const qs2 = buildGoogleMutationQuery(flags, body);
2331
+ const rawBody = parseDataFlag(flags, "Check JSON syntax in --data");
2332
+ const qs2 = buildGoogleMutationQuery(flags, rawBody);
2333
+ const body = removeQueryOnlyBodyKeys(rawBody, ["accountId"]);
2306
2334
  const path4 = `/manage/google/campaigns/${id}${qs2}`;
2307
2335
  return client.patch(path4, body);
2308
2336
  }
2309
- const payload = buildCampaignPayload2(flags);
2310
- const qs = buildGoogleMutationQuery(flags, payload);
2337
+ const rawPayload = buildCampaignUpdatePayloadFromFlags(flags);
2338
+ const qs = buildGoogleMutationQuery(flags, rawPayload);
2339
+ const payload = removeQueryOnlyBodyKeys(rawPayload, ["accountId"]);
2311
2340
  const path3 = `/manage/google/campaigns/${id}${qs}`;
2312
2341
  return client.patch(path3, payload);
2313
2342
  }
@@ -2457,19 +2486,21 @@ async function updateKeyword(client, args, flags) {
2457
2486
  const id = requireArg(args, 0, "keyword-id", "Run: adkit manage google keywords update <keyword-id> --status paused --ad-group 123456");
2458
2487
  validateFlags(flags, KEYWORD_UPDATE_FLAGS, "manage google keywords update");
2459
2488
  if (typeof flags.data === "string") {
2460
- const body = parseDataFlag(flags, "Check JSON syntax in --data");
2461
- const adGroupId2 = resolveGoogleAdGroupId(body, flags);
2489
+ const rawBody = parseDataFlag(flags, "Check JSON syntax in --data");
2490
+ const adGroupId2 = resolveGoogleAdGroupId(rawBody, flags);
2462
2491
  if (!adGroupId2) throw new CliError("MISSING_FLAG", "Missing required flag: `--ad-group`", "Provide --ad-group <id> or include adGroupId in --data");
2463
- const qs2 = buildGoogleMutationQuery(flags, body, { adGroupId: adGroupId2 });
2492
+ const qs2 = buildGoogleMutationQuery(flags, rawBody, { adGroupId: adGroupId2 });
2493
+ const body2 = removeQueryOnlyBodyKeys(rawBody, ["accountId", "adGroupId"]);
2464
2494
  const path4 = `/manage/google/keywords/${id}${qs2}`;
2465
- return client.patch(path4, body);
2495
+ return client.patch(path4, body2);
2466
2496
  }
2467
2497
  const payload = buildKeywordPayload(flags);
2468
2498
  const adGroupId = resolveGoogleAdGroupId(payload, flags);
2469
2499
  if (!adGroupId) throw new CliError("MISSING_FLAG", "Missing required flag: `--ad-group`", "Run: adkit manage google keywords update <keyword-id> --ad-group <ad-group-id> ...");
2470
2500
  const qs = buildGoogleMutationQuery(flags, payload, { adGroupId });
2501
+ const body = removeQueryOnlyBodyKeys(payload, ["accountId", "adGroupId"]);
2471
2502
  const path3 = `/manage/google/keywords/${id}${qs}`;
2472
- return client.patch(path3, payload);
2503
+ return client.patch(path3, body);
2473
2504
  }
2474
2505
  async function removeKeyword(client, args, flags) {
2475
2506
  validateFlags(flags, ["ad-group"], "manage google keywords remove");
@@ -2692,8 +2723,8 @@ var MEDIA_UPLOAD_FLAGS2 = ["file", "url", "base64", "adkit-media", "temporary-up
2692
2723
  var MEDIA_LIST_FLAGS = ["video-id", "material-id", "displayable", "width", "height", "ratio", "limit", "offset"];
2693
2724
  var CAMPAIGN_LIST_FLAGS2 = ["campaign-ids", "fields", "limit", "offset"];
2694
2725
  var PLATFORM_OVERRIDE_FLAG = "platform-overrides";
2695
- var CAMPAIGN_CREATE_FLAGS = ["name", "objective", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2696
- var CAMPAIGN_UPDATE_FLAGS = ["name", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2726
+ var CAMPAIGN_CREATE_FLAGS2 = ["name", "objective", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2727
+ var CAMPAIGN_UPDATE_FLAGS2 = ["name", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2697
2728
  var AD_GROUP_LIST_FLAGS2 = ["campaign-ids", "fields", "limit", "offset"];
2698
2729
  var AD_GROUP_CREATE_FLAGS = ["campaign", "name", "status", "budget-daily", "budget-lifetime", "billing-event", "bid-strategy", "optimization", "start-date", "end-date", "pacing", "bid-amount", "event-type", "pixel", "placement", PLATFORM_OVERRIDE_FLAG];
2699
2730
  var AD_GROUP_UPDATE_FLAGS = ["name", "status", "budget-daily", "budget-lifetime", "billing-event", "optimization", "start-date", "end-date", "pacing", "bid-amount", "event-type", "pixel", PLATFORM_OVERRIDE_FLAG];
@@ -2954,7 +2985,7 @@ async function getTikTokCampaign(client, args, flags) {
2954
2985
  return client.get(`/manage/tiktok/campaigns/${id}${buildTikTokListQuery(flags)}`);
2955
2986
  }
2956
2987
  async function createTikTokCampaign(client, _args, flags) {
2957
- validateFlags(flags, CAMPAIGN_CREATE_FLAGS, "manage tiktok campaigns create");
2988
+ validateFlags(flags, CAMPAIGN_CREATE_FLAGS2, "manage tiktok campaigns create");
2958
2989
  if (typeof flags.data === "string") {
2959
2990
  const body2 = parseDataFlag(flags, 'Use { "campaigns": [...] } for TikTok campaign create');
2960
2991
  return client.post(`/manage/tiktok/campaigns${buildTikTokMutationQuery(flags)}`, body2);
@@ -2963,7 +2994,7 @@ async function createTikTokCampaign(client, _args, flags) {
2963
2994
  return client.post(`/manage/tiktok/campaigns${buildTikTokMutationQuery(flags)}`, body);
2964
2995
  }
2965
2996
  async function updateTikTokCampaign(client, args, flags) {
2966
- validateFlags(flags, CAMPAIGN_UPDATE_FLAGS, "manage tiktok campaigns update");
2997
+ validateFlags(flags, CAMPAIGN_UPDATE_FLAGS2, "manage tiktok campaigns update");
2967
2998
  const id = requireArg(args, 0, "campaign-id", "Run: adkit manage tiktok campaigns update <campaign-id> --status paused");
2968
2999
  const body = typeof flags.data === "string" ? parseDataFlag(flags, "Use a flat TikTok campaign changes object") : buildTikTokCampaignPayload(flags, "update");
2969
3000
  return client.patch(`/manage/tiktok/campaigns/${id}${buildTikTokMutationQuery(flags)}`, body);
@@ -3668,6 +3699,7 @@ function toGoogleAdDisplayRow(ad) {
3668
3699
  ID: ad.platformId ?? "-",
3669
3700
  "AD GROUP": ad.adGroupId ?? "-",
3670
3701
  STATUS: ad.status ?? "-",
3702
+ POLICY: ad.policyStatus ?? "-",
3671
3703
  HEADLINES: formatGoogleAssetsForCli(ad.headlines, "headline"),
3672
3704
  DESCRIPTIONS: formatGoogleAssetsForCli(ad.descriptions, "description"),
3673
3705
  URLS: Array.isArray(ad.finalUrls) && ad.finalUrls.length > 0 ? ad.finalUrls.join(" | ") : "-"
@@ -3684,7 +3716,7 @@ function normalizeGoogleCliPath(path3) {
3684
3716
  return void 0;
3685
3717
  }
3686
3718
  function toGoogleAdDetailLines(ad) {
3687
- const metadataLines = [` Ad ID: ${String(ad.platformId ?? "-")}`, ` Ad Group: ${String(ad.adGroupId ?? "-")}`, ` Status: ${ad.status ?? "-"}`];
3719
+ const metadataLines = [` Ad ID: ${String(ad.platformId ?? "-")}`, ` Ad Group: ${String(ad.adGroupId ?? "-")}`, ` Status: ${ad.status ?? "-"}`, ` Policy: ${ad.policyStatus ?? "-"}`];
3688
3720
  const lines = ["", ...metadataLines];
3689
3721
  const headlines = formatGoogleAssetsForCli(ad.headlines, "headline");
3690
3722
  const descriptions = formatGoogleAssetsForCli(ad.descriptions, "description");
@@ -4631,6 +4663,7 @@ Flags (update):
4631
4663
  --status <s> enabled, paused
4632
4664
  --budget-daily <n> Daily budget in account currency
4633
4665
  --bid-strategy <s> Change bidding strategy
4666
+ --countries <codes> Replace included countries, e.g. US,CA
4634
4667
 
4635
4668
  Flags (list):
4636
4669
  --status <s> Filter by campaign status (default: enabled,paused; use all for every status)
@@ -4677,6 +4710,7 @@ Flags (update):
4677
4710
  --status <s> enabled, paused
4678
4711
  --budget-daily <n> Daily budget in account currency
4679
4712
  --bid-strategy <s> Change bidding strategy
4713
+ --countries <codes> Replace included countries, e.g. US,CA
4680
4714
  ${FLAG.account}
4681
4715
  ${FLAG.publish}
4682
4716
  ${FLAG.data}
@@ -4804,6 +4838,7 @@ Flags (create/update):
4804
4838
  Flags (list):
4805
4839
  --ad-group <id> Filter by Google ad group ID (platformId)
4806
4840
  --status <s> Filter by ad status (default: enabled,paused; use all for every status)
4841
+ --policy-status <s> Filter by policy status: approved, limited, disapproved, problem, pending_review, under_appeal
4807
4842
  --limit <n> Max results
4808
4843
  --offset <n> Pagination offset
4809
4844
 
@@ -4815,6 +4850,7 @@ Notes:
4815
4850
  Upload images first with google media upload, then use returned Google asset id/resourceName in media[].id.
4816
4851
  Display videos are not supported in v1.
4817
4852
  Display support is in beta \u2014 some features may not be available yet. Report issues with: adkit feedback "description" --type bug
4853
+ list/get return policyStatus when Google returns policy review data. policyIssues appears only for blocked/limited/review ads or when filtering by --policy-status.
4818
4854
  Ad-level callout/sitelink input is an AdKit convenience layer. On publish, AdKit creates or reuses reusable Google assets, then attaches them at ad-group scope.
4819
4855
  That means sibling ads in the same ad group may also use those assets. Use google assets if you need explicit scope control or richer sitelink payloads.
4820
4856
 
@@ -4856,6 +4892,7 @@ ${FLAG.data}
4856
4892
  Flags (list):
4857
4893
  --ad-group <id> Filter by Google ad group ID (platformId)
4858
4894
  --status <s> Filter by ad status (default: enabled,paused; use all for every status)
4895
+ --policy-status <s> Filter by policy status: approved, limited, disapproved, problem, pending_review, under_appeal
4859
4896
  --limit <n> Max results
4860
4897
  --offset <n> Pagination offset
4861
4898
 
@@ -4868,6 +4905,7 @@ Notes:
4868
4905
  Media refs are existing Google image asset IDs/resourceNames returned by google media upload.
4869
4906
  Display videos are not supported in v1.
4870
4907
  Display support is in beta \u2014 some features may not be available yet. Report issues with: adkit feedback "description" --type bug
4908
+ list/get return policyStatus when Google returns policy review data. policyIssues appears only for blocked/limited/review ads or when filtering by --policy-status.
4871
4909
  Ad-level callout/sitelink input is stored on the ad draft, but Google serves these assets at ad-group scope. AdKit resolves, de-duplicates, and attaches them there on publish.
4872
4910
  Use google assets for explicit scope control, reusable libraries, account/campaign-level associations, or richer sitelink payloads via --data.
4873
4911
  Path format: pass one string like "crm" or "crm/demo". AdKit normalizes extra slashes, and each segment must stay within Google's 15-character limit.
@@ -4912,6 +4950,7 @@ Flags (list):
4912
4950
 
4913
4951
  Note:
4914
4952
  list returns keyword configuration (bids, match type, status) only.
4953
+ update only changes mutable fields: status and cpc bid.
4915
4954
  Google Ads cannot edit keyword text or match type; pause or remove the old keyword, then create a new one.
4916
4955
  For spend/clicks/conversions per keyword: adkit manage google results keywords
4917
4956
 
@@ -4953,6 +4992,7 @@ Flags (list):
4953
4992
 
4954
4993
  Note:
4955
4994
  list returns keyword configuration (bids, match type, status) only.
4995
+ update only changes mutable fields: status and cpc bid. Raw --data for update must not include text or matchType.
4956
4996
  Google Ads cannot edit keyword text or match type; pause or remove the old keyword, then create a new one.
4957
4997
  For spend/clicks/conversions per keyword: adkit manage google results keywords
4958
4998
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adkit/cli",
3
- "version": "1.12.15",
3
+ "version": "1.12.17",
4
4
  "description": "The Ads CLI for AI agents — manage Meta & Google ad campaigns, browse the ad library, and generate creatives from your terminal.",
5
5
  "keywords": [
6
6
  "ads cli",