grm-shared-library 1.1.182 → 1.1.184
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 +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/auth/dtos/login-mobile-user.dto.js +15 -3
- package/dist/cjs/modules/auth/dtos/login-mobile-user.dto.js.map +1 -1
- package/dist/cjs/modules/auth/dtos/register-mobile-user.dto.js +15 -3
- package/dist/cjs/modules/auth/dtos/register-mobile-user.dto.js.map +1 -1
- package/dist/cjs/modules/auth/dtos/register.dto.js +15 -3
- package/dist/cjs/modules/auth/dtos/register.dto.js.map +1 -1
- package/dist/cjs/modules/auth/dtos/resend-otp.dto.js +15 -3
- package/dist/cjs/modules/auth/dtos/resend-otp.dto.js.map +1 -1
- package/dist/cjs/modules/auth/dtos/send-otp.dto.js +15 -3
- package/dist/cjs/modules/auth/dtos/send-otp.dto.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/cjs/modules/phone/index.js +23 -0
- package/dist/cjs/modules/phone/index.js.map +1 -0
- package/dist/cjs/modules/phone/interfaces/normalized-phone.js +3 -0
- package/dist/cjs/modules/phone/interfaces/normalized-phone.js.map +1 -0
- package/dist/cjs/modules/phone/phone.util.js +92 -0
- package/dist/cjs/modules/phone/phone.util.js.map +1 -0
- package/dist/cjs/modules/phone/validators/is-supported-phone-number.decorator.js +39 -0
- package/dist/cjs/modules/phone/validators/is-supported-phone-number.decorator.js.map +1 -0
- package/dist/cjs/modules/user/dtos/create-user.dto.js +15 -3
- package/dist/cjs/modules/user/dtos/create-user.dto.js.map +1 -1
- package/dist/cjs/modules/user/dtos/guardian.dto.js +15 -3
- package/dist/cjs/modules/user/dtos/guardian.dto.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/auth/dtos/login-mobile-user.dto.js +17 -5
- package/dist/esm/modules/auth/dtos/login-mobile-user.dto.js.map +1 -1
- package/dist/esm/modules/auth/dtos/register-mobile-user.dto.js +17 -5
- package/dist/esm/modules/auth/dtos/register-mobile-user.dto.js.map +1 -1
- package/dist/esm/modules/auth/dtos/register.dto.js +16 -4
- package/dist/esm/modules/auth/dtos/register.dto.js.map +1 -1
- package/dist/esm/modules/auth/dtos/resend-otp.dto.js +16 -4
- package/dist/esm/modules/auth/dtos/resend-otp.dto.js.map +1 -1
- package/dist/esm/modules/auth/dtos/send-otp.dto.js +16 -4
- package/dist/esm/modules/auth/dtos/send-otp.dto.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/esm/modules/phone/index.js +7 -0
- package/dist/esm/modules/phone/index.js.map +1 -0
- package/dist/esm/modules/phone/interfaces/normalized-phone.js +2 -0
- package/dist/esm/modules/phone/interfaces/normalized-phone.js.map +1 -0
- package/dist/esm/modules/phone/phone.util.js +86 -0
- package/dist/esm/modules/phone/phone.util.js.map +1 -0
- package/dist/esm/modules/phone/validators/is-supported-phone-number.decorator.js +36 -0
- package/dist/esm/modules/phone/validators/is-supported-phone-number.decorator.js.map +1 -0
- package/dist/esm/modules/user/dtos/create-user.dto.js +16 -4
- package/dist/esm/modules/user/dtos/create-user.dto.js.map +1 -1
- package/dist/esm/modules/user/dtos/guardian.dto.js +16 -4
- package/dist/esm/modules/user/dtos/guardian.dto.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/modules/auth/dtos/login-mobile-user.dto.d.ts +2 -0
- package/dist/types/modules/auth/dtos/register-mobile-user.dto.d.ts +2 -0
- package/dist/types/modules/auth/dtos/register.dto.d.ts +2 -0
- package/dist/types/modules/auth/dtos/resend-otp.dto.d.ts +2 -0
- package/dist/types/modules/auth/dtos/send-otp.dto.d.ts +2 -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/dist/types/modules/phone/index.d.ts +3 -0
- package/dist/types/modules/phone/interfaces/normalized-phone.d.ts +22 -0
- package/dist/types/modules/phone/phone.util.d.ts +20 -0
- package/dist/types/modules/phone/validators/is-supported-phone-number.decorator.d.ts +12 -0
- package/dist/types/modules/user/dtos/create-user.dto.d.ts +2 -0
- package/dist/types/modules/user/dtos/guardian.dto.d.ts +2 -0
- package/package.json +5 -3
|
@@ -7,9 +7,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
import { IsBoolean, IsEmail, IsEnum, IsNotEmpty, IsNumber, IsOptional,
|
|
10
|
+
import { IsBoolean, IsEmail, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString } from "class-validator";
|
|
11
11
|
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
12
12
|
import { GuardianRelationship } from "../enums/guardian-relationship.enum";
|
|
13
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
14
|
+
import { IsSupportedPhoneNumber } from "../../phone/validators/is-supported-phone-number.decorator";
|
|
13
15
|
export class GuardianDto {
|
|
14
16
|
}
|
|
15
17
|
__decorate([
|
|
@@ -32,14 +34,24 @@ __decorate([
|
|
|
32
34
|
], GuardianDto.prototype, "name", void 0);
|
|
33
35
|
__decorate([
|
|
34
36
|
ApiProperty({
|
|
35
|
-
description: 'Guardian phone number
|
|
36
|
-
example: '+
|
|
37
|
+
description: 'Guardian phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
|
|
38
|
+
example: '+254712345678',
|
|
37
39
|
format: 'phone'
|
|
38
40
|
}),
|
|
39
|
-
|
|
41
|
+
IsSupportedPhoneNumber(),
|
|
40
42
|
IsNotEmpty(),
|
|
41
43
|
__metadata("design:type", String)
|
|
42
44
|
], GuardianDto.prototype, "phoneNumber", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
ApiPropertyOptional({
|
|
47
|
+
description: 'ISO 3166-1 alpha-2 country code for the guardian phone number (KE, UG, TZ). Required when phoneNumber is in national format; defaults to KE.',
|
|
48
|
+
enum: CountryCode,
|
|
49
|
+
example: CountryCode.KE
|
|
50
|
+
}),
|
|
51
|
+
IsEnum(CountryCode),
|
|
52
|
+
IsOptional(),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], GuardianDto.prototype, "countryCode", void 0);
|
|
43
55
|
__decorate([
|
|
44
56
|
ApiPropertyOptional({
|
|
45
57
|
description: 'Whether this is the primary guardian',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guardian.dto.js","sourceRoot":"","sources":["../../../../../src/modules/user/dtos/guardian.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"guardian.dto.js","sourceRoot":"","sources":["../../../../../src/modules/user/dtos/guardian.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAEpG,MAAM,OAAO,WAAW;CA6DvB;AAtDG;IANC,mBAAmB,CAAC;QACjB,WAAW,EAAE,wCAAwC;QACrD,OAAO,EAAE,GAAG;KACf,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;2CACG;AAQhB;IANC,WAAW,CAAC;QACT,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,YAAY;KACxB,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;yCACC;AASd;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,6GAA6G;QAC1H,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,sBAAsB,EAAE;IACxB,UAAU,EAAE;;gDACQ;AASrB;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,8IAA8I;QAC3J,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,WAAW,CAAC,EAAE;KAC1B,CAAC;IACD,MAAM,CAAC,WAAW,CAAC;IACnB,UAAU,EAAE;;gDACa;AAS1B;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,sCAAsC;QACnD,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,KAAK;KACjB,CAAC;IACD,SAAS,EAAE;IACX,UAAU,EAAE;;8CACO;AASpB;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,oBAAoB,CAAC,MAAM;KACvC,CAAC;IACD,MAAM,CAAC,oBAAoB,CAAC;IAC5B,UAAU,EAAE;;iDACuB;AASpC;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,wBAAwB;QACrC,OAAO,EAAE,wBAAwB;QACjC,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,OAAO,EAAE;IACT,UAAU,EAAE;;0CACE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ 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';
|
|
20
|
+
export * from './modules/phone/index';
|
|
19
21
|
export * from './interfaces/server-message';
|
|
20
22
|
export * from './interfaces/i-request-with-user';
|
|
21
23
|
export * from './interfaces/validated-user';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { IncidentAppId } from "../../incident";
|
|
2
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
2
3
|
export declare class RegisterMobileUserDto {
|
|
3
4
|
appId: IncidentAppId;
|
|
4
5
|
name: string;
|
|
5
6
|
email: string;
|
|
6
7
|
phoneNumber: string;
|
|
8
|
+
countryCode?: CountryCode;
|
|
7
9
|
controlCentreId: number;
|
|
8
10
|
organizationId: number;
|
|
9
11
|
}
|
|
@@ -2,12 +2,14 @@ import { MapAddressDto } from "../../common";
|
|
|
2
2
|
import { Roles } from "../../role";
|
|
3
3
|
import { OrganizationType } from "../../organization/enums/org-type.enum";
|
|
4
4
|
import { IncidentAppId, IncidentClass } from "../../incident";
|
|
5
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
5
6
|
export declare class RegisterDto {
|
|
6
7
|
appId: IncidentAppId;
|
|
7
8
|
incidentClass: IncidentClass;
|
|
8
9
|
name: string;
|
|
9
10
|
email: string;
|
|
10
11
|
phoneNumber: string;
|
|
12
|
+
countryCode?: CountryCode;
|
|
11
13
|
roles?: Roles[];
|
|
12
14
|
designation: string;
|
|
13
15
|
password: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { OtpAction } from "../enums/otp-action";
|
|
2
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
2
3
|
export declare class ResendOTPDto {
|
|
3
4
|
action: OtpAction;
|
|
4
5
|
verificationToken?: string;
|
|
5
6
|
email?: string;
|
|
6
7
|
phoneNumber?: string;
|
|
8
|
+
countryCode?: CountryCode;
|
|
7
9
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CountryCode } from '../../country/enums/country-code.enum';
|
|
2
|
+
/** A phone number successfully normalized to canonical E.164 for a supported country. */
|
|
3
|
+
export interface NormalizedPhoneNumber {
|
|
4
|
+
/** Canonical E.164 representation, e.g. '+254712345678'. This is the value to store/query. */
|
|
5
|
+
e164: string;
|
|
6
|
+
/** ISO 3166-1 alpha-2 country the number belongs to (KE/UG/TZ). */
|
|
7
|
+
countryCode: CountryCode;
|
|
8
|
+
/** National (significant) number without the calling code, e.g. '712345678'. */
|
|
9
|
+
nationalNumber: string;
|
|
10
|
+
}
|
|
11
|
+
/** Machine-readable reason a phone number could not be normalized. */
|
|
12
|
+
export type PhoneNormalizationErrorCode = 'INVALID_PHONE_NUMBER' | 'UNSUPPORTED_COUNTRY';
|
|
13
|
+
/**
|
|
14
|
+
* Result of attempting to normalize a phone number to a supported-country E.164 value.
|
|
15
|
+
* Discriminated by `ok` — on success `value` is present, on failure `error`/`message` are.
|
|
16
|
+
*/
|
|
17
|
+
export interface PhoneNormalizationResult {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
value?: NormalizedPhoneNumber;
|
|
20
|
+
error?: PhoneNormalizationErrorCode;
|
|
21
|
+
message?: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CountryCode } from '../country/enums/country-code.enum';
|
|
2
|
+
import { PhoneNormalizationResult } from './interfaces/normalized-phone';
|
|
3
|
+
/**
|
|
4
|
+
* Normalize a phone number to canonical E.164 for a supported country.
|
|
5
|
+
*
|
|
6
|
+
* Resolution order for a raw (non-`+`) input:
|
|
7
|
+
* 1. already international (`+254…`) — parsed as-is;
|
|
8
|
+
* 2. calling code without `+` (`254…`/`256…`/`255…`) — treated as international;
|
|
9
|
+
* 3. national/local (`0712…`, `712…`) — parsed using `defaultCountry`
|
|
10
|
+
* (the caller-supplied country, else Kenya for backward compatibility).
|
|
11
|
+
*
|
|
12
|
+
* @returns a discriminated result: `{ ok: true, value }` or `{ ok: false, error, message }`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeSupportedPhoneNumber(input: string | null | undefined, defaultCountry?: CountryCode | string | null): PhoneNormalizationResult;
|
|
15
|
+
/** Convenience: `true` if the input can be normalized to a supported-country E.164 number. */
|
|
16
|
+
export declare function isSupportedPhoneNumber(input: string | null | undefined, defaultCountry?: CountryCode | string | null): boolean;
|
|
17
|
+
/** Convenience: the canonical E.164 string, or `undefined` if the input cannot be normalized. */
|
|
18
|
+
export declare function toSupportedE164(input: string | null | undefined, defaultCountry?: CountryCode | string | null): string | undefined;
|
|
19
|
+
/** Resolve the supported country a (normalizable) phone number belongs to, or `undefined`. */
|
|
20
|
+
export declare function getCountryForPhoneNumber(input: string | null | undefined, defaultCountry?: CountryCode | string | null): CountryCode | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ValidationOptions } from 'class-validator';
|
|
2
|
+
/**
|
|
3
|
+
* Validates that a property is a phone number for a supported country (KE/UG/TZ).
|
|
4
|
+
*
|
|
5
|
+
* Accepts either a full E.164 number (e.g. '+254712345678') OR a national/local
|
|
6
|
+
* number (e.g. '0712345678') when a sibling `countryCode` field is present. When
|
|
7
|
+
* no `countryCode` sibling is provided, Kenya is used as the default region for
|
|
8
|
+
* backward compatibility.
|
|
9
|
+
*
|
|
10
|
+
* Pairs with an optional `countryCode?: CountryCode` field on the same DTO.
|
|
11
|
+
*/
|
|
12
|
+
export declare function IsSupportedPhoneNumber(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|
|
@@ -2,11 +2,13 @@ import { UserStatus } from '../enums/user-status.enum';
|
|
|
2
2
|
import { Roles } from '../../role';
|
|
3
3
|
import { GuardianDto } from './guardian.dto';
|
|
4
4
|
import { IncidentAppId } from '../../incident';
|
|
5
|
+
import { CountryCode } from '../../country/enums/country-code.enum';
|
|
5
6
|
export declare class CreateUserDto {
|
|
6
7
|
appId: IncidentAppId;
|
|
7
8
|
name: string;
|
|
8
9
|
email: string;
|
|
9
10
|
phoneNumber?: string;
|
|
11
|
+
countryCode?: CountryCode;
|
|
10
12
|
roles: Roles[];
|
|
11
13
|
password?: string;
|
|
12
14
|
avatar?: string;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { GuardianRelationship } from "../enums/guardian-relationship.enum";
|
|
2
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
2
3
|
export declare class GuardianDto {
|
|
3
4
|
userId?: number;
|
|
4
5
|
name: string;
|
|
5
6
|
phoneNumber: string;
|
|
7
|
+
countryCode?: CountryCode;
|
|
6
8
|
isPrimary?: boolean;
|
|
7
9
|
relationship?: GuardianRelationship;
|
|
8
10
|
email?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grm-shared-library",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.184",
|
|
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 --test \"dist-test/**/*.spec.js\""
|
|
30
31
|
},
|
|
31
32
|
"keywords": [],
|
|
32
33
|
"author": "",
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"express": "^5.1.0",
|
|
55
56
|
"geojson": "^0.5.0",
|
|
56
57
|
"grm-shared-library": "^1.1.101",
|
|
58
|
+
"libphonenumber-js": "^1.13.8",
|
|
57
59
|
"rxjs": "^7.8.2",
|
|
58
60
|
"swagger-ui-express": "^5.0.1"
|
|
59
61
|
},
|