grm-shared-library
v1.1.187
Published
Common code for GRM — shared types, enums, interfaces, DTOs and constants for the Clarion / Upesy backend NestJS microservices.
Readme
grm-shared-library
Common code for GRM — shared types, enums, interfaces, DTOs and constants for the Clarion / Upesy backend NestJS microservices.
Country & Currency (multi-country foundation)
Platform-level primitives for country-aware emergency response, newsfeed, notifications, billing, maps and admin. This is the shared source of truth so services stop hard-coding Kenya-specific values.
Supported countries (ISO 3166-1 alpha-2):
| Code | Country | Calling code | Currency | Symbol | Decimals | Timezone | Locale |
|------|----------|--------------|----------|--------|----------|------------------------|---------|
| KE | Kenya | +254 | KES | KSh | 2 | Africa/Nairobi | en-KE |
| UG | Uganda | +256 | UGX | USh | 0 | Africa/Kampala | en-UG |
| TZ | Tanzania | +255 | TZS | TSh | 0 | Africa/Dar_es_Salaam | en-TZ |
Supported currencies (ISO 4217): KES, UGX, TZS.
Importing
Everything is re-exported from the package root:
import {
CountryCode,
CurrencyCode,
CallingCode,
SupportedCountryConfig,
SupportedCurrencyConfig,
SUPPORTED_COUNTRIES, // readonly SupportedCountryConfig[]
SUPPORTED_COUNTRIES_BY_CODE, // Record<CountryCode, SupportedCountryConfig>
SUPPORTED_CURRENCIES,
SUPPORTED_CURRENCIES_BY_CODE,
DEFAULT_COUNTRY_CODE, // CountryCode.KE
DEFAULT_CURRENCY_CODE, // CurrencyCode.KES
CountryScopeDto, // optional { countryCode?, currencyCode? } request scope
getSupportedCountryConfig,
getSupportedCurrencyConfig,
getCurrencyForCountry,
getCallingCodeForCountry,
getCountryByCallingCode,
isSupportedCountryCode,
isSupportedCurrencyCode,
} from 'grm-shared-library';
getCurrencyForCountry(CountryCode.UG); // CurrencyCode.UGX
getCallingCodeForCountry(CountryCode.TZ); // '+255'
isSupportedCountryCode('US'); // falseBackward compatibility
Kenya (KE / KES) is the default market. Wherever a country or currency is
not explicit, fall back to DEFAULT_COUNTRY_CODE / DEFAULT_CURRENCY_CODE /
DEFAULT_TIMEZONE / DEFAULT_LOCALE. Existing Kenyan users, packages, posts,
incidents, OTPs, notifications and billing flows are unaffected.
Scope
This package provides the country/currency primitives only. Country detection (GPS / IP / phone-number inference) and country-aware business logic (phone login, newsfeed filtering, multi-currency billing, SMS routing, map filtering) are delivered in later phases and should build on top of these types.
Tests
npm test # compiles src/modules/country and runs the country/currency suite