@fiado/type-kit 3.516.0 → 3.518.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 (138) hide show
  1. package/_test_/unit/rewardsEligibility/backofficeBarrel.test.ts +17 -0
  2. package/_test_/unit/rewardsEligibility/campaignAndEventTypeDtos.test.ts +52 -0
  3. package/_test_/unit/rewardsEligibility/campaignConfigDecorators.test.ts +49 -0
  4. package/_test_/unit/rewardsEligibility/catalogDtos.test.ts +27 -0
  5. package/_test_/unit/rewardsEligibility/evaluationDtos.test.ts +53 -0
  6. package/_test_/unit/rewardsEligibility/events.test.ts +3 -3
  7. package/_test_/unit/rewardsEligibility/generateRulesRequest.test.ts +50 -0
  8. package/_test_/unit/rewardsEligibility/generateRulesResponse.test.ts +12 -0
  9. package/_test_/unit/rewardsEligibility/metricsDtos.test.ts +17 -0
  10. package/_test_/unit/rewardsEligibility/ruleCatalogRich.test.ts +18 -0
  11. package/_test_/unit/rewardsEligibility/rulesAiEnums.test.ts +15 -0
  12. package/_test_/unit/rewardsEligibility/runDtos.test.ts +36 -0
  13. package/bin/rewardsEligibility/constants/BackofficeLimits.d.ts +16 -0
  14. package/bin/rewardsEligibility/constants/BackofficeLimits.js +19 -0
  15. package/bin/rewardsEligibility/dtos/CampaignAlerts.js +20 -0
  16. package/bin/rewardsEligibility/dtos/CampaignQuota.d.ts +1 -1
  17. package/bin/rewardsEligibility/dtos/CampaignQuota.js +29 -0
  18. package/bin/rewardsEligibility/dtos/backoffice/ApproveRunRequest.d.ts +4 -0
  19. package/bin/rewardsEligibility/dtos/backoffice/ApproveRunRequest.js +27 -0
  20. package/bin/rewardsEligibility/dtos/backoffice/CampaignListResponse.d.ts +6 -0
  21. package/bin/rewardsEligibility/dtos/backoffice/CampaignListResponse.js +6 -0
  22. package/bin/rewardsEligibility/dtos/backoffice/CampaignRequest.d.ts +16 -0
  23. package/bin/rewardsEligibility/dtos/backoffice/CampaignRequest.js +72 -0
  24. package/bin/rewardsEligibility/dtos/backoffice/CampaignResponse.d.ts +23 -0
  25. package/bin/rewardsEligibility/dtos/backoffice/CampaignResponse.js +7 -0
  26. package/bin/rewardsEligibility/dtos/backoffice/CampaignStatusRequest.d.ts +5 -0
  27. package/bin/rewardsEligibility/dtos/backoffice/CampaignStatusRequest.js +24 -0
  28. package/bin/rewardsEligibility/dtos/backoffice/CampaignSummaryResponse.d.ts +28 -0
  29. package/bin/rewardsEligibility/dtos/backoffice/CampaignSummaryResponse.js +7 -0
  30. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.d.ts +11 -0
  31. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.js +45 -0
  32. package/bin/rewardsEligibility/dtos/backoffice/CreateRunResponse.d.ts +9 -0
  33. package/bin/rewardsEligibility/dtos/backoffice/CreateRunResponse.js +7 -0
  34. package/bin/rewardsEligibility/dtos/backoffice/EvaluationListResponse.d.ts +5 -0
  35. package/bin/rewardsEligibility/dtos/backoffice/EvaluationListResponse.js +6 -0
  36. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.d.ts +27 -0
  37. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.js +86 -0
  38. package/bin/rewardsEligibility/dtos/backoffice/EvaluationResponse.d.ts +26 -0
  39. package/bin/rewardsEligibility/dtos/backoffice/EvaluationResponse.js +6 -0
  40. package/bin/rewardsEligibility/dtos/backoffice/EvaluationStatusRequest.d.ts +5 -0
  41. package/bin/rewardsEligibility/dtos/backoffice/EvaluationStatusRequest.js +24 -0
  42. package/bin/rewardsEligibility/dtos/backoffice/EventTypeListResponse.d.ts +5 -0
  43. package/bin/rewardsEligibility/dtos/backoffice/EventTypeListResponse.js +6 -0
  44. package/bin/rewardsEligibility/dtos/backoffice/EventTypeRequest.d.ts +12 -0
  45. package/bin/rewardsEligibility/dtos/backoffice/EventTypeRequest.js +58 -0
  46. package/bin/rewardsEligibility/dtos/backoffice/EventTypeResponse.d.ts +12 -0
  47. package/bin/rewardsEligibility/dtos/backoffice/EventTypeResponse.js +6 -0
  48. package/bin/rewardsEligibility/dtos/backoffice/FailedConditionStatResponse.d.ts +8 -0
  49. package/bin/rewardsEligibility/dtos/backoffice/FailedConditionStatResponse.js +7 -0
  50. package/bin/rewardsEligibility/dtos/backoffice/GenerateRulesRequest.d.ts +17 -0
  51. package/bin/rewardsEligibility/dtos/backoffice/GenerateRulesRequest.js +44 -0
  52. package/bin/rewardsEligibility/dtos/backoffice/GenerateRulesResponse.d.ts +18 -0
  53. package/bin/rewardsEligibility/dtos/backoffice/GenerateRulesResponse.js +12 -0
  54. package/bin/rewardsEligibility/dtos/backoffice/InputTypeResponse.d.ts +6 -0
  55. package/bin/rewardsEligibility/dtos/backoffice/InputTypeResponse.js +7 -0
  56. package/bin/rewardsEligibility/dtos/backoffice/MetricsPointResponse.d.ts +14 -0
  57. package/bin/rewardsEligibility/dtos/backoffice/MetricsPointResponse.js +7 -0
  58. package/bin/rewardsEligibility/dtos/backoffice/MetricsQuery.d.ts +9 -0
  59. package/bin/rewardsEligibility/dtos/backoffice/MetricsQuery.js +7 -0
  60. package/bin/rewardsEligibility/dtos/backoffice/PopulationRunRequest.d.ts +5 -0
  61. package/bin/rewardsEligibility/dtos/backoffice/PopulationRunRequest.js +24 -0
  62. package/bin/rewardsEligibility/dtos/backoffice/PopulationSourceResponse.d.ts +11 -0
  63. package/bin/rewardsEligibility/dtos/backoffice/PopulationSourceResponse.js +7 -0
  64. package/bin/rewardsEligibility/dtos/backoffice/QuotaImpactResponse.d.ts +9 -0
  65. package/bin/rewardsEligibility/dtos/backoffice/QuotaImpactResponse.js +7 -0
  66. package/bin/rewardsEligibility/dtos/backoffice/QuotaUsageResponse.d.ts +10 -0
  67. package/bin/rewardsEligibility/dtos/backoffice/QuotaUsageResponse.js +7 -0
  68. package/bin/rewardsEligibility/dtos/backoffice/ResultTraceResponse.d.ts +34 -0
  69. package/bin/rewardsEligibility/dtos/backoffice/ResultTraceResponse.js +14 -0
  70. package/bin/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.d.ts +33 -0
  71. package/bin/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.js +13 -0
  72. package/bin/rewardsEligibility/dtos/backoffice/RulesChatTurn.d.ts +6 -0
  73. package/bin/rewardsEligibility/dtos/backoffice/RulesChatTurn.js +32 -0
  74. package/bin/rewardsEligibility/dtos/backoffice/RunListResponse.d.ts +5 -0
  75. package/bin/rewardsEligibility/dtos/backoffice/RunListResponse.js +6 -0
  76. package/bin/rewardsEligibility/dtos/backoffice/RunResponse.d.ts +24 -0
  77. package/bin/rewardsEligibility/dtos/backoffice/RunResponse.js +7 -0
  78. package/bin/rewardsEligibility/dtos/backoffice/RunResultListResponse.d.ts +5 -0
  79. package/bin/rewardsEligibility/dtos/backoffice/RunResultListResponse.js +6 -0
  80. package/bin/rewardsEligibility/dtos/backoffice/RunResultResponse.d.ts +22 -0
  81. package/bin/rewardsEligibility/dtos/backoffice/RunResultResponse.js +7 -0
  82. package/bin/rewardsEligibility/dtos/backoffice/SimulateRequest.d.ts +8 -0
  83. package/bin/rewardsEligibility/dtos/backoffice/SimulateRequest.js +40 -0
  84. package/bin/rewardsEligibility/dtos/backoffice/SimulateResponse.d.ts +11 -0
  85. package/bin/rewardsEligibility/dtos/backoffice/SimulateResponse.js +6 -0
  86. package/bin/rewardsEligibility/enums/MetricsDimensionEnum.d.ts +8 -0
  87. package/bin/rewardsEligibility/enums/MetricsDimensionEnum.js +12 -0
  88. package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.d.ts +56 -1
  89. package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.js +56 -0
  90. package/bin/rewardsEligibility/enums/RuleValueTypeEnum.d.ts +9 -0
  91. package/bin/rewardsEligibility/enums/RuleValueTypeEnum.js +13 -0
  92. package/bin/rewardsEligibility/enums/RulesChatRoleEnum.d.ts +5 -0
  93. package/bin/rewardsEligibility/enums/RulesChatRoleEnum.js +9 -0
  94. package/bin/rewardsEligibility/index.d.ts +38 -0
  95. package/bin/rewardsEligibility/index.js +39 -0
  96. package/package.json +1 -1
  97. package/src/rewardsEligibility/constants/BackofficeLimits.ts +16 -0
  98. package/src/rewardsEligibility/dtos/CampaignAlerts.ts +9 -0
  99. package/src/rewardsEligibility/dtos/CampaignQuota.ts +13 -1
  100. package/src/rewardsEligibility/dtos/backoffice/ApproveRunRequest.ts +13 -0
  101. package/src/rewardsEligibility/dtos/backoffice/CampaignListResponse.ts +7 -0
  102. package/src/rewardsEligibility/dtos/backoffice/CampaignRequest.ts +53 -0
  103. package/src/rewardsEligibility/dtos/backoffice/CampaignResponse.ts +24 -0
  104. package/src/rewardsEligibility/dtos/backoffice/CampaignStatusRequest.ts +10 -0
  105. package/src/rewardsEligibility/dtos/backoffice/CampaignSummaryResponse.ts +26 -0
  106. package/src/rewardsEligibility/dtos/backoffice/CreateRunRequest.ts +30 -0
  107. package/src/rewardsEligibility/dtos/backoffice/CreateRunResponse.ts +10 -0
  108. package/src/rewardsEligibility/dtos/backoffice/EvaluationListResponse.ts +6 -0
  109. package/src/rewardsEligibility/dtos/backoffice/EvaluationRequest.ts +69 -0
  110. package/src/rewardsEligibility/dtos/backoffice/EvaluationResponse.ts +25 -0
  111. package/src/rewardsEligibility/dtos/backoffice/EvaluationStatusRequest.ts +10 -0
  112. package/src/rewardsEligibility/dtos/backoffice/EventTypeListResponse.ts +6 -0
  113. package/src/rewardsEligibility/dtos/backoffice/EventTypeRequest.ts +41 -0
  114. package/src/rewardsEligibility/dtos/backoffice/EventTypeResponse.ts +13 -0
  115. package/src/rewardsEligibility/dtos/backoffice/FailedConditionStatResponse.ts +8 -0
  116. package/src/rewardsEligibility/dtos/backoffice/GenerateRulesRequest.ts +33 -0
  117. package/src/rewardsEligibility/dtos/backoffice/GenerateRulesResponse.ts +17 -0
  118. package/src/rewardsEligibility/dtos/backoffice/InputTypeResponse.ts +7 -0
  119. package/src/rewardsEligibility/dtos/backoffice/MetricsPointResponse.ts +14 -0
  120. package/src/rewardsEligibility/dtos/backoffice/MetricsQuery.ts +10 -0
  121. package/src/rewardsEligibility/dtos/backoffice/PopulationRunRequest.ts +11 -0
  122. package/src/rewardsEligibility/dtos/backoffice/PopulationSourceResponse.ts +12 -0
  123. package/src/rewardsEligibility/dtos/backoffice/QuotaImpactResponse.ts +9 -0
  124. package/src/rewardsEligibility/dtos/backoffice/QuotaUsageResponse.ts +11 -0
  125. package/src/rewardsEligibility/dtos/backoffice/ResultTraceResponse.ts +34 -0
  126. package/src/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.ts +32 -0
  127. package/src/rewardsEligibility/dtos/backoffice/RulesChatTurn.ts +17 -0
  128. package/src/rewardsEligibility/dtos/backoffice/RunListResponse.ts +6 -0
  129. package/src/rewardsEligibility/dtos/backoffice/RunResponse.ts +25 -0
  130. package/src/rewardsEligibility/dtos/backoffice/RunResultListResponse.ts +6 -0
  131. package/src/rewardsEligibility/dtos/backoffice/RunResultResponse.ts +23 -0
  132. package/src/rewardsEligibility/dtos/backoffice/SimulateRequest.ts +25 -0
  133. package/src/rewardsEligibility/dtos/backoffice/SimulateResponse.ts +12 -0
  134. package/src/rewardsEligibility/enums/MetricsDimensionEnum.ts +8 -0
  135. package/src/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.ts +57 -0
  136. package/src/rewardsEligibility/enums/RuleValueTypeEnum.ts +9 -0
  137. package/src/rewardsEligibility/enums/RulesChatRoleEnum.ts +5 -0
  138. package/src/rewardsEligibility/index.ts +40 -0
