@fiado/type-kit 3.529.0 → 3.530.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 (142) hide show
  1. package/_test_/unit/rewardsEligibility/backofficeBarrel.test.ts +6 -0
  2. package/_test_/unit/rewardsEligibility/runDtos.test.ts +2 -2
  3. package/_test_/unit/rewardsEligibility/segmentBackofficeDtos.test.ts +29 -0
  4. package/_test_/unit/rewardsEligibility/segmentDefinitionDto.test.ts +46 -0
  5. package/_test_/unit/rewardsEligibility/segmentEnums.test.ts +43 -0
  6. package/_test_/unit/rewardsEligibility/segmentMessagesAndRunDtos.test.ts +52 -0
  7. package/bin/rewardsEligibility/constants/BackofficeLimits.d.ts +2 -0
  8. package/bin/rewardsEligibility/constants/BackofficeLimits.js +3 -1
  9. package/bin/rewardsEligibility/constants/SegmentLimits.d.ts +5 -0
  10. package/bin/rewardsEligibility/constants/SegmentLimits.js +8 -0
  11. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.js +4 -2
  12. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.d.ts +4 -0
  13. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.js +14 -0
  14. package/bin/rewardsEligibility/dtos/backoffice/EvaluationResponse.d.ts +2 -0
  15. package/bin/rewardsEligibility/dtos/backoffice/PopulationRunRequest.d.ts +1 -3
  16. package/bin/rewardsEligibility/dtos/backoffice/PopulationRunRequest.js +1 -18
  17. package/bin/rewardsEligibility/dtos/backoffice/RunPopulationProgress.d.ts +9 -0
  18. package/bin/rewardsEligibility/dtos/backoffice/RunPopulationProgress.js +7 -0
  19. package/bin/rewardsEligibility/dtos/backoffice/RunResponse.d.ts +19 -0
  20. package/bin/rewardsEligibility/dtos/backoffice/segments/PopulationSegmentDefinition.d.ts +8 -0
  21. package/bin/rewardsEligibility/dtos/backoffice/segments/PopulationSegmentDefinition.js +40 -0
  22. package/bin/rewardsEligibility/dtos/backoffice/segments/PrivateSegmentResponse.d.ts +11 -0
  23. package/bin/rewardsEligibility/dtos/backoffice/segments/PrivateSegmentResponse.js +7 -0
  24. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentAggregateCondition.d.ts +18 -0
  25. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentAggregateCondition.js +71 -0
  26. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentColumnCondition.d.ts +11 -0
  27. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentColumnCondition.js +46 -0
  28. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionPageResponse.d.ts +8 -0
  29. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionPageResponse.js +6 -0
  30. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionRequest.d.ts +6 -0
  31. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionRequest.js +31 -0
  32. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionResponse.d.ts +7 -0
  33. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionResponse.js +6 -0
  34. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentGroup.d.ts +9 -0
  35. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentGroup.js +44 -0
  36. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentLastTest.d.ts +8 -0
  37. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentLastTest.js +6 -0
  38. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentListResponse.d.ts +9 -0
  39. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentListResponse.js +10 -0
  40. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentParam.d.ts +10 -0
  41. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentParam.js +7 -0
  42. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentSaveRequest.d.ts +13 -0
  43. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentSaveRequest.js +58 -0
  44. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentSchemaResponse.d.ts +10 -0
  45. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentSchemaResponse.js +10 -0
  46. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentStatusRequest.d.ts +6 -0
  47. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentStatusRequest.js +31 -0
  48. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentTableSchemaResponse.d.ts +12 -0
  49. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentTableSchemaResponse.js +9 -0
  50. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentTestRequest.d.ts +4 -0
  51. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentTestRequest.js +25 -0
  52. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentTestResponse.d.ts +26 -0
  53. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentTestResponse.js +12 -0
  54. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentUsedByResponse.d.ts +21 -0
  55. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentUsedByResponse.js +12 -0
  56. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentUsedColumn.d.ts +5 -0
  57. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentUsedColumn.js +6 -0
  58. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentVersionListResponse.d.ts +4 -0
  59. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentVersionListResponse.js +6 -0
  60. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentVersionResponse.d.ts +24 -0
  61. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentVersionResponse.js +6 -0
  62. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentVersionSummaryResponse.d.ts +12 -0
  63. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentVersionSummaryResponse.js +7 -0
  64. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentWindow.d.ts +5 -0
  65. package/bin/rewardsEligibility/dtos/backoffice/segments/SegmentWindow.js +31 -0
  66. package/bin/rewardsEligibility/dtos/messages/EvaluateBatchMessage.d.ts +14 -0
  67. package/bin/rewardsEligibility/dtos/messages/EvaluateBatchMessage.js +61 -0
  68. package/bin/rewardsEligibility/dtos/messages/GrantBatchMessage.d.ts +8 -0
  69. package/bin/rewardsEligibility/dtos/messages/GrantBatchMessage.js +42 -0
  70. package/bin/rewardsEligibility/dtos/messages/PopulationPageMessage.d.ts +6 -0
  71. package/bin/rewardsEligibility/dtos/messages/PopulationPageMessage.js +30 -0
  72. package/bin/rewardsEligibility/dtos/messages/ReleaseTrancheMessage.d.ts +6 -0
  73. package/bin/rewardsEligibility/dtos/messages/ReleaseTrancheMessage.js +30 -0
  74. package/bin/rewardsEligibility/enums/EligibilityMessageTypeEnum.d.ts +6 -0
  75. package/bin/rewardsEligibility/enums/EligibilityMessageTypeEnum.js +11 -0
  76. package/bin/rewardsEligibility/enums/SegmentAggregateFnEnum.d.ts +5 -0
  77. package/bin/rewardsEligibility/enums/SegmentAggregateFnEnum.js +9 -0
  78. package/bin/rewardsEligibility/enums/SegmentConditionKindEnum.d.ts +4 -0
  79. package/bin/rewardsEligibility/enums/SegmentConditionKindEnum.js +8 -0
  80. package/bin/rewardsEligibility/enums/SegmentErrorCodeEnum.d.ts +16 -0
  81. package/bin/rewardsEligibility/enums/SegmentErrorCodeEnum.js +20 -0
  82. package/bin/rewardsEligibility/enums/SegmentMatchEnum.d.ts +4 -0
  83. package/bin/rewardsEligibility/enums/SegmentMatchEnum.js +8 -0
  84. package/bin/rewardsEligibility/enums/SegmentOperatorEnum.d.ts +16 -0
  85. package/bin/rewardsEligibility/enums/SegmentOperatorEnum.js +20 -0
  86. package/bin/rewardsEligibility/enums/SegmentParamSourceEnum.d.ts +5 -0
  87. package/bin/rewardsEligibility/enums/SegmentParamSourceEnum.js +9 -0
  88. package/bin/rewardsEligibility/enums/SegmentParamTypeEnum.d.ts +7 -0
  89. package/bin/rewardsEligibility/enums/SegmentParamTypeEnum.js +11 -0
  90. package/bin/rewardsEligibility/enums/SegmentStatusEnum.d.ts +5 -0
  91. package/bin/rewardsEligibility/enums/SegmentStatusEnum.js +9 -0
  92. package/bin/rewardsEligibility/enums/SegmentTestStatusEnum.d.ts +5 -0
  93. package/bin/rewardsEligibility/enums/SegmentTestStatusEnum.js +9 -0
  94. package/bin/rewardsEligibility/index.d.ts +39 -0
  95. package/bin/rewardsEligibility/index.js +43 -0
  96. package/package.json +1 -1
  97. package/src/rewardsEligibility/constants/BackofficeLimits.ts +2 -0
  98. package/src/rewardsEligibility/constants/SegmentLimits.ts +5 -0
  99. package/src/rewardsEligibility/dtos/backoffice/CreateRunRequest.ts +3 -2
  100. package/src/rewardsEligibility/dtos/backoffice/EvaluationRequest.ts +16 -2
  101. package/src/rewardsEligibility/dtos/backoffice/EvaluationResponse.ts +2 -0
  102. package/src/rewardsEligibility/dtos/backoffice/PopulationRunRequest.ts +2 -11
  103. package/src/rewardsEligibility/dtos/backoffice/RunPopulationProgress.ts +9 -0
  104. package/src/rewardsEligibility/dtos/backoffice/RunResponse.ts +12 -0
  105. package/src/rewardsEligibility/dtos/backoffice/segments/PopulationSegmentDefinition.ts +12 -0
  106. package/src/rewardsEligibility/dtos/backoffice/segments/PrivateSegmentResponse.ts +12 -0
  107. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentAggregateCondition.ts +22 -0
  108. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentColumnCondition.ts +15 -0
  109. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionPageResponse.ts +8 -0
  110. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionRequest.ts +17 -0
  111. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentExecutionResponse.ts +7 -0
  112. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentGroup.ts +27 -0
  113. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentLastTest.ts +8 -0
  114. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentListResponse.ts +11 -0
  115. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentParam.ts +11 -0
  116. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentSaveRequest.ts +16 -0
  117. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentSchemaResponse.ts +11 -0
  118. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentStatusRequest.ts +9 -0
  119. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentTableSchemaResponse.ts +14 -0
  120. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentTestRequest.ts +7 -0
  121. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentTestResponse.ts +29 -0
  122. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentUsedByResponse.ts +24 -0
  123. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentUsedColumn.ts +5 -0
  124. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentVersionListResponse.ts +5 -0
  125. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentVersionResponse.ts +25 -0
  126. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentVersionSummaryResponse.ts +13 -0
  127. package/src/rewardsEligibility/dtos/backoffice/segments/SegmentWindow.ts +9 -0
  128. package/src/rewardsEligibility/dtos/messages/EvaluateBatchMessage.ts +42 -0
  129. package/src/rewardsEligibility/dtos/messages/GrantBatchMessage.ts +25 -0
  130. package/src/rewardsEligibility/dtos/messages/PopulationPageMessage.ts +15 -0
  131. package/src/rewardsEligibility/dtos/messages/ReleaseTrancheMessage.ts +15 -0
  132. package/src/rewardsEligibility/enums/EligibilityMessageTypeEnum.ts +7 -0
  133. package/src/rewardsEligibility/enums/SegmentAggregateFnEnum.ts +5 -0
  134. package/src/rewardsEligibility/enums/SegmentConditionKindEnum.ts +4 -0
  135. package/src/rewardsEligibility/enums/SegmentErrorCodeEnum.ts +16 -0
  136. package/src/rewardsEligibility/enums/SegmentMatchEnum.ts +4 -0
  137. package/src/rewardsEligibility/enums/SegmentOperatorEnum.ts +16 -0
  138. package/src/rewardsEligibility/enums/SegmentParamSourceEnum.ts +5 -0
  139. package/src/rewardsEligibility/enums/SegmentParamTypeEnum.ts +7 -0
  140. package/src/rewardsEligibility/enums/SegmentStatusEnum.ts +5 -0
  141. package/src/rewardsEligibility/enums/SegmentTestStatusEnum.ts +5 -0
  142. package/src/rewardsEligibility/index.ts +47 -0
