grm-shared-library 1.1.183 → 1.1.185

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.
Files changed (62) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/modules/auth/dtos/login-mobile-user.dto.js +15 -3
  4. package/dist/cjs/modules/auth/dtos/login-mobile-user.dto.js.map +1 -1
  5. package/dist/cjs/modules/auth/dtos/register-mobile-user.dto.js +15 -3
  6. package/dist/cjs/modules/auth/dtos/register-mobile-user.dto.js.map +1 -1
  7. package/dist/cjs/modules/auth/dtos/register.dto.js +15 -3
  8. package/dist/cjs/modules/auth/dtos/register.dto.js.map +1 -1
  9. package/dist/cjs/modules/auth/dtos/resend-otp.dto.js +15 -3
  10. package/dist/cjs/modules/auth/dtos/resend-otp.dto.js.map +1 -1
  11. package/dist/cjs/modules/auth/dtos/send-otp.dto.js +15 -3
  12. package/dist/cjs/modules/auth/dtos/send-otp.dto.js.map +1 -1
  13. package/dist/cjs/modules/phone/index.js +23 -0
  14. package/dist/cjs/modules/phone/index.js.map +1 -0
  15. package/dist/cjs/modules/phone/interfaces/normalized-phone.js +3 -0
  16. package/dist/cjs/modules/phone/interfaces/normalized-phone.js.map +1 -0
  17. package/dist/cjs/modules/phone/phone.util.js +92 -0
  18. package/dist/cjs/modules/phone/phone.util.js.map +1 -0
  19. package/dist/cjs/modules/phone/validators/is-supported-phone-number.decorator.js +39 -0
  20. package/dist/cjs/modules/phone/validators/is-supported-phone-number.decorator.js.map +1 -0
  21. package/dist/cjs/modules/user/dtos/create-user.dto.js +15 -3
  22. package/dist/cjs/modules/user/dtos/create-user.dto.js.map +1 -1
  23. package/dist/cjs/modules/user/dtos/guardian.dto.js +15 -3
  24. package/dist/cjs/modules/user/dtos/guardian.dto.js.map +1 -1
  25. package/dist/esm/index.js +1 -0
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/modules/auth/dtos/login-mobile-user.dto.js +17 -5
  28. package/dist/esm/modules/auth/dtos/login-mobile-user.dto.js.map +1 -1
  29. package/dist/esm/modules/auth/dtos/register-mobile-user.dto.js +17 -5
  30. package/dist/esm/modules/auth/dtos/register-mobile-user.dto.js.map +1 -1
  31. package/dist/esm/modules/auth/dtos/register.dto.js +16 -4
  32. package/dist/esm/modules/auth/dtos/register.dto.js.map +1 -1
  33. package/dist/esm/modules/auth/dtos/resend-otp.dto.js +16 -4
  34. package/dist/esm/modules/auth/dtos/resend-otp.dto.js.map +1 -1
  35. package/dist/esm/modules/auth/dtos/send-otp.dto.js +16 -4
  36. package/dist/esm/modules/auth/dtos/send-otp.dto.js.map +1 -1
  37. package/dist/esm/modules/phone/index.js +7 -0
  38. package/dist/esm/modules/phone/index.js.map +1 -0
  39. package/dist/esm/modules/phone/interfaces/normalized-phone.js +2 -0
  40. package/dist/esm/modules/phone/interfaces/normalized-phone.js.map +1 -0
  41. package/dist/esm/modules/phone/phone.util.js +86 -0
  42. package/dist/esm/modules/phone/phone.util.js.map +1 -0
  43. package/dist/esm/modules/phone/validators/is-supported-phone-number.decorator.js +36 -0
  44. package/dist/esm/modules/phone/validators/is-supported-phone-number.decorator.js.map +1 -0
  45. package/dist/esm/modules/user/dtos/create-user.dto.js +16 -4
  46. package/dist/esm/modules/user/dtos/create-user.dto.js.map +1 -1
  47. package/dist/esm/modules/user/dtos/guardian.dto.js +16 -4
  48. package/dist/esm/modules/user/dtos/guardian.dto.js.map +1 -1
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/modules/auth/dtos/login-mobile-user.dto.d.ts +2 -0
  51. package/dist/types/modules/auth/dtos/register-mobile-user.dto.d.ts +2 -0
  52. package/dist/types/modules/auth/dtos/register.dto.d.ts +2 -0
  53. package/dist/types/modules/auth/dtos/resend-otp.dto.d.ts +2 -0
  54. package/dist/types/modules/auth/dtos/send-otp.dto.d.ts +2 -0
  55. package/dist/types/modules/phone/index.d.ts +3 -0
  56. package/dist/types/modules/phone/interfaces/normalized-phone.d.ts +22 -0
  57. package/dist/types/modules/phone/phone.util.d.ts +20 -0
  58. package/dist/types/modules/phone/validators/is-supported-phone-number.decorator.d.ts +12 -0
  59. package/dist/types/modules/user/dtos/create-user.dto.d.ts +2 -0
  60. package/dist/types/modules/user/dtos/guardian.dto.d.ts +2 -0
  61. package/dist/types/modules/user/interfaces/user.d.ts +6 -0
  62. package/package.json +3 -2
