@koda-sl/baker-cli 0.173.0 → 0.174.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
@@ -45,7 +45,7 @@ import {
45
45
  resolveAccountIdArg,
46
46
  resolveEffectiveStatus,
47
47
  todayIso
48
- } from "./chunk-JOPBGFXC.js";
48
+ } from "./chunk-7QMWNMRW.js";
49
49
  import {
50
50
  buildQueryCacheKey,
51
51
  cacheGet,
@@ -55,18 +55,19 @@ import {
55
55
  getQueryTtl,
56
56
  handleConnectionError,
57
57
  isNotConnectedError,
58
+ needsConnectionFix,
58
59
  resolveCustomerId,
59
60
  toCsvRow,
60
61
  writeAdsJson,
61
62
  writeAdsOutput,
62
63
  writeJsonEnvelope
63
- } from "./chunk-R4PG6VCS.js";
64
+ } from "./chunk-TFPZLUVM.js";
64
65
  import {
65
66
  ApiError,
66
67
  apiGet,
67
68
  apiPost,
68
69
  validateConvexId
69
- } from "./chunk-LVCBCJWF.js";
70
+ } from "./chunk-ZH6ZNYPB.js";
70
71
  import {
71
72
  installStreamTaps,
72
73
  logInvocation
@@ -4601,7 +4602,7 @@ function accountHints(accounts) {
4601
4602
  }
4602
4603
  function handleAccountsError(err) {
4603
4604
  if (err instanceof ApiError) {
4604
- if (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND") {
4605
+ if (needsConnectionFix(err.code, err.message)) {
4605
4606
  handleConnectionError("google_ads", err.message);
4606
4607
  }
4607
4608
  const envelope = {
@@ -4781,6 +4782,309 @@ function isChangeLookbackWithinReach(days, scope) {
4781
4782
  return days <= CHANGE_SCOPE_MAX_DAYS[scope];
4782
4783
  }
4783
4784
 
4785
+ // ../api/src/ads-google/geo-constants.ts
4786
+ var GEO_TARGET_COUNTRIES = {
4787
+ "2004": "Afghanistan",
4788
+ "2008": "Albania",
4789
+ "2010": "Antarctica",
4790
+ "2012": "Algeria",
4791
+ "2016": "American Samoa",
4792
+ "2020": "Andorra",
4793
+ "2024": "Angola",
4794
+ "2028": "Antigua and Barbuda",
4795
+ "2031": "Azerbaijan",
4796
+ "2032": "Argentina",
4797
+ "2036": "Australia",
4798
+ "2040": "Austria",
4799
+ "2044": "The Bahamas",
4800
+ "2048": "Bahrain",
4801
+ "2050": "Bangladesh",
4802
+ "2051": "Armenia",
4803
+ "2052": "Barbados",
4804
+ "2056": "Belgium",
4805
+ "2060": "Bermuda",
4806
+ "2064": "Bhutan",
4807
+ "2068": "Bolivia",
4808
+ "2070": "Bosnia and Herzegovina",
4809
+ "2072": "Botswana",
4810
+ "2074": "Bouvet Island",
4811
+ "2076": "Brazil",
4812
+ "2084": "Belize",
4813
+ "2086": "British Indian Ocean Territory",
4814
+ "2090": "Solomon Islands",
4815
+ "2092": "British Virgin Islands",
4816
+ "2096": "Brunei",
4817
+ "2100": "Bulgaria",
4818
+ "2104": "Myanmar (Burma)",
4819
+ "2108": "Burundi",
4820
+ "2112": "Belarus",
4821
+ "2116": "Cambodia",
4822
+ "2120": "Cameroon",
4823
+ "2124": "Canada",
4824
+ "2132": "Cabo Verde",
4825
+ "2136": "Cayman Islands",
4826
+ "2140": "Central African Republic",
4827
+ "2144": "Sri Lanka",
4828
+ "2148": "Chad",
4829
+ "2152": "Chile",
4830
+ "2156": "China",
4831
+ "2158": "Taiwan",
4832
+ "2162": "Christmas Island",
4833
+ "2166": "Cocos (Keeling) Islands",
4834
+ "2170": "Colombia",
4835
+ "2174": "Comoros",
4836
+ "2175": "Mayotte",
4837
+ "2178": "Republic of the Congo",
4838
+ "2180": "Democratic Republic of the Congo",
4839
+ "2184": "Cook Islands",
4840
+ "2188": "Costa Rica",
4841
+ "2191": "Croatia",
4842
+ "2196": "Cyprus",
4843
+ "2203": "Czechia",
4844
+ "2204": "Benin",
4845
+ "2208": "Denmark",
4846
+ "2212": "Dominica",
4847
+ "2214": "Dominican Republic",
4848
+ "2218": "Ecuador",
4849
+ "2222": "El Salvador",
4850
+ "2226": "Equatorial Guinea",
4851
+ "2231": "Ethiopia",
4852
+ "2232": "Eritrea",
4853
+ "2233": "Estonia",
4854
+ "2234": "Faroe Islands",
4855
+ "2238": "Falkland Islands (Islas Malvinas)",
4856
+ "2239": "South Georgia and the South Sandwich Islands",
4857
+ "2242": "Fiji",
4858
+ "2246": "Finland",
4859
+ "2250": "France",
4860
+ "2254": "French Guiana",
4861
+ "2258": "French Polynesia",
4862
+ "2260": "French Southern and Antarctic Lands",
4863
+ "2262": "Djibouti",
4864
+ "2266": "Gabon",
4865
+ "2268": "Georgia",
4866
+ "2270": "The Gambia",
4867
+ "2275": "Palestine",
4868
+ "2276": "Germany",
4869
+ "2288": "Ghana",
4870
+ "2292": "Gibraltar",
4871
+ "2296": "Kiribati",
4872
+ "2300": "Greece",
4873
+ "2304": "Greenland",
4874
+ "2308": "Grenada",
4875
+ "2312": "Guadeloupe",
4876
+ "2316": "Guam",
4877
+ "2320": "Guatemala",
4878
+ "2324": "Guinea",
4879
+ "2328": "Guyana",
4880
+ "2332": "Haiti",
4881
+ "2334": "Heard Island and McDonald Islands",
4882
+ "2336": "Vatican City",
4883
+ "2340": "Honduras",
4884
+ "2344": "Hong Kong",
4885
+ "2348": "Hungary",
4886
+ "2352": "Iceland",
4887
+ "2356": "India",
4888
+ "2360": "Indonesia",
4889
+ "2368": "Iraq",
4890
+ "2372": "Ireland",
4891
+ "2376": "Israel",
4892
+ "2380": "Italy",
4893
+ "2384": "Cote d'Ivoire",
4894
+ "2388": "Jamaica",
4895
+ "2392": "Japan",
4896
+ "2398": "Kazakhstan",
4897
+ "2400": "Jordan",
4898
+ "2404": "Kenya",
4899
+ "2410": "South Korea",
4900
+ "2414": "Kuwait",
4901
+ "2417": "Kyrgyzstan",
4902
+ "2418": "Laos",
4903
+ "2422": "Lebanon",
4904
+ "2426": "Lesotho",
4905
+ "2428": "Latvia",
4906
+ "2430": "Liberia",
4907
+ "2434": "Libya",
4908
+ "2438": "Liechtenstein",
4909
+ "2440": "Lithuania",
4910
+ "2442": "Luxembourg",
4911
+ "2446": "Macao",
4912
+ "2450": "Madagascar",
4913
+ "2454": "Malawi",
4914
+ "2458": "Malaysia",
4915
+ "2462": "Maldives",
4916
+ "2466": "Mali",
4917
+ "2470": "Malta",
4918
+ "2474": "Martinique",
4919
+ "2478": "Mauritania",
4920
+ "2480": "Mauritius",
4921
+ "2484": "Mexico",
4922
+ "2492": "Monaco",
4923
+ "2496": "Mongolia",
4924
+ "2498": "Moldova",
4925
+ "2499": "Montenegro",
4926
+ "2500": "Montserrat",
4927
+ "2504": "Morocco",
4928
+ "2508": "Mozambique",
4929
+ "2512": "Oman",
4930
+ "2516": "Namibia",
4931
+ "2520": "Nauru",
4932
+ "2524": "Nepal",
4933
+ "2528": "Netherlands",
4934
+ "2531": "Curacao",
4935
+ "2533": "Aruba",
4936
+ "2534": "Sint Maarten",
4937
+ "2535": "Caribbean Netherlands",
4938
+ "2540": "New Caledonia",
4939
+ "2548": "Vanuatu",
4940
+ "2554": "New Zealand",
4941
+ "2558": "Nicaragua",
4942
+ "2562": "Niger",
4943
+ "2566": "Nigeria",
4944
+ "2570": "Niue",
4945
+ "2574": "Norfolk Island",
4946
+ "2578": "Norway",
4947
+ "2580": "Northern Mariana Islands",
4948
+ "2581": "United States Minor Outlying Islands",
4949
+ "2583": "Micronesia",
4950
+ "2584": "Marshall Islands",
4951
+ "2585": "Palau",
4952
+ "2586": "Pakistan",
4953
+ "2591": "Panama",
4954
+ "2598": "Papua New Guinea",
4955
+ "2600": "Paraguay",
4956
+ "2604": "Peru",
4957
+ "2608": "Philippines",
4958
+ "2612": "Pitcairn Islands",
4959
+ "2616": "Poland",
4960
+ "2620": "Portugal",
4961
+ "2624": "Guinea-Bissau",
4962
+ "2626": "Timor-Leste",
4963
+ "2630": "Puerto Rico",
4964
+ "2634": "Qatar",
4965
+ "2638": "Reunion",
4966
+ "2642": "Romania",
4967
+ "2643": "Russia",
4968
+ "2646": "Rwanda",
4969
+ "2652": "Saint Barthelemy",
4970
+ "2654": "Saint Helena, Ascension and Tristan da Cunha",
4971
+ "2659": "Saint Kitts and Nevis",
4972
+ "2660": "Anguilla",
4973
+ "2662": "Saint Lucia",
4974
+ "2663": "Saint Martin",
4975
+ "2666": "Saint Pierre and Miquelon",
4976
+ "2670": "Saint Vincent and the Grenadines",
4977
+ "2674": "San Marino",
4978
+ "2678": "Sao Tome and Principe",
4979
+ "2682": "Saudi Arabia",
4980
+ "2686": "Senegal",
4981
+ "2688": "Serbia",
4982
+ "2690": "Seychelles",
4983
+ "2694": "Sierra Leone",
4984
+ "2702": "Singapore",
4985
+ "2703": "Slovakia",
4986
+ "2704": "Vietnam",
4987
+ "2705": "Slovenia",
4988
+ "2706": "Somalia",
4989
+ "2710": "South Africa",
4990
+ "2716": "Zimbabwe",
4991
+ "2724": "Spain",
4992
+ "2728": "South Sudan",
4993
+ "2732": "Western Sahara",
4994
+ "2736": "Sudan",
4995
+ "2740": "Suriname",
4996
+ "2744": "Svalbard and Jan Mayen",
4997
+ "2748": "Eswatini",
4998
+ "2752": "Sweden",
4999
+ "2756": "Switzerland",
5000
+ "2760": "Syria",
5001
+ "2762": "Tajikistan",
5002
+ "2764": "Thailand",
5003
+ "2768": "Togo",
5004
+ "2772": "Tokelau",
5005
+ "2776": "Tonga",
5006
+ "2780": "Trinidad and Tobago",
5007
+ "2784": "United Arab Emirates",
5008
+ "2788": "Tunisia",
5009
+ "2792": "Turkiye",
5010
+ "2795": "Turkmenistan",
5011
+ "2796": "Turks and Caicos Islands",
5012
+ "2798": "Tuvalu",
5013
+ "2800": "Uganda",
5014
+ "2804": "Ukraine",
5015
+ "2807": "North Macedonia",
5016
+ "2818": "Egypt",
5017
+ "2826": "United Kingdom",
5018
+ "2831": "Guernsey",
5019
+ "2832": "Jersey",
5020
+ "2833": "Isle of Man",
5021
+ "2834": "Tanzania",
5022
+ "2840": "United States",
5023
+ "2850": "U.S. Virgin Islands",
5024
+ "2854": "Burkina Faso",
5025
+ "2858": "Uruguay",
5026
+ "2860": "Uzbekistan",
5027
+ "2862": "Venezuela",
5028
+ "2876": "Wallis and Futuna",
5029
+ "2882": "Samoa",
5030
+ "2887": "Yemen",
5031
+ "2894": "Zambia",
5032
+ "2900": "Kosovo"
5033
+ };
5034
+ var LANGUAGE_CONSTANTS = {
5035
+ "1000": "English",
5036
+ "1001": "German",
5037
+ "1002": "French",
5038
+ "1003": "Spanish",
5039
+ "1004": "Italian",
5040
+ "1005": "Japanese",
5041
+ "1009": "Danish",
5042
+ "1010": "Dutch",
5043
+ "1011": "Finnish",
5044
+ "1012": "Korean",
5045
+ "1013": "Norwegian",
5046
+ "1014": "Portuguese",
5047
+ "1015": "Swedish",
5048
+ "1017": "Chinese (simplified)",
5049
+ "1018": "Chinese (traditional)",
5050
+ "1019": "Arabic",
5051
+ "1020": "Bulgarian",
5052
+ "1021": "Czech",
5053
+ "1022": "Greek",
5054
+ "1023": "Hindi",
5055
+ "1024": "Hungarian",
5056
+ "1025": "Indonesian",
5057
+ "1026": "Icelandic",
5058
+ "1027": "Hebrew",
5059
+ "1028": "Latvian",
5060
+ "1029": "Lithuanian",
5061
+ "1030": "Polish",
5062
+ "1031": "Russian",
5063
+ "1032": "Romanian",
5064
+ "1033": "Slovak",
5065
+ "1034": "Slovenian",
5066
+ "1035": "Serbian",
5067
+ "1036": "Ukrainian",
5068
+ "1037": "Turkish",
5069
+ "1038": "Catalan",
5070
+ "1039": "Croatian",
5071
+ "1040": "Vietnamese",
5072
+ "1041": "Urdu",
5073
+ "1042": "Filipino",
5074
+ "1043": "Estonian",
5075
+ "1044": "Thai",
5076
+ "1056": "Bengali",
5077
+ "1064": "Persian",
5078
+ "1072": "Gujarati",
5079
+ "1086": "Kannada",
5080
+ "1098": "Malayalam",
5081
+ "1101": "Marathi",
5082
+ "1102": "Malay",
5083
+ "1110": "Punjabi",
5084
+ "1130": "Tamil",
5085
+ "1131": "Telugu"
5086
+ };
5087
+
4784
5088
  // ../api/src/ads-google/limits.ts
4785
5089
  var GOOGLE_ADS_LIMITS = {
4786
5090
  budget: {
@@ -7544,73 +7848,11 @@ import { defineCommand as defineCommand27 } from "citty";
7544
7848
  import { defineCommand as defineCommand23 } from "citty";
7545
7849
 
7546
7850
  // src/geo-context.ts
7547
- var GOOGLE_ADS_LOCATIONS = [
7548
- { id: "2840", name: "United States" },
7549
- { id: "2826", name: "United Kingdom" },
7550
- { id: "2124", name: "Canada" },
7551
- { id: "2036", name: "Australia" },
7552
- { id: "2276", name: "Germany" },
7553
- { id: "2250", name: "France" },
7554
- { id: "2724", name: "Spain" },
7555
- { id: "2380", name: "Italy" },
7556
- { id: "2076", name: "Brazil" },
7557
- { id: "2484", name: "Mexico" },
7558
- { id: "2528", name: "Netherlands" },
7559
- { id: "2056", name: "Belgium" },
7560
- { id: "2040", name: "Austria" },
7561
- { id: "2756", name: "Switzerland" },
7562
- { id: "2620", name: "Portugal" },
7563
- { id: "2752", name: "Sweden" },
7564
- { id: "2578", name: "Norway" },
7565
- { id: "2208", name: "Denmark" },
7566
- { id: "2246", name: "Finland" },
7567
- { id: "2372", name: "Ireland" },
7568
- { id: "2554", name: "New Zealand" },
7569
- { id: "2356", name: "India" },
7570
- { id: "2392", name: "Japan" },
7571
- { id: "2410", name: "South Korea" },
7572
- { id: "2702", name: "Singapore" },
7573
- { id: "2032", name: "Argentina" },
7574
- { id: "2152", name: "Chile" },
7575
- { id: "2170", name: "Colombia" },
7576
- { id: "2604", name: "Peru" },
7577
- { id: "2616", name: "Poland" },
7578
- { id: "2203", name: "Czech Republic" },
7579
- { id: "2642", name: "Romania" },
7580
- { id: "2348", name: "Hungary" },
7581
- { id: "2710", name: "South Africa" },
7582
- { id: "2376", name: "Israel" },
7583
- { id: "2784", name: "United Arab Emirates" },
7584
- { id: "2682", name: "Saudi Arabia" },
7585
- { id: "2792", name: "Turkey" },
7586
- { id: "2608", name: "Philippines" },
7587
- { id: "2764", name: "Thailand" },
7588
- { id: "2458", name: "Malaysia" },
7589
- { id: "2360", name: "Indonesia" },
7590
- { id: "2704", name: "Vietnam" },
7591
- { id: "2158", name: "Taiwan" },
7592
- { id: "2344", name: "Hong Kong" }
7593
- ];
7594
- var GOOGLE_ADS_LANGUAGES = [
7595
- { id: "1000", name: "English" },
7596
- { id: "1003", name: "Spanish" },
7597
- { id: "1001", name: "German" },
7598
- { id: "1002", name: "French" },
7599
- { id: "1004", name: "Italian" },
7600
- { id: "1014", name: "Portuguese" },
7601
- { id: "1010", name: "Japanese" },
7602
- { id: "1012", name: "Korean" },
7603
- { id: "1017", name: "Chinese (Simplified)" },
7604
- { id: "1019", name: "Arabic" },
7605
- { id: "1031", name: "Russian" },
7606
- { id: "1030", name: "Polish" },
7607
- { id: "1037", name: "Turkish" },
7608
- { id: "1015", name: "Swedish" },
7609
- { id: "1013", name: "Norwegian" },
7610
- { id: "1009", name: "Danish" },
7611
- { id: "1011", name: "Finnish" },
7612
- { id: "1005", name: "Dutch" }
7613
- ];
7851
+ function toOptions(names) {
7852
+ return Object.entries(names).map(([id, name]) => ({ id, name })).sort((a, b) => a.name.localeCompare(b.name));
7853
+ }
7854
+ var GOOGLE_ADS_LOCATIONS = toOptions(GEO_TARGET_COUNTRIES);
7855
+ var GOOGLE_ADS_LANGUAGES = toOptions(LANGUAGE_CONSTANTS);
7614
7856
  var DATAFORSEO_LOCATIONS = [
7615
7857
  { code: "us", name: "United States" },
7616
7858
  { code: "uk", name: "United Kingdom" },
@@ -7687,8 +7929,6 @@ function toRecord(list) {
7687
7929
  }
7688
7930
  return map;
7689
7931
  }
7690
- var adsLocationMap = toRecord(GOOGLE_ADS_LOCATIONS);
7691
- var adsLanguageMap = toRecord(GOOGLE_ADS_LANGUAGES);
7692
7932
  var researchLocationMap = toRecord(DATAFORSEO_LOCATIONS);
7693
7933
  var researchLanguageMap = toRecord(DATAFORSEO_LANGUAGES);
7694
7934
  function buildAdsQueryContext(locationArg, languageArg) {
@@ -7696,8 +7936,8 @@ function buildAdsQueryContext(locationArg, languageArg) {
7696
7936
  const languageId = languageArg ?? "1000";
7697
7937
  const locationIsDefault = !locationArg;
7698
7938
  const languageIsDefault = !languageArg;
7699
- const locationName = adsLocationMap[locationId] ?? `ID ${locationId}`;
7700
- const languageName = adsLanguageMap[languageId] ?? `ID ${languageId}`;
7939
+ const locationName = GEO_TARGET_COUNTRIES[locationId] ?? `ID ${locationId}`;
7940
+ const languageName = LANGUAGE_CONSTANTS[languageId] ?? `ID ${languageId}`;
7701
7941
  const ctx = {
7702
7942
  location: `${locationName} (${locationId})`,
7703
7943
  language: `${languageName} (${languageId})`,
@@ -9968,10 +10208,7 @@ import { readFileSync as readFileSync4 } from "fs";
9968
10208
  var DAY_MS2 = 864e5;
9969
10209
  function handleLinkedinError(err) {
9970
10210
  if (err instanceof ApiError) {
9971
- if (err.code === "UNAUTHORIZED") {
9972
- handleConnectionError("linkedin_ads", err.message);
9973
- }
9974
- if (err.code === "NOT_FOUND") {
10211
+ if (needsConnectionFix(err.code, err.message)) {
9975
10212
  handleConnectionError("linkedin_ads", err.message);
9976
10213
  }
9977
10214
  if (isNoAccountsSelectedError(err.code, err.message)) {
@@ -15361,10 +15598,10 @@ function duplicateCommand2(entity, label) {
15361
15598
  replace: { type: "boolean", description: "Pause the original once the copy publishes" }
15362
15599
  },
15363
15600
  run: async ({ args }) => {
15364
- const { apiPost: apiPost2 } = await import("./client-R5ZSVIK3.js");
15601
+ const { apiPost: apiPost2 } = await import("./client-XRQWOADV.js");
15365
15602
  const { requireChatId: requireChatId2 } = await import("./env-3JMYIH25.js");
15366
- const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-KLK2GZXR.js");
15367
- const { handleMetaError: handleMetaError2 } = await import("./shared-AXAXNKGE.js");
15603
+ const { writeJsonEnvelope: writeJsonEnvelope2 } = await import("./output-FL7WRIJF.js");
15604
+ const { handleMetaError: handleMetaError2 } = await import("./shared-OIYLDW3G.js");
15368
15605
  try {
15369
15606
  const accountId = bareAccountId2(args);
15370
15607
  const chatId = requireChatId2();
@@ -16243,16 +16480,27 @@ async function runList(args) {
16243
16480
  const accountId = resolveAccountIdArg(args);
16244
16481
  const params = { "account-id": accountId };
16245
16482
  if (args["skip-cache"]) params["skip-cache"] = "true";
16246
- const data = await apiGet("/api/ads/meta/pixels", params);
16247
- emit(data, args);
16483
+ const { pixels, restrictedFields } = await apiGet("/api/ads/meta/pixels", params);
16484
+ emit(pixels, args, pixelWarnings(restrictedFields));
16248
16485
  }
16249
- function emit(data, args) {
16486
+ function pixelWarnings(restrictedFields) {
16487
+ if (restrictedFields.length === 0) {
16488
+ return [];
16489
+ }
16490
+ return [
16491
+ {
16492
+ code: "PIXEL_FIELDS_RESTRICTED",
16493
+ message: `Meta withheld ${restrictedFields.join(", ")} for these pixels \u2014 the connected user holds no role in the Business that owns them. IDs, names, creation and last-fired times are complete; install code and setup details are not. To get them, the client assigns the pixel to the connected user in Meta Business settings \u2192 Data sources \u2192 Datasets.`
16494
+ }
16495
+ ];
16496
+ }
16497
+ function emit(data, args, warnings = []) {
16250
16498
  const fmt = csvOrJson(args);
16251
16499
  if (fmt !== "json") {
16252
16500
  writeAdsOutput(data, fmt);
16253
16501
  return;
16254
16502
  }
16255
- writeAdsJson({ ok: true, data });
16503
+ writeAdsJson({ ok: true, data, ...warnings.length > 0 ? { warnings } : {} });
16256
16504
  }
16257
16505
 
16258
16506
  // src/commands/ads/meta/preview.ts
@@ -16417,7 +16665,7 @@ function accountHints4(accounts) {
16417
16665
  }
16418
16666
  function handleAccountsError2(err) {
16419
16667
  if (err instanceof ApiError) {
16420
- if (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND") {
16668
+ if (needsConnectionFix(err.code, err.message)) {
16421
16669
  handleConnectionError("x_ads", err.message);
16422
16670
  }
16423
16671
  const envelope = {
@@ -16592,7 +16840,7 @@ ${list}`
16592
16840
  });
16593
16841
  process.exit(1);
16594
16842
  } catch (err) {
16595
- if (err instanceof ApiError && (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND")) {
16843
+ if (err instanceof ApiError && needsConnectionFix(err.code, err.message)) {
16596
16844
  handleConnectionError("x_ads", err.message);
16597
16845
  }
16598
16846
  writeAdsJson({
@@ -25774,7 +26022,7 @@ ${list}`
25774
26022
  });
25775
26023
  process.exit(1);
25776
26024
  } catch (err) {
25777
- if (err instanceof ApiError && (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND")) {
26025
+ if (err instanceof ApiError && needsConnectionFix(err.code, err.message)) {
25778
26026
  handleConnectionError("ga4", err.message);
25779
26027
  }
25780
26028
  writeJsonEnvelope({
@@ -25903,7 +26151,7 @@ Examples:
25903
26151
  writeJsonEnvelope({ ok: true, data, hints: propertyHints(data) });
25904
26152
  } catch (err) {
25905
26153
  if (err instanceof ApiError) {
25906
- if (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND") {
26154
+ if (needsConnectionFix(err.code, err.message)) {
25907
26155
  handleConnectionError("ga4", err.message);
25908
26156
  }
25909
26157
  writeJsonEnvelope({ ok: false, error: { code: err.code, message: err.message } });
@@ -26231,7 +26479,7 @@ ${list}`
26231
26479
  });
26232
26480
  process.exit(1);
26233
26481
  } catch (err) {
26234
- if (err instanceof ApiError && (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND")) {
26482
+ if (err instanceof ApiError && needsConnectionFix(err.code, err.message)) {
26235
26483
  handleConnectionError("gsc", err.message);
26236
26484
  }
26237
26485
  writeJsonEnvelope({
@@ -26538,7 +26786,7 @@ Examples:
26538
26786
  writeJsonEnvelope({ ok: true, data, hints: siteHints(data) });
26539
26787
  } catch (err) {
26540
26788
  if (err instanceof ApiError) {
26541
- if (err.code === "UNAUTHORIZED" || err.code === "NOT_FOUND") {
26789
+ if (needsConnectionFix(err.code, err.message)) {
26542
26790
  handleConnectionError("gsc", err.message);
26543
26791
  }
26544
26792
  writeJsonEnvelope({ ok: false, error: { code: err.code, message: err.message } });
@@ -26689,7 +26937,7 @@ Full guide: __tooling__/docs/tools/baker/history.md`
26689
26937
  import { defineCommand as defineCommand114 } from "citty";
26690
26938
  var EMBED_TYPES = ["legacy", "v4", "unknown"];
26691
26939
  function failNotConnected(err) {
26692
- if (err instanceof ApiError && err.code === "UNAUTHORIZED" && err.message.includes(HUBSPOT_MISSING_GRANT_MARKER)) {
26940
+ if (err instanceof ApiError && err.code === "FORBIDDEN" && err.message.includes(HUBSPOT_MISSING_GRANT_MARKER)) {
26693
26941
  writeJson({
26694
26942
  ok: false,
26695
26943
  error: {
@@ -33028,7 +33276,7 @@ function handleError3(err) {
33028
33276
  error: {
33029
33277
  code: err.code,
33030
33278
  message: err.message,
33031
- ...err.code === "UNAUTHORIZED" ? {
33279
+ ...err.code === "UNAUTHORIZED" || err.code === "FORBIDDEN" && isNotConnectedError(err.code, err.message) ? {
33032
33280
  fix: {
33033
33281
  action: "request_connection",
33034
33282
  explanation: 'Tag Manager is not connected for this company yet, or no container has been picked. Do NOT send the user to Settings \u2014 call the `request_connection` tool with { platform: "google-tag-manager", reason } and they connect and pick their containers (they can pick more than one) from inside the chat. `request_tag_input` is NOT the route: that form manages the container snippet on the site, not what runs inside the container, and it cannot pick a container. If `request_connection` is not available to you, say so plainly and point them at dashboard \u2192 Brain \u2192 Integrations \u2192 Tools \u2192 Google Tag Manager, where they also pick the container. Carry on with the rest of the task meanwhile.'