@fiado/type-kit 3.457.0 → 3.458.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.
- package/_test_/unit/emailVerification/dtos/EmailSetTrustedRequest.test.ts +53 -0
- package/_test_/unit/emailVerification/enums/EmailTypeEnum.test.ts +12 -0
- package/bin/emailVerification/dtos/EmailItem.d.ts +2 -0
- package/bin/emailVerification/dtos/EmailItem.js +5 -0
- package/bin/emailVerification/dtos/EmailSetTrustedRequest.d.ts +10 -0
- package/bin/emailVerification/dtos/EmailSetTrustedRequest.js +37 -0
- package/bin/emailVerification/dtos/EmailSetTrustedResponse.d.ts +9 -0
- package/bin/emailVerification/dtos/EmailSetTrustedResponse.js +32 -0
- package/bin/emailVerification/enums/EmailTypeEnum.d.ts +9 -0
- package/bin/emailVerification/enums/EmailTypeEnum.js +13 -0
- package/bin/emailVerification/index.d.ts +3 -0
- package/bin/emailVerification/index.js +3 -0
- package/package.json +1 -1
- package/src/emailVerification/dtos/EmailItem.ts +4 -0
- package/src/emailVerification/dtos/EmailSetTrustedRequest.ts +21 -0
- package/src/emailVerification/dtos/EmailSetTrustedResponse.ts +16 -0
- package/src/emailVerification/enums/EmailTypeEnum.ts +9 -0
- package/src/emailVerification/index.ts +3 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { plainToInstance } from 'class-transformer';
|
|
3
|
+
import { validate } from 'class-validator';
|
|
4
|
+
import { EmailSetTrustedRequest } from '../../../../src/emailVerification/dtos/EmailSetTrustedRequest';
|
|
5
|
+
import { EmailTypeEnum } from '../../../../src/emailVerification/enums/EmailTypeEnum';
|
|
6
|
+
|
|
7
|
+
describe('EmailSetTrustedRequest', () => {
|
|
8
|
+
const valid = {
|
|
9
|
+
directoryId: '01890000-0000-7000-8000-000000000000',
|
|
10
|
+
email: 'user@acme.com',
|
|
11
|
+
type: EmailTypeEnum.CORPORATE,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
it('valida happy path (0 errores)', async () => {
|
|
15
|
+
const dto = plainToInstance(EmailSetTrustedRequest, valid);
|
|
16
|
+
const errors = await validate(dto);
|
|
17
|
+
expect(errors).toEqual([]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('falla si directoryId no es string', async () => {
|
|
21
|
+
const dto = plainToInstance(EmailSetTrustedRequest, {
|
|
22
|
+
...valid,
|
|
23
|
+
directoryId: 12345 as unknown as string,
|
|
24
|
+
});
|
|
25
|
+
const errors = await validate(dto);
|
|
26
|
+
expect(errors.some(e => e.property === 'directoryId')).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('falla si email no es un email válido', async () => {
|
|
30
|
+
const dto = plainToInstance(EmailSetTrustedRequest, {
|
|
31
|
+
...valid,
|
|
32
|
+
email: 'no-es-email',
|
|
33
|
+
});
|
|
34
|
+
const errors = await validate(dto);
|
|
35
|
+
expect(errors.some(e => e.property === 'email')).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('falla si type no es uno de los valores del enum', async () => {
|
|
39
|
+
const dto = plainToInstance(EmailSetTrustedRequest, {
|
|
40
|
+
...valid,
|
|
41
|
+
type: 'WORK' as unknown as EmailTypeEnum,
|
|
42
|
+
});
|
|
43
|
+
const errors = await validate(dto);
|
|
44
|
+
expect(errors.some(e => e.property === 'type')).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('falla si type falta', async () => {
|
|
48
|
+
const { type, ...rest } = valid;
|
|
49
|
+
const dto = plainToInstance(EmailSetTrustedRequest, rest);
|
|
50
|
+
const errors = await validate(dto);
|
|
51
|
+
expect(errors.some(e => e.property === 'type')).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EmailTypeEnum } from '../../../../src/emailVerification/enums/EmailTypeEnum';
|
|
2
|
+
|
|
3
|
+
describe('EmailTypeEnum', () => {
|
|
4
|
+
it('contiene exactamente los 2 tipos del contrato con value === key', () => {
|
|
5
|
+
expect(EmailTypeEnum.PERSONAL).toBe('PERSONAL');
|
|
6
|
+
expect(EmailTypeEnum.CORPORATE).toBe('CORPORATE');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('no tiene tipos de más', () => {
|
|
10
|
+
expect(Object.values(EmailTypeEnum).sort()).toEqual(['CORPORATE', 'PERSONAL']);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EmailVerificationStatusEnum } from '../enums/EmailVerificationStatusEnum';
|
|
2
2
|
import { EmailLinkExpirationReasonEnum } from '../enums/EmailLinkExpirationReasonEnum';
|
|
3
|
+
import { EmailTypeEnum } from '../enums/EmailTypeEnum';
|
|
3
4
|
/**
|
|
4
5
|
* Item de email asociado a un directorio. Se reutiliza en EmailListResponse
|
|
5
6
|
* (público) y en EmailsByDirectoryResponse (interno).
|
|
@@ -9,6 +10,7 @@ export declare class EmailItem {
|
|
|
9
10
|
isVerified: boolean;
|
|
10
11
|
isPrincipal: boolean;
|
|
11
12
|
status: EmailVerificationStatusEnum;
|
|
13
|
+
type: EmailTypeEnum;
|
|
12
14
|
verifiedAt?: number;
|
|
13
15
|
/** Solo presente cuando status === EXPIRED. */
|
|
14
16
|
expirationReason?: EmailLinkExpirationReasonEnum;
|
|
@@ -13,6 +13,7 @@ exports.EmailItem = void 0;
|
|
|
13
13
|
const class_transformer_1 = require("class-transformer");
|
|
14
14
|
const EmailVerificationStatusEnum_1 = require("../enums/EmailVerificationStatusEnum");
|
|
15
15
|
const EmailLinkExpirationReasonEnum_1 = require("../enums/EmailLinkExpirationReasonEnum");
|
|
16
|
+
const EmailTypeEnum_1 = require("../enums/EmailTypeEnum");
|
|
16
17
|
/**
|
|
17
18
|
* Item de email asociado a un directorio. Se reutiliza en EmailListResponse
|
|
18
19
|
* (público) y en EmailsByDirectoryResponse (interno).
|
|
@@ -36,6 +37,10 @@ __decorate([
|
|
|
36
37
|
(0, class_transformer_1.Expose)(),
|
|
37
38
|
__metadata("design:type", String)
|
|
38
39
|
], EmailItem.prototype, "status", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, class_transformer_1.Expose)(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], EmailItem.prototype, "type", void 0);
|
|
39
44
|
__decorate([
|
|
40
45
|
(0, class_transformer_1.Expose)(),
|
|
41
46
|
__metadata("design:type", Number)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EmailTypeEnum } from '../enums/EmailTypeEnum';
|
|
2
|
+
/**
|
|
3
|
+
* Body para registrar un correo como confiable (backoffice): se guarda ya
|
|
4
|
+
* verificado, sin mandar el link de verificación.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EmailSetTrustedRequest {
|
|
7
|
+
directoryId: string;
|
|
8
|
+
email: string;
|
|
9
|
+
type: EmailTypeEnum;
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.EmailSetTrustedRequest = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const EmailTypeEnum_1 = require("../enums/EmailTypeEnum");
|
|
16
|
+
/**
|
|
17
|
+
* Body para registrar un correo como confiable (backoffice): se guarda ya
|
|
18
|
+
* verificado, sin mandar el link de verificación.
|
|
19
|
+
*/
|
|
20
|
+
class EmailSetTrustedRequest {
|
|
21
|
+
}
|
|
22
|
+
exports.EmailSetTrustedRequest = EmailSetTrustedRequest;
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, class_transformer_1.Expose)(),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], EmailSetTrustedRequest.prototype, "directoryId", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, class_transformer_1.Expose)(),
|
|
30
|
+
(0, class_validator_1.IsEmail)(),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], EmailSetTrustedRequest.prototype, "email", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, class_transformer_1.Expose)(),
|
|
35
|
+
(0, class_validator_1.IsEnum)(EmailTypeEnum_1.EmailTypeEnum),
|
|
36
|
+
__metadata("design:type", String)
|
|
37
|
+
], EmailSetTrustedRequest.prototype, "type", void 0);
|
|
@@ -0,0 +1,32 @@
|
|
|
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.EmailSetTrustedResponse = void 0;
|
|
13
|
+
const class_transformer_1 = require("class-transformer");
|
|
14
|
+
const EmailTypeEnum_1 = require("../enums/EmailTypeEnum");
|
|
15
|
+
/**
|
|
16
|
+
* Respuesta al registrar un correo como confiable.
|
|
17
|
+
*/
|
|
18
|
+
class EmailSetTrustedResponse {
|
|
19
|
+
}
|
|
20
|
+
exports.EmailSetTrustedResponse = EmailSetTrustedResponse;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, class_transformer_1.Expose)(),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], EmailSetTrustedResponse.prototype, "email", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, class_transformer_1.Expose)(),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], EmailSetTrustedResponse.prototype, "type", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, class_transformer_1.Expose)(),
|
|
31
|
+
__metadata("design:type", Boolean)
|
|
32
|
+
], EmailSetTrustedResponse.prototype, "isVerified", void 0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailTypeEnum = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Origen del correo asociado a un directorio.
|
|
6
|
+
* PERSONAL: correo particular del titular.
|
|
7
|
+
* CORPORATE: correo institucional/empresarial del titular.
|
|
8
|
+
*/
|
|
9
|
+
var EmailTypeEnum;
|
|
10
|
+
(function (EmailTypeEnum) {
|
|
11
|
+
EmailTypeEnum["PERSONAL"] = "PERSONAL";
|
|
12
|
+
EmailTypeEnum["CORPORATE"] = "CORPORATE";
|
|
13
|
+
})(EmailTypeEnum || (exports.EmailTypeEnum = EmailTypeEnum = {}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './enums/EmailVerificationStatusEnum';
|
|
2
2
|
export * from './enums/EmailLinkExpirationReasonEnum';
|
|
3
|
+
export * from './enums/EmailTypeEnum';
|
|
3
4
|
export * from './dtos/EmailVerificationStartRequest';
|
|
4
5
|
export * from './dtos/EmailVerificationStartResponse';
|
|
5
6
|
export * from './dtos/EmailVerificationResendRequest';
|
|
@@ -10,6 +11,8 @@ export * from './dtos/EmailItem';
|
|
|
10
11
|
export * from './dtos/EmailListResponse';
|
|
11
12
|
export * from './dtos/EmailSetPrincipalRequest';
|
|
12
13
|
export * from './dtos/EmailSetPrincipalResponse';
|
|
14
|
+
export * from './dtos/EmailSetTrustedRequest';
|
|
15
|
+
export * from './dtos/EmailSetTrustedResponse';
|
|
13
16
|
export * from './dtos/EmailDeleteRequest';
|
|
14
17
|
export * from './dtos/EmailDeleteResponse';
|
|
15
18
|
export * from './dtos/EmailConfirmRequest';
|
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./enums/EmailVerificationStatusEnum"), exports);
|
|
18
18
|
__exportStar(require("./enums/EmailLinkExpirationReasonEnum"), exports);
|
|
19
|
+
__exportStar(require("./enums/EmailTypeEnum"), exports);
|
|
19
20
|
__exportStar(require("./dtos/EmailVerificationStartRequest"), exports);
|
|
20
21
|
__exportStar(require("./dtos/EmailVerificationStartResponse"), exports);
|
|
21
22
|
__exportStar(require("./dtos/EmailVerificationResendRequest"), exports);
|
|
@@ -26,6 +27,8 @@ __exportStar(require("./dtos/EmailItem"), exports);
|
|
|
26
27
|
__exportStar(require("./dtos/EmailListResponse"), exports);
|
|
27
28
|
__exportStar(require("./dtos/EmailSetPrincipalRequest"), exports);
|
|
28
29
|
__exportStar(require("./dtos/EmailSetPrincipalResponse"), exports);
|
|
30
|
+
__exportStar(require("./dtos/EmailSetTrustedRequest"), exports);
|
|
31
|
+
__exportStar(require("./dtos/EmailSetTrustedResponse"), exports);
|
|
29
32
|
__exportStar(require("./dtos/EmailDeleteRequest"), exports);
|
|
30
33
|
__exportStar(require("./dtos/EmailDeleteResponse"), exports);
|
|
31
34
|
__exportStar(require("./dtos/EmailConfirmRequest"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Expose } from 'class-transformer';
|
|
2
2
|
import { EmailVerificationStatusEnum } from '../enums/EmailVerificationStatusEnum';
|
|
3
3
|
import { EmailLinkExpirationReasonEnum } from '../enums/EmailLinkExpirationReasonEnum';
|
|
4
|
+
import { EmailTypeEnum } from '../enums/EmailTypeEnum';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Item de email asociado a un directorio. Se reutiliza en EmailListResponse
|
|
@@ -19,6 +20,9 @@ export class EmailItem {
|
|
|
19
20
|
@Expose()
|
|
20
21
|
status!: EmailVerificationStatusEnum;
|
|
21
22
|
|
|
23
|
+
@Expose()
|
|
24
|
+
type!: EmailTypeEnum;
|
|
25
|
+
|
|
22
26
|
@Expose()
|
|
23
27
|
verifiedAt?: number;
|
|
24
28
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Expose } from 'class-transformer';
|
|
2
|
+
import { IsEmail, IsEnum, IsString } from 'class-validator';
|
|
3
|
+
import { EmailTypeEnum } from '../enums/EmailTypeEnum';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Body para registrar un correo como confiable (backoffice): se guarda ya
|
|
7
|
+
* verificado, sin mandar el link de verificación.
|
|
8
|
+
*/
|
|
9
|
+
export class EmailSetTrustedRequest {
|
|
10
|
+
@Expose()
|
|
11
|
+
@IsString()
|
|
12
|
+
directoryId!: string;
|
|
13
|
+
|
|
14
|
+
@Expose()
|
|
15
|
+
@IsEmail()
|
|
16
|
+
email!: string;
|
|
17
|
+
|
|
18
|
+
@Expose()
|
|
19
|
+
@IsEnum(EmailTypeEnum)
|
|
20
|
+
type!: EmailTypeEnum;
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Expose } from 'class-transformer';
|
|
2
|
+
import { EmailTypeEnum } from '../enums/EmailTypeEnum';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Respuesta al registrar un correo como confiable.
|
|
6
|
+
*/
|
|
7
|
+
export class EmailSetTrustedResponse {
|
|
8
|
+
@Expose()
|
|
9
|
+
email!: string;
|
|
10
|
+
|
|
11
|
+
@Expose()
|
|
12
|
+
type!: EmailTypeEnum;
|
|
13
|
+
|
|
14
|
+
@Expose()
|
|
15
|
+
isVerified!: boolean;
|
|
16
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './enums/EmailVerificationStatusEnum';
|
|
2
2
|
export * from './enums/EmailLinkExpirationReasonEnum';
|
|
3
|
+
export * from './enums/EmailTypeEnum';
|
|
3
4
|
export * from './dtos/EmailVerificationStartRequest';
|
|
4
5
|
export * from './dtos/EmailVerificationStartResponse';
|
|
5
6
|
export * from './dtos/EmailVerificationResendRequest';
|
|
@@ -10,6 +11,8 @@ export * from './dtos/EmailItem';
|
|
|
10
11
|
export * from './dtos/EmailListResponse';
|
|
11
12
|
export * from './dtos/EmailSetPrincipalRequest';
|
|
12
13
|
export * from './dtos/EmailSetPrincipalResponse';
|
|
14
|
+
export * from './dtos/EmailSetTrustedRequest';
|
|
15
|
+
export * from './dtos/EmailSetTrustedResponse';
|
|
13
16
|
export * from './dtos/EmailDeleteRequest';
|
|
14
17
|
export * from './dtos/EmailDeleteResponse';
|
|
15
18
|
export * from './dtos/EmailConfirmRequest';
|