@fiado/type-kit 3.528.0 → 3.529.0

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.
@@ -50,4 +50,20 @@ describe('EmailSetTrustedRequest', () => {
50
50
  const errors = await validate(dto);
51
51
  expect(errors.some(e => e.property === 'type')).toBe(true);
52
52
  });
53
+
54
+ it('acepta isPrincipal en true', async () => {
55
+ const dto = plainToInstance(EmailSetTrustedRequest, { ...valid, isPrincipal: true });
56
+ const errors = await validate(dto);
57
+ expect(errors).toEqual([]);
58
+ expect(dto.isPrincipal).toBe(true);
59
+ });
60
+
61
+ it('falla si isPrincipal no es booleano', async () => {
62
+ const dto = plainToInstance(EmailSetTrustedRequest, {
63
+ ...valid,
64
+ isPrincipal: 'si' as unknown as boolean,
65
+ });
66
+ const errors = await validate(dto);
67
+ expect(errors.some(e => e.property === 'isPrincipal')).toBe(true);
68
+ });
53
69
  });
@@ -0,0 +1,53 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validateSync } from 'class-validator';
4
+ import { SendEmailOtpRequest } from '../../../src/retailWizard/dtos/requests/SendEmailOtpRequest';
5
+ import { VerifyEmailOtpRequest } from '../../../src/retailWizard/dtos/requests/VerifyEmailOtpRequest';
6
+ import { EmailStateEnum } from '../../../src/retailWizard/enums/EmailStateEnum';
7
+ import { EmailTypeEnum } from '../../../src/emailVerification/enums/EmailTypeEnum';
8
+ import * as RetailWizard from '../../../src/retailWizard';
9
+
10
+ function errorsOf<T extends object>(cls: new () => T, payload: Record<string, unknown>): string[] {
11
+ const dto = plainToInstance(cls, payload, { excludeExtraneousValues: true });
12
+ return validateSync(dto).map((e) => e.property);
13
+ }
14
+
15
+ describe('SendEmailOtpRequest', () => {
16
+ it('acepta correo y tipo válidos', () => {
17
+ expect(errorsOf(SendEmailOtpRequest, { email: 'cliente@correo.com', type: EmailTypeEnum.PERSONAL })).toEqual([]);
18
+ });
19
+
20
+ it('rechaza un correo mal formado', () => {
21
+ expect(errorsOf(SendEmailOtpRequest, { email: 'no-es-correo', type: EmailTypeEnum.PERSONAL })).toContain('email');
22
+ });
23
+
24
+ it('rechaza un tipo fuera del enum', () => {
25
+ expect(errorsOf(SendEmailOtpRequest, { email: 'cliente@correo.com', type: 'WORK' })).toContain('type');
26
+ });
27
+
28
+ it('exige el tipo', () => {
29
+ expect(errorsOf(SendEmailOtpRequest, { email: 'cliente@correo.com' })).toContain('type');
30
+ });
31
+ });
32
+
33
+ describe('VerifyEmailOtpRequest', () => {
34
+ it('acepta un código de 4 dígitos', () => {
35
+ expect(errorsOf(VerifyEmailOtpRequest, { code: '1234' })).toEqual([]);
36
+ });
37
+
38
+ it('rechaza un código vacío', () => {
39
+ expect(errorsOf(VerifyEmailOtpRequest, { code: '' })).toContain('code');
40
+ });
41
+ });
42
+
43
+ describe('EmailStateEnum', () => {
44
+ it('tiene los tres estados del correo de la sesión', () => {
45
+ expect(Object.values(EmailStateEnum)).toEqual(['EXISTING', 'CAPTURED', 'PENDING']);
46
+ });
47
+
48
+ it('se exporta desde el índice de retailWizard junto con los requests', () => {
49
+ expect(RetailWizard.EmailStateEnum).toBe(EmailStateEnum);
50
+ expect(RetailWizard.SendEmailOtpRequest).toBe(SendEmailOtpRequest);
51
+ expect(RetailWizard.VerifyEmailOtpRequest).toBe(VerifyEmailOtpRequest);
52
+ });
53
+ });
@@ -0,0 +1,22 @@
1
+ import type { WizardSession } from '../../../src/retailWizard/dtos/WizardSession';
2
+ import { EmailStateEnum } from '../../../src/retailWizard/enums/EmailStateEnum';
3
+ import { EmailTypeEnum } from '../../../src/emailVerification/enums/EmailTypeEnum';
4
+
5
+ type SessionEmail = Pick<WizardSession, 'emailState' | 'emailType' | 'emailMasked' | 'email'>;
6
+
7
+ describe('WizardSession — correo del paso 01', () => {
8
+ it('declara los cuatro campos del correo', () => {
9
+ const captured: SessionEmail = {
10
+ emailState: EmailStateEnum.CAPTURED,
11
+ emailType: EmailTypeEnum.PERSONAL,
12
+ emailMasked: 'ju•••••@gmail.com',
13
+ email: 'juan@gmail.com',
14
+ };
15
+ expect(captured.emailState).toBe('CAPTURED');
16
+ });
17
+
18
+ it('los cuatro son opcionales: una sesión vieja no los trae', () => {
19
+ const legacy: SessionEmail = {};
20
+ expect(legacy).toEqual({});
21
+ });
22
+ });
@@ -7,4 +7,6 @@ export declare class EmailSetTrustedRequest {
7
7
  directoryId: string;
8
8
  email: string;
9
9
  type: EmailTypeEnum;
10
+ /** En true, el correo queda como principal del directorio. Sin el campo, no cambia el principal. */
11
+ isPrincipal?: boolean;
10
12
  }
