@fiado/type-kit 3.72.0 → 3.74.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.
@@ -2,6 +2,7 @@ import 'reflect-metadata';
2
2
  import { plainToInstance } from 'class-transformer';
3
3
  import { validate } from 'class-validator';
4
4
  import { CreateTenantRequest } from '../../../../src/platformRbac/dtos/CreateTenantRequest';
5
+ import { TenantType } from '../../../../src/platformRbac/tenantTypes';
5
6
 
6
7
  describe('CreateTenantRequest', () => {
7
8
  const valid = {
@@ -53,6 +54,19 @@ describe('CreateTenantRequest', () => {
53
54
  expect(errors.some(e => e.property === 'passwordMinLength')).toBe(true);
54
55
  });
55
56
 
57
+ it('valida con tenantType opcional = agents', async () => {
58
+ const dto = plainToInstance(CreateTenantRequest, { ...valid, tenantType: 'agents' });
59
+ const errors = await validate(dto);
60
+ expect(errors).toEqual([]);
61
+ expect(dto.tenantType).toBe(TenantType.AGENTS);
62
+ });
63
+
64
+ it('falla si tenantType no es un TenantType válido', async () => {
65
+ const dto = plainToInstance(CreateTenantRequest, { ...valid, tenantType: 'inexistente' });
66
+ const errors = await validate(dto);
67
+ expect(errors.some(e => e.property === 'tenantType')).toBe(true);
68
+ });
69
+
56
70
  it('NO expone temporaryPassword en el request (campo del response, no del body)', () => {
57
71
  // El request NO debe llevar temporaryPassword (es solo del response, fallback out-of-band F-11).
58
72
  // Con excludeExtraneousValues solo sobreviven las props @Expose() del DTO → el contrato lo excluye.
@@ -1,4 +1,4 @@
1
- import { TenantType, levelsOf, tableSuffixForLevel, scopeRankOrder } from '../../../src/platformRbac/tenantTypes';
1
+ import { TenantType, TENANT_TYPES, levelsOf, tableSuffixForLevel, scopeRankOrder } from '../../../src/platformRbac/tenantTypes';
2
2
  import { PermissionScope } from '../../../src/platformRbac/enums/PermissionScope';
3
3
 
4
4
  describe('tenantTypes', () => {
@@ -6,12 +6,13 @@ describe('tenantTypes', () => {
6
6
  expect(levelsOf(TenantType.RETAIL)).toEqual([PermissionScope.RETAILER, PermissionScope.STORE]);
7
7
  });
8
8
 
9
- it('scopeRankOrder = [PLATFORM, TENANT, RETAILER, STORE] (retail único tipo hoy)', () => {
9
+ it('scopeRankOrder = [PLATFORM, TENANT, RETAILER, STORE, GROUP] (retail + agents)', () => {
10
10
  expect(scopeRankOrder()).toEqual([
11
11
  PermissionScope.PLATFORM,
12
12
  PermissionScope.TENANT,
13
13
  PermissionScope.RETAILER,
14
14
  PermissionScope.STORE,
15
+ PermissionScope.GROUP,
15
16
  ]);
16
17
  });
17
18
 
@@ -29,4 +30,23 @@ describe('tenantTypes', () => {
29
30
  const order = scopeRankOrder();
30
31
  expect(new Set(order).size).toBe(order.length);
31
32
  });
33
+
34
+ it('agents define un único nivel GROUP debajo de TENANT', () => {
35
+ expect(levelsOf(TenantType.AGENTS)).toEqual([PermissionScope.GROUP]);
36
+ });
37
+
38
+ it('agents mapea GROUP a su sufijo de tabla SharedGroup', () => {
39
+ expect(TENANT_TYPES[TenantType.AGENTS].tableSuffix).toEqual({ [PermissionScope.GROUP]: 'SharedGroup' });
40
+ expect(tableSuffixForLevel(TenantType.AGENTS, PermissionScope.GROUP)).toBe('SharedGroup');
41
+ });
42
+
43
+ it('scopeRankOrder incluye GROUP al final (vía los levels de agents, después de los de retail)', () => {
44
+ expect(scopeRankOrder()).toEqual([
45
+ PermissionScope.PLATFORM,
46
+ PermissionScope.TENANT,
47
+ PermissionScope.RETAILER,
48
+ PermissionScope.STORE,
49
+ PermissionScope.GROUP,
50
+ ]);
51
+ });
32
52
  });
@@ -1,4 +1,5 @@
1
1
  import { TokenValidationMode } from '../enums/TokenValidationMode';
2
+ import { TenantType } from '../tenantTypes';
2
3
  /**
3
4
  * Input del POST backoffice de creación de tenant (F-11 — onboarding de tenant en SureKeep).
4
5
  * Consumido por el controller `backofficeCreateTenant` del platform-rbac-business y, a futuro,
@@ -16,4 +17,6 @@ export declare class CreateTenantRequest {
16
17
  mfaRequired?: boolean;
17
18
  passwordMinLength?: number;
18
19
  tokenValidationMode?: TokenValidationMode;
20
+ /** Tipo de tenant a crear. Si se omite, el onboarding aplica su default (hoy: retail). */
21
+ tenantType?: TenantType;
19
22
  }
@@ -13,6 +13,7 @@ exports.CreateTenantRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const TokenValidationMode_1 = require("../enums/TokenValidationMode");
16
+ const tenantTypes_1 = require("../tenantTypes");
16
17
  /**
17
18
  * Input del POST backoffice de creación de tenant (F-11 — onboarding de tenant en SureKeep).
18
19
  * Consumido por el controller `backofficeCreateTenant` del platform-rbac-business y, a futuro,
@@ -73,3 +74,9 @@ __decorate([
73
74
  (0, class_validator_1.IsEnum)(TokenValidationMode_1.TokenValidationMode),
74
75
  __metadata("design:type", String)
75
76
  ], CreateTenantRequest.prototype, "tokenValidationMode", void 0);
77
+ __decorate([
78
+ (0, class_transformer_1.Expose)(),
79
+ (0, class_validator_1.IsOptional)(),
80
+ (0, class_validator_1.IsEnum)(tenantTypes_1.TenantType),
81
+ __metadata("design:type", String)
82
+ ], CreateTenantRequest.prototype, "tenantType", void 0);
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Jerarquía: PLATFORM > TENANT > RETAILER > STORE.
3
- * Componente 01 spec copia exacta.
2
+ * Jerarquía retail: PLATFORM > TENANT > RETAILER > STORE.
3
+ * Jerarquía agents: PLATFORM > TENANT > GROUP.
4
+ * Componente 01 spec.
4
5
  */
5
6
  export declare enum PermissionScope {
6
7
  PLATFORM = "PLATFORM",
7
8
  TENANT = "TENANT",
8
9
  RETAILER = "RETAILER",
9
- STORE = "STORE"
10
+ STORE = "STORE",
11
+ GROUP = "GROUP"
10
12
  }
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PermissionScope = void 0;
4
4
  /**
5
- * Jerarquía: PLATFORM > TENANT > RETAILER > STORE.
6
- * Componente 01 spec copia exacta.
5
+ * Jerarquía retail: PLATFORM > TENANT > RETAILER > STORE.
6
+ * Jerarquía agents: PLATFORM > TENANT > GROUP.
7
+ * Componente 01 spec.
7
8
  */
8
9
  var PermissionScope;
9
10
  (function (PermissionScope) {
@@ -11,4 +12,5 @@ var PermissionScope;
11
12
  PermissionScope["TENANT"] = "TENANT";
12
13
  PermissionScope["RETAILER"] = "RETAILER";
13
14
  PermissionScope["STORE"] = "STORE";
15
+ PermissionScope["GROUP"] = "GROUP";
14
16
  })(PermissionScope || (exports.PermissionScope = PermissionScope = {}));
@@ -4,7 +4,8 @@ import { PermissionScope } from './enums/PermissionScope';
4
4
  * jerarquía de niveles DEBAJO de TENANT (data-driven). Hoy solo existe `retail`.
5
5
  */
6
6
  export declare enum TenantType {
7
- RETAIL = "retail"
7
+ RETAIL = "retail",
8
+ AGENTS = "agents"
8
9
  }
9
10
  interface TenantTypeDef {
10
11
  displayName: string;
@@ -12,6 +12,7 @@ const PermissionScope_1 = require("./enums/PermissionScope");
12
12
  var TenantType;
13
13
  (function (TenantType) {
14
14
  TenantType["RETAIL"] = "retail";
15
+ TenantType["AGENTS"] = "agents";
15
16
  })(TenantType || (exports.TenantType = TenantType = {}));
16
17
  exports.TENANT_TYPES = {
17
18
  [TenantType.RETAIL]: {
@@ -22,6 +23,12 @@ exports.TENANT_TYPES = {
22
23
  [PermissionScope_1.PermissionScope.STORE]: 'SharedStore',
23
24
  },
24
25
  },
26
+ // Fiado Agents — un único nivel GROUP debajo de TENANT.
27
+ [TenantType.AGENTS]: {
28
+ displayName: 'Agents',
29
+ levels: [PermissionScope_1.PermissionScope.GROUP],
30
+ tableSuffix: { [PermissionScope_1.PermissionScope.GROUP]: 'SharedGroup' },
31
+ },
25
32
  };
26
33
  function levelsOf(type) {
27
34
  return exports.TENANT_TYPES[type].levels;
@@ -1,4 +1,5 @@
1
1
  import { OperationEnum } from "../../transaction";
2
+ import { ProductSubtypeEnum } from "../../productCatalog";
2
3
  export declare class TransactionAlarmQueueMessage {
3
4
  directoryId: string;
4
5
  peopleId: string;
@@ -8,6 +9,7 @@ export declare class TransactionAlarmQueueMessage {
8
9
  phoneNumber: string;
9
10
  transactionDate: string;
10
11
  transactionType: string;
12
+ subType?: ProductSubtypeEnum;
11
13
  id: string;
12
14
  operation: OperationEnum;
13
15
  }
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.TransactionAlarmQueueMessage = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
+ const productCatalog_1 = require("../../productCatalog");
14
15
  class TransactionAlarmQueueMessage {
15
16
  }
16
17
  exports.TransactionAlarmQueueMessage = TransactionAlarmQueueMessage;
@@ -54,6 +55,11 @@ __decorate([
54
55
  (0, class_validator_1.IsNotEmpty)(),
55
56
  __metadata("design:type", String)
56
57
  ], TransactionAlarmQueueMessage.prototype, "transactionType", void 0);
58
+ __decorate([
59
+ (0, class_validator_1.IsString)(),
60
+ (0, class_validator_1.IsOptional)(),
61
+ __metadata("design:type", String)
62
+ ], TransactionAlarmQueueMessage.prototype, "subType", void 0);
57
63
  __decorate([
58
64
  (0, class_validator_1.IsString)(),
59
65
  (0, class_validator_1.IsNotEmpty)(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.72.0",
3
+ "version": "3.74.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -1,6 +1,7 @@
1
1
  import { Expose } from 'class-transformer';
2
2
  import { IsBoolean, IsEmail, IsEnum, IsInt, IsOptional, IsString, Matches, Min } from 'class-validator';
3
3
  import { TokenValidationMode } from '../enums/TokenValidationMode';
4
+ import { TenantType } from '../tenantTypes';
4
5
 
5
6
  /**
6
7
  * Input del POST backoffice de creación de tenant (F-11 — onboarding de tenant en SureKeep).
@@ -19,4 +20,6 @@ export class CreateTenantRequest {
19
20
  @Expose() @IsOptional() @IsBoolean() mfaRequired?: boolean;
20
21
  @Expose() @IsOptional() @IsInt() @Min(8) passwordMinLength?: number;
21
22
  @Expose() @IsOptional() @IsEnum(TokenValidationMode) tokenValidationMode?: TokenValidationMode;
23
+ /** Tipo de tenant a crear. Si se omite, el onboarding aplica su default (hoy: retail). */
24
+ @Expose() @IsOptional() @IsEnum(TenantType) tenantType?: TenantType;
22
25
  }
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Jerarquía: PLATFORM > TENANT > RETAILER > STORE.
3
- * Componente 01 spec copia exacta.
2
+ * Jerarquía retail: PLATFORM > TENANT > RETAILER > STORE.
3
+ * Jerarquía agents: PLATFORM > TENANT > GROUP.
4
+ * Componente 01 spec.
4
5
  */
5
6
  export enum PermissionScope {
6
7
  PLATFORM = 'PLATFORM',
7
8
  TENANT = 'TENANT',
8
9
  RETAILER = 'RETAILER',
9
10
  STORE = 'STORE',
11
+ GROUP = 'GROUP',
10
12
  }
@@ -6,6 +6,7 @@ import { PermissionScope } from './enums/PermissionScope';
6
6
  */
7
7
  export enum TenantType {
8
8
  RETAIL = 'retail',
9
+ AGENTS = 'agents',
9
10
  }
10
11
 
11
12
  interface TenantTypeDef {
@@ -25,6 +26,12 @@ export const TENANT_TYPES: Record<TenantType, TenantTypeDef> = {
25
26
  [PermissionScope.STORE]: 'SharedStore',
26
27
  },
27
28
  },
29
+ // Fiado Agents — un único nivel GROUP debajo de TENANT.
30
+ [TenantType.AGENTS]: {
31
+ displayName: 'Agents',
32
+ levels: [PermissionScope.GROUP],
33
+ tableSuffix: { [PermissionScope.GROUP]: 'SharedGroup' },
34
+ },
28
35
  };
29
36
 
30
37
  export function levelsOf(type: TenantType): PermissionScope[] {
@@ -1,5 +1,6 @@
1
1
  import { IsNotEmpty, IsNumber, IsOptional, IsString } from "class-validator";
2
2
  import { OperationEnum } from "../../transaction";
3
+ import { ProductSubtypeEnum } from "../../productCatalog";
3
4
 
4
5
 
5
6
 
@@ -37,6 +38,10 @@ export class TransactionAlarmQueueMessage {
37
38
  @IsNotEmpty()
38
39
  transactionType: string
39
40
 
41
+ @IsString()
42
+ @IsOptional()
43
+ subType?: ProductSubtypeEnum
44
+
40
45
  @IsString()
41
46
  @IsNotEmpty()
42
47
  id: string