@fiado/type-kit 3.515.0 → 3.516.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.
@@ -0,0 +1,32 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import { GroupCreateRequest, GroupResponse, GroupStatus } from '../../../src/group';
5
+
6
+ const base = { id: 'TAXMA', name: 'Taxma', status: GroupStatus.ACTIVE };
7
+
8
+ describe('GroupCreateRequest.ownerDirectoryId', () => {
9
+ it('es opcional (la carga masiva por CSV no lo manda)', async () => {
10
+ expect(await validate(plainToInstance(GroupCreateRequest, base))).toEqual([]);
11
+ });
12
+ it('acepta un uuid v4', async () => {
13
+ const dto = plainToInstance(GroupCreateRequest, { ...base, ownerDirectoryId: 'b298ec6b-00b6-487b-b096-f4ac6ac8c91d' });
14
+ expect(await validate(dto)).toEqual([]);
15
+ });
16
+ it('rechaza lo que no es uuid v4', async () => {
17
+ const errors = await validate(plainToInstance(GroupCreateRequest, { ...base, ownerDirectoryId: 'no-es-uuid' }));
18
+ expect(errors[0].property).toBe('ownerDirectoryId');
19
+ expect(errors[0].constraints?.isUuid).toBeDefined();
20
+ });
21
+ });
22
+
23
+ describe('GroupResponse.owner', () => {
24
+ it('admite owner o null', () => {
25
+ const withOwner: Partial<GroupResponse> = {
26
+ owner: { agentId: 'AG-1', directoryId: 'DIR-1', name: null, email: null, status: 'ACTIVE' },
27
+ };
28
+ const withoutOwner: Partial<GroupResponse> = { owner: null };
29
+ expect(withOwner.owner?.agentId).toBe('AG-1');
30
+ expect(withoutOwner.owner).toBeNull();
31
+ });
32
+ });
@@ -0,0 +1,46 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import {
5
+ GroupOwnersByGroupIdsRequest,
6
+ GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH,
7
+ } from '../../../src/referral-business';
8
+ import type { GroupOwnerItem, GroupOwnersByGroupIdsResponse } from '../../../src/referral-business';
9
+
10
+ describe('GroupOwnersByGroupIdsRequest', () => {
11
+ it('el tope del lote es 100', () => {
12
+ expect(GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH).toBe(100);
13
+ });
14
+ it('acepta una lista de groupIds', async () => {
15
+ const dto = plainToInstance(GroupOwnersByGroupIdsRequest, { groupIds: ['FIADO', 'TAXMA'] });
16
+ expect(await validate(dto)).toEqual([]);
17
+ });
18
+ it('acepta la lista vacía', async () => {
19
+ const dto = plainToInstance(GroupOwnersByGroupIdsRequest, { groupIds: [] });
20
+ expect(await validate(dto)).toEqual([]);
21
+ });
22
+ it('rechaza 101 ids con arrayMaxSize', async () => {
23
+ const ids = Array.from({ length: 101 }, (_, i) => `G${i}`);
24
+ const errors = await validate(plainToInstance(GroupOwnersByGroupIdsRequest, { groupIds: ids }));
25
+ expect(errors[0].property).toBe('groupIds');
26
+ expect(errors[0].constraints?.arrayMaxSize).toBeDefined();
27
+ });
28
+ it('rechaza si groupIds no es arreglo', async () => {
29
+ const errors = await validate(plainToInstance(GroupOwnersByGroupIdsRequest, { groupIds: 'FIADO' }));
30
+ expect(errors[0].constraints?.isArray).toBeDefined();
31
+ });
32
+ it('rechaza elementos que no son string', async () => {
33
+ const errors = await validate(plainToInstance(GroupOwnersByGroupIdsRequest, { groupIds: [1] }));
34
+ expect(errors[0].constraints?.isString).toBeDefined();
35
+ });
36
+ });
37
+
38
+ describe('GroupOwnersByGroupIdsResponse', () => {
39
+ it('es un mapa groupId → GroupOwnerItem', () => {
40
+ const owner: GroupOwnerItem = {
41
+ agentId: 'AG-1', directoryId: 'DIR-1', name: 'MARIA DAVALOS', email: 'm@taxma.com', status: 'ACTIVE',
42
+ };
43
+ const res: GroupOwnersByGroupIdsResponse = { TAXMA: owner };
44
+ expect(res.TAXMA.directoryId).toBe('DIR-1');
45
+ });
46
+ });
@@ -5,6 +5,7 @@ export declare class GroupCreateRequest {
5
5
  description: string;
6
6
  leaderEmail?: string | null;
7
7
  leaderDirectoryId?: string | null;
8
+ ownerDirectoryId?: string;
8
9
  status: GroupStatus;
9
10
  codeToRefer?: Array<string>;
10
11
  uniqueMainDirectory?: string;
@@ -44,6 +44,11 @@ __decorate([
44
44
  (0, class_transformer_1.Transform)(({ value }) => value ?? null),
45
45
  __metadata("design:type", String)
46
46
  ], GroupCreateRequest.prototype, "leaderDirectoryId", void 0);
47
+ __decorate([
48
+ (0, class_validator_1.IsOptional)(),
49
+ (0, class_validator_1.IsUUID)('4'),
50
+ __metadata("design:type", String)
51
+ ], GroupCreateRequest.prototype, "ownerDirectoryId", void 0);
47
52
  __decorate([
48
53
  (0, class_validator_1.IsEnum)(GroupStatus_1.GroupStatus),
49
54
  __metadata("design:type", String)
@@ -1,4 +1,5 @@
1
1
  import { GroupStatus } from "../enums/GroupStatus";
2
+ import type { GroupOwnerItem } from "../../referral-business/dtos/GroupOwnersByGroupIdsResponse";
2
3
  export declare class GroupResponse {
3
4
  id: string;
4
5
  name: string;
@@ -15,4 +16,5 @@ export declare class GroupResponse {
15
16
  imageUrl?: string | null;
16
17
  imageUrlSigned?: string | null;
17
18
  parentGroupId: string;
19
+ owner?: GroupOwnerItem | null;
18
20
  }
@@ -0,0 +1,4 @@
1
+ export declare const GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH = 100;
2
+ export declare class GroupOwnersByGroupIdsRequest {
3
+ groupIds: string[];
4
+ }
@@ -0,0 +1,25 @@
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.GroupOwnersByGroupIdsRequest = exports.GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ // Tope de groupIds por request del endpoint batch de owners de grupo.
15
+ exports.GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH = 100;
16
+ // Body de POST /private/agents/owners/by-group-ids; la lista vacía es válida y responde {}.
17
+ class GroupOwnersByGroupIdsRequest {
18
+ }
19
+ exports.GroupOwnersByGroupIdsRequest = GroupOwnersByGroupIdsRequest;
20
+ __decorate([
21
+ (0, class_validator_1.IsArray)(),
22
+ (0, class_validator_1.ArrayMaxSize)(exports.GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH),
23
+ (0, class_validator_1.IsString)({ each: true }),
24
+ __metadata("design:type", Array)
25
+ ], GroupOwnersByGroupIdsRequest.prototype, "groupIds", void 0);
@@ -0,0 +1,8 @@
1
+ export interface GroupOwnerItem {
2
+ agentId: string;
3
+ directoryId: string;
4
+ name: string | null;
5
+ email: string | null;
6
+ status: string;
7
+ }
8
+ export type GroupOwnersByGroupIdsResponse = Record<string, GroupOwnerItem>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,5 @@
1
1
  export * from './enums/AgentRoleEnum';
2
2
  export * from './dtos/AgentsByDirectoryIdsRequest';
3
3
  export * from './dtos/AgentsByDirectoryIdsResponse';
4
+ export * from './dtos/GroupOwnersByGroupIdsRequest';
5
+ export * from './dtos/GroupOwnersByGroupIdsResponse';
@@ -19,3 +19,5 @@ __exportStar(require("./enums/AgentRoleEnum"), exports);
19
19
  //dtos
20
20
  __exportStar(require("./dtos/AgentsByDirectoryIdsRequest"), exports);
21
21
  __exportStar(require("./dtos/AgentsByDirectoryIdsResponse"), exports);
22
+ __exportStar(require("./dtos/GroupOwnersByGroupIdsRequest"), exports);
23
+ __exportStar(require("./dtos/GroupOwnersByGroupIdsResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.515.0",
3
+ "version": "3.516.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -1,4 +1,4 @@
1
- import {IsEnum, IsNotEmpty, IsOptional, IsString, Length} from "class-validator";
1
+ import {IsEnum, IsNotEmpty, IsOptional, IsString, IsUUID, Length} from "class-validator";
2
2
  import {Transform} from "class-transformer";
3
3
  import {GroupStatus} from "../enums/GroupStatus";
4
4
 
@@ -26,6 +26,12 @@ export class GroupCreateRequest {
26
26
  @Transform(({value}) => value ?? null)
27
27
  leaderDirectoryId?: string | null;
28
28
 
29
+ // Directorio que será el agente OWNER_<grupo>. Opcional en el DTO porque la carga por CSV no lo trae;
30
+ // el alta del backoffice lo exige en el controller de group-business.
31
+ @IsOptional()
32
+ @IsUUID('4')
33
+ ownerDirectoryId?: string;
34
+
29
35
  @IsEnum(GroupStatus)
30
36
  status: GroupStatus;
31
37
 
@@ -1,4 +1,5 @@
1
1
  import { GroupStatus } from "../enums/GroupStatus"
2
+ import type { GroupOwnerItem } from "../../referral-business/dtos/GroupOwnersByGroupIdsResponse"
2
3
 
3
4
 
4
5
  export class GroupResponse {
@@ -17,6 +18,9 @@ export class GroupResponse {
17
18
  imageUrl?: string | null
18
19
  imageUrlSigned?: string | null
19
20
  parentGroupId: string
21
+ // Agente OWNER_<grupo> resuelto en vivo desde referral-business. null = sin owner o no se pudo resolver;
22
+ // ausente = la lectura no lo pidió. Reemplaza a leaderNames/leaderEmail/leaderDirectoryId (ya no se escriben).
23
+ owner?: GroupOwnerItem | null
20
24
  }
21
25
 
22
26
 
@@ -0,0 +1,12 @@
1
+ import { ArrayMaxSize, IsArray, IsString } from "class-validator";
2
+
3
+ // Tope de groupIds por request del endpoint batch de owners de grupo.
4
+ export const GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH = 100;
5
+
6
+ // Body de POST /private/agents/owners/by-group-ids; la lista vacía es válida y responde {}.
7
+ export class GroupOwnersByGroupIdsRequest {
8
+ @IsArray()
9
+ @ArrayMaxSize(GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH)
10
+ @IsString({ each: true })
11
+ groupIds!: string[];
12
+ }
@@ -0,0 +1,11 @@
1
+ // Agente OWNER_<grupo> de Agents_GT (excluye DELETE; ACTIVE gana). name/email null si no se pudieron resolver.
2
+ export interface GroupOwnerItem {
3
+ agentId: string;
4
+ directoryId: string;
5
+ name: string | null;
6
+ email: string | null;
7
+ status: string;
8
+ }
9
+
10
+ // Respuesta de POST /private/agents/owners/by-group-ids; un grupo sin owner no aparece.
11
+ export type GroupOwnersByGroupIdsResponse = Record<string, GroupOwnerItem>;
@@ -4,3 +4,5 @@ export * from './enums/AgentRoleEnum';
4
4
  //dtos
5
5
  export * from './dtos/AgentsByDirectoryIdsRequest';
6
6
  export * from './dtos/AgentsByDirectoryIdsResponse';
7
+ export * from './dtos/GroupOwnersByGroupIdsRequest';
8
+ export * from './dtos/GroupOwnersByGroupIdsResponse';