@@ -35,3 +35,9 @@ __decorate([
35
35
  (0, class_validator_1.IsEnum)(EmailTypeEnum_1.EmailTypeEnum),
36
36
  __metadata("design:type", String)
37
37
  ], EmailSetTrustedRequest.prototype, "type", void 0);
38
+ __decorate([
39
+ (0, class_transformer_1.Expose)(),
40
+ (0, class_validator_1.IsOptional)(),
41
+ (0, class_validator_1.IsBoolean)(),
42
+ __metadata("design:type", Boolean)
43
+ ], EmailSetTrustedRequest.prototype, "isPrincipal", void 0);
@@ -15,6 +15,8 @@ import type { WizardReservedLine } from './WizardReservedLine';
15
15
  import type { WizardResumeTarget } from './WizardResumeTarget';
16
16
  import type { WizardWelcome } from './WizardWelcome';
17
17
  import type { WizardCreditPromotionBonus } from './WizardCreditPromotionBonus';
18
+ import type { EmailStateEnum } from '../enums/EmailStateEnum';
19
+ import type { EmailTypeEnum } from '../../emailVerification/enums/EmailTypeEnum';
18
20
  /** Modalidad de captura del KYC (M1 §213-329). */
19
21
  export type KycModality = 'CUSTOMER_LINK' | 'STORE_DEVICE' | 'MANUAL';
20
22
  /** Estado de la apertura de cuenta async (D35) — espejo de `RetailCustomer.accountStatus`. */
