@fiado/type-kit 3.595.0 → 3.597.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/retailPromotions/constants.test.ts +1 -2
- package/_test_/unit/rewardsEligibility/catalogDtos.test.ts +1 -0
- package/_test_/unit/rules/relationContract.test.ts +84 -0
- package/_test_/unit/rules/segmentRelation.test.ts +62 -0
- package/_test_/unit/rules/traceNested.test.ts +115 -0
- package/_test_/unit/rules/validateNodes.test.ts +68 -0
- package/bin/retailPromotions/constants/retailPromotionsErrorHttpStatus.js +0 -1
- package/bin/retailPromotions/enums/RetailPromotionsErrorCodeEnum.d.ts +0 -2
- package/bin/retailPromotions/enums/RetailPromotionsErrorCodeEnum.js +0 -2
- package/bin/rewardsEligibility/dtos/backoffice/ResultTraceResponse.d.ts +28 -1
- package/bin/rewardsEligibility/dtos/backoffice/ResultTraceResponse.js +9 -1
- package/bin/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.d.ts +16 -0
- package/bin/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.js +5 -1
- package/bin/rewardsEligibility/enums/RulesRelationCardinalityEnum.d.ts +1 -0
- package/bin/rewardsEligibility/enums/RulesRelationCardinalityEnum.js +17 -0
- package/bin/rewardsEligibility/enums/RulesRelationTargetEnum.d.ts +1 -0
- package/bin/rewardsEligibility/enums/RulesRelationTargetEnum.js +17 -0
- package/bin/rewardsEligibility/index.d.ts +2 -0
- package/bin/rewardsEligibility/index.js +2 -0
- package/bin/rules/constants/RulesRelationLimits.d.ts +15 -0
- package/bin/rules/constants/RulesRelationLimits.js +21 -0
- package/bin/rules/dtos/RulesCatalogResponse.d.ts +16 -0
- package/bin/rules/dtos/RulesCatalogResponse.js +5 -1
- package/bin/rules/dtos/RulesTraceResponse.d.ts +34 -1
- package/bin/rules/dtos/RulesTraceResponse.js +12 -1
- package/bin/rules/dtos/ValidateRulesResponse.d.ts +22 -0
- package/bin/rules/dtos/ValidateRulesResponse.js +9 -1
- package/bin/rules/dtos/population/SegmentGroup.d.ts +2 -1
- package/bin/rules/dtos/population/SegmentGroup.js +2 -0
- package/bin/rules/dtos/population/SegmentRelationCondition.d.ts +18 -0
- package/bin/rules/dtos/population/SegmentRelationCondition.js +69 -0
- package/bin/rules/enums/RulesNodeErrorCodeEnum.d.ts +21 -0
- package/bin/rules/enums/RulesNodeErrorCodeEnum.js +25 -0
- package/bin/rules/enums/RulesRelationCardinalityEnum.d.ts +5 -0
- package/bin/rules/enums/RulesRelationCardinalityEnum.js +9 -0
- package/bin/rules/enums/RulesRelationTargetEnum.d.ts +5 -0
- package/bin/rules/enums/RulesRelationTargetEnum.js +9 -0
- package/bin/rules/enums/SegmentConditionKindEnum.d.ts +2 -1
- package/bin/rules/enums/SegmentConditionKindEnum.js +1 -0
- package/bin/rules/enums/SegmentRelationQuantifierKindEnum.d.ts +5 -0
- package/bin/rules/enums/SegmentRelationQuantifierKindEnum.js +9 -0
- package/bin/rules/index.d.ts +6 -0
- package/bin/rules/index.js +6 -0
- package/package.json +1 -1
- package/src/retailPromotions/constants/retailPromotionsErrorHttpStatus.ts +0 -1
- package/src/retailPromotions/enums/RetailPromotionsErrorCodeEnum.ts +0 -2
- package/src/rewardsEligibility/dtos/backoffice/ResultTraceResponse.ts +23 -1
- package/src/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.ts +17 -0
- package/src/rewardsEligibility/enums/RulesRelationCardinalityEnum.ts +1 -0
- package/src/rewardsEligibility/enums/RulesRelationTargetEnum.ts +1 -0
- package/src/rewardsEligibility/index.ts +2 -0
- package/src/rules/constants/RulesRelationLimits.ts +18 -0
- package/src/rules/dtos/RulesCatalogResponse.ts +17 -0
- package/src/rules/dtos/RulesTraceResponse.ts +29 -1
- package/src/rules/dtos/ValidateRulesResponse.ts +25 -0
- package/src/rules/dtos/population/SegmentGroup.ts +3 -1
- package/src/rules/dtos/population/SegmentRelationCondition.ts +25 -0
- package/src/rules/enums/RulesNodeErrorCodeEnum.ts +21 -0
- package/src/rules/enums/RulesRelationCardinalityEnum.ts +5 -0
- package/src/rules/enums/RulesRelationTargetEnum.ts +5 -0
- package/src/rules/enums/SegmentConditionKindEnum.ts +1 -0
- package/src/rules/enums/SegmentRelationQuantifierKindEnum.ts +5 -0
- package/src/rules/index.ts +6 -0
|
@@ -1,6 +1,31 @@
|
|
|
1
|
+
import { RulesNodeErrorCodeEnum } from '../enums/RulesNodeErrorCodeEnum';
|
|
2
|
+
import { RulesValueTypeEnum } from '../enums/RulesValueTypeEnum';
|
|
3
|
+
|
|
4
|
+
/** Error de validación de un nodo del árbol de la regla (bloque de relación o condición). */
|
|
5
|
+
export class RulesNodeValidationErrorResponse {
|
|
6
|
+
/** Ruta del nodo dentro de la regla (para pintar el error en el editor). */
|
|
7
|
+
path: string;
|
|
8
|
+
code: RulesNodeErrorCodeEnum;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Campo devuelto que expone un bloque de relación con `exposeAs`. */
|
|
13
|
+
export class RulesExposedFieldResponse {
|
|
14
|
+
/** `relación:exposeAs` (ver `relationReturnFieldId`); cumple `RETURN_FIELD_ID_PATTERN`. */
|
|
15
|
+
id: string;
|
|
16
|
+
relation: string;
|
|
17
|
+
exposeAs: string;
|
|
18
|
+
/** Siempre `NUMBER` (conteo de relacionados). */
|
|
19
|
+
valueType: RulesValueTypeEnum;
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
/** Resultado de `POST /validate`. */
|
|
2
23
|
export class ValidateRulesResponse {
|
|
3
24
|
valid: boolean;
|
|
4
25
|
/** Mensajes de `validateRule`, tal cual (vacío si `valid`). */
|
|
5
26
|
errors: string[];
|
|
27
|
+
/** Errores por nodo de relación (vacío si no hay). */
|
|
28
|
+
nodeErrors: RulesNodeValidationErrorResponse[];
|
|
29
|
+
/** Campos que la regla puede devolver vía `exposeAs` (vacío si no hay). */
|
|
30
|
+
exposedFields: RulesExposedFieldResponse[];
|
|
6
31
|
}
|
|
@@ -4,8 +4,9 @@ import { SegmentConditionKindEnum } from '../../enums/SegmentConditionKindEnum';
|
|
|
4
4
|
import { SegmentMatchEnum } from '../../enums/SegmentMatchEnum';
|
|
5
5
|
import { SegmentAggregateCondition } from './SegmentAggregateCondition';
|
|
6
6
|
import { SegmentColumnCondition } from './SegmentColumnCondition';
|
|
7
|
+
import { SegmentRelationCondition } from './SegmentRelationCondition';
|
|
7
8
|
|
|
8
|
-
export type SegmentCondition = SegmentColumnCondition | SegmentAggregateCondition;
|
|
9
|
+
export type SegmentCondition = SegmentColumnCondition | SegmentAggregateCondition | SegmentRelationCondition;
|
|
9
10
|
|
|
10
11
|
export class SegmentGroup {
|
|
11
12
|
@Expose() @IsEnum(SegmentMatchEnum) match: SegmentMatchEnum;
|
|
@@ -20,6 +21,7 @@ export class SegmentGroup {
|
|
|
20
21
|
subTypes: [
|
|
21
22
|
{ value: SegmentColumnCondition, name: SegmentConditionKindEnum.COLUMN },
|
|
22
23
|
{ value: SegmentAggregateCondition, name: SegmentConditionKindEnum.AGGREGATE },
|
|
24
|
+
{ value: SegmentRelationCondition, name: SegmentConditionKindEnum.RELATION },
|
|
23
25
|
],
|
|
24
26
|
},
|
|
25
27
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Expose, Type } from 'class-transformer';
|
|
2
|
+
import { ArrayMaxSize, Equals, IsArray, IsEnum, IsNumber, IsOptional, Matches, ValidateIf, ValidateNested } from 'class-validator';
|
|
3
|
+
import { RULES_RELATION_NAME_PATTERN } from '../../constants/RulesRelationLimits';
|
|
4
|
+
import { SegmentConditionKindEnum } from '../../enums/SegmentConditionKindEnum';
|
|
5
|
+
import { SegmentOperatorEnum } from '../../enums/SegmentOperatorEnum';
|
|
6
|
+
import { SegmentRelationQuantifierKindEnum } from '../../enums/SegmentRelationQuantifierKindEnum';
|
|
7
|
+
import { SegmentColumnCondition } from './SegmentColumnCondition';
|
|
8
|
+
|
|
9
|
+
/** Cuantificador de una relacion 1:N. COUNT exige `op` y `value`; ANY/ALL no los llevan. */
|
|
10
|
+
export class SegmentRelationQuantifier {
|
|
11
|
+
@Expose() @IsEnum(SegmentRelationQuantifierKindEnum) kind: SegmentRelationQuantifierKindEnum;
|
|
12
|
+
@Expose() @ValidateIf((q: SegmentRelationQuantifier) => q.kind === SegmentRelationQuantifierKindEnum.COUNT || q.op !== undefined)
|
|
13
|
+
@IsEnum(SegmentOperatorEnum) op?: SegmentOperatorEnum;
|
|
14
|
+
@Expose() @ValidateIf((q: SegmentRelationQuantifier) => q.kind === SegmentRelationQuantifierKindEnum.COUNT || q.value !== undefined)
|
|
15
|
+
@IsNumber() value?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** (c) Condicion sobre los relacionados de la persona (referidor / referidos). `filters` se aplica a cada relacionado. */
|
|
19
|
+
export class SegmentRelationCondition {
|
|
20
|
+
@Expose() @Equals(SegmentConditionKindEnum.RELATION) kind: SegmentConditionKindEnum.RELATION;
|
|
21
|
+
@Expose() @Matches(RULES_RELATION_NAME_PATTERN) relation: string;
|
|
22
|
+
/** MANY: obligatorio; ONE: ausente (lo valida el compilador, no el DTO). */
|
|
23
|
+
@Expose() @IsOptional() @ValidateNested() @Type(() => SegmentRelationQuantifier) quantifier?: SegmentRelationQuantifier;
|
|
24
|
+
@Expose() @IsArray() @ArrayMaxSize(10) @ValidateNested({ each: true }) @Type(() => SegmentColumnCondition) filters: SegmentColumnCondition[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Códigos de error de validación de nodos de relación en `POST /validate`.
|
|
3
|
+
* Mismos strings que `RelationIssueCode` de `@fiado/rules-engine`.
|
|
4
|
+
*/
|
|
5
|
+
export enum RulesNodeErrorCodeEnum {
|
|
6
|
+
UNKNOWN_RELATION = 'UNKNOWN_RELATION',
|
|
7
|
+
INVALID_RELATION_NODE = 'INVALID_RELATION_NODE',
|
|
8
|
+
QUANTIFIER_REQUIRED = 'QUANTIFIER_REQUIRED',
|
|
9
|
+
QUANTIFIER_NOT_ALLOWED = 'QUANTIFIER_NOT_ALLOWED',
|
|
10
|
+
INVALID_QUANTIFIER = 'INVALID_QUANTIFIER',
|
|
11
|
+
SUBJECT_IN_RELATION = 'SUBJECT_IN_RELATION',
|
|
12
|
+
EXPOSE_AS_NOT_ALLOWED = 'EXPOSE_AS_NOT_ALLOWED',
|
|
13
|
+
INVALID_EXPOSE_AS = 'INVALID_EXPOSE_AS',
|
|
14
|
+
DUPLICATE_EXPOSE_AS = 'DUPLICATE_EXPOSE_AS',
|
|
15
|
+
MAX_DEPTH_EXCEEDED = 'MAX_DEPTH_EXCEEDED',
|
|
16
|
+
MAX_BLOCKS_EXCEEDED = 'MAX_BLOCKS_EXCEEDED',
|
|
17
|
+
/** LIVE rechaza una sub-regla 1:N con fuentes que no consultan por lote. */
|
|
18
|
+
RELATION_SOURCE_NOT_BATCH_CAPABLE = 'RELATION_SOURCE_NOT_BATCH_CAPABLE',
|
|
19
|
+
/** Runtime: un sujeto excede `maxRelated`. */
|
|
20
|
+
MAX_RELATED_EXCEEDED = 'MAX_RELATED_EXCEEDED',
|
|
21
|
+
}
|
package/src/rules/index.ts
CHANGED
|
@@ -4,9 +4,13 @@ export * from './enums/RulesGenerationStatusEnum';
|
|
|
4
4
|
export * from './enums/RulesChatRoleEnum';
|
|
5
5
|
export * from './enums/RulesValueTypeEnum';
|
|
6
6
|
export * from './enums/RulesErrorCodeEnum';
|
|
7
|
+
export * from './enums/RulesRelationCardinalityEnum';
|
|
8
|
+
export * from './enums/RulesRelationTargetEnum';
|
|
9
|
+
export * from './enums/RulesNodeErrorCodeEnum';
|
|
7
10
|
|
|
8
11
|
//Constants
|
|
9
12
|
export * from './constants/RulesLimits';
|
|
13
|
+
export * from './constants/RulesRelationLimits';
|
|
10
14
|
|
|
11
15
|
//DTOs
|
|
12
16
|
export * from './dtos/RulesCatalogResponse';
|
|
@@ -23,6 +27,7 @@ export * from './dtos/EvaluateRulesResponse';
|
|
|
23
27
|
export * from './enums/SegmentMatchEnum';
|
|
24
28
|
export * from './enums/SegmentOutputEnum';
|
|
25
29
|
export * from './enums/SegmentConditionKindEnum';
|
|
30
|
+
export * from './enums/SegmentRelationQuantifierKindEnum';
|
|
26
31
|
export * from './enums/SegmentAggregateFnEnum';
|
|
27
32
|
export * from './enums/SegmentOperatorEnum';
|
|
28
33
|
export * from './enums/SegmentParamTypeEnum';
|
|
@@ -31,6 +36,7 @@ export * from './constants/SegmentLimits';
|
|
|
31
36
|
export * from './dtos/population/SegmentWindow';
|
|
32
37
|
export * from './dtos/population/SegmentColumnCondition';
|
|
33
38
|
export * from './dtos/population/SegmentAggregateCondition';
|
|
39
|
+
export * from './dtos/population/SegmentRelationCondition';
|
|
34
40
|
export * from './dtos/population/SegmentGroup';
|
|
35
41
|
export * from './dtos/population/PopulationSegmentDefinition';
|
|
36
42
|
export * from './dtos/population/SegmentParam';
|