@fiado/type-kit 3.515.0 → 3.517.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/group/groupOwnerFields.test.ts +32 -0
  2. package/_test_/unit/referral-business/groupOwnersByGroupIdsDtos.test.ts +46 -0
  3. package/_test_/unit/rewardsEligibility/backofficeBarrel.test.ts +16 -0
  4. package/_test_/unit/rewardsEligibility/campaignAndEventTypeDtos.test.ts +52 -0
  5. package/_test_/unit/rewardsEligibility/campaignConfigDecorators.test.ts +49 -0
  6. package/_test_/unit/rewardsEligibility/catalogDtos.test.ts +27 -0
  7. package/_test_/unit/rewardsEligibility/evaluationDtos.test.ts +53 -0
  8. package/_test_/unit/rewardsEligibility/events.test.ts +3 -3
  9. package/_test_/unit/rewardsEligibility/metricsDtos.test.ts +17 -0
  10. package/_test_/unit/rewardsEligibility/runDtos.test.ts +36 -0
  11. package/bin/group/dtos/GroupCreateRequest.d.ts +1 -0
  12. package/bin/group/dtos/GroupCreateRequest.js +5 -0
  13. package/bin/group/dtos/GroupResponse.d.ts +2 -0
  14. package/bin/referral-business/dtos/GroupOwnersByGroupIdsRequest.d.ts +4 -0
  15. package/bin/referral-business/dtos/GroupOwnersByGroupIdsRequest.js +25 -0
  16. package/bin/referral-business/dtos/GroupOwnersByGroupIdsResponse.d.ts +8 -0
  17. package/bin/referral-business/dtos/GroupOwnersByGroupIdsResponse.js +2 -0
  18. package/bin/referral-business/index.d.ts +2 -0
  19. package/bin/referral-business/index.js +2 -0
  20. package/bin/rewardsEligibility/constants/BackofficeLimits.d.ts +12 -0
  21. package/bin/rewardsEligibility/constants/BackofficeLimits.js +15 -0
  22. package/bin/rewardsEligibility/dtos/CampaignAlerts.js +20 -0
  23. package/bin/rewardsEligibility/dtos/CampaignQuota.d.ts +1 -1
  24. package/bin/rewardsEligibility/dtos/CampaignQuota.js +29 -0
  25. package/bin/rewardsEligibility/dtos/backoffice/ApproveRunRequest.d.ts +4 -0
  26. package/bin/rewardsEligibility/dtos/backoffice/ApproveRunRequest.js +27 -0
  27. package/bin/rewardsEligibility/dtos/backoffice/CampaignListResponse.d.ts +6 -0
  28. package/bin/rewardsEligibility/dtos/backoffice/CampaignListResponse.js +6 -0
  29. package/bin/rewardsEligibility/dtos/backoffice/CampaignRequest.d.ts +16 -0
  30. package/bin/rewardsEligibility/dtos/backoffice/CampaignRequest.js +72 -0
  31. package/bin/rewardsEligibility/dtos/backoffice/CampaignResponse.d.ts +23 -0
  32. package/bin/rewardsEligibility/dtos/backoffice/CampaignResponse.js +7 -0
  33. package/bin/rewardsEligibility/dtos/backoffice/CampaignStatusRequest.d.ts +5 -0
  34. package/bin/rewardsEligibility/dtos/backoffice/CampaignStatusRequest.js +24 -0
  35. package/bin/rewardsEligibility/dtos/backoffice/CampaignSummaryResponse.d.ts +28 -0
  36. package/bin/rewardsEligibility/dtos/backoffice/CampaignSummaryResponse.js +7 -0
  37. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.d.ts +11 -0
  38. package/bin/rewardsEligibility/dtos/backoffice/CreateRunRequest.js +45 -0
  39. package/bin/rewardsEligibility/dtos/backoffice/CreateRunResponse.d.ts +9 -0
  40. package/bin/rewardsEligibility/dtos/backoffice/CreateRunResponse.js +7 -0
  41. package/bin/rewardsEligibility/dtos/backoffice/EvaluationListResponse.d.ts +5 -0
  42. package/bin/rewardsEligibility/dtos/backoffice/EvaluationListResponse.js +6 -0
  43. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.d.ts +27 -0
  44. package/bin/rewardsEligibility/dtos/backoffice/EvaluationRequest.js +86 -0
  45. package/bin/rewardsEligibility/dtos/backoffice/EvaluationResponse.d.ts +26 -0
  46. package/bin/rewardsEligibility/dtos/backoffice/EvaluationResponse.js +6 -0
  47. package/bin/rewardsEligibility/dtos/backoffice/EvaluationStatusRequest.d.ts +5 -0
  48. package/bin/rewardsEligibility/dtos/backoffice/EvaluationStatusRequest.js +24 -0
  49. package/bin/rewardsEligibility/dtos/backoffice/EventTypeListResponse.d.ts +5 -0
  50. package/bin/rewardsEligibility/dtos/backoffice/EventTypeListResponse.js +6 -0
  51. package/bin/rewardsEligibility/dtos/backoffice/EventTypeRequest.d.ts +12 -0
  52. package/bin/rewardsEligibility/dtos/backoffice/EventTypeRequest.js +58 -0
  53. package/bin/rewardsEligibility/dtos/backoffice/EventTypeResponse.d.ts +12 -0
  54. package/bin/rewardsEligibility/dtos/backoffice/EventTypeResponse.js +6 -0
  55. package/bin/rewardsEligibility/dtos/backoffice/FailedConditionStatResponse.d.ts +8 -0
  56. package/bin/rewardsEligibility/dtos/backoffice/FailedConditionStatResponse.js +7 -0
  57. package/bin/rewardsEligibility/dtos/backoffice/InputTypeResponse.d.ts +6 -0
  58. package/bin/rewardsEligibility/dtos/backoffice/InputTypeResponse.js +7 -0
  59. package/bin/rewardsEligibility/dtos/backoffice/MetricsPointResponse.d.ts +14 -0
  60. package/bin/rewardsEligibility/dtos/backoffice/MetricsPointResponse.js +7 -0
  61. package/bin/rewardsEligibility/dtos/backoffice/MetricsQuery.d.ts +9 -0
  62. package/bin/rewardsEligibility/dtos/backoffice/MetricsQuery.js +7 -0
  63. package/bin/rewardsEligibility/dtos/backoffice/PopulationRunRequest.d.ts +5 -0
  64. package/bin/rewardsEligibility/dtos/backoffice/PopulationRunRequest.js +24 -0
  65. package/bin/rewardsEligibility/dtos/backoffice/PopulationSourceResponse.d.ts +11 -0
  66. package/bin/rewardsEligibility/dtos/backoffice/PopulationSourceResponse.js +7 -0
  67. package/bin/rewardsEligibility/dtos/backoffice/QuotaImpactResponse.d.ts +9 -0
  68. package/bin/rewardsEligibility/dtos/backoffice/QuotaImpactResponse.js +7 -0
  69. package/bin/rewardsEligibility/dtos/backoffice/QuotaUsageResponse.d.ts +10 -0
  70. package/bin/rewardsEligibility/dtos/backoffice/QuotaUsageResponse.js +7 -0
  71. package/bin/rewardsEligibility/dtos/backoffice/ResultTraceResponse.d.ts +34 -0
  72. package/bin/rewardsEligibility/dtos/backoffice/ResultTraceResponse.js +14 -0
  73. package/bin/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.d.ts +28 -0
  74. package/bin/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.js +13 -0
  75. package/bin/rewardsEligibility/dtos/backoffice/RunListResponse.d.ts +5 -0
  76. package/bin/rewardsEligibility/dtos/backoffice/RunListResponse.js +6 -0
  77. package/bin/rewardsEligibility/dtos/backoffice/RunResponse.d.ts +24 -0
  78. package/bin/rewardsEligibility/dtos/backoffice/RunResponse.js +7 -0
  79. package/bin/rewardsEligibility/dtos/backoffice/RunResultListResponse.d.ts +5 -0
  80. package/bin/rewardsEligibility/dtos/backoffice/RunResultListResponse.js +6 -0
  81. package/bin/rewardsEligibility/dtos/backoffice/RunResultResponse.d.ts +22 -0
  82. package/bin/rewardsEligibility/dtos/backoffice/RunResultResponse.js +7 -0
  83. package/bin/rewardsEligibility/dtos/backoffice/SimulateRequest.d.ts +8 -0
  84. package/bin/rewardsEligibility/dtos/backoffice/SimulateRequest.js +40 -0
  85. package/bin/rewardsEligibility/dtos/backoffice/SimulateResponse.d.ts +11 -0
  86. package/bin/rewardsEligibility/dtos/backoffice/SimulateResponse.js +6 -0
  87. package/bin/rewardsEligibility/enums/MetricsDimensionEnum.d.ts +8 -0
  88. package/bin/rewardsEligibility/enums/MetricsDimensionEnum.js +12 -0
  89. package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.d.ts +46 -1
  90. package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.js +46 -0
  91. package/bin/rewardsEligibility/enums/RuleValueTypeEnum.d.ts +9 -0
  92. package/bin/rewardsEligibility/enums/RuleValueTypeEnum.js +13 -0
  93. package/bin/rewardsEligibility/index.d.ts +34 -0
  94. package/bin/rewardsEligibility/index.js +35 -0
  95. package/package.json +1 -1
  96. package/src/group/dtos/GroupCreateRequest.ts +7 -1
  97. package/src/group/dtos/GroupResponse.ts +4 -0
  98. package/src/referral-business/dtos/GroupOwnersByGroupIdsRequest.ts +12 -0
  99. package/src/referral-business/dtos/GroupOwnersByGroupIdsResponse.ts +11 -0
  100. package/src/referral-business/index.ts +2 -0
  101. package/src/rewardsEligibility/constants/BackofficeLimits.ts +12 -0
  102. package/src/rewardsEligibility/dtos/CampaignAlerts.ts +9 -0
  103. package/src/rewardsEligibility/dtos/CampaignQuota.ts +13 -1
  104. package/src/rewardsEligibility/dtos/backoffice/ApproveRunRequest.ts +13 -0
  105. package/src/rewardsEligibility/dtos/backoffice/CampaignListResponse.ts +7 -0
  106. package/src/rewardsEligibility/dtos/backoffice/CampaignRequest.ts +53 -0
  107. package/src/rewardsEligibility/dtos/backoffice/CampaignResponse.ts +24 -0
  108. package/src/rewardsEligibility/dtos/backoffice/CampaignStatusRequest.ts +10 -0
  109. package/src/rewardsEligibility/dtos/backoffice/CampaignSummaryResponse.ts +26 -0
  110. package/src/rewardsEligibility/dtos/backoffice/CreateRunRequest.ts +30 -0
  111. package/src/rewardsEligibility/dtos/backoffice/CreateRunResponse.ts +10 -0
  112. package/src/rewardsEligibility/dtos/backoffice/EvaluationListResponse.ts +6 -0
  113. package/src/rewardsEligibility/dtos/backoffice/EvaluationRequest.ts +69 -0
  114. package/src/rewardsEligibility/dtos/backoffice/EvaluationResponse.ts +25 -0
  115. package/src/rewardsEligibility/dtos/backoffice/EvaluationStatusRequest.ts +10 -0
  116. package/src/rewardsEligibility/dtos/backoffice/EventTypeListResponse.ts +6 -0
  117. package/src/rewardsEligibility/dtos/backoffice/EventTypeRequest.ts +41 -0
  118. package/src/rewardsEligibility/dtos/backoffice/EventTypeResponse.ts +13 -0
  119. package/src/rewardsEligibility/dtos/backoffice/FailedConditionStatResponse.ts +8 -0
  120. package/src/rewardsEligibility/dtos/backoffice/InputTypeResponse.ts +7 -0
  121. package/src/rewardsEligibility/dtos/backoffice/MetricsPointResponse.ts +14 -0
  122. package/src/rewardsEligibility/dtos/backoffice/MetricsQuery.ts +10 -0
  123. package/src/rewardsEligibility/dtos/backoffice/PopulationRunRequest.ts +11 -0
  124. package/src/rewardsEligibility/dtos/backoffice/PopulationSourceResponse.ts +12 -0
  125. package/src/rewardsEligibility/dtos/backoffice/QuotaImpactResponse.ts +9 -0
  126. package/src/rewardsEligibility/dtos/backoffice/QuotaUsageResponse.ts +11 -0
  127. package/src/rewardsEligibility/dtos/backoffice/ResultTraceResponse.ts +34 -0
  128. package/src/rewardsEligibility/dtos/backoffice/RuleCatalogResponse.ts +28 -0
  129. package/src/rewardsEligibility/dtos/backoffice/RunListResponse.ts +6 -0
  130. package/src/rewardsEligibility/dtos/backoffice/RunResponse.ts +25 -0
  131. package/src/rewardsEligibility/dtos/backoffice/RunResultListResponse.ts +6 -0
  132. package/src/rewardsEligibility/dtos/backoffice/RunResultResponse.ts +23 -0
  133. package/src/rewardsEligibility/dtos/backoffice/SimulateRequest.ts +25 -0
  134. package/src/rewardsEligibility/dtos/backoffice/SimulateResponse.ts +12 -0
  135. package/src/rewardsEligibility/enums/MetricsDimensionEnum.ts +8 -0
  136. package/src/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.ts +47 -0
  137. package/src/rewardsEligibility/enums/RuleValueTypeEnum.ts +9 -0
  138. package/src/rewardsEligibility/index.ts +36 -0