@@ -64,6 +66,14 @@ export interface WizardSession {
64
66
  */
65
67
  resumeTarget?: WizardResumeTarget | null;
66
68
  consents: WizardConsents | null;
69
+ /** Estado del correo del cliente en el paso 01. Ausente en sesiones anteriores al correo. */
70
+ emailState?: EmailStateEnum;
71
+ /** Tipo del correo: personal o corporativo. */
72
+ emailType?: EmailTypeEnum;
73
+ /** Correo enmascarado (`ju•••••@gmail.com`); viaja siempre que la sesión tenga correo. */
74
+ emailMasked?: string;
75
+ /** Correo completo: solo con `emailState` CAPTURED, porque lo tecleó el vendedor. */
76
+ email?: string;
67
77
  /** Espejo del estado KYC (fuente = customer). */
68
78
  kycStatus: string | null;
69
79
  kycModality: KycModality | null;
@@ -0,0 +1,6 @@
1
+ import { EmailTypeEnum } from '../../../emailVerification/enums/EmailTypeEnum';
2
+ /** POST /wizard/sessions/:id/email/otp/send — manda el código al correo que capturó el vendedor. */
3
+ export declare class SendEmailOtpRequest {
4
+ email: string;
5
+ type: EmailTypeEnum;
6
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SendEmailOtpRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const EmailTypeEnum_1 = require("../../../emailVerification/enums/EmailTypeEnum");
16
+ /** POST /wizard/sessions/:id/email/otp/send — manda el código al correo que capturó el vendedor. */
17
+ class SendEmailOtpRequest {
18
+ }
19
+ exports.SendEmailOtpRequest = SendEmailOtpRequest;
20
+ __decorate([
21
+ (0, class_transformer_1.Expose)(),
22
+ (0, class_validator_1.IsEmail)(),
23
+ __metadata("design:type", String)
24
+ ], SendEmailOtpRequest.prototype, "email", void 0);
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ (0, class_validator_1.IsEnum)(EmailTypeEnum_1.EmailTypeEnum),
28
+ __metadata("design:type", String)
29
+ ], SendEmailOtpRequest.prototype, "type", void 0);
@@ -0,0 +1,4 @@
1
+ /** POST /wizard/sessions/:id/email/otp/verify — verifica el código que llegó al correo. */
2
+ export declare class VerifyEmailOtpRequest {
3
+ code: string;
4
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.VerifyEmailOtpRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ /** POST /wizard/sessions/:id/email/otp/verify — verifica el código que llegó al correo. */
16
+ class VerifyEmailOtpRequest {
17
+ }
18
+ exports.VerifyEmailOtpRequest = VerifyEmailOtpRequest;
19
+ __decorate([
20
+ (0, class_transformer_1.Expose)(),
21
+ (0, class_validator_1.IsString)(),
22
+ (0, class_validator_1.Length)(4, 8),
23
+ __metadata("design:type", String)
24
+ ], VerifyEmailOtpRequest.prototype, "code", void 0);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Correo de la sesión del wizard: EXISTING = ya verificado en contacts; CAPTURED = lo tecleó el
3
+ * vendedor y se verificó con OTP; PENDING = falta capturarlo o verificarlo.
4
+ */
5
+ export declare enum EmailStateEnum {
6
+ EXISTING = "EXISTING",
7
+ CAPTURED = "CAPTURED",
8
+ PENDING = "PENDING"
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailStateEnum = void 0;
4
+ /**
5
+ * Correo de la sesión del wizard: EXISTING = ya verificado en contacts; CAPTURED = lo tecleó el
6
+ * vendedor y se verificó con OTP; PENDING = falta capturarlo o verificarlo.
7
+ */
8
+ var EmailStateEnum;
9
+ (function (EmailStateEnum) {
10
+ EmailStateEnum["EXISTING"] = "EXISTING";
11
+ EmailStateEnum["CAPTURED"] = "CAPTURED";
12
+ EmailStateEnum["PENDING"] = "PENDING";
13
+ })(EmailStateEnum || (exports.EmailStateEnum = EmailStateEnum = {}));
@@ -26,6 +26,7 @@ export * from './enums/BlockedCategoryEnum';
26
26
  export * from './enums/WizardLineStatusEnum';
27
27
  export * from './enums/LinePaymentTypeEnum';
28
28
  export * from './enums/WizardLineRoleEnum';
29
+ export * from './enums/EmailStateEnum';
29
30
  export * from './dtos/WizardConsents';
30
31
  export * from './dtos/WizardPayment';
31
32
  export * from './dtos/WizardProduct';
@@ -90,6 +91,8 @@ export * from './dtos/requests/SignatureSignRequest';
90
91
  export * from './dtos/requests/RegisterDeviceRequest';
91
92
  export * from './dtos/requests/CompleteSaleRequest';
92
93
  export * from './dtos/requests/SuggestIdentifiersQuery';
94
+ export * from './dtos/requests/SendEmailOtpRequest';
95
+ export * from './dtos/requests/VerifyEmailOtpRequest';
93
96
  export * from './dtos/responses/KycPrepareResponse';
94
97
  export * from './dtos/responses/ProofOfAddressPrepareResponse';
95
98
  export * from './dtos/responses/SessionFinanciersResponse';
@@ -45,6 +45,7 @@ __exportStar(require("./enums/BlockedCategoryEnum"), exports);
45
45
  __exportStar(require("./enums/WizardLineStatusEnum"), exports);
46
46
  __exportStar(require("./enums/LinePaymentTypeEnum"), exports);
47
47
  __exportStar(require("./enums/WizardLineRoleEnum"), exports);
48
+ __exportStar(require("./enums/EmailStateEnum"), exports);
48
49
  // DTOs anidados
49
50
  __exportStar(require("./dtos/WizardConsents"), exports);
50
51
  __exportStar(require("./dtos/WizardPayment"), exports);
@@ -115,6 +116,8 @@ __exportStar(require("./dtos/requests/SignatureSignRequest"), exports);
115
116
  __exportStar(require("./dtos/requests/RegisterDeviceRequest"), exports);
116
117
  __exportStar(require("./dtos/requests/CompleteSaleRequest"), exports);
117
118
  __exportStar(require("./dtos/requests/SuggestIdentifiersQuery"), exports);
119
+ __exportStar(require("./dtos/requests/SendEmailOtpRequest"), exports);
120
+ __exportStar(require("./dtos/requests/VerifyEmailOtpRequest"), exports);
118
121
  // Response DTOs (output tipado por endpoint)
119
122
  __exportStar(require("./dtos/responses/KycPrepareResponse"), exports);
120
123
  __exportStar(require("./dtos/responses/ProofOfAddressPrepareResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.528.0",
3
+ "version": "3.529.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -1,5 +1,5 @@
1
1
  import { Expose } from 'class-transformer';
2
- import { IsEmail, IsEnum, IsString } from 'class-validator';
2
+ import { IsBoolean, IsEmail, IsEnum, IsOptional, IsString } from 'class-validator';
3
3
  import { EmailTypeEnum } from '../enums/EmailTypeEnum';
4
4
 
5
5
  /**
@@ -18,4 +18,10 @@ export class EmailSetTrustedRequest {
18
18
  @Expose()
19
19
  @IsEnum(EmailTypeEnum)
20
20
  type!: EmailTypeEnum;
21
+
22
+ /** En true, el correo queda como principal del directorio. Sin el campo, no cambia el principal. */
23
+ @Expose()
24
+ @IsOptional()
25
+ @IsBoolean()
26
+ isPrincipal?: boolean;
21
27
  }
@@ -15,6 +15,8 @@ import type { WizardReservedLine } from './WizardReservedLine';
15
15
  import type { WizardResumeTarget } from './WizardResumeTarget';
16
16
  import type { WizardWelcome } from './WizardWelcome';
17
17
  import type { WizardCreditPromotionBonus } from './WizardCreditPromotionBonus';
18
+ import type { EmailStateEnum } from '../enums/EmailStateEnum';
19
+ import type { EmailTypeEnum } from '../../emailVerification/enums/EmailTypeEnum';
18
20
 
19
21
  /** Modalidad de captura del KYC (M1 §213-329). */
20
22
  export type KycModality = 'CUSTOMER_LINK' | 'STORE_DEVICE' | 'MANUAL';
@@ -68,6 +70,14 @@ export interface WizardSession {
68
70
  */
69
71
  resumeTarget?: WizardResumeTarget | null;
70
72
  consents: WizardConsents | null;
73
+ /** Estado del correo del cliente en el paso 01. Ausente en sesiones anteriores al correo. */
74
+ emailState?: EmailStateEnum;
75
+ /** Tipo del correo: personal o corporativo. */
76
+ emailType?: EmailTypeEnum;
77
+ /** Correo enmascarado (`ju•••••@gmail.com`); viaja siempre que la sesión tenga correo. */
78
+ emailMasked?: string;
79
+ /** Correo completo: solo con `emailState` CAPTURED, porque lo tecleó el vendedor. */
80
+ email?: string;
71
81
  /** Espejo del estado KYC (fuente = customer). */
72
82
  kycStatus: string | null;
73
83
  kycModality: KycModality | null;
@@ -0,0 +1,14 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEmail, IsEnum } from 'class-validator';
3
+ import { EmailTypeEnum } from '../../../emailVerification/enums/EmailTypeEnum';
4
+
5
+ /** POST /wizard/sessions/:id/email/otp/send — manda el código al correo que capturó el vendedor. */
6
+ export class SendEmailOtpRequest {
7
+ @Expose()
8
+ @IsEmail()
9
+ email!: string;
10
+
11
+ @Expose()
12
+ @IsEnum(EmailTypeEnum)
13
+ type!: EmailTypeEnum;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsString, Length } from 'class-validator';
3
+
4
+ /** POST /wizard/sessions/:id/email/otp/verify — verifica el código que llegó al correo. */
5
+ export class VerifyEmailOtpRequest {
6
+ @Expose()
7
+ @IsString()
8
+ @Length(4, 8)
9
+ code!: string;
10
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Correo de la sesión del wizard: EXISTING = ya verificado en contacts; CAPTURED = lo tecleó el
3
+ * vendedor y se verificó con OTP; PENDING = falta capturarlo o verificarlo.
4
+ */
5
+ export enum EmailStateEnum {
6
+ EXISTING = 'EXISTING',
7
+ CAPTURED = 'CAPTURED',
8
+ PENDING = 'PENDING',
9
+ }
@@ -29,6 +29,7 @@ export * from './enums/BlockedCategoryEnum';
29
29
  export * from './enums/WizardLineStatusEnum';
30
30
  export * from './enums/LinePaymentTypeEnum';
31
31
  export * from './enums/WizardLineRoleEnum';
32
+ export * from './enums/EmailStateEnum';
32
33
 
33
34
  // DTOs anidados
34
35
  export * from './dtos/WizardConsents';
@@ -101,6 +102,8 @@ export * from './dtos/requests/SignatureSignRequest';
101
102
  export * from './dtos/requests/RegisterDeviceRequest';
102
103
  export * from './dtos/requests/CompleteSaleRequest';
103
104
  export * from './dtos/requests/SuggestIdentifiersQuery';
105
+ export * from './dtos/requests/SendEmailOtpRequest';
106
+ export * from './dtos/requests/VerifyEmailOtpRequest';
104
107
 
105
108
  // Response DTOs (output tipado por endpoint)
106
109
  export * from './dtos/responses/KycPrepareResponse';