@@ -0,0 +1,33 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMaxSize, IsArray, IsObject, IsOptional, ValidateNested } from 'class-validator';
3
+ import { JsonValue } from '../../../common';
4
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
5
+ import { RULES_CHAT_MAX_TURNS_HARD } from '../../constants/BackofficeLimits';
6
+ import { RulesChatTurn } from './RulesChatTurn';
7
+
8
+ /**
9
+ * `POST /rules/generate`: el chat del editor de reglas. El lambda arma el prompt con el catálogo de fuentes y ESTE contrato de entrada
10
+ * (qué sujetos `DIRECTORY` y qué campos de `input` existen), genera `{ match, groups[] }` y lo valida con el mismo `validateRule` de la evaluación.
11
+ */
12
+ export class GenerateRulesRequest {
13
+ /** Del turno más viejo al más nuevo; el último es del admin (`user`). Entre 1 y 10 turnos (el lambda responde `AI_CHAT_HISTORY_EMPTY` / `AI_CHAT_HISTORY_TOO_LONG`). */
14
+ @Expose()
15
+ @IsArray()
16
+ @ArrayMaxSize(RULES_CHAT_MAX_TURNS_HARD)
17
+ @ValidateNested({ each: true })
18
+ @Type(() => RulesChatTurn)
19
+ history: RulesChatTurn[];
20
+
21
+ /** Las reglas que el editor tiene ahora (`{ match, groups[] }`), para refinarlas. Ausente = regla nueva. */
22
+ @Expose()
23
+ @IsOptional()
24
+ @IsObject()
25
+ currentRules?: { [key: string]: JsonValue };
26
+
27
+ /** Contrato de entrada de la evaluación que se está editando (`InputField[]`, dominio `dynamicForm`): de aquí salen los `subject` y los campos de la fuente `input`. */
28
+ @Expose()
29
+ @IsArray()
30
+ @ArrayMaxSize(30)
31
+ @IsObject({ each: true })
32
+ inputs: InputField[];
33
+ }
@@ -0,0 +1,17 @@
1
+ import { JsonValue } from '../../../common';
2
+
3
+ /**
4
+ * Respuesta de `POST /rules/generate`. Tres casos:
5
+ * - Reglas listas: `valid: true` + `rules` (ya validadas contra el catálogo y los inputs: el editor puede cargarlas tal cual).
6
+ * - La IA pidió una aclaración (o no podía con lo pedido): `valid: true`, SIN `rules`; la pregunta va en `explanation`.
7
+ * - La IA generó reglas que no pasaron la validación ni tras el reintento: `valid: false`, SIN `rules`, con `problems`.
8
+ */
9
+ export class GenerateRulesResponse {
10
+ /** Qué hizo (o qué preguntó) la IA, en español. Siempre viene. */
11
+ explanation: string;
12
+ /** `{ match, groups[] }` de `@fiado/rules-engine`. */
13
+ rules?: { [key: string]: JsonValue };
14
+ valid: boolean;
15
+ /** Mensajes legibles de la última salida inválida. Solo con `valid: false`. */
16
+ problems?: string[];
17
+ }
@@ -0,0 +1,7 @@
1
+ import { InputFieldTypeEnum } from '../../../dynamicForm/enums/InputFieldTypeEnum';
2
+
3
+ /** `GET /input-types`: tipos del formulario dinámico compartido. */
4
+ export class InputTypeResponse {
5
+ type: InputFieldTypeEnum;
6
+ label: string;
7
+ }
@@ -0,0 +1,14 @@
1
+ /** Un día de métricas preagregadas (spec 5.7). Solo cuenta resultados que llegaron a un estado final. */
2
+ export class MetricsPointResponse {
3
+ /** `AAAA-MM-DD` (UTC). */
4
+ date: string;
5
+ evaluated: number;
6
+ match: number;
7
+ noMatch: number;
8
+ error: number;
9
+ alreadyGranted: number;
10
+ quotaExhausted: number;
11
+ excluded: number;
12
+ requested: number;
13
+ requestFailed: number;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { MetricsDimensionEnum } from '../../enums/MetricsDimensionEnum';
2
+
3
+ /** Query params ya validados de `GET /metrics` (`from`/`to` = `AAAA-MM-DD`, UTC, inclusivos). */
4
+ export class MetricsQuery {
5
+ dimension: MetricsDimensionEnum;
6
+ /** Obligatorio salvo con `dimension: ALL`. */
7
+ value?: string;
8
+ from: string;
9
+ to: string;
10
+ }
@@ -0,0 +1,11 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { Validate } from 'class-validator';
3
+ import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
+ import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+
6
+ /** Corrida por población (fase 4): los `params` de la fuente para esta corrida. El lambda de la fase 3 la rechaza con `POPULATION_RUN_NOT_SUPPORTED`. */
7
+ export class PopulationRunRequest {
8
+ @Expose()
9
+ @Validate(IsDynamicFormValues)
10
+ params: Record<string, DynamicFormValue>;
11
+ }
@@ -0,0 +1,12 @@
1
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
2
+
3
+ /** `GET /population-sources`: fuente de población para un disparador `CRON` (la ejecución llega en la fase 4). */
4
+ export class PopulationSourceResponse {
5
+ source: string;
6
+ label: string;
7
+ description: string;
8
+ /** Formulario de los params de la fuente. */
9
+ paramsSchema: InputField[];
10
+ /** Keys de input que la fuente provee por sujeto. */
11
+ provides: string[];
12
+ }
@@ -0,0 +1,9 @@
1
+ /** Lo que una corrida en espera de aprobación consumiría de un cupo (spec 7.5). */
2
+ export class QuotaImpactResponse {
3
+ quotaId: string;
4
+ /** Ventana vigente al consultar (`TOTAL`, `2026-W41`…). */
5
+ window: string;
6
+ limit: number;
7
+ consumed: number;
8
+ wouldConsume: number;
9
+ }
@@ -0,0 +1,11 @@
1
+ import { QuotaPeriodEnum } from '../../enums/QuotaPeriodEnum';
2
+
3
+ /** `GET /campaigns/{id}/quotas`: consumo actual de un cupo en su ventana vigente. */
4
+ export class QuotaUsageResponse {
5
+ quotaId: string;
6
+ period: QuotaPeriodEnum;
7
+ /** Ventana vigente: `TOTAL`, `2026-10-08` (DAY), `2026-W41` (WEEK) o `2026-10` (MONTH). */
8
+ window: string;
9
+ limit: number;
10
+ consumed: number;
11
+ }
@@ -0,0 +1,34 @@
1
+ import { JsonValue } from '../../../common';
2
+ import { EvaluationOutcomeEnum } from '../../enums/EvaluationOutcomeEnum';
3
+ import { TraceOriginEnum } from '../../enums/TraceOriginEnum';
4
+
5
+ /** Una condición evaluada: qué se esperaba, qué se encontró y de dónde salió el dato (spec 5.4). */
6
+ export class TraceConditionResponse {
7
+ source: string;
8
+ subject?: string;
9
+ field: string;
10
+ params?: Record<string, string | number | boolean>;
11
+ op: string;
12
+ expected: JsonValue;
13
+ actual?: JsonValue;
14
+ /** `MATCH`, `NO_MATCH` o `ERROR`. */
15
+ outcome: EvaluationOutcomeEnum;
16
+ origin?: TraceOriginEnum;
17
+ /** Solo si `origin` es `PREFETCHED`. */
18
+ asOf?: string;
19
+ /** Solo si `outcome` es `ERROR`. */
20
+ error?: { code: string; message: string };
21
+ }
22
+
23
+ export class TraceGroupResponse {
24
+ match: 'ALL' | 'ANY';
25
+ outcome: EvaluationOutcomeEnum;
26
+ conditions: TraceConditionResponse[];
27
+ }
28
+
29
+ /** Traza completa de una evaluación: por qué cumplió o no (criterio de éxito 4). */
30
+ export class ResultTraceResponse {
31
+ match: 'ALL' | 'ANY';
32
+ outcome: EvaluationOutcomeEnum;
33
+ groups: TraceGroupResponse[];
34
+ }
@@ -0,0 +1,32 @@
1
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
2
+ import { RuleValueTypeEnum } from '../../enums/RuleValueTypeEnum';
3
+
4
+ /** Un campo que una fuente resuelve para las reglas (`GET /rule-catalog`). */
5
+ export class RuleCatalogFieldResponse {
6
+ field: string;
7
+ label: string;
8
+ valueType: RuleValueTypeEnum;
9
+ /** Operadores válidos para este campo (`GT`, `LTE`, `IN`…). */
10
+ operators: string[];
11
+ /** Params del campo (ej. ventana y moneda de `sumAmount`), como formulario dinámico. */
12
+ params?: InputField[];
13
+ /** Valores posibles si es un enum (con qué significa cada uno, si se sabe). */
14
+ options?: { value: string; label: string; description?: string }[];
15
+ /** Qué es este campo, en una frase (tooltip del editor). */
16
+ description?: string;
17
+ /** Frases de ejemplo que típicamente piden este campo (ayuda del chat de IA). */
18
+ examplePhrases?: string[];
19
+ }
20
+
21
+ export class RuleCatalogSourceResponse {
22
+ source: string;
23
+ label: string;
24
+ description: string;
25
+ fields: RuleCatalogFieldResponse[];
26
+ }
27
+
28
+ export class RuleCatalogResponse {
29
+ sources: RuleCatalogSourceResponse[];
30
+ /** Etiqueta legible de cada operador (`GTE` → «≥»). */
31
+ operators: Record<string, string>;
32
+ }
@@ -0,0 +1,17 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsNotEmpty, IsString, MaxLength } from 'class-validator';
3
+ import { RULES_CHAT_TURN_MAX_LENGTH } from '../../constants/BackofficeLimits';
4
+ import { RulesChatRoleEnum } from '../../enums/RulesChatRoleEnum';
5
+
6
+ /** Un turno del chat que genera reglas con IA. */
7
+ export class RulesChatTurn {
8
+ @Expose()
9
+ @IsEnum(RulesChatRoleEnum)
10
+ role: RulesChatRoleEnum;
11
+
12
+ @Expose()
13
+ @IsString()
14
+ @IsNotEmpty()
15
+ @MaxLength(RULES_CHAT_TURN_MAX_LENGTH)
16
+ content: string;
17
+ }
@@ -0,0 +1,6 @@
1
+ import { RunResponse } from './RunResponse';
2
+
3
+ export class RunListResponse {
4
+ items: RunResponse[];
5
+ nextCursor?: string;
6
+ }
@@ -0,0 +1,25 @@
1
+ import { ApprovalModeEnum } from '../../enums/ApprovalModeEnum';
2
+ import { RunModeEnum } from '../../enums/RunModeEnum';
3
+ import { RunStatusEnum } from '../../enums/RunStatusEnum';
4
+ import { TriggerTypeEnum } from '../../enums/TriggerTypeEnum';
5
+ import { RunCounts } from '../RunCounts';
6
+ import { QuotaImpactResponse } from './QuotaImpactResponse';
7
+
8
+ /** Corrida para el backoffice (spec 10). */
9
+ export class RunResponse {
10
+ id: string;
11
+ evaluationId: string;
12
+ /** `version` de la evaluación CONGELADA en la corrida. */
13
+ evaluationVersion: number;
14
+ campaignId: string;
15
+ trigger: TriggerTypeEnum;
16
+ approval: ApprovalModeEnum;
17
+ mode: RunModeEnum;
18
+ status: RunStatusEnum;
19
+ counts: RunCounts;
20
+ /** Solo con `status: AWAITING_APPROVAL`: cuánto consumiría la corrida de cada cupo y cuánto queda. */
21
+ quotaImpact?: QuotaImpactResponse[];
22
+ requestedBy: string;
23
+ createdAt: number;
24
+ updatedAt: number;
25
+ }
@@ -0,0 +1,6 @@
1
+ import { RunResultResponse } from './RunResultResponse';
2
+
3
+ export class RunResultListResponse {
4
+ items: RunResultResponse[];
5
+ nextCursor?: string;
6
+ }
@@ -0,0 +1,23 @@
1
+ import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
2
+ import { EvaluationOutcomeEnum } from '../../enums/EvaluationOutcomeEnum';
3
+ import { GrantRequestStatusEnum } from '../../enums/GrantRequestStatusEnum';
4
+ import { ResultTraceResponse } from './ResultTraceResponse';
5
+
6
+ /** Resultado por sujeto CON traza e inputs (spec 5.4). */
7
+ export class RunResultResponse {
8
+ runId: string;
9
+ subjectKey: string;
10
+ inputs: Record<string, DynamicFormValue>;
11
+ beneficiaryDirectoryId: string;
12
+ campaignId: string;
13
+ evaluationId: string;
14
+ packageId: string;
15
+ outcome: EvaluationOutcomeEnum;
16
+ trace?: ResultTraceResponse;
17
+ grantKey?: string;
18
+ grantStatus: GrantRequestStatusEnum;
19
+ /** Cruza con `GET /grants/{id}` de rewards. */
20
+ grantId?: string;
21
+ errorMessage?: string;
22
+ evaluatedAt: number;
23
+ }
@@ -0,0 +1,25 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { IsOptional, IsString, Matches, Validate, ValidateNested } from 'class-validator';
3
+ import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
+ import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+ import { ELIGIBILITY_ID_PATTERN } from '../../constants/BackofficeLimits';
6
+ import { EvaluationRequest } from './EvaluationRequest';
7
+
8
+ /** `POST /evaluations/simulate`: una evaluación GUARDADA (`evaluationId`) o un BORRADOR sin guardar (`evaluation`), más los inputs del sujeto. No persiste nada. Exactamente uno de los dos lo valida el lambda. */
9
+ export class SimulateRequest {
10
+ @Expose()
11
+ @IsOptional()
12
+ @IsString()
13
+ @Matches(ELIGIBILITY_ID_PATTERN)
14
+ evaluationId?: string;
15
+
16
+ @Expose()
17
+ @IsOptional()
18
+ @ValidateNested()
19
+ @Type(() => EvaluationRequest)
20
+ evaluation?: EvaluationRequest;
21
+
22
+ @Expose()
23
+ @Validate(IsDynamicFormValues)
24
+ inputs: Record<string, DynamicFormValue>;
25
+ }
@@ -0,0 +1,12 @@
1
+ import { EvaluationOutcomeEnum } from '../../enums/EvaluationOutcomeEnum';
2
+ import { ResultTraceResponse } from './ResultTraceResponse';
3
+
4
+ export class SimulateResponse {
5
+ outcome: EvaluationOutcomeEnum;
6
+ /** Ausente si el sujeto ni siquiera pudo evaluarse (inputs inválidos). */
7
+ trace?: ResultTraceResponse;
8
+ beneficiaryDirectoryId?: string;
9
+ grantKey?: string;
10
+ /** Explicación corta: «Ya recibió el premio para la venta s-9». */
11
+ note?: string;
12
+ }
@@ -0,0 +1,8 @@
1
+ /** Dimensión de las métricas preagregadas (spec 5.7). `ALL` suma todas las campañas al consultar (no se escribe). */
2
+ export enum MetricsDimensionEnum {
3
+ CAMPAIGN = 'CAMPAIGN',
4
+ EVALUATION = 'EVALUATION',
5
+ PACKAGE = 'PACKAGE',
6
+ TRIGGER = 'TRIGGER',
7
+ ALL = 'ALL',
8
+ }
@@ -5,4 +5,61 @@ export enum RewardsEligibilityErrorCodeEnum {
5
5
  EVENT_TYPE_NOT_FOUND = 'EVENT_TYPE_NOT_FOUND',
6
6
  /** 404: GET /runs/{id} sin corrida. */
7
7
  RUN_NOT_FOUND = 'RUN_NOT_FOUND',
8
+
9
+ // ── Backoffice (fase 3) ──
10
+ /** 400: el cuerpo no cumple el DTO (solo nombres de propiedad, nunca valores). */
11
+ VALIDATION_ERROR = 'VALIDATION_ERROR',
12
+ /** 400: `limit` fuera de rango o `cursor` que no devolvió esta API. */
13
+ INVALID_PAGE = 'INVALID_PAGE',
14
+ /** 400: un filtro de query (`outcome`, `status`, `dimension`, fechas…) no es válido. */
15
+ INVALID_FILTER = 'INVALID_FILTER',
16
+ /** 503: el índice de listado aún no existe en la tabla (pendiente de infraestructura). */
17
+ LIST_INDEX_NOT_AVAILABLE = 'LIST_INDEX_NOT_AVAILABLE',
18
+ /** 409: otra persona editó la misma fila. */
19
+ VERSION_CONFLICT = 'VERSION_CONFLICT',
20
+ /** 400: el id de la ruta no coincide con el del cuerpo. */
21
+ REQUEST_ID_MISMATCH = 'REQUEST_ID_MISMATCH',
22
+ /** 409: la transición de estado no está permitida. */
23
+ INVALID_STATUS_TRANSITION = 'INVALID_STATUS_TRANSITION',
24
+ CAMPAIGN_NOT_FOUND = 'CAMPAIGN_NOT_FOUND',
25
+ CAMPAIGN_ALREADY_EXISTS = 'CAMPAIGN_ALREADY_EXISTS',
26
+ CAMPAIGN_INVALID = 'CAMPAIGN_INVALID',
27
+ EVALUATION_NOT_FOUND = 'EVALUATION_NOT_FOUND',
28
+ EVALUATION_ALREADY_EXISTS = 'EVALUATION_ALREADY_EXISTS',
29
+ /** 400: la evaluación no pasa las validaciones del spec 5.1 (lista TODOS los problemas). */
30
+ EVALUATION_INVALID = 'EVALUATION_INVALID',
31
+ /** 409: la evaluación o su campaña no están en condiciones de correr (estado o vigencia). */
32
+ EVALUATION_NOT_RUNNABLE = 'EVALUATION_NOT_RUNNABLE',
33
+ EVENT_TYPE_ALREADY_EXISTS = 'EVENT_TYPE_ALREADY_EXISTS',
34
+ EVENT_TYPE_INVALID = 'EVENT_TYPE_INVALID',
35
+ /** 409: el tipo de evento lo escuchan evaluaciones ACTIVAS. */
36
+ EVENT_TYPE_IN_USE = 'EVENT_TYPE_IN_USE',
37
+ PACKAGE_NOT_FOUND = 'PACKAGE_NOT_FOUND',
38
+ /** 503: rewards-business no respondió al consultar un paquete. */
39
+ PACKAGE_LOOKUP_UNAVAILABLE = 'PACKAGE_LOOKUP_UNAVAILABLE',
40
+ /** 400: la evaluación no tiene disparador MANUAL. */
41
+ MANUAL_TRIGGER_MISSING = 'MANUAL_TRIGGER_MISSING',
42
+ /** 400: la corrida manual por población llega con la fase 4 (cron masivo). */
43
+ POPULATION_RUN_NOT_SUPPORTED = 'POPULATION_RUN_NOT_SUPPORTED',
44
+ /** 409: la corrida no está esperando aprobación. */
45
+ RUN_NOT_AWAITING_APPROVAL = 'RUN_NOT_AWAITING_APPROVAL',
46
+ /** 409: la corrida tiene más de un registro de reserva (aprobación masiva = fase 4). */
47
+ APPROVAL_RUN_TOO_LARGE = 'APPROVAL_RUN_TOO_LARGE',
48
+ RESULT_NOT_FOUND = 'RESULT_NOT_FOUND',
49
+ /** 409: solo se reintenta un sujeto en ERROR o REQUEST_FAILED de una corrida LIVE cerrada. */
50
+ RESULT_NOT_RETRYABLE = 'RESULT_NOT_RETRYABLE',
51
+ /** 400: el rango pedido excede el tope de filas de la exportación. */
52
+ EXPORT_TOO_LARGE = 'EXPORT_TOO_LARGE',
53
+ /** 503: la tabla de métricas no responde o no existe aún. */
54
+ METRICS_UNAVAILABLE = 'METRICS_UNAVAILABLE',
55
+ /** 400: `POST /rules/generate` sin ningún turno de chat. */
56
+ AI_CHAT_HISTORY_EMPTY = 'AI_CHAT_HISTORY_EMPTY',
57
+ /** 400: el chat tiene más de 10 turnos (se acota el prompt). */
58
+ AI_CHAT_HISTORY_TOO_LONG = 'AI_CHAT_HISTORY_TOO_LONG',
59
+ /** 503: el motor de IA no respondió o falló. Reintentar. */
60
+ AI_GENERATION_FAILED = 'AI_GENERATION_FAILED',
61
+ /** 503: la IA respondió algo que no se pudo leer como `{ explanation, rules }`. Reintentar. */
62
+ AI_RESPONSE_UNPARSEABLE = 'AI_RESPONSE_UNPARSEABLE',
63
+ /** 503: la IA no contestó dentro del presupuesto de tiempo (el gateway corta a los 29 s). Reintentar. */
64
+ AI_GENERATION_TIMEOUT = 'AI_GENERATION_TIMEOUT',
8
65
  }