@@ -1,4 +1,5 @@
1
1
  import { GroupStatus } from "../enums/GroupStatus"
2
+ import type { GroupOwnerItem } from "../../referral-business/dtos/GroupOwnersByGroupIdsResponse"
2
3
 
3
4
 
4
5
  export class GroupResponse {
@@ -17,6 +18,9 @@ export class GroupResponse {
17
18
  imageUrl?: string | null
18
19
  imageUrlSigned?: string | null
19
20
  parentGroupId: string
21
+ // Agente OWNER_<grupo> resuelto en vivo desde referral-business. null = sin owner o no se pudo resolver;
22
+ // ausente = la lectura no lo pidió. Reemplaza a leaderNames/leaderEmail/leaderDirectoryId (ya no se escriben).
23
+ owner?: GroupOwnerItem | null
20
24
  }
21
25
 
22
26
 
@@ -0,0 +1,12 @@
1
+ import { ArrayMaxSize, IsArray, IsString } from "class-validator";
2
+
3
+ // Tope de groupIds por request del endpoint batch de owners de grupo.
4
+ export const GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH = 100;
5
+
6
+ // Body de POST /private/agents/owners/by-group-ids; la lista vacía es válida y responde {}.
7
+ export class GroupOwnersByGroupIdsRequest {
8
+ @IsArray()
9
+ @ArrayMaxSize(GROUP_OWNERS_BY_GROUP_IDS_MAX_BATCH)
10
+ @IsString({ each: true })
11
+ groupIds!: string[];
12
+ }
@@ -0,0 +1,11 @@
1
+ // Agente OWNER_<grupo> de Agents_GT (excluye DELETE; ACTIVE gana). name/email null si no se pudieron resolver.
2
+ export interface GroupOwnerItem {
3
+ agentId: string;
4
+ directoryId: string;
5
+ name: string | null;
6
+ email: string | null;
7
+ status: string;
8
+ }
9
+
10
+ // Respuesta de POST /private/agents/owners/by-group-ids; un grupo sin owner no aparece.
11
+ export type GroupOwnersByGroupIdsResponse = Record<string, GroupOwnerItem>;
@@ -4,3 +4,5 @@ export * from './enums/AgentRoleEnum';
4
4
  //dtos
5
5
  export * from './dtos/AgentsByDirectoryIdsRequest';
6
6
  export * from './dtos/AgentsByDirectoryIdsResponse';
7
+ export * from './dtos/GroupOwnersByGroupIdsRequest';
8
+ export * from './dtos/GroupOwnersByGroupIdsResponse';
@@ -0,0 +1,12 @@
1
+ /** Id de campaña, evaluación (minúsculas, dígitos y guion; 2 a 64; sin `#` ni `:` porque entran en llaves compuestas y en la idempotencyKey). */
2
+ export const ELIGIBILITY_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,62}[a-z0-9]$/;
3
+ /** `eventKey` de un tipo de evento: MAYÚSCULAS con guion bajo (ej. `PHONE_SALES_CODE_REDEEMED`). */
4
+ export const EVENT_KEY_PATTERN = /^[A-Z][A-Z0-9_]{2,63}$/;
5
+ /** Fecha de vigencia de una campaña (UTC, inclusiva). */
6
+ export const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
7
+ /** Id de solicitud que genera el backoffice al abrir el formulario de una corrida manual (llave de idempotencia). */
8
+ export const REQUEST_ID_PATTERN = /^[A-Za-z0-9_-]{8,64}$/;
9
+ /** Cupos por campaña que caben junto a las reservas de una transacción (100 − 90 − registro del lote). */
10
+ export const MAX_QUOTAS_PER_CAMPAIGN = 9;
11
+ /** Tope de `limit` de los listados paginados. */
12
+ export const LIST_PAGE_MAX = 100;
@@ -1,4 +1,13 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { ArrayMaxSize, IsArray, IsNumber, Max, Min } from 'class-validator';
3
+
1
4
  /** Umbrales de consumo (0 a 1) que avisan a los operadores (spec B 5.6). */
