@fiado/type-kit 3.574.0 → 3.576.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.
Files changed (71) hide show
  1. package/_test_/unit/retailCommission/commissionRules.test.ts +28 -0
  2. package/_test_/unit/rewardsEligibility/evaluationStrategyDtos.test.ts +93 -0
  3. package/_test_/unit/rewardsEligibility/segmentMessagesAndRunDtos.test.ts +2 -2
  4. package/_test_/unit/rules/evaluationDatalakeDtos.test.ts +144 -0
  5. package/bin/retailCommission/dtos/CommissionApi.d.ts +12 -0
  6. package/bin/retailCommission/dtos/CommissionRule.d.ts +6 -0
  7. package/bin/rewardsEligibility/constants/BatchLimits.d.ts +2 -0
  8. package/bin/rewardsEligibility/constants/BatchLimits.js +5 -0
  9. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.d.ts +2 -0
  10. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.js +7 -0
  11. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.d.ts +3 -0
  12. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.js +7 -0
  13. package/bin/rewardsEligibility/dtos/backoffice/EvaluationResponse.d.ts +3 -0
  14. package/bin/rewardsEligibility/dtos/backoffice/SimulateRequest.d.ts +2 -0
  15. package/bin/rewardsEligibility/dtos/backoffice/SimulateRequest.js +7 -0
  16. package/bin/rewardsEligibility/dtos/messages/EvaluateBatchMessage.d.ts +1 -1
  17. package/bin/rewardsEligibility/dtos/messages/EvaluateBatchMessage.js +3 -2
  18. package/bin/rewardsEligibility/index.d.ts +2 -0
  19. package/bin/rewardsEligibility/index.js +2 -0
  20. package/bin/rewardsEligibility/types/RewardInputRef.d.ts +9 -1
  21. package/bin/rewardsEligibility/validators/IsRewardInputs.d.ts +7 -0
  22. package/bin/rewardsEligibility/validators/IsRewardInputs.js +26 -0
  23. package/bin/rules/constants/RulesLimits.d.ts +6 -0
  24. package/bin/rules/constants/RulesLimits.js +7 -1
  25. package/bin/rules/dtos/EvaluateRulesRequest.d.ts +8 -0
  26. package/bin/rules/dtos/EvaluateRulesRequest.js +24 -0
  27. package/bin/rules/dtos/EvaluateRulesResponse.d.ts +3 -0
  28. package/bin/rules/dtos/ValidateRulesRequest.d.ts +5 -0
  29. package/bin/rules/dtos/ValidateRulesRequest.js +15 -0
  30. package/bin/rules/dtos/datalake/EvaluationExecutionRequest.d.ts +21 -0
  31. package/bin/rules/dtos/datalake/EvaluationExecutionRequest.js +83 -0
  32. package/bin/rules/dtos/datalake/EvaluationExecutionResponse.d.ts +6 -0
  33. package/bin/rules/dtos/datalake/EvaluationExecutionResponse.js +7 -0
  34. package/bin/rules/dtos/datalake/EvaluationExecutionResultsResponse.d.ts +11 -0
  35. package/bin/rules/dtos/datalake/EvaluationExecutionResultsResponse.js +7 -0
  36. package/bin/rules/dtos/datalake/EvaluationResultsRequest.d.ts +11 -0
  37. package/bin/rules/dtos/datalake/EvaluationResultsRequest.js +64 -0
  38. package/bin/rules/dtos/datalake/ReturnFieldsCatalogResponse.d.ts +17 -0
  39. package/bin/rules/dtos/datalake/ReturnFieldsCatalogResponse.js +10 -0
  40. package/bin/rules/dtos/population/SegmentTableSchemaResponse.d.ts +2 -0
  41. package/bin/rules/enums/EvaluationStrategyEnum.d.ts +5 -0
  42. package/bin/rules/enums/EvaluationStrategyEnum.js +9 -0
  43. package/bin/rules/enums/RulesErrorCodeEnum.d.ts +11 -1
  44. package/bin/rules/enums/RulesErrorCodeEnum.js +10 -0
  45. package/bin/rules/index.d.ts +6 -0
  46. package/bin/rules/index.js +7 -0
  47. package/package.json +1 -1
  48. package/src/retailCommission/dtos/CommissionApi.ts +12 -0
  49. package/src/retailCommission/dtos/CommissionRule.ts +6 -0
  50. package/src/rewardsEligibility/constants/BatchLimits.ts +2 -0
  51. package/src/rewardsEligibility/dtos/backoffice/CreateRunRequest.ts +7 -0
  52. package/src/rewardsEligibility/dtos/backoffice/EvaluationRequest.ts +8 -1
  53. package/src/rewardsEligibility/dtos/backoffice/EvaluationResponse.ts +3 -0
  54. package/src/rewardsEligibility/dtos/backoffice/SimulateRequest.ts +7 -0
  55. package/src/rewardsEligibility/dtos/messages/EvaluateBatchMessage.ts +3 -2
  56. package/src/rewardsEligibility/index.ts +2 -0
  57. package/src/rewardsEligibility/types/RewardInputRef.ts +6 -2
  58. package/src/rewardsEligibility/validators/IsRewardInputs.ts +16 -0
  59. package/src/rules/constants/RulesLimits.ts +6 -0
  60. package/src/rules/dtos/EvaluateRulesRequest.ts +26 -1
  61. package/src/rules/dtos/EvaluateRulesResponse.ts +3 -0
  62. package/src/rules/dtos/ValidateRulesRequest.ts +17 -2
  63. package/src/rules/dtos/datalake/EvaluationExecutionRequest.ts +73 -0
  64. package/src/rules/dtos/datalake/EvaluationExecutionResponse.ts +7 -0
  65. package/src/rules/dtos/datalake/EvaluationExecutionResultsResponse.ts +12 -0
  66. package/src/rules/dtos/datalake/EvaluationResultsRequest.ts +46 -0
  67. package/src/rules/dtos/datalake/ReturnFieldsCatalogResponse.ts +19 -0
  68. package/src/rules/dtos/population/SegmentTableSchemaResponse.ts +2 -0
  69. package/src/rules/enums/EvaluationStrategyEnum.ts +5 -0
  70. package/src/rules/enums/RulesErrorCodeEnum.ts +10 -0
  71. package/src/rules/index.ts +8 -0
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EvaluateRulesRequest = exports.RuleToEvaluate = exports.RulesEvaluationSubject = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
+ const RulesLimits_1 = require("../constants/RulesLimits");
16
+ const EvaluationStrategyEnum_1 = require("../enums/EvaluationStrategyEnum");
15
17
  /** A quién se le evalúa la regla. */
