@fiado/type-kit 3.666.0 → 3.668.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/platformRbac/customerAccountDtos.test.ts +20 -10
- package/bin/platformRbac/dtos/EnsureCustomerAccountRequest.d.ts +0 -2
- package/bin/platformRbac/dtos/EnsureCustomerAccountRequest.js +0 -6
- package/bin/platformRbac/dtos/EnsureCustomerAccountResponse.d.ts +6 -2
- package/bin/platformRbac/dtos/UserProfileResponse.d.ts +0 -2
- package/package.json +1 -1
- package/src/platformRbac/dtos/EnsureCustomerAccountRequest.ts +0 -2
- package/src/platformRbac/dtos/EnsureCustomerAccountResponse.ts +7 -2
- package/src/platformRbac/dtos/UserProfileResponse.ts +0 -2
|
@@ -5,12 +5,12 @@ import { PlatformRbac } from '../../../src/index';
|
|
|
5
5
|
import { EnsureCustomerAccountRequest } from '../../../src/platformRbac/dtos/EnsureCustomerAccountRequest';
|
|
6
6
|
import type { EnsureCustomerAccountResponse } from '../../../src/platformRbac/dtos/EnsureCustomerAccountResponse';
|
|
7
7
|
import { OtpLoginRequest } from '../../../src/platformRbac/dtos/OtpLoginRequest';
|
|
8
|
+
import type { TenantUserOutcomeValue } from '../../../src/platformRbac/dtos/CreateTenantUserResponse';
|
|
8
9
|
import type { UserProfileResponse } from '../../../src/platformRbac/dtos/UserProfileResponse';
|
|
9
10
|
|
|
10
11
|
const BODY = {
|
|
11
12
|
phone: '+525512345678',
|
|
12
13
|
displayName: 'Ana Pérez',
|
|
13
|
-
externalId: 'customer-1',
|
|
14
14
|
createdBy: 'wizard',
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -38,12 +38,14 @@ describe('EnsureCustomerAccountRequest', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
it('ya no expone los campos de SureKeep', () => {
|
|
41
|
-
const
|
|
41
|
+
const extra = { ...BODY, retailCustomerId: 'c', directoryId: 'd', externalId: 'e' };
|
|
42
|
+
const request = plainToInstance(EnsureCustomerAccountRequest, extra, { excludeExtraneousValues: true });
|
|
42
43
|
expect(request).not.toHaveProperty('retailCustomerId');
|
|
43
44
|
expect(request).not.toHaveProperty('directoryId');
|
|
45
|
+
expect(request).not.toHaveProperty('externalId');
|
|
44
46
|
});
|
|
45
47
|
|
|
46
|
-
it.each(['
|
|
48
|
+
it.each(['displayName', 'createdBy'])('exige %s', async (field) => {
|
|
47
49
|
expect(await propertiesWithError({ ...BODY, [field]: '' })).toEqual([field]);
|
|
48
50
|
});
|
|
49
51
|
|
|
@@ -86,17 +88,25 @@ describe('OtpLoginRequest', () => {
|
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
describe('EnsureCustomerAccountResponse', () => {
|
|
89
|
-
it.each(['CREATED', '
|
|
90
|
-
const response: EnsureCustomerAccountResponse = {
|
|
91
|
+
it.each(['CREATED', 'ADOPTED'] as const)('admite outcome %s', (outcome) => {
|
|
92
|
+
const response: EnsureCustomerAccountResponse = { cognitoSub: 'sub-1', status: 'ACTIVE', rolesAssigned: ['role-1'], outcome };
|
|
91
93
|
expect(response.outcome).toBe(outcome);
|
|
92
94
|
});
|
|
95
|
+
|
|
96
|
+
it('comparte el desenlace con el alta normal de RBAC', () => {
|
|
97
|
+
const outcome: TenantUserOutcomeValue = 'ADOPTED';
|
|
98
|
+
const response: EnsureCustomerAccountResponse = { cognitoSub: 'sub-1', status: 'ACTIVE', rolesAssigned: [], outcome };
|
|
99
|
+
expect(response.outcome).toBe('ADOPTED');
|
|
100
|
+
});
|
|
93
101
|
});
|
|
94
102
|
|
|
95
103
|
describe('UserProfileResponse', () => {
|
|
96
|
-
it('
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
expect
|
|
104
|
+
it('no trae los datos del cliente de SureKeep', () => {
|
|
105
|
+
const profile: UserProfileResponse = { cognitoSub: 's', tenantId: 't' };
|
|
106
|
+
// @ts-expect-error retailCustomerId ya no es parte del perfil
|
|
107
|
+
const withRetail: UserProfileResponse = { cognitoSub: 's', tenantId: 't', retailCustomerId: 'c' };
|
|
108
|
+
// @ts-expect-error directoryId ya no es parte del perfil
|
|
109
|
+
const withDirectory: UserProfileResponse = { cognitoSub: 's', tenantId: 't', directoryId: 'd' };
|
|
110
|
+
expect([profile, withRetail, withDirectory]).toHaveLength(3);
|
|
101
111
|
});
|
|
102
112
|
});
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
export declare class EnsureCustomerAccountRequest {
|
|
3
3
|
phone: string;
|
|
4
4
|
displayName: string;
|
|
5
|
-
/** Identificador del cliente en el sistema que llama; RBAC lo usa para no duplicar la cuenta. */
|
|
6
|
-
externalId: string;
|
|
7
5
|
/** Campos declarados por la aplicación; RBAC los valida contra su catálogo. */
|
|
8
6
|
customFields?: Record<string, string>;
|
|
9
7
|
/** Si falta, RBAC asigna el rol con el permiso del portal. */
|
|
@@ -30,12 +30,6 @@ __decorate([
|
|
|
30
30
|
(0, class_validator_1.IsNotEmpty)(),
|
|
31
31
|
__metadata("design:type", String)
|
|
32
32
|
], EnsureCustomerAccountRequest.prototype, "displayName", void 0);
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, class_transformer_1.Expose)(),
|
|
35
|
-
(0, class_validator_1.IsString)(),
|
|
36
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
37
|
-
__metadata("design:type", String)
|
|
38
|
-
], EnsureCustomerAccountRequest.prototype, "externalId", void 0);
|
|
39
33
|
__decorate([
|
|
40
34
|
(0, class_transformer_1.Expose)(),
|
|
41
35
|
(0, class_validator_1.IsOptional)(),
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TenantUserOutcomeValue } from './CreateTenantUserResponse';
|
|
2
|
+
import type { TenantUserStatusValue } from './TenantUserResponse';
|
|
3
|
+
/** Respuesta de POST /internal/tenants/{tenantId}/customer-accounts; misma forma que el alta normal sin correo ni contraseña. */
|
|
2
4
|
export interface EnsureCustomerAccountResponse {
|
|
3
|
-
outcome: 'CREATED' | 'EXISTING';
|
|
4
5
|
cognitoSub: string;
|
|
6
|
+
status: TenantUserStatusValue;
|
|
7
|
+
rolesAssigned: string[];
|
|
8
|
+
outcome: TenantUserOutcomeValue;
|
|
5
9
|
}
|
package/package.json
CHANGED
|
@@ -7,8 +7,6 @@ import { IsStringValueRecord } from '../../common/validators/IsStringValueRecord
|
|
|
7
7
|
export class EnsureCustomerAccountRequest {
|
|
8
8
|
@Expose() @IsString() @Matches(PHONE_E164_PATTERN) phone!: string;
|
|
9
9
|
@Expose() @IsString() @IsNotEmpty() displayName!: string;
|
|
10
|
-
/** Identificador del cliente en el sistema que llama; RBAC lo usa para no duplicar la cuenta. */
|
|
11
|
-
@Expose() @IsString() @IsNotEmpty() externalId!: string;
|
|
12
10
|
/** Campos declarados por la aplicación; RBAC los valida contra su catálogo. */
|
|
13
11
|
@Expose()
|
|
14
12
|
@IsOptional()
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TenantUserOutcomeValue } from './CreateTenantUserResponse';
|
|
2
|
+
import type { TenantUserStatusValue } from './TenantUserResponse';
|
|
3
|
+
|
|
4
|
+
/** Respuesta de POST /internal/tenants/{tenantId}/customer-accounts; misma forma que el alta normal sin correo ni contraseña. */
|
|
2
5
|
export interface EnsureCustomerAccountResponse {
|
|
3
|
-
outcome: 'CREATED' | 'EXISTING';
|
|
4
6
|
cognitoSub: string;
|
|
7
|
+
status: TenantUserStatusValue;
|
|
8
|
+
rolesAssigned: string[];
|
|
9
|
+
outcome: TenantUserOutcomeValue;
|
|
5
10
|
}
|