2
5
  export class CampaignAlerts {
6
+ @Expose()
7
+ @IsArray()
8
+ @ArrayMaxSize(5)
9
+ @IsNumber({}, { each: true })
10
+ @Min(0.01, { each: true })
11
+ @Max(1, { each: true })
3
12
  thresholds: number[];
4
13
  }
@@ -1,9 +1,21 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsInt, IsString, Matches, Min } from 'class-validator';
1
3
  import { QuotaPeriodEnum } from '../enums/QuotaPeriodEnum';
2
4
 
3
5
  /** Un cupo de campania: cantidad maxima de premios (no dinero) en un periodo (spec B 5.6). */
4
6
  export class CampaignQuota {
5
- /** Unico dentro de la campania (ej. `primeros-500`). Entra en la llave del consumo (`{id}#{periodo}`). */
7
+ /** Unico dentro de la campania (ej. `primeros-500`). Entra en la llave del consumo (`{id}#{periodo}`): sin `#`. */
8
+ @Expose()
9
+ @IsString()
10
+ @Matches(/^[a-z0-9][a-z0-9-]{0,62}$/)
6
11
  id: string;
12
+
13
+ @Expose()
14
+ @IsInt()
15
+ @Min(1)
7
16
  limit: number;
17
+
18
+ @Expose()
19
+ @IsEnum(QuotaPeriodEnum)
8
20
  period: QuotaPeriodEnum;
9
21
  }
