gscdump 1.0.2 → 1.0.3

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/index.mjs CHANGED
@@ -1,3 +1,8 @@
1
+ import { err, isErr, isOk, ok, unwrapResult } from "./core/result.mjs";
2
+ import { DAYS_PER_RANGE, GSC_FINALIZED_LAG_DAYS, GSC_FRESHEST_LAG_DAYS, GSC_RETENTION_MONTHS, MS_PER_DAY, addDays, countDays, generateGscDateRange, getBackfillProgress, getDateRange, getFreshestGscDate, getLatestGscDate, getNextDate, getOldestGscDate, getPendingDates, getPreviousDate, getPstDate, groupIntoRanges, isValidGscDate, toIsoDate } from "./_chunks/gsc-dates.mjs";
3
+ import { resolveToBody } from "./_chunks/resolver.mjs";
4
+ import { normalizeUrl } from "./normalize.mjs";
5
+ import { decodeSiteId, encodeSiteId, normalizeSiteUrl } from "./tenant.mjs";
1
6
  import { ofetch } from "ofetch";
2
7
  import { GSCDUMP_ONBOARDING_CONTRACT_VERSION, GSCDUMP_OPTIONAL_INDEXING_SCOPE, GSCDUMP_REQUIRED_ANALYTICS_SCOPE, GSCDUMP_WRITE_ANALYTICS_SCOPE, accountNextActions, accountStatuses, analyticsNextActions, analyticsStatuses, hasOptionalIndexingScope, hasRequiredAnalyticsScope, indexingNextActions, indexingStatuses, lifecycleErrorCodes, parseGrantedScopes, propertyNextActions, propertyStatuses, querySourceModes, sitemapNextActions, sitemapStatuses } from "@gscdump/contracts/partner";