16
18
  class RulesEvaluationSubject {
17
19
  }
@@ -82,3 +84,25 @@ __decorate([
82
84
  (0, class_validator_1.IsISO8601)(),
83
85
  __metadata("design:type", String)
84
86
  ], EvaluateRulesRequest.prototype, "referenceAt", void 0);
87
+ __decorate([
88
+ (0, class_transformer_1.Expose)(),
89
+ (0, class_validator_1.IsOptional)(),
90
+ (0, class_validator_1.IsEnum)(EvaluationStrategyEnum_1.EvaluationStrategyEnum),
91
+ __metadata("design:type", String)
92
+ ], EvaluateRulesRequest.prototype, "evaluationStrategy", void 0);
93
+ __decorate([
94
+ (0, class_transformer_1.Expose)(),
95
+ (0, class_validator_1.IsOptional)(),
96
+ (0, class_validator_1.IsArray)(),
97
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_RETURN_FIELDS),
98
+ (0, class_validator_1.Matches)(RulesLimits_1.RETURN_FIELD_ID_PATTERN, { each: true }),
99
+ __metadata("design:type", Array)
100
+ ], EvaluateRulesRequest.prototype, "returnFields", void 0);
101
+ __decorate([
102
+ (0, class_transformer_1.Expose)(),
103
+ (0, class_validator_1.IsOptional)(),
104
+ (0, class_validator_1.IsArray)(),
105
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_INPUT_CONTRACT),
106
+ (0, class_validator_1.IsObject)({ each: true }),
107
+ __metadata("design:type", Array)
108
+ ], EvaluateRulesRequest.prototype, "inputContract", void 0);
@@ -1,3 +1,4 @@
1
+ import { JsonValue } from '../../common';
1
2
  import { RulesOutcomeEnum } from '../enums/RulesOutcomeEnum';
2
3
  import { RulesTraceResponse } from './RulesTraceResponse';
3
4
  /** Resultado de una regla para un sujeto. */
@@ -10,6 +11,8 @@ export declare class RuleEvaluationResult {
10
11
  trace?: RulesTraceResponse;
11
12
  /** Solo si `outcome` es `ERROR`. */
12
13
  errorMessage?: string;
14
+ /** Campos devueltos pedidos en `returnFields`: clave = id del campo; `null` = sin dato. */
15
+ returned?: Record<string, JsonValue>;
13
16
  }
14
17
  /** `POST /evaluate`: ordenado por regla y, dentro de cada regla, por `subjectIndex`. */
