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
|
@@ -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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
// Interfaces
|
|
18
|
+
__exportStar(require("./interfaces/normalized-phone"), exports);
|
|
19
|
+
// Utilities
|
|
20
|
+
__exportStar(require("./phone.util"), exports);
|
|
21
|
+
// Validators
|
|
22
|
+
__exportStar(require("./validators/is-supported-phone-number.decorator"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/phone/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,aAAa;AACb,gEAA8C;AAE9C,YAAY;AACZ,+CAA6B;AAE7B,aAAa;AACb,mFAAiE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalized-phone.js","sourceRoot":"","sources":["../../../../../src/modules/phone/interfaces/normalized-phone.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeSupportedPhoneNumber = normalizeSupportedPhoneNumber;
|
|
4
|
+
exports.isSupportedPhoneNumber = isSupportedPhoneNumber;
|
|
5
|
+
exports.toSupportedE164 = toSupportedE164;
|
|
6
|
+
exports.getCountryForPhoneNumber = getCountryForPhoneNumber;
|
|
7
|
+
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
8
|
+
const country_defaults_const_1 = require("../country/constants/country-defaults.const");
|
|
9
|
+
const country_util_1 = require("../country/utils/country.util");
|
|
10
|
+
/**
|
|
11
|
+
* Phone-number normalization for the platform's supported countries (KE/UG/TZ).
|
|
12
|
+
*
|
|
13
|
+
* Built on `libphonenumber-js` (robust parsing/validation — no bespoke regex)
|
|
14
|
+
* and the Phase 1 country primitives. The canonical stored/queried form is
|
|
15
|
+
* always E.164 (e.g. '+254712345678').
|
|
16
|
+
*/
|
|
17
|
+
/** Digit strings of the supported E.164 calling codes, for the "code-without-plus" case. */
|
|
18
|
+
const SUPPORTED_CALLING_CODE_DIGITS = ['254', '256', '255'];
|
|
19
|
+
function toResult(phone) {
|
|
20
|
+
if (!phone || !phone.isValid()) {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: 'INVALID_PHONE_NUMBER',
|
|
24
|
+
message: 'The phone number is not a valid number.',
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const country = phone.country;
|
|
28
|
+
if (!country || !(0, country_util_1.isSupportedCountryCode)(country)) {
|
|
29
|
+
return {
|
|
30
|
+
ok: false,
|
|
31
|
+
error: 'UNSUPPORTED_COUNTRY',
|
|
32
|
+
message: `Phone numbers from ${country !== null && country !== void 0 ? country : 'this country'} are not supported. Supported countries are Kenya (KE), Uganda (UG) and Tanzania (TZ).`,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
ok: true,
|
|
37
|
+
value: {
|
|
38
|
+
e164: phone.number,
|
|
39
|
+
countryCode: country,
|
|
40
|
+
nationalNumber: phone.nationalNumber,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Normalize a phone number to canonical E.164 for a supported country.
|
|
46
|
+
*
|
|
47
|
+
* Resolution order for a raw (non-`+`) input:
|
|
48
|
+
* 1. already international (`+254…`) — parsed as-is;
|
|
49
|
+
* 2. calling code without `+` (`254…`/`256…`/`255…`) — treated as international;
|
|
50
|
+
* 3. national/local (`0712…`, `712…`) — parsed using `defaultCountry`
|
|
51
|
+
* (the caller-supplied country, else Kenya for backward compatibility).
|
|
52
|
+
*
|
|
53
|
+
* @returns a discriminated result: `{ ok: true, value }` or `{ ok: false, error, message }`.
|
|
54
|
+
*/
|
|
55
|
+
function normalizeSupportedPhoneNumber(input, defaultCountry) {
|
|
56
|
+
if (input == null || String(input).trim() === '') {
|
|
57
|
+
return { ok: false, error: 'INVALID_PHONE_NUMBER', message: 'A phone number is required.' };
|
|
58
|
+
}
|
|
59
|
+
const raw = String(input).trim();
|
|
60
|
+
const region = (0, country_util_1.isSupportedCountryCode)(defaultCountry)
|
|
61
|
+
? defaultCountry
|
|
62
|
+
: country_defaults_const_1.DEFAULT_COUNTRY_CODE;
|
|
63
|
+
// 1. Already international.
|
|
64
|
+
if (raw.startsWith('+')) {
|
|
65
|
+
return toResult((0, libphonenumber_js_1.parsePhoneNumberFromString)(raw));
|
|
66
|
+
}
|
|
67
|
+
const digits = raw.replace(/[^\d]/g, '');
|
|
68
|
+
// 2. Calling code supplied without the leading '+', e.g. '254712345678'.
|
|
69
|
+
if (SUPPORTED_CALLING_CODE_DIGITS.some((code) => digits.startsWith(code))) {
|
|
70
|
+
const international = (0, libphonenumber_js_1.parsePhoneNumberFromString)('+' + digits);
|
|
71
|
+
if (international && international.isValid()) {
|
|
72
|
+
return toResult(international);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// 3. National/local format — resolve using the selected/default country.
|
|
76
|
+
return toResult((0, libphonenumber_js_1.parsePhoneNumberFromString)(raw, region));
|
|
77
|
+
}
|
|
78
|
+
/** Convenience: `true` if the input can be normalized to a supported-country E.164 number. */
|
|
79
|
+
function isSupportedPhoneNumber(input, defaultCountry) {
|
|
80
|
+
return normalizeSupportedPhoneNumber(input, defaultCountry).ok;
|
|
81
|
+
}
|
|
82
|
+
/** Convenience: the canonical E.164 string, or `undefined` if the input cannot be normalized. */
|
|
83
|
+
function toSupportedE164(input, defaultCountry) {
|
|
84
|
+
var _a;
|
|
85
|
+
return (_a = normalizeSupportedPhoneNumber(input, defaultCountry).value) === null || _a === void 0 ? void 0 : _a.e164;
|
|
86
|
+
}
|
|
87
|
+
/** Resolve the supported country a (normalizable) phone number belongs to, or `undefined`. */
|
|
88
|
+
function getCountryForPhoneNumber(input, defaultCountry) {
|
|
89
|
+
var _a;
|
|
90
|
+
return (_a = normalizeSupportedPhoneNumber(input, defaultCountry).value) === null || _a === void 0 ? void 0 : _a.countryCode;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=phone.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phone.util.js","sourceRoot":"","sources":["../../../../src/modules/phone/phone.util.ts"],"names":[],"mappings":";;AAsDA,sEA8BC;AAGD,wDAKC;AAGD,0CAKC;AAGD,4DAKC;AA5GD,yDAA4E;AAC5E,wFAAmF;AAEnF,gEAAuE;AAGvE;;;;;;GAMG;AAEH,4FAA4F;AAC5F,MAAM,6BAA6B,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE5D,SAAS,QAAQ,CAAC,KAA8B;IAC5C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7B,OAAO;YACH,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,sBAAsB;YAC7B,OAAO,EAAE,yCAAyC;SACrD,CAAC;IACN,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,IAAI,CAAC,OAAO,IAAI,CAAC,IAAA,qCAAsB,EAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,OAAO;YACH,EAAE,EAAE,KAAK;YACT,KAAK,EAAE,qBAAqB;YAC5B,OAAO,EAAE,sBAAsB,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc,wFAAwF;SACnJ,CAAC;IACN,CAAC;IACD,OAAO;QACH,EAAE,EAAE,IAAI;QACR,KAAK,EAAE;YACH,IAAI,EAAE,KAAK,CAAC,MAAM;YAClB,WAAW,EAAE,OAAsB;YACnC,cAAc,EAAE,KAAK,CAAC,cAAc;SACvC;KACJ,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,6BAA6B,CACzC,KAAgC,EAChC,cAA4C;IAE5C,IAAI,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KA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AChC,cAA4C;;IAE5C,OAAO,MAAA,6BAA6B,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,KAAK,0CAAE,IAAI,CAAC;AAC5E,CAAC;AAED,8FAA8F;AAC9F,SAAgB,wBAAwB,CACpC,KAAgC,EAChC,cAA4C;;IAE5C,OAAO,MAAA,6BAA6B,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,KAAK,0CAAE,WAAW,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsSupportedPhoneNumber = IsSupportedPhoneNumber;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
const country_util_1 = require("../../country/utils/country.util");
|
|
6
|
+
const phone_util_1 = require("../phone.util");
|
|
7
|
+
/**
|
|
8
|
+
* Validates that a property is a phone number for a supported country (KE/UG/TZ).
|
|
9
|
+
*
|
|
10
|
+
* Accepts either a full E.164 number (e.g. '+254712345678') OR a national/local
|
|
11
|
+
* number (e.g. '0712345678') when a sibling `countryCode` field is present. When
|
|
12
|
+
* no `countryCode` sibling is provided, Kenya is used as the default region for
|
|
13
|
+
* backward compatibility.
|
|
14
|
+
*
|
|
15
|
+
* Pairs with an optional `countryCode?: CountryCode` field on the same DTO.
|
|
16
|
+
*/
|
|
17
|
+
function IsSupportedPhoneNumber(validationOptions) {
|
|
18
|
+
return function (object, propertyName) {
|
|
19
|
+
(0, class_validator_1.registerDecorator)({
|
|
20
|
+
name: 'isSupportedPhoneNumber',
|
|
21
|
+
target: object.constructor,
|
|
22
|
+
propertyName,
|
|
23
|
+
options: validationOptions,
|
|
24
|
+
validator: {
|
|
25
|
+
validate(value, args) {
|
|
26
|
+
if (typeof value !== 'string') {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const country = args.object['countryCode'];
|
|
30
|
+
return (0, phone_util_1.isSupportedPhoneNumber)(value, (0, country_util_1.isSupportedCountryCode)(country) ? country : undefined);
|
|
31
|
+
},
|
|
32
|
+
defaultMessage(args) {
|
|
33
|
+
return `${args.property} must be a valid phone number for a supported country (KE, UG, TZ) — provide it in E.164 format (e.g. +254712345678), or in national format together with a countryCode.`;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=is-supported-phone-number.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-supported-phone-number.decorator.js","sourceRoot":"","sources":["../../../../../src/modules/phone/validators/is-supported-phone-number.decorator.ts"],"names":[],"mappings":";;AAcA,wDAwBC;AAtCD,qDAA4F;AAC5F,mEAA0E;AAC1E,8CAAuD;AAEvD;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CAAC,iBAAqC;IACxE,OAAO,UAAU,MAAc,EAAE,YAAoB;QACjD,IAAA,mCAAiB,EAAC;YACd,IAAI,EAAE,wBAAwB;YAC9B,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY;YACZ,OAAO,EAAE,iBAAiB;YAC1B,SAAS,EAAE;gBACP,QAAQ,CAAC,KAAc,EAAE,IAAyB;oBAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;wBAC5B,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,MAAM,OAAO,GAAI,IAAI,CAAC,MAAkC,CAAC,aAAa,CAAC,CAAC;oBACxE,OAAO,IAAA,mCAAsB,EACzB,KAAK,EACL,IAAA,qCAAsB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CACxD,CAAC;gBACN,CAAC;gBACD,cAAc,CAAC,IAAyB;oBACpC,OAAO,GAAG,IAAI,CAAC,QAAQ,0KAA0K,CAAC;gBACtM,CAAC;aACJ;SACJ,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -19,6 +19,8 @@ const role_1 = require("../../role");
|
|
|
19
19
|
const class_transformer_1 = require("class-transformer");
|
|
20
20
|
const guardian_dto_1 = require("./guardian.dto");
|
|
21
21
|
const incident_1 = require("../../incident");
|
|
22
|
+
const country_code_enum_1 = require("../../country/enums/country-code.enum");
|
|
23
|
+
const is_supported_phone_number_decorator_1 = require("../../phone/validators/is-supported-phone-number.decorator");
|
|
22
24
|
class CreateUserDto {
|
|
23
25
|
}
|
|
24
26
|
exports.CreateUserDto = CreateUserDto;
|
|
@@ -60,16 +62,26 @@ __decorate([
|
|
|
60
62
|
], CreateUserDto.prototype, "email", void 0);
|
|
61
63
|
__decorate([
|
|
62
64
|
(0, swagger_1.ApiPropertyOptional)({
|
|
63
|
-
description: 'Phone number
|
|
64
|
-
example: '+
|
|
65
|
+
description: 'Phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
|
|
66
|
+
example: '+254712345678',
|
|
65
67
|
format: 'phone',
|
|
66
68
|
maxLength: 20
|
|
67
69
|
}),
|
|
68
|
-
(0,
|
|
70
|
+
(0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
|
|
69
71
|
(0, class_validator_1.MaxLength)(20),
|
|
70
72
|
(0, class_validator_1.IsOptional)(),
|
|
71
73
|
__metadata("design:type", String)
|
|
72
74
|
], CreateUserDto.prototype, "phoneNumber", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
77
|
+
description: 'ISO 3166-1 alpha-2 country code for the phone number (KE, UG, TZ). Required when phoneNumber is in national format; defaults to KE.',
|
|
78
|
+
enum: country_code_enum_1.CountryCode,
|
|
79
|
+
example: country_code_enum_1.CountryCode.KE
|
|
80
|
+
}),
|
|
81
|
+
(0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
|
|
82
|
+
(0, class_validator_1.IsOptional)(),
|
|
83
|
+
__metadata("design:type", String)
|
|
84
|
+
], CreateUserDto.prototype, "countryCode", void 0);
|
|
73
85
|
__decorate([
|
|
74
86
|
(0, swagger_1.ApiProperty)({
|
|
75
87
|
description: 'User roles',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/user/dtos/create-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"create-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/user/dtos/create-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAeyB;AACzB,6CAAmE;AACnE,yEAAmE;AACnE,gEAAuD;AACvD,sFAAqG;AACrG,qCAAmC;AACnC,yDAAyC;AACzC,iDAA6C;AAC7C,6CAA+C;AAC/C,6EAAoE;AACpE,oHAAoG;AAEpG,MAAa,aAAa;CAiHzB;AAjHD,sCAiHC;AAzGG;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,oCAAoC;QACjD,IAAI,EAAE,wBAAa;QACnB,OAAO,EAAE,wBAAa,CAAC,GAAG;KAC7B,CAAC;IACD,IAAA,wBAAM,EAAC,wBAAa,CAAC;IACrB,IAAA,4BAAU,GAAE;;4CACS;AAatB;IAXC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE,UAAU;QACnB,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,EAAE;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC,CAAC,CAAC;IACZ,IAAA,2BAAS,EAAC,EAAE,CAAC;IACb,IAAA,8BAAY,GAAE;;2CACD;AAWd;IATC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,2BAA2B;QACxC,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,EAAE;KAChB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC,EAAE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AAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,0BAAW,CAAC;IACvB,IAAA,4BAAU,GAAE;;gDACa;AAK1B;IAHC,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,4BAAU,GAAE;;mDACW;AAIxB;IAFC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;sDACa;AAI1B;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACc;AAI3B;IAFC,IAAA,wBAAM,GAAE;IACR,IAAA,4BAAU,GAAE;8BACgB,IAAI;iEAAC;AAIlC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sDACY;AAIzB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qDACW"}
|
|
@@ -13,6 +13,8 @@ exports.GuardianDto = void 0;
|
|
|
13
13
|
const class_validator_1 = require("class-validator");
|
|
14
14
|
const swagger_1 = require("@nestjs/swagger");
|
|
15
15
|
const guardian_relationship_enum_1 = require("../enums/guardian-relationship.enum");
|
|
16
|
+
const country_code_enum_1 = require("../../country/enums/country-code.enum");
|
|
17
|
+
const is_supported_phone_number_decorator_1 = require("../../phone/validators/is-supported-phone-number.decorator");
|
|
16
18
|
class GuardianDto {
|
|
17
19
|
}
|
|
18
20
|
exports.GuardianDto = GuardianDto;
|
|
@@ -36,14 +38,24 @@ __decorate([
|
|
|
36
38
|
], GuardianDto.prototype, "name", void 0);
|
|
37
39
|
__decorate([
|
|
38
40
|
(0, swagger_1.ApiProperty)({
|
|
39
|
-
description: 'Guardian phone number
|
|
40
|
-
example: '+
|
|
41
|
+
description: 'Guardian phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
|
|
42
|
+
example: '+254712345678',
|
|
41
43
|
format: 'phone'
|
|
42
44
|
}),
|
|
43
|
-
(0,
|
|
45
|
+
(0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
|
|
44
46
|
(0, class_validator_1.IsNotEmpty)(),
|
|
45
47
|
__metadata("design:type", String)
|
|
46
48
|
], GuardianDto.prototype, "phoneNumber", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
51
|
+
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.',
|
|
52
|
+
enum: country_code_enum_1.CountryCode,
|
|
53
|
+
example: country_code_enum_1.CountryCode.KE
|
|
54
|
+
}),
|
|
55
|
+
(0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
|
|
56
|
+
(0, class_validator_1.IsOptional)(),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], GuardianDto.prototype, "countryCode", void 0);
|
|
47
59
|
__decorate([
|
|
48
60
|
(0, swagger_1.ApiPropertyOptional)({
|
|
49
61
|
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,
|
|
1
|
+
{"version":3,"file":"guardian.dto.js","sourceRoot":"","sources":["../../../../../src/modules/user/dtos/guardian.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAyG;AACzG,6CAAmE;AACnE,oFAA2E;AAC3E,6EAAoE;AACpE,oHAAoG;AAEpG,MAAa,WAAW;CA6DvB;AA7DD,kCA6DC;AAtDG;IANC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,wCAAwC;QACrD,OAAO,EAAE,GAAG;KACf,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;2CACG;AAQhB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE,YAAY;KACxB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;yCACC;AASd;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,6GAA6G;QAC1H,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,4DAAsB,GAAE;IACxB,IAAA,4BAAU,GAAE;;gDACQ;AASrB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,8IAA8I;QAC3J,IAAI,EAAE,+BAAW;QACjB,OAAO,EAAE,+BAAW,CAAC,EAAE;KAC1B,CAAC;IACD,IAAA,wBAAM,EAAC,+BAAW,CAAC;IACnB,IAAA,4BAAU,GAAE;;gDACa;AAS1B;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,sCAAsC;QACnD,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,KAAK;KACjB,CAAC;IACD,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;8CACO;AASpB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,iDAAoB;QAC1B,OAAO,EAAE,iDAAoB,CAAC,MAAM;KACvC,CAAC;IACD,IAAA,wBAAM,EAAC,iDAAoB,CAAC;IAC5B,IAAA,4BAAU,GAAE;;iDACuB;AASpC;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,wBAAwB;QACrC,OAAO,EAAE,wBAAwB;QACjC,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;0CACE"}
|
package/dist/esm/index.js
CHANGED
|
@@ -17,6 +17,8 @@ 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';
|
|
21
|
+
export * from './modules/phone/index';
|
|
20
22
|
// Interfaces
|
|
21
23
|
export * from './interfaces/server-message';
|
|
22
24
|
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;AACxC,cAAc,uBAAuB,CAAC;AAEtC,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"}
|
|
@@ -7,20 +7,32 @@ 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 { IsNotEmpty,
|
|
11
|
-
import { ApiProperty } from "@nestjs/swagger";
|
|
10
|
+
import { IsEnum, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
|
11
|
+
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
12
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
13
|
+
import { IsSupportedPhoneNumber } from "../../phone/validators/is-supported-phone-number.decorator";
|
|
12
14
|
export class LoginMobileUserDto {
|
|
13
15
|
}
|
|
14
16
|
__decorate([
|
|
15
17
|
ApiProperty({
|
|
16
|
-
description: 'Mobile phone number
|
|
17
|
-
example: '+
|
|
18
|
+
description: 'Mobile phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
|
|
19
|
+
example: '+254712345678',
|
|
18
20
|
format: 'phone'
|
|
19
21
|
}),
|
|
20
|
-
|
|
22
|
+
IsSupportedPhoneNumber(),
|
|
21
23
|
IsNotEmpty(),
|
|
22
24
|
__metadata("design:type", String)
|
|
23
25
|
], LoginMobileUserDto.prototype, "phoneNumber", void 0);
|
|
26
|
+
__decorate([
|
|
27
|
+
ApiPropertyOptional({
|
|
28
|
+
description: 'ISO 3166-1 alpha-2 country code for the phone number (KE, UG, TZ). Required when phoneNumber is in national format; defaults to KE.',
|
|
29
|
+
enum: CountryCode,
|
|
30
|
+
example: CountryCode.KE
|
|
31
|
+
}),
|
|
32
|
+
IsEnum(CountryCode),
|
|
33
|
+
IsOptional(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], LoginMobileUserDto.prototype, "countryCode", void 0);
|
|
24
36
|
__decorate([
|
|
25
37
|
ApiProperty({
|
|
26
38
|
description: 'Verification token received',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-mobile-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/login-mobile-user.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"login-mobile-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/login-mobile-user.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAEpG,MAAM,OAAO,kBAAkB;CA0B9B;AAlBG;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,2GAA2G;QACxH,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,sBAAsB,EAAE;IACxB,UAAU,EAAE;;uDACQ;AASrB;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,qIAAqI;QAClJ,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,WAAW,CAAC,EAAE;KAC1B,CAAC;IACD,MAAM,CAAC,WAAW,CAAC;IACnB,UAAU,EAAE;;uDACa;AAQ1B;IANC,WAAW,CAAC;QACT,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,cAAc;KAC1B,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;6DACc"}
|
|
@@ -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 { IsEmail, IsEnum, IsNotEmpty, IsNumber,
|
|
11
|
-
import { ApiProperty } from "@nestjs/swagger";
|
|
10
|
+
import { IsEmail, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString } from "class-validator";
|
|
11
|
+
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
12
12
|
import { IncidentAppId } from "../../incident";
|
|
13
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
14
|
+
import { IsSupportedPhoneNumber } from "../../phone/validators/is-supported-phone-number.decorator";
|
|
13
15
|
export class RegisterMobileUserDto {
|
|
14
16
|
}
|
|
15
17
|
__decorate([
|
|
@@ -43,14 +45,24 @@ __decorate([
|
|
|
43
45
|
], RegisterMobileUserDto.prototype, "email", void 0);
|
|
44
46
|
__decorate([
|
|
45
47
|
ApiProperty({
|
|
46
|
-
description: 'Phone number
|
|
47
|
-
example: '+
|
|
48
|
+
description: 'Phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
|
|
49
|
+
example: '+254712345678',
|
|
48
50
|
format: 'phone'
|
|
49
51
|
}),
|
|
50
|
-
|
|
52
|
+
IsSupportedPhoneNumber(),
|
|
51
53
|
IsNotEmpty(),
|
|
52
54
|
__metadata("design:type", String)
|
|
53
55
|
], RegisterMobileUserDto.prototype, "phoneNumber", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
ApiPropertyOptional({
|
|
58
|
+
description: 'ISO 3166-1 alpha-2 country code for the phone number (KE, UG, TZ). Required when phoneNumber is in national format; defaults to KE.',
|
|
59
|
+
enum: CountryCode,
|
|
60
|
+
example: CountryCode.KE
|
|
61
|
+
}),
|
|
62
|
+
IsEnum(CountryCode),
|
|
63
|
+
IsOptional(),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], RegisterMobileUserDto.prototype, "countryCode", void 0);
|
|
54
66
|
__decorate([
|
|
55
67
|
ApiProperty({
|
|
56
68
|
description: 'ID of the control centre the user belongs to',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-mobile-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/register-mobile-user.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"register-mobile-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/register-mobile-user.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAEpG,MAAM,OAAO,qBAAqB;CA4DjC;AApDG;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,mDAAmD;QAChE,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,aAAa,CAAC,KAAK;KAC/B,CAAC;IACD,MAAM,CAAC,aAAa,CAAC;IACrB,UAAU,EAAE;;oDACS;AAQtB;IANC,WAAW,CAAC;QACT,WAAW,EAAE,8BAA8B;QAC3C,OAAO,EAAE,UAAU;KACtB,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;mDACC;AASd;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,OAAO,EAAE;IACT,UAAU,EAAE;;oDACE;AASf;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,oGAAoG;QACjH,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,sBAAsB,EAAE;IACxB,UAAU,EAAE;;0DACQ;AASrB;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,qIAAqI;QAClJ,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,WAAW,CAAC,EAAE;KAC1B,CAAC;IACD,MAAM,CAAC,WAAW,CAAC;IACnB,UAAU,EAAE;;0DACa;AAQ1B;IANC,WAAW,CAAC;QACT,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE,GAAG;KACf,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;8DACY;AAQzB;IANC,WAAW,CAAC;QACT,WAAW,EAAE,4CAA4C;QACzD,OAAO,EAAE,GAAG;KACf,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;6DACW"}
|
|
@@ -7,7 +7,7 @@ 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 { IsArray, IsEmail, IsEnum, IsNotEmpty, IsOptional,
|
|
10
|
+
import { IsArray, IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, IsUrl, Matches, MaxLength, MinLength, ValidateNested } from "class-validator";
|
|
11
11
|
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
12
12
|
import { MapAddressDto } from "../../common";
|
|
13
13
|
import { Roles } from "../../role";
|
|
@@ -16,6 +16,8 @@ import { PASSWORD_ERROR_MESSAGE, PASSWORD_REGEX } from "../../common/constants/p
|
|
|
16
16
|
import { Type } from "class-transformer";
|
|
17
17
|
import { OrganizationType } from "../../organization/enums/org-type.enum";
|
|
18
18
|
import { IncidentAppId, IncidentClass } from "../../incident";
|
|
19
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
20
|
+
import { IsSupportedPhoneNumber } from "../../phone/validators/is-supported-phone-number.decorator";
|
|
19
21
|
export class RegisterDto {
|
|
20
22
|
}
|
|
21
23
|
__decorate([
|
|
@@ -66,16 +68,26 @@ __decorate([
|
|
|
66
68
|
], RegisterDto.prototype, "email", void 0);
|
|
67
69
|
__decorate([
|
|
68
70
|
ApiProperty({
|
|
69
|
-
description: 'Phone number
|
|
70
|
-
example: '+
|
|
71
|
+
description: 'Phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
|
|
72
|
+
example: '+254712345678',
|
|
71
73
|
format: 'phone',
|
|
72
74
|
maxLength: 20
|
|
73
75
|
}),
|
|
74
|
-
|
|
76
|
+
IsSupportedPhoneNumber(),
|
|
75
77
|
MaxLength(20),
|
|
76
78
|
IsNotEmpty(),
|
|
77
79
|
__metadata("design:type", String)
|
|
78
80
|
], RegisterDto.prototype, "phoneNumber", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
ApiPropertyOptional({
|
|
83
|
+
description: 'ISO 3166-1 alpha-2 country code for the phone number (KE, UG, TZ). Required when phoneNumber is in national format; defaults to KE.',
|
|
84
|
+
enum: CountryCode,
|
|
85
|
+
example: CountryCode.KE
|
|
86
|
+
}),
|
|
87
|
+
IsEnum(CountryCode),
|
|
88
|
+
IsOptional(),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
|
+
], RegisterDto.prototype, "countryCode", void 0);
|
|
79
91
|
__decorate([
|
|
80
92
|
ApiPropertyOptional({
|
|
81
93
|
description: 'User roles (optional)',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/register.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"register.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/register.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAEpG,MAAM,OAAO,WAAW;CAoIvB;AA5HG;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,a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QACT,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,gBAAgB,CAAC,MAAM;KACnC,CAAC;IACD,MAAM,CAAC,gBAAgB,CAAC;IACxB,UAAU,EAAE;;4CACc"}
|
|
@@ -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 { IsEmail, IsEnum, IsNotEmpty, IsOptional,
|
|
10
|
+
import { IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString } from "class-validator";
|
|
11
11
|
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
12
12
|
import { OtpAction } from "../enums/otp-action";
|
|
13
|
+
import { CountryCode } from "../../country/enums/country-code.enum";
|
|
14
|
+
import { IsSupportedPhoneNumber } from "../../phone/validators/is-supported-phone-number.decorator";
|
|
13
15
|
export class ResendOTPDto {
|
|
14
16
|
}
|
|
15
17
|
__decorate([
|
|
@@ -45,12 +47,22 @@ __decorate([
|
|
|
45
47
|
], ResendOTPDto.prototype, "email", void 0);
|
|
46
48
|
__decorate([
|
|
47
49
|
ApiPropertyOptional({
|
|
48
|
-
description: 'Phone number of the user requesting OTP',
|
|
49
|
-
example: '+
|
|
50
|
+
description: 'Phone number of the user requesting OTP, in E.164 format (e.g. +254712345678) or national format when countryCode is provided',
|
|
51
|
+
example: '+254712345678',
|
|
50
52
|
format: 'phone'
|
|
51
53
|
}),
|
|
52
|
-
|
|
54
|
+
IsSupportedPhoneNumber(),
|
|
53
55
|
IsOptional(),
|
|
54
56
|
__metadata("design:type", String)
|
|
55
57
|
], ResendOTPDto.prototype, "phoneNumber", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
ApiPropertyOptional({
|
|
60
|
+
description: 'ISO 3166-1 alpha-2 country code for the phone number (KE, UG, TZ). Required when phoneNumber is in national format; defaults to KE.',
|
|
61
|
+
enum: CountryCode,
|
|
62
|
+
example: CountryCode.KE
|
|
63
|
+
}),
|
|
64
|
+
IsEnum(CountryCode),
|
|
65
|
+
IsOptional(),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], ResendOTPDto.prototype, "countryCode", void 0);
|
|
56
68
|
//# sourceMappingURL=resend-otp.dto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resend-otp.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/resend-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"resend-otp.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/resend-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AAEpG,MAAM,OAAO,YAAY;CA8CxB;AArCG;IARC,WAAW,CAAC;QACT,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,SAAS,CAAC,KAAK;QACxB,MAAM,EAAE,QAAQ;KACnB,CAAC;IACD,MAAM,CAAC,SAAS,CAAC;IACjB,UAAU,EAAE;;4CACM;AASnB;IAPC,mBAAmB,CAAC;QACjB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,QAAQ;KAC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