@fiado/type-kit 3.384.0 → 3.385.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.
@@ -0,0 +1,53 @@
1
+ import 'reflect-metadata';
2
+ import { ClassConstructor, plainToInstance } from 'class-transformer';
3
+ import { validate } from 'class-validator';
4
+ import {
5
+ PromotionBonusStatusEnum,
6
+ ReservePromotionBonusRequest,
7
+ SettlePromotionBonusRequest,
8
+ } from '../../../src/loanOfferings/index';
9
+
10
+ const errorProperties = async <T extends object>(
11
+ dtoClass: ClassConstructor<T>,
12
+ raw: Record<string, unknown>,
13
+ ): Promise<string[]> => {
14
+ const instance = plainToInstance(dtoClass, raw, { excludeExtraneousValues: true });
15
+ return (await validate(instance as object)).map((error) => error.property);
16
+ };
17
+
18
+ describe('ReservePromotionBonusRequest', () => {
19
+ it('valida con el crédito y nada más', async () => {
20
+ expect(await errorProperties(ReservePromotionBonusRequest, { creditId: 'CR-1' })).toHaveLength(0);
21
+ });
22
+
23
+ it('exige el crédito: es el candado del pago', async () => {
24
+ expect(await errorProperties(ReservePromotionBonusRequest, {})).toContain('creditId');
25
+ });
26
+ });
27
+
28
+ describe('SettlePromotionBonusRequest', () => {
29
+ const base = { bonusId: 'BON-1', status: PromotionBonusStatusEnum.SETTLED, transactionId: 'TX-9' };
30
+
31
+ it('valida el cierre completo', async () => {
32
+ expect(await errorProperties(SettlePromotionBonusRequest, base)).toHaveLength(0);
33
+ });
34
+
35
+ it('el folio es opcional: el processor puede aprobar sin darlo', async () => {
36
+ const { transactionId, ...sinFolio } = base;
37
+ expect(await errorProperties(SettlePromotionBonusRequest, sinFolio)).toHaveLength(0);
38
+ });
39
+
40
+ it('rechaza un estado fuera del enum', async () => {
41
+ expect(await errorProperties(SettlePromotionBonusRequest, { ...base, status: 'PAGADO' })).toContain('status');
42
+ });
43
+
44
+ it('acepta los tres desenlaces del processor', async () => {
45
+ for (const status of [
46
+ PromotionBonusStatusEnum.SETTLED,
47
+ PromotionBonusStatusEnum.FAILED,
48
+ PromotionBonusStatusEnum.UNVERIFIED,
49
+ ]) {
50
+ expect(await errorProperties(SettlePromotionBonusRequest, { ...base, status })).toHaveLength(0);
51
+ }
52
+ });
53
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Body de POST /private/promotions/:promotionId/bonus-payment — el crédito recién activado que va a
3
+ * cobrar el bono. `creditId` es el candado: reenviarlo devuelve `reserved: false`, no un segundo pago.
4
+ */
5
+ export declare class ReservePromotionBonusRequest {
6
+ creditId: string;
7
+ }
@@ -0,0 +1,26 @@
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.ReservePromotionBonusRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ /**
16
+ * Body de POST /private/promotions/:promotionId/bonus-payment — el crédito recién activado que va a
17
+ * cobrar el bono. `creditId` es el candado: reenviarlo devuelve `reserved: false`, no un segundo pago.
18
+ */
19
+ class ReservePromotionBonusRequest {
20
+ }
21
+ exports.ReservePromotionBonusRequest = ReservePromotionBonusRequest;
22
+ __decorate([
23
+ (0, class_transformer_1.Expose)(),
24
+ (0, class_validator_1.IsString)(),
25
+ __metadata("design:type", String)
26
+ ], ReservePromotionBonusRequest.prototype, "creditId", void 0);
@@ -0,0 +1,11 @@
1
+ import { PromotionBonusStatusEnum } from '../../enums/PromotionBonusStatusEnum';
2
+ /**
3
+ * Body de PUT /private/promotions/:promotionId/bonus-payment/result — cierra el asiento con lo que
4
+ * contestó el processor. `RESERVED` no se acepta: es el estado del que se sale, no al que se llega.
5
+ */
6
+ export declare class SettlePromotionBonusRequest {
7
+ bonusId: string;
8
+ status: PromotionBonusStatusEnum;
9
+ /** Folio del processor. Ausente cuando aprobó sin darlo, o cuando el pago falló. */
10
+ transactionId?: string;
11
+ }
@@ -0,0 +1,38 @@
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.SettlePromotionBonusRequest = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const PromotionBonusStatusEnum_1 = require("../../enums/PromotionBonusStatusEnum");
16
+ /**
17
+ * Body de PUT /private/promotions/:promotionId/bonus-payment/result — cierra el asiento con lo que
18
+ * contestó el processor. `RESERVED` no se acepta: es el estado del que se sale, no al que se llega.
19
+ */
20
+ class SettlePromotionBonusRequest {
21
+ }
22
+ exports.SettlePromotionBonusRequest = SettlePromotionBonusRequest;
23
+ __decorate([
24
+ (0, class_transformer_1.Expose)(),
25
+ (0, class_validator_1.IsString)(),
26
+ __metadata("design:type", String)
27
+ ], SettlePromotionBonusRequest.prototype, "bonusId", void 0);
28
+ __decorate([
29
+ (0, class_transformer_1.Expose)(),
30
+ (0, class_validator_1.IsEnum)(PromotionBonusStatusEnum_1.PromotionBonusStatusEnum),
31
+ __metadata("design:type", String)
32
+ ], SettlePromotionBonusRequest.prototype, "status", void 0);
33
+ __decorate([
34
+ (0, class_transformer_1.Expose)(),
35
+ (0, class_validator_1.IsOptional)(),
36
+ (0, class_validator_1.IsString)(),
37
+ __metadata("design:type", String)
38
+ ], SettlePromotionBonusRequest.prototype, "transactionId", void 0);
@@ -0,0 +1,20 @@
1
+ import { PromotionBonusStatusEnum } from '../../enums/PromotionBonusStatusEnum';
2
+ /**
3
+ * Asiento del bono PCF de una promoción, uno por crédito. Vive junto a la promoción porque ahí está
4
+ * el monto y ahí está el presupuesto contra el que se compara.
5
+ */
6
+ export interface PromotionBonusResponse {
7
+ /** Llave de idempotencia con la que el processor mueve la plata. */
8
+ bonusId: string;
9
+ creditId: string;
10
+ promotionId: string;
11
+ /** Versión de la promoción al reservar: el monto queda congelado aunque la promo se edite. */
12
+ promotionVersion: number;
13
+ amountCents: number;
14
+ status: PromotionBonusStatusEnum;
15
+ /** Folio del processor. `null` mientras no haya cerrado, o si cerró sin darlo. */
16
+ transactionId: string | null;
17
+ reservedAt: string;
18
+ /** Instante en que dejó de estar `RESERVED`. `null` si sigue abierto. */
19
+ settledAt: string | null;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { PromotionBonusResponse } from './PromotionBonusResponse';
2
+ /**
3
+ * Resultado de reservar el bono de un crédito. `reserved: false` es un reenvío o una segunda venta
4
+ * del mismo crédito: no es error, y `bonus` trae el asiento que ya existía para poder consultarlo.
5
+ */
6
+ export interface ReservePromotionBonusResponse {
7
+ reserved: boolean;
8
+ /** `null` cuando la promoción no declara bono PCF: no hay nada que pagar ni asiento que abrir. */
9
+ bonus: PromotionBonusResponse | null;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Estado del asiento del bono PCF de una promoción. `RESERVED` nace con el candado por crédito;
3
+ * los otros tres lo cierran según lo que haya contestado el processor.
4
+ * @enum {string}
5
+ */
6
+ export declare enum PromotionBonusStatusEnum {
7
+ RESERVED = "RESERVED",
8
+ SETTLED = "SETTLED",
9
+ FAILED = "FAILED",
10
+ UNVERIFIED = "UNVERIFIED"
11
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PromotionBonusStatusEnum = void 0;
4
+ /**
5
+ * Estado del asiento del bono PCF de una promoción. `RESERVED` nace con el candado por crédito;
6
+ * los otros tres lo cierran según lo que haya contestado el processor.
7
+ * @enum {string}
8
+ */
9
+ var PromotionBonusStatusEnum;
10
+ (function (PromotionBonusStatusEnum) {
11
+ PromotionBonusStatusEnum["RESERVED"] = "RESERVED";
12
+ PromotionBonusStatusEnum["SETTLED"] = "SETTLED";
13
+ PromotionBonusStatusEnum["FAILED"] = "FAILED";
14
+ PromotionBonusStatusEnum["UNVERIFIED"] = "UNVERIFIED";
15
+ })(PromotionBonusStatusEnum || (exports.PromotionBonusStatusEnum = PromotionBonusStatusEnum = {}));
@@ -6,6 +6,7 @@ export * from './enums/FinancierTypeEnum';
6
6
  export * from './enums/FinancierStatusEnum';
7
7
  export * from './enums/PromotionStatusEnum';
8
8
  export * from './enums/PromotionEffectKindEnum';
9
+ export * from './enums/PromotionBonusStatusEnum';
9
10
  export * from './enums/PromotionPhaseEnum';
10
11
  export * from './enums/PromotionLogEventEnum';
11
12
  export * from './enums/StorePolicyStatusEnum';
@@ -30,6 +31,8 @@ export * from './dtos/requests/CreatePromotionRequest';
30
31
  export * from './dtos/requests/UpdatePromotionRequest';
31
32
  export * from './dtos/requests/ChangePromotionStatusRequest';
32
33
  export * from './dtos/requests/ConsumePromotionRequest';
34
+ export * from './dtos/requests/ReservePromotionBonusRequest';
35
+ export * from './dtos/requests/SettlePromotionBonusRequest';
33
36
  export * from './dtos/requests/CreateStorePolicyRequest';
34
37
  export * from './dtos/requests/UpdateStorePolicyRequest';
35
38
  export * from './dtos/requests/ChangeStorePolicyStatusRequest';
@@ -44,6 +47,8 @@ export * from './dtos/responses/SimulationResultResponse';
44
47
  export * from './dtos/responses/PromotionResponse';
45
48
  export * from './dtos/responses/PromotionLogEntryResponse';
46
49
  export * from './dtos/responses/ConsumePromotionResponse';
50
+ export * from './dtos/responses/PromotionBonusResponse';
51
+ export * from './dtos/responses/ReservePromotionBonusResponse';
47
52
  export * from './dtos/responses/PromotedSkusResponse';
48
53
  export * from './dtos/responses/StorePolicyResponse';
49
54
  export * from './dtos/responses/SegmentResponse';
@@ -23,6 +23,7 @@ __exportStar(require("./enums/FinancierTypeEnum"), exports);
23
23
  __exportStar(require("./enums/FinancierStatusEnum"), exports);
24
24
  __exportStar(require("./enums/PromotionStatusEnum"), exports);
25
25
  __exportStar(require("./enums/PromotionEffectKindEnum"), exports);
26
+ __exportStar(require("./enums/PromotionBonusStatusEnum"), exports);
26
27
  __exportStar(require("./enums/PromotionPhaseEnum"), exports);
27
28
  __exportStar(require("./enums/PromotionLogEventEnum"), exports);
28
29
  __exportStar(require("./enums/StorePolicyStatusEnum"), exports);
@@ -49,6 +50,8 @@ __exportStar(require("./dtos/requests/CreatePromotionRequest"), exports);
49
50
  __exportStar(require("./dtos/requests/UpdatePromotionRequest"), exports);
50
51
  __exportStar(require("./dtos/requests/ChangePromotionStatusRequest"), exports);
51
52
  __exportStar(require("./dtos/requests/ConsumePromotionRequest"), exports);
53
+ __exportStar(require("./dtos/requests/ReservePromotionBonusRequest"), exports);
54
+ __exportStar(require("./dtos/requests/SettlePromotionBonusRequest"), exports);
52
55
  __exportStar(require("./dtos/requests/CreateStorePolicyRequest"), exports);
53
56
  __exportStar(require("./dtos/requests/UpdateStorePolicyRequest"), exports);
54
57
  __exportStar(require("./dtos/requests/ChangeStorePolicyStatusRequest"), exports);
@@ -64,6 +67,8 @@ __exportStar(require("./dtos/responses/SimulationResultResponse"), exports);
64
67
  __exportStar(require("./dtos/responses/PromotionResponse"), exports);
65
68
  __exportStar(require("./dtos/responses/PromotionLogEntryResponse"), exports);
66
69
  __exportStar(require("./dtos/responses/ConsumePromotionResponse"), exports);
70
+ __exportStar(require("./dtos/responses/PromotionBonusResponse"), exports);
71
+ __exportStar(require("./dtos/responses/ReservePromotionBonusResponse"), exports);
67
72
  __exportStar(require("./dtos/responses/PromotedSkusResponse"), exports);
68
73
  __exportStar(require("./dtos/responses/StorePolicyResponse"), exports);
69
74
  __exportStar(require("./dtos/responses/SegmentResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.384.0",
3
+ "version": "3.385.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -0,0 +1,12 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsString } from 'class-validator';
3
+
4
+ /**
5
+ * Body de POST /private/promotions/:promotionId/bonus-payment — el crédito recién activado que va a
6
+ * cobrar el bono. `creditId` es el candado: reenviarlo devuelve `reserved: false`, no un segundo pago.
7
+ */
8
+ export class ReservePromotionBonusRequest {
9
+ @Expose()
10
+ @IsString()
11
+ creditId!: string;
12
+ }
@@ -0,0 +1,23 @@
1
+ import { Expose } from 'class-transformer';
2
+ import { IsEnum, IsOptional, IsString } from 'class-validator';
3
+ import { PromotionBonusStatusEnum } from '../../enums/PromotionBonusStatusEnum';
4
+
5
+ /**
6
+ * Body de PUT /private/promotions/:promotionId/bonus-payment/result — cierra el asiento con lo que
7
+ * contestó el processor. `RESERVED` no se acepta: es el estado del que se sale, no al que se llega.
8
+ */
9
+ export class SettlePromotionBonusRequest {
10
+ @Expose()
11
+ @IsString()
12
+ bonusId!: string;
13
+
14
+ @Expose()
15
+ @IsEnum(PromotionBonusStatusEnum)
16
+ status!: PromotionBonusStatusEnum;
17
+
18
+ /** Folio del processor. Ausente cuando aprobó sin darlo, o cuando el pago falló. */
19
+ @Expose()
20
+ @IsOptional()
21
+ @IsString()
22
+ transactionId?: string;
23
+ }
@@ -0,0 +1,21 @@
1
+ import { PromotionBonusStatusEnum } from '../../enums/PromotionBonusStatusEnum';
2
+
3
+ /**
4
+ * Asiento del bono PCF de una promoción, uno por crédito. Vive junto a la promoción porque ahí está
5
+ * el monto y ahí está el presupuesto contra el que se compara.
6
+ */
7
+ export interface PromotionBonusResponse {
8
+ /** Llave de idempotencia con la que el processor mueve la plata. */
9
+ bonusId: string;
10
+ creditId: string;
11
+ promotionId: string;
12
+ /** Versión de la promoción al reservar: el monto queda congelado aunque la promo se edite. */
13
+ promotionVersion: number;
14
+ amountCents: number;
15
+ status: PromotionBonusStatusEnum;
16
+ /** Folio del processor. `null` mientras no haya cerrado, o si cerró sin darlo. */
17
+ transactionId: string | null;
18
+ reservedAt: string;
19
+ /** Instante en que dejó de estar `RESERVED`. `null` si sigue abierto. */
20
+ settledAt: string | null;
21
+ }
@@ -0,0 +1,11 @@
1
+ import { PromotionBonusResponse } from './PromotionBonusResponse';
2
+
3
+ /**
4
+ * Resultado de reservar el bono de un crédito. `reserved: false` es un reenvío o una segunda venta
5
+ * del mismo crédito: no es error, y `bonus` trae el asiento que ya existía para poder consultarlo.
6
+ */
7
+ export interface ReservePromotionBonusResponse {
8
+ reserved: boolean;
9
+ /** `null` cuando la promoción no declara bono PCF: no hay nada que pagar ni asiento que abrir. */
10
+ bonus: PromotionBonusResponse | null;
11
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Estado del asiento del bono PCF de una promoción. `RESERVED` nace con el candado por crédito;
3
+ * los otros tres lo cierran según lo que haya contestado el processor.
4
+ * @enum {string}
5
+ */
6
+ export enum PromotionBonusStatusEnum {
7
+ RESERVED = 'RESERVED',
8
+ SETTLED = 'SETTLED',
9
+ FAILED = 'FAILED',
10
+ UNVERIFIED = 'UNVERIFIED',
11
+ }
@@ -7,6 +7,7 @@ export * from './enums/FinancierTypeEnum';
7
7
  export * from './enums/FinancierStatusEnum';
8
8
  export * from './enums/PromotionStatusEnum';
9
9
  export * from './enums/PromotionEffectKindEnum';
10
+ export * from './enums/PromotionBonusStatusEnum';
10
11
  export * from './enums/PromotionPhaseEnum';
11
12
  export * from './enums/PromotionLogEventEnum';
12
13
  export * from './enums/StorePolicyStatusEnum';
@@ -35,6 +36,8 @@ export * from './dtos/requests/CreatePromotionRequest';
35
36
  export * from './dtos/requests/UpdatePromotionRequest';
36
37
  export * from './dtos/requests/ChangePromotionStatusRequest';
37
38
  export * from './dtos/requests/ConsumePromotionRequest';
39
+ export * from './dtos/requests/ReservePromotionBonusRequest';
40
+ export * from './dtos/requests/SettlePromotionBonusRequest';
38
41
  export * from './dtos/requests/CreateStorePolicyRequest';
39
42
  export * from './dtos/requests/UpdateStorePolicyRequest';
40
43
  export * from './dtos/requests/ChangeStorePolicyStatusRequest';
@@ -51,6 +54,8 @@ export * from './dtos/responses/SimulationResultResponse';
51
54
  export * from './dtos/responses/PromotionResponse';
52
55
  export * from './dtos/responses/PromotionLogEntryResponse';
53
56
  export * from './dtos/responses/ConsumePromotionResponse';
57
+ export * from './dtos/responses/PromotionBonusResponse';
58
+ export * from './dtos/responses/ReservePromotionBonusResponse';
54
59
  export * from './dtos/responses/PromotedSkusResponse';
55
60
  export * from './dtos/responses/StorePolicyResponse';
56
61
  export * from './dtos/responses/SegmentResponse';