3
8
  async function runSequentialBatch(items, operation, options = {}) {
@@ -405,28 +410,6 @@ function isPermissionDeniedError(err) {
405
410
  const msg = String(err?.message ?? err ?? "").toLowerCase();
406
411
  return PERMISSION_SIGNALS.some((s) => msg.includes(s));
407
412
  }
408
- function ok(value) {
409
- return {
410
- ok: true,
411
- value
412
- };
413
- }
414
- function err(error) {
415
- return {
416
- ok: false,
417
- error
418
- };
419
- }
420
- function isOk(result) {
421
- return result.ok;
422
- }
423
- function isErr(result) {
424
- return !result.ok;
425
- }
426
- function unwrapResult(result, toError) {
427
- if (result.ok) return result.value;
428
- throw toError(result.error);
429
- }
430
413
  const OAUTH_TOKEN_URL = "https://oauth2.googleapis.com/token";
431
414
  const OAUTH_TOKEN_INFO_URL = "https://oauth2.googleapis.com/tokeninfo";
432
415
  const OAUTH_REVOKE_URL = "https://oauth2.googleapis.com/revoke";
@@ -698,1882 +681,6 @@ async function getVerifiedSite(client, id) {
698
681
  async function unverifySite(client, id) {
699
682
  return client.verification.delete(id);
700
683
  }
701
- const MS_PER_DAY = 864e5;
702
- function toIsoDate(d) {
703
- return d.toISOString().slice(0, 10);
704
- }
705
- const GSC_FINALIZED_LAG_DAYS = 3;
706
- const GSC_FRESHEST_LAG_DAYS = 1;
707
- const GSC_RETENTION_MONTHS = 16;
708
- function getPstDate() {
709
- return (/* @__PURE__ */ new Date()).toLocaleDateString("en-CA", { timeZone: "America/Los_Angeles" });
710
- }
711
- function getPstDateDaysAgo(daysAgo) {
712
- const pstNow = new Date((/* @__PURE__ */ new Date()).toLocaleString("en-US", { timeZone: "America/Los_Angeles" }));
713
- pstNow.setDate(pstNow.getDate() - daysAgo);
714
- return toIsoDate(pstNow);
715
- }
716
- function getLatestGscDate() {
717
- return getPstDateDaysAgo(3);
718
- }
719
- function getFreshestGscDate() {
720
- return getPstDateDaysAgo(1);
721
- }
722
- function getPendingDates() {
723
- const dates = [];
724
- for (let daysAgo = 1; daysAgo <= 3; daysAgo++) dates.push(getPstDateDaysAgo(daysAgo));
725
- return dates;
726
- }
727
- function getDateRange(startDate, endDate) {
728
- const dates = [];
729
- const endMs = Date.parse(`${endDate}T00:00:00Z`);
730
- for (let cursor = Date.parse(`${startDate}T00:00:00Z`); cursor <= endMs; cursor += MS_PER_DAY) dates.push(toIsoDate(new Date(cursor)));
731
- return dates;
732
- }
733
- const DAYS_PER_RANGE = 30;
734
- function generateGscDateRange(startDate, endDate) {
735
- const start = startDate < getOldestGscDate() ? getOldestGscDate() : startDate;
736
- const end = endDate > getFreshestGscDate() ? getFreshestGscDate() : endDate;
737
- return start <= end ? getDateRange(start, end) : [];
738
- }
739
- function groupIntoRanges(dates, daysPerRange = 30) {
740
- if (dates.length === 0) return [];
741
- const sorted = [...dates].sort();
742
- const ranges = [];
743
- let rangeStart = sorted[0];
744
- let rangePrev = sorted[0];
745
- for (let i = 1; i < sorted.length; i++) {
746
- const current = sorted[i];
747
- const expected = getNextDate(rangePrev);
748
- const daysInRange = countDays(rangeStart, rangePrev);
749
- if (current !== expected || daysInRange >= daysPerRange) {
750
- ranges.push({
751
- startDate: rangeStart,
752
- endDate: rangePrev
753
- });
754
- rangeStart = current;
755
- }
756
- rangePrev = current;
757
- }
758
- ranges.push({
759
- startDate: rangeStart,
760
- endDate: rangePrev
761
- });
762
- return ranges;
763
- }
764
- function countDays(startDate, endDate) {
765
- return Math.round((Date.parse(`${endDate}T00:00:00Z`) - Date.parse(`${startDate}T00:00:00Z`)) / MS_PER_DAY) + 1;
766
- }
767
- function getOldestGscDate() {
768
- const date = /* @__PURE__ */ new Date();
769
- date.setMonth(date.getMonth() - 16);
770
- return toIsoDate(date);
771
- }
772
- function addDays(dateStr, n) {
773
- return toIsoDate(new Date(Date.parse(`${dateStr}T00:00:00Z`) + n * MS_PER_DAY));
774
- }
775
- function getPreviousDate(dateStr) {
776
- return addDays(dateStr, -1);
777
- }
778
- function getNextDate(dateStr) {
779
- return addDays(dateStr, 1);
780
- }
781
- function isValidGscDate(dateStr) {
782
- return dateStr >= getOldestGscDate() && dateStr <= getFreshestGscDate();
783
- }
784
- function getBackfillProgress(oldestDateSynced, newestDateSynced) {
785
- if (!oldestDateSynced || !newestDateSynced) return null;
786
- const oldestGsc = getOldestGscDate();
787
- const totalDays = countDays(oldestGsc, getLatestGscDate());
788
- const syncedDays = countDays(oldestDateSynced, newestDateSynced);
789
- return {
790
- progress: Math.round(Math.min(1, syncedDays / totalDays) * 100) / 100,
791
- daysAvailable: totalDays,
792
- daysSynced: syncedDays,
793
- oldestGscDate: oldestGsc,
794
- isComplete: oldestDateSynced <= oldestGsc
795
- };
796
- }
797
- var countries_default = [
798
- {
799
- "name": "Afghanistan",
800
- "alpha-2": "AF",
801
- "alpha-3": "AFG",
802
- "country-code": "004"
803
- },
804
- {
805
- "name": "Åland Islands",
806
- "alpha-2": "AX",
807
- "alpha-3": "ALA",
808
- "country-code": "248"
809
- },
810
- {
811
- "name": "Albania",
812
- "alpha-2": "AL",
813
- "alpha-3": "ALB",
814
- "country-code": "008"
815
- },
816
- {
817
- "name": "Algeria",
818
- "alpha-2": "DZ",
819
- "alpha-3": "DZA",
820
- "country-code": "012"
821
- },
822
- {
823
- "name": "American Samoa",
824
- "alpha-2": "AS",
825
- "alpha-3": "ASM",
826
- "country-code": "016"
827
- },
828
- {
829
- "name": "Andorra",
830
- "alpha-2": "AD",
831
- "alpha-3": "AND",
832
- "country-code": "020"
833
- },
834
- {
835
- "name": "Angola",
836
- "alpha-2": "AO",
837
- "alpha-3": "AGO",
838
- "country-code": "024"
839
- },
840
- {
841
- "name": "Anguilla",
842
- "alpha-2": "AI",
843
- "alpha-3": "AIA",
844
- "country-code": "660"
845
- },
846
- {
847
- "name": "Antarctica",
848
- "alpha-2": "AQ",
849
- "alpha-3": "ATA",
850
- "country-code": "010"
851
- },
852
- {
853
- "name": "Antigua and Barbuda",
854
- "alpha-2": "AG",
855
- "alpha-3": "ATG",
856
- "country-code": "028"
857
- },
858
- {
859
- "name": "Argentina",
860
- "alpha-2": "AR",
861
- "alpha-3": "ARG",
862
- "country-code": "032"
863
- },
864
- {
865
- "name": "Armenia",
866
- "alpha-2": "AM",
867
- "alpha-3": "ARM",
868
- "country-code": "051"
869
- },
870
- {
871
- "name": "Aruba",
872
- "alpha-2": "AW",
873
- "alpha-3": "ABW",
874
- "country-code": "533"
875
- },
876
- {
877
- "name": "Australia",
878
- "alpha-2": "AU",
879
- "alpha-3": "AUS",
880
- "country-code": "036"
881
- },
882
- {
883
- "name": "Austria",
884
- "alpha-2": "AT",
885
- "alpha-3": "AUT",
886
- "country-code": "040"
887
- },
888
- {
889
- "name": "Azerbaijan",
890
- "alpha-2": "AZ",
891
- "alpha-3": "AZE",
892
- "country-code": "031"
893
- },
894
- {
895
- "name": "Bahamas",
896
- "alpha-2": "BS",
897
- "alpha-3": "BHS",
898
- "country-code": "044"
899
- },
900
- {
901
- "name": "Bahrain",
902
- "alpha-2": "BH",
903
- "alpha-3": "BHR",
904
- "country-code": "048"
905
- },
906
- {
907
- "name": "Bangladesh",
908
- "alpha-2": "BD",
909
- "alpha-3": "BGD",
910
- "country-code": "050"
911
- },
912
- {
913
- "name": "Barbados",
914
- "alpha-2": "BB",
915
- "alpha-3": "BRB",
916
- "country-code": "052"
917
- },
918
- {
919
- "name": "Belarus",
920
- "alpha-2": "BY",
921
- "alpha-3": "BLR",
922
- "country-code": "112"
923
- },
924
- {
925
- "name": "Belgium",
926
- "alpha-2": "BE",
927
- "alpha-3": "BEL",
928
- "country-code": "056"
929
- },
930
- {
931
- "name": "Belize",
932
- "alpha-2": "BZ",
933
- "alpha-3": "BLZ",
934
- "country-code": "084"
935
- },
936
- {
937
- "name": "Benin",
938
- "alpha-2": "BJ",
939
- "alpha-3": "BEN",
940
- "country-code": "204"
941
- },
942
- {
943
- "name": "Bermuda",
944
- "alpha-2": "BM",
945
- "alpha-3": "BMU",
946
- "country-code": "060"
947
- },
948
- {
949
- "name": "Bhutan",
950
- "alpha-2": "BT",
951
- "alpha-3": "BTN",
952
- "country-code": "064"
953
- },
954
- {
955
- "name": "Bolivia (Plurinational State of)",
956
- "alpha-2": "BO",
957
- "alpha-3": "BOL",
958
- "country-code": "068"
959
- },
960
- {
961
- "name": "Bonaire, Sint Eustatius and Saba",
962
- "alpha-2": "BQ",
963
- "alpha-3": "BES",
964
- "country-code": "535"
965
- },
966
- {
967
- "name": "Bosnia and Herzegovina",
968
- "alpha-2": "BA",
969
- "alpha-3": "BIH",
970
- "country-code": "070"
971
- },
972
- {
973
- "name": "Botswana",
974
- "alpha-2": "BW",
975
- "alpha-3": "BWA",
976
- "country-code": "072"
977
- },
978
- {
979
- "name": "Bouvet Island",
980
- "alpha-2": "BV",
981
- "alpha-3": "BVT",
982
- "country-code": "074"
983
- },
984
- {
985
- "name": "Brazil",
986
- "alpha-2": "BR",
987
- "alpha-3": "BRA",
988
- "country-code": "076"
989
- },
990
- {
991
- "name": "British Indian Ocean Territory",
992
- "alpha-2": "IO",
993
- "alpha-3": "IOT",
994
- "country-code": "086"
995
- },
996
- {
997
- "name": "Brunei Darussalam",
998
- "alpha-2": "BN",
999
- "alpha-3": "BRN",
1000
- "country-code": "096"
1001
- },
1002
- {
1003
- "name": "Bulgaria",
1004
- "alpha-2": "BG",
1005
- "alpha-3": "BGR",
1006
- "country-code": "100"
1007
- },
1008
- {
1009
- "name": "Burkina Faso",
1010
- "alpha-2": "BF",
1011
- "alpha-3": "BFA",
1012
- "country-code": "854"
1013
- },
1014
- {
1015
- "name": "Burundi",
1016
- "alpha-2": "BI",
1017
- "alpha-3": "BDI",
1018
- "country-code": "108"
1019
- },
1020
- {
1021
- "name": "Cabo Verde",
1022
- "alpha-2": "CV",
1023
- "alpha-3": "CPV",
1024
- "country-code": "132"
1025
- },
1026
- {
1027
- "name": "Cambodia",
1028
- "alpha-2": "KH",
1029
- "alpha-3": "KHM",
1030
- "country-code": "116"
1031
- },
1032
- {
1033
- "name": "Cameroon",
1034
- "alpha-2": "CM",
1035
- "alpha-3": "CMR",
1036
- "country-code": "120"
1037
- },
1038
- {
1039
- "name": "Canada",
1040
- "alpha-2": "CA",
1041
- "alpha-3": "CAN",
1042
- "country-code": "124"
1043
- },
1044
- {
1045
- "name": "Cayman Islands",
1046
- "alpha-2": "KY",
1047
- "alpha-3": "CYM",
1048
- "country-code": "136"
1049
- },
1050
- {
1051
- "name": "Central African Republic",
1052
- "alpha-2": "CF",
1053
- "alpha-3": "CAF",
1054
- "country-code": "140"
1055
- },
1056
- {
1057
- "name": "Chad",
1058
- "alpha-2": "TD",
1059
- "alpha-3": "TCD",
1060
- "country-code": "148"
1061
- },
1062
- {
1063
- "name": "Chile",
1064
- "alpha-2": "CL",
1065
- "alpha-3": "CHL",
1066
- "country-code": "152"
1067
- },
1068
- {
1069
- "name": "China",
1070
- "alpha-2": "CN",
1071
- "alpha-3": "CHN",
1072
- "country-code": "156"
1073
- },
1074
- {
1075
- "name": "Christmas Island",
1076
- "alpha-2": "CX",
1077
- "alpha-3": "CXR",
1078
- "country-code": "162"
1079
- },
1080
- {
1081
- "name": "Cocos (Keeling) Islands",
1082
- "alpha-2": "CC",
1083
- "alpha-3": "CCK",
1084
- "country-code": "166"
1085
- },
1086
- {
1087
- "name": "Colombia",
1088
- "alpha-2": "CO",
1089
- "alpha-3": "COL",
1090
- "country-code": "170"
1091
- },
1092
- {
1093
- "name": "Comoros",
1094
- "alpha-2": "KM",
1095
- "alpha-3": "COM",
1096
- "country-code": "174"
1097
- },
1098
- {
1099
- "name": "Congo",
1100
- "alpha-2": "CG",
1101
- "alpha-3": "COG",
1102
- "country-code": "178"
1103
- },
1104
- {
1105
- "name": "Congo, Democratic Republic of the",
1106
- "alpha-2": "CD",
1107
- "alpha-3": "COD",
1108
- "country-code": "180"
1109
- },
1110
- {
1111
- "name": "Cook Islands",
1112
- "alpha-2": "CK",
1113
- "alpha-3": "COK",
1114
- "country-code": "184"
1115
- },
1116
- {
1117
- "name": "Costa Rica",
1118
- "alpha-2": "CR",
1119
- "alpha-3": "CRI",
1120
- "country-code": "188"
1121
- },
1122
- {
1123
- "name": "Côte d'Ivoire",
1124
- "alpha-2": "CI",
1125
- "alpha-3": "CIV",
1126
- "country-code": "384"
1127
- },
1128
- {
1129
- "name": "Croatia",
1130
- "alpha-2": "HR",
1131
- "alpha-3": "HRV",
1132
- "country-code": "191"
1133
- },
1134
- {
1135
- "name": "Cuba",
1136
- "alpha-2": "CU",
1137
- "alpha-3": "CUB",
1138
- "country-code": "192"
1139
- },
1140
- {
1141
- "name": "Curaçao",
1142
- "alpha-2": "CW",
1143
- "alpha-3": "CUW",
1144
- "country-code": "531"
1145
- },
1146
- {
1147
- "name": "Cyprus",
1148
- "alpha-2": "CY",
1149
- "alpha-3": "CYP",
1150
- "country-code": "196"
1151
- },
1152
- {
1153
- "name": "Czechia",
1154
- "alpha-2": "CZ",
1155
- "alpha-3": "CZE",
1156
- "country-code": "203"
1157
- },
1158
- {
1159
- "name": "Denmark",
1160
- "alpha-2": "DK",
1161
- "alpha-3": "DNK",
1162
- "country-code": "208"
1163
- },
1164
- {
1165
- "name": "Djibouti",
1166
- "alpha-2": "DJ",
1167
- "alpha-3": "DJI",
1168
- "country-code": "262"
1169
- },
1170
- {
1171
- "name": "Dominica",
1172
- "alpha-2": "DM",
1173
- "alpha-3": "DMA",
1174
- "country-code": "212"
1175
- },
1176
- {
1177
- "name": "Dominican Republic",
1178
- "alpha-2": "DO",
1179
- "alpha-3": "DOM",
1180
- "country-code": "214"
1181
- },
1182
- {
1183
- "name": "Ecuador",
1184
- "alpha-2": "EC",
1185
- "alpha-3": "ECU",
1186
- "country-code": "218"
1187
- },
1188
- {
1189
- "name": "Egypt",
1190
- "alpha-2": "EG",
1191
- "alpha-3": "EGY",
1192
- "country-code": "818"
1193
- },
1194
- {
1195
- "name": "El Salvador",
1196
- "alpha-2": "SV",
1197
- "alpha-3": "SLV",
1198
- "country-code": "222"
1199
- },
1200
- {
1201
- "name": "Equatorial Guinea",
1202
- "alpha-2": "GQ",
1203
- "alpha-3": "GNQ",
1204
- "country-code": "226"
1205
- },
1206
- {
1207
- "name": "Eritrea",
1208
- "alpha-2": "ER",
1209
- "alpha-3": "ERI",
1210
- "country-code": "232"
1211
- },
1212
- {
1213
- "name": "Estonia",
1214
- "alpha-2": "EE",
1215
- "alpha-3": "EST",
1216
- "country-code": "233"
1217
- },
1218
- {
1219
- "name": "Eswatini",
1220
- "alpha-2": "SZ",
1221
- "alpha-3": "SWZ",
1222
- "country-code": "748"
1223
- },
1224
- {
1225
- "name": "Ethiopia",
1226
- "alpha-2": "ET",
1227
- "alpha-3": "ETH",
1228
- "country-code": "231"
1229
- },
1230
- {
1231
- "name": "Falkland Islands (Malvinas)",
1232
- "alpha-2": "FK",
1233
- "alpha-3": "FLK",
1234
- "country-code": "238"
1235
- },
1236
- {
1237
- "name": "Faroe Islands",
1238
- "alpha-2": "FO",
1239
- "alpha-3": "FRO",
1240
- "country-code": "234"
1241
- },
1242
- {
1243
- "name": "Fiji",
1244
- "alpha-2": "FJ",
1245
- "alpha-3": "FJI",
1246
- "country-code": "242"
1247
- },
1248
- {
1249
- "name": "Finland",
1250
- "alpha-2": "FI",
1251
- "alpha-3": "FIN",
1252
- "country-code": "246"
1253
- },
1254
- {
1255
- "name": "France",
1256
- "alpha-2": "FR",
1257
- "alpha-3": "FRA",
1258
- "country-code": "250"
1259
- },
1260
- {
1261
- "name": "French Guiana",
1262
- "alpha-2": "GF",
1263
- "alpha-3": "GUF",
1264
- "country-code": "254"
1265
- },
1266
- {
1267
- "name": "French Polynesia",
1268
- "alpha-2": "PF",
1269
- "alpha-3": "PYF",
1270
- "country-code": "258"
1271
- },
1272
- {
1273
- "name": "French Southern Territories",
1274
- "alpha-2": "TF",
1275
- "alpha-3": "ATF",
1276
- "country-code": "260"
1277
- },
1278
- {
1279
- "name": "Gabon",
1280
- "alpha-2": "GA",
1281
- "alpha-3": "GAB",
1282
- "country-code": "266"
1283
- },
1284
- {
1285
- "name": "Gambia",
1286
- "alpha-2": "GM",
1287
- "alpha-3": "GMB",
1288
- "country-code": "270"
1289
- },
1290
- {
1291
- "name": "Georgia",
1292
- "alpha-2": "GE",
1293
- "alpha-3": "GEO",
1294
- "country-code": "268"
1295
- },
1296
- {
1297
- "name": "Germany",
1298
- "alpha-2": "DE",
1299
- "alpha-3": "DEU",
1300
- "country-code": "276"
1301
- },
1302
- {
1303
- "name": "Ghana",
1304
- "alpha-2": "GH",
1305
- "alpha-3": "GHA",
1306
- "country-code": "288"
1307
- },
1308
- {
1309
- "name": "Gibraltar",
1310
- "alpha-2": "GI",
1311
- "alpha-3": "GIB",
1312
- "country-code": "292"
1313
- },
1314
- {
1315
- "name": "Greece",
1316
- "alpha-2": "GR",
1317
- "alpha-3": "GRC",
1318
- "country-code": "300"
1319
- },
1320
- {
1321
- "name": "Greenland",
1322
- "alpha-2": "GL",
1323
- "alpha-3": "GRL",
1324
- "country-code": "304"
1325
- },
1326
- {
1327
- "name": "Grenada",
1328
- "alpha-2": "GD",
1329
- "alpha-3": "GRD",
1330
- "country-code": "308"
1331
- },
1332
- {
1333
- "name": "Guadeloupe",
1334
- "alpha-2": "GP",
1335
- "alpha-3": "GLP",
1336
- "country-code": "312"
1337
- },
1338
- {
1339
- "name": "Guam",
1340
- "alpha-2": "GU",
1341
- "alpha-3": "GUM",
1342
- "country-code": "316"
1343
- },
1344
- {
1345
- "name": "Guatemala",
1346
- "alpha-2": "GT",
1347
- "alpha-3": "GTM",
1348
- "country-code": "320"
1349
- },
1350
- {
1351
- "name": "Guernsey",
1352
- "alpha-2": "GG",
1353
- "alpha-3": "GGY",
1354
- "country-code": "831"
1355
- },
1356
- {
1357
- "name": "Guinea",
1358
- "alpha-2": "GN",
1359
- "alpha-3": "GIN",
1360
- "country-code": "324"
1361
- },
1362
- {
1363
- "name": "Guinea-Bissau",
1364
- "alpha-2": "GW",
1365
- "alpha-3": "GNB",
1366
- "country-code": "624"
1367
- },
1368
- {
1369
- "name": "Guyana",
1370
- "alpha-2": "GY",
1371
- "alpha-3": "GUY",
1372
- "country-code": "328"
1373
- },
1374
- {
1375
- "name": "Haiti",
1376
- "alpha-2": "HT",
1377
- "alpha-3": "HTI",
1378
- "country-code": "332"
1379
- },
1380
- {
1381
- "name": "Heard Island and McDonald Islands",
1382
- "alpha-2": "HM",
1383
- "alpha-3": "HMD",
1384
- "country-code": "334"
1385
- },
1386
- {
1387
- "name": "Holy See",
1388
- "alpha-2": "VA",
1389
- "alpha-3": "VAT",
1390
- "country-code": "336"
1391
- },
1392
- {
1393
- "name": "Honduras",
1394
- "alpha-2": "HN",
1395
- "alpha-3": "HND",
1396
- "country-code": "340"
1397
- },
1398
- {
1399
- "name": "Hong Kong",
1400
- "alpha-2": "HK",
1401
- "alpha-3": "HKG",
1402
- "country-code": "344"
1403
- },
1404
- {
1405
- "name": "Hungary",
1406
- "alpha-2": "HU",
1407
- "alpha-3": "HUN",
1408
- "country-code": "348"
1409
- },
1410
- {
1411
- "name": "Iceland",
1412
- "alpha-2": "IS",
1413
- "alpha-3": "ISL",
1414
- "country-code": "352"
1415
- },
1416
- {
1417
- "name": "India",
1418
- "alpha-2": "IN",
1419
- "alpha-3": "IND",
1420
- "country-code": "356"
1421
- },
1422
- {
1423
- "name": "Indonesia",
1424
- "alpha-2": "ID",
1425
- "alpha-3": "IDN",
1426
- "country-code": "360"
1427
- },
1428
- {
1429
- "name": "Iran (Islamic Republic of)",
1430
- "alpha-2": "IR",
1431
- "alpha-3": "IRN",
1432
- "country-code": "364"
1433
- },
1434
- {
1435
- "name": "Iraq",
1436
- "alpha-2": "IQ",
1437
- "alpha-3": "IRQ",
1438
- "country-code": "368"
1439
- },
1440
- {
1441
- "name": "Ireland",
1442
- "alpha-2": "IE",
1443
- "alpha-3": "IRL",
1444
- "country-code": "372"
1445
- },
1446
- {
1447
- "name": "Isle of Man",
1448
- "alpha-2": "IM",
1449
- "alpha-3": "IMN",
1450
- "country-code": "833"
1451
- },
1452
- {
1453
- "name": "Israel",
1454
- "alpha-2": "IL",
1455
- "alpha-3": "ISR",
1456
- "country-code": "376"
1457
- },
1458
- {
1459
- "name": "Italy",
1460
- "alpha-2": "IT",
1461
- "alpha-3": "ITA",
1462
- "country-code": "380"
1463
- },
1464
- {
1465
- "name": "Jamaica",
1466
- "alpha-2": "JM",
1467
- "alpha-3": "JAM",
1468
- "country-code": "388"
1469
- },
1470
- {
1471
- "name": "Japan",
1472
- "alpha-2": "JP",
1473
- "alpha-3": "JPN",
1474
- "country-code": "392"
1475
- },
1476
- {
1477
- "name": "Jersey",
1478
- "alpha-2": "JE",
1479
- "alpha-3": "JEY",
1480
- "country-code": "832"
1481
- },
1482
- {
1483
- "name": "Jordan",
1484
- "alpha-2": "JO",
1485
- "alpha-3": "JOR",
1486
- "country-code": "400"
1487
- },
1488
- {
1489
- "name": "Kazakhstan",
1490
- "alpha-2": "KZ",
1491
- "alpha-3": "KAZ",
1492
- "country-code": "398"
1493
- },
1494
- {
1495
- "name": "Kenya",
1496
- "alpha-2": "KE",
1497
- "alpha-3": "KEN",
1498
- "country-code": "404"
1499
- },
1500
- {
1501
- "name": "Kiribati",
1502
- "alpha-2": "KI",
1503
- "alpha-3": "KIR",
1504
- "country-code": "296"
1505
- },
1506
- {
1507
- "name": "Korea (Democratic People's Republic of)",
1508
- "alpha-2": "KP",
1509
- "alpha-3": "PRK",
1510
- "country-code": "408"
1511
- },
1512
- {
1513
- "name": "Korea, Republic of",
1514
- "alpha-2": "KR",
1515
- "alpha-3": "KOR",
1516
- "country-code": "410"
1517
- },
1518
- {
1519
- "name": "Kuwait",
1520
- "alpha-2": "KW",
1521
- "alpha-3": "KWT",
1522
- "country-code": "414"
1523
- },
1524
- {
1525
- "name": "Kyrgyzstan",
1526
- "alpha-2": "KG",
1527
- "alpha-3": "KGZ",
1528
- "country-code": "417"
1529
- },
1530
- {
1531
- "name": "Lao People's Democratic Republic",
1532
- "alpha-2": "LA",
1533
- "alpha-3": "LAO",
1534
- "country-code": "418"
1535
- },
1536
- {
1537
- "name": "Latvia",
1538
- "alpha-2": "LV",
1539
- "alpha-3": "LVA",
1540
- "country-code": "428"
1541
- },
1542
- {
1543
- "name": "Lebanon",
1544
- "alpha-2": "LB",
1545
- "alpha-3": "LBN",
1546
- "country-code": "422"
1547
- },
1548
- {
1549
- "name": "Lesotho",
1550
- "alpha-2": "LS",
1551
- "alpha-3": "LSO",
1552
- "country-code": "426"
1553
- },
1554
- {
1555
- "name": "Liberia",
1556
- "alpha-2": "LR",
1557
- "alpha-3": "LBR",
1558
- "country-code": "430"
1559
- },
1560
- {
1561
- "name": "Libya",
1562
- "alpha-2": "LY",
1563
- "alpha-3": "LBY",
1564
- "country-code": "434"
1565
- },
1566
- {
1567
- "name": "Liechtenstein",
1568
- "alpha-2": "LI",
1569
- "alpha-3": "LIE",
1570
- "country-code": "438"
1571
- },
1572
- {
1573
- "name": "Lithuania",
1574
- "alpha-2": "LT",
1575
- "alpha-3": "LTU",
1576
- "country-code": "440"
1577
- },
1578
- {
1579
- "name": "Luxembourg",
1580
- "alpha-2": "LU",
1581
- "alpha-3": "LUX",
1582
- "country-code": "442"
1583
- },
1584
- {
1585
- "name": "Macao",
1586
- "alpha-2": "MO",
1587
- "alpha-3": "MAC",
1588
- "country-code": "446"
1589
- },
1590
- {
1591
- "name": "Madagascar",
1592
- "alpha-2": "MG",
1593
- "alpha-3": "MDG",
1594
- "country-code": "450"
1595
- },
1596
- {
1597
- "name": "Malawi",
1598
- "alpha-2": "MW",
1599
- "alpha-3": "MWI",
1600
- "country-code": "454"
1601
- },
1602
- {
1603
- "name": "Malaysia",
1604
- "alpha-2": "MY",
1605
- "alpha-3": "MYS",
1606
- "country-code": "458"
1607
- },
1608
- {
1609
- "name": "Maldives",
1610
- "alpha-2": "MV",
1611
- "alpha-3": "MDV",
1612
- "country-code": "462"
1613
- },
1614
- {
1615
- "name": "Mali",
1616
- "alpha-2": "ML",
1617
- "alpha-3": "MLI",
1618
- "country-code": "466"
1619
- },
1620
- {
1621
- "name": "Malta",
1622
- "alpha-2": "MT",
1623
- "alpha-3": "MLT",
1624
- "country-code": "470"
1625
- },
1626
- {
1627
- "name": "Marshall Islands",
1628
- "alpha-2": "MH",
1629
- "alpha-3": "MHL",
1630
- "country-code": "584"
1631
- },
1632
- {
1633
- "name": "Martinique",
1634
- "alpha-2": "MQ",
1635
- "alpha-3": "MTQ",
1636
- "country-code": "474"
1637
- },
1638
- {
1639
- "name": "Mauritania",
1640
- "alpha-2": "MR",
1641
- "alpha-3": "MRT",
1642
- "country-code": "478"
1643
- },
1644
- {
1645
- "name": "Mauritius",
1646
- "alpha-2": "MU",
1647
- "alpha-3": "MUS",
1648
- "country-code": "480"
1649
- },
1650
- {
1651
- "name": "Mayotte",
1652
- "alpha-2": "YT",
1653
- "alpha-3": "MYT",
1654
- "country-code": "175"
1655
- },
1656
- {
1657
- "name": "Mexico",
1658
- "alpha-2": "MX",
1659
- "alpha-3": "MEX",
1660
- "country-code": "484"
1661
- },
1662
- {
1663
- "name": "Micronesia (Federated States of)",
1664
- "alpha-2": "FM",
1665
- "alpha-3": "FSM",
1666
- "country-code": "583"
1667
- },
1668
- {
1669
- "name": "Moldova, Republic of",
1670
- "alpha-2": "MD",
1671
- "alpha-3": "MDA",
1672
- "country-code": "498"
1673
- },
1674
- {
1675
- "name": "Monaco",
1676
- "alpha-2": "MC",
1677
- "alpha-3": "MCO",
1678
- "country-code": "492"
1679
- },
1680
- {
1681
- "name": "Mongolia",
1682
- "alpha-2": "MN",
1683
- "alpha-3": "MNG",
1684
- "country-code": "496"
1685
- },
1686
- {
1687
- "name": "Montenegro",
1688
- "alpha-2": "ME",
1689
- "alpha-3": "MNE",
1690
- "country-code": "499"
1691
- },
1692
- {
1693
- "name": "Montserrat",
1694
- "alpha-2": "MS",
1695
- "alpha-3": "MSR",
1696
- "country-code": "500"
1697
- },
1698
- {
1699
- "name": "Morocco",
1700
- "alpha-2": "MA",
1701
- "alpha-3": "MAR",
1702
- "country-code": "504"
1703
- },
1704
- {
1705
- "name": "Mozambique",
1706
- "alpha-2": "MZ",
1707
- "alpha-3": "MOZ",
1708
- "country-code": "508"
1709
- },
1710
- {
1711
- "name": "Myanmar",
1712
- "alpha-2": "MM",
1713
- "alpha-3": "MMR",
1714
- "country-code": "104"
1715
- },
1716
- {
1717
- "name": "Namibia",
1718
- "alpha-2": "NA",
1719
- "alpha-3": "NAM",
1720
- "country-code": "516"
1721
- },
1722
- {
1723
- "name": "Nauru",
1724
- "alpha-2": "NR",
1725
- "alpha-3": "NRU",
1726
- "country-code": "520"
1727
- },
1728
- {
1729
- "name": "Nepal",
1730
- "alpha-2": "NP",
1731
- "alpha-3": "NPL",
1732
- "country-code": "524"
1733
- },
1734
- {
1735
- "name": "Netherlands",
1736
- "alpha-2": "NL",
1737
- "alpha-3": "NLD",
1738
- "country-code": "528"
1739
- },
1740
- {
1741
- "name": "New Caledonia",
1742
- "alpha-2": "NC",
1743
- "alpha-3": "NCL",
1744
- "country-code": "540"
1745
- },
1746
- {
1747
- "name": "New Zealand",
1748
- "alpha-2": "NZ",
1749
- "alpha-3": "NZL",
1750
- "country-code": "554"
1751
- },
1752
- {
1753
- "name": "Nicaragua",
1754
- "alpha-2": "NI",
1755
- "alpha-3": "NIC",
1756
- "country-code": "558"
1757
- },
1758
- {
1759
- "name": "Niger",
1760
- "alpha-2": "NE",
1761
- "alpha-3": "NER",
1762
- "country-code": "562"
1763
- },
1764
- {
1765
- "name": "Nigeria",
1766
- "alpha-2": "NG",
1767
- "alpha-3": "NGA",
1768
- "country-code": "566"
1769
- },
1770
- {
1771
- "name": "Niue",
1772
- "alpha-2": "NU",
1773
- "alpha-3": "NIU",
1774
- "country-code": "570"
1775
- },
1776
- {
1777
- "name": "Norfolk Island",
1778
- "alpha-2": "NF",
1779
- "alpha-3": "NFK",
1780
- "country-code": "574"
1781
- },
1782
- {
1783
- "name": "North Macedonia",
1784
- "alpha-2": "MK",
1785
- "alpha-3": "MKD",
1786
- "country-code": "807"
1787
- },
1788
- {
1789
- "name": "Northern Mariana Islands",
1790
- "alpha-2": "MP",
1791
- "alpha-3": "MNP",
1792
- "country-code": "580"
1793
- },
1794
- {
1795
- "name": "Norway",
1796
- "alpha-2": "NO",
1797
- "alpha-3": "NOR",
1798
- "country-code": "578"
1799
- },
1800
- {
1801
- "name": "Oman",
1802
- "alpha-2": "OM",
1803
- "alpha-3": "OMN",
1804
- "country-code": "512"
1805
- },
1806
- {
1807
- "name": "Pakistan",
1808
- "alpha-2": "PK",
1809
- "alpha-3": "PAK",
1810
- "country-code": "586"
1811
- },
1812
- {
1813
- "name": "Palau",
1814
- "alpha-2": "PW",
1815
- "alpha-3": "PLW",
1816
- "country-code": "585"
1817
- },
1818
- {
1819
- "name": "Palestine, State of",
1820
- "alpha-2": "PS",
1821
- "alpha-3": "PSE",
1822
- "country-code": "275"
1823
- },
1824
- {
1825
- "name": "Panama",
1826
- "alpha-2": "PA",
1827
- "alpha-3": "PAN",
1828
- "country-code": "591"
1829
- },
1830
- {
1831
- "name": "Papua New Guinea",
1832
- "alpha-2": "PG",
1833
- "alpha-3": "PNG",
1834
- "country-code": "598"
1835
- },
1836
- {
1837
- "name": "Paraguay",
1838
- "alpha-2": "PY",
1839
- "alpha-3": "PRY",
1840
- "country-code": "600"
1841
- },
1842
- {
1843
- "name": "Peru",
1844
- "alpha-2": "PE",
1845
- "alpha-3": "PER",
1846
- "country-code": "604"
1847
- },
1848
- {
1849
- "name": "Philippines",
1850
- "alpha-2": "PH",
1851
- "alpha-3": "PHL",
1852
- "country-code": "608"
1853
- },
1854
- {
1855
- "name": "Pitcairn",
1856
- "alpha-2": "PN",
1857
- "alpha-3": "PCN",
1858
- "country-code": "612"
1859
- },
1860
- {
1861
- "name": "Poland",
1862
- "alpha-2": "PL",
1863
- "alpha-3": "POL",
1864
- "country-code": "616"
1865
- },
1866
- {
1867
- "name": "Portugal",
1868
- "alpha-2": "PT",
1869
- "alpha-3": "PRT",
1870
- "country-code": "620"
1871
- },
1872
- {
1873
- "name": "Puerto Rico",
1874
- "alpha-2": "PR",
1875
- "alpha-3": "PRI",
1876
- "country-code": "630"
1877
- },
1878
- {
1879
- "name": "Qatar",
1880
- "alpha-2": "QA",
1881
- "alpha-3": "QAT",
1882
- "country-code": "634"
1883
- },
1884
- {
1885
- "name": "Réunion",
1886
- "alpha-2": "RE",
1887
- "alpha-3": "REU",
1888
- "country-code": "638"
1889
- },
1890
- {
1891
- "name": "Romania",
1892
- "alpha-2": "RO",
1893
- "alpha-3": "ROU",
1894
- "country-code": "642"
1895
- },
1896
- {
1897
- "name": "Russian Federation",
1898
- "alpha-2": "RU",
1899
- "alpha-3": "RUS",
1900
- "country-code": "643"
1901
- },
1902
- {
1903
- "name": "Rwanda",
1904
- "alpha-2": "RW",
1905
- "alpha-3": "RWA",
1906
- "country-code": "646"
1907
- },
1908
- {
1909
- "name": "Saint Barthélemy",
1910
- "alpha-2": "BL",
1911
- "alpha-3": "BLM",
1912
- "country-code": "652"
1913
- },
1914
- {
1915
- "name": "Saint Helena, Ascension and Tristan da Cunha",
1916
- "alpha-2": "SH",
1917
- "alpha-3": "SHN",
1918
- "country-code": "654"
1919
- },
1920
- {
1921
- "name": "Saint Kitts and Nevis",
1922
- "alpha-2": "KN",
1923
- "alpha-3": "KNA",
1924
- "country-code": "659"
1925
- },
1926
- {
1927
- "name": "Saint Lucia",
1928
- "alpha-2": "LC",
1929
- "alpha-3": "LCA",
1930
- "country-code": "662"
1931
- },
1932
- {
1933
- "name": "Saint Martin (French part)",
1934
- "alpha-2": "MF",
1935
- "alpha-3": "MAF",
1936
- "country-code": "663"
1937
- },
1938
- {
1939
- "name": "Saint Pierre and Miquelon",
1940
- "alpha-2": "PM",
1941
- "alpha-3": "SPM",
1942
- "country-code": "666"
1943
- },
1944
- {
1945
- "name": "Saint Vincent and the Grenadines",
1946
- "alpha-2": "VC",
1947
- "alpha-3": "VCT",
1948
- "country-code": "670"
1949
- },
1950
- {
1951
- "name": "Samoa",
1952
- "alpha-2": "WS",
1953
- "alpha-3": "WSM",
1954
- "country-code": "882"
1955
- },
1956
- {
1957
- "name": "San Marino",
1958
- "alpha-2": "SM",
1959
- "alpha-3": "SMR",
1960
- "country-code": "674"
1961
- },
1962
- {
1963
- "name": "Sao Tome and Principe",
1964
- "alpha-2": "ST",
1965
- "alpha-3": "STP",
1966
- "country-code": "678"
1967
- },
1968
- {
1969
- "name": "Saudi Arabia",
1970
- "alpha-2": "SA",
1971
- "alpha-3": "SAU",
1972
- "country-code": "682"
1973
- },
1974
- {
1975
- "name": "Senegal",
1976
- "alpha-2": "SN",
1977
- "alpha-3": "SEN",
1978
- "country-code": "686"
1979
- },
1980
- {
1981
- "name": "Serbia",
1982
- "alpha-2": "RS",
1983
- "alpha-3": "SRB",
1984
- "country-code": "688"
1985
- },
1986
- {
1987
- "name": "Seychelles",
1988
- "alpha-2": "SC",
1989
- "alpha-3": "SYC",
1990
- "country-code": "690"
1991
- },
1992
- {
1993
- "name": "Sierra Leone",
1994
- "alpha-2": "SL",
1995
- "alpha-3": "SLE",
1996
- "country-code": "694"
1997
- },
1998
- {
1999
- "name": "Singapore",
2000
- "alpha-2": "SG",
2001
- "alpha-3": "SGP",
2002
- "country-code": "702"
2003
- },
2004
- {
2005
- "name": "Sint Maarten (Dutch part)",
2006
- "alpha-2": "SX",
2007
- "alpha-3": "SXM",
2008
- "country-code": "534"
2009
- },
2010
- {
2011
- "name": "Slovakia",
2012
- "alpha-2": "SK",
2013
- "alpha-3": "SVK",
2014
- "country-code": "703"
2015
- },
2016
- {
2017
- "name": "Slovenia",
2018
- "alpha-2": "SI",
2019
- "alpha-3": "SVN",
2020
- "country-code": "705"
2021
- },
2022
- {
2023
- "name": "Solomon Islands",
2024
- "alpha-2": "SB",
2025
- "alpha-3": "SLB",
2026
- "country-code": "090"
2027
- },
2028
- {
2029
- "name": "Somalia",
2030
- "alpha-2": "SO",
2031
- "alpha-3": "SOM",
2032
- "country-code": "706"
2033
- },
2034
- {
2035
- "name": "South Africa",
2036
- "alpha-2": "ZA",
2037
- "alpha-3": "ZAF",
2038
- "country-code": "710"
2039
- },
2040
- {
2041
- "name": "South Georgia and the South Sandwich Islands",
2042
- "alpha-2": "GS",
2043
- "alpha-3": "SGS",
2044
- "country-code": "239"
2045
- },
2046
- {
2047
- "name": "South Sudan",
2048
- "alpha-2": "SS",
2049
- "alpha-3": "SSD",
2050
- "country-code": "728"
2051
- },
2052
- {
2053
- "name": "Spain",
2054
- "alpha-2": "ES",
2055
- "alpha-3": "ESP",
2056
- "country-code": "724"
2057
- },
2058
- {
2059
- "name": "Sri Lanka",
2060
- "alpha-2": "LK",
2061
- "alpha-3": "LKA",
2062
- "country-code": "144"
2063
- },
2064
- {
2065
- "name": "Sudan",
2066
- "alpha-2": "SD",
2067
- "alpha-3": "SDN",
2068
- "country-code": "729"
2069
- },
2070
- {
2071
- "name": "Suriname",
2072
- "alpha-2": "SR",
2073
- "alpha-3": "SUR",
2074
- "country-code": "740"
2075
- },
2076
- {
2077
- "name": "Svalbard and Jan Mayen",
2078
- "alpha-2": "SJ",
2079
- "alpha-3": "SJM",
2080
- "country-code": "744"
2081
- },
2082
- {
2083
- "name": "Sweden",
2084
- "alpha-2": "SE",
2085
- "alpha-3": "SWE",
2086
- "country-code": "752"
2087
- },
2088
- {
2089
- "name": "Switzerland",
2090
- "alpha-2": "CH",
2091
- "alpha-3": "CHE",
2092
- "country-code": "756"
2093
- },
2094
- {
2095
- "name": "Syrian Arab Republic",
2096
- "alpha-2": "SY",
2097
- "alpha-3": "SYR",
2098
- "country-code": "760"
2099
- },
2100
- {
2101
- "name": "Taiwan",
2102
- "alpha-2": "TW",
2103
- "alpha-3": "TWN",
2104
- "country-code": "158"
2105
- },
2106
- {
2107
- "name": "Tajikistan",
2108
- "alpha-2": "TJ",
2109
- "alpha-3": "TJK",
2110
- "country-code": "762"
2111
- },
2112
- {
2113
- "name": "Tanzania, United Republic of",
2114
- "alpha-2": "TZ",
2115
- "alpha-3": "TZA",
2116
- "country-code": "834"
2117
- },
2118
- {
2119
- "name": "Thailand",
2120
- "alpha-2": "TH",
2121
- "alpha-3": "THA",
2122
- "country-code": "764"
2123
- },
2124
- {
2125
- "name": "Timor-Leste",
2126
- "alpha-2": "TL",
2127
- "alpha-3": "TLS",
2128
- "country-code": "626"
2129
- },
2130
- {
2131
- "name": "Togo",
2132
- "alpha-2": "TG",
2133
- "alpha-3": "TGO",
2134
- "country-code": "768"
2135
- },
2136
- {
2137
- "name": "Tokelau",
2138
- "alpha-2": "TK",
2139
- "alpha-3": "TKL",
2140
- "country-code": "772"
2141
- },
2142
- {
2143
- "name": "Tonga",
2144
- "alpha-2": "TO",
2145
- "alpha-3": "TON",
2146
- "country-code": "776"
2147
- },
2148
- {
2149
- "name": "Trinidad and Tobago",
2150
- "alpha-2": "TT",
2151
- "alpha-3": "TTO",
2152
- "country-code": "780"
2153
- },
2154
- {
2155
- "name": "Tunisia",
2156
- "alpha-2": "TN",
2157
- "alpha-3": "TUN",
2158
- "country-code": "788"
2159
- },
2160
- {
2161
- "name": "Turkey",
2162
- "alpha-2": "TR",
2163
- "alpha-3": "TUR",
2164
- "country-code": "792"
2165
- },
2166
- {
2167
- "name": "Turkmenistan",
2168
- "alpha-2": "TM",
2169
- "alpha-3": "TKM",
2170
- "country-code": "795"
2171
- },
2172
- {
2173
- "name": "Turks and Caicos Islands",
2174
- "alpha-2": "TC",
2175
- "alpha-3": "TCA",
2176
- "country-code": "796"
2177
- },
2178
- {
2179
- "name": "Tuvalu",
2180
- "alpha-2": "TV",
2181
- "alpha-3": "TUV",
2182
- "country-code": "798"
2183
- },
2184
- {
2185
- "name": "Uganda",
2186
- "alpha-2": "UG",
2187
- "alpha-3": "UGA",
2188
- "country-code": "800"
2189
- },
2190
- {
2191
- "name": "Ukraine",
2192
- "alpha-2": "UA",
2193
- "alpha-3": "UKR",
2194
- "country-code": "804"
2195
- },
2196
- {
2197
- "name": "United Arab Emirates",
2198
- "alpha-2": "AE",
2199
- "alpha-3": "ARE",
2200
- "country-code": "784"
2201
- },
2202
- {
2203
- "name": "United Kingdom",
2204
- "alpha-2": "GB",
2205
- "alpha-3": "GBR",
2206
- "country-code": "826"
2207
- },
2208
- {
2209
- "name": "America",
2210
- "alpha-2": "US",
2211
- "alpha-3": "USA",
2212
- "country-code": "840"
2213
- },
2214
- {
2215
- "name": "United States Minor Outlying Islands",
2216
- "alpha-2": "UM",
2217
- "alpha-3": "UMI",
2218
- "country-code": "581"
2219
- },
2220
- {
2221
- "name": "Uruguay",
2222
- "alpha-2": "UY",
2223
- "alpha-3": "URY",
2224
- "country-code": "858"
2225
- },
2226
- {
2227
- "name": "Uzbekistan",
2228
- "alpha-2": "UZ",
2229
- "alpha-3": "UZB",
2230
- "country-code": "860"
2231
- },
2232
- {
2233
- "name": "Vanuatu",
2234
- "alpha-2": "VU",
2235
- "alpha-3": "VUT",
2236
- "country-code": "548"
2237
- },
2238
- {
2239
- "name": "Venezuela (Bolivarian Republic of)",
2240
- "alpha-2": "VE",
2241
- "alpha-3": "VEN",
2242
- "country-code": "862"
2243
- },
2244
- {
2245
- "name": "Vietnam",
2246
- "alpha-2": "VN",
2247
- "alpha-3": "VNM",
2248
- "country-code": "704"
2249
- },
2250
- {
2251
- "name": "Virgin Islands (British)",
2252
- "alpha-2": "VG",
2253
- "alpha-3": "VGB",
2254
- "country-code": "092"
2255
- },
2256
- {
2257
- "name": "Virgin Islands (U.S.)",
2258
- "alpha-2": "VI",
2259
- "alpha-3": "VIR",
2260
- "country-code": "850"
2261
- },
2262
- {
2263
- "name": "Wallis and Futuna",
2264
- "alpha-2": "WF",
2265
- "alpha-3": "WLF",
2266
- "country-code": "876"
2267
- },
2268
- {
2269
- "name": "Western Sahara",
2270
- "alpha-2": "EH",
2271
- "alpha-3": "ESH",
2272
- "country-code": "732"
2273
- },
2274
- {
2275
- "name": "Yemen",
2276
- "alpha-2": "YE",
2277
- "alpha-3": "YEM",
2278
- "country-code": "887"
2279
- },
2280
- {
2281
- "name": "Zambia",
2282
- "alpha-2": "ZM",
2283
- "alpha-3": "ZMB",
2284
- "country-code": "894"
2285
- },
2286
- {
2287
- "name": "Zimbabwe",
2288
- "alpha-2": "ZW",
2289
- "alpha-3": "ZWE",
2290
- "country-code": "716"
2291
- }
2292
- ];
2293
- const SearchTypes = {
2294
- WEB: "web",
2295
- IMAGE: "image",
2296
- VIDEO: "video",
2297
- NEWS: "news",
2298
- DISCOVER: "discover",
2299
- GOOGLE_NEWS: "googleNews"
2300
- };
2301
- Object.fromEntries(countries_default.map((c) => [c["alpha-3"], c["alpha-3"].toLowerCase()]));
2302
- const TIME_AXIS_DIMENSIONS = /* @__PURE__ */ new Set(["date", "hour"]);
2303
- const queryErrors = {
2304
- missingDateRange() {
2305
- return {
2306
- kind: "missing-date-range",
2307
- message: "Date range required: use .where(between(date, start, end)) or .where(and(gte(date, start), lte(date, end)))"
2308
- };
2309
- },
2310
- invalidRowLimit(value) {
2311
- return {
2312
- kind: "invalid-row-limit",
2313
- value,
2314
- message: `rowLimit must be a positive integer, got ${value}`
2315
- };
2316
- },
2317
- invalidStartRow(value) {
2318
- return {
2319
- kind: "invalid-start-row",
2320
- value,
2321
- message: `startRow must be a non-negative integer, got ${value}`
2322
- };
2323
- },
2324
- hourDimensionRequiresHourlyState() {
2325
- return {
2326
- kind: "invalid-data-state",
2327
- message: "hour dimension requires dataState: \"hourly_all\""
2328
- };
2329
- },
2330
- hourlyStateRequiresHourDimension() {
2331
- return {
2332
- kind: "invalid-data-state",
2333
- message: "dataState: \"hourly_all\" requires grouping by hour dimension"
2334
- };
2335
- },
2336
- byPropertyUnsupportedSearchType() {
2337
- return {
2338
- kind: "invalid-aggregation-type",
2339
- message: "aggregationType: \"byProperty\" is not supported for type \"discover\" or \"googleNews\""
2340
- };
2341
- },
2342
- byPropertyNotAllowedWithPage() {
2343
- return {
2344
- kind: "invalid-aggregation-type",
2345
- message: "aggregationType: \"byProperty\" is not allowed when grouping or filtering by page"
2346
- };
2347
- },
2348
- byNewsShowcaseRequiresSearchType() {
2349
- return {
2350
- kind: "invalid-aggregation-type",
2351
- message: "aggregationType: \"byNewsShowcasePanel\" requires type \"discover\" or \"googleNews\""
2352
- };
2353
- },
2354
- byNewsShowcaseNotAllowedWithPage() {
2355
- return {
2356
- kind: "invalid-aggregation-type",
2357
- message: "aggregationType: \"byNewsShowcasePanel\" is not allowed when grouping or filtering by page"
2358
- };
2359
- },
2360
- byNewsShowcaseRequiresShowcaseFilter() {
2361
- return {
2362
- kind: "invalid-aggregation-type",
2363
- message: "aggregationType: \"byNewsShowcasePanel\" requires a searchAppearance equals \"NEWS_SHOWCASE\" filter and no other searchAppearance filter"
2364
- };
2365
- },
2366
- invalidBuilderState(cause) {
2367
- return {
2368
- kind: "invalid-builder-state",
2369
- cause,
2370
- message: "Invalid state"
2371
- };
2372
- },
2373
- malformedFilterLeaf() {
2374
- return {
2375
- kind: "invalid-filter",
2376
- message: "Malformed filter: each filter leaf requires a string `dimension` and `operator`"
2377
- };
2378
- },
2379
- unsupportedCapability(capability, context) {
2380
- return {
2381
- kind: "unsupported-capability",
2382
- capability,
2383
- context,
2384
- message: `${context} requires ${capability} capability`
2385
- };
2386
- },
2387
- unresolvableDataset(dimensions, filterDims = []) {
2388
- const grouped = dimensions.filter((d) => !TIME_AXIS_DIMENSIONS.has(d));
2389
- const filtered = filterDims.filter((d) => !TIME_AXIS_DIMENSIONS.has(d));
2390
- return {
2391
- kind: "unresolvable-dataset",
2392
- dimensions,
2393
- filterDims,
2394
- message: `Cannot resolve a [${grouped.join(", ")}] breakdown filtered by [${filtered.join(", ")}] from stored data: these dimensions live in separate per-dimension tables. Only the live GSC API computes cross-dimension aggregates.`
2395
- };
2396
- }
2397
- };
2398
- var UnsupportedLogicalCapabilityError = class extends Error {
2399
- queryError;
2400
- constructor(capability, context) {
2401
- const error = queryErrors.unsupportedCapability(capability, context);
2402
- super(error.message);
2403
- this.name = "UnsupportedLogicalCapabilityError";
2404
- this.queryError = error;
2405
- }
2406
- };
2407
- var UnresolvableDatasetError = class extends Error {
2408
- queryError;
2409
- constructor(dimensions, filterDims = []) {
2410
- const error = queryErrors.unresolvableDataset(dimensions, filterDims);
2411
- super(error.message);
2412
- this.name = "UnresolvableDatasetError";
2413
- this.queryError = error;
2414
- }
2415
- };
2416
- function queryErrorToException(error) {
2417
- switch (error.kind) {
2418
- case "unsupported-capability": return new UnsupportedLogicalCapabilityError(error.capability, error.context);
2419
- case "unresolvable-dataset": return new UnresolvableDatasetError(error.dimensions, error.filterDims);
2420
- default: {
2421
- const exception = new Error(error.message);
2422
- if ("cause" in error && error.cause !== void 0) exception.cause = error.cause;
2423
- exception.queryError = error;
2424
- return exception;
2425
- }
2426
- }
2427
- }
2428
- const DATE_OPERATORS = [
2429
- "gte",
2430
- "gt",
2431
- "lte",
2432
- "lt",
2433
- "between"
2434
- ];
2435
- const METRIC_OPERATORS = [
2436
- "metricGte",
2437
- "metricGt",
2438
- "metricLte",
2439
- "metricLt",
2440
- "metricBetween"
2441
- ];
2442
- const SPECIAL_OPERATORS = ["topLevel"];
2443
- const QUERY_PARAMS = ["searchType"];
2444
- function isDateOperator(op) {
2445
- return DATE_OPERATORS.includes(op);
2446
- }
2447
- function isMetricOperator(op) {
2448
- return METRIC_OPERATORS.includes(op);
2449
- }
2450
- function isSpecialOperator(op) {
2451
- return SPECIAL_OPERATORS.includes(op);
2452
- }
2453
- function isQueryParam(value) {
2454
- return QUERY_PARAMS.includes(value);
2455
- }
2456
- new Set(Object.values(SearchTypes));
2457
- function extractSpecialFilters(filter) {
2458
- if (!filter || !Array.isArray(filter._filters)) return {};
2459
- let startDate;
2460
- let endDate;
2461
- let searchType;
2462
- const otherFilters = [];
2463
- const cleanedNestedGroups = [];
2464
- for (const f of filter._filters) if (f.dimension === "date" && isDateOperator(f.operator)) switch (f.operator) {
2465
- case "gte":
2466
- startDate = f.expression;
2467
- break;
2468
- case "gt":
2469
- startDate = addDays(f.expression, 1);
2470
- break;
2471
- case "lte":
2472
- endDate = f.expression;
2473
- break;
2474
- case "lt":
2475
- endDate = addDays(f.expression, -1);
2476
- break;
2477
- case "between":
2478
- startDate = f.expression;
2479
- endDate = f.expression2;
2480
- break;
2481
- }
2482
- else if (isQueryParam(f.dimension)) {
2483
- if (f.dimension === "searchType") searchType = f.expression;
2484
- } else if (isMetricOperator(f.operator) || isSpecialOperator(f.operator)) otherFilters.push(f);
2485
- else otherFilters.push(f);
2486
- if (filter._nestedGroups) for (const nested of filter._nestedGroups) {
2487
- const extracted = extractSpecialFilters(nested);
2488
- if (!startDate && extracted.startDate) startDate = extracted.startDate;
2489
- if (!endDate && extracted.endDate) endDate = extracted.endDate;
2490
- if (!searchType && extracted.searchType) searchType = extracted.searchType;
2491
- if (extracted.dimensionFilter) cleanedNestedGroups.push(extracted.dimensionFilter);
2492
- }
2493
- const dimensionFilter = otherFilters.length > 0 || cleanedNestedGroups.length > 0 ? {
2494
- ...filter,
2495
- _filters: otherFilters,
2496
- _nestedGroups: cleanedNestedGroups.length > 0 ? cleanedNestedGroups : void 0
2497
- } : void 0;
2498
- return {
2499
- startDate,
2500
- endDate,
2501
- searchType,
2502
- dimensionFilter
2503
- };
2504
- }
2505
- function resolveToBodyResult(state) {
2506
- const { startDate, endDate, searchType, dimensionFilter } = extractSpecialFilters(state.filter);
2507
- if (!startDate || !endDate) return err(queryErrors.missingDateRange());
2508
- const body = {
2509
- dimensions: state.dimensions,
2510
- startDate,
2511
- endDate
2512
- };
2513
- const resolvedType = state.searchType ?? searchType;
2514
- if (resolvedType) body.type = resolvedType;
2515
- if (state.rowLimit !== void 0) {
2516
- if (!Number.isInteger(state.rowLimit) || state.rowLimit < 1) return err(queryErrors.invalidRowLimit(state.rowLimit));
2517
- body.rowLimit = state.rowLimit;
2518
- }
2519
- if (state.startRow !== void 0) {
2520
- if (!Number.isInteger(state.startRow) || state.startRow < 0) return err(queryErrors.invalidStartRow(state.startRow));
2521
- if (state.startRow > 0) body.startRow = state.startRow;
2522
- }
2523
- const hasHour = state.dimensions?.includes("hour");
2524
- if (hasHour && state.dataState !== "hourly_all") return err(queryErrors.hourDimensionRequiresHourlyState());
2525
- if (state.dataState === "hourly_all" && !hasHour) return err(queryErrors.hourlyStateRequiresHourDimension());
2526
- if (state.dataState) body.dataState = state.dataState;
2527
- const filterGroups = resolveFilter(dimensionFilter);
2528
- if (filterGroups.length > 0) body.dimensionFilterGroups = filterGroups;
2529
- if (state.aggregationType) {
2530
- const groupsByPage = (body.dimensions ?? []).includes("page");
2531
- const apiLeafFilters = filterGroups.flatMap((g) => g.filters ?? []);
2532
- const filtersByPage = apiLeafFilters.some((f) => f.dimension === "page");
2533
- if (state.aggregationType === "byProperty") {
2534
- if (body.type === "discover" || body.type === "googleNews") return err(queryErrors.byPropertyUnsupportedSearchType());
2535
- if (groupsByPage || filtersByPage) return err(queryErrors.byPropertyNotAllowedWithPage());
2536
- }
2537
- if (state.aggregationType === "byNewsShowcasePanel") {
2538
- if (body.type !== "discover" && body.type !== "googleNews") return err(queryErrors.byNewsShowcaseRequiresSearchType());
2539
- if (groupsByPage || filtersByPage) return err(queryErrors.byNewsShowcaseNotAllowedWithPage());
2540
- const saFilters = apiLeafFilters.filter((f) => f.dimension === "searchAppearance");
2541
- const hasNewsShowcase = saFilters.some((f) => f.operator === "equals" && f.expression === "NEWS_SHOWCASE");
2542
- const hasOther = saFilters.some((f) => !(f.operator === "equals" && f.expression === "NEWS_SHOWCASE"));
2543
- if (!hasNewsShowcase || hasOther) return err(queryErrors.byNewsShowcaseRequiresShowcaseFilter());
2544
- }
2545
- body.aggregationType = state.aggregationType;
2546
- }
2547
- return ok(body);
2548
- }
2549
- function resolveToBody(state) {
2550
- return unwrapResult(resolveToBodyResult(state), queryErrorToException);
2551
- }
2552
- function isApiFilter(f) {
2553
- return !isMetricOperator(f.operator) && !isSpecialOperator(f.operator);
2554
- }
2555
- function resolveFilter(filter) {
2556
- if (!filter) return [];
2557
- const groups = [];
2558
- const groupType = filter._groupType ?? "and";
2559
- const apiFilters = filter._filters.filter(isApiFilter);
2560
- if (groupType === "or") {
2561
- if (apiFilters.length > 0) groups.push({
2562
- groupType: "or",
2563
- filters: apiFilters.map((f) => ({
2564
- dimension: f.dimension,
2565
- operator: f.operator,
2566
- expression: f.expression
2567
- }))
2568
- });
2569
- } else if (apiFilters.length > 0) groups.push({ filters: apiFilters.map((f) => ({
2570
- dimension: f.dimension,
2571
- operator: f.operator,
2572
- expression: f.expression
2573
- })) });
2574
- if (filter._nestedGroups) for (const nested of filter._nestedGroups) groups.push(...resolveFilter(nested));
2575
- return groups;
2576
- }
2577
684
  function rowWithMetricDefaults(row) {
2578
685
  return {
2579
686
  clicks: row.clicks ?? 0,
@@ -3063,21 +1170,6 @@ function formatGscPropertyCandidates(candidates) {
3063
1170
  return candidates.filter((c) => !!c).map((property) => `${property.siteUrl} (${property.permissionLevel})`).join(", ");
3064
1171
  }
3065
1172
  const URL_INSPECTION_EFFECTIVE_LIMIT = 1800;
3066
- const URL_PROTOCOL_RE = /^[a-z][a-z0-9+.-]*:\/\//i;
3067
- function normalizeUrl(input) {
3068
- if (!input) return input;
3069
- if (!URL_PROTOCOL_RE.test(input)) return input.startsWith("/") ? input : `/${input}`;
3070
- const parsed = safeParse(input);
3071
- if (!parsed) return input;
3072
- return `${parsed.pathname}${parsed.search}${parsed.hash}`;
3073
- }
3074
- function safeParse(input) {
3075
- try {
3076
- return new URL(input);
3077
- } catch {
3078
- return null;
3079
- }
3080
- }
3081
1173
  const FETCH_TIMEOUT_MS = 1e4;
3082
1174
  const COMMON_PATHS = ["/sitemap.xml", "/sitemap_index.xml"];
3083
1175
  const SITEMAP_DIRECTIVE_RE = /^Sitemap:\s*(\S+)/im;
@@ -3147,23 +1239,6 @@ async function fetchSitemapUrls(sitemapUrl, options = {}) {
3147
1239
  await visit(sitemapUrl, 0);
3148
1240
  return out;
3149
1241
  }
3150
- const SC_DOMAIN_RE = /^sc-domain:/;
3151
- const PROTOCOL_RE = /^https?:\/\//;
3152
- const NON_ID_RE = /[^\w.-]/g;
3153
- const TRAILING_UNDERSCORES_RE = /_+$/;
3154
- function encodeSiteId(siteUrl) {
3155
- return siteUrl.replace(SC_DOMAIN_RE, "d_").replace(PROTOCOL_RE, "h_").replace(NON_ID_RE, "_").replace(TRAILING_UNDERSCORES_RE, "");
3156
- }
3157
- function decodeSiteId(encoded) {
3158
- if (encoded.startsWith("d_")) return `sc-domain:${encoded.slice(2)}`;
3159
- if (encoded.startsWith("h_")) return `https://${encoded.slice(2)}/`;
3160
- return encoded;
3161
- }
3162
- function normalizeSiteUrl(siteUrl) {
3163
- if (siteUrl.startsWith("sc-domain:")) return siteUrl;
3164
- if (siteUrl.startsWith("http://") || siteUrl.startsWith("https://")) return siteUrl;
3165
- return `sc-domain:${siteUrl}`;
3166
- }
3167
1242
  function urlMatchKey(url) {
3168
1243
  const u = URL.parse(url);
3169
1244
  if (!u) return null;