regions-config 1.0.7 → 1.2.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/index.js CHANGED
@@ -1,25 +1,8 @@
1
1
  "use strict";
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
6
  var __export = (target, all) => {
24
7
  for (var name in all)
25
8
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -37,17 +20,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
20
  // src/index.ts
38
21
  var index_exports = {};
39
22
  __export(index_exports, {
23
+ COUNTRIES_TO_REDIRECT: () => COUNTRIES_TO_REDIRECT,
24
+ DefaultCurrencySchema: () => DefaultCurrencySchema,
40
25
  EUROPE_COUNTRIES: () => EUROPE_COUNTRIES,
41
26
  GROUP_REGIONS: () => GROUP_REGIONS,
27
+ MarketRegionEnum: () => MarketRegionEnum,
28
+ MarketRegionSchema: () => MarketRegionSchema,
29
+ RegionCodeSchema: () => RegionCodeSchema,
42
30
  RegionConfigSchema: () => RegionConfigSchema,
31
+ RegionCountryCodeEnum: () => RegionCountryCodeEnum,
32
+ RegionCountryCodeSchema: () => RegionCountryCodeSchema,
33
+ RegionNameEnum: () => RegionNameEnum,
34
+ RegionNameSchema: () => RegionNameSchema,
43
35
  US_CANADA_COUNTRIES: () => US_CANADA_COUNTRIES,
44
36
  US_CANADA_JAPAN_COUNTRIES: () => US_CANADA_JAPAN_COUNTRIES,
45
37
  WORLD_COUNTRIES: () => WORLD_COUNTRIES,
38
+ getAllRegions: () => getAllRegions,
39
+ getCountriesToRedirect: () => getCountriesToRedirect,
46
40
  getRegionConfig: () => getRegionConfig,
47
41
  getRegionConfigById: () => getRegionConfigById,
42
+ getRegionConfigByName: () => getRegionConfigByName,
48
43
  getRegionConfigByRegionCode: () => getRegionConfigByRegionCode,
49
44
  regionsConfig: () => regionsConfig_default,
50
45
  resolveDocumentTypeOptions: () => resolveDocumentTypeOptions,
46
+ resolvePostalCodeFormat: () => resolvePostalCodeFormat,
51
47
  validateRegion: () => validateRegion
52
48
  });
53
49
  module.exports = __toCommonJS(index_exports);
@@ -323,130 +319,53 @@ var WORLD_COUNTRIES = [
323
319
  271
324
320
  ];
325
321
 
326
- // src/domain/RegionConfigSchema.ts
327
- var import_zod = require("zod");
328
- var RegionConfigSchema = import_zod.z.strictObject({
329
- id: import_zod.z.number(),
330
- gtmId: import_zod.z.object({
331
- staging: import_zod.z.string().regex(/^GTM-[A-Z0-9]+$/, "Invalid GTM ID format"),
332
- production: import_zod.z.string().regex(/^GTM-[A-Z0-9]+$/, "Invalid GTM ID format")
333
- }),
334
- countriesToRedirect: import_zod.z.record(
335
- import_zod.z.string(),
336
- import_zod.z.object({
337
- label: import_zod.z.string(),
338
- countries: import_zod.z.array(
339
- import_zod.z.object({
340
- countryId: import_zod.z.string(),
341
- name: import_zod.z.string().optional()
342
- })
343
- )
344
- })
345
- ).optional(),
346
- regionUrls: import_zod.z.object({
347
- staging: import_zod.z.url(),
348
- production: import_zod.z.url()
349
- }).optional(),
350
- timeZone: import_zod.z.string(),
351
- regionsToGroup: import_zod.z.array(
352
- import_zod.z.object({
353
- priority: import_zod.z.enum(["high", "medium", "low"]),
354
- countries: import_zod.z.array(import_zod.z.number()),
355
- regionId: import_zod.z.number()
356
- })
357
- ).optional(),
358
- footer: import_zod.z.array(
359
- import_zod.z.object({
360
- href: import_zod.z.url(),
361
- label: import_zod.z.string()
362
- })
363
- ),
364
- documentTypeOptions: import_zod.z.array(
365
- import_zod.z.object({
366
- label: import_zod.z.string(),
367
- value: import_zod.z.string()
368
- })
369
- ),
370
- documentTypeOptionsByOrigin: import_zod.z.object({
371
- local: import_zod.z.array(import_zod.z.object({ label: import_zod.z.string(), value: import_zod.z.string() })),
372
- foreign: import_zod.z.array(import_zod.z.object({ label: import_zod.z.string(), value: import_zod.z.string() }))
373
- }).optional(),
374
- dateFormat: import_zod.z.string(),
375
- postalCodeFormat: import_zod.z.string().optional(),
376
- regionCode: import_zod.z.enum(["es-ES", "es-MX", "en-EU", "en-ROW", "it-IT", "pt-PT", "es-CO", "es-PE"]),
377
- paymentCardTypes: import_zod.z.array(
378
- import_zod.z.object({
379
- id: import_zod.z.number(),
380
- name: import_zod.z.string(),
381
- imagePath: import_zod.z.string()
382
- })
383
- ),
384
- webSitePath: import_zod.z.string().optional()
385
- });
386
-
387
- // src/regions/index.ts
388
- var regions_exports = {};
389
- __export(regions_exports, {
390
- comco: () => comco_default,
391
- comen: () => comen_default,
392
- comeneu: () => comeneu_default,
393
- commx: () => commx_default,
394
- compe: () => compe_default,
395
- es: () => es_default,
396
- it: () => it_default,
397
- pt: () => pt_default
398
- });
322
+ // src/utils/countriesToRedirect.ts
323
+ var COUNTRIES_TO_REDIRECT = {
324
+ es: {
325
+ label: "Spain",
326
+ countries: [{ countryId: "1", name: "Espa\xF1a" }]
327
+ },
328
+ pt: {
329
+ label: "Portugal",
330
+ countries: [
331
+ { countryId: "190", name: "Portugal" },
332
+ { countryId: "7", name: "Angola" },
333
+ { countryId: "36", name: "Brasil" },
334
+ { countryId: "42", name: "Cabo Verde" },
335
+ { countryId: "93", name: "Guin\xE9-Bissau" },
336
+ { countryId: "92", name: "Guin\xE9 Equatorial" },
337
+ { countryId: "165", name: "Mo\xE7ambique" },
338
+ { countryId: "212", name: "S\xE3o Tom\xE9 e Pr\xEDncipe" }
339
+ ]
340
+ },
341
+ it: {
342
+ label: "Italy",
343
+ countries: [{ countryId: "124", name: "Italia" }]
344
+ },
345
+ comco: {
346
+ label: "Colombia",
347
+ countries: [{ countryId: "52", name: "Colombia" }]
348
+ },
349
+ commx: {
350
+ label: "Mexico",
351
+ countries: [{ countryId: "158", name: "M\xE9xico" }]
352
+ },
353
+ compe: {
354
+ label: "Peru",
355
+ countries: [{ countryId: "187", name: "Per\xFA" }]
356
+ }
357
+ };
358
+ var getCountriesToRedirect = (currentSite) => Object.fromEntries(Object.entries(COUNTRIES_TO_REDIRECT).filter(([site]) => site !== currentSite));
399
359
 
400
- // src/regions/comco.json
360
+ // src/regions/comco.ts
401
361
  var comco_default = {
402
362
  id: 9,
403
- countriesToRedirect: {
404
- es: {
405
- label: "Espa\xF1a",
406
- countries: [
407
- {
408
- countryId: "1",
409
- name: "Espa\xF1a"
410
- }
411
- ]
412
- },
413
- pt: {
414
- label: "Portugal",
415
- countries: [
416
- {
417
- countryId: "190",
418
- name: "Portugal"
419
- }
420
- ]
421
- },
422
- commx: {
423
- label: "M\xE9xico",
424
- countries: [
425
- {
426
- countryId: "158",
427
- name: "M\xE9xico"
428
- }
429
- ]
430
- },
431
- compe: {
432
- label: "Per\xFA",
433
- countries: [
434
- {
435
- countryId: "187",
436
- name: "Per\xFA"
437
- }
438
- ]
439
- },
440
- it: {
441
- label: "Italia",
442
- countries: [
443
- {
444
- countryId: "124",
445
- name: "Italia"
446
- }
447
- ]
448
- }
449
- },
363
+ name: "colombia",
364
+ countryCode: "CO",
365
+ defaultCurrency: "USD",
366
+ marketRegion: "latam",
367
+ emoji: "\u{1F1E8}\u{1F1F4}",
368
+ countriesToRedirect: getCountriesToRedirect("comco"),
450
369
  regionUrls: {
451
370
  staging: "https://iatiglobal.iatidev.link/co/",
452
371
  production: "https://www.iatiglobal.com/co/"
@@ -455,18 +374,18 @@ var comco_default = {
455
374
  regionsToGroup: [
456
375
  {
457
376
  priority: "high",
458
- countries: "US_CANADA_COUNTRIES",
459
- regionId: "US_CANADA"
377
+ countries: US_CANADA_COUNTRIES,
378
+ regionId: GROUP_REGIONS.US_CANADA
460
379
  },
461
380
  {
462
381
  priority: "medium",
463
- countries: "WORLD_COUNTRIES",
464
- regionId: "WORLD"
382
+ countries: WORLD_COUNTRIES,
383
+ regionId: GROUP_REGIONS.WORLD
465
384
  },
466
385
  {
467
386
  priority: "low",
468
- countries: "EUROPE_COUNTRIES",
469
- regionId: "EUROPE"
387
+ countries: EUROPE_COUNTRIES,
388
+ regionId: GROUP_REGIONS.EUROPE
470
389
  }
471
390
  ],
472
391
  footer: [
@@ -523,93 +442,15 @@ var comco_default = {
523
442
  webSitePath: "/co"
524
443
  };
525
444
 
526
- // src/regions/comen.json
445
+ // src/regions/comen.ts
527
446
  var comen_default = {
528
447
  id: 5,
529
- countriesToRedirect: {
530
- es: {
531
- label: "Spain",
532
- countries: [
533
- {
534
- countryId: "1",
535
- name: "Espa\xF1a"
536
- }
537
- ]
538
- },
539
- comco: {
540
- label: "Colombia",
541
- countries: [
542
- {
543
- countryId: "52",
544
- name: "Colombia"
545
- }
546
- ]
547
- },
548
- commx: {
549
- label: "Mexico",
550
- countries: [
551
- {
552
- countryId: "158",
553
- name: "M\xE9xico"
554
- }
555
- ]
556
- },
557
- compe: {
558
- label: "Peru",
559
- countries: [
560
- {
561
- countryId: "187",
562
- name: "Per\xFA"
563
- }
564
- ]
565
- },
566
- pt: {
567
- label: "Portugal",
568
- countries: [
569
- {
570
- countryId: "190",
571
- name: "Portugal"
572
- },
573
- {
574
- countryId: "7",
575
- name: "Angola"
576
- },
577
- {
578
- countryId: "36",
579
- name: "Brasil"
580
- },
581
- {
582
- countryId: "42",
583
- name: "Cabo Verde"
584
- },
585
- {
586
- countryId: "93",
587
- name: "Guin\xE9-Bissau"
588
- },
589
- {
590
- countryId: "92",
591
- name: "Guin\xE9 Equatorial"
592
- },
593
- {
594
- countryId: "165",
595
- name: "Mo\xE7ambique"
596
- },
597
- {
598
- countryId: "212",
599
- name: "S\xE3o Tom\xE9 e Pr\xEDncipe"
600
- }
601
- ]
602
- },
603
- it: {
604
- label: "Italy",
605
- countries: [
606
- {
607
- countryId: "124",
608
- name: "Italia"
609
- }
610
- ]
611
- }
612
- },
448
+ name: "world",
449
+ countryCode: "WR",
450
+ defaultCurrency: "EUR",
451
+ marketRegion: "world",
452
+ emoji: "\u{1F310}",
453
+ countriesToRedirect: getCountriesToRedirect("comen"),
613
454
  regionUrls: {
614
455
  staging: "https://stg.iatiglobal.com/en/",
615
456
  production: "https://www.iatiglobal.com/en/"
@@ -618,18 +459,18 @@ var comen_default = {
618
459
  regionsToGroup: [
619
460
  {
620
461
  priority: "high",
621
- countries: "US_CANADA_JAPAN_COUNTRIES",
622
- regionId: "US_CANADA_JAPAN"
462
+ countries: US_CANADA_JAPAN_COUNTRIES,
463
+ regionId: GROUP_REGIONS.US_CANADA_JAPAN
623
464
  },
624
465
  {
625
466
  priority: "medium",
626
- countries: "WORLD_COUNTRIES",
627
- regionId: "REST_OF_THE_WORLD"
467
+ countries: WORLD_COUNTRIES,
468
+ regionId: GROUP_REGIONS.REST_OF_THE_WORLD
628
469
  },
629
470
  {
630
471
  priority: "low",
631
- countries: "EUROPE_COUNTRIES",
632
- regionId: "EUROPE"
472
+ countries: EUROPE_COUNTRIES,
473
+ regionId: GROUP_REGIONS.EUROPE
633
474
  }
634
475
  ],
635
476
  footer: [
@@ -701,65 +542,15 @@ var comen_default = {
701
542
  webSitePath: "/en"
702
543
  };
703
544
 
704
- // src/regions/comeneu.json
545
+ // src/regions/comeneu.ts
705
546
  var comeneu_default = {
706
547
  id: 6,
707
- countriesToRedirect: {
708
- es: {
709
- label: "Spain",
710
- countries: [
711
- {
712
- countryId: "1",
713
- name: "Espa\xF1a"
714
- }
715
- ]
716
- },
717
- comco: {
718
- label: "Colombia",
719
- countries: [
720
- {
721
- countryId: "52",
722
- name: "Colombia"
723
- }
724
- ]
725
- },
726
- commx: {
727
- label: "Mexico",
728
- countries: [
729
- {
730
- countryId: "158",
731
- name: "M\xE9xico"
732
- }
733
- ]
734
- },
735
- compe: {
736
- label: "Peru",
737
- countries: [
738
- {
739
- countryId: "187",
740
- name: "Per\xFA"
741
- }
742
- ]
743
- },
744
- pt: {
745
- label: "Portugal",
746
- countries: [
747
- {
748
- countryId: "190",
749
- name: "Portugal"
750
- }
751
- ]
752
- },
753
- it: {
754
- label: "Italy",
755
- countries: [
756
- {
757
- countryId: "124",
758
- name: "Italia"
759
- }
760
- ]
761
- }
762
- },
548
+ name: "europe",
549
+ countryCode: "EU",
550
+ defaultCurrency: "EUR",
551
+ marketRegion: "europe",
552
+ emoji: "\u{1F1EA}\u{1F1FA}",
553
+ countriesToRedirect: getCountriesToRedirect("comeneu"),
763
554
  regionUrls: {
764
555
  staging: "https://stg.iatiglobal.com/en-eu/",
765
556
  production: "https://www.iatiglobal.com/en-eu/"
@@ -768,18 +559,18 @@ var comeneu_default = {
768
559
  regionsToGroup: [
769
560
  {
770
561
  priority: "high",
771
- countries: "US_CANADA_JAPAN_COUNTRIES",
772
- regionId: "US_CANADA_JAPAN"
562
+ countries: US_CANADA_JAPAN_COUNTRIES,
563
+ regionId: GROUP_REGIONS.US_CANADA_JAPAN
773
564
  },
774
565
  {
775
566
  priority: "medium",
776
- countries: "WORLD_COUNTRIES",
777
- regionId: "REST_OF_THE_WORLD"
567
+ countries: WORLD_COUNTRIES,
568
+ regionId: GROUP_REGIONS.REST_OF_THE_WORLD
778
569
  },
779
570
  {
780
571
  priority: "low",
781
- countries: "EUROPE_COUNTRIES",
782
- regionId: "EUROPE"
572
+ countries: EUROPE_COUNTRIES,
573
+ regionId: GROUP_REGIONS.EUROPE
783
574
  }
784
575
  ],
785
576
  footer: [
@@ -851,56 +642,15 @@ var comeneu_default = {
851
642
  webSitePath: "/en-eu"
852
643
  };
853
644
 
854
- // src/regions/commx.json
645
+ // src/regions/commx.ts
855
646
  var commx_default = {
856
647
  id: 7,
857
- countriesToRedirect: {
858
- es: {
859
- label: "Espa\xF1a",
860
- countries: [
861
- {
862
- countryId: "1",
863
- name: "Espa\xF1a"
864
- }
865
- ]
866
- },
867
- pt: {
868
- label: "Portugal",
869
- countries: [
870
- {
871
- countryId: "190",
872
- name: "Portugal"
873
- }
874
- ]
875
- },
876
- comco: {
877
- label: "Colombia",
878
- countries: [
879
- {
880
- countryId: "52",
881
- name: "Colombia"
882
- }
883
- ]
884
- },
885
- compe: {
886
- label: "Per\xFA",
887
- countries: [
888
- {
889
- countryId: "187",
890
- name: "Per\xFA"
891
- }
892
- ]
893
- },
894
- it: {
895
- label: "Italia",
896
- countries: [
897
- {
898
- countryId: "124",
899
- name: "Italia"
900
- }
901
- ]
902
- }
903
- },
648
+ name: "mexico",
649
+ countryCode: "MX",
650
+ defaultCurrency: "USD",
651
+ marketRegion: "latam",
652
+ emoji: "\u{1F1F2}\u{1F1FD}",
653
+ countriesToRedirect: getCountriesToRedirect("commx"),
904
654
  regionUrls: {
905
655
  staging: "https://stg.iatiglobal.com/mx/",
906
656
  production: "https://www.iatiglobal.com/mx/"
@@ -909,18 +659,18 @@ var commx_default = {
909
659
  regionsToGroup: [
910
660
  {
911
661
  priority: "high",
912
- countries: "US_CANADA_COUNTRIES",
913
- regionId: "US_CANADA"
662
+ countries: US_CANADA_COUNTRIES,
663
+ regionId: GROUP_REGIONS.US_CANADA
914
664
  },
915
665
  {
916
666
  priority: "medium",
917
- countries: "WORLD_COUNTRIES",
918
- regionId: "WORLD"
667
+ countries: WORLD_COUNTRIES,
668
+ regionId: GROUP_REGIONS.WORLD
919
669
  },
920
670
  {
921
671
  priority: "low",
922
- countries: "EUROPE_COUNTRIES",
923
- regionId: "EUROPE"
672
+ countries: EUROPE_COUNTRIES,
673
+ regionId: GROUP_REGIONS.EUROPE
924
674
  }
925
675
  ],
926
676
  footer: [
@@ -977,56 +727,15 @@ var commx_default = {
977
727
  webSitePath: "/mx"
978
728
  };
979
729
 
980
- // src/regions/compe.json
730
+ // src/regions/compe.ts
981
731
  var compe_default = {
982
732
  id: 8,
983
- countriesToRedirect: {
984
- es: {
985
- label: "Espa\xF1a",
986
- countries: [
987
- {
988
- countryId: "1",
989
- name: "Espa\xF1a"
990
- }
991
- ]
992
- },
993
- pt: {
994
- label: "Portugal",
995
- countries: [
996
- {
997
- countryId: "190",
998
- name: "Portugal"
999
- }
1000
- ]
1001
- },
1002
- comco: {
1003
- label: "Colombia",
1004
- countries: [
1005
- {
1006
- countryId: "52",
1007
- name: "Colombia"
1008
- }
1009
- ]
1010
- },
1011
- commx: {
1012
- label: "M\xE9xico",
1013
- countries: [
1014
- {
1015
- countryId: "158",
1016
- name: "M\xE9xico"
1017
- }
1018
- ]
1019
- },
1020
- it: {
1021
- label: "Italia",
1022
- countries: [
1023
- {
1024
- countryId: "124",
1025
- name: "Italia"
1026
- }
1027
- ]
1028
- }
1029
- },
733
+ name: "peru",
734
+ countryCode: "PE",
735
+ defaultCurrency: "USD",
736
+ marketRegion: "latam",
737
+ emoji: "\u{1F1F5}\u{1F1EA}",
738
+ countriesToRedirect: getCountriesToRedirect("compe"),
1030
739
  regionUrls: {
1031
740
  staging: "https://stg.iatiglobal.com/pe/",
1032
741
  production: "https://www.iatiglobal.com/pe/"
@@ -1035,18 +744,18 @@ var compe_default = {
1035
744
  regionsToGroup: [
1036
745
  {
1037
746
  priority: "high",
1038
- countries: "US_CANADA_COUNTRIES",
1039
- regionId: "US_CANADA"
747
+ countries: US_CANADA_COUNTRIES,
748
+ regionId: GROUP_REGIONS.US_CANADA
1040
749
  },
1041
750
  {
1042
751
  priority: "medium",
1043
- countries: "WORLD_COUNTRIES",
1044
- regionId: "WORLD"
752
+ countries: WORLD_COUNTRIES,
753
+ regionId: GROUP_REGIONS.WORLD
1045
754
  },
1046
755
  {
1047
756
  priority: "low",
1048
- countries: "EUROPE_COUNTRIES",
1049
- regionId: "EUROPE"
757
+ countries: EUROPE_COUNTRIES,
758
+ regionId: GROUP_REGIONS.EUROPE
1050
759
  }
1051
760
  ],
1052
761
  footer: [
@@ -1103,56 +812,15 @@ var compe_default = {
1103
812
  webSitePath: "/pe"
1104
813
  };
1105
814
 
1106
- // src/regions/es.json
815
+ // src/regions/es.ts
1107
816
  var es_default = {
1108
817
  id: 1,
1109
- countriesToRedirect: {
1110
- comco: {
1111
- label: "Colombia",
1112
- countries: [
1113
- {
1114
- countryId: "52",
1115
- name: "Colombia"
1116
- }
1117
- ]
1118
- },
1119
- commx: {
1120
- label: "M\xE9xico",
1121
- countries: [
1122
- {
1123
- countryId: "158",
1124
- name: "M\xE9xico"
1125
- }
1126
- ]
1127
- },
1128
- compe: {
1129
- label: "Per\xFA",
1130
- countries: [
1131
- {
1132
- countryId: "187",
1133
- name: "Per\xFA"
1134
- }
1135
- ]
1136
- },
1137
- pt: {
1138
- label: "Portugal",
1139
- countries: [
1140
- {
1141
- countryId: "190",
1142
- name: "Portugal"
1143
- }
1144
- ]
1145
- },
1146
- it: {
1147
- label: "Italia",
1148
- countries: [
1149
- {
1150
- countryId: "124",
1151
- name: "Italia"
1152
- }
1153
- ]
1154
- }
1155
- },
818
+ name: "spain",
819
+ countryCode: "ES",
820
+ defaultCurrency: "EUR",
821
+ marketRegion: "europe",
822
+ emoji: "\u{1F1EA}\u{1F1F8}",
823
+ countriesToRedirect: getCountriesToRedirect("es"),
1156
824
  regionUrls: {
1157
825
  staging: "https://stg.iatiseguros.com",
1158
826
  production: "https://www.iatiseguros.com"
@@ -1161,18 +829,18 @@ var es_default = {
1161
829
  regionsToGroup: [
1162
830
  {
1163
831
  priority: "high",
1164
- countries: "US_CANADA_JAPAN_COUNTRIES",
1165
- regionId: "US_CANADA_JAPAN"
832
+ countries: US_CANADA_JAPAN_COUNTRIES,
833
+ regionId: GROUP_REGIONS.US_CANADA_JAPAN
1166
834
  },
1167
835
  {
1168
836
  priority: "medium",
1169
- countries: "WORLD_COUNTRIES",
1170
- regionId: "REST_OF_THE_WORLD"
837
+ countries: WORLD_COUNTRIES,
838
+ regionId: GROUP_REGIONS.REST_OF_THE_WORLD
1171
839
  },
1172
840
  {
1173
841
  priority: "low",
1174
- countries: "EUROPE_COUNTRIES",
1175
- regionId: "EUROPE"
842
+ countries: EUROPE_COUNTRIES,
843
+ regionId: GROUP_REGIONS.EUROPE
1176
844
  }
1177
845
  ],
1178
846
  footer: [
@@ -1265,56 +933,15 @@ var es_default = {
1265
933
  ]
1266
934
  };
1267
935
 
1268
- // src/regions/it.json
936
+ // src/regions/it.ts
1269
937
  var it_default = {
1270
938
  id: 10,
1271
- countriesToRedirect: {
1272
- es: {
1273
- label: "Spagna",
1274
- countries: [
1275
- {
1276
- countryId: "1",
1277
- name: "Espa\xF1a"
1278
- }
1279
- ]
1280
- },
1281
- pt: {
1282
- label: "Portogallo",
1283
- countries: [
1284
- {
1285
- countryId: "190",
1286
- name: "Portugal"
1287
- }
1288
- ]
1289
- },
1290
- commx: {
1291
- label: "Messico",
1292
- countries: [
1293
- {
1294
- countryId: "158",
1295
- name: "M\xE9xico"
1296
- }
1297
- ]
1298
- },
1299
- compe: {
1300
- label: "Per\xF9",
1301
- countries: [
1302
- {
1303
- countryId: "187",
1304
- name: "Per\xFA"
1305
- }
1306
- ]
1307
- },
1308
- comco: {
1309
- label: "Colombia",
1310
- countries: [
1311
- {
1312
- countryId: "52",
1313
- name: "Colombia"
1314
- }
1315
- ]
1316
- }
1317
- },
939
+ name: "italy",
940
+ countryCode: "IT",
941
+ defaultCurrency: "EUR",
942
+ marketRegion: "europe",
943
+ emoji: "\u{1F1EE}\u{1F1F9}",
944
+ countriesToRedirect: getCountriesToRedirect("it"),
1318
945
  regionUrls: {
1319
946
  staging: "https://stg.iatiassicurazioni.it",
1320
947
  production: "https://www.iatiassicurazioni.it"
@@ -1323,18 +950,18 @@ var it_default = {
1323
950
  regionsToGroup: [
1324
951
  {
1325
952
  priority: "high",
1326
- countries: "US_CANADA_JAPAN_COUNTRIES",
1327
- regionId: "US_CANADA_JAPAN"
953
+ countries: US_CANADA_JAPAN_COUNTRIES,
954
+ regionId: GROUP_REGIONS.US_CANADA_JAPAN
1328
955
  },
1329
956
  {
1330
957
  priority: "medium",
1331
- countries: "WORLD_COUNTRIES",
1332
- regionId: "REST_OF_THE_WORLD"
958
+ countries: WORLD_COUNTRIES,
959
+ regionId: GROUP_REGIONS.REST_OF_THE_WORLD
1333
960
  },
1334
961
  {
1335
962
  priority: "low",
1336
- countries: "EUROPE_COUNTRIES",
1337
- regionId: "EUROPE"
963
+ countries: EUROPE_COUNTRIES,
964
+ regionId: GROUP_REGIONS.EUROPE
1338
965
  }
1339
966
  ],
1340
967
  footer: [
@@ -1401,56 +1028,15 @@ var it_default = {
1401
1028
  ]
1402
1029
  };
1403
1030
 
1404
- // src/regions/pt.json
1031
+ // src/regions/pt.ts
1405
1032
  var pt_default = {
1406
1033
  id: 2,
1407
- countriesToRedirect: {
1408
- es: {
1409
- label: "Espanha",
1410
- countries: [
1411
- {
1412
- countryId: "1",
1413
- name: "Espa\xF1a"
1414
- }
1415
- ]
1416
- },
1417
- comco: {
1418
- label: "Col\xF4mbia",
1419
- countries: [
1420
- {
1421
- countryId: "52",
1422
- name: "Colombia"
1423
- }
1424
- ]
1425
- },
1426
- commx: {
1427
- label: "M\xE9xico",
1428
- countries: [
1429
- {
1430
- countryId: "158",
1431
- name: "M\xE9xico"
1432
- }
1433
- ]
1434
- },
1435
- compe: {
1436
- label: "Peru",
1437
- countries: [
1438
- {
1439
- countryId: "187",
1440
- name: "Per\xFA"
1441
- }
1442
- ]
1443
- },
1444
- it: {
1445
- label: "It\xE1lia",
1446
- countries: [
1447
- {
1448
- countryId: "124",
1449
- name: "Italia"
1450
- }
1451
- ]
1452
- }
1453
- },
1034
+ name: "portugal",
1035
+ countryCode: "PT",
1036
+ defaultCurrency: "EUR",
1037
+ marketRegion: "europe",
1038
+ emoji: "\u{1F1F5}\u{1F1F9}",
1039
+ countriesToRedirect: getCountriesToRedirect("pt"),
1454
1040
  regionUrls: {
1455
1041
  staging: "https://stg.iatiseguros.pt",
1456
1042
  production: "https://www.iatiseguros.pt"
@@ -1459,18 +1045,18 @@ var pt_default = {
1459
1045
  regionsToGroup: [
1460
1046
  {
1461
1047
  priority: "high",
1462
- countries: "US_CANADA_JAPAN_COUNTRIES",
1463
- regionId: "US_CANADA_JAPAN"
1048
+ countries: US_CANADA_JAPAN_COUNTRIES,
1049
+ regionId: GROUP_REGIONS.US_CANADA_JAPAN
1464
1050
  },
1465
1051
  {
1466
1052
  priority: "medium",
1467
- countries: "WORLD_COUNTRIES",
1468
- regionId: "REST_OF_THE_WORLD"
1053
+ countries: WORLD_COUNTRIES,
1054
+ regionId: GROUP_REGIONS.REST_OF_THE_WORLD
1469
1055
  },
1470
1056
  {
1471
1057
  priority: "low",
1472
- countries: "EUROPE_COUNTRIES",
1473
- regionId: "EUROPE"
1058
+ countries: EUROPE_COUNTRIES,
1059
+ regionId: GROUP_REGIONS.EUROPE
1474
1060
  }
1475
1061
  ],
1476
1062
  footer: [
@@ -1556,36 +1142,113 @@ var pt_default = {
1556
1142
  ]
1557
1143
  };
1558
1144
 
1559
- // src/regionsConfig.ts
1560
- var resolveRegion = (region) => {
1561
- var _a;
1562
- const resolved = __spreadProps(__spreadValues({}, region), {
1563
- regionsToGroup: (_a = region.regionsToGroup) == null ? void 0 : _a.map((group) => __spreadProps(__spreadValues({}, group), {
1564
- countries: (() => {
1565
- switch (group.countries) {
1566
- case "US_CANADA_JAPAN_COUNTRIES":
1567
- return US_CANADA_JAPAN_COUNTRIES;
1568
- case "WORLD_COUNTRIES":
1569
- return WORLD_COUNTRIES;
1570
- case "EUROPE_COUNTRIES":
1571
- return EUROPE_COUNTRIES;
1572
- case "US_CANADA_COUNTRIES":
1573
- return US_CANADA_COUNTRIES;
1574
- default:
1575
- return [];
1576
- }
1577
- })(),
1578
- regionId: GROUP_REGIONS[group.regionId]
1579
- }))
1580
- });
1581
- return RegionConfigSchema.parse(resolved);
1145
+ // src/regions/index.ts
1146
+ var regions = {
1147
+ comco: comco_default,
1148
+ comen: comen_default,
1149
+ comeneu: comeneu_default,
1150
+ commx: commx_default,
1151
+ compe: compe_default,
1152
+ es: es_default,
1153
+ it: it_default,
1154
+ pt: pt_default
1582
1155
  };
1583
- var regionsConfig = Object.entries(regions_exports).reduce((acc, [key, value]) => {
1584
- acc[key] = resolveRegion(value);
1156
+
1157
+ // src/domain/RegionConfigSchema.ts
1158
+ var import_zod = require("zod");
1159
+ var uniqueSorted = (values) => {
1160
+ const unique = [...new Set(values)].sort((a, b) => a.localeCompare(b));
1161
+ const [first, ...rest] = unique;
1162
+ if (first === void 0) {
1163
+ throw new Error("At least one value is required");
1164
+ }
1165
+ return [first, ...rest];
1166
+ };
1167
+ var RegionNameSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.name)));
1168
+ var RegionCountryCodeSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.countryCode)));
1169
+ var regionEmojiSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.emoji)));
1170
+ var RegionCodeSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.regionCode)));
1171
+ var MarketRegionSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.marketRegion)));
1172
+ var DefaultCurrencySchema = import_zod.z.enum(
1173
+ uniqueSorted(Object.values(regions).map((region) => region.defaultCurrency))
1174
+ );
1175
+ var RegionNameEnum = RegionNameSchema.enum;
1176
+ var RegionCountryCodeEnum = RegionCountryCodeSchema.enum;
1177
+ var MarketRegionEnum = MarketRegionSchema.enum;
1178
+ var RegionConfigSchema = import_zod.z.strictObject({
1179
+ id: import_zod.z.number(),
1180
+ gtmId: import_zod.z.object({
1181
+ staging: import_zod.z.string().regex(/^GTM-[A-Z0-9]+$/, "Invalid GTM ID format"),
1182
+ production: import_zod.z.string().regex(/^GTM-[A-Z0-9]+$/, "Invalid GTM ID format")
1183
+ }),
1184
+ countriesToRedirect: import_zod.z.record(
1185
+ import_zod.z.string(),
1186
+ import_zod.z.object({
1187
+ label: import_zod.z.string(),
1188
+ countries: import_zod.z.array(
1189
+ import_zod.z.object({
1190
+ countryId: import_zod.z.string(),
1191
+ name: import_zod.z.string().optional()
1192
+ })
1193
+ )
1194
+ })
1195
+ ).optional(),
1196
+ regionUrls: import_zod.z.object({
1197
+ staging: import_zod.z.url(),
1198
+ production: import_zod.z.url()
1199
+ }).optional(),
1200
+ timeZone: import_zod.z.string(),
1201
+ regionsToGroup: import_zod.z.array(
1202
+ import_zod.z.object({
1203
+ priority: import_zod.z.enum(["high", "medium", "low"]),
1204
+ countries: import_zod.z.array(import_zod.z.number()),
1205
+ regionId: import_zod.z.number()
1206
+ })
1207
+ ).optional(),
1208
+ footer: import_zod.z.array(
1209
+ import_zod.z.object({
1210
+ href: import_zod.z.url(),
1211
+ label: import_zod.z.string()
1212
+ })
1213
+ ),
1214
+ documentTypeOptions: import_zod.z.array(
1215
+ import_zod.z.object({
1216
+ label: import_zod.z.string(),
1217
+ value: import_zod.z.string()
1218
+ })
1219
+ ),
1220
+ documentTypeOptionsByOrigin: import_zod.z.object({
1221
+ local: import_zod.z.array(import_zod.z.object({ label: import_zod.z.string(), value: import_zod.z.string() })),
1222
+ foreign: import_zod.z.array(import_zod.z.object({ label: import_zod.z.string(), value: import_zod.z.string() }))
1223
+ }).optional(),
1224
+ dateFormat: import_zod.z.string(),
1225
+ postalCodeFormat: import_zod.z.string().optional(),
1226
+ regionCode: RegionCodeSchema,
1227
+ paymentCardTypes: import_zod.z.array(
1228
+ import_zod.z.object({
1229
+ id: import_zod.z.number(),
1230
+ name: import_zod.z.string(),
1231
+ imagePath: import_zod.z.string()
1232
+ })
1233
+ ),
1234
+ webSitePath: import_zod.z.string().optional(),
1235
+ name: RegionNameSchema,
1236
+ countryCode: RegionCountryCodeSchema,
1237
+ defaultCurrency: DefaultCurrencySchema,
1238
+ marketRegion: MarketRegionSchema,
1239
+ emoji: regionEmojiSchema
1240
+ });
1241
+
1242
+ // src/regionsConfig.ts
1243
+ var regionsConfig = Object.entries(regions).reduce((acc, [key, value]) => {
1244
+ acc[key] = RegionConfigSchema.parse(value);
1585
1245
  return acc;
1586
1246
  }, {});
1587
1247
  var regionsConfig_default = regionsConfig;
1588
1248
 
1249
+ // src/utils/getAllRegions.ts
1250
+ var getAllRegions = () => Object.values(regionsConfig_default);
1251
+
1589
1252
  // src/utils/getRegionConfig.ts
1590
1253
  var getRegionConfig = (name) => {
1591
1254
  const key = name.replace(/[/-]/g, "").toLowerCase();
@@ -1599,6 +1262,12 @@ var getRegionConfigById = (id) => {
1599
1262
  return region;
1600
1263
  };
1601
1264
 
1265
+ // src/utils/getRegionConfigByName.ts
1266
+ var getRegionConfigByName = (name) => {
1267
+ const normalized = name.trim().toLowerCase();
1268
+ return Object.values(regionsConfig_default).find((region) => region.name.trim().toLowerCase() === normalized);
1269
+ };
1270
+
1602
1271
  // src/utils/getRegionConfigByRegionCode.ts
1603
1272
  var getRegionConfigByRegionCode = (regionCode) => {
1604
1273
  const region = Object.values(regionsConfig_default).find((region2) => region2.regionCode === regionCode);
@@ -1614,6 +1283,14 @@ var resolveDocumentTypeOptions = (documentTypeOptions, documentTypeOptionsByOrig
1614
1283
  return isLocal ? documentTypeOptionsByOrigin.local : documentTypeOptionsByOrigin.foreign;
1615
1284
  };
1616
1285
 
1286
+ // src/utils/resolvePostalCodeFormat.ts
1287
+ var resolvePostalCodeFormat = (postalCodeFormat, originCountryId, siteCountryId) => {
1288
+ if (!postalCodeFormat) return void 0;
1289
+ if (!originCountryId || !siteCountryId) return void 0;
1290
+ const isLocal = String(originCountryId) === String(siteCountryId);
1291
+ return isLocal ? postalCodeFormat : void 0;
1292
+ };
1293
+
1617
1294
  // src/validators/validateRegion.ts
1618
1295
  var validateRegion = (region) => {
1619
1296
  if (!Object.values(regionsConfig_default).some((regionConfig) => regionConfig.regionCode === region)) {
@@ -1622,16 +1299,29 @@ var validateRegion = (region) => {
1622
1299
  };
1623
1300
  // Annotate the CommonJS export names for ESM import in node:
1624
1301
  0 && (module.exports = {
1302
+ COUNTRIES_TO_REDIRECT,
1303
+ DefaultCurrencySchema,
1625
1304
  EUROPE_COUNTRIES,
1626
1305
  GROUP_REGIONS,
1306
+ MarketRegionEnum,
1307
+ MarketRegionSchema,
1308
+ RegionCodeSchema,
1627
1309
  RegionConfigSchema,
1310
+ RegionCountryCodeEnum,
1311
+ RegionCountryCodeSchema,
1312
+ RegionNameEnum,
1313
+ RegionNameSchema,
1628
1314
  US_CANADA_COUNTRIES,
1629
1315
  US_CANADA_JAPAN_COUNTRIES,
1630
1316
  WORLD_COUNTRIES,
1317
+ getAllRegions,
1318
+ getCountriesToRedirect,
1631
1319
  getRegionConfig,
1632
1320
  getRegionConfigById,
1321
+ getRegionConfigByName,
1633
1322
  getRegionConfigByRegionCode,
1634
1323
  regionsConfig,
1635
1324
  resolveDocumentTypeOptions,
1325
+ resolvePostalCodeFormat,
1636
1326
  validateRegion
1637
1327
  });