@fiado/type-kit 3.509.0 → 3.511.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_test_/unit/dynamicForm/dynamicForm.test.ts +78 -0
- package/_test_/unit/rewards/enums.test.ts +103 -0
- package/_test_/unit/rewards/grantMessages.test.ts +129 -0
- package/_test_/unit/rewards/readResponses.test.ts +153 -0
- package/_test_/unit/rewardsEligibility/events.test.ts +130 -0
- package/bin/benefitCenter/dtos/InputField.d.ts +1 -13
- package/bin/benefitCenter/dtos/InputField.js +3 -3
- package/bin/benefitCenter/dtos/InputSchema.d.ts +1 -6
- package/bin/benefitCenter/dtos/InputSchema.js +3 -3
- package/bin/benefitCenter/dtos/InputValidation.d.ts +1 -8
- package/bin/benefitCenter/dtos/InputValidation.js +3 -3
- package/bin/benefitCenter/dtos/SelectOption.d.ts +1 -4
- package/bin/benefitCenter/dtos/SelectOption.js +3 -3
- package/bin/benefitCenter/enums/InputFieldTypeEnum.d.ts +1 -10
- package/bin/benefitCenter/enums/InputFieldTypeEnum.js +3 -11
- package/bin/common/index.d.ts +1 -0
- package/bin/common/index.js +2 -0
- package/bin/common/types/JsonValue.d.ts +7 -0
- package/bin/common/types/JsonValue.js +2 -0
- package/bin/dynamicForm/dtos/InputField.d.ts +15 -0
- package/bin/dynamicForm/dtos/InputField.js +6 -0
- package/bin/dynamicForm/dtos/InputSchema.d.ts +6 -0
- package/bin/dynamicForm/dtos/InputSchema.js +6 -0
- package/bin/dynamicForm/dtos/InputValidation.d.ts +8 -0
- package/bin/dynamicForm/dtos/InputValidation.js +6 -0
- package/bin/dynamicForm/dtos/SelectOption.d.ts +4 -0
- package/bin/dynamicForm/dtos/SelectOption.js +6 -0
- package/bin/dynamicForm/enums/InputFieldTypeEnum.d.ts +18 -0
- package/bin/dynamicForm/enums/InputFieldTypeEnum.js +22 -0
- package/bin/dynamicForm/helpers/isDynamicFormValue.d.ts +7 -0
- package/bin/dynamicForm/helpers/isDynamicFormValue.js +19 -0
- package/bin/dynamicForm/index.d.ts +8 -0
- package/bin/dynamicForm/index.js +29 -0
- package/bin/dynamicForm/types/DynamicFormValue.d.ts +10 -0
- package/bin/dynamicForm/types/DynamicFormValue.js +2 -0
- package/bin/dynamicForm/validators/IsDynamicFormValues.d.ts +7 -0
- package/bin/dynamicForm/validators/IsDynamicFormValues.js +26 -0
- package/bin/index.d.ts +3 -0
- package/bin/index.js +12 -1
- package/bin/rewards/constants/RewardsLimits.d.ts +2 -0
- package/bin/rewards/constants/RewardsLimits.js +5 -0
- package/bin/rewards/dtos/GrantFailedMessage.d.ts +13 -0
- package/bin/rewards/dtos/GrantFailedMessage.js +46 -0
- package/bin/rewards/dtos/GrantRequestedMessage.d.ts +21 -0
- package/bin/rewards/dtos/GrantRequestedMessage.js +61 -0
- package/bin/rewards/dtos/RewardChargeTo.d.ts +5 -0
- package/bin/rewards/dtos/RewardChargeTo.js +7 -0
- package/bin/rewards/dtos/RewardCost.d.ts +6 -0
- package/bin/rewards/dtos/RewardCost.js +7 -0
- package/bin/rewards/dtos/RewardDependency.d.ts +17 -0
- package/bin/rewards/dtos/RewardDependency.js +12 -0
- package/bin/rewards/dtos/RewardSource.d.ts +12 -0
- package/bin/rewards/dtos/RewardSource.js +40 -0
- package/bin/rewards/dtos/responses/GrantAttemptResponse.d.ts +15 -0
- package/bin/rewards/dtos/responses/GrantAttemptResponse.js +10 -0
- package/bin/rewards/dtos/responses/GrantItemResponse.d.ts +20 -0
- package/bin/rewards/dtos/responses/GrantItemResponse.js +6 -0
- package/bin/rewards/dtos/responses/GrantResponse.d.ts +23 -0
- package/bin/rewards/dtos/responses/GrantResponse.js +7 -0
- package/bin/rewards/dtos/responses/PackageContractItem.d.ts +12 -0
- package/bin/rewards/dtos/responses/PackageContractItem.js +7 -0
- package/bin/rewards/dtos/responses/PackageContractResponse.d.ts +13 -0
- package/bin/rewards/dtos/responses/PackageContractResponse.js +7 -0
- package/bin/rewards/enums/DependencyIfMissingEnum.d.ts +5 -0
- package/bin/rewards/enums/DependencyIfMissingEnum.js +9 -0
- package/bin/rewards/enums/GrantFailedReasonEnum.d.ts +15 -0
- package/bin/rewards/enums/GrantFailedReasonEnum.js +19 -0
- package/bin/rewards/enums/GrantItemStatusEnum.d.ts +11 -0
- package/bin/rewards/enums/GrantItemStatusEnum.js +15 -0
- package/bin/rewards/enums/GrantRejectReasonEnum.d.ts +11 -0
- package/bin/rewards/enums/GrantRejectReasonEnum.js +15 -0
- package/bin/rewards/enums/GrantStatusEnum.d.ts +8 -0
- package/bin/rewards/enums/GrantStatusEnum.js +12 -0
- package/bin/rewards/enums/ItemErrorCategoryEnum.d.ts +7 -0
- package/bin/rewards/enums/ItemErrorCategoryEnum.js +11 -0
- package/bin/rewards/enums/RewardStatusEnum.d.ts +4 -0
- package/bin/rewards/enums/RewardStatusEnum.js +8 -0
- package/bin/rewards/enums/RewardsErrorCodeEnum.d.ts +5 -0
- package/bin/rewards/enums/RewardsErrorCodeEnum.js +9 -0
- package/bin/rewards/enums/RewardsMessageTypeEnum.d.ts +4 -0
- package/bin/rewards/enums/RewardsMessageTypeEnum.js +8 -0
- package/bin/rewards/index.d.ts +24 -0
- package/bin/rewards/index.js +47 -0
- package/bin/rewards/types/RewardInputs.d.ts +3 -0
- package/bin/rewards/types/RewardInputs.js +2 -0
- package/bin/rewards/validators/IsRewardInputs.d.ts +7 -0
- package/bin/rewards/validators/IsRewardInputs.js +26 -0
- package/bin/rewards/validators/IsRewardTags.d.ts +7 -0
- package/bin/rewards/validators/IsRewardTags.js +28 -0
- package/bin/rewardsEligibility/dtos/EventRunResult.d.ts +11 -0
- package/bin/rewardsEligibility/dtos/EventRunResult.js +7 -0
- package/bin/rewardsEligibility/dtos/EventSource.d.ts +5 -0
- package/bin/rewardsEligibility/dtos/EventSource.js +30 -0
- package/bin/rewardsEligibility/dtos/GetRunResponse.d.ts +22 -0
- package/bin/rewardsEligibility/dtos/GetRunResponse.js +7 -0
- package/bin/rewardsEligibility/dtos/PostEventRequest.d.ts +14 -0
- package/bin/rewardsEligibility/dtos/PostEventRequest.js +47 -0
- package/bin/rewardsEligibility/dtos/PostEventResponse.d.ts +5 -0
- package/bin/rewardsEligibility/dtos/PostEventResponse.js +7 -0
- package/bin/rewardsEligibility/dtos/RunCounts.d.ts +12 -0
- package/bin/rewardsEligibility/dtos/RunCounts.js +7 -0
- package/bin/rewardsEligibility/dtos/RunResultItem.d.ts +16 -0
- package/bin/rewardsEligibility/dtos/RunResultItem.js +7 -0
- package/bin/rewardsEligibility/enums/EvaluationOutcomeEnum.d.ts +11 -0
- package/bin/rewardsEligibility/enums/EvaluationOutcomeEnum.js +15 -0
- package/bin/rewardsEligibility/enums/GrantRequestStatusEnum.d.ts +11 -0
- package/bin/rewardsEligibility/enums/GrantRequestStatusEnum.js +15 -0
- package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.d.ts +8 -0
- package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.js +12 -0
- package/bin/rewardsEligibility/enums/RunModeEnum.d.ts +4 -0
- package/bin/rewardsEligibility/enums/RunModeEnum.js +8 -0
- package/bin/rewardsEligibility/enums/RunStatusEnum.d.ts +9 -0
- package/bin/rewardsEligibility/enums/RunStatusEnum.js +13 -0
- package/bin/rewardsEligibility/enums/TriggerTypeEnum.d.ts +5 -0
- package/bin/rewardsEligibility/enums/TriggerTypeEnum.js +9 -0
- package/bin/rewardsEligibility/index.d.ts +13 -0
- package/bin/rewardsEligibility/index.js +31 -0
- package/package.json +1 -1
- package/src/benefitCenter/dtos/InputField.ts +2 -14
- package/src/benefitCenter/dtos/InputSchema.ts +2 -7
- package/src/benefitCenter/dtos/InputValidation.ts +2 -8
- package/src/benefitCenter/dtos/SelectOption.ts +2 -4
- package/src/benefitCenter/enums/InputFieldTypeEnum.ts +2 -10
- package/src/common/index.ts +4 -1
- package/src/common/types/JsonValue.ts +5 -0
- package/src/dynamicForm/dtos/InputField.ts +16 -0
- package/src/dynamicForm/dtos/InputSchema.ts +7 -0
- package/src/dynamicForm/dtos/InputValidation.ts +8 -0
- package/src/dynamicForm/dtos/SelectOption.ts +4 -0
- package/src/dynamicForm/enums/InputFieldTypeEnum.ts +18 -0
- package/src/dynamicForm/helpers/isDynamicFormValue.ts +16 -0
- package/src/dynamicForm/index.ts +17 -0
- package/src/dynamicForm/types/DynamicFormValue.ts +8 -0
- package/src/dynamicForm/validators/IsDynamicFormValues.ts +16 -0
- package/src/index.ts +14 -0
- package/src/rewards/constants/RewardsLimits.ts +2 -0
- package/src/rewards/dtos/GrantFailedMessage.ts +29 -0
- package/src/rewards/dtos/GrantRequestedMessage.ts +46 -0
- package/src/rewards/dtos/RewardChargeTo.ts +5 -0
- package/src/rewards/dtos/RewardCost.ts +7 -0
- package/src/rewards/dtos/RewardDependency.ts +18 -0
- package/src/rewards/dtos/RewardSource.ts +27 -0
- package/src/rewards/dtos/responses/GrantAttemptResponse.ts +16 -0
- package/src/rewards/dtos/responses/GrantItemResponse.ts +21 -0
- package/src/rewards/dtos/responses/GrantResponse.ts +24 -0
- package/src/rewards/dtos/responses/PackageContractItem.ts +13 -0
- package/src/rewards/dtos/responses/PackageContractResponse.ts +14 -0
- package/src/rewards/enums/DependencyIfMissingEnum.ts +5 -0
- package/src/rewards/enums/GrantFailedReasonEnum.ts +15 -0
- package/src/rewards/enums/GrantItemStatusEnum.ts +11 -0
- package/src/rewards/enums/GrantRejectReasonEnum.ts +11 -0
- package/src/rewards/enums/GrantStatusEnum.ts +8 -0
- package/src/rewards/enums/ItemErrorCategoryEnum.ts +7 -0
- package/src/rewards/enums/RewardStatusEnum.ts +4 -0
- package/src/rewards/enums/RewardsErrorCodeEnum.ts +5 -0
- package/src/rewards/enums/RewardsMessageTypeEnum.ts +4 -0
- package/src/rewards/index.ts +37 -0
- package/src/rewards/types/RewardInputs.ts +4 -0
- package/src/rewards/validators/IsRewardInputs.ts +18 -0
- package/src/rewards/validators/IsRewardTags.ts +18 -0
- package/src/rewardsEligibility/dtos/EventRunResult.ts +12 -0
- package/src/rewardsEligibility/dtos/EventSource.ts +15 -0
- package/src/rewardsEligibility/dtos/GetRunResponse.ts +23 -0
- package/src/rewardsEligibility/dtos/PostEventRequest.ts +32 -0
- package/src/rewardsEligibility/dtos/PostEventResponse.ts +6 -0
- package/src/rewardsEligibility/dtos/RunCounts.ts +12 -0
- package/src/rewardsEligibility/dtos/RunResultItem.ts +17 -0
- package/src/rewardsEligibility/enums/EvaluationOutcomeEnum.ts +11 -0
- package/src/rewardsEligibility/enums/GrantRequestStatusEnum.ts +11 -0
- package/src/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.ts +8 -0
- package/src/rewardsEligibility/enums/RunModeEnum.ts +4 -0
- package/src/rewardsEligibility/enums/RunStatusEnum.ts +9 -0
- package/src/rewardsEligibility/enums/TriggerTypeEnum.ts +5 -0
- package/src/rewardsEligibility/index.ts +16 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InputField } from '../../dynamicForm/dtos/InputField';
|
|
2
|
+
import { DependencyIfMissingEnum } from '../enums/DependencyIfMissingEnum';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Una dependencia de una recompensa: lo que quien consume debe enviar para poder entregarla.
|
|
6
|
+
* Adopta la forma de `InputField` (formulario dinámico compartido) y suma los campos propios
|
|
7
|
+
* de rewards (spec A 5.1).
|
|
8
|
+
*/
|
|
9
|
+
export class RewardDependency extends InputField {
|
|
10
|
+
/** Condición que la vuelve necesaria (sobre otras dependencias), si aplica. */
|
|
11
|
+
requiredWhen?: string;
|
|
12
|
+
/** Qué pasa si falta cuando se necesitaba. Por defecto, REJECT. */
|
|
13
|
+
ifMissing?: DependencyIfMissingEnum;
|
|
14
|
+
/** De dónde la saca el lambda solo cuando no se envía. */
|
|
15
|
+
resolvedFrom?: string;
|
|
16
|
+
/** Texto corto para quien consume. */
|
|
17
|
+
description?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Expose } from 'class-transformer';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString, Validate } from 'class-validator';
|
|
3
|
+
import { IsRewardTags } from '../validators/IsRewardTags';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Quién pide la entrega. El lambda no interpreta `reference` ni `tags`: los guarda y los usa como
|
|
7
|
+
* filtro/auditoría (spec A D1, D10).
|
|
8
|
+
*/
|
|
9
|
+
export class RewardSource {
|
|
10
|
+
/** Servicio llamador (ej. `rewards-eligibility`). Entra en el `grantId`. */
|
|
11
|
+
@Expose()
|
|
12
|
+
@IsString()
|
|
13
|
+
@IsNotEmpty()
|
|
14
|
+
service!: string;
|
|
15
|
+
|
|
16
|
+
/** Referencia opaca del llamador (ej. `runId`). */
|
|
17
|
+
@Expose()
|
|
18
|
+
@IsString()
|
|
19
|
+
@IsNotEmpty()
|
|
20
|
+
reference!: string;
|
|
21
|
+
|
|
22
|
+
/** Etiquetas opacas (ej. `campaignId`, `evaluationId`). Máx. 10 llaves. */
|
|
23
|
+
@Expose()
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@Validate(IsRewardTags)
|
|
26
|
+
tags?: Record<string, string>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ItemErrorCategoryEnum } from '../../enums/ItemErrorCategoryEnum';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Un intento de ejecutar un ítem. Sin `providerResponse`, `requestSnapshot` ni `correlationIds`:
|
|
5
|
+
* contienen PII y solo se leen en el backoffice (spec A R2).
|
|
6
|
+
*/
|
|
7
|
+
export class GrantAttemptResponse {
|
|
8
|
+
attempt: number;
|
|
9
|
+
/** Epoch en milisegundos. */
|
|
10
|
+
startedAt: number;
|
|
11
|
+
/** Epoch en milisegundos. */
|
|
12
|
+
finishedAt: number;
|
|
13
|
+
errorCategory?: ItemErrorCategoryEnum;
|
|
14
|
+
errorCode?: string;
|
|
15
|
+
httpStatus?: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GrantItemStatusEnum } from '../../enums/GrantItemStatusEnum';
|
|
2
|
+
import { RewardChargeTo } from '../RewardChargeTo';
|
|
3
|
+
import { RewardCost } from '../RewardCost';
|
|
4
|
+
import { GrantAttemptResponse } from './GrantAttemptResponse';
|
|
5
|
+
|
|
6
|
+
export class GrantItemResponse {
|
|
7
|
+
itemKey: string;
|
|
8
|
+
catalogItemId: string;
|
|
9
|
+
status: GrantItemStatusEnum;
|
|
10
|
+
/** Solo si `status` es SKIPPED (ej. `DEPENDENCY_MISSING`, `ITEM_NOT_APPLICABLE`). */
|
|
11
|
+
skipReason?: string;
|
|
12
|
+
chargeTo: RewardChargeTo;
|
|
13
|
+
cost: RewardCost;
|
|
14
|
+
attemptCount: number;
|
|
15
|
+
/** Epoch en milisegundos; solo si `status` es GRANTED. */
|
|
16
|
+
grantedAt?: number;
|
|
17
|
+
/** Referencias del proveedor (ej. `{ transactionNumber }`). */
|
|
18
|
+
externalRef?: Record<string, string>;
|
|
19
|
+
/** Últimos intentos (máx. 5). */
|
|
20
|
+
attempts: GrantAttemptResponse[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { GrantRejectReasonEnum } from '../../enums/GrantRejectReasonEnum';
|
|
2
|
+
import { GrantStatusEnum } from '../../enums/GrantStatusEnum';
|
|
3
|
+
import { RewardSource } from '../RewardSource';
|
|
4
|
+
import { GrantItemResponse } from './GrantItemResponse';
|
|
5
|
+
|
|
6
|
+
/** Respuesta de `GET /grants/{id}`: estado de la entrega y de cada ítem (spec A 6.4). */
|
|
7
|
+
export class GrantResponse {
|
|
8
|
+
id: string;
|
|
9
|
+
directoryId: string;
|
|
10
|
+
packageId: string;
|
|
11
|
+
/** Versión del paquete congelada al crear la entrega. */
|
|
12
|
+
packageVersion: number;
|
|
13
|
+
source: RewardSource;
|
|
14
|
+
status: GrantStatusEnum;
|
|
15
|
+
/** Solo si `status` es REJECTED. */
|
|
16
|
+
rejectReason?: GrantRejectReasonEnum;
|
|
17
|
+
/** Solo si `rejectReason` es `INPUT_INVALID`: claves de los campos inválidos, `itemKey.inputKey` (spec A §6.2). */
|
|
18
|
+
invalidFields?: string[];
|
|
19
|
+
items: GrantItemResponse[];
|
|
20
|
+
/** Epoch en milisegundos. */
|
|
21
|
+
createdAt: number;
|
|
22
|
+
/** Epoch en milisegundos. */
|
|
23
|
+
updatedAt: number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RewardCost } from '../RewardCost';
|
|
2
|
+
import { RewardDependency } from '../RewardDependency';
|
|
3
|
+
|
|
4
|
+
/** Una recompensa dentro del contrato de un paquete (spec A 6.3). */
|
|
5
|
+
export class PackageContractItem {
|
|
6
|
+
itemKey: string;
|
|
7
|
+
catalogItemId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
cost: RewardCost;
|
|
11
|
+
/** Lo que el llamador debe enviar en `inputs[itemKey]`. */
|
|
12
|
+
dependencies: RewardDependency[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RewardStatusEnum } from '../../enums/RewardStatusEnum';
|
|
2
|
+
import { RewardCost } from '../RewardCost';
|
|
3
|
+
import { PackageContractItem } from './PackageContractItem';
|
|
4
|
+
|
|
5
|
+
/** Respuesta de `GET /packages/{id}`: el contrato de entrada del paquete (spec A 6.3). */
|
|
6
|
+
export class PackageContractResponse {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
status: RewardStatusEnum;
|
|
10
|
+
version: number;
|
|
11
|
+
items: PackageContractItem[];
|
|
12
|
+
/** Costo total declarado del paquete, por moneda (sin conversión). */
|
|
13
|
+
totalCost: RewardCost[];
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `reason` de `GRANT_FAILED` (spec A 6.5). `INPUT_INVALID`, `PACKAGE_NOT_FOUND` y `PACKAGE_INACTIVE` son las
|
|
3
|
+
* de `GrantRejectReasonEnum` (entrega REJECTED); `ITEMS_FAILED` es una entrega FAILED: ningún ítem se entregó.
|
|
4
|
+
* Decisión P-2 aprobada.
|
|
5
|
+
*
|
|
6
|
+
* Excepción: un REJECTED por `GrantRejectReasonEnum.UNSUPPORTED_REWARD_TYPE` se avisa como `INPUT_INVALID`
|
|
7
|
+
* (el paquete pide algo que el núcleo no puede ejecutar, o sea una solicitud inválida para este lambda).
|
|
8
|
+
* No se agregó un valor nuevo para no ampliar el contrato de la cola.
|
|
9
|
+
*/
|
|
10
|
+
export enum GrantFailedReasonEnum {
|
|
11
|
+
INPUT_INVALID = 'INPUT_INVALID',
|
|
12
|
+
PACKAGE_NOT_FOUND = 'PACKAGE_NOT_FOUND',
|
|
13
|
+
PACKAGE_INACTIVE = 'PACKAGE_INACTIVE',
|
|
14
|
+
ITEMS_FAILED = 'ITEMS_FAILED',
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export enum GrantItemStatusEnum {
|
|
2
|
+
PENDING = 'PENDING',
|
|
3
|
+
/**
|
|
4
|
+
* Reclamado por el worker antes de ejecutar; si un reintento lo encuentra así, el envío pudo haber
|
|
5
|
+
* ocurrido y el adaptador debe reconciliar antes de reintentar.
|
|
6
|
+
*/
|
|
7
|
+
PROCESSING = 'PROCESSING',
|
|
8
|
+
GRANTED = 'GRANTED',
|
|
9
|
+
FAILED = 'FAILED',
|
|
10
|
+
SKIPPED = 'SKIPPED',
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Por qué una solicitud quedó REJECTED (spec A 6.2). */
|
|
2
|
+
export enum GrantRejectReasonEnum {
|
|
3
|
+
INPUT_INVALID = 'INPUT_INVALID',
|
|
4
|
+
PACKAGE_NOT_FOUND = 'PACKAGE_NOT_FOUND',
|
|
5
|
+
PACKAGE_INACTIVE = 'PACKAGE_INACTIVE',
|
|
6
|
+
/**
|
|
7
|
+
* El paquete contiene un tipo de recompensa sin adaptador registrado; se rechaza antes de ejecutar
|
|
8
|
+
* cualquier ítem.
|
|
9
|
+
*/
|
|
10
|
+
UNSUPPORTED_REWARD_TYPE = 'UNSUPPORTED_REWARD_TYPE',
|
|
11
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//Enums
|
|
2
|
+
export * from './enums/RewardsMessageTypeEnum';
|
|
3
|
+
export * from './enums/GrantStatusEnum';
|
|
4
|
+
export * from './enums/GrantItemStatusEnum';
|
|
5
|
+
export * from './enums/GrantRejectReasonEnum';
|
|
6
|
+
export * from './enums/GrantFailedReasonEnum';
|
|
7
|
+
export * from './enums/ItemErrorCategoryEnum';
|
|
8
|
+
export * from './enums/RewardStatusEnum';
|
|
9
|
+
export * from './enums/DependencyIfMissingEnum';
|
|
10
|
+
export * from './enums/RewardsErrorCodeEnum';
|
|
11
|
+
|
|
12
|
+
//Types
|
|
13
|
+
export * from './types/RewardInputs';
|
|
14
|
+
|
|
15
|
+
//DTOs
|
|
16
|
+
export * from './dtos/RewardCost';
|
|
17
|
+
export * from './dtos/RewardChargeTo';
|
|
18
|
+
export * from './dtos/RewardDependency';
|
|
19
|
+
|
|
20
|
+
//Constants
|
|
21
|
+
export * from './constants/RewardsLimits';
|
|
22
|
+
|
|
23
|
+
//Validators
|
|
24
|
+
export * from './validators/IsRewardTags';
|
|
25
|
+
export * from './validators/IsRewardInputs';
|
|
26
|
+
|
|
27
|
+
//Messages (colas compartidas)
|
|
28
|
+
export * from './dtos/RewardSource';
|
|
29
|
+
export * from './dtos/GrantRequestedMessage';
|
|
30
|
+
export * from './dtos/GrantFailedMessage';
|
|
31
|
+
|
|
32
|
+
//Responses (lecturas privadas)
|
|
33
|
+
export * from './dtos/responses/PackageContractItem';
|
|
34
|
+
export * from './dtos/responses/PackageContractResponse';
|
|
35
|
+
export * from './dtos/responses/GrantAttemptResponse';
|
|
36
|
+
export * from './dtos/responses/GrantItemResponse';
|
|
37
|
+
export * from './dtos/responses/GrantResponse';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import { JsonValue } from '../../common/types/JsonValue';
|
|
3
|
+
import { isDynamicFormValue, isPlainObject } from '../../dynamicForm/helpers/isDynamicFormValue';
|
|
4
|
+
|
|
5
|
+
/** `inputs`: `itemKey → inputKey → valor` (dos niveles exactos; la hoja es un DynamicFormValue). */
|
|
6
|
+
@ValidatorConstraint({ name: 'IsRewardInputs', async: false })
|
|
7
|
+
export class IsRewardInputs implements ValidatorConstraintInterface {
|
|
8
|
+
validate(value: JsonValue, _args: ValidationArguments): boolean {
|
|
9
|
+
if (!isPlainObject(value)) return false;
|
|
10
|
+
return Object.values(value).every(
|
|
11
|
+
(porItem) => isPlainObject(porItem) && Object.values(porItem).every(isDynamicFormValue),
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
defaultMessage(_args: ValidationArguments): string {
|
|
16
|
+
return 'inputs debe ser un mapa itemKey → (inputKey → string | number | boolean | {from, to})';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import { JsonValue } from '../../common/types/JsonValue';
|
|
3
|
+
import { isPlainObject } from '../../dynamicForm/helpers/isDynamicFormValue';
|
|
4
|
+
import { REWARD_TAGS_MAX_KEYS } from '../constants/RewardsLimits';
|
|
5
|
+
|
|
6
|
+
/** `source.tags`: mapa texto → texto, máximo `REWARD_TAGS_MAX_KEYS` llaves. */
|
|
7
|
+
@ValidatorConstraint({ name: 'IsRewardTags', async: false })
|
|
8
|
+
export class IsRewardTags implements ValidatorConstraintInterface {
|
|
9
|
+
validate(value: JsonValue, _args: ValidationArguments): boolean {
|
|
10
|
+
if (!isPlainObject(value)) return false;
|
|
11
|
+
const entries = Object.entries(value);
|
|
12
|
+
return entries.length <= REWARD_TAGS_MAX_KEYS && entries.every(([, tag]) => typeof tag === 'string');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
defaultMessage(_args: ValidationArguments): string {
|
|
16
|
+
return `tags debe ser un mapa texto → texto de máximo ${REWARD_TAGS_MAX_KEYS} llaves`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EvaluationOutcomeEnum } from '../enums/EvaluationOutcomeEnum';
|
|
2
|
+
import { GrantRequestStatusEnum } from '../enums/GrantRequestStatusEnum';
|
|
3
|
+
|
|
4
|
+
/** Resultado de una evaluación suscrita al evento (una corrida con lote de 1). */
|
|
5
|
+
export class EventRunResult {
|
|
6
|
+
evaluationId: string;
|
|
7
|
+
runId: string;
|
|
8
|
+
outcome: EvaluationOutcomeEnum;
|
|
9
|
+
grantStatus: GrantRequestStatusEnum;
|
|
10
|
+
/** true si el `idempotencyKey` ya había creado esta corrida. */
|
|
11
|
+
idempotentReplay: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Expose } from 'class-transformer';
|
|
2
|
+
import { IsNotEmpty, IsString } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
/** Quién emite el evento. El validador no interpreta `reference`. */
|
|
5
|
+
export class EventSource {
|
|
6
|
+
@Expose()
|
|
7
|
+
@IsString()
|
|
8
|
+
@IsNotEmpty()
|
|
9
|
+
service!: string;
|
|
10
|
+
|
|
11
|
+
@Expose()
|
|
12
|
+
@IsString()
|
|
13
|
+
@IsNotEmpty()
|
|
14
|
+
reference!: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RunModeEnum } from '../enums/RunModeEnum';
|
|
2
|
+
import { RunStatusEnum } from '../enums/RunStatusEnum';
|
|
3
|
+
import { TriggerTypeEnum } from '../enums/TriggerTypeEnum';
|
|
4
|
+
import { RunCounts } from './RunCounts';
|
|
5
|
+
import { RunResultItem } from './RunResultItem';
|
|
6
|
+
|
|
7
|
+
/** Respuesta de `GET /runs/{id}` (spec B 6.2). */
|
|
8
|
+
export class GetRunResponse {
|
|
9
|
+
runId: string;
|
|
10
|
+
evaluationId: string;
|
|
11
|
+
trigger: TriggerTypeEnum;
|
|
12
|
+
mode: RunModeEnum;
|
|
13
|
+
status: RunStatusEnum;
|
|
14
|
+
counts: RunCounts;
|
|
15
|
+
/** Una página de resultados. */
|
|
16
|
+
results: RunResultItem[];
|
|
17
|
+
/** Presente si hay más resultados. */
|
|
18
|
+
nextToken?: string;
|
|
19
|
+
/** Epoch en milisegundos. */
|
|
20
|
+
createdAt: number;
|
|
21
|
+
/** Epoch en milisegundos. */
|
|
22
|
+
updatedAt: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Expose, Type } from 'class-transformer';
|
|
2
|
+
import { IsNotEmpty, IsString, Validate, ValidateNested } from 'class-validator';
|
|
3
|
+
import { DynamicFormValue } from '../../dynamicForm/types/DynamicFormValue';
|
|
4
|
+
import { IsDynamicFormValues } from '../../dynamicForm/validators/IsDynamicFormValues';
|
|
5
|
+
import { EventSource } from './EventSource';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Cuerpo de `POST /events` (spec B 6.1). El emisor informa qué pasó y quién participó; NO decide
|
|
9
|
+
* la elegibilidad (E3). Parsear con `excludeExtraneousValues: true`: cualquier campo extra
|
|
10
|
+
* (p. ej. `prefetchedFacts`) se descarta.
|
|
11
|
+
*/
|
|
12
|
+
export class PostEventRequest {
|
|
13
|
+
@Expose()
|
|
14
|
+
@IsString()
|
|
15
|
+
@IsNotEmpty()
|
|
16
|
+
eventKey!: string;
|
|
17
|
+
|
|
18
|
+
@Expose()
|
|
19
|
+
@IsString()
|
|
20
|
+
@IsNotEmpty()
|
|
21
|
+
idempotencyKey!: string;
|
|
22
|
+
|
|
23
|
+
@Expose()
|
|
24
|
+
@ValidateNested()
|
|
25
|
+
@Type(() => EventSource)
|
|
26
|
+
source!: EventSource;
|
|
27
|
+
|
|
28
|
+
/** Los `fields` del tipo de evento (`RewardEventType_GT`), con su valor. */
|
|
29
|
+
@Expose()
|
|
30
|
+
@Validate(IsDynamicFormValues)
|
|
31
|
+
inputs!: Record<string, DynamicFormValue>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Conteos de una corrida (mismos nombres que las métricas, spec B 5.7). */
|
|
2
|
+
export class RunCounts {
|
|
3
|
+
evaluated: number;
|
|
4
|
+
match: number;
|
|
5
|
+
noMatch: number;
|
|
6
|
+
error: number;
|
|
7
|
+
alreadyGranted: number;
|
|
8
|
+
quotaExhausted: number;
|
|
9
|
+
excluded: number;
|
|
10
|
+
requested: number;
|
|
11
|
+
requestFailed: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EvaluationOutcomeEnum } from '../enums/EvaluationOutcomeEnum';
|
|
2
|
+
import { GrantRequestStatusEnum } from '../enums/GrantRequestStatusEnum';
|
|
3
|
+
|
|
4
|
+
/** Un resultado por sujeto, SIN traza (la traza es del backoffice). Asumido hasta cerrar P-7. */
|
|
5
|
+
export class RunResultItem {
|
|
6
|
+
subjectKey: string;
|
|
7
|
+
beneficiaryDirectoryId: string;
|
|
8
|
+
campaignId: string;
|
|
9
|
+
evaluationId: string;
|
|
10
|
+
packageId: string;
|
|
11
|
+
outcome: EvaluationOutcomeEnum;
|
|
12
|
+
grantStatus: GrantRequestStatusEnum;
|
|
13
|
+
/** `grantIdFor("rewards-eligibility", idempotencyKey)`; cruza con `GET /grants/{id}` de rewards. */
|
|
14
|
+
grantId?: string;
|
|
15
|
+
/** Solo si `outcome` es ERROR. */
|
|
16
|
+
errorMessage?: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export enum EvaluationOutcomeEnum {
|
|
2
|
+
MATCH = 'MATCH',
|
|
3
|
+
NO_MATCH = 'NO_MATCH',
|
|
4
|
+
ERROR = 'ERROR',
|
|
5
|
+
/** La política de frecuencia lo bloqueó. */
|
|
6
|
+
ALREADY_GRANTED = 'ALREADY_GRANTED',
|
|
7
|
+
/** Calificó, pero la campaña no tenía cupo. */
|
|
8
|
+
QUOTA_EXHAUSTED = 'QUOTA_EXHAUSTED',
|
|
9
|
+
/** El operador lo sacó al aprobar. */
|
|
10
|
+
EXCLUDED = 'EXCLUDED',
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export enum GrantRequestStatusEnum {
|
|
2
|
+
NOT_APPLICABLE = 'NOT_APPLICABLE',
|
|
3
|
+
PENDING_APPROVAL = 'PENDING_APPROVAL',
|
|
4
|
+
/** Reservado, esperando su tramo de publicación. */
|
|
5
|
+
QUEUED = 'QUEUED',
|
|
6
|
+
/** Publicado en RewardsGrantQueue al instante (en línea). */
|
|
7
|
+
REQUESTED = 'REQUESTED',
|
|
8
|
+
/** La publicación falló o llegó GRANT_FAILED. */
|
|
9
|
+
REQUEST_FAILED = 'REQUEST_FAILED',
|
|
10
|
+
CANCELLED = 'CANCELLED',
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export enum RewardsEligibilityErrorCodeEnum {
|
|
2
|
+
/** 400: faltan campos obligatorios del evento o tienen tipo inválido. */
|
|
3
|
+
INPUT_INVALID = 'INPUT_INVALID',
|
|
4
|
+
/** 404: el eventKey no existe o está inactivo. */
|
|
5
|
+
EVENT_TYPE_NOT_FOUND = 'EVENT_TYPE_NOT_FOUND',
|
|
6
|
+
/** 404: GET /runs/{id} sin corrida. */
|
|
7
|
+
RUN_NOT_FOUND = 'RUN_NOT_FOUND',
|
|
8
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//Enums
|
|
2
|
+
export * from './enums/EvaluationOutcomeEnum';
|
|
3
|
+
export * from './enums/GrantRequestStatusEnum';
|
|
4
|
+
export * from './enums/RunStatusEnum';
|
|
5
|
+
export * from './enums/RunModeEnum';
|
|
6
|
+
export * from './enums/TriggerTypeEnum';
|
|
7
|
+
export * from './enums/RewardsEligibilityErrorCodeEnum';
|
|
8
|
+
|
|
9
|
+
//DTOs
|
|
10
|
+
export * from './dtos/EventSource';
|
|
11
|
+
export * from './dtos/PostEventRequest';
|
|
12
|
+
export * from './dtos/EventRunResult';
|
|
13
|
+
export * from './dtos/PostEventResponse';
|
|
14
|
+
export * from './dtos/RunCounts';
|
|
15
|
+
export * from './dtos/RunResultItem';
|
|
16
|
+
export * from './dtos/GetRunResponse';
|