package/dist/cjs/index.js CHANGED
@@ -34,6 +34,7 @@ __exportStar(require("./modules/web-notification/index"), exports);
34
34
  __exportStar(require("./modules/notification/index"), exports);
35
35
  __exportStar(require("./modules/chat/index"), exports);
36
36
  __exportStar(require("./modules/country/index"), exports);
37
+ __exportStar(require("./modules/phone/index"), exports);
37
38
  // Interfaces
38
39
  __exportStar(require("./interfaces/server-message"), exports);
39
40
  __exportStar(require("./interfaces/i-request-with-user"), exports);
@@ -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;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"}
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;AACxC,wDAAsC;AAEtC,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"}
@@ -12,19 +12,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.LoginMobileUserDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
+ const country_code_enum_1 = require("../../country/enums/country-code.enum");
16
+ const is_supported_phone_number_decorator_1 = require("../../phone/validators/is-supported-phone-number.decorator");
15
17
  class LoginMobileUserDto {
16
18
  }
17
19
  exports.LoginMobileUserDto = LoginMobileUserDto;
18
20
  __decorate([
19
21
  (0, swagger_1.ApiProperty)({
20
- description: 'Mobile phone number with country code',
21
- example: '+1234567890',
22
+ description: 'Mobile phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
23
+ example: '+254712345678',
22
24
  format: 'phone'
23
25
  }),
24
- (0, class_validator_1.IsPhoneNumber)(),
26
+ (0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
25
27
  (0, class_validator_1.IsNotEmpty)(),
26
28
  __metadata("design:type", String)
27
29
  ], LoginMobileUserDto.prototype, "phoneNumber", void 0);
30
+ __decorate([
31
+ (0, swagger_1.ApiPropertyOptional)({
32
+ 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.',
33
+ enum: country_code_enum_1.CountryCode,
34
+ example: country_code_enum_1.CountryCode.KE
35
+ }),
36
+ (0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
37
+ (0, class_validator_1.IsOptional)(),
38
+ __metadata("design:type", String)
39
+ ], LoginMobileUserDto.prototype, "countryCode", void 0);
28
40
  __decorate([
29
41
  (0, swagger_1.ApiProperty)({
30
42
  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,qDAAsE;AACtE,6CAA8C;AAE9C,MAAa,kBAAkB;CAiB9B;AAjBD,gDAiBC;AATG;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,uCAAuC;QACpD,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,+BAAa,GAAE;IACf,IAAA,4BAAU,GAAE;;uDACQ;AAQrB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,cAAc;KAC1B,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6DACc"}
1
+ {"version":3,"file":"login-mobile-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/login-mobile-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2E;AAC3E,6CAAmE;AACnE,6EAAoE;AACpE,oHAAoG;AAEpG,MAAa,kBAAkB;CA0B9B;AA1BD,gDA0BC;AAlBG;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,2GAA2G;QACxH,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,4DAAsB,GAAE;IACxB,IAAA,4BAAU,GAAE;;uDACQ;AASrB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,qIAAqI;QAClJ,IAAI,EAAE,+BAAW;QACjB,OAAO,EAAE,+BAAW,CAAC,EAAE;KAC1B,CAAC;IACD,IAAA,wBAAM,EAAC,+BAAW,CAAC;IACnB,IAAA,4BAAU,GAAE;;uDACa;AAQ1B;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,cAAc;KAC1B,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6DACc"}
@@ -13,6 +13,8 @@ exports.RegisterMobileUserDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const incident_1 = require("../../incident");
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 RegisterMobileUserDto {
17
19
  }
18
20
  exports.RegisterMobileUserDto = RegisterMobileUserDto;
@@ -47,14 +49,24 @@ __decorate([
47
49
  ], RegisterMobileUserDto.prototype, "email", void 0);
48
50
  __decorate([
49
51
  (0, swagger_1.ApiProperty)({
50
- description: 'Phone number with country code',
51
- example: '+1234567890',
52
+ description: 'Phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
53
+ example: '+254712345678',
52
54
  format: 'phone'
53
55
  }),
54
- (0, class_validator_1.IsPhoneNumber)(),
56
+ (0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
55
57
  (0, class_validator_1.IsNotEmpty)(),
56
58
  __metadata("design:type", String)
57
59
  ], RegisterMobileUserDto.prototype, "phoneNumber", void 0);
60
+ __decorate([
61
+ (0, swagger_1.ApiPropertyOptional)({
62
+ 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.',
63
+ enum: country_code_enum_1.CountryCode,
64
+ example: country_code_enum_1.CountryCode.KE
65
+ }),
66
+ (0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
67
+ (0, class_validator_1.IsOptional)(),
68
+ __metadata("design:type", String)
69
+ ], RegisterMobileUserDto.prototype, "countryCode", void 0);
58
70
  __decorate([
59
71
  (0, swagger_1.ApiProperty)({
60
72
  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,qDAAiG;AACjG,6CAA8C;AAC9C,6CAA+C;AAE/C,MAAa,qBAAqB;CAmDjC;AAnDD,sDAmDC;AA3CG;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,mDAAmD;QAChE,IAAI,EAAE,wBAAa;QACnB,OAAO,EAAE,wBAAa,CAAC,KAAK;KAC/B,CAAC;IACD,IAAA,wBAAM,EAAC,wBAAa,CAAC;IACrB,IAAA,4BAAU,GAAE;;oDACS;AAQtB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,8BAA8B;QAC3C,OAAO,EAAE,UAAU;KACtB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;mDACC;AASd;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;oDACE;AASf;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,gCAAgC;QAC7C,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,+BAAa,GAAE;IACf,IAAA,4BAAU,GAAE;;0DACQ;AAQrB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE,GAAG;KACf,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;8DACY;AAQzB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,4CAA4C;QACzD,OAAO,EAAE,GAAG;KACf,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6DACW"}
1
+ {"version":3,"file":"register-mobile-user.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/register-mobile-user.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8F;AAC9F,6CAAmE;AACnE,6CAA+C;AAC/C,6EAAoE;AACpE,oHAAoG;AAEpG,MAAa,qBAAqB;CA4DjC;AA5DD,sDA4DC;AApDG;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,mDAAmD;QAChE,IAAI,EAAE,wBAAa;QACnB,OAAO,EAAE,wBAAa,CAAC,KAAK;KAC/B,CAAC;IACD,IAAA,wBAAM,EAAC,wBAAa,CAAC;IACrB,IAAA,4BAAU,GAAE;;oDACS;AAQtB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,8BAA8B;QAC3C,OAAO,EAAE,UAAU;KACtB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;mDACC;AASd;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE,sBAAsB;QAC/B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;oDACE;AASf;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,oGAAoG;QACjH,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,4DAAsB,GAAE;IACxB,IAAA,4BAAU,GAAE;;0DACQ;AASrB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,qIAAqI;QAClJ,IAAI,EAAE,+BAAW;QACjB,OAAO,EAAE,+BAAW,CAAC,EAAE;KAC1B,CAAC;IACD,IAAA,wBAAM,EAAC,+BAAW,CAAC;IACnB,IAAA,4BAAU,GAAE;;0DACa;AAQ1B;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE,GAAG;KACf,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;8DACY;AAQzB;IANC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,4CAA4C;QACzD,OAAO,EAAE,GAAG;KACf,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6DACW"}
@@ -19,6 +19,8 @@ const password_regex_const_1 = require("../../common/constants/password-regex.co
19
19
  const class_transformer_1 = require("class-transformer");
20
20
  const org_type_enum_1 = require("../../organization/enums/org-type.enum");
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 RegisterDto {
23
25
  }
24
26
  exports.RegisterDto = RegisterDto;
@@ -70,16 +72,26 @@ __decorate([
70
72
  ], RegisterDto.prototype, "email", void 0);
71
73
  __decorate([
72
74
  (0, swagger_1.ApiProperty)({
73
- description: 'Phone number with country code',
74
- example: '+1234567890',
75
+ description: 'Phone number in E.164 format (e.g. +254712345678), or national format when countryCode is provided',
76
+ example: '+254712345678',
75
77
  format: 'phone',
76
78
  maxLength: 20
77
79
  }),
78
- (0, class_validator_1.IsPhoneNumber)(),
80
+ (0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
79
81
  (0, class_validator_1.MaxLength)(20),
80
82
  (0, class_validator_1.IsNotEmpty)(),
81
83
  __metadata("design:type", String)
82
84
  ], RegisterDto.prototype, "phoneNumber", void 0);
85
+ __decorate([
86
+ (0, swagger_1.ApiPropertyOptional)({
87
+ 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.',
88
+ enum: country_code_enum_1.CountryCode,
89
+ example: country_code_enum_1.CountryCode.KE
90
+ }),
91
+ (0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
92
+ (0, class_validator_1.IsOptional)(),
93
+ __metadata("design:type", String)
94
+ ], RegisterDto.prototype, "countryCode", void 0);
83
95
  __decorate([
84
96
  (0, swagger_1.ApiPropertyOptional)({
85
97
  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,qDAAkK;AAClK,6CAAmE;AACnE,yCAA6C;AAC7C,qCAAmC;AACnC,yEAAmE;AACnE,sFAAqG;AACrG,yDAAyC;AACzC,0EAA0E;AAC1E,6CAA8D;AAE9D,MAAa,WAAW;CA2HvB;AA3HD,kCA2HC;AAnHG;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,wBAAa;QACnB,OAAO,EAAE,wBAAa,CAAC,GAAG;KAC7B,CAAC;IACD,IAAA,wBAAM,EAAC,wBAAa,CAAC;IACrB,IAAA,4BAAU,GAAE;;0CACS;AAStB;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,wBAAa;QACnB,OAAO,EAAE,wBAAa,CAAC,QAAQ;KAClC,CAAC;IACD,IAAA,wBAAM,EAAC,wBAAa,CAAC;IACrB,IAAA,4BAAU,GAAE;;kDACiB;AAa9B;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,EAA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,CAAC;IACZ,IAAA,yBAAO,EAAC,qCAAc,EAAE,EAAE,OAAO,EAAE,6CAAsB,EAAE,CAAC;IAC5D,IAAA,4BAAU,GAAE;;6CACK;AAUlB;IARC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE,kCAAkC;QAC3C,SAAS,EAAE,EAAE;KAChB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,2BAAS,EAAC,EAAE,CAAC;;4CACG;AASjB;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,sBAAa;KACtB,CAAC;IACD,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC;IACzB,IAAA,4BAAU,GAAE;8BACA,sBAAa;+CAAC;AAS3B;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,0BAA0B;QACvC,OAAO,EAAE,mCAAmC;QAC5C,MAAM,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,uBAAK,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,sDAAsD,EAAE,CAAC;IAC9E,IAAA,4BAAU,GAAE;;+CACO;AASpB;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,gCAAgB;QACtB,OAAO,EAAE,gCAAgB,CAAC,MAAM;KACnC,CAAC;IACD,IAAA,wBAAM,EAAC,gCAAgB,CAAC;IACxB,IAAA,4BAAU,GAAE;;4CACc"}
1
+ {"version":3,"file":"register.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/register.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmJ;AACnJ,6CAAmE;AACnE,yCAA6C;AAC7C,qCAAmC;AACnC,yEAAmE;AACnE,sFAAqG;AACrG,yDAAyC;AACzC,0EAA0E;AAC1E,6CAA8D;AAC9D,6E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2BAAS,EAAC,EAAE,CAAC;;4CACG;AASjB;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,sBAAa;KACtB,CAAC;IACD,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,sBAAa,CAAC;IACzB,IAAA,4BAAU,GAAE;8BACA,sBAAa;+CAAC;AAS3B;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,0BAA0B;QACvC,OAAO,EAAE,mCAAmC;QAC5C,MAAM,EAAE,KAAK;KAChB,CAAC;IACD,IAAA,uBAAK,EAAC,EAAE,EAAE,EAAE,OAAO,EAAE,sDAAsD,EAAE,CAAC;IAC9E,IAAA,4BAAU,GAAE;;+CACO;AASpB;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,gCAAgB;QACtB,OAAO,EAAE,gCAAgB,CAAC,MAAM;KACnC,CAAC;IACD,IAAA,wBAAM,EAAC,gCAAgB,CAAC;IACxB,IAAA,4BAAU,GAAE;;4CACc"}
@@ -13,6 +13,8 @@ exports.ResendOTPDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
15
  const otp_action_1 = require("../enums/otp-action");
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 ResendOTPDto {
17
19
  }
18
20
  exports.ResendOTPDto = ResendOTPDto;
@@ -49,12 +51,22 @@ __decorate([
49
51
  ], ResendOTPDto.prototype, "email", void 0);
50
52
  __decorate([
51
53
  (0, swagger_1.ApiPropertyOptional)({
52
- description: 'Phone number of the user requesting OTP',
53
- example: '+1234567890',
54
+ description: 'Phone number of the user requesting OTP, in E.164 format (e.g. +254712345678) or national format when countryCode is provided',
55
+ example: '+254712345678',
54
56
  format: 'phone'
55
57
  }),
56
- (0, class_validator_1.IsPhoneNumber)(),
58
+ (0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
57
59
  (0, class_validator_1.IsOptional)(),
58
60
  __metadata("design:type", String)
59
61
  ], ResendOTPDto.prototype, "phoneNumber", void 0);
62
+ __decorate([
63
+ (0, swagger_1.ApiPropertyOptional)({
64
+ 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.',
65
+ enum: country_code_enum_1.CountryCode,
66
+ example: country_code_enum_1.CountryCode.KE
67
+ }),
68
+ (0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
69
+ (0, class_validator_1.IsOptional)(),
70
+ __metadata("design:type", String)
71
+ ], ResendOTPDto.prototype, "countryCode", void 0);
60
72
  //# 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,qDAAmG;AACnG,6CAAmE;AACnE,oDAAgD;AAEhD,MAAa,YAAY;CAqCxB;AArCD,oCAqCC;AA5BG;IARC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,sBAAS;QACf,OAAO,EAAE,sBAAS,CAAC,KAAK;QACxB,MAAM,EAAE,QAAQ;KACnB,CAAC;IACD,IAAA,wBAAM,EAAC,sBAAS,CAAC;IACjB,IAAA,4BAAU,GAAE;;4CACM;AASnB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,QAAQ;KACnB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;uDACc;AAS3B;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;2CACE;AASf;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,yCAAyC;QACtD,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,+BAAa,GAAE;IACf,IAAA,4BAAU,GAAE;;iDACQ"}
1
+ {"version":3,"file":"resend-otp.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/resend-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoF;AACpF,6CAAmE;AACnE,oDAAgD;AAChD,6EAAoE;AACpE,oHAAoG;AAEpG,MAAa,YAAY;CA8CxB;AA9CD,oCA8CC;AArCG;IARC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,sBAAS;QACf,OAAO,EAAE,sBAAS,CAAC,KAAK;QACxB,MAAM,EAAE,QAAQ;KACnB,CAAC;IACD,IAAA,wBAAM,EAAC,sBAAS,CAAC;IACjB,IAAA,4BAAU,GAAE;;4CACM;AASnB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,QAAQ;KACnB,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;uDACc;AAS3B;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,kCAAkC;QAC/C,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;2CACE;AASf;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,+HAA+H;QAC5I,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,4DAAsB,GAAE;IACxB,IAAA,4BAAU,GAAE;;iDACQ;AASrB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,qIAAqI;QAClJ,IAAI,EAAE,+BAAW;QACjB,OAAO,EAAE,+BAAW,CAAC,EAAE;KAC1B,CAAC;IACD,IAAA,wBAAM,EAAC,+BAAW,CAAC;IACnB,IAAA,4BAAU,GAAE;;iDACa"}
@@ -13,19 +13,31 @@ exports.SendOTPDto = void 0;
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const otp_action_1 = require("../enums/otp-action");
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 SendOTPDto {
17
19
  }
18
20
  exports.SendOTPDto = SendOTPDto;
19
21
  __decorate([
20
22
  (0, swagger_1.ApiPropertyOptional)({
21
- description: 'The phone number to send the OTP to (If email is not provided)',
22
- example: '+1234567890',
23
+ description: 'The phone number to send the OTP to, in E.164 format (e.g. +254712345678) or national format when countryCode is provided (If email is not provided)',
24
+ example: '+254712345678',
23
25
  format: 'phone'
24
26
  }),
25
- (0, class_validator_1.IsPhoneNumber)(),
27
+ (0, is_supported_phone_number_decorator_1.IsSupportedPhoneNumber)(),
26
28
  (0, class_validator_1.IsOptional)(),
27
29
  __metadata("design:type", String)
28
30
  ], SendOTPDto.prototype, "phoneNumber", void 0);
31
+ __decorate([
32
+ (0, swagger_1.ApiPropertyOptional)({
33
+ 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.',
34
+ enum: country_code_enum_1.CountryCode,
35
+ example: country_code_enum_1.CountryCode.KE
36
+ }),
37
+ (0, class_validator_1.IsEnum)(country_code_enum_1.CountryCode),
38
+ (0, class_validator_1.IsOptional)(),
39
+ __metadata("design:type", String)
40
+ ], SendOTPDto.prototype, "countryCode", void 0);
29
41
  __decorate([
30
42
  (0, swagger_1.ApiPropertyOptional)({
31
43
  description: 'The email address to send the OTP to (If phone number is not provided)',
@@ -1 +1 @@
1
- {"version":3,"file":"send-otp.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/send-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,qDAAmG;AACnG,oDAAgD;AAEhD,MAAa,UAAU;CA2BtB;AA3BD,gCA2BC;AAnBG;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,gEAAgE;QAC7E,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,+BAAa,GAAE;IACf,IAAA,4BAAU,GAAE;;+CACQ;AASrB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,wEAAwE;QACrF,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;yCACE;AASf;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,sBAAS;QACf,OAAO,EAAE,sBAAS,CAAC,YAAY;KAClC,CAAC;IACD,IAAA,wBAAM,EAAC,sBAAS,CAAC;IACjB,IAAA,4BAAU,GAAE;;0CACM"}
1
+ {"version":3,"file":"send-otp.dto.js","sourceRoot":"","sources":["../../../../../src/modules/auth/dtos/send-otp.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,qDAAoF;AACpF,oDAAgD;AAChD,6EAAoE;AACpE,oHAAoG;AAEpG,MAAa,UAAU;CAoCtB;AApCD,gCAoCC;AA5BG;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,sJAAsJ;QACnK,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,4DAAsB,GAAE;IACxB,IAAA,4BAAU,GAAE;;+CACQ;AASrB;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,qIAAqI;QAClJ,IAAI,EAAE,+BAAW;QACjB,OAAO,EAAE,+BAAW,CAAC,EAAE;KAC1B,CAAC;IACD,IAAA,wBAAM,EAAC,+BAAW,CAAC;IACnB,IAAA,4BAAU,GAAE;;+CACa;AAS1B;IAPC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,wEAAwE;QACrF,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,yBAAO,GAAE;IACT,IAAA,4BAAU,GAAE;;yCACE;AASf;IAPC,IAAA,qBAAW,EAAC;QACT,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,sBAAS;QACf,OAAO,EAAE,sBAAS,CAAC,YAAY;KAClC,CAAC;IACD,IAAA,wBAAM,EAAC,sBAAS,CAAC;IACjB,IAAA,4BAAU,GAAE;;0CACM"}
@@ -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,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=normalized-phone.js.map
@@ -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,OA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;IACzE,OAAO,QAAQ,CAAC,IAAA,8CAA0B,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,8FAA8F;AAC9F,SAAgB,sBAAsB,CAClC,KAAgC,EAChC,cAA4C;IAE5C,OAAO,6BAA6B,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC;AACnE,CAAC;AAED,iGAAiG;AACjG,SAAgB,eAAe,CAC3B,KAAgC,EAChC,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 with country code',
64
- example: '+1234567890',
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, class_validator_1.IsPhoneNumber)(),
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,qDAgByB;AACzB,6CAAmE;AACnE,yEAAmE;AACnE,gEAAuD;AACvD,s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ACW;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 with country code',
40
- example: '+1234567890',
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, class_validator_1.IsPhoneNumber)(),
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,qDAAwH;AACxH,6CAAmE;AACnE,oFAA2E;AAE3E,MAAa,WAAW;CAoDvB;AApDD,kCAoDC;AA7CG;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,yCAAyC;QACtD,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,IAAA,+BAAa,GAAE;IACf,IAAA,4BAAU,GAAE;;gDACQ;AASrB;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"}
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
@@ -18,6 +18,7 @@ export * from './modules/web-notification/index';
18
18
  export * from './modules/notification/index';
19
19
  export * from './modules/chat/index';
20
20
  export * from './modules/country/index';
21
+ export * from './modules/phone/index';
21
22
  // Interfaces
22
23
  export * from './interfaces/server-message';
23
24
  export * from './interfaces/i-request-with-user';
@@ -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;AACrC,cAAc,yBAAyB,CAAC;AAEx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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, IsPhoneNumber, IsString } from "class-validator";
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 with country code',
17
- example: '+1234567890',
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
- IsPhoneNumber(),
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,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,kBAAkB;CAiB9B;AATG;IAPC,WAAW,CAAC;QACT,WAAW,EAAE,uCAAuC;QACpD,OAAO,EAAE,aAAa;QACtB,MAAM,EAAE,OAAO;KAClB,CAAC;IACD,aAAa,EAAE;IACf,UAAU,EAAE;;uDACQ;AAQrB;IANC,WAAW,CAAC;QACT,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,cAAc;KAC1B,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;;6DACc"}
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"}