@fiado/type-kit 3.590.0 → 3.591.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.
@@ -8,20 +8,68 @@ import {
8
8
  MessageMomentBlockEnum,
9
9
  MessageMomentEnum,
10
10
  OTP_MOMENT_VARIABLES,
11
+ REFERRAL_BONUS_ALWAYS_VARIABLES,
12
+ REFERRAL_BONUS_CONDITIONAL_VARIABLES,
13
+ REFERRAL_COUPON_ALWAYS_VARIABLES,
14
+ REFERRAL_COUPON_CONDITIONAL_VARIABLES,
11
15
  RESTRUCTURE_MOMENT_VARIABLES,
12
16
  TEMPLATE_PLACEHOLDER_PATTERN,
13
17
  momentByMessageType,
14
18
  momentByTemplateId,
15
19
  } from '../../../src/messageMoments/index';
16
20
 
21
+ const NON_CREDIT_MOMENTS = new Set<string>([
22
+ MessageMomentEnum.OTP_CODE,
23
+ MessageMomentEnum.REFERRAL_BONUS_CREDITED,
24
+ MessageMomentEnum.REFERRAL_COUPON_ISSUED,
25
+ ]);
26
+
17
27
  describe('MESSAGE_MOMENT_CATALOG', () => {
18
- it('trae los 38 momentos del recorrido del crédito', () => {
19
- expect(MESSAGE_MOMENT_CATALOG).toHaveLength(38);
28
+ it('trae los 38 momentos del crédito más los 2 de referidos', () => {
29
+ expect(MESSAGE_MOMENT_CATALOG).toHaveLength(40);
20
30
  });
21
31
 
22
32
  it('ni el templateId ni el messageType se repiten', () => {
23
- expect(momentByTemplateId.size).toBe(38);
24
- expect(momentByMessageType.size).toBe(38);
33
+ expect(momentByTemplateId.size).toBe(40);
34
+ expect(momentByMessageType.size).toBe(40);
35
+ });
36
+
37
+ it('los momentos de referidos cierran el catálogo, en su bloque', () => {
38
+ expect(MESSAGE_MOMENT_CATALOG.slice(-2).map((m) => [m.templateId, m.messageType, m.blockId])).toEqual([
39
+ ['PM-080', MessageMomentEnum.REFERRAL_BONUS_CREDITED, MessageMomentBlockEnum.REFERRALS],
40
+ ['PM-081', MessageMomentEnum.REFERRAL_COUPON_ISSUED, MessageMomentBlockEnum.REFERRALS],
41
+ ]);
42
+ expect(MessageMomentBlockEnum.REFERRALS).toBe('referrals');
43
+ });
44
+
45
+ it('el premio abonado ofrece cliente y monto, y el nombre del referido cuando se conoce', () => {
46
+ const bonus = momentByTemplateId.get('PM-080');
47
+ expect(REFERRAL_BONUS_ALWAYS_VARIABLES).toEqual(['cliente_nombre', 'monto']);
48
+ expect(REFERRAL_BONUS_CONDITIONAL_VARIABLES).toEqual(['referido_nombre']);
49
+ expect(bonus?.alwaysVariables).toEqual(REFERRAL_BONUS_ALWAYS_VARIABLES);
50
+ expect(bonus?.conditionalVariables).toEqual(REFERRAL_BONUS_CONDITIONAL_VARIABLES);
51
+ });
52
+
53
+ it('el cupón emitido ofrece código, descuento y vigencia, y la tienda cuando no aplica en todas', () => {
54
+ const coupon = momentByTemplateId.get('PM-081');
55
+ expect(REFERRAL_COUPON_ALWAYS_VARIABLES).toEqual(['cliente_nombre', 'codigo', 'descuento', 'vigencia']);
56
+ expect(REFERRAL_COUPON_CONDITIONAL_VARIABLES).toEqual(['tienda']);
57
+ expect(coupon?.alwaysVariables).toEqual(REFERRAL_COUPON_ALWAYS_VARIABLES);
58
+ expect(coupon?.conditionalVariables).toEqual(REFERRAL_COUPON_CONDITIONAL_VARIABLES);
59
+ });
60
+
61
+ it('los momentos de referidos no ofrecen variables del crédito', () => {
62
+ const credit = new Set([...CREDIT_MOMENT_ALWAYS_VARIABLES, ...CREDIT_MOMENT_CONDITIONAL_VARIABLES].filter((n) => n !== 'cliente_nombre' && n !== 'monto' && n !== 'tienda'));
63
+ for (const moment of MESSAGE_MOMENT_CATALOG.filter((m) => m.blockId === MessageMomentBlockEnum.REFERRALS)) {
64
+ expect([...moment.alwaysVariables, ...moment.conditionalVariables].filter((n) => credit.has(n))).toEqual([]);
65
+ }
66
+ });
67
+
68
+ it('en ningún momento una variable es siempre y condicional a la vez', () => {
69
+ for (const moment of MESSAGE_MOMENT_CATALOG) {
70
+ const always = new Set(moment.alwaysVariables);
71
+ expect(moment.conditionalVariables.filter((n) => always.has(n))).toEqual([]);
72
+ }
25
73
  });
26
74
 
27
75
  it('todo templateId tiene la forma PM-NNN', () => {
@@ -47,8 +95,8 @@ describe('MESSAGE_MOMENT_CATALOG', () => {
47
95
  expect(otp?.conditionalVariables).toEqual([]);
48
96
  });
49
97
 
50
- it('los demás momentos ofrecen las variables del crédito más las propias del momento', () => {
51
- for (const moment of MESSAGE_MOMENT_CATALOG.filter((m) => m.messageType !== MessageMomentEnum.OTP_CODE)) {
98
+ it('los momentos del crédito ofrecen sus variables más las propias del momento', () => {
99
+ for (const moment of MESSAGE_MOMENT_CATALOG.filter((m) => !NON_CREDIT_MOMENTS.has(m.messageType))) {
52
100
  const own = MOMENT_SPECIFIC_VARIABLES[moment.messageType] ?? [];
53
101
  expect(moment.alwaysVariables).toEqual([...CREDIT_MOMENT_ALWAYS_VARIABLES, ...own]);
54
102
  expect(moment.conditionalVariables).toEqual(CREDIT_MOMENT_CONDITIONAL_VARIABLES);
@@ -70,7 +118,7 @@ describe('MESSAGE_MOMENT_CATALOG', () => {
70
118
  it('una variable propia no se cuela en otro momento', () => {
71
119
  const own = new Set(Object.values(MOMENT_SPECIFIC_VARIABLES).flat());
72
120
  const owners = new Set(Object.keys(MOMENT_SPECIFIC_VARIABLES));
73
- for (const moment of MESSAGE_MOMENT_CATALOG.filter((m) => !owners.has(m.messageType))) {
121
+ for (const moment of MESSAGE_MOMENT_CATALOG.filter((m) => !owners.has(m.messageType) && !NON_CREDIT_MOMENTS.has(m.messageType))) {
74
122
  expect(moment.alwaysVariables.filter((name) => own.has(name))).toEqual([]);
75
123
  }
76
124
  });
@@ -10,7 +10,7 @@ export interface MessageMomentIdentity {
10
10
  alwaysVariables: readonly string[];
11
11
  conditionalVariables: readonly string[];
12
12
  }
13
- /** Los 38 momentos EN ORDEN de recorrido del crédito. `PM-071` apunta al OTP de plataforma. */
13
+ /** Los 38 momentos del crédito EN ORDEN de recorrido y al final los de referidos. `PM-071` apunta al OTP de plataforma. */
14
14
  export declare const MESSAGE_MOMENT_CATALOG: readonly MessageMomentIdentity[];
15
15
  /** La identidad por id de ficha (`PM-030`). */
16
16
  export declare const momentByTemplateId: ReadonlyMap<string, MessageMomentIdentity>;
@@ -14,9 +14,13 @@ function creditMoment(templateId, messageType, blockId) {
14
14
  conditionalVariables: MessageMomentVariables_1.CREDIT_MOMENT_CONDITIONAL_VARIABLES,
15
15
  };
16
16
  }
17
+ /** Un momento fuera del crédito: solo las variables que su emisor manda. */
18
+ function standaloneMoment(templateId, messageType, blockId, alwaysVariables, conditionalVariables = []) {
19
+ return { templateId, messageType, blockId, alwaysVariables, conditionalVariables };
20
+ }
17
21
  const B = MessageMomentBlockEnum_1.MessageMomentBlockEnum;
18
22
  const M = MessageMomentEnum_1.MessageMomentEnum;
19
- /** Los 38 momentos EN ORDEN de recorrido del crédito. `PM-071` apunta al OTP de plataforma. */
23
+ /** Los 38 momentos del crédito EN ORDEN de recorrido y al final los de referidos. `PM-071` apunta al OTP de plataforma. */
20
24
  exports.MESSAGE_MOMENT_CATALOG = [
21
25
  creditMoment('PM-001', M.APPLICATION_APPROVED, B.ORIGINATION),
22
26
  creditMoment('PM-002', M.APPLICATION_REJECTED, B.ORIGINATION),
@@ -50,18 +54,14 @@ exports.MESSAGE_MOMENT_CATALOG = [
50
54
  creditMoment('PM-062', M.SETTLEMENT_BUREAU_NOTICE, B.CLOSURE),
51
55
  creditMoment('PM-063', M.REENTRY_INVITATION, B.CLOSURE),
52
56
  creditMoment('PM-070', M.APP_WELCOME, B.SERVICE),
53
- {
54
- templateId: 'PM-071',
55
- messageType: M.OTP_CODE,
56
- blockId: B.SERVICE,
57
- alwaysVariables: MessageMomentVariables_1.OTP_MOMENT_VARIABLES,
58
- conditionalVariables: [],
59
- },
57
+ standaloneMoment('PM-071', M.OTP_CODE, B.SERVICE, MessageMomentVariables_1.OTP_MOMENT_VARIABLES),
60
58
  creditMoment('PM-072', M.SECURITY_ALERT, B.SERVICE),
61
59
  creditMoment('PM-073', M.PROFILE_CHANGE_CONFIRMED, B.SERVICE),
62
60
  creditMoment('PM-074', M.MONTHLY_STATEMENT, B.SERVICE),
63
61
  creditMoment('PM-075', M.CAT_TERMS_NOTICE, B.SERVICE),
64
62
  creditMoment('PM-076', M.PRIVACY_ARCO_NOTICE, B.SERVICE),
63
+ standaloneMoment('PM-080', M.REFERRAL_BONUS_CREDITED, B.REFERRALS, MessageMomentVariables_1.REFERRAL_BONUS_ALWAYS_VARIABLES, MessageMomentVariables_1.REFERRAL_BONUS_CONDITIONAL_VARIABLES),
64
+ standaloneMoment('PM-081', M.REFERRAL_COUPON_ISSUED, B.REFERRALS, MessageMomentVariables_1.REFERRAL_COUPON_ALWAYS_VARIABLES, MessageMomentVariables_1.REFERRAL_COUPON_CONDITIONAL_VARIABLES),
65
65
  ];
66
66
  /** La identidad por id de ficha (`PM-030`). */
67
67
  exports.momentByTemplateId = new Map(exports.MESSAGE_MOMENT_CATALOG.map((moment) => [moment.templateId, moment]));
@@ -5,6 +5,14 @@ export declare const CREDIT_MOMENT_ALWAYS_VARIABLES: readonly string[];
5
5
  export declare const CREDIT_MOMENT_CONDITIONAL_VARIABLES: readonly string[];
6
6
  /** El OTP lo arma messages-business: llena `code` y su alias posicional `var1`. */
7
7
  export declare const OTP_MOMENT_VARIABLES: readonly string[];
8
+ /** Premio de referido abonado a la cuenta PCF: a quién y cuánto. */
9
+ export declare const REFERRAL_BONUS_ALWAYS_VARIABLES: readonly string[];
10
+ /** El referido solo se nombra cuando el premio es de quien recomendó. */
11
+ export declare const REFERRAL_BONUS_CONDITIONAL_VARIABLES: readonly string[];
12
+ /** Cupón de referido emitido: el código, su descuento ya formateado y hasta cuándo vale. */
13
+ export declare const REFERRAL_COUPON_ALWAYS_VARIABLES: readonly string[];
14
+ /** La tienda solo viaja cuando el cupón no vale en todas. */
15
+ export declare const REFERRAL_COUPON_CONDITIONAL_VARIABLES: readonly string[];
8
16
  /** Lo que el plan nuevo de una reestructura le dice al cliente. */
9
17
  export declare const RESTRUCTURE_MOMENT_VARIABLES: readonly string[];
10
18
  /** Variables que solo emite su momento, siempre con valor. */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MOMENT_SPECIFIC_VARIABLES = exports.RESTRUCTURE_MOMENT_VARIABLES = exports.OTP_MOMENT_VARIABLES = exports.CREDIT_MOMENT_CONDITIONAL_VARIABLES = exports.CREDIT_MOMENT_ALWAYS_VARIABLES = void 0;
3
+ exports.MOMENT_SPECIFIC_VARIABLES = exports.RESTRUCTURE_MOMENT_VARIABLES = exports.REFERRAL_COUPON_CONDITIONAL_VARIABLES = exports.REFERRAL_COUPON_ALWAYS_VARIABLES = exports.REFERRAL_BONUS_CONDITIONAL_VARIABLES = exports.REFERRAL_BONUS_ALWAYS_VARIABLES = exports.OTP_MOMENT_VARIABLES = exports.CREDIT_MOMENT_CONDITIONAL_VARIABLES = exports.CREDIT_MOMENT_ALWAYS_VARIABLES = void 0;
4
4
  const MessageMomentEnum_1 = require("../enums/MessageMomentEnum");
5
5
  /** Variables del crédito que el emisor manda siempre con valor. */
6
6
  exports.CREDIT_MOMENT_ALWAYS_VARIABLES = [
@@ -29,6 +29,14 @@ exports.CREDIT_MOMENT_CONDITIONAL_VARIABLES = [
29
29
  ];
30
30
  /** El OTP lo arma messages-business: llena `code` y su alias posicional `var1`. */
31
31
  exports.OTP_MOMENT_VARIABLES = ['code', 'var1'];
32
+ /** Premio de referido abonado a la cuenta PCF: a quién y cuánto. */
33
+ exports.REFERRAL_BONUS_ALWAYS_VARIABLES = ['cliente_nombre', 'monto'];
34
+ /** El referido solo se nombra cuando el premio es de quien recomendó. */
35
+ exports.REFERRAL_BONUS_CONDITIONAL_VARIABLES = ['referido_nombre'];
36
+ /** Cupón de referido emitido: el código, su descuento ya formateado y hasta cuándo vale. */
37
+ exports.REFERRAL_COUPON_ALWAYS_VARIABLES = ['cliente_nombre', 'codigo', 'descuento', 'vigencia'];
38
+ /** La tienda solo viaja cuando el cupón no vale en todas. */
39
+ exports.REFERRAL_COUPON_CONDITIONAL_VARIABLES = ['tienda'];
32
40
  /** Lo que el plan nuevo de una reestructura le dice al cliente. */
33
41
  exports.RESTRUCTURE_MOMENT_VARIABLES = ['plazo_nuevo', 'cuota_nueva', 'saldo_nuevo'];
34
42
  /** Variables que solo emite su momento, siempre con valor. */
@@ -7,5 +7,6 @@ export declare enum MessageMomentBlockEnum {
7
7
  DEVICE_LOCK = "deviceLock",
8
8
  EXCEPTIONS = "exceptions",
9
9
  CLOSURE = "closure",
10
- SERVICE = "service"
10
+ SERVICE = "service",
11
+ REFERRALS = "referrals"
11
12
  }
@@ -12,4 +12,5 @@ var MessageMomentBlockEnum;
12
12
  MessageMomentBlockEnum["EXCEPTIONS"] = "exceptions";
13
13
  MessageMomentBlockEnum["CLOSURE"] = "closure";
14
14
  MessageMomentBlockEnum["SERVICE"] = "service";
15
+ MessageMomentBlockEnum["REFERRALS"] = "referrals";
15
16
  })(MessageMomentBlockEnum || (exports.MessageMomentBlockEnum = MessageMomentBlockEnum = {}));
@@ -38,5 +38,7 @@ export declare enum MessageMomentEnum {
38
38
  PROFILE_CHANGE_CONFIRMED = "PROFILE_CHANGE_CONFIRMED",
39
39
  MONTHLY_STATEMENT = "MONTHLY_STATEMENT",
40
40
  CAT_TERMS_NOTICE = "CAT_TERMS_NOTICE",
41
- PRIVACY_ARCO_NOTICE = "PRIVACY_ARCO_NOTICE"
41
+ PRIVACY_ARCO_NOTICE = "PRIVACY_ARCO_NOTICE",
42
+ REFERRAL_BONUS_CREDITED = "REFERRAL_BONUS_CREDITED",
43
+ REFERRAL_COUPON_ISSUED = "REFERRAL_COUPON_ISSUED"
42
44
  }
@@ -43,4 +43,6 @@ var MessageMomentEnum;
43
43
  MessageMomentEnum["MONTHLY_STATEMENT"] = "MONTHLY_STATEMENT";
44
44
  MessageMomentEnum["CAT_TERMS_NOTICE"] = "CAT_TERMS_NOTICE";
45
45
  MessageMomentEnum["PRIVACY_ARCO_NOTICE"] = "PRIVACY_ARCO_NOTICE";
46
+ MessageMomentEnum["REFERRAL_BONUS_CREDITED"] = "REFERRAL_BONUS_CREDITED";
47
+ MessageMomentEnum["REFERRAL_COUPON_ISSUED"] = "REFERRAL_COUPON_ISSUED";
46
48
  })(MessageMomentEnum || (exports.MessageMomentEnum = MessageMomentEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.590.0",
3
+ "version": "3.591.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -5,6 +5,10 @@ import {
5
5
  CREDIT_MOMENT_CONDITIONAL_VARIABLES,
6
6
  MOMENT_SPECIFIC_VARIABLES,
7
7
  OTP_MOMENT_VARIABLES,
8
+ REFERRAL_BONUS_ALWAYS_VARIABLES,
9
+ REFERRAL_BONUS_CONDITIONAL_VARIABLES,
10
+ REFERRAL_COUPON_ALWAYS_VARIABLES,
11
+ REFERRAL_COUPON_CONDITIONAL_VARIABLES,
8
12
  } from './MessageMomentVariables';
9
13
 
10
14
  /** Quién es un momento: su id de ficha, su plantilla, su bloque y las variables que emite. */
@@ -29,10 +33,21 @@ function creditMoment(templateId: string, messageType: MessageMomentEnum, blockI
29
33
  };
30
34
  }
31
35
 
36
+ /** Un momento fuera del crédito: solo las variables que su emisor manda. */
37
+ function standaloneMoment(
38
+ templateId: string,
39
+ messageType: MessageMomentEnum,
40
+ blockId: MessageMomentBlockEnum,
41
+ alwaysVariables: readonly string[],
42
+ conditionalVariables: readonly string[] = [],
43
+ ): MessageMomentIdentity {
44
+ return { templateId, messageType, blockId, alwaysVariables, conditionalVariables };
45
+ }
46
+
32
47
  const B = MessageMomentBlockEnum;
33
48
  const M = MessageMomentEnum;
34
49
 
35
- /** Los 38 momentos EN ORDEN de recorrido del crédito. `PM-071` apunta al OTP de plataforma. */
50
+ /** Los 38 momentos del crédito EN ORDEN de recorrido y al final los de referidos. `PM-071` apunta al OTP de plataforma. */
36
51
  export const MESSAGE_MOMENT_CATALOG: readonly MessageMomentIdentity[] = [
37
52
  creditMoment('PM-001', M.APPLICATION_APPROVED, B.ORIGINATION),
38
53
  creditMoment('PM-002', M.APPLICATION_REJECTED, B.ORIGINATION),
@@ -66,18 +81,14 @@ export const MESSAGE_MOMENT_CATALOG: readonly MessageMomentIdentity[] = [
66
81
  creditMoment('PM-062', M.SETTLEMENT_BUREAU_NOTICE, B.CLOSURE),
67
82
  creditMoment('PM-063', M.REENTRY_INVITATION, B.CLOSURE),
68
83
  creditMoment('PM-070', M.APP_WELCOME, B.SERVICE),
69
- {
70
- templateId: 'PM-071',
71
- messageType: M.OTP_CODE,
72
- blockId: B.SERVICE,
73
- alwaysVariables: OTP_MOMENT_VARIABLES,
74
- conditionalVariables: [],
75
- },
84
+ standaloneMoment('PM-071', M.OTP_CODE, B.SERVICE, OTP_MOMENT_VARIABLES),
76
85
  creditMoment('PM-072', M.SECURITY_ALERT, B.SERVICE),
77
86
  creditMoment('PM-073', M.PROFILE_CHANGE_CONFIRMED, B.SERVICE),
78
87
  creditMoment('PM-074', M.MONTHLY_STATEMENT, B.SERVICE),
79
88
  creditMoment('PM-075', M.CAT_TERMS_NOTICE, B.SERVICE),
80
89
  creditMoment('PM-076', M.PRIVACY_ARCO_NOTICE, B.SERVICE),
90
+ standaloneMoment('PM-080', M.REFERRAL_BONUS_CREDITED, B.REFERRALS, REFERRAL_BONUS_ALWAYS_VARIABLES, REFERRAL_BONUS_CONDITIONAL_VARIABLES),
91
+ standaloneMoment('PM-081', M.REFERRAL_COUPON_ISSUED, B.REFERRALS, REFERRAL_COUPON_ALWAYS_VARIABLES, REFERRAL_COUPON_CONDITIONAL_VARIABLES),
81
92
  ];
82
93
 
83
94
  /** La identidad por id de ficha (`PM-030`). */
@@ -30,6 +30,18 @@ export const CREDIT_MOMENT_CONDITIONAL_VARIABLES: readonly string[] = [
30
30
  /** El OTP lo arma messages-business: llena `code` y su alias posicional `var1`. */
31
31
  export const OTP_MOMENT_VARIABLES: readonly string[] = ['code', 'var1'];
32
32
 
33
+ /** Premio de referido abonado a la cuenta PCF: a quién y cuánto. */
34
+ export const REFERRAL_BONUS_ALWAYS_VARIABLES: readonly string[] = ['cliente_nombre', 'monto'];
35
+
36
+ /** El referido solo se nombra cuando el premio es de quien recomendó. */
37
+ export const REFERRAL_BONUS_CONDITIONAL_VARIABLES: readonly string[] = ['referido_nombre'];
38
+
39
+ /** Cupón de referido emitido: el código, su descuento ya formateado y hasta cuándo vale. */
40
+ export const REFERRAL_COUPON_ALWAYS_VARIABLES: readonly string[] = ['cliente_nombre', 'codigo', 'descuento', 'vigencia'];
41
+
42
+ /** La tienda solo viaja cuando el cupón no vale en todas. */
43
+ export const REFERRAL_COUPON_CONDITIONAL_VARIABLES: readonly string[] = ['tienda'];
44
+
33
45
  /** Lo que el plan nuevo de una reestructura le dice al cliente. */
34
46
  export const RESTRUCTURE_MOMENT_VARIABLES: readonly string[] = ['plazo_nuevo', 'cuota_nueva', 'saldo_nuevo'];
35
47
 
@@ -8,4 +8,5 @@ export enum MessageMomentBlockEnum {
8
8
  EXCEPTIONS = 'exceptions',
9
9
  CLOSURE = 'closure',
10
10
  SERVICE = 'service',
11
+ REFERRALS = 'referrals',
11
12
  }
@@ -47,4 +47,7 @@ export enum MessageMomentEnum {
47
47
  MONTHLY_STATEMENT = 'MONTHLY_STATEMENT',
48
48
  CAT_TERMS_NOTICE = 'CAT_TERMS_NOTICE',
49
49
  PRIVACY_ARCO_NOTICE = 'PRIVACY_ARCO_NOTICE',
50
+
51
+ REFERRAL_BONUS_CREDITED = 'REFERRAL_BONUS_CREDITED',
52
+ REFERRAL_COUPON_ISSUED = 'REFERRAL_COUPON_ISSUED',
50
53
  }