regions-config 1.4.0 → 1.5.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/README.md +41 -11
- package/dist/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +36 -0
- package/dist/index.mjs +32 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,20 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Paquete de configuración de regiones para las aplicaciones de IATI. Proporciona la configuración completa de cada región (zona horaria, tipos de documento, métodos de pago, links de footer, países a redirigir, etc.) junto con utilidades tipadas para acceder a ella.
|
|
4
4
|
|
|
5
|
-
> ℹ️ Esta config la consumen los proyectos de purchase-funnel-widget y purchase-funnel (iati-backoffice-monorepo)
|
|
5
|
+
> ℹ️ Esta config la consumen los proyectos de purchase-funnel-widget y purchase-funnel (iati-backoffice-monorepo), y las webs de iati-websites-monorepo
|
|
6
6
|
|
|
7
7
|
## Regiones disponibles
|
|
8
8
|
|
|
9
|
-
| Clave | `regionCode` | Descripción |
|
|
10
|
-
| --------- | ------------ | ----------------------------- |
|
|
11
|
-
| `es` | `es-ES` | España |
|
|
12
|
-
| `commx` | `es-MX` | México |
|
|
13
|
-
| `comeneu` | `en-EU` | Internacional Europa (EN) |
|
|
14
|
-
| `comen` | `en-ROW` | Internacional resto del mundo |
|
|
15
|
-
| `it` | `it-IT` | Italia |
|
|
16
|
-
| `pt` | `pt-PT` | Portugal |
|
|
17
|
-
| `comco` | `es-CO` | Colombia |
|
|
18
|
-
| `compe` | `es-PE` | Perú |
|
|
9
|
+
| Clave | `regionCode` | `websiteAppName` | Descripción |
|
|
10
|
+
| --------- | ------------ | ---------------- | ----------------------------- |
|
|
11
|
+
| `es` | `es-ES` | `spain` | España |
|
|
12
|
+
| `commx` | `es-MX` | `mexico` | México |
|
|
13
|
+
| `comeneu` | `en-EU` | `eu` | Internacional Europa (EN) |
|
|
14
|
+
| `comen` | `en-ROW` | `row` | Internacional resto del mundo |
|
|
15
|
+
| `it` | `it-IT` | `italy` | Italia |
|
|
16
|
+
| `pt` | `pt-PT` | `portugal` | Portugal |
|
|
17
|
+
| `comco` | `es-CO` | `colombia` | Colombia |
|
|
18
|
+
| `compe` | `es-PE` | `peru` | Perú |
|
|
19
|
+
|
|
20
|
+
`websiteAppName` es el nombre de la app de `iati-websites-monorepo` que sirve cada región: coincide con el `APP_NAME` de ese repo (el nombre del package sin el prefijo `@repo/`), que es también el `appName` por el que se filtran sus documentos de Sanity.
|
|
19
21
|
|
|
20
22
|
## Instalación
|
|
21
23
|
|
|
@@ -94,6 +96,31 @@ const config = getRegionConfigByRegionCode('es-ES');
|
|
|
94
96
|
|
|
95
97
|
---
|
|
96
98
|
|
|
99
|
+
### `getRegionConfigByWebsiteAppName(websiteAppName: string): RegionConfig | undefined`
|
|
100
|
+
|
|
101
|
+
Obtiene la configuración de la región que sirve una app de `iati-websites-monorepo`. Devuelve `undefined` si la app no está asociada a ninguna región (por ejemplo `studio`, `dispatcher` o `docs`), de modo que "sin región" sea un estado válido para el consumidor.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { getRegionConfigByWebsiteAppName } from 'regions-config';
|
|
105
|
+
|
|
106
|
+
const config = getRegionConfigByWebsiteAppName('italy'); // Config Italia
|
|
107
|
+
const none = getRegionConfigByWebsiteAppName('studio'); // undefined
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### `getRegionCodeByWebsiteAppName(websiteAppName: string): RegionCode | undefined`
|
|
113
|
+
|
|
114
|
+
Atajo que devuelve únicamente el `regionCode` que corresponde a una app de `iati-websites-monorepo`.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { getRegionCodeByWebsiteAppName } from 'regions-config';
|
|
118
|
+
|
|
119
|
+
const regionCode = getRegionCodeByWebsiteAppName('eu'); // 'en-EU'
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
97
124
|
### `validateRegion(region: RegionCode): void`
|
|
98
125
|
|
|
99
126
|
Valida que un `regionCode` sea válido. Lanza un error si no corresponde a ninguna región configurada.
|
|
@@ -133,6 +160,7 @@ type RegionConfig = {
|
|
|
133
160
|
id: number;
|
|
134
161
|
gtmId: string; // Formato: GTM-XXXXXXX
|
|
135
162
|
regionCode: 'es-ES' | 'es-MX' | 'en-EU' | 'en-ROW' | 'it-IT' | 'pt-PT' | 'es-CO' | 'es-PE';
|
|
163
|
+
websiteAppName: 'spain' | 'mexico' | 'eu' | 'row' | 'italy' | 'portugal' | 'colombia' | 'peru';
|
|
136
164
|
timeZone: string;
|
|
137
165
|
dateFormat: string;
|
|
138
166
|
footer: Array<{ href: string; label: string }>;
|
|
@@ -179,6 +207,8 @@ src/
|
|
|
179
207
|
│ ├── getRegionConfig.ts
|
|
180
208
|
│ ├── getRegionConfigById.ts
|
|
181
209
|
│ ├── getRegionConfigByRegionCode.ts
|
|
210
|
+
│ ├── getRegionConfigByWebsiteAppName.ts
|
|
211
|
+
│ ├── getRegionCodeByWebsiteAppName.ts
|
|
182
212
|
│ └── resolveDocumentTypeOptions.ts
|
|
183
213
|
└── validators/
|
|
184
214
|
└── validateRegion.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ declare const regions: {
|
|
|
4
4
|
readonly comco: {
|
|
5
5
|
readonly id: 9;
|
|
6
6
|
readonly name: "colombia";
|
|
7
|
+
readonly websiteAppName: "colombia";
|
|
7
8
|
readonly countryCode: "CO";
|
|
8
9
|
readonly defaultCurrency: "USD";
|
|
9
10
|
readonly marketRegion: "latam";
|
|
@@ -183,6 +184,7 @@ declare const regions: {
|
|
|
183
184
|
readonly comen: {
|
|
184
185
|
readonly id: 5;
|
|
185
186
|
readonly name: "world";
|
|
187
|
+
readonly websiteAppName: "row";
|
|
186
188
|
readonly countryCode: "WR";
|
|
187
189
|
readonly defaultCurrency: "EUR";
|
|
188
190
|
readonly marketRegion: "world";
|
|
@@ -345,6 +347,7 @@ declare const regions: {
|
|
|
345
347
|
readonly comeneu: {
|
|
346
348
|
readonly id: 6;
|
|
347
349
|
readonly name: "europe";
|
|
350
|
+
readonly websiteAppName: "eu";
|
|
348
351
|
readonly countryCode: "EU";
|
|
349
352
|
readonly defaultCurrency: "EUR";
|
|
350
353
|
readonly marketRegion: "europe";
|
|
@@ -507,6 +510,7 @@ declare const regions: {
|
|
|
507
510
|
readonly commx: {
|
|
508
511
|
readonly id: 7;
|
|
509
512
|
readonly name: "mexico";
|
|
513
|
+
readonly websiteAppName: "mexico";
|
|
510
514
|
readonly countryCode: "MX";
|
|
511
515
|
readonly defaultCurrency: "USD";
|
|
512
516
|
readonly marketRegion: "latam";
|
|
@@ -657,6 +661,7 @@ declare const regions: {
|
|
|
657
661
|
readonly compe: {
|
|
658
662
|
readonly id: 8;
|
|
659
663
|
readonly name: "peru";
|
|
664
|
+
readonly websiteAppName: "peru";
|
|
660
665
|
readonly countryCode: "PE";
|
|
661
666
|
readonly defaultCurrency: "USD";
|
|
662
667
|
readonly marketRegion: "latam";
|
|
@@ -807,6 +812,7 @@ declare const regions: {
|
|
|
807
812
|
readonly es: {
|
|
808
813
|
readonly id: 1;
|
|
809
814
|
readonly name: "spain";
|
|
815
|
+
readonly websiteAppName: "spain";
|
|
810
816
|
readonly countryCode: "ES";
|
|
811
817
|
readonly defaultCurrency: "EUR";
|
|
812
818
|
readonly marketRegion: "europe";
|
|
@@ -984,6 +990,7 @@ declare const regions: {
|
|
|
984
990
|
readonly it: {
|
|
985
991
|
readonly id: 10;
|
|
986
992
|
readonly name: "italy";
|
|
993
|
+
readonly websiteAppName: "italy";
|
|
987
994
|
readonly countryCode: "IT";
|
|
988
995
|
readonly defaultCurrency: "EUR";
|
|
989
996
|
readonly marketRegion: "europe";
|
|
@@ -1142,6 +1149,7 @@ declare const regions: {
|
|
|
1142
1149
|
readonly pt: {
|
|
1143
1150
|
readonly id: 2;
|
|
1144
1151
|
readonly name: "portugal";
|
|
1152
|
+
readonly websiteAppName: "portugal";
|
|
1145
1153
|
readonly countryCode: "PT";
|
|
1146
1154
|
readonly defaultCurrency: "EUR";
|
|
1147
1155
|
readonly marketRegion: "europe";
|
|
@@ -1319,6 +1327,7 @@ type RegionCountryCode = RegionConfigSource['countryCode'];
|
|
|
1319
1327
|
type MarketRegion = RegionConfigSource['marketRegion'];
|
|
1320
1328
|
type RegionCode = RegionConfigSource['regionCode'];
|
|
1321
1329
|
type DefaultCurrency = RegionConfigSource['defaultCurrency'];
|
|
1330
|
+
type WebsiteAppName = RegionConfigSource['websiteAppName'];
|
|
1322
1331
|
declare const RegionNameSchema: z.ZodEnum<{
|
|
1323
1332
|
colombia: "colombia";
|
|
1324
1333
|
world: "world";
|
|
@@ -1349,6 +1358,16 @@ declare const RegionCodeSchema: z.ZodEnum<{
|
|
|
1349
1358
|
"it-IT": "it-IT";
|
|
1350
1359
|
"pt-PT": "pt-PT";
|
|
1351
1360
|
}>;
|
|
1361
|
+
declare const WebsiteAppNameSchema: z.ZodEnum<{
|
|
1362
|
+
colombia: "colombia";
|
|
1363
|
+
row: "row";
|
|
1364
|
+
eu: "eu";
|
|
1365
|
+
mexico: "mexico";
|
|
1366
|
+
peru: "peru";
|
|
1367
|
+
spain: "spain";
|
|
1368
|
+
italy: "italy";
|
|
1369
|
+
portugal: "portugal";
|
|
1370
|
+
}>;
|
|
1352
1371
|
declare const MarketRegionSchema: z.ZodEnum<{
|
|
1353
1372
|
latam: "latam";
|
|
1354
1373
|
world: "world";
|
|
@@ -1383,6 +1402,16 @@ declare const MarketRegionEnum: {
|
|
|
1383
1402
|
world: "world";
|
|
1384
1403
|
europe: "europe";
|
|
1385
1404
|
};
|
|
1405
|
+
declare const WebsiteAppNameEnum: {
|
|
1406
|
+
colombia: "colombia";
|
|
1407
|
+
row: "row";
|
|
1408
|
+
eu: "eu";
|
|
1409
|
+
mexico: "mexico";
|
|
1410
|
+
peru: "peru";
|
|
1411
|
+
spain: "spain";
|
|
1412
|
+
italy: "italy";
|
|
1413
|
+
portugal: "portugal";
|
|
1414
|
+
};
|
|
1386
1415
|
type DocumentTypeOption = {
|
|
1387
1416
|
label: string;
|
|
1388
1417
|
value: string;
|
|
@@ -1494,6 +1523,16 @@ declare const RegionConfigSchema: z.ZodObject<{
|
|
|
1494
1523
|
italy: "italy";
|
|
1495
1524
|
portugal: "portugal";
|
|
1496
1525
|
}>;
|
|
1526
|
+
websiteAppName: z.ZodEnum<{
|
|
1527
|
+
colombia: "colombia";
|
|
1528
|
+
row: "row";
|
|
1529
|
+
eu: "eu";
|
|
1530
|
+
mexico: "mexico";
|
|
1531
|
+
peru: "peru";
|
|
1532
|
+
spain: "spain";
|
|
1533
|
+
italy: "italy";
|
|
1534
|
+
portugal: "portugal";
|
|
1535
|
+
}>;
|
|
1497
1536
|
countryCode: z.ZodEnum<{
|
|
1498
1537
|
CO: "CO";
|
|
1499
1538
|
WR: "WR";
|
|
@@ -1550,6 +1589,21 @@ declare const getRegionConfigByName: (name: string) => RegionConfig | undefined;
|
|
|
1550
1589
|
|
|
1551
1590
|
declare const getRegionConfigByRegionCode: (regionCode: RegionConfig["regionCode"]) => RegionConfig;
|
|
1552
1591
|
|
|
1592
|
+
/**
|
|
1593
|
+
* Resolve the region config served by a website app.
|
|
1594
|
+
*
|
|
1595
|
+
* Returns `undefined` for apps that are not region-scoped (e.g. `studio`,
|
|
1596
|
+
* `dispatcher`, `docs`), so callers can treat "no region" as a valid state.
|
|
1597
|
+
*/
|
|
1598
|
+
declare const getRegionConfigByWebsiteAppName: (websiteAppName: string) => RegionConfig | undefined;
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* Resolve just the region code (e.g. `es-ES`, `en-ROW`) served by a website app.
|
|
1602
|
+
*
|
|
1603
|
+
* Returns `undefined` for apps that are not region-scoped.
|
|
1604
|
+
*/
|
|
1605
|
+
declare const getRegionCodeByWebsiteAppName: (websiteAppName: string) => RegionCode | undefined;
|
|
1606
|
+
|
|
1553
1607
|
declare const COUNTRIES_TO_REDIRECT: {
|
|
1554
1608
|
readonly es: {
|
|
1555
1609
|
readonly label: "Spain";
|
|
@@ -1731,4 +1785,4 @@ declare const resolvePostalCodeFormat: (postalCodeFormat?: string, originCountry
|
|
|
1731
1785
|
|
|
1732
1786
|
declare const validateRegion: (region: RegionConfig["regionCode"]) => void;
|
|
1733
1787
|
|
|
1734
|
-
export { COUNTRIES_TO_REDIRECT, type CountriesToRedirectMap, type CountryReference, type CountryToRedirect, type DefaultCurrency, DefaultCurrencySchema, type DocumentTypeOption, type DocumentTypeOptionsByOrigin, EUROPE_COUNTRIES, GROUP_REGIONS, type MarketRegion, MarketRegionEnum, MarketRegionSchema, type PaymentCardType, type RedirectGroup, type RedirectSiteKey, type RegionCode, RegionCodeSchema, type RegionConfig, RegionConfigSchema, type RegionCountryCode, RegionCountryCodeEnum, RegionCountryCodeSchema, type RegionName, RegionNameEnum, RegionNameSchema, type RegionToGroup, type RegionsConfig, US_CANADA_COUNTRIES, US_CANADA_JAPAN_COUNTRIES, WORLD_COUNTRIES, getAllRegions, getCountriesToRedirect, getRegionConfig, getRegionConfigById, getRegionConfigByName, getRegionConfigByRegionCode, regionsConfig, resolveDocumentTypeOptions, resolvePostalCodeFormat, validateRegion };
|
|
1788
|
+
export { COUNTRIES_TO_REDIRECT, type CountriesToRedirectMap, type CountryReference, type CountryToRedirect, type DefaultCurrency, DefaultCurrencySchema, type DocumentTypeOption, type DocumentTypeOptionsByOrigin, EUROPE_COUNTRIES, GROUP_REGIONS, type MarketRegion, MarketRegionEnum, MarketRegionSchema, type PaymentCardType, type RedirectGroup, type RedirectSiteKey, type RegionCode, RegionCodeSchema, type RegionConfig, RegionConfigSchema, type RegionCountryCode, RegionCountryCodeEnum, RegionCountryCodeSchema, type RegionName, RegionNameEnum, RegionNameSchema, type RegionToGroup, type RegionsConfig, US_CANADA_COUNTRIES, US_CANADA_JAPAN_COUNTRIES, WORLD_COUNTRIES, type WebsiteAppName, WebsiteAppNameEnum, WebsiteAppNameSchema, getAllRegions, getCountriesToRedirect, getRegionCodeByWebsiteAppName, getRegionConfig, getRegionConfigById, getRegionConfigByName, getRegionConfigByRegionCode, getRegionConfigByWebsiteAppName, regionsConfig, resolveDocumentTypeOptions, resolvePostalCodeFormat, validateRegion };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare const regions: {
|
|
|
4
4
|
readonly comco: {
|
|
5
5
|
readonly id: 9;
|
|
6
6
|
readonly name: "colombia";
|
|
7
|
+
readonly websiteAppName: "colombia";
|
|
7
8
|
readonly countryCode: "CO";
|
|
8
9
|
readonly defaultCurrency: "USD";
|
|
9
10
|
readonly marketRegion: "latam";
|
|
@@ -183,6 +184,7 @@ declare const regions: {
|
|
|
183
184
|
readonly comen: {
|
|
184
185
|
readonly id: 5;
|
|
185
186
|
readonly name: "world";
|
|
187
|
+
readonly websiteAppName: "row";
|
|
186
188
|
readonly countryCode: "WR";
|
|
187
189
|
readonly defaultCurrency: "EUR";
|
|
188
190
|
readonly marketRegion: "world";
|
|
@@ -345,6 +347,7 @@ declare const regions: {
|
|
|
345
347
|
readonly comeneu: {
|
|
346
348
|
readonly id: 6;
|
|
347
349
|
readonly name: "europe";
|
|
350
|
+
readonly websiteAppName: "eu";
|
|
348
351
|
readonly countryCode: "EU";
|
|
349
352
|
readonly defaultCurrency: "EUR";
|
|
350
353
|
readonly marketRegion: "europe";
|
|
@@ -507,6 +510,7 @@ declare const regions: {
|
|
|
507
510
|
readonly commx: {
|
|
508
511
|
readonly id: 7;
|
|
509
512
|
readonly name: "mexico";
|
|
513
|
+
readonly websiteAppName: "mexico";
|
|
510
514
|
readonly countryCode: "MX";
|
|
511
515
|
readonly defaultCurrency: "USD";
|
|
512
516
|
readonly marketRegion: "latam";
|
|
@@ -657,6 +661,7 @@ declare const regions: {
|
|
|
657
661
|
readonly compe: {
|
|
658
662
|
readonly id: 8;
|
|
659
663
|
readonly name: "peru";
|
|
664
|
+
readonly websiteAppName: "peru";
|
|
660
665
|
readonly countryCode: "PE";
|
|
661
666
|
readonly defaultCurrency: "USD";
|
|
662
667
|
readonly marketRegion: "latam";
|
|
@@ -807,6 +812,7 @@ declare const regions: {
|
|
|
807
812
|
readonly es: {
|
|
808
813
|
readonly id: 1;
|
|
809
814
|
readonly name: "spain";
|
|
815
|
+
readonly websiteAppName: "spain";
|
|
810
816
|
readonly countryCode: "ES";
|
|
811
817
|
readonly defaultCurrency: "EUR";
|
|
812
818
|
readonly marketRegion: "europe";
|
|
@@ -984,6 +990,7 @@ declare const regions: {
|
|
|
984
990
|
readonly it: {
|
|
985
991
|
readonly id: 10;
|
|
986
992
|
readonly name: "italy";
|
|
993
|
+
readonly websiteAppName: "italy";
|
|
987
994
|
readonly countryCode: "IT";
|
|
988
995
|
readonly defaultCurrency: "EUR";
|
|
989
996
|
readonly marketRegion: "europe";
|
|
@@ -1142,6 +1149,7 @@ declare const regions: {
|
|
|
1142
1149
|
readonly pt: {
|
|
1143
1150
|
readonly id: 2;
|
|
1144
1151
|
readonly name: "portugal";
|
|
1152
|
+
readonly websiteAppName: "portugal";
|
|
1145
1153
|
readonly countryCode: "PT";
|
|
1146
1154
|
readonly defaultCurrency: "EUR";
|
|
1147
1155
|
readonly marketRegion: "europe";
|
|
@@ -1319,6 +1327,7 @@ type RegionCountryCode = RegionConfigSource['countryCode'];
|
|
|
1319
1327
|
type MarketRegion = RegionConfigSource['marketRegion'];
|
|
1320
1328
|
type RegionCode = RegionConfigSource['regionCode'];
|
|
1321
1329
|
type DefaultCurrency = RegionConfigSource['defaultCurrency'];
|
|
1330
|
+
type WebsiteAppName = RegionConfigSource['websiteAppName'];
|
|
1322
1331
|
declare const RegionNameSchema: z.ZodEnum<{
|
|
1323
1332
|
colombia: "colombia";
|
|
1324
1333
|
world: "world";
|
|
@@ -1349,6 +1358,16 @@ declare const RegionCodeSchema: z.ZodEnum<{
|
|
|
1349
1358
|
"it-IT": "it-IT";
|
|
1350
1359
|
"pt-PT": "pt-PT";
|
|
1351
1360
|
}>;
|
|
1361
|
+
declare const WebsiteAppNameSchema: z.ZodEnum<{
|
|
1362
|
+
colombia: "colombia";
|
|
1363
|
+
row: "row";
|
|
1364
|
+
eu: "eu";
|
|
1365
|
+
mexico: "mexico";
|
|
1366
|
+
peru: "peru";
|
|
1367
|
+
spain: "spain";
|
|
1368
|
+
italy: "italy";
|
|
1369
|
+
portugal: "portugal";
|
|
1370
|
+
}>;
|
|
1352
1371
|
declare const MarketRegionSchema: z.ZodEnum<{
|
|
1353
1372
|
latam: "latam";
|
|
1354
1373
|
world: "world";
|
|
@@ -1383,6 +1402,16 @@ declare const MarketRegionEnum: {
|
|
|
1383
1402
|
world: "world";
|
|
1384
1403
|
europe: "europe";
|
|
1385
1404
|
};
|
|
1405
|
+
declare const WebsiteAppNameEnum: {
|
|
1406
|
+
colombia: "colombia";
|
|
1407
|
+
row: "row";
|
|
1408
|
+
eu: "eu";
|
|
1409
|
+
mexico: "mexico";
|
|
1410
|
+
peru: "peru";
|
|
1411
|
+
spain: "spain";
|
|
1412
|
+
italy: "italy";
|
|
1413
|
+
portugal: "portugal";
|
|
1414
|
+
};
|
|
1386
1415
|
type DocumentTypeOption = {
|
|
1387
1416
|
label: string;
|
|
1388
1417
|
value: string;
|
|
@@ -1494,6 +1523,16 @@ declare const RegionConfigSchema: z.ZodObject<{
|
|
|
1494
1523
|
italy: "italy";
|
|
1495
1524
|
portugal: "portugal";
|
|
1496
1525
|
}>;
|
|
1526
|
+
websiteAppName: z.ZodEnum<{
|
|
1527
|
+
colombia: "colombia";
|
|
1528
|
+
row: "row";
|
|
1529
|
+
eu: "eu";
|
|
1530
|
+
mexico: "mexico";
|
|
1531
|
+
peru: "peru";
|
|
1532
|
+
spain: "spain";
|
|
1533
|
+
italy: "italy";
|
|
1534
|
+
portugal: "portugal";
|
|
1535
|
+
}>;
|
|
1497
1536
|
countryCode: z.ZodEnum<{
|
|
1498
1537
|
CO: "CO";
|
|
1499
1538
|
WR: "WR";
|
|
@@ -1550,6 +1589,21 @@ declare const getRegionConfigByName: (name: string) => RegionConfig | undefined;
|
|
|
1550
1589
|
|
|
1551
1590
|
declare const getRegionConfigByRegionCode: (regionCode: RegionConfig["regionCode"]) => RegionConfig;
|
|
1552
1591
|
|
|
1592
|
+
/**
|
|
1593
|
+
* Resolve the region config served by a website app.
|
|
1594
|
+
*
|
|
1595
|
+
* Returns `undefined` for apps that are not region-scoped (e.g. `studio`,
|
|
1596
|
+
* `dispatcher`, `docs`), so callers can treat "no region" as a valid state.
|
|
1597
|
+
*/
|
|
1598
|
+
declare const getRegionConfigByWebsiteAppName: (websiteAppName: string) => RegionConfig | undefined;
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* Resolve just the region code (e.g. `es-ES`, `en-ROW`) served by a website app.
|
|
1602
|
+
*
|
|
1603
|
+
* Returns `undefined` for apps that are not region-scoped.
|
|
1604
|
+
*/
|
|
1605
|
+
declare const getRegionCodeByWebsiteAppName: (websiteAppName: string) => RegionCode | undefined;
|
|
1606
|
+
|
|
1553
1607
|
declare const COUNTRIES_TO_REDIRECT: {
|
|
1554
1608
|
readonly es: {
|
|
1555
1609
|
readonly label: "Spain";
|
|
@@ -1731,4 +1785,4 @@ declare const resolvePostalCodeFormat: (postalCodeFormat?: string, originCountry
|
|
|
1731
1785
|
|
|
1732
1786
|
declare const validateRegion: (region: RegionConfig["regionCode"]) => void;
|
|
1733
1787
|
|
|
1734
|
-
export { COUNTRIES_TO_REDIRECT, type CountriesToRedirectMap, type CountryReference, type CountryToRedirect, type DefaultCurrency, DefaultCurrencySchema, type DocumentTypeOption, type DocumentTypeOptionsByOrigin, EUROPE_COUNTRIES, GROUP_REGIONS, type MarketRegion, MarketRegionEnum, MarketRegionSchema, type PaymentCardType, type RedirectGroup, type RedirectSiteKey, type RegionCode, RegionCodeSchema, type RegionConfig, RegionConfigSchema, type RegionCountryCode, RegionCountryCodeEnum, RegionCountryCodeSchema, type RegionName, RegionNameEnum, RegionNameSchema, type RegionToGroup, type RegionsConfig, US_CANADA_COUNTRIES, US_CANADA_JAPAN_COUNTRIES, WORLD_COUNTRIES, getAllRegions, getCountriesToRedirect, getRegionConfig, getRegionConfigById, getRegionConfigByName, getRegionConfigByRegionCode, regionsConfig, resolveDocumentTypeOptions, resolvePostalCodeFormat, validateRegion };
|
|
1788
|
+
export { COUNTRIES_TO_REDIRECT, type CountriesToRedirectMap, type CountryReference, type CountryToRedirect, type DefaultCurrency, DefaultCurrencySchema, type DocumentTypeOption, type DocumentTypeOptionsByOrigin, EUROPE_COUNTRIES, GROUP_REGIONS, type MarketRegion, MarketRegionEnum, MarketRegionSchema, type PaymentCardType, type RedirectGroup, type RedirectSiteKey, type RegionCode, RegionCodeSchema, type RegionConfig, RegionConfigSchema, type RegionCountryCode, RegionCountryCodeEnum, RegionCountryCodeSchema, type RegionName, RegionNameEnum, RegionNameSchema, type RegionToGroup, type RegionsConfig, US_CANADA_COUNTRIES, US_CANADA_JAPAN_COUNTRIES, WORLD_COUNTRIES, type WebsiteAppName, WebsiteAppNameEnum, WebsiteAppNameSchema, getAllRegions, getCountriesToRedirect, getRegionCodeByWebsiteAppName, getRegionConfig, getRegionConfigById, getRegionConfigByName, getRegionConfigByRegionCode, getRegionConfigByWebsiteAppName, regionsConfig, resolveDocumentTypeOptions, resolvePostalCodeFormat, validateRegion };
|
package/dist/index.js
CHANGED
|
@@ -35,12 +35,16 @@ __export(index_exports, {
|
|
|
35
35
|
US_CANADA_COUNTRIES: () => US_CANADA_COUNTRIES,
|
|
36
36
|
US_CANADA_JAPAN_COUNTRIES: () => US_CANADA_JAPAN_COUNTRIES,
|
|
37
37
|
WORLD_COUNTRIES: () => WORLD_COUNTRIES,
|
|
38
|
+
WebsiteAppNameEnum: () => WebsiteAppNameEnum,
|
|
39
|
+
WebsiteAppNameSchema: () => WebsiteAppNameSchema,
|
|
38
40
|
getAllRegions: () => getAllRegions,
|
|
39
41
|
getCountriesToRedirect: () => getCountriesToRedirect,
|
|
42
|
+
getRegionCodeByWebsiteAppName: () => getRegionCodeByWebsiteAppName,
|
|
40
43
|
getRegionConfig: () => getRegionConfig,
|
|
41
44
|
getRegionConfigById: () => getRegionConfigById,
|
|
42
45
|
getRegionConfigByName: () => getRegionConfigByName,
|
|
43
46
|
getRegionConfigByRegionCode: () => getRegionConfigByRegionCode,
|
|
47
|
+
getRegionConfigByWebsiteAppName: () => getRegionConfigByWebsiteAppName,
|
|
44
48
|
regionsConfig: () => regionsConfig_default,
|
|
45
49
|
resolveDocumentTypeOptions: () => resolveDocumentTypeOptions,
|
|
46
50
|
resolvePostalCodeFormat: () => resolvePostalCodeFormat,
|
|
@@ -371,6 +375,7 @@ var getCountriesToRedirect = (currentSite) => Object.fromEntries(Object.entries(
|
|
|
371
375
|
var comco_default = {
|
|
372
376
|
id: 9,
|
|
373
377
|
name: "colombia",
|
|
378
|
+
websiteAppName: "colombia",
|
|
374
379
|
countryCode: "CO",
|
|
375
380
|
defaultCurrency: "USD",
|
|
376
381
|
marketRegion: "latam",
|
|
@@ -458,6 +463,7 @@ var comco_default = {
|
|
|
458
463
|
var comen_default = {
|
|
459
464
|
id: 5,
|
|
460
465
|
name: "world",
|
|
466
|
+
websiteAppName: "row",
|
|
461
467
|
countryCode: "WR",
|
|
462
468
|
defaultCurrency: "EUR",
|
|
463
469
|
marketRegion: "world",
|
|
@@ -558,6 +564,7 @@ var comen_default = {
|
|
|
558
564
|
var comeneu_default = {
|
|
559
565
|
id: 6,
|
|
560
566
|
name: "europe",
|
|
567
|
+
websiteAppName: "eu",
|
|
561
568
|
countryCode: "EU",
|
|
562
569
|
defaultCurrency: "EUR",
|
|
563
570
|
marketRegion: "europe",
|
|
@@ -658,6 +665,7 @@ var comeneu_default = {
|
|
|
658
665
|
var commx_default = {
|
|
659
666
|
id: 7,
|
|
660
667
|
name: "mexico",
|
|
668
|
+
websiteAppName: "mexico",
|
|
661
669
|
countryCode: "MX",
|
|
662
670
|
defaultCurrency: "USD",
|
|
663
671
|
marketRegion: "latam",
|
|
@@ -743,6 +751,7 @@ var commx_default = {
|
|
|
743
751
|
var compe_default = {
|
|
744
752
|
id: 8,
|
|
745
753
|
name: "peru",
|
|
754
|
+
websiteAppName: "peru",
|
|
746
755
|
countryCode: "PE",
|
|
747
756
|
defaultCurrency: "USD",
|
|
748
757
|
marketRegion: "latam",
|
|
@@ -828,6 +837,7 @@ var compe_default = {
|
|
|
828
837
|
var es_default = {
|
|
829
838
|
id: 1,
|
|
830
839
|
name: "spain",
|
|
840
|
+
websiteAppName: "spain",
|
|
831
841
|
countryCode: "ES",
|
|
832
842
|
defaultCurrency: "EUR",
|
|
833
843
|
marketRegion: "europe",
|
|
@@ -949,6 +959,7 @@ var es_default = {
|
|
|
949
959
|
var it_default = {
|
|
950
960
|
id: 10,
|
|
951
961
|
name: "italy",
|
|
962
|
+
websiteAppName: "italy",
|
|
952
963
|
countryCode: "IT",
|
|
953
964
|
defaultCurrency: "EUR",
|
|
954
965
|
marketRegion: "europe",
|
|
@@ -1044,6 +1055,7 @@ var it_default = {
|
|
|
1044
1055
|
var pt_default = {
|
|
1045
1056
|
id: 2,
|
|
1046
1057
|
name: "portugal",
|
|
1058
|
+
websiteAppName: "portugal",
|
|
1047
1059
|
countryCode: "PT",
|
|
1048
1060
|
defaultCurrency: "EUR",
|
|
1049
1061
|
marketRegion: "europe",
|
|
@@ -1180,6 +1192,7 @@ var RegionNameSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map
|
|
|
1180
1192
|
var RegionCountryCodeSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.countryCode)));
|
|
1181
1193
|
var regionEmojiSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.emoji)));
|
|
1182
1194
|
var RegionCodeSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.regionCode)));
|
|
1195
|
+
var WebsiteAppNameSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.websiteAppName)));
|
|
1183
1196
|
var MarketRegionSchema = import_zod.z.enum(uniqueSorted(Object.values(regions).map((region) => region.marketRegion)));
|
|
1184
1197
|
var DefaultCurrencySchema = import_zod.z.enum(
|
|
1185
1198
|
uniqueSorted(Object.values(regions).map((region) => region.defaultCurrency))
|
|
@@ -1187,6 +1200,7 @@ var DefaultCurrencySchema = import_zod.z.enum(
|
|
|
1187
1200
|
var RegionNameEnum = RegionNameSchema.enum;
|
|
1188
1201
|
var RegionCountryCodeEnum = RegionCountryCodeSchema.enum;
|
|
1189
1202
|
var MarketRegionEnum = MarketRegionSchema.enum;
|
|
1203
|
+
var WebsiteAppNameEnum = WebsiteAppNameSchema.enum;
|
|
1190
1204
|
var CountryReferenceSchema = import_zod.z.object({
|
|
1191
1205
|
countryId: import_zod.z.string(),
|
|
1192
1206
|
name: import_zod.z.string().optional()
|
|
@@ -1246,6 +1260,12 @@ var RegionConfigSchema = import_zod.z.strictObject({
|
|
|
1246
1260
|
),
|
|
1247
1261
|
webSitePath: import_zod.z.string().optional(),
|
|
1248
1262
|
name: RegionNameSchema,
|
|
1263
|
+
/**
|
|
1264
|
+
* Name of the app in iati-websites-monorepo that serves this region.
|
|
1265
|
+
* Matches that repo's `APP_NAME` (its package name minus the `@repo/` prefix),
|
|
1266
|
+
* which is also the `appName` its Sanity documents are filtered by.
|
|
1267
|
+
*/
|
|
1268
|
+
websiteAppName: WebsiteAppNameSchema,
|
|
1249
1269
|
countryCode: RegionCountryCodeSchema,
|
|
1250
1270
|
defaultCurrency: DefaultCurrencySchema,
|
|
1251
1271
|
marketRegion: MarketRegionSchema,
|
|
@@ -1288,6 +1308,18 @@ var getRegionConfigByRegionCode = (regionCode) => {
|
|
|
1288
1308
|
return region;
|
|
1289
1309
|
};
|
|
1290
1310
|
|
|
1311
|
+
// src/utils/getRegionConfigByWebsiteAppName.ts
|
|
1312
|
+
var getRegionConfigByWebsiteAppName = (websiteAppName) => {
|
|
1313
|
+
const normalized = websiteAppName.trim().toLowerCase();
|
|
1314
|
+
return Object.values(regionsConfig_default).find((region) => region.websiteAppName === normalized);
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
// src/utils/getRegionCodeByWebsiteAppName.ts
|
|
1318
|
+
var getRegionCodeByWebsiteAppName = (websiteAppName) => {
|
|
1319
|
+
var _a;
|
|
1320
|
+
return (_a = getRegionConfigByWebsiteAppName(websiteAppName)) == null ? void 0 : _a.regionCode;
|
|
1321
|
+
};
|
|
1322
|
+
|
|
1291
1323
|
// src/utils/resolveDocumentTypeOptions.ts
|
|
1292
1324
|
var resolveDocumentTypeOptions = (documentTypeOptions, documentTypeOptionsByOrigin, originCountryId, siteCountryId) => {
|
|
1293
1325
|
if (!documentTypeOptionsByOrigin) return documentTypeOptions;
|
|
@@ -1327,12 +1359,16 @@ var validateRegion = (region) => {
|
|
|
1327
1359
|
US_CANADA_COUNTRIES,
|
|
1328
1360
|
US_CANADA_JAPAN_COUNTRIES,
|
|
1329
1361
|
WORLD_COUNTRIES,
|
|
1362
|
+
WebsiteAppNameEnum,
|
|
1363
|
+
WebsiteAppNameSchema,
|
|
1330
1364
|
getAllRegions,
|
|
1331
1365
|
getCountriesToRedirect,
|
|
1366
|
+
getRegionCodeByWebsiteAppName,
|
|
1332
1367
|
getRegionConfig,
|
|
1333
1368
|
getRegionConfigById,
|
|
1334
1369
|
getRegionConfigByName,
|
|
1335
1370
|
getRegionConfigByRegionCode,
|
|
1371
|
+
getRegionConfigByWebsiteAppName,
|
|
1336
1372
|
regionsConfig,
|
|
1337
1373
|
resolveDocumentTypeOptions,
|
|
1338
1374
|
resolvePostalCodeFormat,
|
package/dist/index.mjs
CHANGED
|
@@ -321,6 +321,7 @@ var getCountriesToRedirect = (currentSite) => Object.fromEntries(Object.entries(
|
|
|
321
321
|
var comco_default = {
|
|
322
322
|
id: 9,
|
|
323
323
|
name: "colombia",
|
|
324
|
+
websiteAppName: "colombia",
|
|
324
325
|
countryCode: "CO",
|
|
325
326
|
defaultCurrency: "USD",
|
|
326
327
|
marketRegion: "latam",
|
|
@@ -408,6 +409,7 @@ var comco_default = {
|
|
|
408
409
|
var comen_default = {
|
|
409
410
|
id: 5,
|
|
410
411
|
name: "world",
|
|
412
|
+
websiteAppName: "row",
|
|
411
413
|
countryCode: "WR",
|
|
412
414
|
defaultCurrency: "EUR",
|
|
413
415
|
marketRegion: "world",
|
|
@@ -508,6 +510,7 @@ var comen_default = {
|
|
|
508
510
|
var comeneu_default = {
|
|
509
511
|
id: 6,
|
|
510
512
|
name: "europe",
|
|
513
|
+
websiteAppName: "eu",
|
|
511
514
|
countryCode: "EU",
|
|
512
515
|
defaultCurrency: "EUR",
|
|
513
516
|
marketRegion: "europe",
|
|
@@ -608,6 +611,7 @@ var comeneu_default = {
|
|
|
608
611
|
var commx_default = {
|
|
609
612
|
id: 7,
|
|
610
613
|
name: "mexico",
|
|
614
|
+
websiteAppName: "mexico",
|
|
611
615
|
countryCode: "MX",
|
|
612
616
|
defaultCurrency: "USD",
|
|
613
617
|
marketRegion: "latam",
|
|
@@ -693,6 +697,7 @@ var commx_default = {
|
|
|
693
697
|
var compe_default = {
|
|
694
698
|
id: 8,
|
|
695
699
|
name: "peru",
|
|
700
|
+
websiteAppName: "peru",
|
|
696
701
|
countryCode: "PE",
|
|
697
702
|
defaultCurrency: "USD",
|
|
698
703
|
marketRegion: "latam",
|
|
@@ -778,6 +783,7 @@ var compe_default = {
|
|
|
778
783
|
var es_default = {
|
|
779
784
|
id: 1,
|
|
780
785
|
name: "spain",
|
|
786
|
+
websiteAppName: "spain",
|
|
781
787
|
countryCode: "ES",
|
|
782
788
|
defaultCurrency: "EUR",
|
|
783
789
|
marketRegion: "europe",
|
|
@@ -899,6 +905,7 @@ var es_default = {
|
|
|
899
905
|
var it_default = {
|
|
900
906
|
id: 10,
|
|
901
907
|
name: "italy",
|
|
908
|
+
websiteAppName: "italy",
|
|
902
909
|
countryCode: "IT",
|
|
903
910
|
defaultCurrency: "EUR",
|
|
904
911
|
marketRegion: "europe",
|
|
@@ -994,6 +1001,7 @@ var it_default = {
|
|
|
994
1001
|
var pt_default = {
|
|
995
1002
|
id: 2,
|
|
996
1003
|
name: "portugal",
|
|
1004
|
+
websiteAppName: "portugal",
|
|
997
1005
|
countryCode: "PT",
|
|
998
1006
|
defaultCurrency: "EUR",
|
|
999
1007
|
marketRegion: "europe",
|
|
@@ -1130,6 +1138,7 @@ var RegionNameSchema = z.enum(uniqueSorted(Object.values(regions).map((region) =
|
|
|
1130
1138
|
var RegionCountryCodeSchema = z.enum(uniqueSorted(Object.values(regions).map((region) => region.countryCode)));
|
|
1131
1139
|
var regionEmojiSchema = z.enum(uniqueSorted(Object.values(regions).map((region) => region.emoji)));
|
|
1132
1140
|
var RegionCodeSchema = z.enum(uniqueSorted(Object.values(regions).map((region) => region.regionCode)));
|
|
1141
|
+
var WebsiteAppNameSchema = z.enum(uniqueSorted(Object.values(regions).map((region) => region.websiteAppName)));
|
|
1133
1142
|
var MarketRegionSchema = z.enum(uniqueSorted(Object.values(regions).map((region) => region.marketRegion)));
|
|
1134
1143
|
var DefaultCurrencySchema = z.enum(
|
|
1135
1144
|
uniqueSorted(Object.values(regions).map((region) => region.defaultCurrency))
|
|
@@ -1137,6 +1146,7 @@ var DefaultCurrencySchema = z.enum(
|
|
|
1137
1146
|
var RegionNameEnum = RegionNameSchema.enum;
|
|
1138
1147
|
var RegionCountryCodeEnum = RegionCountryCodeSchema.enum;
|
|
1139
1148
|
var MarketRegionEnum = MarketRegionSchema.enum;
|
|
1149
|
+
var WebsiteAppNameEnum = WebsiteAppNameSchema.enum;
|
|
1140
1150
|
var CountryReferenceSchema = z.object({
|
|
1141
1151
|
countryId: z.string(),
|
|
1142
1152
|
name: z.string().optional()
|
|
@@ -1196,6 +1206,12 @@ var RegionConfigSchema = z.strictObject({
|
|
|
1196
1206
|
),
|
|
1197
1207
|
webSitePath: z.string().optional(),
|
|
1198
1208
|
name: RegionNameSchema,
|
|
1209
|
+
/**
|
|
1210
|
+
* Name of the app in iati-websites-monorepo that serves this region.
|
|
1211
|
+
* Matches that repo's `APP_NAME` (its package name minus the `@repo/` prefix),
|
|
1212
|
+
* which is also the `appName` its Sanity documents are filtered by.
|
|
1213
|
+
*/
|
|
1214
|
+
websiteAppName: WebsiteAppNameSchema,
|
|
1199
1215
|
countryCode: RegionCountryCodeSchema,
|
|
1200
1216
|
defaultCurrency: DefaultCurrencySchema,
|
|
1201
1217
|
marketRegion: MarketRegionSchema,
|
|
@@ -1238,6 +1254,18 @@ var getRegionConfigByRegionCode = (regionCode) => {
|
|
|
1238
1254
|
return region;
|
|
1239
1255
|
};
|
|
1240
1256
|
|
|
1257
|
+
// src/utils/getRegionConfigByWebsiteAppName.ts
|
|
1258
|
+
var getRegionConfigByWebsiteAppName = (websiteAppName) => {
|
|
1259
|
+
const normalized = websiteAppName.trim().toLowerCase();
|
|
1260
|
+
return Object.values(regionsConfig_default).find((region) => region.websiteAppName === normalized);
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
// src/utils/getRegionCodeByWebsiteAppName.ts
|
|
1264
|
+
var getRegionCodeByWebsiteAppName = (websiteAppName) => {
|
|
1265
|
+
var _a;
|
|
1266
|
+
return (_a = getRegionConfigByWebsiteAppName(websiteAppName)) == null ? void 0 : _a.regionCode;
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1241
1269
|
// src/utils/resolveDocumentTypeOptions.ts
|
|
1242
1270
|
var resolveDocumentTypeOptions = (documentTypeOptions, documentTypeOptionsByOrigin, originCountryId, siteCountryId) => {
|
|
1243
1271
|
if (!documentTypeOptionsByOrigin) return documentTypeOptions;
|
|
@@ -1276,12 +1304,16 @@ export {
|
|
|
1276
1304
|
US_CANADA_COUNTRIES,
|
|
1277
1305
|
US_CANADA_JAPAN_COUNTRIES,
|
|
1278
1306
|
WORLD_COUNTRIES,
|
|
1307
|
+
WebsiteAppNameEnum,
|
|
1308
|
+
WebsiteAppNameSchema,
|
|
1279
1309
|
getAllRegions,
|
|
1280
1310
|
getCountriesToRedirect,
|
|
1311
|
+
getRegionCodeByWebsiteAppName,
|
|
1281
1312
|
getRegionConfig,
|
|
1282
1313
|
getRegionConfigById,
|
|
1283
1314
|
getRegionConfigByName,
|
|
1284
1315
|
getRegionConfigByRegionCode,
|
|
1316
|
+
getRegionConfigByWebsiteAppName,
|
|
1285
1317
|
regionsConfig_default as regionsConfig,
|
|
1286
1318
|
resolveDocumentTypeOptions,
|
|
1287
1319
|
resolvePostalCodeFormat,
|