@fiado/type-kit 3.496.0 → 3.498.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.
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import {
3
3
  EvaluatedSalePromotion,
4
+ PromotionAppliesToEnum,
4
5
  RetailPromotionsErrorCodeEnum,
5
6
  SalePromotionKindEnum,
6
7
  } from '../../../src/retailPromotions/index';
@@ -17,6 +18,7 @@ const basePromotion: EvaluatedSalePromotion = {
17
18
  giftOptions: [],
18
19
  giftChooseCount: null,
19
20
  afterSale: [],
21
+ appliesTo: PromotionAppliesToEnum.SUREKEEP_ONLY,
20
22
  };
21
23
 
22
24
  describe('EvaluatedSalePromotion.blockedBy', () => {
@@ -1,6 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import {
3
3
  EvaluatedSalePromotion,
4
+ PromotionAppliesToEnum,
4
5
  SalePromotionKindEnum,
5
6
  SalePromotionLeverEnum,
6
7
  resolveSalePromotionKind,
@@ -40,6 +41,7 @@ describe('EvaluatedSalePromotion.kind', () => {
40
41
  giftOptions: [],
41
42
  giftChooseCount: 1,
42
43
  afterSale: [],
44
+ appliesTo: PromotionAppliesToEnum.SUREKEEP_ONLY,
43
45
  };
44
46
  expect(promotion.kind).toBe(SalePromotionKindEnum.GIFT);
45
47
  });
@@ -0,0 +1,71 @@
1
+ import 'reflect-metadata';
2
+ import {
3
+ EvaluatedSalePromotion,
4
+ PromotionAppliesToEnum,
5
+ RetailPromotionsErrorCodeEnum,
6
+ SalePromotionConditions,
7
+ SalePromotionKindEnum,
8
+ StoreSalePromotionItem,
9
+ } from '../../../src/retailPromotions/index';
10
+
11
+ const storeItem: StoreSalePromotionItem = {
12
+ promotionId: 'promo-1',
13
+ version: 1,
14
+ name: 'Regalo',
15
+ customerText: 'Llévate un regalo',
16
+ levers: { gift: null, deviceDiscount: null, accessoryDiscount: null, coupon: null, walletBonus: null, extendedWarranty: null, airtime: null },
17
+ scope: { storeIds: null, productCategories: null, tiers: null, skus: null },
18
+ appliesTo: PromotionAppliesToEnum.ANY_FINANCIER,
19
+ };
20
+
21
+ const evaluated: EvaluatedSalePromotion = {
22
+ promotionId: 'promo-1',
23
+ version: 1,
24
+ kind: SalePromotionKindEnum.SALE,
25
+ name: 'Regalo',
26
+ customerText: 'Llévate un regalo',
27
+ levers: [],
28
+ lines: [],
29
+ totalDiscountCents: 0,
30
+ giftOptions: [],
31
+ giftChooseCount: null,
32
+ afterSale: [],
33
+ appliesTo: PromotionAppliesToEnum.SUREKEEP_ONLY,
34
+ };
35
+
36
+ describe('SalePromotionConditions', () => {
37
+ it('todas sus llaves son opcionales', () => {
38
+ const none: SalePromotionConditions = {};
39
+ expect(Object.keys(none)).toHaveLength(0);
40
+ });
41
+
42
+ it('acepta las tres condiciones del cliente', () => {
43
+ const all: SalePromotionConditions = { oncePerCustomer: true, requiresActiveSurekeepCredit: true, segmentIds: ['seg-1'] };
44
+ expect(all.segmentIds).toEqual(['seg-1']);
45
+ });
46
+ });
47
+
48
+ describe('StoreSalePromotionItem', () => {
49
+ it('trae appliesTo y no trae condiciones ni bloqueo cuando no aplican', () => {
50
+ expect(storeItem.appliesTo).toBe(PromotionAppliesToEnum.ANY_FINANCIER);
51
+ expect(storeItem.conditions).toBeUndefined();
52
+ expect(storeItem.blockedBy).toBeUndefined();
53
+ });
54
+
55
+ it('acepta condiciones y el motivo de bloqueo', () => {
56
+ const blocked: StoreSalePromotionItem = {
57
+ ...storeItem,
58
+ conditions: { oncePerCustomer: true },
59
+ blockedBy: RetailPromotionsErrorCodeEnum.CUSTOMER_NOT_IDENTIFIED,
60
+ };
61
+ expect(blocked.blockedBy).toBe(RetailPromotionsErrorCodeEnum.CUSTOMER_NOT_IDENTIFIED);
62
+ });
63
+ });
64
+
65
+ describe('EvaluatedSalePromotion', () => {
66
+ it('trae appliesTo y condiciones opcionales', () => {
67
+ const withConditions: EvaluatedSalePromotion = { ...evaluated, conditions: { requiresActiveSurekeepCredit: true } };
68
+ expect(withConditions.appliesTo).toBe(PromotionAppliesToEnum.SUREKEEP_ONLY);
69
+ expect(withConditions.conditions?.requiresActiveSurekeepCredit).toBe(true);
70
+ });
71
+ });
@@ -2,6 +2,7 @@ import { CouponScopeEnum } from '../../enums/CouponScopeEnum';
2
2
  import { CouponStatusEnum } from '../../enums/CouponStatusEnum';
3
3
  import { EntitlementKindEnum } from '../../enums/EntitlementKindEnum';
4
4
  import { EntitlementStateEnum } from '../../enums/EntitlementStateEnum';
5
+ import { PromotionAppliesToEnum } from '../../enums/PromotionAppliesToEnum';
5
6
  import { RetailPromotionsErrorCodeEnum } from '../../enums/RetailPromotionsErrorCodeEnum';
6
7
  import { SaleCouponAvailabilityEnum } from '../../enums/SaleCouponAvailabilityEnum';
7
8
  import { SalePromotionKindEnum } from '../../enums/SalePromotionKindEnum';
@@ -9,6 +10,12 @@ import { SalePromotionLeverEnum } from '../../enums/SalePromotionLeverEnum';
9
10
  import { DiscountValue } from '../DiscountValue';
10
11
  import { LinePromotionDiscount } from '../LinePromotionDiscount';
11
12
  import { SalePromotionLevers, SalePromotionScope } from '../SalePromotionLevers';
13
+ /** Condiciones del cliente que pide la promo; solo vienen las que aplican. */
14
+ export interface SalePromotionConditions {
15
+ oncePerCustomer?: boolean;
16
+ requiresActiveSurekeepCredit?: boolean;
17
+ segmentIds?: string[];
18
+ }
12
19
  /** Promo vigente en la tienda de la sesión, para los chips de «Elige el teléfono». */
13
20
  export interface StoreSalePromotionItem {
14
21
  promotionId: string;
@@ -18,6 +25,11 @@ export interface StoreSalePromotionItem {
18
25
  levers: SalePromotionLevers;
19
26
  /** Para cruzar con cada equipo; todo `null` = fila «Toda la tienda». */
20
27
  scope: SalePromotionScope;
28
+ /** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
29
+ appliesTo: PromotionAppliesToEnum;
30
+ conditions?: SalePromotionConditions;
31
+ /** Si viene, todavía no se puede decidir para este cliente (ej. CUSTOMER_NOT_IDENTIFIED). */
32
+ blockedBy?: RetailPromotionsErrorCodeEnum | null;
21
33
  }
22
34
  export interface ListStoreSalePromotionsResponse {
23
35
  items: StoreSalePromotionItem[];
@@ -49,6 +61,9 @@ export interface EvaluatedSalePromotion {
49
61
  giftOptions: GiftOption[];
50
62
  giftChooseCount: number | null;
51
63
  afterSale: AfterSaleBenefit[];
64
+ /** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
65
+ appliesTo: PromotionAppliesToEnum;
66
+ conditions?: SalePromotionConditions;
52
67
  /** Si viene, la promo se muestra pero no se puede elegir; dice por qué (ej. CUSTOMER_NOT_IDENTIFIED). */
53
68
  blockedBy?: RetailPromotionsErrorCodeEnum | null;
54
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.496.0",
3
+ "version": "3.498.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -2,6 +2,7 @@ import { CouponScopeEnum } from '../../enums/CouponScopeEnum';
2
2
  import { CouponStatusEnum } from '../../enums/CouponStatusEnum';
3
3
  import { EntitlementKindEnum } from '../../enums/EntitlementKindEnum';
4
4
  import { EntitlementStateEnum } from '../../enums/EntitlementStateEnum';
5
+ import { PromotionAppliesToEnum } from '../../enums/PromotionAppliesToEnum';
5
6
  import { RetailPromotionsErrorCodeEnum } from '../../enums/RetailPromotionsErrorCodeEnum';
6
7
  import { SaleCouponAvailabilityEnum } from '../../enums/SaleCouponAvailabilityEnum';
7
8
  import { SalePromotionKindEnum } from '../../enums/SalePromotionKindEnum';
@@ -10,6 +11,13 @@ import { DiscountValue } from '../DiscountValue';
10
11
  import { LinePromotionDiscount } from '../LinePromotionDiscount';
11
12
  import { SalePromotionLevers, SalePromotionScope } from '../SalePromotionLevers';
12
13
 
14
+ /** Condiciones del cliente que pide la promo; solo vienen las que aplican. */
15
+ export interface SalePromotionConditions {
16
+ oncePerCustomer?: boolean;
17
+ requiresActiveSurekeepCredit?: boolean;
18
+ segmentIds?: string[];
19
+ }
20
+
13
21
  /** Promo vigente en la tienda de la sesión, para los chips de «Elige el teléfono». */
14
22
  export interface StoreSalePromotionItem {
15
23
  promotionId: string;
@@ -19,6 +27,11 @@ export interface StoreSalePromotionItem {
19
27
  levers: SalePromotionLevers;
20
28
  /** Para cruzar con cada equipo; todo `null` = fila «Toda la tienda». */
21
29
  scope: SalePromotionScope;
30
+ /** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
31
+ appliesTo: PromotionAppliesToEnum;
32
+ conditions?: SalePromotionConditions;
33
+ /** Si viene, todavía no se puede decidir para este cliente (ej. CUSTOMER_NOT_IDENTIFIED). */
34
+ blockedBy?: RetailPromotionsErrorCodeEnum | null;
22
35
  }
23
36
 
24
37
  export interface ListStoreSalePromotionsResponse {
@@ -54,6 +67,9 @@ export interface EvaluatedSalePromotion {
54
67
  giftOptions: GiftOption[];
55
68
  giftChooseCount: number | null;
56
69
  afterSale: AfterSaleBenefit[];
70
+ /** SUREKEEP_ONLY = solo con crédito SureKeep; ANY_FINANCIER = también contado o derivada. */
71
+ appliesTo: PromotionAppliesToEnum;
72
+ conditions?: SalePromotionConditions;
57
73
  /** Si viene, la promo se muestra pero no se puede elegir; dice por qué (ej. CUSTOMER_NOT_IDENTIFIED). */
58
74
  blockedBy?: RetailPromotionsErrorCodeEnum | null;
59
75
  }