@fiado/type-kit 3.18.0 → 3.19.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.
@@ -16,5 +16,11 @@ export declare class BenefitCreateRequest {
16
16
  flow: BenefitFlowEnum;
17
17
  translationKey?: string;
18
18
  moduleConfig: BenefitModuleConfigRequest;
19
- rulesVisibility: Record<string, unknown>;
19
+ /**
20
+ * Reglas de visibilidad. `null` se acepta como "beneficio público"
21
+ * (visible a todos los usuarios); `undefined` también — el backend
22
+ * normaliza ambos a "sin regla". Si se envía un objeto, debe pasar
23
+ * la validación del VisibilityRulesValidator.
24
+ */
25
+ rulesVisibility?: Record<string, unknown> | null;
20
26
  }
@@ -68,6 +68,7 @@ __decorate([
68
68
  __metadata("design:type", BenefitModuleConfigRequest_1.BenefitModuleConfigRequest)
69
69
  ], BenefitCreateRequest.prototype, "moduleConfig", void 0);
70
70
  __decorate([
71
+ (0, class_validator_1.ValidateIf)((_, value) => value !== null && value !== undefined),
71
72
  (0, class_validator_1.IsObject)(),
72
73
  __metadata("design:type", Object)
73
74
  ], BenefitCreateRequest.prototype, "rulesVisibility", void 0);
@@ -10,5 +10,11 @@ export declare class BenefitUpdateRequest {
10
10
  flow?: BenefitFlowEnum;
11
11
  translationKey?: string;
12
12
  moduleConfig?: BenefitModuleConfigRequest;
13
- rulesVisibility?: Record<string, unknown>;
13
+ /**
14
+ * Reglas de visibilidad — patch parcial:
15
+ * - `undefined` → no toca el campo existente.
16
+ * - `null` → limpia la regla (beneficio se vuelve público).
17
+ * - objeto → reemplaza la regla; debe pasar VisibilityRulesValidator.
18
+ */
19
+ rulesVisibility?: Record<string, unknown> | null;
14
20
  }
@@ -61,7 +61,7 @@ __decorate([
61
61
  __metadata("design:type", BenefitModuleConfigRequest_1.BenefitModuleConfigRequest)
62
62
  ], BenefitUpdateRequest.prototype, "moduleConfig", void 0);
63
63
  __decorate([
64
- (0, class_validator_1.IsOptional)(),
64
+ (0, class_validator_1.ValidateIf)((_, value) => value !== null && value !== undefined),
65
65
  (0, class_validator_1.IsObject)(),
66
66
  __metadata("design:type", Object)
67
67
  ], BenefitUpdateRequest.prototype, "rulesVisibility", void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.18.0",
3
+ "version": "3.19.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -6,6 +6,7 @@ import {
6
6
  IsOptional,
7
7
  IsString,
8
8
  Min,
9
+ ValidateIf,
9
10
  ValidateNested,
10
11
  } from "class-validator";
11
12
  import { Type } from "class-transformer";
@@ -54,6 +55,13 @@ export class BenefitCreateRequest {
54
55
  @Type(() => BenefitModuleConfigRequest)
55
56
  moduleConfig!: BenefitModuleConfigRequest;
56
57
 
58
+ /**
59
+ * Reglas de visibilidad. `null` se acepta como "beneficio público"
60
+ * (visible a todos los usuarios); `undefined` también — el backend
61
+ * normaliza ambos a "sin regla". Si se envía un objeto, debe pasar
62
+ * la validación del VisibilityRulesValidator.
63
+ */
64
+ @ValidateIf((_, value) => value !== null && value !== undefined)
57
65
  @IsObject()
58
- rulesVisibility!: Record<string, unknown>;
66
+ rulesVisibility?: Record<string, unknown> | null;
59
67
  }
@@ -5,6 +5,7 @@ import {
5
5
  IsOptional,
6
6
  IsString,
7
7
  Min,
8
+ ValidateIf,
8
9
  ValidateNested,
9
10
  } from "class-validator";
10
11
  import { Type } from "class-transformer";
@@ -28,7 +29,13 @@ export class BenefitUpdateRequest {
28
29
  @Type(() => BenefitModuleConfigRequest)
29
30
  moduleConfig?: BenefitModuleConfigRequest;
30
31
 
31
- @IsOptional()
32
+ /**
33
+ * Reglas de visibilidad — patch parcial:
34
+ * - `undefined` → no toca el campo existente.
35
+ * - `null` → limpia la regla (beneficio se vuelve público).
36
+ * - objeto → reemplaza la regla; debe pasar VisibilityRulesValidator.
37
+ */
38
+ @ValidateIf((_, value) => value !== null && value !== undefined)
32
39
  @IsObject()
33
- rulesVisibility?: Record<string, unknown>;
40
+ rulesVisibility?: Record<string, unknown> | null;
34
41
  }