@@ -0,0 +1,13 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { ArrayMaxSize, IsArray, IsOptional, IsString, Matches } from 'class-validator';
3
+
4
+ /** `POST /runs/{id}/approve`: aprueba todo salvo los sujetos excluidos (`subjectKey`). */
5
+ export class ApproveRunRequest {
6
+ @Expose()
7
+ @IsOptional()
8
+ @IsArray()
9
+ @ArrayMaxSize(1000)
10
+ @IsString({ each: true })
11
+ @Matches(/^[A-Za-z0-9_-]{8,128}$/, { each: true })
12
+ excludeSubjectKeys?: string[];
13
+ }
@@ -0,0 +1,7 @@
1
+ import { CampaignResponse } from './CampaignResponse';
2
+
3
+ export class CampaignListResponse {
4
+ items: CampaignResponse[];
5
+ /** Cursor opaco de la página siguiente; ausente en la última. */
6
+ nextCursor?: string;
7
+ }
@@ -0,0 +1,53 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMaxSize, IsArray, IsDefined, IsEnum, IsNotEmpty, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
3
+ import { DATE_PATTERN, ELIGIBILITY_ID_PATTERN, MAX_QUOTAS_PER_CAMPAIGN } from '../../constants/BackofficeLimits';
4
+ import { QuotaExhaustedActionEnum } from '../../enums/QuotaExhaustedActionEnum';
5
+ import { CampaignAlerts } from '../CampaignAlerts';
6
+ import { CampaignQuota } from '../CampaignQuota';
7
+
8
+ /** Crear (POST) o reemplazar (PUT) una campaña. `status`, `pausedReason` y las fechas de auditoría las pone el servidor (el estado cambia con `POST /campaigns/{id}/status`). */
9
+ export class CampaignRequest {
10
+ @Expose()
11
+ @IsString()
12
+ @Matches(ELIGIBILITY_ID_PATTERN)
13
+ id: string;
14
+
15
+ @Expose()
16
+ @IsString()
17
+ @IsNotEmpty()
18
+ @MaxLength(120)
19
+ name: string;
20
+
21
+ /** Qué se quiere lograr (texto libre). */
22
+ @Expose()
23
+ @IsString()
24
+ @IsNotEmpty()
25
+ @MaxLength(500)
26
+ objective: string;
27
+
28
+ /** `AAAA-MM-DD` (UTC, inclusiva). */
29
+ @Expose()
30
+ @Matches(DATE_PATTERN)
31
+ startsAt: string;
32
+
33
+ @Expose()
34
+ @Matches(DATE_PATTERN)
35
+ endsAt: string;
36
+
37
+ @Expose()
38
+ @IsArray()
39
+ @ArrayMaxSize(MAX_QUOTAS_PER_CAMPAIGN)
40
+ @ValidateNested({ each: true })
41
+ @Type(() => CampaignQuota)
42
+ quotas: CampaignQuota[];
43
+
44
+ @Expose()
45
+ @IsEnum(QuotaExhaustedActionEnum)
46
+ onExhausted: QuotaExhaustedActionEnum;
47
+
48
+ @Expose()
49
+ @IsDefined()
50
+ @ValidateNested()
51
+ @Type(() => CampaignAlerts)
52
+ alerts: CampaignAlerts;
53
+ }
@@ -0,0 +1,24 @@
1
+ import { CampaignPausedReasonEnum } from '../../enums/CampaignPausedReasonEnum';
2
+ import { CampaignStatusEnum } from '../../enums/CampaignStatusEnum';
3
+ import { QuotaExhaustedActionEnum } from '../../enums/QuotaExhaustedActionEnum';
4
+ import { CampaignAlerts } from '../CampaignAlerts';
5
+ import { CampaignQuota } from '../CampaignQuota';
6
+
7
+ /** Una campaña (spec B 5.6). */
8
+ export class CampaignResponse {
9
+ id: string;
10
+ name: string;
11
+ objective: string;
12
+ status: CampaignStatusEnum;
13
+ /** Solo si `status` es `PAUSED`. */
14
+ pausedReason?: CampaignPausedReasonEnum;
15
+ startsAt: string;
16
+ endsAt: string;
17
+ quotas: CampaignQuota[];
18
+ onExhausted: QuotaExhaustedActionEnum;
19
+ alerts: CampaignAlerts;
20
+ /** Epoch en milisegundos. */
21
+ createdAt: number;
22
+ updatedAt: number;
23
+ updatedBy: string;
24
+ }
@@ -0,0 +1,10 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum } from 'class-validator';
3
+ import { CampaignStatusEnum } from '../../enums/CampaignStatusEnum';
4
+
5
+ /** Cuerpo de `POST /campaigns/{id}/status`: activar, pausar, terminar o archivar. */
6
+ export class CampaignStatusRequest {
7
+ @Expose()
8
+ @IsEnum(CampaignStatusEnum)
9
+ status: CampaignStatusEnum;
10
+ }
@@ -0,0 +1,26 @@
1
+ import { CampaignPausedReasonEnum } from '../../enums/CampaignPausedReasonEnum';
2
+ import { CampaignStatusEnum } from '../../enums/CampaignStatusEnum';
3
+
4
+ /** Fila de la tabla ejecutiva `GET /campaigns/summary` (spec 10.1). */
5
+ export class CampaignSummaryResponse {
6
+ campaignId: string;
7
+ name: string;
8
+ status: CampaignStatusEnum;
9
+ pausedReason?: CampaignPausedReasonEnum;
10
+ startsAt: string;
11
+ endsAt: string;
12
+ evaluated: number;
13
+ matched: number;
14
+ requested: number;
15
+ quotaExhausted: number;
16
+ /** Cupo más restrictivo, de 0 a 1 (0 si la campaña no tiene cupos). */
17
+ quotaUsed: number;
18
+ /** Ritmo diario de pedidos de los últimos 7 días (para proyectar el agotamiento). */
19
+ dailyRate: number;
20
+ /** `AAAA-MM-DD` estimada en que se agota el cupo más restrictivo al ritmo actual; ausente si no aplica. */
21
+ projectedExhaustionDate?: string;
22
+ /** Valor entregado: lo calcula rewards por `campaignId`; este lambda no lo informa. */
23
+ value?: { amount: number; currency: string }[];
24
+ /** Entregados de verdad según rewards; este lambda no lo informa. */
25
+ granted?: number;
26
+ }
@@ -0,0 +1,30 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { IsEnum, IsOptional, Matches, Validate, ValidateNested } from 'class-validator';
3
+ import { DynamicFormValue } from '../../../dynamicForm/types/DynamicFormValue';
4
+ import { IsDynamicFormValues } from '../../../dynamicForm/validators/IsDynamicFormValues';
5
+ import { REQUEST_ID_PATTERN } from '../../constants/BackofficeLimits';
6
+ import { RunModeEnum } from '../../enums/RunModeEnum';
7
+ import { PopulationRunRequest } from './PopulationRunRequest';
8
+
9
+ /** `POST /evaluations/{id}/runs` (spec 10): una corrida manual de UN sujeto (`inputs`) o de una población (`population`, fase 4). */
10
+ export class CreateRunRequest {
11
+ /** Id de solicitud que genera el backoffice al abrir el formulario: es la llave de idempotencia (doble clic = misma corrida). */
12
+ @Expose()
13
+ @Matches(REQUEST_ID_PATTERN)
14
+ requestId: string;
15
+
16
+ @Expose()
17
+ @IsEnum(RunModeEnum)
18
+ mode: RunModeEnum;
19
+
20
+ @Expose()
21
+ @IsOptional()
22
+ @Validate(IsDynamicFormValues)
23
+ inputs?: Record<string, DynamicFormValue>;
24
+
25
+ @Expose()
26
+ @IsOptional()
27
+ @ValidateNested()
28
+ @Type(() => PopulationRunRequest)
29
+ population?: PopulationRunRequest;
30
+ }
@@ -0,0 +1,10 @@
1
+ import { RunResponse } from './RunResponse';
2
+ import { RunResultResponse } from './RunResultResponse';
3
+
4
+ /** Respuesta de `POST /evaluations/{id}/runs`: la corrida y, si es de un sujeto, su resultado con traza (spec 7.3). */
5
+ export class CreateRunResponse {
6
+ run: RunResponse;
7
+ result?: RunResultResponse;
8
+ /** `true` si el `requestId` ya existía: es la MISMA corrida de antes. */
9
+ idempotentReplay: boolean;
10
+ }
@@ -0,0 +1,6 @@
1
+ import { EvaluationResponse } from './EvaluationResponse';
2
+
3
+ export class EvaluationListResponse {
4
+ items: EvaluationResponse[];
5
+ nextCursor?: string;
6
+ }
@@ -0,0 +1,69 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { ArrayMaxSize, ArrayMinSize, IsArray, IsNotEmpty, IsObject, IsString, Matches, MaxLength } from 'class-validator';
3
+ import { JsonValue } from '../../../common';
4
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
5
+ import { ELIGIBILITY_ID_PATTERN } from '../../constants/BackofficeLimits';
6
+ import { EvaluationReward } from '../EvaluationReward';
7
+ import { EvaluationTrigger } from '../EvaluationTrigger';
8
+ import { GrantPolicy } from '../GrantPolicy';
9
+
10
+ /**
11
+ * Crear (POST) o reemplazar (PUT) una evaluación (spec 5.1). `status`, `version` y auditoría los pone el servidor.
12
+ * Aquí solo se valida la FORMA gruesa; las reglas del spec 5.1 (llaves únicas, `validateRule`, paquete ACTIVO, disparadores…)
13
+ * las valida el lambda, que devuelve TODOS los problemas juntos.
14
+ */
15
+ export class EvaluationRequest {
16
+ @Expose()
17
+ @IsString()
18
+ @Matches(ELIGIBILITY_ID_PATTERN)
19
+ id: string;
20
+
21
+ @Expose()
22
+ @IsString()
23
+ @Matches(ELIGIBILITY_ID_PATTERN)
24
+ campaignId: string;
25
+
26
+ @Expose()
27
+ @IsString()
28
+ @IsNotEmpty()
29
+ @MaxLength(160)
30
+ name: string;
31
+
32
+ @Expose()
33
+ @IsString()
34
+ @MaxLength(500)
35
+ description: string;
36
+
37
+ /** Contrato de entrada (`InputField[]`, dominio `dynamicForm`). */
38
+ @Expose()
39
+ @IsArray()
40
+ @ArrayMaxSize(30)
41
+ @IsObject({ each: true })
42
+ inputs: InputField[];
43
+
44
+ /** Reglas de `@fiado/rules-engine` (`{ match, groups[] }`). */
45
+ @Expose()
46
+ @IsObject()
47
+ rules: { [key: string]: JsonValue };
48
+
49
+ /** Llave del input `DIRECTORY` al que se le entrega el premio. */
50
+ @Expose()
51
+ @IsString()
52
+ @IsNotEmpty()
53
+ beneficiaryInput: string;
54
+
55
+ @Expose()
56
+ @IsObject()
57
+ reward: EvaluationReward;
58
+
59
+ @Expose()
60
+ @IsObject()
61
+ grantPolicy: GrantPolicy;
62
+
63
+ @Expose()
64
+ @IsArray()
65
+ @ArrayMinSize(1)
66
+ @ArrayMaxSize(10)
67
+ @IsObject({ each: true })
68
+ triggers: EvaluationTrigger[];
69
+ }
@@ -0,0 +1,25 @@
1
+ import { JsonValue } from '../../../common';
2
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
3
+ import { EvaluationStatusEnum } from '../../enums/EvaluationStatusEnum';
4
+ import { EvaluationReward } from '../EvaluationReward';
5
+ import { EvaluationTrigger } from '../EvaluationTrigger';
6
+ import { GrantPolicy } from '../GrantPolicy';
7
+
8
+ export class EvaluationResponse {
9
+ id: string;
10
+ campaignId: string;
11
+ name: string;
12
+ description: string;
13
+ status: EvaluationStatusEnum;
14
+ /** Sube con cada edición de una evaluación `ACTIVE`. */
15
+ version: number;
16
+ inputs: InputField[];
17
+ rules: { [key: string]: JsonValue };
18
+ beneficiaryInput: string;
19
+ reward: EvaluationReward;
20
+ grantPolicy: GrantPolicy;
21
+ triggers: EvaluationTrigger[];
22
+ createdAt: number;
23
+ updatedAt: number;
24
+ updatedBy: string;
25
+ }
@@ -0,0 +1,10 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum } from 'class-validator';
3
+ import { EvaluationStatusEnum } from '../../enums/EvaluationStatusEnum';
4
+
5
+ /** Cuerpo de `POST /evaluations/{id}/status`: activar, pausar o archivar. */
6
+ export class EvaluationStatusRequest {
7
+ @Expose()
8
+ @IsEnum(EvaluationStatusEnum)
9
+ status: EvaluationStatusEnum;
10
+ }
@@ -0,0 +1,6 @@
1
+ import { EventTypeResponse } from './EventTypeResponse';
2
+
3
+ export class EventTypeListResponse {
4
+ items: EventTypeResponse[];
5
+ nextCursor?: string;
6
+ }
@@ -0,0 +1,41 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { ArrayMaxSize, IsArray, IsEnum, IsNotEmpty, IsObject, IsString, Matches, MaxLength } from 'class-validator';
3
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
4
+ import { RewardStatusEnum } from '../../../rewards/enums/RewardStatusEnum';
5
+ import { EVENT_KEY_PATTERN } from '../../constants/BackofficeLimits';
6
+
7
+ /** Alta (POST) o reemplazo (PUT) de un tipo de evento (spec 5.2). Los `fields` se validan a fondo en el lambda (`InputFieldValidationService`). */
8
+ export class EventTypeRequest {
9
+ @Expose()
10
+ @IsString()
11
+ @Matches(EVENT_KEY_PATTERN)
12
+ eventKey: string;
13
+
14
+ @Expose()
15
+ @IsString()
16
+ @IsNotEmpty()
17
+ @MaxLength(120)
18
+ name: string;
19
+
20
+ @Expose()
21
+ @IsString()
22
+ @MaxLength(500)
23
+ description: string;
24
+
25
+ /** Servicio que lo emite (ej. `phone-sales`). */
26
+ @Expose()
27
+ @IsString()
28
+ @IsNotEmpty()
29
+ @MaxLength(60)
30
+ emitter: string;
31
+
32
+ @Expose()
33
+ @IsArray()
34
+ @ArrayMaxSize(30)
35
+ @IsObject({ each: true })
36
+ fields: InputField[];
37
+
38
+ @Expose()
39
+ @IsEnum(RewardStatusEnum)
40
+ status: RewardStatusEnum;
41
+ }
@@ -0,0 +1,13 @@
1
+ import { InputField } from '../../../dynamicForm/dtos/InputField';
2
+ import { RewardStatusEnum } from '../../../rewards/enums/RewardStatusEnum';
3
+
4
+ export class EventTypeResponse {
5
+ eventKey: string;
6
+ name: string;
7
+ description: string;
8
+ emitter: string;
9
+ fields: InputField[];
10
+ status: RewardStatusEnum;
11
+ createdAt: number;
12
+ updatedAt: number;
13
+ }
@@ -0,0 +1,8 @@
1
+ /** Condición que más hace fallar la regla (`GET /metrics/failed-conditions`). */
2
+ export class FailedConditionStatResponse {
3
+ /** `{source}.{field}`. */
4
+ key: string;
5
+ /** Etiqueta legible (del catálogo de reglas; si no está, la propia `key`). */
6
+ label: string;
7
+ count: number;
8
+ }
@@ -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,28 @@
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. */
14
+ options?: { value: string; label: string }[];
15
+ }
16
+
17
+ export class RuleCatalogSourceResponse {
18
+ source: string;
19
+ label: string;
20
+ description: string;
21
+ fields: RuleCatalogFieldResponse[];
22
+ }
23
+
24
+ export class RuleCatalogResponse {
25
+ sources: RuleCatalogSourceResponse[];
26
+ /** Etiqueta legible de cada operador (`GTE` → «≥»). */
27
+ operators: Record<string, string>;
28
+ }
@@ -0,0 +1,6 @@
1
+ import { RunResponse } from './RunResponse';
2
+
3
+ export class RunListResponse {
4
+ items: RunResponse[];
5
+ nextCursor?: string;
6
+ }