@@ -4,6 +4,7 @@ import { RunStatusEnum } from '../../enums/RunStatusEnum';
4
4
  import { TriggerTypeEnum } from '../../enums/TriggerTypeEnum';
5
5
  import { RunCounts } from '../RunCounts';
6
6
  import { QuotaImpactResponse } from './QuotaImpactResponse';
7
+ import { RunPopulationProgress } from './RunPopulationProgress';
7
8
 
8
9
  /** Corrida para el backoffice (spec 10). */
9
10
  export class RunResponse {
@@ -19,6 +20,17 @@ export class RunResponse {
19
20
  counts: RunCounts;
20
21
  /** Solo con `status: AWAITING_APPROVAL`: cuánto consumiría la corrida de cada cupo y cuánto queda. */
21
22
  quotaImpact?: QuotaImpactResponse[];
23
+ /** Corrida masiva: instante fijo (epoch ms) contra el que se resuelven las ventanas relativas del segmento. */
24
+ referenceAt?: number;
25
+ /** Corrida masiva: version del segmento congelada. */
26
+ segment?: { segmentId: string; version: number };
27
+ population?: RunPopulationProgress;
28
+ /** Fallos de entrega (`GRANT_FAILED`) que llegaron tarde, con la corrida ya cerrada. */
29
+ requestFailedLate?: number;
30
+ /** Motivo de una corrida `FAILED` que nunca llego a tener `population`. */
31
+ failureReason?: string;
32
+ /** Avance del drenaje de una aprobacion masiva. */
33
+ approvalDrain?: { action: 'GRANT' | 'RELEASE' | 'CANCEL'; enqueued: number; done: boolean };
22
34
  requestedBy: string;
23
35
  createdAt: number;
24
36
  updatedAt: number;
@@ -0,0 +1,12 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMaxSize, ArrayMinSize, IsArray, IsEnum, Matches, ValidateNested } from 'class-validator';
3
+ import { SEGMENT_IDENTIFIER_PATTERN } from '../../../constants/SegmentLimits';
4
+ import { SegmentMatchEnum } from '../../../enums/SegmentMatchEnum';
5
+ import { SegmentGroup } from './SegmentGroup';
6
+
7
+ /** El constructor tal cual (A§4.1): tabla ancla (una fila -> un directoryid), TODAS/ALGUNA global y grupos con su propio TODAS/ALGUNA. */
8
+ export class PopulationSegmentDefinition {
9
+ @Expose() @Matches(SEGMENT_IDENTIFIER_PATTERN) baseTable: string;
10
+ @Expose() @IsEnum(SegmentMatchEnum) match: SegmentMatchEnum;
11
+ @Expose() @IsArray() @ArrayMinSize(1) @ArrayMaxSize(10) @ValidateNested({ each: true }) @Type(() => SegmentGroup) groups: SegmentGroup[];
12
+ }
@@ -0,0 +1,12 @@
1
+ import { PopulationSegmentDefinition } from './PopulationSegmentDefinition';
2
+ import { SegmentParam } from './SegmentParam';
3
+
4
+ /** Version de un segmento tal como la consumen otros servicios (con el SQL compilado). */
5
+ export class PrivateSegmentResponse {
6
+ segmentId: string;
7
+ version: number;
8
+ name: string;
9
+ definition: PopulationSegmentDefinition;
10
+ sql: string;
11
+ params: SegmentParam[];
12
+ }
@@ -0,0 +1,22 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMaxSize, Equals, IsArray, IsEnum, IsNumber, IsOptional, Matches, ValidateNested } from 'class-validator';
3
+ import { SEGMENT_IDENTIFIER_PATTERN } from '../../../constants/SegmentLimits';
4
+ import { SegmentAggregateFnEnum } from '../../../enums/SegmentAggregateFnEnum';
5
+ import { SegmentConditionKindEnum } from '../../../enums/SegmentConditionKindEnum';
6
+ import { SegmentOperatorEnum } from '../../../enums/SegmentOperatorEnum';
7
+ import { SegmentColumnCondition } from './SegmentColumnCondition';
8
+ import { SegmentWindow } from './SegmentWindow';
9
+
10
+ /** (b) Agregado con ventana relativa sobre una tabla relacionada (existe / cuenta / suma). `filters` elige QUE cuenta (estados, moneda...). */
11
+ export class SegmentAggregateCondition {
12
+ @Expose() @Equals(SegmentConditionKindEnum.AGGREGATE) kind: SegmentConditionKindEnum.AGGREGATE;
13
+ @Expose() @Matches(SEGMENT_IDENTIFIER_PATTERN) table: string;
14
+ @Expose() @IsEnum(SegmentAggregateFnEnum) fn: SegmentAggregateFnEnum;
15
+ /** Solo SUM. */
16
+ @Expose() @IsOptional() @Matches(SEGMENT_IDENTIFIER_PATTERN) column?: string;
17
+ /** COUNT y SUM; EXISTS no lleva. */
18
+ @Expose() @IsOptional() @IsEnum(SegmentOperatorEnum) op?: SegmentOperatorEnum;
19
+ @Expose() @IsOptional() @IsNumber() value?: number;
20
+ @Expose() @ValidateNested() @Type(() => SegmentWindow) window: SegmentWindow;
21
+ @Expose() @IsArray() @ArrayMaxSize(10) @ValidateNested({ each: true }) @Type(() => SegmentColumnCondition) filters: SegmentColumnCondition[];
22
+ }
@@ -0,0 +1,15 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { Equals, IsEnum, IsOptional, Matches } from 'class-validator';
3
+ import { JsonValue } from '../../../../common';
4
+ import { SEGMENT_IDENTIFIER_PATTERN } from '../../../constants/SegmentLimits';
5
+ import { SegmentConditionKindEnum } from '../../../enums/SegmentConditionKindEnum';
6
+ import { SegmentOperatorEnum } from '../../../enums/SegmentOperatorEnum';
7
+
8
+ /** (a) Columna de una tabla unida por `directoryid`. El tipo de `value` (escalar, lista o `{days}`) lo valida el compilador contra el tipo de Glue. */
9
+ export class SegmentColumnCondition {
10
+ @Expose() @Equals(SegmentConditionKindEnum.COLUMN) kind: SegmentConditionKindEnum.COLUMN;
11
+ @Expose() @Matches(SEGMENT_IDENTIFIER_PATTERN) table: string;
12
+ @Expose() @Matches(SEGMENT_IDENTIFIER_PATTERN) column: string;
13
+ @Expose() @IsEnum(SegmentOperatorEnum) op: SegmentOperatorEnum;
14
+ @Expose() @IsOptional() value?: JsonValue;
15
+ }
@@ -0,0 +1,8 @@
1
+ export class SegmentExecutionPageResponse {
2
+ executionId: string;
3
+ status: string;
4
+ /** Hasta 1000 `directoryid`. */
5
+ ids: string[];
6
+ nextToken?: string;
7
+ reason?: string;
8
+ }
@@ -0,0 +1,17 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsInt, IsISO8601, IsOptional, Min } from 'class-validator';
3
+
4
+ /** Ejecucion de un segmento desde otro servicio (endpoint privado). */
5
+ export class SegmentExecutionRequest {
6
+ @Expose()
7
+ @IsOptional()
8
+ @IsInt()
9
+ @Min(1)
10
+ version?: number;
11
+
12
+ /** ISO-8601 UTC; por defecto, ahora. Fija la ventana relativa del segmento. */
13
+ @Expose()
14
+ @IsOptional()
15
+ @IsISO8601({ strict: true })
16
+ referenceAt?: string;
17
+ }
@@ -0,0 +1,7 @@
1
+ export class SegmentExecutionResponse {
2
+ executionId: string;
3
+ segmentId: string;
4
+ version: number;
5
+ referenceAt: string;
6
+ status: string;
7
+ }
@@ -0,0 +1,27 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMaxSize, ArrayMinSize, IsArray, IsEnum, ValidateNested } from 'class-validator';
3
+ import { SegmentConditionKindEnum } from '../../../enums/SegmentConditionKindEnum';
4
+ import { SegmentMatchEnum } from '../../../enums/SegmentMatchEnum';
5
+ import { SegmentAggregateCondition } from './SegmentAggregateCondition';
6
+ import { SegmentColumnCondition } from './SegmentColumnCondition';
7
+
8
+ export type SegmentCondition = SegmentColumnCondition | SegmentAggregateCondition;
9
+
10
+ export class SegmentGroup {
11
+ @Expose() @IsEnum(SegmentMatchEnum) match: SegmentMatchEnum;
12
+
13
+ /** `kind` decide la clase; un `kind` desconocido NO se instancia y la validacion lo rechaza (el objeto queda sin `@Equals` valido). */
14
+ @Expose()
15
+ @IsArray() @ArrayMinSize(1) @ArrayMaxSize(20) @ValidateNested({ each: true })
16
+ @Type(() => Object, {
17
+ keepDiscriminatorProperty: true,
18
+ discriminator: {
19
+ property: 'kind',
20
+ subTypes: [
21
+ { value: SegmentColumnCondition, name: SegmentConditionKindEnum.COLUMN },
22
+ { value: SegmentAggregateCondition, name: SegmentConditionKindEnum.AGGREGATE },
23
+ ],
24
+ },
25
+ })
26
+ conditions: SegmentCondition[];
27
+ }
@@ -0,0 +1,8 @@
1
+ export class SegmentLastTest {
2
+ testedAt: string;
3
+ count: number;
4
+ bytesScanned: number;
5
+ durationMs: number;
6
+ referenceAt: string;
7
+ queryExecutionId: string;
8
+ }
@@ -0,0 +1,11 @@
1
+ import { SegmentVersionResponse } from './SegmentVersionResponse';
2
+
3
+ export class SegmentListItemResponse extends SegmentVersionResponse {
4
+ /** Evaluaciones de rewards que lo usan (los consumidores externos del endpoint privado NO cuentan). */
5
+ usedByCount: number;
6
+ }
7
+
8
+ export class SegmentListResponse {
9
+ items: SegmentListItemResponse[];
10
+ nextCursor?: string;
11
+ }
@@ -0,0 +1,11 @@
1
+ import { SegmentParamSourceEnum } from '../../../enums/SegmentParamSourceEnum';
2
+ import { SegmentParamTypeEnum } from '../../../enums/SegmentParamTypeEnum';
3
+
4
+ /** Un `?` del SQL, en orden. LITERAL lleva `value` como texto canonico; REFERENCE_AT_MINUS_DAYS lleva `days`. */
5
+ export class SegmentParam {
6
+ name: string;
7
+ type: SegmentParamTypeEnum;
8
+ source: SegmentParamSourceEnum;
9
+ value?: string;
10
+ days?: number;
11
+ }
@@ -0,0 +1,16 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { IsDefined, IsIn, IsNotEmpty, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
3
+ import { SegmentStatusEnum } from '../../../enums/SegmentStatusEnum';
4
+ import { PopulationSegmentDefinition } from './PopulationSegmentDefinition';
5
+
6
+ /** POST /population-segments y PUT /population-segments/{segmentId}. */
7
+ export class SegmentSaveRequest {
8
+ @Expose() @IsString() @IsNotEmpty() @MaxLength(160) name: string;
9
+ @Expose() @IsString() @MaxLength(500) description: string;
10
+ /** Responsable del segmento (usuario o equipo, texto). */
11
+ @Expose() @IsString() @IsNotEmpty() @MaxLength(120) owner: string;
12
+ @Expose() @IsDefined() @ValidateNested() @Type(() => PopulationSegmentDefinition) definition: PopulationSegmentDefinition;
13
+ /** `testId` de `POST /population-segments/test`: el servidor exige que sea PASSED, vigente y de ESTA definicion. */
14
+ @Expose() @IsString() @Matches(/^[A-Za-z0-9-]{1,64}$/) testId: string;
15
+ @Expose() @IsIn([SegmentStatusEnum.DRAFT, SegmentStatusEnum.ACTIVE]) status: SegmentStatusEnum.DRAFT | SegmentStatusEnum.ACTIVE;
16
+ }
@@ -0,0 +1,11 @@
1
+ export class SegmentSchemaTableResponse {
2
+ table: string;
3
+ joinKey: string;
4
+ columnCount: number;
5
+ }
6
+
7
+ /** `available: false` = ambiente sin datalake accesible: el constructor muestra "no disponible". */
8
+ export class SegmentSchemaResponse {
9
+ available: boolean;
10
+ tables: SegmentSchemaTableResponse[];
11
+ }
@@ -0,0 +1,9 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsInt, IsOptional, Min } from 'class-validator';
3
+ import { SegmentStatusEnum } from '../../../enums/SegmentStatusEnum';
4
+
5
+ /** POST /population-segments/{segmentId}/status: activar un DRAFT (con `version`) o archivar el segmento completo. */
6
+ export class SegmentStatusRequest {
7
+ @Expose() @IsOptional() @IsInt() @Min(1) version?: number;
8
+ @Expose() @IsEnum(SegmentStatusEnum) status: SegmentStatusEnum;
9
+ }
@@ -0,0 +1,14 @@
1
+ import { SegmentOperatorEnum } from '../../../enums/SegmentOperatorEnum';
2
+
3
+ export class SegmentColumnSchemaResponse {
4
+ name: string;
5
+ type: string;
6
+ isDate: boolean;
7
+ operators: SegmentOperatorEnum[];
8
+ }
9
+
10
+ export class SegmentTableSchemaResponse {
11
+ table: string;
12
+ joinKey: string;
13
+ columns: SegmentColumnSchemaResponse[];
14
+ }
@@ -0,0 +1,7 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { IsDefined, ValidateNested } from 'class-validator';
3
+ import { PopulationSegmentDefinition } from './PopulationSegmentDefinition';
4
+
5
+ export class SegmentTestRequest {
6
+ @Expose() @IsDefined() @ValidateNested() @Type(() => PopulationSegmentDefinition) definition: PopulationSegmentDefinition;
7
+ }
@@ -0,0 +1,29 @@
1
+ import { SegmentErrorCodeEnum } from '../../../enums/SegmentErrorCodeEnum';
2
+ import { SegmentTestStatusEnum } from '../../../enums/SegmentTestStatusEnum';
3
+ import { SegmentParam } from './SegmentParam';
4
+
5
+ export class SegmentTestResultResponse {
6
+ count: number;
7
+ /** Ids parciales (`a41f...09c2`), hasta 20. */
8
+ sampleIds: string[];
9
+ bytesScanned: number;
10
+ durationMs: number;
11
+ }
12
+
13
+ export class SegmentTestErrorResponse {
14
+ code: SegmentErrorCodeEnum;
15
+ message: string;
16
+ }
17
+
18
+ export class SegmentTestResponse {
19
+ testId: string;
20
+ status: SegmentTestStatusEnum;
21
+ referenceAt: string;
22
+ /** Resumen en lenguaje normal generado de forma determinista (sin IA). */
23
+ humanSummary: string;
24
+ /** SQL de solo lectura + params separados (la UI no deja editarlos). */
25
+ sql: string;
26
+ params: SegmentParam[];
27
+ result?: SegmentTestResultResponse;
28
+ errors?: SegmentTestErrorResponse[];
29
+ }
@@ -0,0 +1,24 @@
1
+ import { EvaluationStatusEnum } from '../../../enums/EvaluationStatusEnum';
2
+ import { RunStatusEnum } from '../../../enums/RunStatusEnum';
3
+ import { TriggerTypeEnum } from '../../../enums/TriggerTypeEnum';
4
+
5
+ export class SegmentUsedByEvaluation {
6
+ id: string;
7
+ name: string;
8
+ campaignId: string;
9
+ status: EvaluationStatusEnum;
10
+ triggers: TriggerTypeEnum[];
11
+ }
12
+
13
+ export class SegmentUsedByRun {
14
+ runId: string;
15
+ evaluationId: string;
16
+ segmentVersion: number;
17
+ status: RunStatusEnum;
18
+ createdAt: number;
19
+ }
20
+
21
+ export class SegmentUsedByResponse {
22
+ evaluations: SegmentUsedByEvaluation[];
23
+ runs: SegmentUsedByRun[];
24
+ }
@@ -0,0 +1,5 @@
1
+ export class SegmentUsedColumn {
2
+ table: string;
3
+ column: string;
4
+ type: string;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { SegmentVersionSummaryResponse } from './SegmentVersionSummaryResponse';
2
+
3
+ export class SegmentVersionListResponse {
4
+ items: SegmentVersionSummaryResponse[];
5
+ }
@@ -0,0 +1,25 @@
1
+ import { SegmentStatusEnum } from '../../../enums/SegmentStatusEnum';
2
+ import { PopulationSegmentDefinition } from './PopulationSegmentDefinition';
3
+ import { SegmentLastTest } from './SegmentLastTest';
4
+ import { SegmentParam } from './SegmentParam';
5
+ import { SegmentUsedColumn } from './SegmentUsedColumn';
6
+
7
+ export class SegmentVersionResponse {
8
+ segmentId: string;
9
+ version: number;
10
+ name: string;
11
+ description: string;
12
+ owner: string;
13
+ status: SegmentStatusEnum;
14
+ definition: PopulationSegmentDefinition;
15
+ definitionHash: string;
16
+ sql: string;
17
+ params: SegmentParam[];
18
+ usedColumns: SegmentUsedColumn[];
19
+ humanSummary: string;
20
+ lastTest?: SegmentLastTest;
21
+ createdBy: string;
22
+ createdAt: string;
23
+ updatedBy: string;
24
+ updatedAt: string;
25
+ }
@@ -0,0 +1,13 @@
1
+ import { SegmentStatusEnum } from '../../../enums/SegmentStatusEnum';
2
+ import { SegmentLastTest } from './SegmentLastTest';
3
+
4
+ /** Igual que SegmentVersionResponse sin definition/sql/params/usedColumns/humanSummary. */
5
+ export class SegmentVersionSummaryResponse {
6
+ segmentId: string;
7
+ version: number;
8
+ status: SegmentStatusEnum;
9
+ lastTest?: SegmentLastTest;
10
+ createdBy: string;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
@@ -0,0 +1,9 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsInt, Matches, Max, Min } from 'class-validator';
3
+ import { SEGMENT_IDENTIFIER_PATTERN, SEGMENT_MAX_DAYS } from '../../../constants/SegmentLimits';
4
+
5
+ /** Ventana relativa [referenceAt - days, referenceAt) sobre una columna de fecha (A§4.1). */
6
+ export class SegmentWindow {
7
+ @Expose() @Matches(SEGMENT_IDENTIFIER_PATTERN) dateColumn: string;
8
+ @Expose() @IsInt() @Min(1) @Max(SEGMENT_MAX_DAYS) days: number;
9
+ }
@@ -0,0 +1,42 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMaxSize, ArrayMinSize, Equals, IsArray, IsNotEmpty, IsString, Validate, ValidateNested } from 'class-validator';
3
+ import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
+ import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+ import { EligibilityMessageTypeEnum } from '../../enums/EligibilityMessageTypeEnum';
6
+
7
+ /** Un sujeto del lote. No lleva hechos precargados: la evaluacion siempre es en vivo. */
8
+ export class EvaluateBatchSubject {
9
+ @Expose()
10
+ @IsString()
11
+ @IsNotEmpty()
12
+ subjectKey: string;
13
+
14
+ @Expose()
15
+ @Validate(IsDynamicFormValues)
16
+ inputs: Record<string, DynamicFormValue>;
17
+ }
18
+
19
+ /** Lote de hasta 100 sujetos a evaluar en una corrida masiva. */
20
+ export class EvaluateBatchMessage {
21
+ @Expose()
22
+ @Equals(EligibilityMessageTypeEnum.EVALUATE_BATCH)
23
+ messageType: EligibilityMessageTypeEnum.EVALUATE_BATCH;
24
+
25
+ @Expose()
26
+ @IsString()
27
+ @IsNotEmpty()
28
+ runId: string;
29
+
30
+ @Expose()
31
+ @IsString()
32
+ @IsNotEmpty()
33
+ batchId: string;
34
+
35
+ @Expose()
36
+ @IsArray()
37
+ @ArrayMinSize(1)
38
+ @ArrayMaxSize(100)
39
+ @ValidateNested({ each: true })
40
+ @Type(() => EvaluateBatchSubject)
41
+ subjects: EvaluateBatchSubject[];
42
+ }
@@ -0,0 +1,25 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { Equals, IsInt, IsNotEmpty, IsString, Min } from 'class-validator';
3
+ import { EligibilityMessageTypeEnum } from '../../enums/EligibilityMessageTypeEnum';
4
+
5
+ /** Publica las entregas (grants) de una parte de un lote de la corrida masiva. */
6
+ export class GrantBatchMessage {
7
+ @Expose()
8
+ @Equals(EligibilityMessageTypeEnum.GRANT_BATCH)
9
+ messageType: EligibilityMessageTypeEnum.GRANT_BATCH;
10
+
11
+ @Expose()
12
+ @IsString()
13
+ @IsNotEmpty()
14
+ runId: string;
15
+
16
+ @Expose()
17
+ @IsString()
18
+ @IsNotEmpty()
19
+ batchId: string;
20
+
21
+ @Expose()
22
+ @IsInt()
23
+ @Min(0)
24
+ part: number;
25
+ }
@@ -0,0 +1,15 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { Equals, IsNotEmpty, IsString } from 'class-validator';
3
+ import { EligibilityMessageTypeEnum } from '../../enums/EligibilityMessageTypeEnum';
4
+
5
+ /** Pide la siguiente pagina de ids del segmento de una corrida masiva. */
6
+ export class PopulationPageMessage {
7
+ @Expose()
8
+ @Equals(EligibilityMessageTypeEnum.POPULATION_PAGE)
9
+ messageType: EligibilityMessageTypeEnum.POPULATION_PAGE;
10
+
11
+ @Expose()
12
+ @IsString()
13
+ @IsNotEmpty()
14
+ runId: string;
15
+ }
@@ -0,0 +1,15 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { Equals, IsInt, Min } from 'class-validator';
3
+ import { EligibilityMessageTypeEnum } from '../../enums/EligibilityMessageTypeEnum';
4
+
5
+ /** Libera el tramo `seq` de la publicacion por tramos (RELEASER). */
6
+ export class ReleaseTrancheMessage {
7
+ @Expose()
8
+ @Equals(EligibilityMessageTypeEnum.RELEASE_TRANCHE)
9
+ messageType: EligibilityMessageTypeEnum.RELEASE_TRANCHE;
10
+
11
+ @Expose()
12
+ @IsInt()
13
+ @Min(0)
14
+ seq: number;
15
+ }
@@ -0,0 +1,7 @@
1
+ // GRANT_FAILED sigue en RewardsMessageTypeEnum del dominio rewards.
2
+ export enum EligibilityMessageTypeEnum {
3
+ POPULATION_PAGE = 'POPULATION_PAGE',
4
+ EVALUATE_BATCH = 'EVALUATE_BATCH',
5
+ GRANT_BATCH = 'GRANT_BATCH',
6
+ RELEASE_TRANCHE = 'RELEASE_TRANCHE',
7
+ }
@@ -0,0 +1,5 @@
1
+ export enum SegmentAggregateFnEnum {
2
+ EXISTS = 'EXISTS',
3
+ COUNT = 'COUNT',
4
+ SUM = 'SUM',
5
+ }
@@ -0,0 +1,4 @@
1
+ export enum SegmentConditionKindEnum {
2
+ COLUMN = 'COLUMN',
3
+ AGGREGATE = 'AGGREGATE',
4
+ }
@@ -0,0 +1,16 @@
1
+ export enum SegmentErrorCodeEnum {
2
+ SEGMENT_NOT_FOUND = 'SEGMENT_NOT_FOUND',
3
+ SEGMENT_INVALID = 'SEGMENT_INVALID',
4
+ SEGMENT_TEST_REQUIRED = 'SEGMENT_TEST_REQUIRED',
5
+ SEGMENT_IN_USE = 'SEGMENT_IN_USE',
6
+ SEGMENT_NOT_ACTIVE = 'SEGMENT_NOT_ACTIVE',
7
+ SEGMENT_BLOCKED_COLUMN = 'SEGMENT_BLOCKED_COLUMN',
8
+ SEGMENT_SCHEMA_DRIFT = 'SEGMENT_SCHEMA_DRIFT',
9
+ SEGMENT_BYTES_EXCEEDED = 'SEGMENT_BYTES_EXCEEDED',
10
+ SEGMENT_QUERY_FAILED = 'SEGMENT_QUERY_FAILED',
11
+ SEGMENT_DATALAKE_UNAVAILABLE = 'SEGMENT_DATALAKE_UNAVAILABLE',
12
+ SEGMENT_DATALAKE_UNAVAILABLE_IN_ENV = 'SEGMENT_DATALAKE_UNAVAILABLE_IN_ENV',
13
+ SEGMENT_VERSION_CONFLICT = 'SEGMENT_VERSION_CONFLICT',
14
+ SEGMENT_STATUS_TRANSITION_INVALID = 'SEGMENT_STATUS_TRANSITION_INVALID',
15
+ SEGMENT_EXECUTION_NOT_FOUND = 'SEGMENT_EXECUTION_NOT_FOUND',
16
+ }
@@ -0,0 +1,4 @@
1
+ export enum SegmentMatchEnum {
2
+ ALL = 'ALL',
3
+ ANY = 'ANY',
4
+ }
@@ -0,0 +1,16 @@
1
+ export enum SegmentOperatorEnum {
2
+ EQUALS = 'EQUALS',
3
+ NOT_EQUALS = 'NOT_EQUALS',
4
+ IN = 'IN',
5
+ NOT_IN = 'NOT_IN',
6
+ IS_NULL = 'IS_NULL',
7
+ IS_NOT_NULL = 'IS_NOT_NULL',
8
+ GT = 'GT',
9
+ GTE = 'GTE',
10
+ LT = 'LT',
11
+ LTE = 'LTE',
12
+ CONTAINS = 'CONTAINS',
13
+ ANY_IN = 'ANY_IN',
14
+ WITHIN_LAST_DAYS = 'WITHIN_LAST_DAYS',
15
+ NOT_WITHIN_LAST_DAYS = 'NOT_WITHIN_LAST_DAYS',
16
+ }
@@ -0,0 +1,5 @@
1
+ export enum SegmentParamSourceEnum {
2
+ LITERAL = 'LITERAL',
3
+ REFERENCE_AT = 'REFERENCE_AT',
4
+ REFERENCE_AT_MINUS_DAYS = 'REFERENCE_AT_MINUS_DAYS',
5
+ }
@@ -0,0 +1,7 @@
1
+ export enum SegmentParamTypeEnum {
2
+ STRING = 'STRING',
3
+ INTEGER = 'INTEGER',
4
+ DECIMAL = 'DECIMAL',
5
+ BOOLEAN = 'BOOLEAN',
6
+ TIMESTAMP = 'TIMESTAMP',
7
+ }
@@ -0,0 +1,5 @@
1
+ export enum SegmentStatusEnum {
2
+ DRAFT = 'DRAFT',
3
+ ACTIVE = 'ACTIVE',
4
+ ARCHIVED = 'ARCHIVED',
5
+ }
@@ -0,0 +1,5 @@
1
+ export enum SegmentTestStatusEnum {
2
+ RUNNING = 'RUNNING',
3
+ PASSED = 'PASSED',
4
+ FAILED = 'FAILED',
5
+ }
@@ -79,3 +79,50 @@ export * from './dtos/backoffice/MetricsPointResponse';
79
79
  export * from './dtos/backoffice/FailedConditionStatResponse';
