@fiado/type-kit 3.652.0 → 3.654.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 (54) hide show
  1. package/_test_/unit/benefitCenter/benefitLeafProductPrice.test.ts +35 -0
  2. package/_test_/unit/rewards/backoffice.test.ts +15 -0
  3. package/_test_/unit/rewards/chargeDtos.test.ts +25 -1
  4. package/_test_/unit/rewards/mobileTopup.test.ts +21 -0
  5. package/_test_/unit/rewards/mobileTopupItemConfig.test.ts +104 -0
  6. package/_test_/unit/rewards/waitingLimit.test.ts +3 -3
  7. package/bin/benefitCenter/dtos/BenefitLeafProductPriceResponse.d.ts +14 -0
  8. package/bin/benefitCenter/dtos/BenefitLeafProductPriceResponse.js +2 -0
  9. package/bin/benefitCenter/index.d.ts +1 -0
  10. package/bin/benefitCenter/index.js +1 -0
  11. package/bin/rewards/constants/MobileTopupLimits.d.ts +10 -0
  12. package/bin/rewards/constants/MobileTopupLimits.js +13 -0
  13. package/bin/rewards/dtos/MobileTopupCarrierConfig.d.ts +17 -0
  14. package/bin/rewards/dtos/MobileTopupCarrierConfig.js +79 -0
  15. package/bin/rewards/dtos/MobileTopupItemConfig.d.ts +8 -0
  16. package/bin/rewards/dtos/MobileTopupItemConfig.js +35 -0
  17. package/bin/rewards/dtos/backoffice/CatalogItemRequest.d.ts +5 -0
  18. package/bin/rewards/dtos/backoffice/CatalogItemRequest.js +9 -0
  19. package/bin/rewards/dtos/backoffice/CatalogItemResponse.d.ts +2 -0
  20. package/bin/rewards/dtos/backoffice/ChargeRecord.d.ts +11 -0
  21. package/bin/rewards/dtos/backoffice/MobileTopupConfigRequest.d.ts +4 -1
  22. package/bin/rewards/dtos/backoffice/MobileTopupConfigRequest.js +4 -1
  23. package/bin/rewards/dtos/backoffice/MobileTopupConfigResponse.d.ts +1 -0
  24. package/bin/rewards/dtos/backoffice/MobileTopupContributionCarrier.d.ts +10 -0
  25. package/bin/rewards/dtos/backoffice/MobileTopupContributionCarrier.js +2 -0
  26. package/bin/rewards/dtos/backoffice/MobileTopupContributionResponse.d.ts +7 -0
  27. package/bin/rewards/dtos/backoffice/RewardChargeAdjustment.d.ts +15 -0
  28. package/bin/rewards/dtos/backoffice/RewardChargeAdjustment.js +7 -0
  29. package/bin/rewards/enums/MobileTopupDependencyKeyEnum.d.ts +7 -0
  30. package/bin/rewards/enums/MobileTopupDependencyKeyEnum.js +11 -0
  31. package/bin/rewards/enums/RewardChargeKindEnum.d.ts +7 -0
  32. package/bin/rewards/enums/RewardChargeKindEnum.js +11 -0
  33. package/bin/rewards/enums/RewardItemCodeEnum.d.ts +5 -1
  34. package/bin/rewards/enums/RewardItemCodeEnum.js +4 -0
  35. package/bin/rewards/index.d.ts +7 -0
  36. package/bin/rewards/index.js +7 -0
  37. package/package.json +1 -1
  38. package/src/benefitCenter/dtos/BenefitLeafProductPriceResponse.ts +15 -0
  39. package/src/benefitCenter/index.ts +1 -0
  40. package/src/rewards/constants/MobileTopupLimits.ts +10 -0
  41. package/src/rewards/dtos/MobileTopupCarrierConfig.ts +62 -0
  42. package/src/rewards/dtos/MobileTopupItemConfig.ts +22 -0
  43. package/src/rewards/dtos/backoffice/CatalogItemRequest.ts +13 -1
  44. package/src/rewards/dtos/backoffice/CatalogItemResponse.ts +2 -0
  45. package/src/rewards/dtos/backoffice/ChargeRecord.ts +11 -0
  46. package/src/rewards/dtos/backoffice/MobileTopupConfigRequest.ts +4 -1
  47. package/src/rewards/dtos/backoffice/MobileTopupConfigResponse.ts +1 -0
  48. package/src/rewards/dtos/backoffice/MobileTopupContributionCarrier.ts +10 -0
  49. package/src/rewards/dtos/backoffice/MobileTopupContributionResponse.ts +8 -0
  50. package/src/rewards/dtos/backoffice/RewardChargeAdjustment.ts +16 -0
  51. package/src/rewards/enums/MobileTopupDependencyKeyEnum.ts +7 -0
  52. package/src/rewards/enums/RewardChargeKindEnum.ts +7 -0
  53. package/src/rewards/enums/RewardItemCodeEnum.ts +4 -0
  54. package/src/rewards/index.ts +7 -0
@@ -0,0 +1,35 @@
1
+ import 'reflect-metadata';
2
+ import { BenefitLeafProductPriceResponse } from '../../../src/benefitCenter';
3
+ import { AmountTypeEnum } from '../../../src/servicePayment';
4
+
5
+ describe('BenefitLeafProductPriceResponse', () => {
6
+ it('tiene la forma exacta del contrato', () => {
7
+ const ok = {
8
+ price: 120,
9
+ currency: 'MXN',
10
+ amountType: AmountTypeEnum.FIXED,
11
+ productEnabled: true,
12
+ leafEnabled: true,
13
+ } satisfies BenefitLeafProductPriceResponse;
14
+ expect(Object.keys(ok).sort()).toEqual(['amountType', 'currency', 'leafEnabled', 'price', 'productEnabled']);
15
+ });
16
+
17
+ it('rechaza amountType fuera del enum y campos faltantes', () => {
18
+ const badAmountType: BenefitLeafProductPriceResponse = {
19
+ price: 1,
20
+ currency: 'MXN',
21
+ // @ts-expect-error amountType debe ser AmountTypeEnum
22
+ amountType: 'OTRO',
23
+ productEnabled: true,
24
+ leafEnabled: true,
25
+ };
26
+ // @ts-expect-error falta leafEnabled
27
+ const missingLeafEnabled: BenefitLeafProductPriceResponse = {
28
+ price: 1,
29
+ currency: 'MXN',
30
+ amountType: AmountTypeEnum.VARIABLE,
31
+ productEnabled: true,
32
+ };
33
+ expect([badAmountType.price, missingLeafEnabled.price]).toEqual([1, 1]);
34
+ });
35
+ });
@@ -45,6 +45,21 @@ describe('CatalogItemRequest', () => {
45
45
  expect(await props(asCatalog(override))).toContain(property);
46
46
  });
47
47
 
48
+ it('costCenterId es opcional: ausente, null o un texto de hasta 64', async () => {
49
+ expect(await validate(asCatalog())).toHaveLength(0);
50
+ expect(await validate(asCatalog({ costCenterId: null }))).toHaveLength(0);
51
+ expect(await validate(asCatalog({ costCenterId: 'CC-VENTA-CELULARES' }))).toHaveLength(0);
52
+ expect(asCatalog({ costCenterId: 'CC-1' }).costCenterId).toBe('CC-1');
53
+ });
54
+
55
+ it.each<[string, JsonValue]>([
56
+ ['vacío', ''],
57
+ ['> 64', 'c'.repeat(65)],
58
+ ['no texto', 5],
59
+ ])('rechaza costCenterId %s', async (_nombre, costCenterId) => {
60
+ expect(await props(asCatalog({ costCenterId }))).toContain('costCenterId');
61
+ });
62
+
48
63
  it('acepta costo 0 (recompensa gratuita para el aliado)', async () => {
49
64
  expect(await validate(asCatalog({ cost: { amount: 0, currency: 'MXN' } }))).toHaveLength(0);
50
65
  });
@@ -1,6 +1,6 @@
1
1
  import 'reflect-metadata';
2
2
  import { CurrencyId } from '../../../src/currency';
3
- import { CHARGES_EXPORT_MAX_ROWS, CHARGES_MONTH_PATTERN } from '../../../src/rewards';
3
+ import { CHARGES_EXPORT_MAX_ROWS, CHARGES_MONTH_PATTERN, RewardChargeKindEnum } from '../../../src/rewards';
4
4
  import type { ChargeListResponse, ChargeRecord, ChargesExportQuery, ChargesQuery } from '../../../src/rewards';
