@adkit/cli 1.12.16 → 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 +54 -20
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1815,7 +1815,8 @@ 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
1822
  var AD_LIST_FLAGS = ["ad-group", "status", "policy-status", "limit", "offset"];
@@ -1871,6 +1872,12 @@ function buildGoogleMutationQuery(flags, body, extra = {}) {
1871
1872
  const publish = flags.publish === true ? "true" : void 0;
1872
1873
  return queryString({ accountId, publish, ...extra });
1873
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
+ }
1874
1881
  function buildGoogleAssetQuery(flags, extra = {}) {
1875
1882
  const accountId = typeof flags.account === "string" ? flags.account : void 0;
1876
1883
  const type = typeof flags.type === "string" ? flags.type : void 0;
@@ -1970,11 +1977,30 @@ function buildCampaignPayload2(flags) {
1970
1977
  if (flags["search-partners"] === true) payload.searchPartners = true;
1971
1978
  if (flags["display-network"] === true) payload.displayNetwork = true;
1972
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"];
1973
1997
  if (typeof flags.countries === "string") {
1974
- payload.countries = flags.countries.split(",").map((country) => {
1975
- const normalizedCountry = country.trim();
1976
- return normalizedCountry.toUpperCase();
1977
- });
1998
+ const countries = parseCampaignCountries(flags.countries);
1999
+ payload.targeting = {
2000
+ geoLocations: {
2001
+ include: countries.map((country) => ({ type: "country", country }))
2002
+ }
2003
+ };
1978
2004
  }
1979
2005
  return payload;
1980
2006
  }
@@ -2284,7 +2310,7 @@ async function getCampaign2(client, args, flags) {
2284
2310
  return client.get(path3);
2285
2311
  }
2286
2312
  async function createCampaign2(client, _args, flags) {
2287
- validateFlags(flags, CAMPAIGN_FLAGS2, "manage google campaigns create");
2313
+ validateFlags(flags, CAMPAIGN_CREATE_FLAGS, "manage google campaigns create");
2288
2314
  if (typeof flags.data === "string") {
2289
2315
  const body2 = parseDataFlag(flags, "Check JSON syntax in --data");
2290
2316
  const qs2 = buildGoogleMutationQuery(flags, body2);
@@ -2300,15 +2326,17 @@ async function createCampaign2(client, _args, flags) {
2300
2326
  }
2301
2327
  async function updateCampaign2(client, args, flags) {
2302
2328
  const id = requireArg(args, 0, "campaign-id", "Run: adkit manage google campaigns update <campaign-id> --status paused");
2303
- validateFlags(flags, CAMPAIGN_FLAGS2, "manage google campaigns update");
2329
+ validateFlags(flags, CAMPAIGN_UPDATE_FLAGS, "manage google campaigns update");
2304
2330
  if (typeof flags.data === "string") {
2305
- const body = parseDataFlag(flags, "Check JSON syntax in --data");
2306
- 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"]);
2307
2334
  const path4 = `/manage/google/campaigns/${id}${qs2}`;
2308
2335
  return client.patch(path4, body);
2309
2336
  }
2310
- const payload = buildCampaignPayload2(flags);
2311
- const qs = buildGoogleMutationQuery(flags, payload);
2337
+ const rawPayload = buildCampaignUpdatePayloadFromFlags(flags);
2338
+ const qs = buildGoogleMutationQuery(flags, rawPayload);
2339
+ const payload = removeQueryOnlyBodyKeys(rawPayload, ["accountId"]);
2312
2340
  const path3 = `/manage/google/campaigns/${id}${qs}`;
2313
2341
  return client.patch(path3, payload);
2314
2342
  }
@@ -2458,19 +2486,21 @@ async function updateKeyword(client, args, flags) {
2458
2486
  const id = requireArg(args, 0, "keyword-id", "Run: adkit manage google keywords update <keyword-id> --status paused --ad-group 123456");
2459
2487
  validateFlags(flags, KEYWORD_UPDATE_FLAGS, "manage google keywords update");
2460
2488
  if (typeof flags.data === "string") {
2461
- const body = parseDataFlag(flags, "Check JSON syntax in --data");
2462
- const adGroupId2 = resolveGoogleAdGroupId(body, flags);
2489
+ const rawBody = parseDataFlag(flags, "Check JSON syntax in --data");
2490
+ const adGroupId2 = resolveGoogleAdGroupId(rawBody, flags);
2463
2491
  if (!adGroupId2) throw new CliError("MISSING_FLAG", "Missing required flag: `--ad-group`", "Provide --ad-group <id> or include adGroupId in --data");
2464
- const qs2 = buildGoogleMutationQuery(flags, body, { adGroupId: adGroupId2 });
2492
+ const qs2 = buildGoogleMutationQuery(flags, rawBody, { adGroupId: adGroupId2 });
2493
+ const body2 = removeQueryOnlyBodyKeys(rawBody, ["accountId", "adGroupId"]);
2465
2494
  const path4 = `/manage/google/keywords/${id}${qs2}`;
2466
- return client.patch(path4, body);
2495
+ return client.patch(path4, body2);
2467
2496
  }
2468
2497
  const payload = buildKeywordPayload(flags);
2469
2498
  const adGroupId = resolveGoogleAdGroupId(payload, flags);
2470
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> ...");
2471
2500
  const qs = buildGoogleMutationQuery(flags, payload, { adGroupId });
2501
+ const body = removeQueryOnlyBodyKeys(payload, ["accountId", "adGroupId"]);
2472
2502
  const path3 = `/manage/google/keywords/${id}${qs}`;
2473
- return client.patch(path3, payload);
2503
+ return client.patch(path3, body);
2474
2504
  }
2475
2505
  async function removeKeyword(client, args, flags) {
2476
2506
  validateFlags(flags, ["ad-group"], "manage google keywords remove");
@@ -2693,8 +2723,8 @@ var MEDIA_UPLOAD_FLAGS2 = ["file", "url", "base64", "adkit-media", "temporary-up
2693
2723
  var MEDIA_LIST_FLAGS = ["video-id", "material-id", "displayable", "width", "height", "ratio", "limit", "offset"];
2694
2724
  var CAMPAIGN_LIST_FLAGS2 = ["campaign-ids", "fields", "limit", "offset"];
2695
2725
  var PLATFORM_OVERRIDE_FLAG = "platform-overrides";
2696
- var CAMPAIGN_CREATE_FLAGS = ["name", "objective", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2697
- 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];
2698
2728
  var AD_GROUP_LIST_FLAGS2 = ["campaign-ids", "fields", "limit", "offset"];
2699
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];
2700
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];
@@ -2955,7 +2985,7 @@ async function getTikTokCampaign(client, args, flags) {
2955
2985
  return client.get(`/manage/tiktok/campaigns/${id}${buildTikTokListQuery(flags)}`);
2956
2986
  }
2957
2987
  async function createTikTokCampaign(client, _args, flags) {
2958
- validateFlags(flags, CAMPAIGN_CREATE_FLAGS, "manage tiktok campaigns create");
2988
+ validateFlags(flags, CAMPAIGN_CREATE_FLAGS2, "manage tiktok campaigns create");
2959
2989
  if (typeof flags.data === "string") {
2960
2990
  const body2 = parseDataFlag(flags, 'Use { "campaigns": [...] } for TikTok campaign create');
2961
2991
  return client.post(`/manage/tiktok/campaigns${buildTikTokMutationQuery(flags)}`, body2);
@@ -2964,7 +2994,7 @@ async function createTikTokCampaign(client, _args, flags) {
2964
2994
  return client.post(`/manage/tiktok/campaigns${buildTikTokMutationQuery(flags)}`, body);
2965
2995
  }
2966
2996
  async function updateTikTokCampaign(client, args, flags) {
2967
- validateFlags(flags, CAMPAIGN_UPDATE_FLAGS, "manage tiktok campaigns update");
2997
+ validateFlags(flags, CAMPAIGN_UPDATE_FLAGS2, "manage tiktok campaigns update");
2968
2998
  const id = requireArg(args, 0, "campaign-id", "Run: adkit manage tiktok campaigns update <campaign-id> --status paused");
2969
2999
  const body = typeof flags.data === "string" ? parseDataFlag(flags, "Use a flat TikTok campaign changes object") : buildTikTokCampaignPayload(flags, "update");
2970
3000
  return client.patch(`/manage/tiktok/campaigns/${id}${buildTikTokMutationQuery(flags)}`, body);
@@ -4633,6 +4663,7 @@ Flags (update):
4633
4663
  --status <s> enabled, paused
4634
4664
  --budget-daily <n> Daily budget in account currency
4635
4665
  --bid-strategy <s> Change bidding strategy
4666
+ --countries <codes> Replace included countries, e.g. US,CA
4636
4667
 
4637
4668
  Flags (list):
4638
4669
  --status <s> Filter by campaign status (default: enabled,paused; use all for every status)
@@ -4679,6 +4710,7 @@ Flags (update):
4679
4710
  --status <s> enabled, paused
4680
4711
  --budget-daily <n> Daily budget in account currency
4681
4712
  --bid-strategy <s> Change bidding strategy
4713
+ --countries <codes> Replace included countries, e.g. US,CA
4682
4714
  ${FLAG.account}
4683
4715
  ${FLAG.publish}
4684
4716
  ${FLAG.data}
@@ -4918,6 +4950,7 @@ Flags (list):
4918
4950
 
4919
4951
  Note:
4920
4952
  list returns keyword configuration (bids, match type, status) only.
4953
+ update only changes mutable fields: status and cpc bid.
4921
4954
  Google Ads cannot edit keyword text or match type; pause or remove the old keyword, then create a new one.
4922
4955
  For spend/clicks/conversions per keyword: adkit manage google results keywords
4923
4956
 
@@ -4959,6 +4992,7 @@ Flags (list):
4959
4992
 
4960
4993
  Note:
4961
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.
4962
4996
  Google Ads cannot edit keyword text or match type; pause or remove the old keyword, then create a new one.
4963
4997
  For spend/clicks/conversions per keyword: adkit manage google results keywords
4964
4998
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adkit/cli",
3
- "version": "1.12.16",
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",