15
18
  export declare class EvaluateRulesResponse {
@@ -1,5 +1,6 @@
1
1
  import { JsonValue } from '../../common';
2
2
  import { InputField } from '../../dynamicForm/dtos/InputField';
3
+ import { EvaluationStrategyEnum } from '../enums/EvaluationStrategyEnum';
3
4
  /** `POST /validate`: valida una regla guardada contra el catálogo de los ítems indicados y el contrato de `input`. */
4
5
  export declare class ValidateRulesRequest {
5
6
  /** Quién llama (solo logs y métricas). */
@@ -12,4 +13,8 @@ export declare class ValidateRulesRequest {
12
13
  };
13
14
  /** Contrato de la fuente `input` (`InputField[]`, dominio `dynamicForm`). */
14
15
  inputContract?: InputField[];
16
+ /** Estrategia contra la que se valida; ausente = `LIVE`. */
17
+ evaluationStrategy?: EvaluationStrategyEnum;
18
+ /** Campos devueltos a validar (`fuente:campo` o `tabla.ruta.hoja`); máx. 20. */
19
+ returnFields?: string[];
15
20
  }
@@ -13,6 +13,7 @@ exports.ValidateRulesRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
15
  const RulesLimits_1 = require("../constants/RulesLimits");
16
+ const EvaluationStrategyEnum_1 = require("../enums/EvaluationStrategyEnum");
16
17
  /** `POST /validate`: valida una regla guardada contra el catálogo de los ítems indicados y el contrato de `input`. */
17
18
  class ValidateRulesRequest {
18
19
  }
@@ -42,3 +43,17 @@ __decorate([
42
43
  (0, class_validator_1.IsObject)({ each: true }),
43
44
  __metadata("design:type", Array)
44
45
  ], ValidateRulesRequest.prototype, "inputContract", void 0);
46
+ __decorate([
47
+ (0, class_transformer_1.Expose)(),
48
+ (0, class_validator_1.IsOptional)(),
49
+ (0, class_validator_1.IsEnum)(EvaluationStrategyEnum_1.EvaluationStrategyEnum),
50
+ __metadata("design:type", String)
51
+ ], ValidateRulesRequest.prototype, "evaluationStrategy", void 0);
52
+ __decorate([
53
+ (0, class_transformer_1.Expose)(),
54
+ (0, class_validator_1.IsOptional)(),
55
+ (0, class_validator_1.IsArray)(),
56
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_RETURN_FIELDS),
57
+ (0, class_validator_1.Matches)(RulesLimits_1.RETURN_FIELD_ID_PATTERN, { each: true }),
58
+ __metadata("design:type", Array)
59
+ ], ValidateRulesRequest.prototype, "returnFields", void 0);
@@ -0,0 +1,21 @@
1
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
2
+ import { RuleToEvaluate, RulesEvaluationSubject } from '../EvaluateRulesRequest';
3
+ /**
4
+ * `POST /evaluate/executions`: inicia UNA query Athena por lote (hasta 1000 sujetos).
5
+ * `rules` ausente = modo "solo campos" (exige `returnFields` ≥ 1: esa regla la valida el lambda).
6
+ */
7
+ export declare class EvaluationExecutionRequest {
8
+ /** Quién llama (solo logs y métricas). */
9
+ consumer?: string;
10
+ /** Ids de ítems del catálogo (`source:key`) que las reglas pueden usar. */
11
+ items: string[];
12
+ rules?: RuleToEvaluate[];
13
+ /** Contrato de la fuente `input` (tipos de las columnas `i_<llave>`). */
14
+ inputContract?: InputField[];
15
+ subjects: RulesEvaluationSubject[];
16
+ /** Fecha ISO 8601 con hora (ancla del cálculo, nunca `now()`). */
17
+ referenceAt: string;
18
+ returnFields?: string[];
19
+ /** Mismo lote reintentado = mismo `QueryExecutionId`. */
20
+ idempotencyKey: string;
21
+ }
@@ -0,0 +1,83 @@
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.EvaluationExecutionRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const RulesLimits_1 = require("../../constants/RulesLimits");
16
+ const EvaluateRulesRequest_1 = require("../EvaluateRulesRequest");
17
+ /**
18
+ * `POST /evaluate/executions`: inicia UNA query Athena por lote (hasta 1000 sujetos).
19
+ * `rules` ausente = modo "solo campos" (exige `returnFields` ≥ 1: esa regla la valida el lambda).
20
+ */
21
+ class EvaluationExecutionRequest {
22
+ }
23
+ exports.EvaluationExecutionRequest = EvaluationExecutionRequest;
24
+ __decorate([
25
+ (0, class_transformer_1.Expose)(),
26
+ (0, class_validator_1.IsOptional)(),
27
+ (0, class_validator_1.IsString)(),
28
+ __metadata("design:type", String)
29
+ ], EvaluationExecutionRequest.prototype, "consumer", void 0);
30
+ __decorate([
31
+ (0, class_transformer_1.Expose)(),
32
+ (0, class_validator_1.IsArray)(),
33
+ (0, class_validator_1.IsString)({ each: true }),
34
+ __metadata("design:type", Array)
35
+ ], EvaluationExecutionRequest.prototype, "items", void 0);
36
+ __decorate([
37
+ (0, class_transformer_1.Expose)(),
38
+ (0, class_validator_1.IsOptional)(),
39
+ (0, class_validator_1.IsArray)(),
40
+ (0, class_validator_1.ArrayMinSize)(1),
41
+ (0, class_validator_1.ArrayMaxSize)(10),
42
+ (0, class_validator_1.ValidateNested)({ each: true }),
43
+ (0, class_transformer_1.Type)(() => EvaluateRulesRequest_1.RuleToEvaluate),
44
+ __metadata("design:type", Array)
45
+ ], EvaluationExecutionRequest.prototype, "rules", void 0);
46
+ __decorate([
47
+ (0, class_transformer_1.Expose)(),
48
+ (0, class_validator_1.IsOptional)(),
49
+ (0, class_validator_1.IsArray)(),
50
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_INPUT_CONTRACT),
51
+ (0, class_validator_1.IsObject)({ each: true }),
52
+ __metadata("design:type", Array)
53
+ ], EvaluationExecutionRequest.prototype, "inputContract", void 0);
54
+ __decorate([
55
+ (0, class_transformer_1.Expose)(),
56
+ (0, class_validator_1.IsArray)(),
57
+ (0, class_validator_1.ArrayMinSize)(1),
58
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_SUBJECTS_PER_DATALAKE_CALL),
59
+ (0, class_validator_1.ValidateNested)({ each: true }),
60
+ (0, class_transformer_1.Type)(() => EvaluateRulesRequest_1.RulesEvaluationSubject),
61
+ __metadata("design:type", Array)
62
+ ], EvaluationExecutionRequest.prototype, "subjects", void 0);
63
+ __decorate([
64
+ (0, class_transformer_1.Expose)(),
65
+ (0, class_validator_1.IsISO8601)({ strict: true }),
66
+ (0, class_validator_1.Matches)(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/),
67
+ __metadata("design:type", String)
68
+ ], EvaluationExecutionRequest.prototype, "referenceAt", void 0);
69
+ __decorate([
70
+ (0, class_transformer_1.Expose)(),
71
+ (0, class_validator_1.IsOptional)(),
72
+ (0, class_validator_1.IsArray)(),
73
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_RETURN_FIELDS),
74
+ (0, class_validator_1.Matches)(RulesLimits_1.RETURN_FIELD_ID_PATTERN, { each: true }),
75
+ __metadata("design:type", Array)
76
+ ], EvaluationExecutionRequest.prototype, "returnFields", void 0);
77
+ __decorate([
78
+ (0, class_transformer_1.Expose)(),
79
+ (0, class_validator_1.IsString)(),
80
+ (0, class_validator_1.MinLength)(32),
81
+ (0, class_validator_1.MaxLength)(128),
82
+ __metadata("design:type", String)
83
+ ], EvaluationExecutionRequest.prototype, "idempotencyKey", void 0);
@@ -0,0 +1,6 @@
1
+ import { PopulationExecutionStatusEnum } from '../../enums/PopulationExecutionStatusEnum';
2
+ /** Respuesta de `POST /evaluate/executions`. */
3
+ export declare class EvaluationExecutionResponse {
4
+ executionId: string;
5
+ status: PopulationExecutionStatusEnum;
6
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EvaluationExecutionResponse = void 0;
4
+ /** Respuesta de `POST /evaluate/executions`. */
5
+ class EvaluationExecutionResponse {
6
+ }
7
+ exports.EvaluationExecutionResponse = EvaluationExecutionResponse;
@@ -0,0 +1,11 @@
1
+ import { PopulationExecutionStatusEnum } from '../../enums/PopulationExecutionStatusEnum';
2
+ import { RulesErrorCodeEnum } from '../../enums/RulesErrorCodeEnum';
3
+ import { RuleEvaluationResult } from '../EvaluateRulesResponse';
4
+ /** Pagina de resultados. Sin `nextToken` = última página. `reason` solo si `status` es `FAILED`. */
5
+ export declare class EvaluationExecutionResultsResponse {
6
+ executionId: string;
7
+ status: PopulationExecutionStatusEnum;
8
+ results: RuleEvaluationResult[];
9
+ nextToken?: string;
10
+ reason?: RulesErrorCodeEnum;
11
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EvaluationExecutionResultsResponse = void 0;
4
+ /** Pagina de resultados. Sin `nextToken` = última página. `reason` solo si `status` es `FAILED`. */
5
+ class EvaluationExecutionResultsResponse {
6
+ }
7
+ exports.EvaluationExecutionResultsResponse = EvaluationExecutionResultsResponse;
@@ -0,0 +1,11 @@
1
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
2
+ import { RuleToEvaluate } from '../EvaluateRulesRequest';
3
+ /** `POST /evaluate/executions/{id}/results`: pagina de resultados. Reglas, ítems e `inputContract` deben ser los del inicio. */
4
+ export declare class EvaluationResultsRequest {
5
+ consumer?: string;
6
+ items: string[];
7
+ rules?: RuleToEvaluate[];
8
+ inputContract?: InputField[];
9
+ returnFields?: string[];
10
+ nextToken?: string;
11
+ }
@@ -0,0 +1,64 @@
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.EvaluationResultsRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const RulesLimits_1 = require("../../constants/RulesLimits");
16
+ const EvaluateRulesRequest_1 = require("../EvaluateRulesRequest");
17
+ /** `POST /evaluate/executions/{id}/results`: pagina de resultados. Reglas, ítems e `inputContract` deben ser los del inicio. */
18
+ class EvaluationResultsRequest {
19
+ }
20
+ exports.EvaluationResultsRequest = EvaluationResultsRequest;
21
+ __decorate([
22
+ (0, class_transformer_1.Expose)(),
23
+ (0, class_validator_1.IsOptional)(),
24
+ (0, class_validator_1.IsString)(),
25
+ __metadata("design:type", String)
26
+ ], EvaluationResultsRequest.prototype, "consumer", void 0);
27
+ __decorate([
28
+ (0, class_transformer_1.Expose)(),
29
+ (0, class_validator_1.IsArray)(),
30
+ (0, class_validator_1.IsString)({ each: true }),
31
+ __metadata("design:type", Array)
32
+ ], EvaluationResultsRequest.prototype, "items", void 0);
33
+ __decorate([
34
+ (0, class_transformer_1.Expose)(),
35
+ (0, class_validator_1.IsOptional)(),
36
+ (0, class_validator_1.IsArray)(),
37
+ (0, class_validator_1.ArrayMinSize)(1),
38
+ (0, class_validator_1.ArrayMaxSize)(10),
39
+ (0, class_validator_1.ValidateNested)({ each: true }),
40
+ (0, class_transformer_1.Type)(() => EvaluateRulesRequest_1.RuleToEvaluate),
41
+ __metadata("design:type", Array)
42
+ ], EvaluationResultsRequest.prototype, "rules", void 0);
43
+ __decorate([
44
+ (0, class_transformer_1.Expose)(),
45
+ (0, class_validator_1.IsOptional)(),
46
+ (0, class_validator_1.IsArray)(),
47
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_INPUT_CONTRACT),
48
+ (0, class_validator_1.IsObject)({ each: true }),
49
+ __metadata("design:type", Array)
50
+ ], EvaluationResultsRequest.prototype, "inputContract", void 0);
51
+ __decorate([
52
+ (0, class_transformer_1.Expose)(),
53
+ (0, class_validator_1.IsOptional)(),
54
+ (0, class_validator_1.IsArray)(),
55
+ (0, class_validator_1.ArrayMaxSize)(RulesLimits_1.RULES_MAX_RETURN_FIELDS),
56
+ (0, class_validator_1.Matches)(RulesLimits_1.RETURN_FIELD_ID_PATTERN, { each: true }),
57
+ __metadata("design:type", Array)
58
+ ], EvaluationResultsRequest.prototype, "returnFields", void 0);
59
+ __decorate([
60
+ (0, class_transformer_1.Expose)(),
61
+ (0, class_validator_1.IsOptional)(),
62
+ (0, class_validator_1.IsString)(),
63
+ __metadata("design:type", String)
64
+ ], EvaluationResultsRequest.prototype, "nextToken", void 0);
@@ -0,0 +1,17 @@
1
+ import { RulesValueTypeEnum } from '../../enums/RulesValueTypeEnum';
2
+ /** Un campo del catálogo que se puede devolver (`GET /return-fields`). */
3
+ export declare class ReturnableFieldResponse {
4
+ /** `fuente:campo`. */
5
+ id: string;
6
+ source: string;
7
+ field: string;
8
+ label: string;
9
+ description: string;
10
+ valueType: RulesValueTypeEnum;
11
+ datalakeCompatible: boolean;
12
+ }
13
+ export declare class ReturnFieldsCatalogResponse {
14
+ /** `false` si el datalake no está disponible en el ambiente. */
15
+ available: boolean;
16
+ fields: ReturnableFieldResponse[];
17
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReturnFieldsCatalogResponse = exports.ReturnableFieldResponse = void 0;
4
+ /** Un campo del catálogo que se puede devolver (`GET /return-fields`). */
5
+ class ReturnableFieldResponse {
6
+ }
7
+ exports.ReturnableFieldResponse = ReturnableFieldResponse;
8
+ class ReturnFieldsCatalogResponse {
9
+ }
10
+ exports.ReturnFieldsCatalogResponse = ReturnFieldsCatalogResponse;
@@ -5,6 +5,8 @@ export declare class SegmentColumnSchemaResponse {
5
5
  root?: string;
6
6
  type: string;
7
7
  isDate: boolean;
8
+ /** La hoja está detrás de al menos un `array<struct>`: semántica de elemento (`any_match`). */
9
+ inArray?: boolean;
8
10
  operators: SegmentOperatorEnum[];
9
11
  }
10
12
  export declare class SegmentTableSchemaResponse {
@@ -0,0 +1,5 @@
1
+ /** Cómo evalúa el central una regla: `LIVE` (resolvers en vivo, default) o `DATALAKE` (una query Athena por lote). */
2
+ export declare enum EvaluationStrategyEnum {
3
+ LIVE = "LIVE",
4
+ DATALAKE = "DATALAKE"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EvaluationStrategyEnum = void 0;
4
+ /** Cómo evalúa el central una regla: `LIVE` (resolvers en vivo, default) o `DATALAKE` (una query Athena por lote). */
5
+ var EvaluationStrategyEnum;
6
+ (function (EvaluationStrategyEnum) {
7
+ EvaluationStrategyEnum["LIVE"] = "LIVE";
8
+ EvaluationStrategyEnum["DATALAKE"] = "DATALAKE";
9
+ })(EvaluationStrategyEnum || (exports.EvaluationStrategyEnum = EvaluationStrategyEnum = {}));
@@ -3,5 +3,15 @@ export declare enum RulesErrorCodeEnum {
3
3
  UNKNOWN_CATALOG_ITEM = "UNKNOWN_CATALOG_ITEM",
4
4
  DUPLICATE_SOURCE_IN_ITEMS = "DUPLICATE_SOURCE_IN_ITEMS",
5
5
  TOO_MANY_SUBJECTS = "TOO_MANY_SUBJECTS",
6
- VALIDATION_ERROR = "VALIDATION_ERROR"
6
+ VALIDATION_ERROR = "VALIDATION_ERROR",
7
+ /** 400: la regla usa `params`, o una tabla que el campo necesita no existe en el ambiente. */
8
+ RULE_NOT_DATALAKE_COMPATIBLE = "RULE_NOT_DATALAKE_COMPATIBLE",
9
+ /** 503: el datalake no está disponible. */
10
+ DATALAKE_UNAVAILABLE = "DATALAKE_UNAVAILABLE",
11
+ /** La query del datalake terminó en error. */
12
+ DATALAKE_EVALUATION_FAILED = "DATALAKE_EVALUATION_FAILED",
13
+ /** La query del datalake superó el tiempo de espera (reintentable). */
14
+ DATALAKE_EVALUATION_TIMEOUT = "DATALAKE_EVALUATION_TIMEOUT",
15
+ /** 400: un id de `returnFields` no existe en el catálogo ni en el esquema del datalake. */
16
+ UNKNOWN_RETURN_FIELD = "UNKNOWN_RETURN_FIELD"
7
17
  }
@@ -8,4 +8,14 @@ var RulesErrorCodeEnum;
8
8
  RulesErrorCodeEnum["DUPLICATE_SOURCE_IN_ITEMS"] = "DUPLICATE_SOURCE_IN_ITEMS";
9
9
  RulesErrorCodeEnum["TOO_MANY_SUBJECTS"] = "TOO_MANY_SUBJECTS";
10
10
  RulesErrorCodeEnum["VALIDATION_ERROR"] = "VALIDATION_ERROR";
11
+ /** 400: la regla usa `params`, o una tabla que el campo necesita no existe en el ambiente. */
12
+ RulesErrorCodeEnum["RULE_NOT_DATALAKE_COMPATIBLE"] = "RULE_NOT_DATALAKE_COMPATIBLE";
13
+ /** 503: el datalake no está disponible. */
14
+ RulesErrorCodeEnum["DATALAKE_UNAVAILABLE"] = "DATALAKE_UNAVAILABLE";
15
+ /** La query del datalake terminó en error. */
16
+ RulesErrorCodeEnum["DATALAKE_EVALUATION_FAILED"] = "DATALAKE_EVALUATION_FAILED";
17
+ /** La query del datalake superó el tiempo de espera (reintentable). */
18
+ RulesErrorCodeEnum["DATALAKE_EVALUATION_TIMEOUT"] = "DATALAKE_EVALUATION_TIMEOUT";
19
+ /** 400: un id de `returnFields` no existe en el catálogo ni en el esquema del datalake. */
20
+ RulesErrorCodeEnum["UNKNOWN_RETURN_FIELD"] = "UNKNOWN_RETURN_FIELD";
11
21
  })(RulesErrorCodeEnum || (exports.RulesErrorCodeEnum = RulesErrorCodeEnum = {}));
@@ -40,3 +40,9 @@ export * from './dtos/population/PopulationTestResponse';
40
40
  export * from './dtos/population/PopulationExecutionRequest';
41
41
  export * from './dtos/population/PopulationExecutionResponse';
42
42
  export * from './dtos/population/PopulationExecutionPageResponse';
43
+ export * from './enums/EvaluationStrategyEnum';
44
+ export * from './dtos/datalake/EvaluationExecutionRequest';
45
+ export * from './dtos/datalake/EvaluationExecutionResponse';
46
+ export * from './dtos/datalake/EvaluationResultsRequest';
47
+ export * from './dtos/datalake/EvaluationExecutionResultsResponse';
48
+ export * from './dtos/datalake/ReturnFieldsCatalogResponse';
@@ -61,3 +61,10 @@ __exportStar(require("./dtos/population/PopulationTestResponse"), exports);
61
61
  __exportStar(require("./dtos/population/PopulationExecutionRequest"), exports);
62
62
  __exportStar(require("./dtos/population/PopulationExecutionResponse"), exports);
63
63
  __exportStar(require("./dtos/population/PopulationExecutionPageResponse"), exports);
64
+ //Evaluacion DATALAKE, campos devueltos y ejecucion asincrona
65
+ __exportStar(require("./enums/EvaluationStrategyEnum"), exports);
66
+ __exportStar(require("./dtos/datalake/EvaluationExecutionRequest"), exports);
67
+ __exportStar(require("./dtos/datalake/EvaluationExecutionResponse"), exports);
68
+ __exportStar(require("./dtos/datalake/EvaluationResultsRequest"), exports);
69
+ __exportStar(require("./dtos/datalake/EvaluationExecutionResultsResponse"), exports);
70
+ __exportStar(require("./dtos/datalake/ReturnFieldsCatalogResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.574.0",
3
+ "version": "3.576.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -264,6 +264,12 @@ export interface CommissionRuleInput {
264
264
  countBy?: CommissionCountByEnum;
265
265
  /** Cuándo se paga lo que gana. Ausente = `ON_CUT`. */
266
266
  payTiming?: CommissionPayTimingEnum;
267
+ /**
268
+ * Parte del bono por venta que se paga al registrar la venta, en puntos base (100–9900); el resto se
269
+ * paga en `payTiming`. Solo en reglas cuya única palanca es el bono por venta y con `payTiming`
270
+ * `ON_CUT` o `MONTHLY`. Ausente o `null` = sin adelanto.
271
+ */
272
+ onSaleAdvanceBps?: number | null;
267
273
  }
268
274
 
269
275
  /** `POST /backoffice/commissions/rules` — la regla nace en borrador. */
@@ -466,6 +472,12 @@ export interface CommissionRuleView {
466
472
  countBy?: CommissionCountByEnum;
467
473
  /** Cuándo se paga lo que gana. Ausente = `ON_CUT`. */
468
474
  payTiming?: CommissionPayTimingEnum;
475
+ /**
476
+ * Parte del bono por venta que se paga al registrar la venta, en puntos base (100–9900); el resto se
477
+ * paga en `payTiming`. Solo en reglas cuya única palanca es el bono por venta y con `payTiming`
478
+ * `ON_CUT` o `MONTHLY`. Ausente o `null` = sin adelanto.
479
+ */
480
+ onSaleAdvanceBps?: number | null;
469
481
  }
470
482
 
471
483
  /** Lo pagado en varios cortes. */
@@ -88,6 +88,12 @@ export interface CommissionRule {
88
88
  countBy?: CommissionCountByEnum;
89
89
  /** Cuándo se paga lo que gana. Ausente = `ON_CUT`. */
90
90
  payTiming?: CommissionPayTimingEnum;
91
+ /**
92
+ * Parte del bono por venta que se paga al registrar la venta, en puntos base (100–9900); el resto se
93
+ * paga en `payTiming`. Solo en reglas cuya única palanca es el bono por venta y con `payTiming`
94
+ * `ON_CUT` o `MONTHLY`. Ausente o `null` = sin adelanto.
95
+ */
96
+ onSaleAdvanceBps?: number | null;
91
97
  /** Sube en cada guardado. */
92
98
  version: number;
93
99
  /** La versión que está en el plan vigente. `null` si nunca se publicó. */
@@ -0,0 +1,2 @@
1
+ /** Máximo de sujetos de un `EvaluateBatchMessage` (lote de una evaluación DATALAKE). */
2
+ export const EVALUATE_BATCH_MAX_SUBJECTS = 1000;
@@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer';
2
2
  import { IsEnum, IsObject, IsOptional, Matches, Validate } from 'class-validator';
3
3
  import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
4
  import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+ import { IsRewardInputs } from '../../validators/IsRewardInputs';
5
6
  import { REQUEST_ID_PATTERN } from '../../constants/BackofficeLimits';
6
7
  import { RunModeEnum } from '../../enums/RunModeEnum';
7
8
  import { PopulationRunRequest } from './PopulationRunRequest';
@@ -28,4 +29,10 @@ export class CreateRunRequest {
28
29
  @IsObject()
29
30
  @Type(() => PopulationRunRequest)
30
31
  population?: PopulationRunRequest;
32
+
33
+ /** Valores escritos por el operador para ESTA corrida: itemKey → inputKey → valor. */
34
+ @Expose()
35
+ @IsOptional()
36
+ @Validate(IsRewardInputs)
37
+ rewardInputs?: Record<string, Record<string, DynamicFormValue>>;
31
38
  }
@@ -1,6 +1,7 @@
1
1
  import { Expose } from 'class-transformer';
2
- import { ArrayMaxSize, ArrayMinSize, IsArray, IsNotEmpty, IsObject, IsOptional, IsString, Matches, MaxLength } from 'class-validator';
2
+ import { ArrayMaxSize, ArrayMinSize, IsArray, IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, Matches, MaxLength } from 'class-validator';
3
3
  import { JsonValue } from '../../../common';
4
+ import { EvaluationStrategyEnum } from '../../../rules/enums/EvaluationStrategyEnum';
4
5
  import { InputField } from '../../../dynamicForm/dtos/InputField';
5
6
  import { ELIGIBILITY_ID_PATTERN, INPUT_KEY_PATTERN } from '../../constants/BackofficeLimits';
6
7
  import { EvaluationReward } from '../EvaluationReward';
@@ -80,4 +81,10 @@ export class EvaluationRequest {
80
81
  @IsString()
81
82
  @Matches(INPUT_KEY_PATTERN)
82
83
  populationInputKey?: string;
84
+
85
+ /** Estrategia de evaluación de las corridas masivas; ausente = `LIVE`. */
86
+ @Expose()
87
+ @IsOptional()
88
+ @IsEnum(EvaluationStrategyEnum)
89
+ evaluationStrategy?: EvaluationStrategyEnum;
83
90
  }
@@ -1,4 +1,5 @@
1
1
  import { JsonValue } from '../../../common';
2
+ import { EvaluationStrategyEnum } from '../../../rules/enums/EvaluationStrategyEnum';
2
3
  import { InputField } from '../../../dynamicForm/dtos/InputField';
3
4
  import { EvaluationStatusEnum } from '../../enums/EvaluationStatusEnum';
4
5
  import { EvaluationReward } from '../EvaluationReward';
@@ -21,6 +22,8 @@ export class EvaluationResponse {
21
22
  triggers: EvaluationTrigger[];
22
23
  populationSegmentId?: string;
23
24
  populationInputKey?: string;
25
+ /** Ausente = `LIVE`. */
26
+ evaluationStrategy?: EvaluationStrategyEnum;
24
27
  createdAt: number;
25
28
  updatedAt: number;
26
29
  updatedBy: string;
@@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer';
2
2
  import { IsOptional, IsString, Matches, Validate, ValidateNested } from 'class-validator';
3
3
  import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
4
  import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+ import { IsRewardInputs } from '../../validators/IsRewardInputs';
5
6
  import { ELIGIBILITY_ID_PATTERN } from '../../constants/BackofficeLimits';
6
7
  import { EvaluationRequest } from './EvaluationRequest';
7
8
 
@@ -22,4 +23,10 @@ export class SimulateRequest {
22
23
  @Expose()
23
24
  @Validate(IsDynamicFormValues)
24
25
  inputs: Record<string, DynamicFormValue>;
26
+
27
+ /** Valores escritos por el operador para ESTA corrida: itemKey → inputKey → valor. */
28
+ @Expose()
29
+ @IsOptional()
30
+ @Validate(IsRewardInputs)
31
+ rewardInputs?: Record<string, Record<string, DynamicFormValue>>;
25
32
  }
@@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer';
2
2
  import { ArrayMaxSize, ArrayMinSize, Equals, IsArray, IsNotEmpty, IsString, Validate, ValidateNested } from 'class-validator';
3
3
  import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
4
  import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+ import { EVALUATE_BATCH_MAX_SUBJECTS } from '../../constants/BatchLimits';
5
6
  import { EligibilityMessageTypeEnum } from '../../enums/EligibilityMessageTypeEnum';
6
7
 
7
8
  /** Un sujeto del lote. No lleva hechos precargados: la evaluacion siempre es en vivo. */
@@ -16,7 +17,7 @@ export class EvaluateBatchSubject {
16
17
  inputs: Record<string, DynamicFormValue>;
17
18
  }
18
19
 
19
- /** Lote de hasta 100 sujetos a evaluar en una corrida masiva. */
20
+ /** Lote de hasta 1000 sujetos a evaluar en una corrida masiva. */
20
21
  export class EvaluateBatchMessage {
21
22
  @Expose()
22
23
  @Equals(EligibilityMessageTypeEnum.EVALUATE_BATCH)
@@ -35,7 +36,7 @@ export class EvaluateBatchMessage {
35
36
  @Expose()
36
37
  @IsArray()
37
38
  @ArrayMinSize(1)
38
- @ArrayMaxSize(100)
39
+ @ArrayMaxSize(EVALUATE_BATCH_MAX_SUBJECTS)
39
40
  @ValidateNested({ each: true })
40
41
  @Type(() => EvaluateBatchSubject)
41
42
  subjects: EvaluateBatchSubject[];
@@ -43,6 +43,8 @@ export * from './enums/MetricsDimensionEnum';
43
43
  export * from './enums/RuleValueTypeEnum';
44
44
  export * from './enums/RulesChatRoleEnum';
45
45
  export * from './constants/BackofficeLimits';
46
+ export * from './constants/BatchLimits';
47
+ export * from './validators/IsRewardInputs';
46
48
  export * from './dtos/backoffice/CampaignRequest';
47
49
  export * from './dtos/backoffice/CampaignStatusRequest';
48
50
  export * from './dtos/backoffice/CampaignResponse';
@@ -1,4 +1,8 @@
1
+ import { InputFieldTypeEnum } from '../../dynamicForm/enums/InputFieldTypeEnum';
1
2
  import { DynamicFormValue } from '../../dynamicForm/types/DynamicFormValue';
2
3
 
3
- /** Valor de un input de `reward.inputs`: constante o tomado de un input de la evaluacion (spec B 5.1). */
4
- export type RewardInputRef = { const: DynamicFormValue } | { input: string };
4
+ /**
5
+ * Valor de un input de `reward.inputs`: constante, tomado de un input de la evaluacion (spec B 5.1)
6
+ * o de un campo del usuario leído del datalake (`field`). `as` lo fija el backend al guardar (tipo de la dependencia destino).
7
+ */
8
+ export type RewardInputRef = { const: DynamicFormValue } | { input: string } | { field: string; fallback?: DynamicFormValue; as?: InputFieldTypeEnum };
@@ -0,0 +1,16 @@
1
+ import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator';
2
+ import { JsonValue } from '../../common/types/JsonValue';
3
+ import { isDynamicFormValue, isPlainObject } from '../../dynamicForm/helpers/isDynamicFormValue';
4
+
5
+ /** Valida `itemKey → inputKey → DynamicFormValue` (dos niveles exactos). */
6
+ @ValidatorConstraint({ name: 'IsRewardInputs', async: false })
7
+ export class IsRewardInputs implements ValidatorConstraintInterface {
8
+ validate(value: JsonValue, _args: ValidationArguments): boolean {
9
+ if (!isPlainObject(value)) return false;
10
+ return Object.values(value).every((inner) => isPlainObject(inner) && Object.values(inner).every(isDynamicFormValue));
11
+ }
12
+
13
+ defaultMessage(_args: ValidationArguments): string {
14
+ return 'rewardInputs debe ser un mapa itemKey → inputKey → string | number | boolean | {from, to}';
15
+ }
16
+ }