5
5
 
6
6
  describe('contrato de cargos (D-C1)', () => {
@@ -18,4 +18,28 @@ describe('contrato de cargos (D-C1)', () => {
18
18
  expect([CHARGES_EXPORT_MAX_ROWS, list.items.length, q.month, e.partnerId]).toEqual([10000, 1, '2026-10', 'FIADO']);
19
19
  expect('source' in record).toBe(false);
20
20
  });
21
+
22
+ it('RewardChargeKindEnum con valores exactos', () => {
23
+ expect({ ...RewardChargeKindEnum }).toEqual({ GRANT: 'GRANT', PRICE_ADJUSTMENT: 'PRICE_ADJUSTMENT' });
24
+ });
25
+
26
+ it('ChargeRecord de ajuste a FIADO (monto con signo) compila y el normal sigue sin kind', () => {
27
+ const base = {
28
+ grantId: 'g', itemKey: 'a', grantedAt: 1, directoryId: 'd', catalogItemId: 'c', catalogItemName: 'Recarga', packageId: 'p',
29
+ };
30
+ const ajuste: ChargeRecord = {
31
+ ...base,
32
+ kind: RewardChargeKindEnum.PRICE_ADJUSTMENT,
33
+ cost: { amount: -20, currency: CurrencyId.MXN },
34
+ chargeTo: { partnerId: 'FIADO', partnerName: 'Fiado' },
35
+ adjustment: {
36
+ rechargeFolio: 'RW-g-i-M2', rechargeNumber: 2, carrierId: 'BAIT', chargedUnitPrice: 100, paidUnitPrice: 80,
37
+ originalChargeTo: { partnerId: 'ALIADO-1', partnerName: 'Aliado' },
38
+ },
39
+ };
40
+ const normal: ChargeRecord = { ...base, cost: { amount: 10, currency: CurrencyId.MXN }, chargeTo: { partnerId: 'FIADO', partnerName: 'Fiado' } };
41
+ expect(ajuste.cost.amount).toBe(-20);
42
+ expect(ajuste.adjustment?.originalChargeTo.partnerId).toBe('ALIADO-1');
43
+ expect('kind' in normal).toBe(false);
44
+ });
21
45
  });
@@ -3,6 +3,8 @@ import { plainToInstance } from 'class-transformer';
3
3
  import { validate } from 'class-validator';