@@ -0,0 +1,9 @@
1
+ /** Tipo de valor de un campo del catálogo de reglas (`GET /rule-catalog`). */
2
+ export enum RuleValueTypeEnum {
3
+ NUMBER = 'NUMBER',
4
+ STRING = 'STRING',
5
+ BOOLEAN = 'BOOLEAN',
6
+ DATE = 'DATE',
7
+ /** Lista de textos (ej. `directory.scope`). */
8
+ STRING_LIST = 'STRING_LIST',
9
+ }
@@ -0,0 +1,5 @@
1
+ /** Quién habló en un turno del chat que genera reglas con IA (`POST /rules/generate`). */
2
+ export enum RulesChatRoleEnum {
3
+ USER = 'user',
4
+ ASSISTANT = 'assistant',
5
+ }
@@ -38,3 +38,43 @@ export * from './dtos/CampaignAlerts';
38
38
  export * from './dtos/PopulationRef';
39
39
  export * from './dtos/EvaluationReward';
40
40
  export * from './dtos/EvaluationTrigger';
41
+
42
+ //Backoffice (fase 3): enums, constantes y DTOs
43
+ export * from './enums/MetricsDimensionEnum';
44
+ export * from './enums/RuleValueTypeEnum';
45
+ export * from './enums/RulesChatRoleEnum';
46
+ export * from './constants/BackofficeLimits';
47
+ export * from './dtos/backoffice/CampaignRequest';
48
+ export * from './dtos/backoffice/CampaignStatusRequest';
49
+ export * from './dtos/backoffice/CampaignResponse';
50
+ export * from './dtos/backoffice/CampaignListResponse';
51
+ export * from './dtos/backoffice/QuotaUsageResponse';
52
+ export * from './dtos/backoffice/CampaignSummaryResponse';
53
+ export * from './dtos/backoffice/EventTypeRequest';
54
+ export * from './dtos/backoffice/EventTypeResponse';
55
+ export * from './dtos/backoffice/EventTypeListResponse';
56
+ export * from './dtos/backoffice/EvaluationRequest';
57
+ export * from './dtos/backoffice/EvaluationStatusRequest';
58
+ export * from './dtos/backoffice/EvaluationResponse';
59
+ export * from './dtos/backoffice/EvaluationListResponse';
60
+ export * from './dtos/backoffice/ResultTraceResponse';
61
+ export * from './dtos/backoffice/SimulateRequest';
62
+ export * from './dtos/backoffice/SimulateResponse';
63
+ export * from './dtos/backoffice/RuleCatalogResponse';
64
+ export * from './dtos/backoffice/PopulationSourceResponse';
65
+ export * from './dtos/backoffice/InputTypeResponse';
66
+ export * from './dtos/backoffice/RulesChatTurn';
67
+ export * from './dtos/backoffice/GenerateRulesRequest';
68
+ export * from './dtos/backoffice/GenerateRulesResponse';
69
+ export * from './dtos/backoffice/CreateRunRequest';
70
+ export * from './dtos/backoffice/PopulationRunRequest';
71
+ export * from './dtos/backoffice/ApproveRunRequest';
72
+ export * from './dtos/backoffice/QuotaImpactResponse';
73
+ export * from './dtos/backoffice/RunResponse';
74
+ export * from './dtos/backoffice/RunListResponse';
75
+ export * from './dtos/backoffice/RunResultResponse';
76
+ export * from './dtos/backoffice/RunResultListResponse';
77
+ export * from './dtos/backoffice/CreateRunResponse';
78
+ export * from './dtos/backoffice/MetricsPointResponse';
79
+ export * from './dtos/backoffice/FailedConditionStatResponse';
80
+ export * from './dtos/backoffice/MetricsQuery';