@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.
Files changed (174) hide show
  1. package/_test_/unit/dynamicForm/dynamicForm.test.ts +78 -0
  2. package/_test_/unit/rewards/enums.test.ts +103 -0
  3. package/_test_/unit/rewards/grantMessages.test.ts +129 -0
  4. package/_test_/unit/rewards/readResponses.test.ts +153 -0
  5. package/_test_/unit/rewardsEligibility/events.test.ts +130 -0
  6. package/bin/benefitCenter/dtos/InputField.d.ts +1 -13
  7. package/bin/benefitCenter/dtos/InputField.js +3 -3
  8. package/bin/benefitCenter/dtos/InputSchema.d.ts +1 -6
  9. package/bin/benefitCenter/dtos/InputSchema.js +3 -3
  10. package/bin/benefitCenter/dtos/InputValidation.d.ts +1 -8
  11. package/bin/benefitCenter/dtos/InputValidation.js +3 -3
  12. package/bin/benefitCenter/dtos/SelectOption.d.ts +1 -4
  13. package/bin/benefitCenter/dtos/SelectOption.js +3 -3
  14. package/bin/benefitCenter/enums/InputFieldTypeEnum.d.ts +1 -10
  15. package/bin/benefitCenter/enums/InputFieldTypeEnum.js +3 -11
  16. package/bin/common/index.d.ts +1 -0
  17. package/bin/common/index.js +2 -0
  18. package/bin/common/types/JsonValue.d.ts +7 -0
  19. package/bin/common/types/JsonValue.js +2 -0
  20. package/bin/dynamicForm/dtos/InputField.d.ts +15 -0
  21. package/bin/dynamicForm/dtos/InputField.js +6 -0
  22. package/bin/dynamicForm/dtos/InputSchema.d.ts +6 -0
  23. package/bin/dynamicForm/dtos/InputSchema.js +6 -0
  24. package/bin/dynamicForm/dtos/InputValidation.d.ts +8 -0
  25. package/bin/dynamicForm/dtos/InputValidation.js +6 -0
  26. package/bin/dynamicForm/dtos/SelectOption.d.ts +4 -0
  27. package/bin/dynamicForm/dtos/SelectOption.js +6 -0
  28. package/bin/dynamicForm/enums/InputFieldTypeEnum.d.ts +18 -0
  29. package/bin/dynamicForm/enums/InputFieldTypeEnum.js +22 -0
  30. package/bin/dynamicForm/helpers/isDynamicFormValue.d.ts +7 -0
  31. package/bin/dynamicForm/helpers/isDynamicFormValue.js +19 -0
  32. package/bin/dynamicForm/index.d.ts +8 -0
  33. package/bin/dynamicForm/index.js +29 -0
  34. package/bin/dynamicForm/types/DynamicFormValue.d.ts +10 -0
  35. package/bin/dynamicForm/types/DynamicFormValue.js +2 -0
  36. package/bin/dynamicForm/validators/IsDynamicFormValues.d.ts +7 -0
  37. package/bin/dynamicForm/validators/IsDynamicFormValues.js +26 -0
  38. package/bin/index.d.ts +3 -0
  39. package/bin/index.js +12 -1
  40. package/bin/rewards/constants/RewardsLimits.d.ts +2 -0
  41. package/bin/rewards/constants/RewardsLimits.js +5 -0
  42. package/bin/rewards/dtos/GrantFailedMessage.d.ts +13 -0
  43. package/bin/rewards/dtos/GrantFailedMessage.js +46 -0
  44. package/bin/rewards/dtos/GrantRequestedMessage.d.ts +21 -0
  45. package/bin/rewards/dtos/GrantRequestedMessage.js +61 -0
  46. package/bin/rewards/dtos/RewardChargeTo.d.ts +5 -0
  47. package/bin/rewards/dtos/RewardChargeTo.js +7 -0
  48. package/bin/rewards/dtos/RewardCost.d.ts +6 -0
  49. package/bin/rewards/dtos/RewardCost.js +7 -0
  50. package/bin/rewards/dtos/RewardDependency.d.ts +17 -0
  51. package/bin/rewards/dtos/RewardDependency.js +12 -0
  52. package/bin/rewards/dtos/RewardSource.d.ts +12 -0
  53. package/bin/rewards/dtos/RewardSource.js +40 -0
  54. package/bin/rewards/dtos/responses/GrantAttemptResponse.d.ts +15 -0
  55. package/bin/rewards/dtos/responses/GrantAttemptResponse.js +10 -0
  56. package/bin/rewards/dtos/responses/GrantItemResponse.d.ts +20 -0
  57. package/bin/rewards/dtos/responses/GrantItemResponse.js +6 -0
  58. package/bin/rewards/dtos/responses/GrantResponse.d.ts +23 -0
  59. package/bin/rewards/dtos/responses/GrantResponse.js +7 -0
  60. package/bin/rewards/dtos/responses/PackageContractItem.d.ts +12 -0
  61. package/bin/rewards/dtos/responses/PackageContractItem.js +7 -0
  62. package/bin/rewards/dtos/responses/PackageContractResponse.d.ts +13 -0
  63. package/bin/rewards/dtos/responses/PackageContractResponse.js +7 -0
  64. package/bin/rewards/enums/DependencyIfMissingEnum.d.ts +5 -0
  65. package/bin/rewards/enums/DependencyIfMissingEnum.js +9 -0
  66. package/bin/rewards/enums/GrantFailedReasonEnum.d.ts +15 -0
  67. package/bin/rewards/enums/GrantFailedReasonEnum.js +19 -0
  68. package/bin/rewards/enums/GrantItemStatusEnum.d.ts +11 -0
  69. package/bin/rewards/enums/GrantItemStatusEnum.js +15 -0
  70. package/bin/rewards/enums/GrantRejectReasonEnum.d.ts +11 -0
  71. package/bin/rewards/enums/GrantRejectReasonEnum.js +15 -0
  72. package/bin/rewards/enums/GrantStatusEnum.d.ts +8 -0
  73. package/bin/rewards/enums/GrantStatusEnum.js +12 -0
  74. package/bin/rewards/enums/ItemErrorCategoryEnum.d.ts +7 -0
  75. package/bin/rewards/enums/ItemErrorCategoryEnum.js +11 -0
  76. package/bin/rewards/enums/RewardStatusEnum.d.ts +4 -0
  77. package/bin/rewards/enums/RewardStatusEnum.js +8 -0
  78. package/bin/rewards/enums/RewardsErrorCodeEnum.d.ts +5 -0
  79. package/bin/rewards/enums/RewardsErrorCodeEnum.js +9 -0
  80. package/bin/rewards/enums/RewardsMessageTypeEnum.d.ts +4 -0
  81. package/bin/rewards/enums/RewardsMessageTypeEnum.js +8 -0
  82. package/bin/rewards/index.d.ts +24 -0
  83. package/bin/rewards/index.js +47 -0
  84. package/bin/rewards/types/RewardInputs.d.ts +3 -0
  85. package/bin/rewards/types/RewardInputs.js +2 -0
  86. package/bin/rewards/validators/IsRewardInputs.d.ts +7 -0
  87. package/bin/rewards/validators/IsRewardInputs.js +26 -0
  88. package/bin/rewards/validators/IsRewardTags.d.ts +7 -0
  89. package/bin/rewards/validators/IsRewardTags.js +28 -0
  90. package/bin/rewardsEligibility/dtos/EventRunResult.d.ts +11 -0
  91. package/bin/rewardsEligibility/dtos/EventRunResult.js +7 -0
  92. package/bin/rewardsEligibility/dtos/EventSource.d.ts +5 -0
  93. package/bin/rewardsEligibility/dtos/EventSource.js +30 -0
  94. package/bin/rewardsEligibility/dtos/GetRunResponse.d.ts +22 -0
  95. package/bin/rewardsEligibility/dtos/GetRunResponse.js +7 -0
  96. package/bin/rewardsEligibility/dtos/PostEventRequest.d.ts +14 -0
  97. package/bin/rewardsEligibility/dtos/PostEventRequest.js +47 -0
  98. package/bin/rewardsEligibility/dtos/PostEventResponse.d.ts +5 -0
  99. package/bin/rewardsEligibility/dtos/PostEventResponse.js +7 -0
  100. package/bin/rewardsEligibility/dtos/RunCounts.d.ts +12 -0
  101. package/bin/rewardsEligibility/dtos/RunCounts.js +7 -0
  102. package/bin/rewardsEligibility/dtos/RunResultItem.d.ts +16 -0
  103. package/bin/rewardsEligibility/dtos/RunResultItem.js +7 -0
  104. package/bin/rewardsEligibility/enums/EvaluationOutcomeEnum.d.ts +11 -0
  105. package/bin/rewardsEligibility/enums/EvaluationOutcomeEnum.js +15 -0
  106. package/bin/rewardsEligibility/enums/GrantRequestStatusEnum.d.ts +11 -0
  107. package/bin/rewardsEligibility/enums/GrantRequestStatusEnum.js +15 -0
  108. package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.d.ts +8 -0
  109. package/bin/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.js +12 -0
  110. package/bin/rewardsEligibility/enums/RunModeEnum.d.ts +4 -0
  111. package/bin/rewardsEligibility/enums/RunModeEnum.js +8 -0
  112. package/bin/rewardsEligibility/enums/RunStatusEnum.d.ts +9 -0
  113. package/bin/rewardsEligibility/enums/RunStatusEnum.js +13 -0
  114. package/bin/rewardsEligibility/enums/TriggerTypeEnum.d.ts +5 -0
  115. package/bin/rewardsEligibility/enums/TriggerTypeEnum.js +9 -0
  116. package/bin/rewardsEligibility/index.d.ts +13 -0
  117. package/bin/rewardsEligibility/index.js +31 -0
  118. package/package.json +1 -1
  119. package/src/benefitCenter/dtos/InputField.ts +2 -14
  120. package/src/benefitCenter/dtos/InputSchema.ts +2 -7
  121. package/src/benefitCenter/dtos/InputValidation.ts +2 -8
  122. package/src/benefitCenter/dtos/SelectOption.ts +2 -4
  123. package/src/benefitCenter/enums/InputFieldTypeEnum.ts +2 -10
  124. package/src/common/index.ts +4 -1
  125. package/src/common/types/JsonValue.ts +5 -0
  126. package/src/dynamicForm/dtos/InputField.ts +16 -0
  127. package/src/dynamicForm/dtos/InputSchema.ts +7 -0
  128. package/src/dynamicForm/dtos/InputValidation.ts +8 -0
  129. package/src/dynamicForm/dtos/SelectOption.ts +4 -0
  130. package/src/dynamicForm/enums/InputFieldTypeEnum.ts +18 -0
  131. package/src/dynamicForm/helpers/isDynamicFormValue.ts +16 -0
  132. package/src/dynamicForm/index.ts +17 -0
  133. package/src/dynamicForm/types/DynamicFormValue.ts +8 -0
  134. package/src/dynamicForm/validators/IsDynamicFormValues.ts +16 -0
  135. package/src/index.ts +14 -0
  136. package/src/rewards/constants/RewardsLimits.ts +2 -0
  137. package/src/rewards/dtos/GrantFailedMessage.ts +29 -0
  138. package/src/rewards/dtos/GrantRequestedMessage.ts +46 -0
  139. package/src/rewards/dtos/RewardChargeTo.ts +5 -0
  140. package/src/rewards/dtos/RewardCost.ts +7 -0
  141. package/src/rewards/dtos/RewardDependency.ts +18 -0
  142. package/src/rewards/dtos/RewardSource.ts +27 -0
  143. package/src/rewards/dtos/responses/GrantAttemptResponse.ts +16 -0
  144. package/src/rewards/dtos/responses/GrantItemResponse.ts +21 -0
  145. package/src/rewards/dtos/responses/GrantResponse.ts +24 -0
  146. package/src/rewards/dtos/responses/PackageContractItem.ts +13 -0
  147. package/src/rewards/dtos/responses/PackageContractResponse.ts +14 -0
  148. package/src/rewards/enums/DependencyIfMissingEnum.ts +5 -0
  149. package/src/rewards/enums/GrantFailedReasonEnum.ts +15 -0
  150. package/src/rewards/enums/GrantItemStatusEnum.ts +11 -0
  151. package/src/rewards/enums/GrantRejectReasonEnum.ts +11 -0
  152. package/src/rewards/enums/GrantStatusEnum.ts +8 -0
  153. package/src/rewards/enums/ItemErrorCategoryEnum.ts +7 -0
  154. package/src/rewards/enums/RewardStatusEnum.ts +4 -0
  155. package/src/rewards/enums/RewardsErrorCodeEnum.ts +5 -0
  156. package/src/rewards/enums/RewardsMessageTypeEnum.ts +4 -0
  157. package/src/rewards/index.ts +37 -0
  158. package/src/rewards/types/RewardInputs.ts +4 -0
  159. package/src/rewards/validators/IsRewardInputs.ts +18 -0
  160. package/src/rewards/validators/IsRewardTags.ts +18 -0
  161. package/src/rewardsEligibility/dtos/EventRunResult.ts +12 -0
  162. package/src/rewardsEligibility/dtos/EventSource.ts +15 -0
  163. package/src/rewardsEligibility/dtos/GetRunResponse.ts +23 -0
  164. package/src/rewardsEligibility/dtos/PostEventRequest.ts +32 -0
  165. package/src/rewardsEligibility/dtos/PostEventResponse.ts +6 -0
  166. package/src/rewardsEligibility/dtos/RunCounts.ts +12 -0
  167. package/src/rewardsEligibility/dtos/RunResultItem.ts +17 -0
  168. package/src/rewardsEligibility/enums/EvaluationOutcomeEnum.ts +11 -0
  169. package/src/rewardsEligibility/enums/GrantRequestStatusEnum.ts +11 -0
  170. package/src/rewardsEligibility/enums/RewardsEligibilityErrorCodeEnum.ts +8 -0
  171. package/src/rewardsEligibility/enums/RunModeEnum.ts +4 -0
  172. package/src/rewardsEligibility/enums/RunStatusEnum.ts +9 -0
  173. package/src/rewardsEligibility/enums/TriggerTypeEnum.ts +5 -0
  174. package/src/rewardsEligibility/index.ts +16 -0
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PostEventRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const IsDynamicFormValues_1 = require("../../dynamicForm/validators/IsDynamicFormValues");
16
+ const EventSource_1 = require("./EventSource");
17
+ /**
18
+ * Cuerpo de `POST /events` (spec B 6.1). El emisor informa qué pasó y quién participó; NO decide
19
+ * la elegibilidad (E3). Parsear con `excludeExtraneousValues: true`: cualquier campo extra
20
+ * (p. ej. `prefetchedFacts`) se descarta.
21
+ */
22
+ class PostEventRequest {
23
+ }
24
+ exports.PostEventRequest = PostEventRequest;
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ (0, class_validator_1.IsString)(),
28
+ (0, class_validator_1.IsNotEmpty)(),
29
+ __metadata("design:type", String)
30
+ ], PostEventRequest.prototype, "eventKey", void 0);
31
+ __decorate([
32
+ (0, class_transformer_1.Expose)(),
33
+ (0, class_validator_1.IsString)(),
34
+ (0, class_validator_1.IsNotEmpty)(),
35
+ __metadata("design:type", String)
36
+ ], PostEventRequest.prototype, "idempotencyKey", void 0);
37
+ __decorate([
38
+ (0, class_transformer_1.Expose)(),
39
+ (0, class_validator_1.ValidateNested)(),
40
+ (0, class_transformer_1.Type)(() => EventSource_1.EventSource),
41
+ __metadata("design:type", EventSource_1.EventSource)
42
+ ], PostEventRequest.prototype, "source", void 0);
43
+ __decorate([
44
+ (0, class_transformer_1.Expose)(),
45
+ (0, class_validator_1.Validate)(IsDynamicFormValues_1.IsDynamicFormValues),
46
+ __metadata("design:type", Object)
47
+ ], PostEventRequest.prototype, "inputs", void 0);
@@ -0,0 +1,5 @@
1
+ import { EventRunResult } from './EventRunResult';
2
+ /** Respuesta 202 de `POST /events`; `runs` vacío si ninguna evaluación escucha el evento. */
3
+ export declare class PostEventResponse {
4
+ runs: EventRunResult[];
5
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PostEventResponse = void 0;
4
+ /** Respuesta 202 de `POST /events`; `runs` vacío si ninguna evaluación escucha el evento. */
5
+ class PostEventResponse {
6
+ }
7
+ exports.PostEventResponse = PostEventResponse;
@@ -0,0 +1,12 @@
1
+ /** Conteos de una corrida (mismos nombres que las métricas, spec B 5.7). */
2
+ export declare 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,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RunCounts = void 0;
4
+ /** Conteos de una corrida (mismos nombres que las métricas, spec B 5.7). */
5
+ class RunCounts {
6
+ }
7
+ exports.RunCounts = RunCounts;
@@ -0,0 +1,16 @@
1
+ import { EvaluationOutcomeEnum } from '../enums/EvaluationOutcomeEnum';
2
+ import { GrantRequestStatusEnum } from '../enums/GrantRequestStatusEnum';
3
+ /** Un resultado por sujeto, SIN traza (la traza es del backoffice). Asumido hasta cerrar P-7. */
4
+ export declare class RunResultItem {
5
+ subjectKey: string;
6
+ beneficiaryDirectoryId: string;
7
+ campaignId: string;
8
+ evaluationId: string;
9
+ packageId: string;
10
+ outcome: EvaluationOutcomeEnum;
11
+ grantStatus: GrantRequestStatusEnum;
12
+ /** `grantIdFor("rewards-eligibility", idempotencyKey)`; cruza con `GET /grants/{id}` de rewards. */
13
+ grantId?: string;
14
+ /** Solo si `outcome` es ERROR. */
15
+ errorMessage?: string;
16
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RunResultItem = void 0;
4
+ /** Un resultado por sujeto, SIN traza (la traza es del backoffice). Asumido hasta cerrar P-7. */
5
+ class RunResultItem {
6
+ }
7
+ exports.RunResultItem = RunResultItem;
@@ -0,0 +1,11 @@
1
+ export declare 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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EvaluationOutcomeEnum = void 0;
4
+ var EvaluationOutcomeEnum;
5
+ (function (EvaluationOutcomeEnum) {
6
+ EvaluationOutcomeEnum["MATCH"] = "MATCH";
7
+ EvaluationOutcomeEnum["NO_MATCH"] = "NO_MATCH";
8
+ EvaluationOutcomeEnum["ERROR"] = "ERROR";
9
+ /** La política de frecuencia lo bloqueó. */
10
+ EvaluationOutcomeEnum["ALREADY_GRANTED"] = "ALREADY_GRANTED";
11
+ /** Calificó, pero la campaña no tenía cupo. */
12
+ EvaluationOutcomeEnum["QUOTA_EXHAUSTED"] = "QUOTA_EXHAUSTED";
13
+ /** El operador lo sacó al aprobar. */
14
+ EvaluationOutcomeEnum["EXCLUDED"] = "EXCLUDED";
15
+ })(EvaluationOutcomeEnum || (exports.EvaluationOutcomeEnum = EvaluationOutcomeEnum = {}));
@@ -0,0 +1,11 @@
1
+ export declare 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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GrantRequestStatusEnum = void 0;
4
+ var GrantRequestStatusEnum;
5
+ (function (GrantRequestStatusEnum) {
6
+ GrantRequestStatusEnum["NOT_APPLICABLE"] = "NOT_APPLICABLE";
7
+ GrantRequestStatusEnum["PENDING_APPROVAL"] = "PENDING_APPROVAL";
8
+ /** Reservado, esperando su tramo de publicación. */
9
+ GrantRequestStatusEnum["QUEUED"] = "QUEUED";
10
+ /** Publicado en RewardsGrantQueue al instante (en línea). */
11
+ GrantRequestStatusEnum["REQUESTED"] = "REQUESTED";
12
+ /** La publicación falló o llegó GRANT_FAILED. */
13
+ GrantRequestStatusEnum["REQUEST_FAILED"] = "REQUEST_FAILED";
14
+ GrantRequestStatusEnum["CANCELLED"] = "CANCELLED";
15
+ })(GrantRequestStatusEnum || (exports.GrantRequestStatusEnum = GrantRequestStatusEnum = {}));
@@ -0,0 +1,8 @@
1
+ export declare 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,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RewardsEligibilityErrorCodeEnum = void 0;
4
+ var RewardsEligibilityErrorCodeEnum;
5
+ (function (RewardsEligibilityErrorCodeEnum) {
6
+ /** 400: faltan campos obligatorios del evento o tienen tipo inválido. */
7
+ RewardsEligibilityErrorCodeEnum["INPUT_INVALID"] = "INPUT_INVALID";
8
+ /** 404: el eventKey no existe o está inactivo. */
9
+ RewardsEligibilityErrorCodeEnum["EVENT_TYPE_NOT_FOUND"] = "EVENT_TYPE_NOT_FOUND";
10
+ /** 404: GET /runs/{id} sin corrida. */
11
+ RewardsEligibilityErrorCodeEnum["RUN_NOT_FOUND"] = "RUN_NOT_FOUND";
12
+ })(RewardsEligibilityErrorCodeEnum || (exports.RewardsEligibilityErrorCodeEnum = RewardsEligibilityErrorCodeEnum = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum RunModeEnum {
2
+ LIVE = "LIVE",
3
+ SIMULATION = "SIMULATION"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RunModeEnum = void 0;
4
+ var RunModeEnum;
5
+ (function (RunModeEnum) {
6
+ RunModeEnum["LIVE"] = "LIVE";
7
+ RunModeEnum["SIMULATION"] = "SIMULATION";
8
+ })(RunModeEnum || (exports.RunModeEnum = RunModeEnum = {}));
@@ -0,0 +1,9 @@
1
+ export declare enum RunStatusEnum {
2
+ RUNNING = "RUNNING",
3
+ AWAITING_APPROVAL = "AWAITING_APPROVAL",
4
+ PUBLISHING = "PUBLISHING",
5
+ COMPLETED = "COMPLETED",
6
+ PARTIAL = "PARTIAL",
7
+ FAILED = "FAILED",
8
+ REJECTED = "REJECTED"
9
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RunStatusEnum = void 0;
4
+ var RunStatusEnum;
5
+ (function (RunStatusEnum) {
6
+ RunStatusEnum["RUNNING"] = "RUNNING";
7
+ RunStatusEnum["AWAITING_APPROVAL"] = "AWAITING_APPROVAL";
8
+ RunStatusEnum["PUBLISHING"] = "PUBLISHING";
9
+ RunStatusEnum["COMPLETED"] = "COMPLETED";
10
+ RunStatusEnum["PARTIAL"] = "PARTIAL";
11
+ RunStatusEnum["FAILED"] = "FAILED";
12
+ RunStatusEnum["REJECTED"] = "REJECTED";
13
+ })(RunStatusEnum || (exports.RunStatusEnum = RunStatusEnum = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum TriggerTypeEnum {
2
+ EVENT = "EVENT",
3
+ MANUAL = "MANUAL",
4
+ CRON = "CRON"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TriggerTypeEnum = void 0;
4
+ var TriggerTypeEnum;
5
+ (function (TriggerTypeEnum) {
6
+ TriggerTypeEnum["EVENT"] = "EVENT";
7
+ TriggerTypeEnum["MANUAL"] = "MANUAL";
8
+ TriggerTypeEnum["CRON"] = "CRON";
9
+ })(TriggerTypeEnum || (exports.TriggerTypeEnum = TriggerTypeEnum = {}));
@@ -0,0 +1,13 @@
1
+ export * from './enums/EvaluationOutcomeEnum';
2
+ export * from './enums/GrantRequestStatusEnum';
3
+ export * from './enums/RunStatusEnum';
4
+ export * from './enums/RunModeEnum';
5
+ export * from './enums/TriggerTypeEnum';
6
+ export * from './enums/RewardsEligibilityErrorCodeEnum';
7
+ export * from './dtos/EventSource';
8
+ export * from './dtos/PostEventRequest';
9
+ export * from './dtos/EventRunResult';
10
+ export * from './dtos/PostEventResponse';
11
+ export * from './dtos/RunCounts';
12
+ export * from './dtos/RunResultItem';
13
+ export * from './dtos/GetRunResponse';
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ //Enums
18
+ __exportStar(require("./enums/EvaluationOutcomeEnum"), exports);
19
+ __exportStar(require("./enums/GrantRequestStatusEnum"), exports);
20
+ __exportStar(require("./enums/RunStatusEnum"), exports);
21
+ __exportStar(require("./enums/RunModeEnum"), exports);
22
+ __exportStar(require("./enums/TriggerTypeEnum"), exports);
23
+ __exportStar(require("./enums/RewardsEligibilityErrorCodeEnum"), exports);
24
+ //DTOs
25
+ __exportStar(require("./dtos/EventSource"), exports);
26
+ __exportStar(require("./dtos/PostEventRequest"), exports);
27
+ __exportStar(require("./dtos/EventRunResult"), exports);
28
+ __exportStar(require("./dtos/PostEventResponse"), exports);
29
+ __exportStar(require("./dtos/RunCounts"), exports);
30
+ __exportStar(require("./dtos/RunResultItem"), exports);
31
+ __exportStar(require("./dtos/GetRunResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.509.0",
3
+ "version": "3.511.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -1,14 +1,2 @@
1
- import { InputFieldTypeEnum } from "../enums/InputFieldTypeEnum";
2
- import { SelectOption } from "./SelectOption";
3
-
4
- export class InputField {
5
- key: string;
6
- type: InputFieldTypeEnum;
7
- label: string;
8
- required: boolean;
9
- placeholder?: string;
10
- helpImage?: string;
11
- showHelp?: boolean;
12
- options?: SelectOption[];
13
- dependsOn?: string;
14
- }
1
+ // Alias (D-E5): el origen vive en `dynamicForm`. No duplicar.
2
+ export { InputField } from '../../dynamicForm/dtos/InputField';
@@ -1,7 +1,2 @@
1
- import { InputField } from "./InputField";
2
- import { InputValidation } from "./InputValidation";
3
-
4
- export class InputSchema {
5
- fields: InputField[];
6
- validations?: Record<string, InputValidation>;
7
- }
1
+ // Alias (D-E5): el origen vive en `dynamicForm`. No duplicar.
2
+ export { InputSchema } from '../../dynamicForm/dtos/InputSchema';
@@ -1,8 +1,2 @@
1
- export class InputValidation {
2
- pattern?: string;
3
- maxLength?: number;
4
- minLength?: number;
5
- min?: number;
6
- max?: number;
7
- hasCheckDigit?: boolean;
8
- }
1
+ // Alias (D-E5): el origen vive en `dynamicForm`. No duplicar.
2
+ export { InputValidation } from '../../dynamicForm/dtos/InputValidation';
@@ -1,4 +1,2 @@
1
- export class SelectOption {
2
- value: string;
3
- label: string;
4
- }
1
+ // Alias (D-E5): el origen vive en `dynamicForm`. No duplicar.
2
+ export { SelectOption } from '../../dynamicForm/dtos/SelectOption';
@@ -1,10 +1,2 @@
1
- export enum InputFieldTypeEnum {
2
- PHONE = "PHONE",
3
- BARCODE = "BARCODE",
4
- ACCOUNT_NUMBER = "ACCOUNT_NUMBER",
5
- TEXT = "TEXT",
6
- NUMBER = "NUMBER",
7
- MONEY = "MONEY",
8
- SELECT = "SELECT",
9
- DATE = "DATE",
10
- }
1
+ // Alias (D-E5): el origen vive en el dominio compartido `dynamicForm`. No duplicar.
2
+ export { InputFieldTypeEnum } from '../../dynamicForm/enums/InputFieldTypeEnum';
@@ -9,4 +9,7 @@ export * from './dtos/ProcessValidationResultDto';
9
9
 
10
10
  //Enums
11
11
  export * from './enums/ProcessValidationEnum';
12
- export * from './enums/ProcessResultEnum';
12
+ export * from './enums/ProcessResultEnum';
13
+
14
+ //types
15
+ export * from './types/JsonValue';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Valor JSON arbitrario, sin `any` ni `unknown`. Tipo de entrada para los validadores de
3
+ * class-validator que reciben datos no confiables (mensajes de cola, cuerpos HTTP).
4
+ */
5
+ export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
@@ -0,0 +1,16 @@
1
+ import { InputFieldTypeEnum } from "../enums/InputFieldTypeEnum";
2
+ import { SelectOption } from "./SelectOption";
3
+
4
+ export class InputField {
5
+ key: string;
6
+ type: InputFieldTypeEnum;
7
+ label: string;
8
+ required: boolean;
9
+ placeholder?: string;
10
+ helpImage?: string;
11
+ showHelp?: boolean;
12
+ options?: SelectOption[];
13
+ dependsOn?: string;
14
+ /** Endpoint del que salen las opciones (SELECT ampliado y ENTITY_REF). */
15
+ optionsSource?: string;
16
+ }
@@ -0,0 +1,7 @@
1
+ import { InputField } from "./InputField";
2
+ import { InputValidation } from "./InputValidation";
3
+
4
+ export class InputSchema {
5
+ fields: InputField[];
6
+ validations?: Record<string, InputValidation>;
7
+ }
@@ -0,0 +1,8 @@
1
+ export class InputValidation {
2
+ pattern?: string;
3
+ maxLength?: number;
4
+ minLength?: number;
5
+ min?: number;
6
+ max?: number;
7
+ hasCheckDigit?: boolean;
8
+ }
@@ -0,0 +1,4 @@
1
+ export class SelectOption {
2
+ value: string;
3
+ label: string;
4
+ }
@@ -0,0 +1,18 @@
1
+ export enum InputFieldTypeEnum {
2
+ PHONE = "PHONE",
3
+ BARCODE = "BARCODE",
4
+ ACCOUNT_NUMBER = "ACCOUNT_NUMBER",
5
+ TEXT = "TEXT",
6
+ NUMBER = "NUMBER",
7
+ MONEY = "MONEY",
8
+ SELECT = "SELECT",
9
+ DATE = "DATE",
10
+ /** Buscador de usuario (nombre, teléfono, correo). Valor: `directoryId`. */
11
+ DIRECTORY = "DIRECTORY",
12
+ /** Buscador contra `optionsSource` (ej. ventas). Valor: id de la entidad. */
13
+ ENTITY_REF = "ENTITY_REF",
14
+ /** Rango de fechas. Valor: `{from, to}`; cada extremo es fecha ISO o ventana relativa (`7d`, `1M`; spec B §9). */
15
+ DATE_RANGE = "DATE_RANGE",
16
+ /** Interruptor. Valor: `true`/`false`. */
17
+ BOOLEAN = "BOOLEAN",
18
+ }
@@ -0,0 +1,16 @@
1
+ import { JsonValue } from '../../common/types/JsonValue';
2
+ import { DateRangeValue, DynamicFormValue } from '../types/DynamicFormValue';
3
+
4
+ export const isPlainObject = (value: JsonValue): value is { [key: string]: JsonValue } =>
5
+ typeof value === 'object' && value !== null && !Array.isArray(value);
6
+
7
+ export const isDateRangeValue = (value: JsonValue): value is DateRangeValue => {
8
+ if (!isPlainObject(value)) return false;
9
+ return Object.keys(value).length === 2 && typeof value.from === 'string' && typeof value.to === 'string';
10
+ };
11
+
12
+ export const isDynamicFormValue = (value: JsonValue): value is DynamicFormValue => {
13
+ if (typeof value === 'string' || typeof value === 'boolean') return true;
14
+ if (typeof value === 'number') return Number.isFinite(value);
15
+ return isDateRangeValue(value);
16
+ };
@@ -0,0 +1,17 @@
1
+ //Enums
2
+ export * from './enums/InputFieldTypeEnum';
3
+
4
+ //DTOs
5
+ export * from './dtos/SelectOption';
6
+ export * from './dtos/InputValidation';
7
+ export * from './dtos/InputField';
8
+ export * from './dtos/InputSchema';
9
+
10
+ //Types
11
+ export * from './types/DynamicFormValue';
12
+
13
+ //Helpers
14
+ export * from './helpers/isDynamicFormValue';
15
+
16
+ //Validators
17
+ export * from './validators/IsDynamicFormValues';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Valor de un campo `DATE_RANGE`: `{from, to}`. `from`/`to` son fechas ISO o una ventana relativa
3
+ * (`7d`, `1M`; spec B §9) que el consumidor resuelve contra «ahora».
4
+ */
5
+ export type DateRangeValue = { from: string; to: string };
6
+
7
+ /** Lo que puede valer una entrada de un formulario dinámico. */
8
+ export type DynamicFormValue = string | number | boolean | DateRangeValue;
@@ -0,0 +1,16 @@
1
+ import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator';
2
+ import { JsonValue } from '../../common/types/JsonValue';
3
+ import { isDynamicFormValue, isPlainObject } from '../helpers/isDynamicFormValue';
4
+
5
+ /** Valida un mapa `clave → DynamicFormValue` (string | number | boolean | {from, to}). */
6
+ @ValidatorConstraint({ name: 'IsDynamicFormValues', async: false })
7
+ export class IsDynamicFormValues implements ValidatorConstraintInterface {
8
+ validate(value: JsonValue, _args: ValidationArguments): boolean {
9
+ if (!isPlainObject(value)) return false;
10
+ return Object.values(value).every(isDynamicFormValue);
11
+ }
12
+
13
+ defaultMessage(_args: ValidationArguments): string {
14
+ return 'inputs debe ser un mapa clave → string | number | boolean | {from, to}';
15
+ }
16
+ }
package/src/index.ts CHANGED
@@ -193,3 +193,17 @@ export * as RetailLoan from './retailLoan';
193
193
  export * as MoneyTransfer from './moneyTransfer';
194
194
  // FileStorage: contrato de fiado-s3-lambda (documentos de usuario en S3). Consumido por api-invoker (IFileStorageApi).
195
195
  export * as FileStorage from './fileStorage';
196
+
197
+ // DynamicForm: formulario dinámico compartido (InputField, InputFieldTypeEnum, SelectOption,
198
+ // InputValidation, InputSchema). Antes vivía en `benefitCenter`, que lo reexporta como alias.
199
+ // Lo usan rewards (dependencies de las recompensas) y rewardsEligibility (inputs, fields, params).
200
+ export * as DynamicForm from './dynamicForm';
201
+
202
+ // Rewards: contrato entre rewards-business (entrega paquetes de recompensas) y sus llamadores
203
+ // (rewards-eligibility-business): mensajes GRANT_REQUESTED / GRANT_FAILED de las colas compartidas
204
+ // y respuestas de las lecturas privadas GET /packages/{id} y GET /grants/{id}.
205
+ export * as Rewards from './rewards';
206
+
207
+ // RewardsEligibility: contrato del validador de elegibilidad (rewards-eligibility-business) hacia los
208
+ // servicios emisores: POST /events (request/response) y GET /runs/{id}.
209
+ export * as RewardsEligibility from './rewardsEligibility';
@@ -0,0 +1,2 @@
1
+ /** Máximo de llaves en `source.tags` (spec A 5.3). */
2
+ export const REWARD_TAGS_MAX_KEYS = 10;
@@ -0,0 +1,29 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { Equals, IsEnum, IsNotEmpty, IsString } from 'class-validator';
3
+ import { GrantFailedReasonEnum } from '../enums/GrantFailedReasonEnum';
4
+ import { RewardsMessageTypeEnum } from '../enums/RewardsMessageTypeEnum';
5
+
6
+ /**
7
+ * Aviso de que una entrega terminó SIN ningún ítem entregado (`FAILED` o `REJECTED`). Lo publica
8
+ * rewards-business en la cola registrada para `source.service` (spec A 6.5) para que el llamador
9
+ * libere lo que reservó. Una entrega `PARTIAL` no avisa. Es idempotente en el destino.
10
+ */
11
+ export class GrantFailedMessage {
12
+ @Expose()
13
+ @Equals(RewardsMessageTypeEnum.GRANT_FAILED)
14
+ messageType!: RewardsMessageTypeEnum.GRANT_FAILED;
15
+
16
+ @Expose()
17
+ @IsString()
18
+ @IsNotEmpty()
19
+ idempotencyKey!: string;
20
+
21
+ @Expose()
22
+ @IsString()
23
+ @IsNotEmpty()
24
+ grantId!: string;
25
+
26
+ @Expose()
27
+ @IsEnum(GrantFailedReasonEnum)
28
+ reason!: GrantFailedReasonEnum;
29
+ }
@@ -0,0 +1,46 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { Equals, IsNotEmpty, IsString, Validate, ValidateNested } from 'class-validator';
3
+ import { RewardsMessageTypeEnum } from '../enums/RewardsMessageTypeEnum';
4
+ import { RewardInputs } from '../types/RewardInputs';
5
+ import { IsRewardInputs } from '../validators/IsRewardInputs';
6
+ import { RewardSource } from './RewardSource';
7
+
8
+ /**
9
+ * Pedido de entrega de un paquete, publicado en `RewardsGrantQueue` (spec A 6.1). Que la
10
+ * publicación funcione es la aceptación del pedido. El `grantId` NO viaja: el llamador lo calcula
11
+ * con `grantIdFor(source.service, idempotencyKey)` de `@fiado/api-invoker`.
12
+ *
13
+ * Parseo en el consumidor: `plainToInstance(GrantRequestedMessage, raw, { excludeExtraneousValues: true })`.
14
+ */
15
+ export class GrantRequestedMessage {
16
+ @Expose()
17
+ @Equals(RewardsMessageTypeEnum.GRANT_REQUESTED)
18
+ messageType!: RewardsMessageTypeEnum.GRANT_REQUESTED;
19
+
20
+ /** Beneficiario de la recompensa. */
21
+ @Expose()
22
+ @IsString()
23
+ @IsNotEmpty()
24
+ directoryId!: string;
25
+
26
+ @Expose()
27
+ @IsString()
28
+ @IsNotEmpty()
29
+ packageId!: string;
30
+
31
+ @Expose()
32
+ @ValidateNested()
33
+ @Type(() => RewardSource)
34
+ source!: RewardSource;
35
+
36
+ /** Ej. `elig:{evaluationId}:{beneficiaryDirectoryId}:{grantKey}:r{n}`. Con `source.service` da el `grantId`. */
37
+ @Expose()
38
+ @IsString()
39
+ @IsNotEmpty()
40
+ idempotencyKey!: string;
41
+
42
+ /** `itemKey → inputKey → valor`. */
43
+ @Expose()
44
+ @Validate(IsRewardInputs)
45
+ inputs!: RewardInputs;
46
+ }
@@ -0,0 +1,5 @@
1
+ /** A quién se le cobra la recompensa (spec A D8). */
2
+ export class RewardChargeTo {
3
+ partnerId: string;
4
+ partnerName: string;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { CurrencyId } from '../../currency';
2
+
3
+ /** Costo declarado de una recompensa (spec A 5.1). Un paquete puede mezclar monedas: se reporta por moneda. */
4
+ export class RewardCost {
5
+ amount: number;
6
+ currency: CurrencyId;
7
+ }