4
4
  import {
5
5
  BackofficeGrantItemResponse,
6
+ MobileTopupContributionCarrier,
7
+ MobileTopupContributionResponse,
6
8
  MobileTopupConfigRequest,
7
9
  MobileTopupPlanResponse,
8
10
  MobileTopupPlanStatusEnum,
@@ -29,6 +31,11 @@ describe('rewards mobile topup', () => {
29
31
  expect(RewardItemCodeEnum.AMOUNT_ABOVE_MAX).toBe('AMOUNT_ABOVE_MAX');
30
32
  expect(RewardItemCodeEnum.LIMIT_WAIT_EXPIRED).toBe('LIMIT_WAIT_EXPIRED');
31
33
  expect(RewardItemCodeEnum.OUTCOME_UNKNOWN).toBe('OUTCOME_UNKNOWN');
34
+ expect(RewardItemCodeEnum.CARRIER_NOT_AVAILABLE).toBe('CARRIER_NOT_AVAILABLE');
35
+ expect(RewardItemCodeEnum.TOPUP_PLAN_UNAVAILABLE).toBe('TOPUP_PLAN_UNAVAILABLE');
36
+ expect(Object.values(RewardItemCodeEnum)).toEqual(
37
+ expect.arrayContaining(['TOPUP_REJECTED', 'ITEM_DISMISSED', 'OUTCOME_UNKNOWN', 'AMOUNT_ABOVE_MAX', 'LIMIT_WAIT_EXPIRED']),
38
+ );
32
39
  });
33
40
 
34
41
  it('MobileTopupConfigRequest válido', async () => {
@@ -70,6 +77,20 @@ describe('rewards mobile topup', () => {
70
77
  expect(plan.pending).toBe(2);
71
78
  });
72
79
 
80
+ it('MobileTopupContributionResponse acepta carrier y unitPrice (opcionales)', () => {
81
+ const base = { grantId: 'g', itemKey: 'i', months: 3, sourceService: 's', sourceReference: 'r', addedAt: 1 };
82
+ const conSnapshot = {
83
+ ...base,
84
+ carrier: { carrierId: 'BAIT', label: 'Bait', moduleName: 'multicenter', benefitId: 'ben-3', leafId: 'l1', productId: '730', validityDays: 30 },
85
+ unitPrice: 100,
86
+ } satisfies MobileTopupContributionResponse;
87
+ const legacy = base satisfies MobileTopupContributionResponse;
88
+ const carrier: MobileTopupContributionCarrier = conSnapshot.carrier;
89
+ // @ts-expect-error unitPrice debe ser número
90
+ const invalido: MobileTopupContributionResponse = { ...base, unitPrice: '100' };
91
+ expect([conSnapshot.unitPrice, carrier.carrierId, 'carrier' in legacy, invalido.months]).toEqual([100, 'BAIT', false, 3]);
92
+ });
93
+
73
94
  it('BackofficeGrantItemResponse acepta type opcional', () => {
74
95
  const item = new BackofficeGrantItemResponse();
75
96
  item.type = 'MOBILE_TOPUP';
@@ -0,0 +1,104 @@
1
+ import 'reflect-metadata';
2
+ import { plainToInstance } from 'class-transformer';
3
+ import { validate, ValidationError } from 'class-validator';
4
+ import {
5
+ MOBILE_TOPUP_CARRIER_ID_PATTERN,
6
+ MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS,
7
+ MOBILE_TOPUP_MONTHS_MAX,
8
+ MOBILE_TOPUP_MONTHS_MIN,
9
+ MOBILE_TOPUP_VALIDITY_DAYS_MAX,
10
+ MobileTopupDependencyKeyEnum,
11
+ MobileTopupItemConfig,
12
+ } from '../../../src/rewards';
13
+
14
+ const carrier = {
15
+ carrierId: 'BAIT',
16
+ label: 'Bait',
17
+ moduleName: 'multicenter',
18
+ benefitId: 'ben-3',
19
+ leafId: 'l1',
20
+ productId: '730',
21
+ validityDays: 30,
22
+ enabled: true,
23
+ };
24
+ const base = { months: 3, carriers: [carrier] };
25
+
26
+ const fields = (errors: ValidationError[]): string[] =>
27
+ errors.flatMap((e) => [e.property, ...fields(e.children ?? [])]);
28
+
29
+ const check = async (plain: object): Promise<string[]> => fields(await validate(plainToInstance(MobileTopupItemConfig, plain)));
30
+ const withCarrier = (patch: object) => ({ ...base, carriers: [{ ...carrier, ...patch }] });
31
+
32
+ describe('MobileTopupItemConfig', () => {
33
+ it('config válida sin errores', async () => {
34
+ expect(await check(base)).toEqual([]);
35
+ });
36
+
37
+ it('sin validityDays aplica el default 30', async () => {
38
+ const { validityDays: _omit, ...sinValidez } = carrier;
39
+ const instance = plainToInstance(MobileTopupItemConfig, { ...base, carriers: [sinValidez] });
40
+ expect(fields(await validate(instance))).toEqual([]);
41
+ expect(instance.carriers[0].validityDays).toBe(30);
42
+ });
43
+
44
+ it.each([0, 100, 1.5])('months %s es inválido', async (months) => {
45
+ expect(await check({ ...base, months })).toContain('months');
46
+ });
47
+
48
+ it.each([1, 99])('months %s es válido', async (months) => {
49
+ expect(await check({ ...base, months })).toEqual([]);
50
+ });
51
+
52
+ it('carriers vacío o con carrierId repetido es inválido', async () => {
53
+ expect(await check({ ...base, carriers: [] })).toContain('carriers');
54
+ expect(await check({ ...base, carriers: [carrier, { ...carrier, label: 'Otro' }] })).toContain('carriers');
55
+ });
56
+
57
+ it.each(['bait', 'B', 'A'.repeat(21), 'TEL-CEL'])('carrierId %s es inválido', async (carrierId) => {
58
+ expect(await check(withCarrier({ carrierId }))).toContain('carrierId');
59
+ });
60
+
61
+ it.each(['TELCEL', 'AT_T'])('carrierId %s es válido', async (carrierId) => {
62
+ expect(await check(withCarrier({ carrierId }))).toEqual([]);
63
+ });
64
+
65
+ it.each([
66
+ ['leafId', ''],
67
+ ['productId', 'x'.repeat(65)],
68
+ ['label', ''],
69
+ ['benefitId', 'x'.repeat(65)],
70
+ ['moduleName', 'x'.repeat(65)],
71
+ ['leafId', 'x'.repeat(257)],
72
+ ])('%s inválido (%s)', async (prop, value) => {
73
+ expect(await check(withCarrier({ [prop]: value }))).toContain(prop);
74
+ });
75
+
76
+ it.each([0, -1, 30.5, 366])('validityDays %s es inválido', async (validityDays) => {
77
+ expect(await check(withCarrier({ validityDays }))).toContain('validityDays');
78
+ });
79
+
80
+ it('enabled no booleano es inválido', async () => {
81
+ expect(await check(withCarrier({ enabled: 'yes' }))).toContain('enabled');
82
+ });
83
+
84
+ describe('referencePrice (solo para mostrar; lo escribe rewards)', () => {
85
+ it('es opcional', async () => {
86
+ expect(await check(withCarrier({}))).toEqual([]);
87
+ });
88
+
89
+ it.each([0, 100, 120.5, 99.99])('referencePrice %s es válido', async (referencePrice) => {
90
+ expect(await check(withCarrier({ referencePrice }))).toEqual([]);
91
+ });
92
+
93
+ it.each([-1, 10.123, '100'])('referencePrice %s es inválido', async (referencePrice) => {
94
+ expect(await check(withCarrier({ referencePrice }))).toContain('referencePrice');
95
+ });
96
+ });
97
+
98
+ it('enum y constantes con valores exactos', () => {
99
+ expect({ ...MobileTopupDependencyKeyEnum }).toEqual({ PHONE: 'phone', CARRIER: 'carrier' });
100
+ expect([MOBILE_TOPUP_MONTHS_MIN, MOBILE_TOPUP_MONTHS_MAX]).toEqual([1, 99]);
101
+ expect([MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS, MOBILE_TOPUP_VALIDITY_DAYS_MAX]).toEqual([30, 365]);
102
+ expect(MOBILE_TOPUP_CARRIER_ID_PATTERN.source).toBe('^[A-Z0-9_]{2,20}$');
103
+ });
104
+ });
@@ -18,11 +18,11 @@ describe('espera por tope de nivel (WAITING_LIMIT)', () => {
18
18
  expect(Object.values(LimitWaitReasonEnum)).toHaveLength(2);
19
19
  });
20
20
 
21
- it('RewardItemCodeEnum contiene los cinco códigos', () => {
21
+ it('RewardItemCodeEnum contiene los siete códigos', () => {
22
22
  expect(Object.values(RewardItemCodeEnum)).toEqual(
23
- expect.arrayContaining(['AMOUNT_ABOVE_MAX', 'LIMIT_WAIT_EXPIRED', 'OUTCOME_UNKNOWN', 'TOPUP_REJECTED', 'ITEM_DISMISSED']),
23
+ expect.arrayContaining(['AMOUNT_ABOVE_MAX', 'LIMIT_WAIT_EXPIRED', 'OUTCOME_UNKNOWN', 'TOPUP_REJECTED', 'ITEM_DISMISSED', 'CARRIER_NOT_AVAILABLE', 'TOPUP_PLAN_UNAVAILABLE']),
24
24
  );
25
- expect(Object.values(RewardItemCodeEnum)).toHaveLength(5);
25
+ expect(Object.values(RewardItemCodeEnum)).toHaveLength(7);
26
26
  });
27
27
 
28
28
  it('BackofficeGrantItemResponse acepta los campos de espera', () => {
@@ -0,0 +1,14 @@
1
+ import { AmountTypeEnum } from '../../servicePayment';
2
+ /** Precio vigente (leído en vivo del conector) de un producto de un leaf de benefits. */
3
+ export interface BenefitLeafProductPriceResponse {
4
+ /** Precio vigente del producto (MXN en recargas); 0 si el monto es VARIABLE. */
5
+ price: number;
6
+ /** Moneda del leaf (`ConnectorCatalogItem.currency`), ej. "MXN". */
7
+ currency: string;
8
+ /** Tipo de monto del producto; se devuelve tal cual, sin decidir. */
9
+ amountType: AmountTypeEnum;
10
+ /** `ProductItem.enabled`; ausente en el catálogo se interpreta como `true`. */
11
+ productEnabled: boolean;
12
+ /** `ConnectorCatalogItem.enabled` del leaf. */
13
+ leafEnabled: boolean;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -56,6 +56,7 @@ export * from "./dtos/FavoriteUpdateRequest";
56
56
  export * from "./dtos/FavoriteReorderRequest";
57
57
  export * from "./dtos/BenefitPaymentRequest";
58
58
  export * from "./dtos/BenefitPaymentResponse";
59
+ export * from "./dtos/BenefitLeafProductPriceResponse";
59
60
  export * from "./dtos/AuthorizeBenefitsMarketplaceTransactionRequest";
60
61
  export * from "./dtos/FavoriteUpsertContext";
61
62
  export * from "./dtos/BackofficeLeafUpdateRequest";
@@ -79,6 +79,7 @@ __exportStar(require("./dtos/FavoriteReorderRequest"), exports);
79
79
  //Phase 2 — Payments + favorite upsert context (v3.9.0)
80
80
  __exportStar(require("./dtos/BenefitPaymentRequest"), exports);
81
81
  __exportStar(require("./dtos/BenefitPaymentResponse"), exports);
82
+ __exportStar(require("./dtos/BenefitLeafProductPriceResponse"), exports);
82
83
  __exportStar(require("./dtos/AuthorizeBenefitsMarketplaceTransactionRequest"), exports);
83
84
  __exportStar(require("./dtos/FavoriteUpsertContext"), exports);
84
85
  //Admin leaves in-place (v3.16.0)
@@ -0,0 +1,10 @@
1
+ /** Mínimo de meses (recargas) por ítem `MOBILE_TOPUP`. */
2
+ export declare const MOBILE_TOPUP_MONTHS_MIN = 1;
3
+ /** Máximo de meses (recargas) por ítem `MOBILE_TOPUP`. */
4
+ export declare const MOBILE_TOPUP_MONTHS_MAX = 99;
5
+ /** Vigencia en días de una recarga cuando el operador no la define. */
6
+ export declare const MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS = 30;
7
+ /** Máximo de días de vigencia de una recarga por operador. */
8
+ export declare const MOBILE_TOPUP_VALIDITY_DAYS_MAX = 365;
9
+ /** Formato de la clave estable de un operador (`TELCEL`, `BAIT`, `AT_T`). */
10
+ export declare const MOBILE_TOPUP_CARRIER_ID_PATTERN: RegExp;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MOBILE_TOPUP_CARRIER_ID_PATTERN = exports.MOBILE_TOPUP_VALIDITY_DAYS_MAX = exports.MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS = exports.MOBILE_TOPUP_MONTHS_MAX = exports.MOBILE_TOPUP_MONTHS_MIN = void 0;
4
+ /** Mínimo de meses (recargas) por ítem `MOBILE_TOPUP`. */
5
+ exports.MOBILE_TOPUP_MONTHS_MIN = 1;
6
+ /** Máximo de meses (recargas) por ítem `MOBILE_TOPUP`. */
7
+ exports.MOBILE_TOPUP_MONTHS_MAX = 99;
8
+ /** Vigencia en días de una recarga cuando el operador no la define. */
9
+ exports.MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS = 30;
10
+ /** Máximo de días de vigencia de una recarga por operador. */
11
+ exports.MOBILE_TOPUP_VALIDITY_DAYS_MAX = 365;
12
+ /** Formato de la clave estable de un operador (`TELCEL`, `BAIT`, `AT_T`). */
13
+ exports.MOBILE_TOPUP_CARRIER_ID_PATTERN = /^[A-Z0-9_]{2,20}$/;
@@ -0,0 +1,17 @@
1
+ /** Un operador de la recarga celular: identifica el plan en benefits (solo identificadores, nunca el precio de cobro). */
2
+ export declare class MobileTopupCarrierConfig {
3
+ /** Clave estable del operador (ej. `TELCEL`, `BAIT`). */
4
+ carrierId: string;
5
+ /** Nombre para mostrar. */
6
+ label: string;
7
+ moduleName: string;
8
+ benefitId: string;
9
+ leafId: string;
10
+ productId: string;
11
+ /** Vigencia en días de cada recarga; por defecto 30. */
12
+ validityDays: number;
13
+ /** Si está apagado, no se ofrece ni se acepta como operador. */
14
+ enabled: boolean;
15
+ /** SOLO para mostrar el aviso de cambio de precio: lo escribe rewards en el servidor (el valor del cliente se ignora) y nunca se usa para cobrar ni pagar. */
16
+ referencePrice?: number;
17
+ }
@@ -0,0 +1,79 @@
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.MobileTopupCarrierConfig = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const MobileTopupLimits_1 = require("../constants/MobileTopupLimits");
16
+ /** Un operador de la recarga celular: identifica el plan en benefits (solo identificadores, nunca el precio de cobro). */
17
+ class MobileTopupCarrierConfig {
18
+ }
19
+ exports.MobileTopupCarrierConfig = MobileTopupCarrierConfig;
20
+ __decorate([
21
+ (0, class_transformer_1.Expose)(),
22
+ (0, class_validator_1.Matches)(MobileTopupLimits_1.MOBILE_TOPUP_CARRIER_ID_PATTERN),
23
+ __metadata("design:type", String)
24
+ ], MobileTopupCarrierConfig.prototype, "carrierId", void 0);
25
+ __decorate([
26
+ (0, class_transformer_1.Expose)(),
27
+ (0, class_validator_1.IsString)(),
28
+ (0, class_validator_1.IsNotEmpty)(),
29
+ (0, class_validator_1.MaxLength)(60),
30
+ __metadata("design:type", String)
31
+ ], MobileTopupCarrierConfig.prototype, "label", void 0);
32
+ __decorate([
33
+ (0, class_transformer_1.Expose)(),
34
+ (0, class_validator_1.IsString)(),
35
+ (0, class_validator_1.IsNotEmpty)(),
36
+ (0, class_validator_1.MaxLength)(64),
37
+ __metadata("design:type", String)
38
+ ], MobileTopupCarrierConfig.prototype, "moduleName", void 0);
39
+ __decorate([
40
+ (0, class_transformer_1.Expose)(),
41
+ (0, class_validator_1.IsString)(),
42
+ (0, class_validator_1.IsNotEmpty)(),
43
+ (0, class_validator_1.MaxLength)(64),
44
+ __metadata("design:type", String)
45
+ ], MobileTopupCarrierConfig.prototype, "benefitId", void 0);
46
+ __decorate([
47
+ (0, class_transformer_1.Expose)(),
48
+ (0, class_validator_1.IsString)(),
49
+ (0, class_validator_1.IsNotEmpty)(),
50
+ (0, class_validator_1.MaxLength)(256),
51
+ __metadata("design:type", String)
52
+ ], MobileTopupCarrierConfig.prototype, "leafId", void 0);
53
+ __decorate([
54
+ (0, class_transformer_1.Expose)(),
55
+ (0, class_validator_1.IsString)(),
56
+ (0, class_validator_1.IsNotEmpty)(),
57
+ (0, class_validator_1.MaxLength)(64),
58
+ __metadata("design:type", String)
59
+ ], MobileTopupCarrierConfig.prototype, "productId", void 0);
60
+ __decorate([
61
+ (0, class_transformer_1.Expose)(),
62
+ (0, class_transformer_1.Transform)(({ value }) => value ?? MobileTopupLimits_1.MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS),
63
+ (0, class_validator_1.IsInt)(),
64
+ (0, class_validator_1.Min)(1),
65
+ (0, class_validator_1.Max)(MobileTopupLimits_1.MOBILE_TOPUP_VALIDITY_DAYS_MAX),
66
+ __metadata("design:type", Number)
67
+ ], MobileTopupCarrierConfig.prototype, "validityDays", void 0);
68
+ __decorate([
69
+ (0, class_transformer_1.Expose)(),
70
+ (0, class_validator_1.IsBoolean)(),
71
+ __metadata("design:type", Boolean)
72
+ ], MobileTopupCarrierConfig.prototype, "enabled", void 0);
73
+ __decorate([
74
+ (0, class_transformer_1.Expose)(),
75
+ (0, class_validator_1.IsOptional)(),
76
+ (0, class_validator_1.IsNumber)({ maxDecimalPlaces: 2 }),
77
+ (0, class_validator_1.Min)(0),
78
+ __metadata("design:type", Number)
79
+ ], MobileTopupCarrierConfig.prototype, "referencePrice", void 0);
@@ -0,0 +1,8 @@
1
+ import { MobileTopupCarrierConfig } from './MobileTopupCarrierConfig';
2
+ /** Config del ítem `MOBILE_TOPUP`: cuántas recargas mensuales da y con qué operadores. */
3
+ export declare class MobileTopupItemConfig {
4
+ /** Cantidad de recargas mensuales (1–99). */
5
+ months: number;
6
+ /** Operadores del ítem; `carrierId` único. Que haya al menos uno habilitado lo valida rewards-business. */
7
+ carriers: MobileTopupCarrierConfig[];
8
+ }
@@ -0,0 +1,35 @@
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.MobileTopupItemConfig = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ const MobileTopupLimits_1 = require("../constants/MobileTopupLimits");
16
+ const MobileTopupCarrierConfig_1 = require("./MobileTopupCarrierConfig");
17
+ /** Config del ítem `MOBILE_TOPUP`: cuántas recargas mensuales da y con qué operadores. */
18
+ class MobileTopupItemConfig {
19
+ }
20
+ exports.MobileTopupItemConfig = MobileTopupItemConfig;
21
+ __decorate([
22
+ (0, class_transformer_1.Expose)(),
23
+ (0, class_validator_1.IsInt)(),
24
+ (0, class_validator_1.Min)(MobileTopupLimits_1.MOBILE_TOPUP_MONTHS_MIN),
25
+ (0, class_validator_1.Max)(MobileTopupLimits_1.MOBILE_TOPUP_MONTHS_MAX),
26
+ __metadata("design:type", Number)
27
+ ], MobileTopupItemConfig.prototype, "months", void 0);
28
+ __decorate([
29
+ (0, class_transformer_1.Expose)(),
30
+ (0, class_validator_1.ArrayMinSize)(1),
31
+ (0, class_validator_1.ArrayUnique)((carrier) => carrier.carrierId),
32
+ (0, class_validator_1.ValidateNested)({ each: true }),
33
+ (0, class_transformer_1.Type)(() => MobileTopupCarrierConfig_1.MobileTopupCarrierConfig),
34
+ __metadata("design:type", Array)
35
+ ], MobileTopupItemConfig.prototype, "carriers", void 0);
@@ -15,5 +15,10 @@ export declare class CatalogItemRequest {
15
15
  };
16
16
  cost: RewardCostInput;
17
17
  chargeTo: RewardChargeToInput;
18
+ /**
19
+ * Centro de costo con que el ledger imputa lo que esta recompensa paga (saldo, recarga). Viaja en cada
20
+ * `disburse`. Ausente o `null` = sin centro: el pago se asienta como `UNASSIGNED`.
21
+ */
22
+ costCenterId?: string | null;
18
23
  status: RewardStatusEnum;
19
24
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CatalogItemRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
+ const costCenter_1 = require("../../../transaction/constants/costCenter");
15
16
  const BackofficeLimits_1 = require("../../constants/BackofficeLimits");
16
17
  const RewardStatusEnum_1 = require("../../enums/RewardStatusEnum");
17
18
  const RewardChargeToInput_1 = require("./RewardChargeToInput");
@@ -63,6 +64,14 @@ __decorate([
63
64
  (0, class_transformer_1.Type)(() => RewardChargeToInput_1.RewardChargeToInput),
64
65
  __metadata("design:type", RewardChargeToInput_1.RewardChargeToInput)
65
66
  ], CatalogItemRequest.prototype, "chargeTo", void 0);
67
+ __decorate([
68
+ (0, class_transformer_1.Expose)(),
69
+ (0, class_validator_1.IsOptional)(),
70
+ (0, class_validator_1.IsString)(),
71
+ (0, class_validator_1.IsNotEmpty)(),
72
+ (0, class_validator_1.MaxLength)(costCenter_1.COST_CENTER_ID_MAX_LENGTH),
73
+ __metadata("design:type", String)
74
+ ], CatalogItemRequest.prototype, "costCenterId", void 0);
66
75
  __decorate([
67
76
  (0, class_transformer_1.Expose)(),
68
77
  (0, class_validator_1.IsEnum)(RewardStatusEnum_1.RewardStatusEnum),
@@ -13,6 +13,8 @@ export declare class CatalogItemResponse {
13
13
  };
14
14
  cost: RewardCost;
15
15
  chargeTo: RewardChargeTo;
16
+ /** Centro de costo de lo que paga esta recompensa; ausente = `UNASSIGNED` en el ledger. */
17
+ costCenterId?: string;
16
18
  /** Solo lectura: las calcula el tipo a partir de `config`. */
17
19
  dependencies: RewardDependency[];
18
20
  status: RewardStatusEnum;
@@ -1,5 +1,7 @@
1
1
  import { RewardChargeTo } from '../RewardChargeTo';
2
2
  import { RewardCost } from '../RewardCost';
3
+ import { RewardChargeKindEnum } from '../../enums/RewardChargeKindEnum';
4
+ import { RewardChargeAdjustment } from './RewardChargeAdjustment';
3
5
  /** Un cargo = un ítem que quedó GRANTED, con el costo CONGELADO en la entrega (no el actual del catálogo). Sin `source` (R4 lo guarda, no se expone). */
4
6
  export declare class ChargeRecord {
5
7
  grantId: string;
@@ -14,4 +16,13 @@ export declare class ChargeRecord {
14
16
  cost: RewardCost;
15
17
  chargeTo: RewardChargeTo;
16
18
  externalRef?: Record<string, string>;
19
+ /**
20
+ * Tipo de registro; ausente ⇒ `GRANT`.
21
+ * En `PRICE_ADJUSTMENT`: `chargeTo = { partnerId: 'FIADO', partnerName }`, `cost.amount = round2(paidUnitPrice − chargedUnitPrice)`
22
+ * CON SIGNO (`+` a cargo de Fiado, `−` a favor), `cost.currency = MXN`, `grantedAt` = momento de la recarga (de ahí sale el mes UTC del libro)
23
+ * y `grantId`/`itemKey` = los del aporte. Un monto negativo es nuevo: sumas y export CSV deben tolerarlo.
24
+ */
25
+ kind?: RewardChargeKindEnum;
26
+ /** Detalle del ajuste; solo en registros `PRICE_ADJUSTMENT`. */
27
+ adjustment?: RewardChargeAdjustment;
17
28
  }
@@ -1,4 +1,7 @@
1
- /** Guarda la configuración de la recarga Bait (producto en Multicenter y precio mensual). */
1
+ /**
2
+ * Guarda la configuración de la recarga Bait (producto en Multicenter y precio mensual).
3
+ * @deprecated Reemplazado por MobileTopupItemConfig; se borra en T8 cuando rewards-business y backoffice dejen de importarlo.
4
+ */
2
5
  export declare class MobileTopupConfigRequest {
3
6
  moduleName: string;
4
7
  benefitId: string;
@@ -12,7 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MobileTopupConfigRequest = void 0;
13
13
  const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
- /** Guarda la configuración de la recarga Bait (producto en Multicenter y precio mensual). */
15
+ /**
16
+ * Guarda la configuración de la recarga Bait (producto en Multicenter y precio mensual).
17
+ * @deprecated Reemplazado por MobileTopupItemConfig; se borra en T8 cuando rewards-business y backoffice dejen de importarlo.
18
+ */
16
19
  class MobileTopupConfigRequest {
17
20
  }
18
21
  exports.MobileTopupConfigRequest = MobileTopupConfigRequest;
@@ -1,3 +1,4 @@
1
+ /** @deprecated Reemplazado por MobileTopupItemConfig; se borra en T8 cuando rewards-business y backoffice dejen de importarlos. */
1
2
  export interface MobileTopupConfigResponse {
2
3
  moduleName: string;
3
4
  benefitId: string;
@@ -0,0 +1,10 @@
1
+ /** Snapshot del operador elegido al otorgar; el calendario se muestra aunque el operador luego se apague o elimine del ítem. */
2
+ export interface MobileTopupContributionCarrier {
3
+ carrierId: string;
4
+ label: string;
5
+ moduleName: string;
6
+ benefitId: string;
7
+ leafId: string;
8
+ productId: string;
9
+ validityDays: number;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,4 @@
1
+ import { MobileTopupContributionCarrier } from './MobileTopupContributionCarrier';
1
2
  export interface MobileTopupContributionResponse {
2
3
  grantId: string;
3
4
  itemKey: string;
@@ -6,4 +7,10 @@ export interface MobileTopupContributionResponse {
6
7
  sourceReference: string;
7
8
  campaignId?: string;
8
9
  addedAt: number;
10
+ /** Snapshot del operador elegido al otorgar; solo falta en aportes legacy. */
11
+ carrier?: MobileTopupContributionCarrier;
12
+ /** Precio unitario cobrado al aliado (MXN, 2 decimales); no cambia nunca. Solo falta en aportes legacy. */
13
+ unitPrice?: number;
14
+ /** Centro de costo del ítem al otorgar; lo llevan todas las recargas del aporte. Ausente = `UNASSIGNED`. */
15
+ costCenterId?: string;
9
16
  }
@@ -0,0 +1,15 @@
1
+ import { RewardChargeTo } from '../RewardChargeTo';
2
+ /** Detalle de un ajuste de precio de una recarga: qué se cobró al aliado, qué se pagó y a quién se le cobró originalmente. */
3
+ export declare class RewardChargeAdjustment {
4
+ /** Folio de la recarga que pagó la diferencia. */
5
+ rechargeFolio: string;
6
+ /** Número de la recarga dentro del aporte (1..months). */
7
+ rechargeNumber: number;
8
+ carrierId: string;
9
+ /** `unitPrice` del aporte: lo cobrado al aliado. */
10
+ chargedUnitPrice: number;
11
+ /** Precio vigente pagado en esa recarga. */
12
+ paidUnitPrice: number;
13
+ /** Aliado original del premio. */
14
+ originalChargeTo: RewardChargeTo;
15
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RewardChargeAdjustment = void 0;
4
+ /** Detalle de un ajuste de precio de una recarga: qué se cobró al aliado, qué se pagó y a quién se le cobró originalmente. */
5
+ class RewardChargeAdjustment {
6
+ }
7
+ exports.RewardChargeAdjustment = RewardChargeAdjustment;
@@ -0,0 +1,7 @@
1
+ /** Llaves de las dependencias de entrada de un ítem `MOBILE_TOPUP`. */
2
+ export declare enum MobileTopupDependencyKeyEnum {
3
+ /** Número celular que recibe la recarga. */
4
+ PHONE = "phone",
5
+ /** Operador elegido (opciones = `carrierId` habilitados). */
6
+ CARRIER = "carrier"
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MobileTopupDependencyKeyEnum = void 0;
4
+ /** Llaves de las dependencias de entrada de un ítem `MOBILE_TOPUP`. */
5
+ var MobileTopupDependencyKeyEnum;
6
+ (function (MobileTopupDependencyKeyEnum) {
7
+ /** Número celular que recibe la recarga. */
8
+ MobileTopupDependencyKeyEnum["PHONE"] = "phone";
9
+ /** Operador elegido (opciones = `carrierId` habilitados). */
10
+ MobileTopupDependencyKeyEnum["CARRIER"] = "carrier";
11
+ })(MobileTopupDependencyKeyEnum || (exports.MobileTopupDependencyKeyEnum = MobileTopupDependencyKeyEnum = {}));
@@ -0,0 +1,7 @@
1
+ /** Tipo de registro del libro de cargos ("Entregas y costos"). */
2
+ export declare enum RewardChargeKindEnum {
3
+ /** Cargo de un ítem entregado (es el valor implícito cuando `kind` no viene). */
4
+ GRANT = "GRANT",
5
+ /** Ajuste simétrico a cargo/favor de FIADO por diferencia de precio en una recarga. */
6
+ PRICE_ADJUSTMENT = "PRICE_ADJUSTMENT"
7
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RewardChargeKindEnum = void 0;
4
+ /** Tipo de registro del libro de cargos ("Entregas y costos"). */
5
+ var RewardChargeKindEnum;
6
+ (function (RewardChargeKindEnum) {
7
+ /** Cargo de un ítem entregado (es el valor implícito cuando `kind` no viene). */
8
+ RewardChargeKindEnum["GRANT"] = "GRANT";
9
+ /** Ajuste simétrico a cargo/favor de FIADO por diferencia de precio en una recarga. */
10
+ RewardChargeKindEnum["PRICE_ADJUSTMENT"] = "PRICE_ADJUSTMENT";
11
+ })(RewardChargeKindEnum || (exports.RewardChargeKindEnum = RewardChargeKindEnum = {}));
@@ -9,5 +9,9 @@ export declare enum RewardItemCodeEnum {
9
9
  /** Bait rechazó la recarga de forma permanente: queda en atención del operador. */
10
10
  TOPUP_REJECTED = "TOPUP_REJECTED",
11
11
  /** Un operador dio el ítem por fallido. */
12
- ITEM_DISMISSED = "ITEM_DISMISSED"
12
+ ITEM_DISMISSED = "ITEM_DISMISSED",
13
+ /** El operador (`carrier`) es desconocido, está deshabilitado, o falta habiendo más de uno habilitado. */
14
+ CARRIER_NOT_AVAILABLE = "CARRIER_NOT_AVAILABLE",
15
+ /** El plan del operador está deshabilitado o no existe en benefits, no es `FIXED` o su precio es ≤ 0. */
16
+ TOPUP_PLAN_UNAVAILABLE = "TOPUP_PLAN_UNAVAILABLE"
13
17
  }
@@ -14,4 +14,8 @@ var RewardItemCodeEnum;
14
14
  RewardItemCodeEnum["TOPUP_REJECTED"] = "TOPUP_REJECTED";
15
15
  /** Un operador dio el ítem por fallido. */
16
16
  RewardItemCodeEnum["ITEM_DISMISSED"] = "ITEM_DISMISSED";
17
+ /** El operador (`carrier`) es desconocido, está deshabilitado, o falta habiendo más de uno habilitado. */
18
+ RewardItemCodeEnum["CARRIER_NOT_AVAILABLE"] = "CARRIER_NOT_AVAILABLE";
19
+ /** El plan del operador está deshabilitado o no existe en benefits, no es `FIXED` o su precio es ≤ 0. */
20
+ RewardItemCodeEnum["TOPUP_PLAN_UNAVAILABLE"] = "TOPUP_PLAN_UNAVAILABLE";
17
21
  })(RewardItemCodeEnum || (exports.RewardItemCodeEnum = RewardItemCodeEnum = {}));
@@ -14,11 +14,16 @@ export * from './enums/DeliveryTopDimensionEnum';
14
14
  export * from './enums/DeliveryTopByEnum';
15
15
  export * from './enums/MobileTopupPlanStatusEnum';
16
16
  export * from './enums/MobileTopupRechargeStatusEnum';
17
+ export * from './enums/MobileTopupDependencyKeyEnum';
18
+ export * from './enums/RewardChargeKindEnum';
17
19
  export * from './types/RewardInputs';
18
20
  export * from './dtos/RewardCost';
19
21
  export * from './dtos/RewardChargeTo';
20
22
  export * from './dtos/RewardDependency';
23
+ export * from './dtos/MobileTopupCarrierConfig';
24
+ export * from './dtos/MobileTopupItemConfig';
21
25
  export * from './constants/RewardsLimits';
26
+ export * from './constants/MobileTopupLimits';
22
27
  export * from './validators/IsRewardTags';
23
28
  export * from './validators/IsRewardInputs';
24
29
  export * from './dtos/RewardSource';
@@ -50,6 +55,7 @@ export * from './dtos/backoffice/BackofficeGrantAttemptResponse';
50
55
  export * from './dtos/backoffice/BackofficeGrantItemResponse';
51
56
  export * from './dtos/backoffice/BackofficeGrantResponse';
52
57
  export * from './dtos/backoffice/GrantListResponse';
58
+ export * from './dtos/backoffice/RewardChargeAdjustment';
53
59
  export * from './dtos/backoffice/ChargeRecord';
54
60
  export * from './dtos/backoffice/ChargeListResponse';
55
61
  export * from './dtos/backoffice/ChargesQuery';
@@ -60,6 +66,7 @@ export * from './dtos/backoffice/DeliveryMetricsPoint';
60
66
  export * from './dtos/backoffice/DeliveryTopEntry';
61
67
  export * from './dtos/backoffice/MobileTopupConfigRequest';
62
68
  export * from './dtos/backoffice/MobileTopupConfigResponse';
69
+ export * from './dtos/backoffice/MobileTopupContributionCarrier';
63
70
  export * from './dtos/backoffice/MobileTopupContributionResponse';
64
71
  export * from './dtos/backoffice/MobileTopupRechargeResponse';
65
72
  export * from './dtos/backoffice/MobileTopupPlanResponse';
@@ -31,14 +31,19 @@ __exportStar(require("./enums/DeliveryTopDimensionEnum"), exports);
31
31
  __exportStar(require("./enums/DeliveryTopByEnum"), exports);
32
32
  __exportStar(require("./enums/MobileTopupPlanStatusEnum"), exports);
33
33
  __exportStar(require("./enums/MobileTopupRechargeStatusEnum"), exports);
34
+ __exportStar(require("./enums/MobileTopupDependencyKeyEnum"), exports);
35
+ __exportStar(require("./enums/RewardChargeKindEnum"), exports);
34
36
  //Types
35
37
  __exportStar(require("./types/RewardInputs"), exports);
36
38
  //DTOs
37
39
  __exportStar(require("./dtos/RewardCost"), exports);
38
40
  __exportStar(require("./dtos/RewardChargeTo"), exports);
39
41
  __exportStar(require("./dtos/RewardDependency"), exports);
42
+ __exportStar(require("./dtos/MobileTopupCarrierConfig"), exports);
43
+ __exportStar(require("./dtos/MobileTopupItemConfig"), exports);
40
44
  //Constants
41
45
  __exportStar(require("./constants/RewardsLimits"), exports);
46
+ __exportStar(require("./constants/MobileTopupLimits"), exports);
42
47
  //Validators
43
48
  __exportStar(require("./validators/IsRewardTags"), exports);
44
49
  __exportStar(require("./validators/IsRewardInputs"), exports);
@@ -75,6 +80,7 @@ __exportStar(require("./dtos/backoffice/BackofficeGrantAttemptResponse"), export
75
80
  __exportStar(require("./dtos/backoffice/BackofficeGrantItemResponse"), exports);
76
81
  __exportStar(require("./dtos/backoffice/BackofficeGrantResponse"), exports);
77
82
  __exportStar(require("./dtos/backoffice/GrantListResponse"), exports);
83
+ __exportStar(require("./dtos/backoffice/RewardChargeAdjustment"), exports);
78
84
  __exportStar(require("./dtos/backoffice/ChargeRecord"), exports);
79
85
  __exportStar(require("./dtos/backoffice/ChargeListResponse"), exports);
80
86
  __exportStar(require("./dtos/backoffice/ChargesQuery"), exports);
@@ -85,6 +91,7 @@ __exportStar(require("./dtos/backoffice/DeliveryMetricsPoint"), exports);
85
91
  __exportStar(require("./dtos/backoffice/DeliveryTopEntry"), exports);
86
92
  __exportStar(require("./dtos/backoffice/MobileTopupConfigRequest"), exports);
87
93
  __exportStar(require("./dtos/backoffice/MobileTopupConfigResponse"), exports);
94
+ __exportStar(require("./dtos/backoffice/MobileTopupContributionCarrier"), exports);
88
95
  __exportStar(require("./dtos/backoffice/MobileTopupContributionResponse"), exports);
89
96
  __exportStar(require("./dtos/backoffice/MobileTopupRechargeResponse"), exports);
90
97
  __exportStar(require("./dtos/backoffice/MobileTopupPlanResponse"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.652.0",
3
+ "version": "3.654.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -0,0 +1,15 @@
1
+ import { AmountTypeEnum } from '../../servicePayment';
2
+
3
+ /** Precio vigente (leído en vivo del conector) de un producto de un leaf de benefits. */
4
+ export interface BenefitLeafProductPriceResponse {
5
+ /** Precio vigente del producto (MXN en recargas); 0 si el monto es VARIABLE. */
6
+ price: number;
7
+ /** Moneda del leaf (`ConnectorCatalogItem.currency`), ej. "MXN". */
8
+ currency: string;
9
+ /** Tipo de monto del producto; se devuelve tal cual, sin decidir. */
10
+ amountType: AmountTypeEnum;
11
+ /** `ProductItem.enabled`; ausente en el catálogo se interpreta como `true`. */
12
+ productEnabled: boolean;
13
+ /** `ConnectorCatalogItem.enabled` del leaf. */
14
+ leafEnabled: boolean;
15
+ }
@@ -64,6 +64,7 @@ export * from "./dtos/FavoriteReorderRequest";
64
64
  //Phase 2 — Payments + favorite upsert context (v3.9.0)
65
65
  export * from "./dtos/BenefitPaymentRequest";
66
66
  export * from "./dtos/BenefitPaymentResponse";
67
+ export * from "./dtos/BenefitLeafProductPriceResponse";
67
68
  export * from "./dtos/AuthorizeBenefitsMarketplaceTransactionRequest";
68
69
  export * from "./dtos/FavoriteUpsertContext";
69
70
  //Admin leaves in-place (v3.16.0)
@@ -0,0 +1,10 @@
1
+ /** Mínimo de meses (recargas) por ítem `MOBILE_TOPUP`. */
2
+ export const MOBILE_TOPUP_MONTHS_MIN = 1;
3
+ /** Máximo de meses (recargas) por ítem `MOBILE_TOPUP`. */
4
+ export const MOBILE_TOPUP_MONTHS_MAX = 99;
5
+ /** Vigencia en días de una recarga cuando el operador no la define. */
6
+ export const MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS = 30;
7
+ /** Máximo de días de vigencia de una recarga por operador. */
8
+ export const MOBILE_TOPUP_VALIDITY_DAYS_MAX = 365;
9
+ /** Formato de la clave estable de un operador (`TELCEL`, `BAIT`, `AT_T`). */
10
+ export const MOBILE_TOPUP_CARRIER_ID_PATTERN = /^[A-Z0-9_]{2,20}$/;
@@ -0,0 +1,62 @@
1
+ import { Expose, Transform } from 'class-transformer';
2
+ import { IsBoolean, IsInt, IsNotEmpty, IsNumber, IsOptional, IsString, Matches, Max, MaxLength, Min } from 'class-validator';
3
+ import { MOBILE_TOPUP_CARRIER_ID_PATTERN, MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS, MOBILE_TOPUP_VALIDITY_DAYS_MAX } from '../constants/MobileTopupLimits';
4
+
5
+ /** Un operador de la recarga celular: identifica el plan en benefits (solo identificadores, nunca el precio de cobro). */
6
+ export class MobileTopupCarrierConfig {
7
+ /** Clave estable del operador (ej. `TELCEL`, `BAIT`). */
8
+ @Expose()
9
+ @Matches(MOBILE_TOPUP_CARRIER_ID_PATTERN)
10
+ carrierId: string;
11
+
12
+ /** Nombre para mostrar. */
13
+ @Expose()
14
+ @IsString()
15
+ @IsNotEmpty()
16
+ @MaxLength(60)
17
+ label: string;
18
+
19
+ @Expose()
20
+ @IsString()
21
+ @IsNotEmpty()
22
+ @MaxLength(64)
23
+ moduleName: string;
24
+
25
+ @Expose()
26
+ @IsString()
27
+ @IsNotEmpty()
28
+ @MaxLength(64)
29
+ benefitId: string;
30
+
31
+ @Expose()
32
+ @IsString()
33
+ @IsNotEmpty()
34
+ @MaxLength(256)
35
+ leafId: string;
36
+
37
+ @Expose()
38
+ @IsString()
39
+ @IsNotEmpty()
40
+ @MaxLength(64)
41
+ productId: string;
42
+
43
+ /** Vigencia en días de cada recarga; por defecto 30. */
44
+ @Expose()
45
+ @Transform(({ value }) => value ?? MOBILE_TOPUP_DEFAULT_VALIDITY_DAYS)
46
+ @IsInt()
47
+ @Min(1)
48
+ @Max(MOBILE_TOPUP_VALIDITY_DAYS_MAX)
49
+ validityDays: number;
50
+
51
+ /** Si está apagado, no se ofrece ni se acepta como operador. */
52
+ @Expose()
53
+ @IsBoolean()
54
+ enabled: boolean;
55
+
56
+ /** SOLO para mostrar el aviso de cambio de precio: lo escribe rewards en el servidor (el valor del cliente se ignora) y nunca se usa para cobrar ni pagar. */
57
+ @Expose()
58
+ @IsOptional()
59
+ @IsNumber({ maxDecimalPlaces: 2 })
60
+ @Min(0)
61
+ referencePrice?: number;
62
+ }
@@ -0,0 +1,22 @@
1
+ import { Expose, Type } from 'class-transformer';
2
+ import { ArrayMinSize, ArrayUnique, IsInt, Max, Min, ValidateNested } from 'class-validator';
3
+ import { MOBILE_TOPUP_MONTHS_MAX, MOBILE_TOPUP_MONTHS_MIN } from '../constants/MobileTopupLimits';
4
+ import { MobileTopupCarrierConfig } from './MobileTopupCarrierConfig';
5
+
6
+ /** Config del ítem `MOBILE_TOPUP`: cuántas recargas mensuales da y con qué operadores. */
7
+ export class MobileTopupItemConfig {
8
+ /** Cantidad de recargas mensuales (1–99). */
9
+ @Expose()
10
+ @IsInt()
11
+ @Min(MOBILE_TOPUP_MONTHS_MIN)
12
+ @Max(MOBILE_TOPUP_MONTHS_MAX)
13
+ months: number;
14
+
15
+ /** Operadores del ítem; `carrierId` único. Que haya al menos uno habilitado lo valida rewards-business. */
16
+ @Expose()
17
+ @ArrayMinSize(1)
18
+ @ArrayUnique((carrier: MobileTopupCarrierConfig) => carrier.carrierId)
19
+ @ValidateNested({ each: true })
20
+ @Type(() => MobileTopupCarrierConfig)
21
+ carriers: MobileTopupCarrierConfig[];
22
+ }
@@ -1,6 +1,7 @@
1
1
  import { Expose, Type } from 'class-transformer';
2
- import { IsEnum, IsNotEmpty, IsObject, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
2
+ import { IsEnum, IsNotEmpty, IsObject, IsOptional, IsString, Matches, MaxLength, ValidateNested } from 'class-validator';
3
3
  import { JsonValue } from '../../../common';
4
+ import { COST_CENTER_ID_MAX_LENGTH } from '../../../transaction/constants/costCenter';
4
5
  import { REWARD_ID_PATTERN } from '../../constants/BackofficeLimits';
5
6
  import { RewardStatusEnum } from '../../enums/RewardStatusEnum';
6
7
  import { RewardChargeToInput } from './RewardChargeToInput';
@@ -46,6 +47,17 @@ export class CatalogItemRequest {
46
47
  @Type(() => RewardChargeToInput)
47
48
  chargeTo: RewardChargeToInput;
48
49
 
50
+ /**
51
+ * Centro de costo con que el ledger imputa lo que esta recompensa paga (saldo, recarga). Viaja en cada
52
+ * `disburse`. Ausente o `null` = sin centro: el pago se asienta como `UNASSIGNED`.
53
+ */
54
+ @Expose()
55
+ @IsOptional()
56
+ @IsString()
57
+ @IsNotEmpty()
58
+ @MaxLength(COST_CENTER_ID_MAX_LENGTH)
59
+ costCenterId?: string | null;
60
+
49
61
  @Expose()
50
62
  @IsEnum(RewardStatusEnum)
51
63
  status: RewardStatusEnum;
@@ -12,6 +12,8 @@ export class CatalogItemResponse {
12
12
  config: { [key: string]: JsonValue };
13
13
  cost: RewardCost;
14
14
  chargeTo: RewardChargeTo;
15
+ /** Centro de costo de lo que paga esta recompensa; ausente = `UNASSIGNED` en el ledger. */
16
+ costCenterId?: string;
15
17
  /** Solo lectura: las calcula el tipo a partir de `config`. */
16
18
  dependencies: RewardDependency[];
17
19
  status: RewardStatusEnum;
@@ -1,5 +1,7 @@
1
1
  import { RewardChargeTo } from '../RewardChargeTo';
2
2
  import { RewardCost } from '../RewardCost';
3
+ import { RewardChargeKindEnum } from '../../enums/RewardChargeKindEnum';
4
+ import { RewardChargeAdjustment } from './RewardChargeAdjustment';
3
5
 
4
6
  /** Un cargo = un ítem que quedó GRANTED, con el costo CONGELADO en la entrega (no el actual del catálogo). Sin `source` (R4 lo guarda, no se expone). */
5
7
  export class ChargeRecord {
@@ -15,4 +17,13 @@ export class ChargeRecord {
15
17
  cost: RewardCost;
16
18
  chargeTo: RewardChargeTo;
17
19
  externalRef?: Record<string, string>;
20
+ /**
21
+ * Tipo de registro; ausente ⇒ `GRANT`.
22
+ * En `PRICE_ADJUSTMENT`: `chargeTo = { partnerId: 'FIADO', partnerName }`, `cost.amount = round2(paidUnitPrice − chargedUnitPrice)`
23
+ * CON SIGNO (`+` a cargo de Fiado, `−` a favor), `cost.currency = MXN`, `grantedAt` = momento de la recarga (de ahí sale el mes UTC del libro)
24
+ * y `grantId`/`itemKey` = los del aporte. Un monto negativo es nuevo: sumas y export CSV deben tolerarlo.
25
+ */
26
+ kind?: RewardChargeKindEnum;
27
+ /** Detalle del ajuste; solo en registros `PRICE_ADJUSTMENT`. */
28
+ adjustment?: RewardChargeAdjustment;
18
29
  }
@@ -1,7 +1,10 @@
1
1
  import { Expose } from 'class-transformer';
2
2
  import { IsInt, IsNotEmpty, IsNumber, IsOptional, IsPositive, IsString, MaxLength, Min } from 'class-validator';
3
3
 
4
- /** Guarda la configuración de la recarga Bait (producto en Multicenter y precio mensual). */
4
+ /**
5
+ * Guarda la configuración de la recarga Bait (producto en Multicenter y precio mensual).
6
+ * @deprecated Reemplazado por MobileTopupItemConfig; se borra en T8 cuando rewards-business y backoffice dejen de importarlo.
7
+ */
5
8
  export class MobileTopupConfigRequest {
6
9
  @Expose()
7
10
  @IsString()
@@ -1,3 +1,4 @@
1
+ /** @deprecated Reemplazado por MobileTopupItemConfig; se borra en T8 cuando rewards-business y backoffice dejen de importarlos. */
1
2
  export interface MobileTopupConfigResponse {
2
3
  moduleName: string;
3
4
  benefitId: string;
@@ -0,0 +1,10 @@
1
+ /** Snapshot del operador elegido al otorgar; el calendario se muestra aunque el operador luego se apague o elimine del ítem. */
2
+ export interface MobileTopupContributionCarrier {
3
+ carrierId: string;
4
+ label: string;
5
+ moduleName: string;
6
+ benefitId: string;
7
+ leafId: string;
8
+ productId: string;
9
+ validityDays: number;
10
+ }
@@ -1,3 +1,5 @@
1
+ import { MobileTopupContributionCarrier } from './MobileTopupContributionCarrier';
2
+
1
3
  export interface MobileTopupContributionResponse {
2
4
  grantId: string;
3
5
  itemKey: string;
@@ -6,4 +8,10 @@ export interface MobileTopupContributionResponse {
6
8
  sourceReference: string;
7
9
  campaignId?: string;
8
10
  addedAt: number;
11
+ /** Snapshot del operador elegido al otorgar; solo falta en aportes legacy. */
12
+ carrier?: MobileTopupContributionCarrier;
13
+ /** Precio unitario cobrado al aliado (MXN, 2 decimales); no cambia nunca. Solo falta en aportes legacy. */
14
+ unitPrice?: number;
15
+ /** Centro de costo del ítem al otorgar; lo llevan todas las recargas del aporte. Ausente = `UNASSIGNED`. */
16
+ costCenterId?: string;
9
17
  }
@@ -0,0 +1,16 @@
1
+ import { RewardChargeTo } from '../RewardChargeTo';
2
+
3
+ /** Detalle de un ajuste de precio de una recarga: qué se cobró al aliado, qué se pagó y a quién se le cobró originalmente. */
4
+ export class RewardChargeAdjustment {
5
+ /** Folio de la recarga que pagó la diferencia. */
6
+ rechargeFolio: string;
7
+ /** Número de la recarga dentro del aporte (1..months). */
8
+ rechargeNumber: number;
9
+ carrierId: string;
10
+ /** `unitPrice` del aporte: lo cobrado al aliado. */
11
+ chargedUnitPrice: number;
12
+ /** Precio vigente pagado en esa recarga. */
13
+ paidUnitPrice: number;
14
+ /** Aliado original del premio. */
15
+ originalChargeTo: RewardChargeTo;
16
+ }
@@ -0,0 +1,7 @@
1
+ /** Llaves de las dependencias de entrada de un ítem `MOBILE_TOPUP`. */
2
+ export enum MobileTopupDependencyKeyEnum {
3
+ /** Número celular que recibe la recarga. */
4
+ PHONE = 'phone',
5
+ /** Operador elegido (opciones = `carrierId` habilitados). */
6
+ CARRIER = 'carrier',
7
+ }
@@ -0,0 +1,7 @@
1
+ /** Tipo de registro del libro de cargos ("Entregas y costos"). */
2
+ export enum RewardChargeKindEnum {
3
+ /** Cargo de un ítem entregado (es el valor implícito cuando `kind` no viene). */
4
+ GRANT = 'GRANT',
5
+ /** Ajuste simétrico a cargo/favor de FIADO por diferencia de precio en una recarga. */
6
+ PRICE_ADJUSTMENT = 'PRICE_ADJUSTMENT',
7
+ }
@@ -10,4 +10,8 @@ export enum RewardItemCodeEnum {
10
10
  TOPUP_REJECTED = 'TOPUP_REJECTED',
11
11
  /** Un operador dio el ítem por fallido. */
12
12
  ITEM_DISMISSED = 'ITEM_DISMISSED',
13
+ /** El operador (`carrier`) es desconocido, está deshabilitado, o falta habiendo más de uno habilitado. */
14
+ CARRIER_NOT_AVAILABLE = 'CARRIER_NOT_AVAILABLE',
15
+ /** El plan del operador está deshabilitado o no existe en benefits, no es `FIXED` o su precio es ≤ 0. */
16
+ TOPUP_PLAN_UNAVAILABLE = 'TOPUP_PLAN_UNAVAILABLE',
13
17
  }
@@ -15,6 +15,8 @@ export * from './enums/DeliveryTopDimensionEnum';
15
15
  export * from './enums/DeliveryTopByEnum';
16
16
  export * from './enums/MobileTopupPlanStatusEnum';
17
17
  export * from './enums/MobileTopupRechargeStatusEnum';
18
+ export * from './enums/MobileTopupDependencyKeyEnum';
19
+ export * from './enums/RewardChargeKindEnum';
18
20
 
19
21
  //Types
20
22
  export * from './types/RewardInputs';
@@ -23,9 +25,12 @@ export * from './types/RewardInputs';
23
25
  export * from './dtos/RewardCost';
24
26
  export * from './dtos/RewardChargeTo';
25
27
  export * from './dtos/RewardDependency';
28
+ export * from './dtos/MobileTopupCarrierConfig';
29
+ export * from './dtos/MobileTopupItemConfig';
26
30
 
27
31
  //Constants
28
32
  export * from './constants/RewardsLimits';
33
+ export * from './constants/MobileTopupLimits';
29
34
 
30
35
  //Validators
31
36
  export * from './validators/IsRewardTags';
@@ -67,6 +72,7 @@ export * from './dtos/backoffice/BackofficeGrantAttemptResponse';
67
72
  export * from './dtos/backoffice/BackofficeGrantItemResponse';
68
73
  export * from './dtos/backoffice/BackofficeGrantResponse';
69
74
  export * from './dtos/backoffice/GrantListResponse';
75
+ export * from './dtos/backoffice/RewardChargeAdjustment';
70
76
  export * from './dtos/backoffice/ChargeRecord';
71
77
  export * from './dtos/backoffice/ChargeListResponse';
72
78
  export * from './dtos/backoffice/ChargesQuery';
@@ -77,6 +83,7 @@ export * from './dtos/backoffice/DeliveryMetricsPoint';
77
83
  export * from './dtos/backoffice/DeliveryTopEntry';
78
84
  export * from './dtos/backoffice/MobileTopupConfigRequest';
79
85
  export * from './dtos/backoffice/MobileTopupConfigResponse';
86
+ export * from './dtos/backoffice/MobileTopupContributionCarrier';
80
87
  export * from './dtos/backoffice/MobileTopupContributionResponse';
81
88
  export * from './dtos/backoffice/MobileTopupRechargeResponse';
82
89
  export * from './dtos/backoffice/MobileTopupPlanResponse';