@adkit/cli 1.12.16 → 1.12.18

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 +100 -21
  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"];
@@ -1832,6 +1833,7 @@ var SEARCH_TERMS_FLAGS = ["campaign", "ad-group", "keyword", "keyword-match-type
1832
1833
  var PLACEMENT_REPORT_FLAGS = ["campaign", "ad-group", "period", "from", "to", "sort", "limit", "raw"];
1833
1834
  var GOOGLE_RESULTS_FLAGS = ["campaign", "ad-group", "period", "from", "to", "sort", "limit", "status", "breakdown", "fields", "raw"];
1834
1835
  var GOOGLE_KEYWORD_RESULTS_FLAGS = ["campaign", "ad-group", "period", "from", "to", "sort", "limit", "status", "fields", "raw"];
1836
+ var CHANGE_HISTORY_FLAGS = ["account", "period", "from", "to", "limit"];
1835
1837
  var KEYWORD_RESEARCH_FLAGS = ["url", "location", "language", "limit", "min-volume"];
1836
1838
  var TARGETING_RESEARCH_FLAGS = ["limit"];
1837
1839
  function generateCampaignName2() {
@@ -1871,6 +1873,12 @@ function buildGoogleMutationQuery(flags, body, extra = {}) {
1871
1873
  const publish = flags.publish === true ? "true" : void 0;
1872
1874
  return queryString({ accountId, publish, ...extra });
1873
1875
  }
1876
+ function removeQueryOnlyBodyKeys(body, keys) {
1877
+ if (typeof body !== "object" || body === null || Array.isArray(body)) return body;
1878
+ const dropKeys = new Set(keys);
1879
+ const bodyEntries = Object.entries(body).filter(([key]) => !dropKeys.has(key));
1880
+ return Object.fromEntries(bodyEntries);
1881
+ }
1874
1882
  function buildGoogleAssetQuery(flags, extra = {}) {
1875
1883
  const accountId = typeof flags.account === "string" ? flags.account : void 0;
1876
1884
  const type = typeof flags.type === "string" ? flags.type : void 0;
@@ -1970,11 +1978,30 @@ function buildCampaignPayload2(flags) {
1970
1978
  if (flags["search-partners"] === true) payload.searchPartners = true;
1971
1979
  if (flags["display-network"] === true) payload.displayNetwork = true;
1972
1980
  if (typeof flags["tracking-url-suffix"] === "string") payload.trackingUrlSuffix = flags["tracking-url-suffix"];
1981
+ if (typeof flags.countries === "string") payload.countries = parseCampaignCountries(flags.countries);
1982
+ return payload;
1983
+ }
1984
+ function parseCampaignCountries(value) {
1985
+ const countryParts = value.split(",");
1986
+ const normalizedCountries = countryParts.map((country) => country.trim().toUpperCase());
1987
+ return normalizedCountries.filter(Boolean);
1988
+ }
1989
+ function buildCampaignUpdatePayloadFromFlags(flags) {
1990
+ const payload = {};
1991
+ if (typeof flags.name === "string") payload.name = flags.name;
1992
+ if (typeof flags.status === "string") payload.status = flags.status;
1993
+ if (typeof flags["budget-daily"] === "string") payload.budget = { daily: Number.parseFloat(flags["budget-daily"]) };
1994
+ if (typeof flags["bid-strategy"] === "string") payload.bidStrategy = flags["bid-strategy"];
1995
+ if (flags["search-partners"] === true) payload.searchPartners = true;
1996
+ if (flags["display-network"] === true) payload.displayNetwork = true;
1997
+ if (typeof flags["tracking-url-suffix"] === "string") payload.trackingUrlSuffix = flags["tracking-url-suffix"];
1973
1998
  if (typeof flags.countries === "string") {
1974
- payload.countries = flags.countries.split(",").map((country) => {
1975
- const normalizedCountry = country.trim();
1976
- return normalizedCountry.toUpperCase();
1977
- });
1999
+ const countries = parseCampaignCountries(flags.countries);
2000
+ payload.targeting = {
2001
+ geoLocations: {
2002
+ include: countries.map((country) => ({ type: "country", country }))
2003
+ }
2004
+ };
1978
2005
  }
1979
2006
  return payload;
1980
2007
  }
@@ -2284,7 +2311,7 @@ async function getCampaign2(client, args, flags) {
2284
2311
  return client.get(path3);
2285
2312
  }
2286
2313
  async function createCampaign2(client, _args, flags) {
2287
- validateFlags(flags, CAMPAIGN_FLAGS2, "manage google campaigns create");
2314
+ validateFlags(flags, CAMPAIGN_CREATE_FLAGS, "manage google campaigns create");
2288
2315
  if (typeof flags.data === "string") {
2289
2316
  const body2 = parseDataFlag(flags, "Check JSON syntax in --data");
2290
2317
  const qs2 = buildGoogleMutationQuery(flags, body2);
@@ -2300,15 +2327,17 @@ async function createCampaign2(client, _args, flags) {
2300
2327
  }
2301
2328
  async function updateCampaign2(client, args, flags) {
2302
2329
  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");
2330
+ validateFlags(flags, CAMPAIGN_UPDATE_FLAGS, "manage google campaigns update");
2304
2331
  if (typeof flags.data === "string") {
2305
- const body = parseDataFlag(flags, "Check JSON syntax in --data");
2306
- const qs2 = buildGoogleMutationQuery(flags, body);
2332
+ const rawBody = parseDataFlag(flags, "Check JSON syntax in --data");
2333
+ const qs2 = buildGoogleMutationQuery(flags, rawBody);
2334
+ const body = removeQueryOnlyBodyKeys(rawBody, ["accountId"]);
2307
2335
  const path4 = `/manage/google/campaigns/${id}${qs2}`;
2308
2336
  return client.patch(path4, body);
2309
2337
  }
2310
- const payload = buildCampaignPayload2(flags);
2311
- const qs = buildGoogleMutationQuery(flags, payload);
2338
+ const rawPayload = buildCampaignUpdatePayloadFromFlags(flags);
2339
+ const qs = buildGoogleMutationQuery(flags, rawPayload);
2340
+ const payload = removeQueryOnlyBodyKeys(rawPayload, ["accountId"]);
2312
2341
  const path3 = `/manage/google/campaigns/${id}${qs}`;
2313
2342
  return client.patch(path3, payload);
2314
2343
  }
@@ -2458,19 +2487,21 @@ async function updateKeyword(client, args, flags) {
2458
2487
  const id = requireArg(args, 0, "keyword-id", "Run: adkit manage google keywords update <keyword-id> --status paused --ad-group 123456");
2459
2488
  validateFlags(flags, KEYWORD_UPDATE_FLAGS, "manage google keywords update");
2460
2489
  if (typeof flags.data === "string") {
2461
- const body = parseDataFlag(flags, "Check JSON syntax in --data");
2462
- const adGroupId2 = resolveGoogleAdGroupId(body, flags);
2490
+ const rawBody = parseDataFlag(flags, "Check JSON syntax in --data");
2491
+ const adGroupId2 = resolveGoogleAdGroupId(rawBody, flags);
2463
2492
  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 });
2493
+ const qs2 = buildGoogleMutationQuery(flags, rawBody, { adGroupId: adGroupId2 });
2494
+ const body2 = removeQueryOnlyBodyKeys(rawBody, ["accountId", "adGroupId"]);
2465
2495
  const path4 = `/manage/google/keywords/${id}${qs2}`;
2466
- return client.patch(path4, body);
2496
+ return client.patch(path4, body2);
2467
2497
  }
2468
2498
  const payload = buildKeywordPayload(flags);
2469
2499
  const adGroupId = resolveGoogleAdGroupId(payload, flags);
2470
2500
  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
2501
  const qs = buildGoogleMutationQuery(flags, payload, { adGroupId });
2502
+ const body = removeQueryOnlyBodyKeys(payload, ["accountId", "adGroupId"]);
2472
2503
  const path3 = `/manage/google/keywords/${id}${qs}`;
2473
- return client.patch(path3, payload);
2504
+ return client.patch(path3, body);
2474
2505
  }
2475
2506
  async function removeKeyword(client, args, flags) {
2476
2507
  validateFlags(flags, ["ad-group"], "manage google keywords remove");
@@ -2634,6 +2665,15 @@ async function listGooglePlacements(client, _args, flags) {
2634
2665
  const qs = buildPlacementReportQuery(flags);
2635
2666
  return client.get(`/manage/google/results/placements${qs}`);
2636
2667
  }
2668
+ async function listGoogleChangeHistory(client, _args, flags) {
2669
+ validateFlags(flags, CHANGE_HISTORY_FLAGS, "manage google change-history list");
2670
+ const period = typeof flags.period === "string" ? flags.period : void 0;
2671
+ const from = typeof flags.from === "string" ? flags.from : void 0;
2672
+ const to = typeof flags.to === "string" ? flags.to : void 0;
2673
+ const qs = buildGoogleListQuery(flags, { period, from, to });
2674
+ const path3 = `/manage/google/change-history${qs}`;
2675
+ return client.get(path3);
2676
+ }
2637
2677
  async function listGoogleKeywordResults(client, _args, flags) {
2638
2678
  validateFlags(flags, GOOGLE_KEYWORD_RESULTS_FLAGS, "manage google results keywords");
2639
2679
  const accountId = typeof flags.account === "string" ? flags.account : void 0;
@@ -2693,8 +2733,8 @@ var MEDIA_UPLOAD_FLAGS2 = ["file", "url", "base64", "adkit-media", "temporary-up
2693
2733
  var MEDIA_LIST_FLAGS = ["video-id", "material-id", "displayable", "width", "height", "ratio", "limit", "offset"];
2694
2734
  var CAMPAIGN_LIST_FLAGS2 = ["campaign-ids", "fields", "limit", "offset"];
2695
2735
  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];
2736
+ var CAMPAIGN_CREATE_FLAGS2 = ["name", "objective", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2737
+ var CAMPAIGN_UPDATE_FLAGS2 = ["name", "status", "budget-daily", "budget-lifetime", PLATFORM_OVERRIDE_FLAG];
2698
2738
  var AD_GROUP_LIST_FLAGS2 = ["campaign-ids", "fields", "limit", "offset"];
2699
2739
  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
2740
  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 +2995,7 @@ async function getTikTokCampaign(client, args, flags) {
2955
2995
  return client.get(`/manage/tiktok/campaigns/${id}${buildTikTokListQuery(flags)}`);
2956
2996
  }
2957
2997
  async function createTikTokCampaign(client, _args, flags) {
2958
- validateFlags(flags, CAMPAIGN_CREATE_FLAGS, "manage tiktok campaigns create");
2998
+ validateFlags(flags, CAMPAIGN_CREATE_FLAGS2, "manage tiktok campaigns create");
2959
2999
  if (typeof flags.data === "string") {
2960
3000
  const body2 = parseDataFlag(flags, 'Use { "campaigns": [...] } for TikTok campaign create');
2961
3001
  return client.post(`/manage/tiktok/campaigns${buildTikTokMutationQuery(flags)}`, body2);
@@ -2964,7 +3004,7 @@ async function createTikTokCampaign(client, _args, flags) {
2964
3004
  return client.post(`/manage/tiktok/campaigns${buildTikTokMutationQuery(flags)}`, body);
2965
3005
  }
2966
3006
  async function updateTikTokCampaign(client, args, flags) {
2967
- validateFlags(flags, CAMPAIGN_UPDATE_FLAGS, "manage tiktok campaigns update");
3007
+ validateFlags(flags, CAMPAIGN_UPDATE_FLAGS2, "manage tiktok campaigns update");
2968
3008
  const id = requireArg(args, 0, "campaign-id", "Run: adkit manage tiktok campaigns update <campaign-id> --status paused");
2969
3009
  const body = typeof flags.data === "string" ? parseDataFlag(flags, "Use a flat TikTok campaign changes object") : buildTikTokCampaignPayload(flags, "update");
2970
3010
  return client.patch(`/manage/tiktok/campaigns/${id}${buildTikTokMutationQuery(flags)}`, body);
@@ -4633,6 +4673,7 @@ Flags (update):
4633
4673
  --status <s> enabled, paused
4634
4674
  --budget-daily <n> Daily budget in account currency
4635
4675
  --bid-strategy <s> Change bidding strategy
4676
+ --countries <codes> Replace included countries, e.g. US,CA
4636
4677
 
4637
4678
  Flags (list):
4638
4679
  --status <s> Filter by campaign status (default: enabled,paused; use all for every status)
@@ -4679,6 +4720,7 @@ Flags (update):
4679
4720
  --status <s> enabled, paused
4680
4721
  --budget-daily <n> Daily budget in account currency
4681
4722
  --bid-strategy <s> Change bidding strategy
4723
+ --countries <codes> Replace included countries, e.g. US,CA
4682
4724
  ${FLAG.account}
4683
4725
  ${FLAG.publish}
4684
4726
  ${FLAG.data}
@@ -4918,6 +4960,7 @@ Flags (list):
4918
4960
 
4919
4961
  Note:
4920
4962
  list returns keyword configuration (bids, match type, status) only.
4963
+ update only changes mutable fields: status and cpc bid.
4921
4964
  Google Ads cannot edit keyword text or match type; pause or remove the old keyword, then create a new one.
4922
4965
  For spend/clicks/conversions per keyword: adkit manage google results keywords
4923
4966
 
@@ -4959,6 +5002,7 @@ Flags (list):
4959
5002
 
4960
5003
  Note:
4961
5004
  list returns keyword configuration (bids, match type, status) only.
5005
+ update only changes mutable fields: status and cpc bid. Raw --data for update must not include text or matchType.
4962
5006
  Google Ads cannot edit keyword text or match type; pause or remove the old keyword, then create a new one.
4963
5007
  For spend/clicks/conversions per keyword: adkit manage google results keywords
4964
5008
 
@@ -5080,6 +5124,32 @@ Examples:
5080
5124
  adkit manage google results --period this_month --sort clicks --limit 20
5081
5125
  adkit manage google results search-terms --campaign 123 --period 30d
5082
5126
  adkit manage google results --campaign 123 --fields all`;
5127
+ var GOOGLE_CHANGE_HISTORY_HELP = `adkit manage google change-history \u2014 recent Google Ads account changes
5128
+
5129
+ Read-only audit log of who changed what and when (campaigns, budgets, ad
5130
+ groups, ads, keywords, etc.). Google only keeps the last 30 days.
5131
+
5132
+ list Recent changes as compact diffs (default action)
5133
+
5134
+ Flags:
5135
+ --account <id> Optional if one Google Ads account is connected
5136
+ --period <period> Date range (7d, 14d, 30d, this_month, maximum, etc. Default: 7d, max 30d back)
5137
+ --from <date> Start date (YYYY-MM-DD, requires --to). Window must be <= 30 days and within the last 30 days.
5138
+ --to <date> End date (YYYY-MM-DD, requires --from)
5139
+ --limit <n> Max changes (default: 50, max: 10000)
5140
+
5141
+ Each record:
5142
+ time, resourceType, resourceName, operation (create | update | remove),
5143
+ changedBy, clientType, changes: [{ field, oldValue, newValue }]
5144
+ create shows only newValue; update shows old + new; remove has no field changes.
5145
+
5146
+ Note:
5147
+ Hard 30-day cap \u2014 a range that starts more than 30 days ago returns an error.
5148
+
5149
+ Examples:
5150
+ adkit manage google change-history list --period 7d
5151
+ adkit manage google change-history list --period 30d --limit 200
5152
+ adkit manage google change-history list --from 2026-06-01 --to 2026-06-15`;
5083
5153
  var GOOGLE_RESULTS_PLACEMENTS_HELP = `adkit manage google results placements \u2014 Google placement report
5084
5154
 
5085
5155
  Shows each website, app, or YouTube placement where ads appeared.
@@ -5265,6 +5335,7 @@ Examples:
5265
5335
  "google results placements": GOOGLE_RESULTS_PLACEMENTS_HELP,
5266
5336
  "google results search-terms": GOOGLE_KEYWORD_SEARCH_TERMS_HELP,
5267
5337
  "google results keywords": GOOGLE_RESULTS_KEYWORDS_HELP,
5338
+ "google change-history": GOOGLE_CHANGE_HISTORY_HELP,
5268
5339
  "google research": GOOGLE_RESEARCH_HELP,
5269
5340
  "google media": GOOGLE_MEDIA_HELP,
5270
5341
  "tiktok accounts": `adkit manage tiktok accounts \u2014 TikTok Ads accounts
@@ -5509,6 +5580,7 @@ Entity groups:
5509
5580
  keywords Manage keywords and negatives \u2014 config only, not metrics
5510
5581
  keywords negative-lists Shared negative keyword lists (create, attach to campaigns)
5511
5582
  results Performance metrics (campaigns, ad-groups, ads, keywords, search-terms)
5583
+ change-history Recent Google Ads account changes from the last 30 days
5512
5584
  research Keyword Planner plus Display topic/interest IDs
5513
5585
  assets Manage reusable assets (sitelinks, callouts, structured snippets, images)
5514
5586
  media Upload images for Display creative media
@@ -5800,6 +5872,7 @@ var HELP_FULL = {
5800
5872
  "google results placements": GOOGLE_RESULTS_PLACEMENTS_HELP,
5801
5873
  "google results search-terms": GOOGLE_KEYWORD_SEARCH_TERMS_HELP_FULL,
5802
5874
  "google results keywords": GOOGLE_RESULTS_KEYWORDS_HELP,
5875
+ "google change-history": GOOGLE_CHANGE_HISTORY_HELP,
5803
5876
  "google research": GOOGLE_RESEARCH_HELP,
5804
5877
  "google media": GOOGLE_MEDIA_HELP,
5805
5878
  "meta research": META_RESEARCH_HELP,
@@ -7118,6 +7191,12 @@ async function main() {
7118
7191
  else data = await listGoogleResults(client, restArgs, flags);
7119
7192
  break;
7120
7193
  }
7194
+ case "change-history": {
7195
+ if (action && action !== "list") throw new CliError("UNKNOWN_COMMAND", `Unknown action: google change-history ${action}`, "Available: list");
7196
+ data = await listGoogleChangeHistory(client, restArgs, flags);
7197
+ emptyHint = "No changes found in the selected window. Try a wider --period (max 30d).";
7198
+ break;
7199
+ }
7121
7200
  case "research": {
7122
7201
  switch (action) {
7123
7202
  case "keywords":
@@ -7138,7 +7217,7 @@ async function main() {
7138
7217
  break;
7139
7218
  }
7140
7219
  default:
7141
- throw new CliError("UNKNOWN_COMMAND", `Unknown entity: google ${entity}`, "Available: accounts, assets, media, campaigns, ad-groups, ads, keywords, results, research");
7220
+ throw new CliError("UNKNOWN_COMMAND", `Unknown entity: google ${entity}`, "Available: accounts, assets, media, campaigns, ad-groups, ads, keywords, results, change-history, research");
7142
7221
  }
7143
7222
  } else if (platform2 === "tiktok") {
7144
7223
  switch (entity) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adkit/cli",
3
- "version": "1.12.16",
3
+ "version": "1.12.18",
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",