grm-shared-library 1.1.182 → 1.1.183
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 +72 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/country/constants/country-defaults.const.js +20 -0
- package/dist/cjs/modules/country/constants/country-defaults.const.js.map +1 -0
- package/dist/cjs/modules/country/constants/supported-countries.const.js +64 -0
- package/dist/cjs/modules/country/constants/supported-countries.const.js.map +1 -0
- package/dist/cjs/modules/country/constants/supported-currencies.const.js +36 -0
- package/dist/cjs/modules/country/constants/supported-currencies.const.js.map +1 -0
- package/dist/cjs/modules/country/dtos/country-scope.dto.js +47 -0
- package/dist/cjs/modules/country/dtos/country-scope.dto.js.map +1 -0
- package/dist/cjs/modules/country/enums/calling-code.enum.js +19 -0
- package/dist/cjs/modules/country/enums/calling-code.enum.js.map +1 -0
- package/dist/cjs/modules/country/enums/country-code.enum.js +21 -0
- package/dist/cjs/modules/country/enums/country-code.enum.js.map +1 -0
- package/dist/cjs/modules/country/enums/currency-code.enum.js +20 -0
- package/dist/cjs/modules/country/enums/currency-code.enum.js.map +1 -0
- package/dist/cjs/modules/country/index.js +34 -0
- package/dist/cjs/modules/country/index.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/geo-coordinates.js +3 -0
- package/dist/cjs/modules/country/interfaces/geo-coordinates.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/map-bounds.js +3 -0
- package/dist/cjs/modules/country/interfaces/map-bounds.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/supported-country-config.js +3 -0
- package/dist/cjs/modules/country/interfaces/supported-country-config.js.map +1 -0
- package/dist/cjs/modules/country/interfaces/supported-currency-config.js +3 -0
- package/dist/cjs/modules/country/interfaces/supported-currency-config.js.map +1 -0
- package/dist/cjs/modules/country/utils/country.util.js +60 -0
- package/dist/cjs/modules/country/utils/country.util.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/country/constants/country-defaults.const.js +17 -0
- package/dist/esm/modules/country/constants/country-defaults.const.js.map +1 -0
- package/dist/esm/modules/country/constants/supported-countries.const.js +61 -0
- package/dist/esm/modules/country/constants/supported-countries.const.js.map +1 -0
- package/dist/esm/modules/country/constants/supported-currencies.const.js +33 -0
- package/dist/esm/modules/country/constants/supported-currencies.const.js.map +1 -0
- package/dist/esm/modules/country/dtos/country-scope.dto.js +43 -0
- package/dist/esm/modules/country/dtos/country-scope.dto.js.map +1 -0
- package/dist/esm/modules/country/enums/calling-code.enum.js +16 -0
- package/dist/esm/modules/country/enums/calling-code.enum.js.map +1 -0
- package/dist/esm/modules/country/enums/country-code.enum.js +18 -0
- package/dist/esm/modules/country/enums/country-code.enum.js.map +1 -0
- package/dist/esm/modules/country/enums/currency-code.enum.js +17 -0
- package/dist/esm/modules/country/enums/currency-code.enum.js.map +1 -0
- package/dist/esm/modules/country/index.js +18 -0
- package/dist/esm/modules/country/index.js.map +1 -0
- package/dist/esm/modules/country/interfaces/geo-coordinates.js +2 -0
- package/dist/esm/modules/country/interfaces/geo-coordinates.js.map +1 -0
- package/dist/esm/modules/country/interfaces/map-bounds.js +2 -0
- package/dist/esm/modules/country/interfaces/map-bounds.js.map +1 -0
- package/dist/esm/modules/country/interfaces/supported-country-config.js +2 -0
- package/dist/esm/modules/country/interfaces/supported-country-config.js.map +1 -0
- package/dist/esm/modules/country/interfaces/supported-currency-config.js +2 -0
- package/dist/esm/modules/country/interfaces/supported-currency-config.js.map +1 -0
- package/dist/esm/modules/country/utils/country.util.js +51 -0
- package/dist/esm/modules/country/utils/country.util.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/modules/country/constants/country-defaults.const.d.ts +15 -0
- package/dist/types/modules/country/constants/supported-countries.const.d.ts +13 -0
- package/dist/types/modules/country/constants/supported-currencies.const.d.ts +11 -0
- package/dist/types/modules/country/dtos/country-scope.dto.d.ts +13 -0
- package/dist/types/modules/country/enums/calling-code.enum.d.ts +14 -0
- package/dist/types/modules/country/enums/country-code.enum.d.ts +16 -0
- package/dist/types/modules/country/enums/currency-code.enum.d.ts +15 -0
- package/dist/types/modules/country/index.d.ts +12 -0
- package/dist/types/modules/country/interfaces/geo-coordinates.d.ts +12 -0
- package/dist/types/modules/country/interfaces/map-bounds.d.ts +16 -0
- package/dist/types/modules/country/interfaces/supported-country-config.d.ts +39 -0
- package/dist/types/modules/country/interfaces/supported-currency-config.d.ts +19 -0
- package/dist/types/modules/country/utils/country.util.d.ts +27 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,2 +1,72 @@
|
|
|
1
|
-
# grm-shared-library
|
|
2
|
-
|
|
1
|
+
# grm-shared-library
|
|
2
|
+
|
|
3
|
+
Common code for GRM — shared types, enums, interfaces, DTOs and constants for the
|
|
4
|
+
Clarion / Upesy backend NestJS microservices.
|
|
5
|
+
|
|
6
|
+
## Country & Currency (multi-country foundation)
|
|
7
|
+
|
|
8
|
+
Platform-level primitives for country-aware emergency response, newsfeed,
|
|
9
|
+
notifications, billing, maps and admin. This is the shared source of truth so
|
|
10
|
+
services stop hard-coding Kenya-specific values.
|
|
11
|
+
|
|
12
|
+
**Supported countries** (ISO 3166-1 alpha-2):
|
|
13
|
+
|
|
14
|
+
| Code | Country | Calling code | Currency | Symbol | Decimals | Timezone | Locale |
|
|
15
|
+
|------|----------|--------------|----------|--------|----------|------------------------|---------|
|
|
16
|
+
| `KE` | Kenya | `+254` | `KES` | `KSh` | 2 | `Africa/Nairobi` | `en-KE` |
|
|
17
|
+
| `UG` | Uganda | `+256` | `UGX` | `USh` | 0 | `Africa/Kampala` | `en-UG` |
|
|
18
|
+
| `TZ` | Tanzania | `+255` | `TZS` | `TSh` | 0 | `Africa/Dar_es_Salaam` | `en-TZ` |
|
|
19
|
+
|
|
20
|
+
**Supported currencies** (ISO 4217): `KES`, `UGX`, `TZS`.
|
|
21
|
+
|
|
22
|
+
### Importing
|
|
23
|
+
|
|
24
|
+
Everything is re-exported from the package root:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import {
|
|
28
|
+
CountryCode,
|
|
29
|
+
CurrencyCode,
|
|
30
|
+
CallingCode,
|
|
31
|
+
SupportedCountryConfig,
|
|
32
|
+
SupportedCurrencyConfig,
|
|
33
|
+
SUPPORTED_COUNTRIES, // readonly SupportedCountryConfig[]
|
|
34
|
+
SUPPORTED_COUNTRIES_BY_CODE, // Record<CountryCode, SupportedCountryConfig>
|
|
35
|
+
SUPPORTED_CURRENCIES,
|
|
36
|
+
SUPPORTED_CURRENCIES_BY_CODE,
|
|
37
|
+
DEFAULT_COUNTRY_CODE, // CountryCode.KE
|
|
38
|
+
DEFAULT_CURRENCY_CODE, // CurrencyCode.KES
|
|
39
|
+
CountryScopeDto, // optional { countryCode?, currencyCode? } request scope
|
|
40
|
+
getSupportedCountryConfig,
|
|
41
|
+
getSupportedCurrencyConfig,
|
|
42
|
+
getCurrencyForCountry,
|
|
43
|
+
getCallingCodeForCountry,
|
|
44
|
+
getCountryByCallingCode,
|
|
45
|
+
isSupportedCountryCode,
|
|
46
|
+
isSupportedCurrencyCode,
|
|
47
|
+
} from 'grm-shared-library';
|
|
48
|
+
|
|
49
|
+
getCurrencyForCountry(CountryCode.UG); // CurrencyCode.UGX
|
|
50
|
+
getCallingCodeForCountry(CountryCode.TZ); // '+255'
|
|
51
|
+
isSupportedCountryCode('US'); // false
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Backward compatibility
|
|
55
|
+
|
|
56
|
+
**Kenya (`KE` / `KES`) is the default market.** Wherever a country or currency is
|
|
57
|
+
not explicit, fall back to `DEFAULT_COUNTRY_CODE` / `DEFAULT_CURRENCY_CODE` /
|
|
58
|
+
`DEFAULT_TIMEZONE` / `DEFAULT_LOCALE`. Existing Kenyan users, packages, posts,
|
|
59
|
+
incidents, OTPs, notifications and billing flows are unaffected.
|
|
60
|
+
|
|
61
|
+
### Scope
|
|
62
|
+
|
|
63
|
+
This package provides the country/currency **primitives only**. Country
|
|
64
|
+
detection (GPS / IP / phone-number inference) and country-aware business logic
|
|
65
|
+
(phone login, newsfeed filtering, multi-currency billing, SMS routing, map
|
|
66
|
+
filtering) are delivered in later phases and should build on top of these types.
|
|
67
|
+
|
|
68
|
+
### Tests
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm test # compiles src/modules/country and runs the country/currency suite
|
|
72
|
+
```
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __exportStar(require("./modules/socket/index"), exports);
|
|
|
33
33
|
__exportStar(require("./modules/web-notification/index"), exports);
|
|
34
34
|
__exportStar(require("./modules/notification/index"), exports);
|
|
35
35
|
__exportStar(require("./modules/chat/index"), exports);
|
|
36
|
+
__exportStar(require("./modules/country/index"), exports);
|
|
36
37
|
// Interfaces
|
|
37
38
|
__exportStar(require("./interfaces/server-message"), exports);
|
|
38
39
|
__exportStar(require("./interfaces/i-request-with-user"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AAExC,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,wFAAsE;AAEtE,aAAa;AACb,qDAAmC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_LOCALE = exports.DEFAULT_TIMEZONE = exports.DEFAULT_CALLING_CODE = exports.DEFAULT_CURRENCY_CODE = exports.DEFAULT_COUNTRY_CODE = void 0;
|
|
4
|
+
const calling_code_enum_1 = require("../enums/calling-code.enum");
|
|
5
|
+
const country_code_enum_1 = require("../enums/country-code.enum");
|
|
6
|
+
const currency_code_enum_1 = require("../enums/currency-code.enum");
|
|
7
|
+
/**
|
|
8
|
+
* Platform defaults.
|
|
9
|
+
*
|
|
10
|
+
* Kenya remains the default / backward-compatible market: existing users,
|
|
11
|
+
* packages, posts, incidents, OTPs, notifications and billing flows continue
|
|
12
|
+
* to behave exactly as they did before multi-country support was introduced.
|
|
13
|
+
* Use these constants wherever a country/currency is not (yet) explicit.
|
|
14
|
+
*/
|
|
15
|
+
exports.DEFAULT_COUNTRY_CODE = country_code_enum_1.CountryCode.KE;
|
|
16
|
+
exports.DEFAULT_CURRENCY_CODE = currency_code_enum_1.CurrencyCode.KES;
|
|
17
|
+
exports.DEFAULT_CALLING_CODE = calling_code_enum_1.CallingCode.KE;
|
|
18
|
+
exports.DEFAULT_TIMEZONE = 'Africa/Nairobi';
|
|
19
|
+
exports.DEFAULT_LOCALE = 'en-KE';
|
|
20
|
+
//# sourceMappingURL=country-defaults.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-defaults.const.js","sourceRoot":"","sources":["../../../../../src/modules/country/constants/country-defaults.const.ts"],"names":[],"mappings":";;;AAAA,kEAAyD;AACzD,kEAAyD;AACzD,oEAA2D;AAE3D;;;;;;;GAOG;AACU,QAAA,oBAAoB,GAAgB,+BAAW,CAAC,EAAE,CAAC;AACnD,QAAA,qBAAqB,GAAiB,iCAAY,CAAC,GAAG,CAAC;AACvD,QAAA,oBAAoB,GAAW,+BAAW,CAAC,EAAE,CAAC;AAC9C,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,cAAc,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_COUNTRIES = exports.SUPPORTED_COUNTRIES_BY_CODE = void 0;
|
|
4
|
+
const calling_code_enum_1 = require("../enums/calling-code.enum");
|
|
5
|
+
const country_code_enum_1 = require("../enums/country-code.enum");
|
|
6
|
+
const currency_code_enum_1 = require("../enums/currency-code.enum");
|
|
7
|
+
/**
|
|
8
|
+
* Supported countries keyed by ISO 3166-1 alpha-2 code (source of truth,
|
|
9
|
+
* O(1) lookup).
|
|
10
|
+
*
|
|
11
|
+
* The `Record<CountryCode, ...>` typing enforces at compile time that every
|
|
12
|
+
* country code has a configuration entry. Map centers are the capital cities;
|
|
13
|
+
* bounds are approximate country bounding boxes and can be refined later.
|
|
14
|
+
*/
|
|
15
|
+
exports.SUPPORTED_COUNTRIES_BY_CODE = {
|
|
16
|
+
[country_code_enum_1.CountryCode.KE]: {
|
|
17
|
+
code: country_code_enum_1.CountryCode.KE,
|
|
18
|
+
name: 'Kenya',
|
|
19
|
+
callingCode: calling_code_enum_1.CallingCode.KE,
|
|
20
|
+
currencyCode: currency_code_enum_1.CurrencyCode.KES,
|
|
21
|
+
currencySymbol: 'KSh',
|
|
22
|
+
currencyDecimalPlaces: 2,
|
|
23
|
+
timezone: 'Africa/Nairobi',
|
|
24
|
+
defaultLocale: 'en-KE',
|
|
25
|
+
googleMapsRegion: 'KE',
|
|
26
|
+
defaultMapCenter: { lat: -1.2921, lng: 36.8219 }, // Nairobi
|
|
27
|
+
defaultMapZoom: 6,
|
|
28
|
+
mapBounds: { north: 5.019, south: -4.72, east: 41.899, west: 33.909 },
|
|
29
|
+
enabled: true,
|
|
30
|
+
},
|
|
31
|
+
[country_code_enum_1.CountryCode.UG]: {
|
|
32
|
+
code: country_code_enum_1.CountryCode.UG,
|
|
33
|
+
name: 'Uganda',
|
|
34
|
+
callingCode: calling_code_enum_1.CallingCode.UG,
|
|
35
|
+
currencyCode: currency_code_enum_1.CurrencyCode.UGX,
|
|
36
|
+
currencySymbol: 'USh',
|
|
37
|
+
currencyDecimalPlaces: 0,
|
|
38
|
+
timezone: 'Africa/Kampala',
|
|
39
|
+
defaultLocale: 'en-UG',
|
|
40
|
+
googleMapsRegion: 'UG',
|
|
41
|
+
defaultMapCenter: { lat: 0.3476, lng: 32.5825 }, // Kampala
|
|
42
|
+
defaultMapZoom: 6,
|
|
43
|
+
mapBounds: { north: 4.234, south: -1.482, east: 35.036, west: 29.573 },
|
|
44
|
+
enabled: true,
|
|
45
|
+
},
|
|
46
|
+
[country_code_enum_1.CountryCode.TZ]: {
|
|
47
|
+
code: country_code_enum_1.CountryCode.TZ,
|
|
48
|
+
name: 'Tanzania',
|
|
49
|
+
callingCode: calling_code_enum_1.CallingCode.TZ,
|
|
50
|
+
currencyCode: currency_code_enum_1.CurrencyCode.TZS,
|
|
51
|
+
currencySymbol: 'TSh',
|
|
52
|
+
currencyDecimalPlaces: 0,
|
|
53
|
+
timezone: 'Africa/Dar_es_Salaam',
|
|
54
|
+
defaultLocale: 'en-TZ',
|
|
55
|
+
googleMapsRegion: 'TZ',
|
|
56
|
+
defaultMapCenter: { lat: -6.7924, lng: 39.2083 }, // Dar es Salaam
|
|
57
|
+
defaultMapZoom: 6,
|
|
58
|
+
mapBounds: { north: -0.984, south: -11.761, east: 40.444, west: 29.327 },
|
|
59
|
+
enabled: true,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
/** Supported countries as an array (convenient for iteration / pickers). */
|
|
63
|
+
exports.SUPPORTED_COUNTRIES = Object.values(exports.SUPPORTED_COUNTRIES_BY_CODE);
|
|
64
|
+
//# sourceMappingURL=supported-countries.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-countries.const.js","sourceRoot":"","sources":["../../../../../src/modules/country/constants/supported-countries.const.ts"],"names":[],"mappings":";;;AAAA,kEAAyD;AACzD,kEAAyD;AACzD,oEAA2D;AAG3D;;;;;;;GAOG;AACU,QAAA,2BAA2B,GAA0D;IAC9F,CAAC,+BAAW,CAAC,EAAE,CAAC,EAAE;QACd,IAAI,EAAE,+BAAW,CAAC,EAAE;QACpB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,+BAAW,CAAC,EAAE;QAC3B,YAAY,EAAE,iCAAY,CAAC,GAAG;QAC9B,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,gBAAgB;QAC1B,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,UAAU;QAC5D,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACrE,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,+BAAW,CAAC,EAAE,CAAC,EAAE;QACd,IAAI,EAAE,+BAAW,CAAC,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,+BAAW,CAAC,EAAE;QAC3B,YAAY,EAAE,iCAAY,CAAC,GAAG;QAC9B,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,gBAAgB;QAC1B,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,UAAU;QAC3D,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACtE,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,+BAAW,CAAC,EAAE,CAAC,EAAE;QACd,IAAI,EAAE,+BAAW,CAAC,EAAE;QACpB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,+BAAW,CAAC,EAAE;QAC3B,YAAY,EAAE,iCAAY,CAAC,GAAG;QAC9B,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,sBAAsB;QAChC,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,gBAAgB;QAClE,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACxE,OAAO,EAAE,IAAI;KAChB;CACJ,CAAC;AAEF,4EAA4E;AAC/D,QAAA,mBAAmB,GAC5B,MAAM,CAAC,MAAM,CAAC,mCAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_CURRENCIES = exports.SUPPORTED_CURRENCIES_BY_CODE = void 0;
|
|
4
|
+
const currency_code_enum_1 = require("../enums/currency-code.enum");
|
|
5
|
+
/**
|
|
6
|
+
* Supported currencies keyed by ISO 4217 code (source of truth, O(1) lookup).
|
|
7
|
+
*
|
|
8
|
+
* The `Record<CurrencyCode, ...>` typing enforces at compile time that every
|
|
9
|
+
* currency code has a configuration entry.
|
|
10
|
+
*/
|
|
11
|
+
exports.SUPPORTED_CURRENCIES_BY_CODE = {
|
|
12
|
+
[currency_code_enum_1.CurrencyCode.KES]: {
|
|
13
|
+
code: currency_code_enum_1.CurrencyCode.KES,
|
|
14
|
+
name: 'Kenyan Shilling',
|
|
15
|
+
symbol: 'KSh',
|
|
16
|
+
decimalPlaces: 2,
|
|
17
|
+
enabled: true,
|
|
18
|
+
},
|
|
19
|
+
[currency_code_enum_1.CurrencyCode.UGX]: {
|
|
20
|
+
code: currency_code_enum_1.CurrencyCode.UGX,
|
|
21
|
+
name: 'Ugandan Shilling',
|
|
22
|
+
symbol: 'USh',
|
|
23
|
+
decimalPlaces: 0,
|
|
24
|
+
enabled: true,
|
|
25
|
+
},
|
|
26
|
+
[currency_code_enum_1.CurrencyCode.TZS]: {
|
|
27
|
+
code: currency_code_enum_1.CurrencyCode.TZS,
|
|
28
|
+
name: 'Tanzanian Shilling',
|
|
29
|
+
symbol: 'TSh',
|
|
30
|
+
decimalPlaces: 0,
|
|
31
|
+
enabled: true,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
/** Supported currencies as an array (convenient for iteration / pickers). */
|
|
35
|
+
exports.SUPPORTED_CURRENCIES = Object.values(exports.SUPPORTED_CURRENCIES_BY_CODE);
|
|
36
|
+
//# sourceMappingURL=supported-currencies.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-currencies.const.js","sourceRoot":"","sources":["../../../../../src/modules/country/constants/supported-currencies.const.ts"],"names":[],"mappings":";;;AAAA,oEAA2D;AAG3D;;;;;GAKG;AACU,QAAA,4BAA4B,GAA4D;IACjG,CAAC,iCAAY,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,EAAE,iCAAY,CAAC,GAAG;QACtB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,iCAAY,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,EAAE,iCAAY,CAAC,GAAG;QACtB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,iCAAY,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,EAAE,iCAAY,CAAC,GAAG;QACtB,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI;KAChB;CACJ,CAAC;AAEF,6EAA6E;AAChE,QAAA,oBAAoB,GAC7B,MAAM,CAAC,MAAM,CAAC,oCAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CountryScopeDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const country_code_enum_1 = require("../enums/country-code.enum");
|
|
16
|
+
const currency_code_enum_1 = require("../enums/currency-code.enum");
|
|
17
|
+
/**
|
|
18
|
+
* Reusable, optional country/currency scope for requests and queries.
|
|
19
|
+
*
|
|
20
|
+
* Compose or extend this into country-aware DTOs (newsfeed posts, service
|
|
21
|
+
* packages, billing queries, ...). Both fields are optional so existing
|
|
22
|
+
* single-country (Kenya) requests remain valid without any change.
|
|
23
|
+
*/
|
|
24
|
+
class CountryScopeDto {
|
|
25
|
+
}
|
|
26
|
+
exports.CountryScopeDto = CountryScopeDto;
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
29
|
+
description: 'ISO 3166-1 alpha-2 country code the request is scoped to',
|
|
30
|
+
enum: country_code_enum_1.CountryCode,
|
|
31
|
+
example: country_code_enum_1.CountryCode.KE,
|
|
32
|
+
}),
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
(0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], CountryScopeDto.prototype, "countryCode", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
39
|
+
description: 'ISO 4217 currency code the request is scoped to',
|
|
40
|
+
enum: currency_code_enum_1.CurrencyCode,
|
|
41
|
+
example: currency_code_enum_1.CurrencyCode.KES,
|
|
42
|
+
}),
|
|
43
|
+
(0, class_validator_1.IsOptional)(),
|
|
44
|
+
(0, class_validator_1.IsEnum)(currency_code_enum_1.CurrencyCode),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], CountryScopeDto.prototype, "currencyCode", void 0);
|
|
47
|
+
//# sourceMappingURL=country-scope.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-scope.dto.js","sourceRoot":"","sources":["../../../../../src/modules/country/dtos/country-scope.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAsD;AACtD,qDAAqD;AACrD,kEAAyD;AACzD,oEAA2D;AAE3D;;;;;;GAMG;AACH,MAAa,eAAe;CAkB3B;AAlBD,0CAkBC;AAVG;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,0DAA0D;QACvE,IAAI,EAAE,+BAAW;QACjB,OAAO,EAAE,+BAAW,CAAC,EAAE;KAC1B,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,+BAAW,CAAC;;oDACM;AAS1B;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,iCAAY;QAClB,OAAO,EAAE,iCAAY,CAAC,GAAG;KAC5B,CAAC;IACD,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,iCAAY,CAAC;;qDACO"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallingCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* E.164 country calling codes, keyed by ISO 3166-1 alpha-2 country code.
|
|
6
|
+
*
|
|
7
|
+
* Kept as a string enum so the value (e.g. '+254') can be used directly when
|
|
8
|
+
* composing phone numbers, and the key (e.g. KE) aligns with {@link CountryCode}.
|
|
9
|
+
*/
|
|
10
|
+
var CallingCode;
|
|
11
|
+
(function (CallingCode) {
|
|
12
|
+
/** Kenya */
|
|
13
|
+
CallingCode["KE"] = "+254";
|
|
14
|
+
/** Uganda */
|
|
15
|
+
CallingCode["UG"] = "+256";
|
|
16
|
+
/** Tanzania */
|
|
17
|
+
CallingCode["TZ"] = "+255";
|
|
18
|
+
})(CallingCode || (exports.CallingCode = CallingCode = {}));
|
|
19
|
+
//# sourceMappingURL=calling-code.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calling-code.enum.js","sourceRoot":"","sources":["../../../../../src/modules/country/enums/calling-code.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,YAAY;IACZ,0BAAW,CAAA;IACX,aAAa;IACb,0BAAW,CAAA;IACX,eAAe;IACf,0BAAW,CAAA;AACf,CAAC,EAPW,WAAW,2BAAX,WAAW,QAOtB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CountryCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Supported country codes.
|
|
6
|
+
*
|
|
7
|
+
* ISO 3166-1 alpha-2 country codes. These are the platform-level identifiers
|
|
8
|
+
* for every country the Clarion / Upesy platform operates in.
|
|
9
|
+
*
|
|
10
|
+
* Kenya (KE) is the default/backward-compatible market.
|
|
11
|
+
*/
|
|
12
|
+
var CountryCode;
|
|
13
|
+
(function (CountryCode) {
|
|
14
|
+
/** Kenya */
|
|
15
|
+
CountryCode["KE"] = "KE";
|
|
16
|
+
/** Uganda */
|
|
17
|
+
CountryCode["UG"] = "UG";
|
|
18
|
+
/** Tanzania */
|
|
19
|
+
CountryCode["TZ"] = "TZ";
|
|
20
|
+
})(CountryCode || (exports.CountryCode = CountryCode = {}));
|
|
21
|
+
//# sourceMappingURL=country-code.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-code.enum.js","sourceRoot":"","sources":["../../../../../src/modules/country/enums/country-code.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,YAAY;IACZ,wBAAS,CAAA;IACT,aAAa;IACb,wBAAS,CAAA;IACT,eAAe;IACf,wBAAS,CAAA;AACb,CAAC,EAPW,WAAW,2BAAX,WAAW,QAOtB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CurrencyCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Supported currency codes.
|
|
6
|
+
*
|
|
7
|
+
* ISO 4217 currency codes for the markets the platform operates in.
|
|
8
|
+
*
|
|
9
|
+
* KES (Kenyan Shilling) is the default/backward-compatible currency.
|
|
10
|
+
*/
|
|
11
|
+
var CurrencyCode;
|
|
12
|
+
(function (CurrencyCode) {
|
|
13
|
+
/** Kenyan Shilling */
|
|
14
|
+
CurrencyCode["KES"] = "KES";
|
|
15
|
+
/** Ugandan Shilling */
|
|
16
|
+
CurrencyCode["UGX"] = "UGX";
|
|
17
|
+
/** Tanzanian Shilling */
|
|
18
|
+
CurrencyCode["TZS"] = "TZS";
|
|
19
|
+
})(CurrencyCode || (exports.CurrencyCode = CurrencyCode = {}));
|
|
20
|
+
//# sourceMappingURL=currency-code.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency-code.enum.js","sourceRoot":"","sources":["../../../../../src/modules/country/enums/currency-code.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,IAAY,YAOX;AAPD,WAAY,YAAY;IACpB,sBAAsB;IACtB,2BAAW,CAAA;IACX,uBAAuB;IACvB,2BAAW,CAAA;IACX,yBAAyB;IACzB,2BAAW,CAAA;AACf,CAAC,EAPW,YAAY,4BAAZ,YAAY,QAOvB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Enums
|
|
18
|
+
__exportStar(require("./enums/country-code.enum"), exports);
|
|
19
|
+
__exportStar(require("./enums/currency-code.enum"), exports);
|
|
20
|
+
__exportStar(require("./enums/calling-code.enum"), exports);
|
|
21
|
+
// Interfaces
|
|
22
|
+
__exportStar(require("./interfaces/geo-coordinates"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/map-bounds"), exports);
|
|
24
|
+
__exportStar(require("./interfaces/supported-currency-config"), exports);
|
|
25
|
+
__exportStar(require("./interfaces/supported-country-config"), exports);
|
|
26
|
+
// Constants
|
|
27
|
+
__exportStar(require("./constants/supported-currencies.const"), exports);
|
|
28
|
+
__exportStar(require("./constants/supported-countries.const"), exports);
|
|
29
|
+
__exportStar(require("./constants/country-defaults.const"), exports);
|
|
30
|
+
// DTOs
|
|
31
|
+
__exportStar(require("./dtos/country-scope.dto"), exports);
|
|
32
|
+
// Utilities
|
|
33
|
+
__exportStar(require("./utils/country.util"), exports);
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/country/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,4DAA0C;AAC1C,6DAA2C;AAC3C,4DAA0C;AAE1C,aAAa;AACb,+DAA6C;AAC7C,0DAAwC;AACxC,yEAAuD;AACvD,wEAAsD;AAEtD,YAAY;AACZ,yEAAuD;AACvD,wEAAsD;AACtD,qEAAmD;AAEnD,OAAO;AACP,2DAAyC;AAEzC,YAAY;AACZ,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo-coordinates.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/geo-coordinates.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-bounds.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/map-bounds.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-country-config.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/supported-country-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-currency-config.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/supported-currency-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSupportedCountryCode = isSupportedCountryCode;
|
|
4
|
+
exports.isSupportedCurrencyCode = isSupportedCurrencyCode;
|
|
5
|
+
exports.getSupportedCountryConfig = getSupportedCountryConfig;
|
|
6
|
+
exports.getSupportedCurrencyConfig = getSupportedCurrencyConfig;
|
|
7
|
+
exports.getCurrencyForCountry = getCurrencyForCountry;
|
|
8
|
+
exports.getCallingCodeForCountry = getCallingCodeForCountry;
|
|
9
|
+
exports.getCountryByCallingCode = getCountryByCallingCode;
|
|
10
|
+
const supported_countries_const_1 = require("../constants/supported-countries.const");
|
|
11
|
+
const supported_currencies_const_1 = require("../constants/supported-currencies.const");
|
|
12
|
+
/**
|
|
13
|
+
* Country / currency helper utilities.
|
|
14
|
+
*
|
|
15
|
+
* These are intentionally simple, synchronous and dependency-free so they can
|
|
16
|
+
* be reused across every backend microservice without pulling in extra deps.
|
|
17
|
+
*/
|
|
18
|
+
/** Type guard: is `value` a supported ISO 3166-1 alpha-2 country code? */
|
|
19
|
+
function isSupportedCountryCode(value) {
|
|
20
|
+
return (typeof value === 'string' &&
|
|
21
|
+
Object.prototype.hasOwnProperty.call(supported_countries_const_1.SUPPORTED_COUNTRIES_BY_CODE, value));
|
|
22
|
+
}
|
|
23
|
+
/** Type guard: is `value` a supported ISO 4217 currency code? */
|
|
24
|
+
function isSupportedCurrencyCode(value) {
|
|
25
|
+
return (typeof value === 'string' &&
|
|
26
|
+
Object.prototype.hasOwnProperty.call(supported_currencies_const_1.SUPPORTED_CURRENCIES_BY_CODE, value));
|
|
27
|
+
}
|
|
28
|
+
/** Get the full config for a supported country, or `undefined` if unsupported. */
|
|
29
|
+
function getSupportedCountryConfig(countryCode) {
|
|
30
|
+
return isSupportedCountryCode(countryCode)
|
|
31
|
+
? supported_countries_const_1.SUPPORTED_COUNTRIES_BY_CODE[countryCode]
|
|
32
|
+
: undefined;
|
|
33
|
+
}
|
|
34
|
+
/** Get the full config for a supported currency, or `undefined` if unsupported. */
|
|
35
|
+
function getSupportedCurrencyConfig(currencyCode) {
|
|
36
|
+
return isSupportedCurrencyCode(currencyCode)
|
|
37
|
+
? supported_currencies_const_1.SUPPORTED_CURRENCIES_BY_CODE[currencyCode]
|
|
38
|
+
: undefined;
|
|
39
|
+
}
|
|
40
|
+
/** Resolve the currency used by a supported country, or `undefined`. */
|
|
41
|
+
function getCurrencyForCountry(countryCode) {
|
|
42
|
+
var _a;
|
|
43
|
+
return (_a = getSupportedCountryConfig(countryCode)) === null || _a === void 0 ? void 0 : _a.currencyCode;
|
|
44
|
+
}
|
|
45
|
+
/** Resolve the E.164 calling code (e.g. '+254') for a supported country, or `undefined`. */
|
|
46
|
+
function getCallingCodeForCountry(countryCode) {
|
|
47
|
+
var _a;
|
|
48
|
+
return (_a = getSupportedCountryConfig(countryCode)) === null || _a === void 0 ? void 0 : _a.callingCode;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Reverse lookup: find the supported country whose E.164 calling code matches
|
|
52
|
+
* `callingCode` (e.g. '+254' -> Kenya), or `undefined` if none match.
|
|
53
|
+
*/
|
|
54
|
+
function getCountryByCallingCode(callingCode) {
|
|
55
|
+
if (!callingCode) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return supported_countries_const_1.SUPPORTED_COUNTRIES.find((country) => country.callingCode === callingCode);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=country.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country.util.js","sourceRoot":"","sources":["../../../../../src/modules/country/utils/country.util.ts"],"names":[],"mappings":";;AAeA,wDAKC;AAGD,0DAKC;AAGD,8DAMC;AAGD,gEAMC;AAGD,sDAIC;AAGD,4DAIC;AAMD,0DAOC;AAzED,sFAA0G;AAC1G,wFAAuF;AAMvF;;;;;GAKG;AAEH,0EAA0E;AAC1E,SAAgB,sBAAsB,CAAC,KAAc;IACjD,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,uDAA2B,EAAE,KAAK,CAAC,CAC3E,CAAC;AACN,CAAC;AAED,iEAAiE;AACjE,SAAgB,uBAAuB,CAAC,KAAc;IAClD,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,yDAA4B,EAAE,KAAK,CAAC,CAC5E,CAAC;AACN,CAAC;AAED,kFAAkF;AAClF,SAAgB,yBAAyB,CACrC,WAAsC;IAEtC,OAAO,sBAAsB,CAAC,WAAW,CAAC;QACtC,CAAC,CAAC,uDAA2B,CAAC,WAAW,CAAC;QAC1C,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AAED,mFAAmF;AACnF,SAAgB,0BAA0B,CACtC,YAAuC;IAEvC,OAAO,uBAAuB,CAAC,YAAY,CAAC;QACxC,CAAC,CAAC,yDAA4B,CAAC,YAAY,CAAC;QAC5C,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AAED,wEAAwE;AACxE,SAAgB,qBAAqB,CACjC,WAAsC;;IAEtC,OAAO,MAAA,yBAAyB,CAAC,WAAW,CAAC,0CAAE,YAAY,CAAC;AAChE,CAAC;AAED,4FAA4F;AAC5F,SAAgB,wBAAwB,CACpC,WAAsC;;IAEtC,OAAO,MAAA,yBAAyB,CAAC,WAAW,CAAC,0CAAE,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACnC,WAAsC;IAEtC,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,+CAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC;AACtF,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from './modules/socket/index';
|
|
|
17
17
|
export * from './modules/web-notification/index';
|
|
18
18
|
export * from './modules/notification/index';
|
|
19
19
|
export * from './modules/chat/index';
|
|
20
|
+
export * from './modules/country/index';
|
|
20
21
|
// Interfaces
|
|
21
22
|
export * from './interfaces/server-message';
|
|
22
23
|
export * from './interfaces/i-request-with-user';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AAExC,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,YAAY;AACZ,cAAc,0BAA0B,CAAC;AAEzC,QAAQ;AACR,cAAc,eAAe,CAAC;AAE9B,YAAY;AACZ,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uDAAuD,CAAC;AAEtE,aAAa;AACb,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CallingCode } from '../enums/calling-code.enum';
|
|
2
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
3
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
4
|
+
/**
|
|
5
|
+
* Platform defaults.
|
|
6
|
+
*
|
|
7
|
+
* Kenya remains the default / backward-compatible market: existing users,
|
|
8
|
+
* packages, posts, incidents, OTPs, notifications and billing flows continue
|
|
9
|
+
* to behave exactly as they did before multi-country support was introduced.
|
|
10
|
+
* Use these constants wherever a country/currency is not (yet) explicit.
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_COUNTRY_CODE = CountryCode.KE;
|
|
13
|
+
export const DEFAULT_CURRENCY_CODE = CurrencyCode.KES;
|
|
14
|
+
export const DEFAULT_CALLING_CODE = CallingCode.KE;
|
|
15
|
+
export const DEFAULT_TIMEZONE = 'Africa/Nairobi';
|
|
16
|
+
export const DEFAULT_LOCALE = 'en-KE';
|
|
17
|
+
//# sourceMappingURL=country-defaults.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-defaults.const.js","sourceRoot":"","sources":["../../../../../src/modules/country/constants/country-defaults.const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB,WAAW,CAAC,EAAE,CAAC;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAiB,YAAY,CAAC,GAAG,CAAC;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAW,WAAW,CAAC,EAAE,CAAC;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CallingCode } from '../enums/calling-code.enum';
|
|
2
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
3
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
4
|
+
/**
|
|
5
|
+
* Supported countries keyed by ISO 3166-1 alpha-2 code (source of truth,
|
|
6
|
+
* O(1) lookup).
|
|
7
|
+
*
|
|
8
|
+
* The `Record<CountryCode, ...>` typing enforces at compile time that every
|
|
9
|
+
* country code has a configuration entry. Map centers are the capital cities;
|
|
10
|
+
* bounds are approximate country bounding boxes and can be refined later.
|
|
11
|
+
*/
|
|
12
|
+
export const SUPPORTED_COUNTRIES_BY_CODE = {
|
|
13
|
+
[CountryCode.KE]: {
|
|
14
|
+
code: CountryCode.KE,
|
|
15
|
+
name: 'Kenya',
|
|
16
|
+
callingCode: CallingCode.KE,
|
|
17
|
+
currencyCode: CurrencyCode.KES,
|
|
18
|
+
currencySymbol: 'KSh',
|
|
19
|
+
currencyDecimalPlaces: 2,
|
|
20
|
+
timezone: 'Africa/Nairobi',
|
|
21
|
+
defaultLocale: 'en-KE',
|
|
22
|
+
googleMapsRegion: 'KE',
|
|
23
|
+
defaultMapCenter: { lat: -1.2921, lng: 36.8219 }, // Nairobi
|
|
24
|
+
defaultMapZoom: 6,
|
|
25
|
+
mapBounds: { north: 5.019, south: -4.72, east: 41.899, west: 33.909 },
|
|
26
|
+
enabled: true,
|
|
27
|
+
},
|
|
28
|
+
[CountryCode.UG]: {
|
|
29
|
+
code: CountryCode.UG,
|
|
30
|
+
name: 'Uganda',
|
|
31
|
+
callingCode: CallingCode.UG,
|
|
32
|
+
currencyCode: CurrencyCode.UGX,
|
|
33
|
+
currencySymbol: 'USh',
|
|
34
|
+
currencyDecimalPlaces: 0,
|
|
35
|
+
timezone: 'Africa/Kampala',
|
|
36
|
+
defaultLocale: 'en-UG',
|
|
37
|
+
googleMapsRegion: 'UG',
|
|
38
|
+
defaultMapCenter: { lat: 0.3476, lng: 32.5825 }, // Kampala
|
|
39
|
+
defaultMapZoom: 6,
|
|
40
|
+
mapBounds: { north: 4.234, south: -1.482, east: 35.036, west: 29.573 },
|
|
41
|
+
enabled: true,
|
|
42
|
+
},
|
|
43
|
+
[CountryCode.TZ]: {
|
|
44
|
+
code: CountryCode.TZ,
|
|
45
|
+
name: 'Tanzania',
|
|
46
|
+
callingCode: CallingCode.TZ,
|
|
47
|
+
currencyCode: CurrencyCode.TZS,
|
|
48
|
+
currencySymbol: 'TSh',
|
|
49
|
+
currencyDecimalPlaces: 0,
|
|
50
|
+
timezone: 'Africa/Dar_es_Salaam',
|
|
51
|
+
defaultLocale: 'en-TZ',
|
|
52
|
+
googleMapsRegion: 'TZ',
|
|
53
|
+
defaultMapCenter: { lat: -6.7924, lng: 39.2083 }, // Dar es Salaam
|
|
54
|
+
defaultMapZoom: 6,
|
|
55
|
+
mapBounds: { north: -0.984, south: -11.761, east: 40.444, west: 29.327 },
|
|
56
|
+
enabled: true,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
/** Supported countries as an array (convenient for iteration / pickers). */
|
|
60
|
+
export const SUPPORTED_COUNTRIES = Object.values(SUPPORTED_COUNTRIES_BY_CODE);
|
|
61
|
+
//# sourceMappingURL=supported-countries.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-countries.const.js","sourceRoot":"","sources":["../../../../../src/modules/country/constants/supported-countries.const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAA0D;IAC9F,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;QACd,IAAI,EAAE,WAAW,CAAC,EAAE;QACpB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,WAAW,CAAC,EAAE;QAC3B,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,gBAAgB;QAC1B,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,UAAU;QAC5D,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACrE,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;QACd,IAAI,EAAE,WAAW,CAAC,EAAE;QACpB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,WAAW,CAAC,EAAE;QAC3B,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,gBAAgB;QAC1B,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,UAAU;QAC3D,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACtE,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;QACd,IAAI,EAAE,WAAW,CAAC,EAAE;QACpB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,WAAW,CAAC,EAAE;QAC3B,YAAY,EAAE,YAAY,CAAC,GAAG;QAC9B,cAAc,EAAE,KAAK;QACrB,qBAAqB,EAAE,CAAC;QACxB,QAAQ,EAAE,sBAAsB;QAChC,aAAa,EAAE,OAAO;QACtB,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,gBAAgB;QAClE,cAAc,EAAE,CAAC;QACjB,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;QACxE,OAAO,EAAE,IAAI;KAChB;CACJ,CAAC;AAEF,4EAA4E;AAC5E,MAAM,CAAC,MAAM,mBAAmB,GAC5B,MAAM,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
2
|
+
/**
|
|
3
|
+
* Supported currencies keyed by ISO 4217 code (source of truth, O(1) lookup).
|
|
4
|
+
*
|
|
5
|
+
* The `Record<CurrencyCode, ...>` typing enforces at compile time that every
|
|
6
|
+
* currency code has a configuration entry.
|
|
7
|
+
*/
|
|
8
|
+
export const SUPPORTED_CURRENCIES_BY_CODE = {
|
|
9
|
+
[CurrencyCode.KES]: {
|
|
10
|
+
code: CurrencyCode.KES,
|
|
11
|
+
name: 'Kenyan Shilling',
|
|
12
|
+
symbol: 'KSh',
|
|
13
|
+
decimalPlaces: 2,
|
|
14
|
+
enabled: true,
|
|
15
|
+
},
|
|
16
|
+
[CurrencyCode.UGX]: {
|
|
17
|
+
code: CurrencyCode.UGX,
|
|
18
|
+
name: 'Ugandan Shilling',
|
|
19
|
+
symbol: 'USh',
|
|
20
|
+
decimalPlaces: 0,
|
|
21
|
+
enabled: true,
|
|
22
|
+
},
|
|
23
|
+
[CurrencyCode.TZS]: {
|
|
24
|
+
code: CurrencyCode.TZS,
|
|
25
|
+
name: 'Tanzanian Shilling',
|
|
26
|
+
symbol: 'TSh',
|
|
27
|
+
decimalPlaces: 0,
|
|
28
|
+
enabled: true,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/** Supported currencies as an array (convenient for iteration / pickers). */
|
|
32
|
+
export const SUPPORTED_CURRENCIES = Object.values(SUPPORTED_CURRENCIES_BY_CODE);
|
|
33
|
+
//# sourceMappingURL=supported-currencies.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-currencies.const.js","sourceRoot":"","sources":["../../../../../src/modules/country/constants/supported-currencies.const.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAA4D;IACjG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,EAAE,YAAY,CAAC,GAAG;QACtB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,EAAE,YAAY,CAAC,GAAG;QACtB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI;KAChB;IACD,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;QAChB,IAAI,EAAE,YAAY,CAAC,GAAG;QACtB,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,CAAC;QAChB,OAAO,EAAE,IAAI;KAChB;CACJ,CAAC;AAEF,6EAA6E;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAC7B,MAAM,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
11
|
+
import { IsEnum, IsOptional } from 'class-validator';
|
|
12
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
13
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
14
|
+
/**
|
|
15
|
+
* Reusable, optional country/currency scope for requests and queries.
|
|
16
|
+
*
|
|
17
|
+
* Compose or extend this into country-aware DTOs (newsfeed posts, service
|
|
18
|
+
* packages, billing queries, ...). Both fields are optional so existing
|
|
19
|
+
* single-country (Kenya) requests remain valid without any change.
|
|
20
|
+
*/
|
|
21
|
+
export class CountryScopeDto {
|
|
22
|
+
}
|
|
23
|
+
__decorate([
|
|
24
|
+
ApiPropertyOptional({
|
|
25
|
+
description: 'ISO 3166-1 alpha-2 country code the request is scoped to',
|
|
26
|
+
enum: CountryCode,
|
|
27
|
+
example: CountryCode.KE,
|
|
28
|
+
}),
|
|
29
|
+
IsOptional(),
|
|
30
|
+
IsEnum(CountryCode),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], CountryScopeDto.prototype, "countryCode", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
ApiPropertyOptional({
|
|
35
|
+
description: 'ISO 4217 currency code the request is scoped to',
|
|
36
|
+
enum: CurrencyCode,
|
|
37
|
+
example: CurrencyCode.KES,
|
|
38
|
+
}),
|
|
39
|
+
IsOptional(),
|
|
40
|
+
IsEnum(CurrencyCode),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], CountryScopeDto.prototype, "currencyCode", void 0);
|
|
43
|
+
//# sourceMappingURL=country-scope.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-scope.dto.js","sourceRoot":"","sources":["../../../../../src/modules/country/dtos/country-scope.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;CAkB3B;AAVG;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,0DAA0D;QACvE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,WAAW,CAAC,EAAE;KAC1B,CAAC;IACD,UAAU,EAAE;IACZ,MAAM,CAAC,WAAW,CAAC;;oDACM;AAS1B;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,YAAY,CAAC,GAAG;KAC5B,CAAC;IACD,UAAU,EAAE;IACZ,MAAM,CAAC,YAAY,CAAC;;qDACO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E.164 country calling codes, keyed by ISO 3166-1 alpha-2 country code.
|
|
3
|
+
*
|
|
4
|
+
* Kept as a string enum so the value (e.g. '+254') can be used directly when
|
|
5
|
+
* composing phone numbers, and the key (e.g. KE) aligns with {@link CountryCode}.
|
|
6
|
+
*/
|
|
7
|
+
export var CallingCode;
|
|
8
|
+
(function (CallingCode) {
|
|
9
|
+
/** Kenya */
|
|
10
|
+
CallingCode["KE"] = "+254";
|
|
11
|
+
/** Uganda */
|
|
12
|
+
CallingCode["UG"] = "+256";
|
|
13
|
+
/** Tanzania */
|
|
14
|
+
CallingCode["TZ"] = "+255";
|
|
15
|
+
})(CallingCode || (CallingCode = {}));
|
|
16
|
+
//# sourceMappingURL=calling-code.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calling-code.enum.js","sourceRoot":"","sources":["../../../../../src/modules/country/enums/calling-code.enum.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,YAAY;IACZ,0BAAW,CAAA;IACX,aAAa;IACb,0BAAW,CAAA;IACX,eAAe;IACf,0BAAW,CAAA;AACf,CAAC,EAPW,WAAW,KAAX,WAAW,QAOtB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported country codes.
|
|
3
|
+
*
|
|
4
|
+
* ISO 3166-1 alpha-2 country codes. These are the platform-level identifiers
|
|
5
|
+
* for every country the Clarion / Upesy platform operates in.
|
|
6
|
+
*
|
|
7
|
+
* Kenya (KE) is the default/backward-compatible market.
|
|
8
|
+
*/
|
|
9
|
+
export var CountryCode;
|
|
10
|
+
(function (CountryCode) {
|
|
11
|
+
/** Kenya */
|
|
12
|
+
CountryCode["KE"] = "KE";
|
|
13
|
+
/** Uganda */
|
|
14
|
+
CountryCode["UG"] = "UG";
|
|
15
|
+
/** Tanzania */
|
|
16
|
+
CountryCode["TZ"] = "TZ";
|
|
17
|
+
})(CountryCode || (CountryCode = {}));
|
|
18
|
+
//# sourceMappingURL=country-code.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country-code.enum.js","sourceRoot":"","sources":["../../../../../src/modules/country/enums/country-code.enum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,WAOX;AAPD,WAAY,WAAW;IACnB,YAAY;IACZ,wBAAS,CAAA;IACT,aAAa;IACb,wBAAS,CAAA;IACT,eAAe;IACf,wBAAS,CAAA;AACb,CAAC,EAPW,WAAW,KAAX,WAAW,QAOtB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported currency codes.
|
|
3
|
+
*
|
|
4
|
+
* ISO 4217 currency codes for the markets the platform operates in.
|
|
5
|
+
*
|
|
6
|
+
* KES (Kenyan Shilling) is the default/backward-compatible currency.
|
|
7
|
+
*/
|
|
8
|
+
export var CurrencyCode;
|
|
9
|
+
(function (CurrencyCode) {
|
|
10
|
+
/** Kenyan Shilling */
|
|
11
|
+
CurrencyCode["KES"] = "KES";
|
|
12
|
+
/** Ugandan Shilling */
|
|
13
|
+
CurrencyCode["UGX"] = "UGX";
|
|
14
|
+
/** Tanzanian Shilling */
|
|
15
|
+
CurrencyCode["TZS"] = "TZS";
|
|
16
|
+
})(CurrencyCode || (CurrencyCode = {}));
|
|
17
|
+
//# sourceMappingURL=currency-code.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency-code.enum.js","sourceRoot":"","sources":["../../../../../src/modules/country/enums/currency-code.enum.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACpB,sBAAsB;IACtB,2BAAW,CAAA;IACX,uBAAuB;IACvB,2BAAW,CAAA;IACX,yBAAyB;IACzB,2BAAW,CAAA;AACf,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Enums
|
|
2
|
+
export * from './enums/country-code.enum';
|
|
3
|
+
export * from './enums/currency-code.enum';
|
|
4
|
+
export * from './enums/calling-code.enum';
|
|
5
|
+
// Interfaces
|
|
6
|
+
export * from './interfaces/geo-coordinates';
|
|
7
|
+
export * from './interfaces/map-bounds';
|
|
8
|
+
export * from './interfaces/supported-currency-config';
|
|
9
|
+
export * from './interfaces/supported-country-config';
|
|
10
|
+
// Constants
|
|
11
|
+
export * from './constants/supported-currencies.const';
|
|
12
|
+
export * from './constants/supported-countries.const';
|
|
13
|
+
export * from './constants/country-defaults.const';
|
|
14
|
+
// DTOs
|
|
15
|
+
export * from './dtos/country-scope.dto';
|
|
16
|
+
// Utilities
|
|
17
|
+
export * from './utils/country.util';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/country/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAE1C,aAAa;AACb,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AAEtD,YAAY;AACZ,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AAEnD,OAAO;AACP,cAAc,0BAA0B,CAAC;AAEzC,YAAY;AACZ,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo-coordinates.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/geo-coordinates.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-bounds.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/map-bounds.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-country-config.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/supported-country-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supported-currency-config.js","sourceRoot":"","sources":["../../../../../src/modules/country/interfaces/supported-currency-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SUPPORTED_COUNTRIES, SUPPORTED_COUNTRIES_BY_CODE } from '../constants/supported-countries.const';
|
|
2
|
+
import { SUPPORTED_CURRENCIES_BY_CODE } from '../constants/supported-currencies.const';
|
|
3
|
+
/**
|
|
4
|
+
* Country / currency helper utilities.
|
|
5
|
+
*
|
|
6
|
+
* These are intentionally simple, synchronous and dependency-free so they can
|
|
7
|
+
* be reused across every backend microservice without pulling in extra deps.
|
|
8
|
+
*/
|
|
9
|
+
/** Type guard: is `value` a supported ISO 3166-1 alpha-2 country code? */
|
|
10
|
+
export function isSupportedCountryCode(value) {
|
|
11
|
+
return (typeof value === 'string' &&
|
|
12
|
+
Object.prototype.hasOwnProperty.call(SUPPORTED_COUNTRIES_BY_CODE, value));
|
|
13
|
+
}
|
|
14
|
+
/** Type guard: is `value` a supported ISO 4217 currency code? */
|
|
15
|
+
export function isSupportedCurrencyCode(value) {
|
|
16
|
+
return (typeof value === 'string' &&
|
|
17
|
+
Object.prototype.hasOwnProperty.call(SUPPORTED_CURRENCIES_BY_CODE, value));
|
|
18
|
+
}
|
|
19
|
+
/** Get the full config for a supported country, or `undefined` if unsupported. */
|
|
20
|
+
export function getSupportedCountryConfig(countryCode) {
|
|
21
|
+
return isSupportedCountryCode(countryCode)
|
|
22
|
+
? SUPPORTED_COUNTRIES_BY_CODE[countryCode]
|
|
23
|
+
: undefined;
|
|
24
|
+
}
|
|
25
|
+
/** Get the full config for a supported currency, or `undefined` if unsupported. */
|
|
26
|
+
export function getSupportedCurrencyConfig(currencyCode) {
|
|
27
|
+
return isSupportedCurrencyCode(currencyCode)
|
|
28
|
+
? SUPPORTED_CURRENCIES_BY_CODE[currencyCode]
|
|
29
|
+
: undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Resolve the currency used by a supported country, or `undefined`. */
|
|
32
|
+
export function getCurrencyForCountry(countryCode) {
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = getSupportedCountryConfig(countryCode)) === null || _a === void 0 ? void 0 : _a.currencyCode;
|
|
35
|
+
}
|
|
36
|
+
/** Resolve the E.164 calling code (e.g. '+254') for a supported country, or `undefined`. */
|
|
37
|
+
export function getCallingCodeForCountry(countryCode) {
|
|
38
|
+
var _a;
|
|
39
|
+
return (_a = getSupportedCountryConfig(countryCode)) === null || _a === void 0 ? void 0 : _a.callingCode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Reverse lookup: find the supported country whose E.164 calling code matches
|
|
43
|
+
* `callingCode` (e.g. '+254' -> Kenya), or `undefined` if none match.
|
|
44
|
+
*/
|
|
45
|
+
export function getCountryByCallingCode(callingCode) {
|
|
46
|
+
if (!callingCode) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
return SUPPORTED_COUNTRIES.find((country) => country.callingCode === callingCode);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=country.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"country.util.js","sourceRoot":"","sources":["../../../../../src/modules/country/utils/country.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AAMvF;;;;;GAKG;AAEH,0EAA0E;AAC1E,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACjD,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAC3E,CAAC;AACN,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,uBAAuB,CAAC,KAAc;IAClD,OAAO,CACH,OAAO,KAAK,KAAK,QAAQ;QACzB,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAC5E,CAAC;AACN,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,yBAAyB,CACrC,WAAsC;IAEtC,OAAO,sBAAsB,CAAC,WAAW,CAAC;QACtC,CAAC,CAAC,2BAA2B,CAAC,WAAW,CAAC;QAC1C,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,0BAA0B,CACtC,YAAuC;IAEvC,OAAO,uBAAuB,CAAC,YAAY,CAAC;QACxC,CAAC,CAAC,4BAA4B,CAAC,YAAY,CAAC;QAC5C,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,qBAAqB,CACjC,WAAsC;;IAEtC,OAAO,MAAA,yBAAyB,CAAC,WAAW,CAAC,0CAAE,YAAY,CAAC;AAChE,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,wBAAwB,CACpC,WAAsC;;IAEtC,OAAO,MAAA,yBAAyB,CAAC,WAAW,CAAC,0CAAE,WAAW,CAAC;AAC/D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACnC,WAAsC;IAEtC,IAAI,CAAC,WAAW,EAAE,CAAC;QACf,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,CAAC;AACtF,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from './modules/socket/index';
|
|
|
16
16
|
export * from './modules/web-notification/index';
|
|
17
17
|
export * from './modules/notification/index';
|
|
18
18
|
export * from './modules/chat/index';
|
|
19
|
+
export * from './modules/country/index';
|
|
19
20
|
export * from './interfaces/server-message';
|
|
20
21
|
export * from './interfaces/i-request-with-user';
|
|
21
22
|
export * from './interfaces/validated-user';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
3
|
+
/**
|
|
4
|
+
* Platform defaults.
|
|
5
|
+
*
|
|
6
|
+
* Kenya remains the default / backward-compatible market: existing users,
|
|
7
|
+
* packages, posts, incidents, OTPs, notifications and billing flows continue
|
|
8
|
+
* to behave exactly as they did before multi-country support was introduced.
|
|
9
|
+
* Use these constants wherever a country/currency is not (yet) explicit.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_COUNTRY_CODE: CountryCode;
|
|
12
|
+
export declare const DEFAULT_CURRENCY_CODE: CurrencyCode;
|
|
13
|
+
export declare const DEFAULT_CALLING_CODE: string;
|
|
14
|
+
export declare const DEFAULT_TIMEZONE = "Africa/Nairobi";
|
|
15
|
+
export declare const DEFAULT_LOCALE = "en-KE";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { SupportedCountryConfig } from '../interfaces/supported-country-config';
|
|
3
|
+
/**
|
|
4
|
+
* Supported countries keyed by ISO 3166-1 alpha-2 code (source of truth,
|
|
5
|
+
* O(1) lookup).
|
|
6
|
+
*
|
|
7
|
+
* The `Record<CountryCode, ...>` typing enforces at compile time that every
|
|
8
|
+
* country code has a configuration entry. Map centers are the capital cities;
|
|
9
|
+
* bounds are approximate country bounding boxes and can be refined later.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SUPPORTED_COUNTRIES_BY_CODE: Readonly<Record<CountryCode, SupportedCountryConfig>>;
|
|
12
|
+
/** Supported countries as an array (convenient for iteration / pickers). */
|
|
13
|
+
export declare const SUPPORTED_COUNTRIES: readonly SupportedCountryConfig[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
2
|
+
import { SupportedCurrencyConfig } from '../interfaces/supported-currency-config';
|
|
3
|
+
/**
|
|
4
|
+
* Supported currencies keyed by ISO 4217 code (source of truth, O(1) lookup).
|
|
5
|
+
*
|
|
6
|
+
* The `Record<CurrencyCode, ...>` typing enforces at compile time that every
|
|
7
|
+
* currency code has a configuration entry.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SUPPORTED_CURRENCIES_BY_CODE: Readonly<Record<CurrencyCode, SupportedCurrencyConfig>>;
|
|
10
|
+
/** Supported currencies as an array (convenient for iteration / pickers). */
|
|
11
|
+
export declare const SUPPORTED_CURRENCIES: readonly SupportedCurrencyConfig[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
3
|
+
/**
|
|
4
|
+
* Reusable, optional country/currency scope for requests and queries.
|
|
5
|
+
*
|
|
6
|
+
* Compose or extend this into country-aware DTOs (newsfeed posts, service
|
|
7
|
+
* packages, billing queries, ...). Both fields are optional so existing
|
|
8
|
+
* single-country (Kenya) requests remain valid without any change.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CountryScopeDto {
|
|
11
|
+
countryCode?: CountryCode;
|
|
12
|
+
currencyCode?: CurrencyCode;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E.164 country calling codes, keyed by ISO 3166-1 alpha-2 country code.
|
|
3
|
+
*
|
|
4
|
+
* Kept as a string enum so the value (e.g. '+254') can be used directly when
|
|
5
|
+
* composing phone numbers, and the key (e.g. KE) aligns with {@link CountryCode}.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum CallingCode {
|
|
8
|
+
/** Kenya */
|
|
9
|
+
KE = "+254",
|
|
10
|
+
/** Uganda */
|
|
11
|
+
UG = "+256",
|
|
12
|
+
/** Tanzania */
|
|
13
|
+
TZ = "+255"
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported country codes.
|
|
3
|
+
*
|
|
4
|
+
* ISO 3166-1 alpha-2 country codes. These are the platform-level identifiers
|
|
5
|
+
* for every country the Clarion / Upesy platform operates in.
|
|
6
|
+
*
|
|
7
|
+
* Kenya (KE) is the default/backward-compatible market.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum CountryCode {
|
|
10
|
+
/** Kenya */
|
|
11
|
+
KE = "KE",
|
|
12
|
+
/** Uganda */
|
|
13
|
+
UG = "UG",
|
|
14
|
+
/** Tanzania */
|
|
15
|
+
TZ = "TZ"
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported currency codes.
|
|
3
|
+
*
|
|
4
|
+
* ISO 4217 currency codes for the markets the platform operates in.
|
|
5
|
+
*
|
|
6
|
+
* KES (Kenyan Shilling) is the default/backward-compatible currency.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum CurrencyCode {
|
|
9
|
+
/** Kenyan Shilling */
|
|
10
|
+
KES = "KES",
|
|
11
|
+
/** Ugandan Shilling */
|
|
12
|
+
UGX = "UGX",
|
|
13
|
+
/** Tanzanian Shilling */
|
|
14
|
+
TZS = "TZS"
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './enums/country-code.enum';
|
|
2
|
+
export * from './enums/currency-code.enum';
|
|
3
|
+
export * from './enums/calling-code.enum';
|
|
4
|
+
export * from './interfaces/geo-coordinates';
|
|
5
|
+
export * from './interfaces/map-bounds';
|
|
6
|
+
export * from './interfaces/supported-currency-config';
|
|
7
|
+
export * from './interfaces/supported-country-config';
|
|
8
|
+
export * from './constants/supported-currencies.const';
|
|
9
|
+
export * from './constants/supported-countries.const';
|
|
10
|
+
export * from './constants/country-defaults.const';
|
|
11
|
+
export * from './dtos/country-scope.dto';
|
|
12
|
+
export * from './utils/country.util';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple latitude/longitude pair (WGS84 decimal degrees).
|
|
3
|
+
*
|
|
4
|
+
* Used for country-level map defaults (e.g. the default map center). Kept
|
|
5
|
+
* dependency-free so it is reusable across backend, admin and mobile.
|
|
6
|
+
*/
|
|
7
|
+
export interface GeoCoordinates {
|
|
8
|
+
/** Latitude in decimal degrees, range -90..90. */
|
|
9
|
+
lat: number;
|
|
10
|
+
/** Longitude in decimal degrees, range -180..180. */
|
|
11
|
+
lng: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rectangular geographic bounding box.
|
|
3
|
+
*
|
|
4
|
+
* Field names match the Google Maps `LatLngBoundsLiteral` shape so the value
|
|
5
|
+
* can be passed straight to the Maps JS SDK / Flutter map bounds restriction.
|
|
6
|
+
*/
|
|
7
|
+
export interface MapBounds {
|
|
8
|
+
/** Northernmost latitude (max lat). */
|
|
9
|
+
north: number;
|
|
10
|
+
/** Southernmost latitude (min lat). */
|
|
11
|
+
south: number;
|
|
12
|
+
/** Easternmost longitude (max lng). */
|
|
13
|
+
east: number;
|
|
14
|
+
/** Westernmost longitude (min lng). */
|
|
15
|
+
west: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
3
|
+
import { GeoCoordinates } from './geo-coordinates';
|
|
4
|
+
import { MapBounds } from './map-bounds';
|
|
5
|
+
/**
|
|
6
|
+
* Full platform configuration for a supported country/market.
|
|
7
|
+
*
|
|
8
|
+
* This is the single source of truth that country-aware features (billing,
|
|
9
|
+
* newsfeed, notifications, maps, admin, mobile) should read from instead of
|
|
10
|
+
* hard-coding Kenya-specific values.
|
|
11
|
+
*/
|
|
12
|
+
export interface SupportedCountryConfig {
|
|
13
|
+
/** ISO 3166-1 alpha-2 country code, e.g. 'KE'. */
|
|
14
|
+
code: CountryCode;
|
|
15
|
+
/** Human-readable country name, e.g. 'Kenya'. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** E.164 calling code, e.g. '+254'. */
|
|
18
|
+
callingCode: string;
|
|
19
|
+
/** ISO 4217 currency code used in this country. */
|
|
20
|
+
currencyCode: CurrencyCode;
|
|
21
|
+
/** Currency display symbol, e.g. 'KSh'. */
|
|
22
|
+
currencySymbol: string;
|
|
23
|
+
/** Number of minor-unit decimal digits for the currency. */
|
|
24
|
+
currencyDecimalPlaces: number;
|
|
25
|
+
/** IANA timezone identifier, e.g. 'Africa/Nairobi'. */
|
|
26
|
+
timezone: string;
|
|
27
|
+
/** BCP-47 default locale, e.g. 'en-KE'. */
|
|
28
|
+
defaultLocale: string;
|
|
29
|
+
/** Google Maps region bias (ccTLD), e.g. 'KE'. */
|
|
30
|
+
googleMapsRegion: string;
|
|
31
|
+
/** Default map center (typically the capital city). */
|
|
32
|
+
defaultMapCenter: GeoCoordinates;
|
|
33
|
+
/** Default map zoom level for a country-wide view. */
|
|
34
|
+
defaultMapZoom: number;
|
|
35
|
+
/** Approximate geographic bounding box for the country. */
|
|
36
|
+
mapBounds: MapBounds;
|
|
37
|
+
/** Whether the country is currently enabled for use. */
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration describing a currency the platform supports.
|
|
4
|
+
*
|
|
5
|
+
* `decimalPlaces` is the number of minor-unit digits (e.g. KES has 2, UGX/TZS
|
|
6
|
+
* have 0) and should drive money formatting and minor-unit conversions.
|
|
7
|
+
*/
|
|
8
|
+
export interface SupportedCurrencyConfig {
|
|
9
|
+
/** ISO 4217 currency code. */
|
|
10
|
+
code: CurrencyCode;
|
|
11
|
+
/** Human-readable currency name, e.g. 'Kenyan Shilling'. */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Display symbol, e.g. 'KSh'. */
|
|
14
|
+
symbol: string;
|
|
15
|
+
/** Number of minor-unit decimal digits, e.g. 2 for KES, 0 for UGX/TZS. */
|
|
16
|
+
decimalPlaces: number;
|
|
17
|
+
/** Whether the currency is currently enabled for use. */
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CountryCode } from '../enums/country-code.enum';
|
|
2
|
+
import { CurrencyCode } from '../enums/currency-code.enum';
|
|
3
|
+
import { SupportedCountryConfig } from '../interfaces/supported-country-config';
|
|
4
|
+
import { SupportedCurrencyConfig } from '../interfaces/supported-currency-config';
|
|
5
|
+
/**
|
|
6
|
+
* Country / currency helper utilities.
|
|
7
|
+
*
|
|
8
|
+
* These are intentionally simple, synchronous and dependency-free so they can
|
|
9
|
+
* be reused across every backend microservice without pulling in extra deps.
|
|
10
|
+
*/
|
|
11
|
+
/** Type guard: is `value` a supported ISO 3166-1 alpha-2 country code? */
|
|
12
|
+
export declare function isSupportedCountryCode(value: unknown): value is CountryCode;
|
|
13
|
+
/** Type guard: is `value` a supported ISO 4217 currency code? */
|
|
14
|
+
export declare function isSupportedCurrencyCode(value: unknown): value is CurrencyCode;
|
|
15
|
+
/** Get the full config for a supported country, or `undefined` if unsupported. */
|
|
16
|
+
export declare function getSupportedCountryConfig(countryCode: string | null | undefined): SupportedCountryConfig | undefined;
|
|
17
|
+
/** Get the full config for a supported currency, or `undefined` if unsupported. */
|
|
18
|
+
export declare function getSupportedCurrencyConfig(currencyCode: string | null | undefined): SupportedCurrencyConfig | undefined;
|
|
19
|
+
/** Resolve the currency used by a supported country, or `undefined`. */
|
|
20
|
+
export declare function getCurrencyForCountry(countryCode: string | null | undefined): CurrencyCode | undefined;
|
|
21
|
+
/** Resolve the E.164 calling code (e.g. '+254') for a supported country, or `undefined`. */
|
|
22
|
+
export declare function getCallingCodeForCountry(countryCode: string | null | undefined): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Reverse lookup: find the supported country whose E.164 calling code matches
|
|
25
|
+
* `callingCode` (e.g. '+254' -> Kenya), or `undefined` if none match.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getCountryByCallingCode(callingCode: string | null | undefined): SupportedCountryConfig | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grm-shared-library",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.183",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -20,13 +20,14 @@
|
|
|
20
20
|
"dist/**/*"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"clean": "rimraf dist",
|
|
23
|
+
"clean": "rimraf dist dist-test",
|
|
24
24
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
25
25
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
26
26
|
"build:types": "tsc -p tsconfig.types.json",
|
|
27
27
|
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm",
|
|
28
28
|
"prepublishOnly": "npm run build",
|
|
29
|
-
"
|
|
29
|
+
"pretest": "rimraf dist-test",
|
|
30
|
+
"test": "tsc -p tsconfig.spec.json && node dist-test/modules/country/__tests__/country.spec.js"
|
|
30
31
|
},
|
|
31
32
|
"keywords": [],
|
|
32
33
|
"author": "",
|