80
80
  export * from './dtos/backoffice/FailedConditionEvaluationResponse';
81
81
  export * from './dtos/backoffice/MetricsQuery';
82
+
83
+ //Segmentos de poblacion (adenda 2026-10-12)
84
+ export * from './enums/SegmentStatusEnum';
85
+ export * from './enums/SegmentTestStatusEnum';
86
+ export * from './enums/SegmentMatchEnum';
87
+ export * from './enums/SegmentConditionKindEnum';
88
+ export * from './enums/SegmentAggregateFnEnum';
89
+ export * from './enums/SegmentOperatorEnum';
90
+ export * from './enums/SegmentParamTypeEnum';
91
+ export * from './enums/SegmentParamSourceEnum';
92
+ export * from './enums/SegmentErrorCodeEnum';
93
+ export * from './enums/EligibilityMessageTypeEnum';
94
+ export * from './constants/SegmentLimits';
95
+
96
+ //Segmentos de poblacion: definicion del constructor (A2)
97
+ export * from './dtos/backoffice/segments/SegmentWindow';
98
+ export * from './dtos/backoffice/segments/SegmentColumnCondition';
99
+ export * from './dtos/backoffice/segments/SegmentAggregateCondition';
100
+ export * from './dtos/backoffice/segments/SegmentGroup';
101
+ export * from './dtos/backoffice/segments/PopulationSegmentDefinition';
102
+
103
+ //Segmentos de poblacion: request/response del backoffice (A3)
104
+ export * from './dtos/backoffice/segments/SegmentParam';
105
+ export * from './dtos/backoffice/segments/SegmentUsedColumn';
106
+ export * from './dtos/backoffice/segments/SegmentLastTest';
107
+ export * from './dtos/backoffice/segments/SegmentTestRequest';
108
+ export * from './dtos/backoffice/segments/SegmentTestResponse';
109
+ export * from './dtos/backoffice/segments/SegmentSaveRequest';
110
+ export * from './dtos/backoffice/segments/SegmentStatusRequest';
111
+ export * from './dtos/backoffice/segments/SegmentVersionResponse';
112
+ export * from './dtos/backoffice/segments/SegmentVersionSummaryResponse';
113
+ export * from './dtos/backoffice/segments/SegmentListResponse';
114
+ export * from './dtos/backoffice/segments/SegmentVersionListResponse';
115
+ export * from './dtos/backoffice/segments/SegmentSchemaResponse';
116
+ export * from './dtos/backoffice/segments/SegmentTableSchemaResponse';
117
+ export * from './dtos/backoffice/segments/SegmentUsedByResponse';
118
+
119
+ //Segmentos de poblacion: mensajes SQS, endpoint privado y avance de corrida (A4)
120
+ export * from './dtos/messages/PopulationPageMessage';
121
+ export * from './dtos/messages/EvaluateBatchMessage';
122
+ export * from './dtos/messages/GrantBatchMessage';
123
+ export * from './dtos/messages/ReleaseTrancheMessage';
124
+ export * from './dtos/backoffice/segments/PrivateSegmentResponse';
125
+ export * from './dtos/backoffice/segments/SegmentExecutionRequest';
126
+ export * from './dtos/backoffice/segments/SegmentExecutionResponse';
127
+ export * from './dtos/backoffice/segments/SegmentExecutionPageResponse';
128
+ export * from './dtos/backoffice/RunPopulationProgress';