@fiado/type-kit 3.408.0 → 3.410.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.
@@ -369,13 +369,24 @@ describe('LoanDeviceNotifyRequest', () => {
369
369
  expect(JSON.stringify(itemsError)).toContain(field);
370
370
  });
371
371
 
372
- it.each(['notificationCode', 'title', 'content'] as const)('falla si %s no viene', async field => {
372
+ it.each(['notificationCode', 'title', 'content'] as const)('valida sin %s', async field => {
373
373
  const { [field]: _omitted, ...rest } = validNotifyItem;
374
374
  const dto = plainToInstance(LoanDeviceNotifyRequest, notifyWithItems([rest]));
375
375
  const errors = await validate(dto);
376
- const itemsError = errors.find(e => e.property === 'items');
377
- expect(itemsError).toBeDefined();
378
- expect(JSON.stringify(itemsError)).toContain(field);
376
+ expect(errors).toEqual([]);
377
+ });
378
+
379
+ it('valida el ítem que manda el motor: noticeType y nada de texto', async () => {
380
+ const items = [
381
+ {
382
+ creditId: CREDIT_ID,
383
+ intensity: DeviceNotifyIntensityEnum.FULLSCREEN,
384
+ noticeType: MdmNoticeTypeEnum.OVERDUE_1_DAY,
385
+ },
386
+ ];
387
+ const dto = plainToInstance(LoanDeviceNotifyRequest, notifyWithItems(items));
388
+ const errors = await validate(dto);
389
+ expect(errors).toEqual([]);
379
390
  });
380
391
 
381
392
  it.each(['notificationCode', 'title', 'content'] as const)('falla si %s no es string', async field => {
@@ -116,6 +116,38 @@ describe('DeviceNotifyRequest.noticeType', () => {
116
116
  });
117
117
  });
118
118
 
119
+ describe('DeviceNotifyRequest — los tres textos son opcionales', () => {
120
+ /** Aviso como lo manda el motor: solo el id agnóstico, sin relleno de texto. */
121
+ const noticeOnly = {
122
+ imei: validNotify.imei,
123
+ intensity: validNotify.intensity,
124
+ noticeType: MdmNoticeTypeEnum.OVERDUE_1_DAY,
125
+ operationReference: validNotify.operationReference,
126
+ };
127
+
128
+ it('valida con noticeType y sin ninguno de los tres textos', async () => {
129
+ const dto = plainToInstance(DeviceNotifyRequest, noticeOnly);
130
+ const errors = await validate(dto);
131
+ expect(errors).toEqual([]);
132
+ expect(dto.notificationCode).toBeUndefined();
133
+ expect(dto.title).toBeUndefined();
134
+ expect(dto.content).toBeUndefined();
135
+ });
136
+
137
+ it.each(['notificationCode', 'title', 'content'] as const)('valida sin %s', async field => {
138
+ const { [field]: _omitted, ...rest } = validNotify;
139
+ const dto = plainToInstance(DeviceNotifyRequest, rest);
140
+ const errors = await validate(dto);
141
+ expect(errors).toEqual([]);
142
+ });
143
+
144
+ it.each(['notificationCode', 'title', 'content'] as const)('falla si %s viene vacío', async field => {
145
+ const dto = plainToInstance(DeviceNotifyRequest, { ...validNotify, [field]: '' });
146
+ const errors = await validate(dto);
147
+ expect(hasConstraint(errors, field, 'isNotEmpty')).toBe(true);
148
+ });
149
+ });
150
+
119
151
  describe('MdmNoticeTypeEnum', () => {
120
152
  it('expone los diez avisos del catálogo de cobranza', () => {
121
153
  expect(Object.values(MdmNoticeTypeEnum)).toEqual([
@@ -2,22 +2,20 @@ import { DeviceNotifyIntensityEnum } from '../../mdm/enums/DeviceNotifyIntensity
2
2
  import { MdmNoticeTypeEnum } from '../../mdm/enums/MdmNoticeTypeEnum';
3
3
  /**
4
4
  * Ítem de notificación: a qué crédito se le avisa y con qué aviso.
5
- * El aviso viaja como `noticeType`; los tres campos de texto siguen siendo obligatorios porque
6
- * Datacultr usa el código del catálogo y Trustonic el texto crudo.
5
+ * El aviso viaja como `noticeType`; los tres campos de texto son el camino legacy.
7
6
  */
8
7
  export declare class LoanDeviceNotifyItem {
9
8
  creditId: string;
10
9
  intensity: DeviceNotifyIntensityEnum;
11
10
  /**
12
11
  * Id agnóstico del aviso; cada connector lo traduce a lo que su proveedor entiende.
13
- * Los connectors lo van a preferir sobre `notificationCode`/`title`/`content`;
14
- * hasta entonces esos tres siguen siendo la fuente.
12
+ * Cuando viaja, manda: los connectors ignoran `notificationCode`, `title` y `content`.
15
13
  */
16
14
  noticeType?: MdmNoticeTypeEnum;
17
- /** Código de notificación del catálogo de Datacultr. Queda por compatibilidad durante la migración a `noticeType`. */
18
- notificationCode: string;
19
- /** Título crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
20
- title: string;
21
- /** Cuerpo crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
22
- content: string;
15
+ /** Código del catálogo de Datacultr. Camino legacy: solo se lee si no viaja `noticeType`. */
16
+ notificationCode?: string;
17
+ /** Título crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
18
+ title?: string;
19
+ /** Cuerpo crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
20
+ content?: string;
23
21
  }
@@ -17,8 +17,7 @@ const MdmNoticeTypeEnum_1 = require("../../mdm/enums/MdmNoticeTypeEnum");
17
17
  const CreditIdPattern_1 = require("../constants/CreditIdPattern");
18
18
  /**
19
19
  * Ítem de notificación: a qué crédito se le avisa y con qué aviso.
20
- * El aviso viaja como `noticeType`; los tres campos de texto siguen siendo obligatorios porque
21
- * Datacultr usa el código del catálogo y Trustonic el texto crudo.
20
+ * El aviso viaja como `noticeType`; los tres campos de texto son el camino legacy.
22
21
  */
23
22
  class LoanDeviceNotifyItem {
24
23
  }
@@ -41,6 +40,7 @@ __decorate([
41
40
  ], LoanDeviceNotifyItem.prototype, "noticeType", void 0);
42
41
  __decorate([
43
42
  (0, class_transformer_1.Expose)(),
43
+ (0, class_validator_1.IsOptional)(),
44
44
  (0, class_validator_1.IsString)(),
45
45
  (0, class_validator_1.IsNotEmpty)(),
46
46
  (0, class_validator_1.MaxLength)(64),
@@ -48,6 +48,7 @@ __decorate([
48
48
  ], LoanDeviceNotifyItem.prototype, "notificationCode", void 0);
49
49
  __decorate([
50
50
  (0, class_transformer_1.Expose)(),
51
+ (0, class_validator_1.IsOptional)(),
51
52
  (0, class_validator_1.IsString)(),
52
53
  (0, class_validator_1.IsNotEmpty)(),
53
54
  (0, class_validator_1.MaxLength)(128),
@@ -55,6 +56,7 @@ __decorate([
55
56
  ], LoanDeviceNotifyItem.prototype, "title", void 0);
56
57
  __decorate([
57
58
  (0, class_transformer_1.Expose)(),
59
+ (0, class_validator_1.IsOptional)(),
58
60
  (0, class_validator_1.IsString)(),
59
61
  (0, class_validator_1.IsNotEmpty)(),
60
62
  (0, class_validator_1.MaxLength)(1024),
@@ -17,7 +17,10 @@ export declare class LoanInstallment {
17
17
  ivaCents: number;
18
18
  /** capital + interés + IVA. */
19
19
  totalCents: number;
20
- /** Saldo insoluto de capital tras aplicar la cuota. */
20
+ /**
21
+ * Lo que debe ESTA cuota, no el insoluto del crédito: nace igual a `totalCents`. Hoy nadie lo
22
+ * decrementa — quien aplique pagos es quien lo consume.
23
+ */
21
24
  outstandingBalanceCents: number;
22
25
  paidAt?: string;
23
26
  createdBy: string;
@@ -12,6 +12,10 @@ export interface LoanInstallmentResponse {
12
12
  interestCents: number;
13
13
  ivaCents: number;
14
14
  totalCents: number;
15
+ /**
16
+ * Lo que debe ESTA cuota, no el insoluto del crédito: nace igual a `totalCents`. Hoy nadie lo
17
+ * decrementa — quien aplique pagos es quien lo consume.
18
+ */
15
19
  outstandingBalanceCents: number;
16
20
  paidAt?: string;
17
21
  }
@@ -5,15 +5,14 @@ export declare class DeviceNotifyRequest {
5
5
  intensity: DeviceNotifyIntensityEnum;
6
6
  /**
7
7
  * Id agnóstico del aviso; cada connector lo traduce a lo que su proveedor entiende.
8
- * Los connectors lo van a preferir sobre `notificationCode`/`title`/`content`;
9
- * hasta entonces esos tres siguen siendo la fuente.
8
+ * Cuando viaja, manda: los connectors ignoran `notificationCode`, `title` y `content`.
10
9
  */
11
10
  noticeType?: MdmNoticeTypeEnum;
12
- /** Código de notificación del catálogo de Datacultr. Queda por compatibilidad durante la migración a `noticeType`. */
13
- notificationCode: string;
14
- /** Título crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
15
- title: string;
16
- /** Cuerpo crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
17
- content: string;
11
+ /** Código del catálogo de Datacultr. Camino legacy: solo se lee si no viaja `noticeType`. */
12
+ notificationCode?: string;
13
+ /** Título crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
14
+ title?: string;
15
+ /** Cuerpo crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
16
+ content?: string;
18
17
  operationReference: string;
19
18
  }
@@ -36,18 +36,21 @@ __decorate([
36
36
  ], DeviceNotifyRequest.prototype, "noticeType", void 0);
37
37
  __decorate([
38
38
  (0, class_transformer_1.Expose)(),
39
+ (0, class_validator_1.IsOptional)(),
39
40
  (0, class_validator_1.IsString)(),
40
41
  (0, class_validator_1.IsNotEmpty)(),
41
42
  __metadata("design:type", String)
42
43
  ], DeviceNotifyRequest.prototype, "notificationCode", void 0);
43
44
  __decorate([
44
45
  (0, class_transformer_1.Expose)(),
46
+ (0, class_validator_1.IsOptional)(),
45
47
  (0, class_validator_1.IsString)(),
46
48
  (0, class_validator_1.IsNotEmpty)(),
47
49
  __metadata("design:type", String)
48
50
  ], DeviceNotifyRequest.prototype, "title", void 0);
49
51
  __decorate([
50
52
  (0, class_transformer_1.Expose)(),
53
+ (0, class_validator_1.IsOptional)(),
51
54
  (0, class_validator_1.IsString)(),
52
55
  (0, class_validator_1.IsNotEmpty)(),
53
56
  __metadata("design:type", String)
@@ -3,6 +3,11 @@ export declare enum MdmErrorCodeEnum {
3
3
  PROVIDER_NOT_SUPPORTED = "PROVIDER_NOT_SUPPORTED",
4
4
  /** El proveedor la tiene, pero ESTE equipo no la admite por cómo se enroló. No es terminal. */
5
5
  DEVICE_CAPABILITY_NOT_SUPPORTED = "DEVICE_CAPABILITY_NOT_SUPPORTED",
6
+ /**
7
+ * El proveedor la tiene y el equipo la admite, pero no en el ESTADO en que está ahora. No es
8
+ * terminal ni describe cómo se enroló: el mismo equipo, en otro estado, sí acepta la operación.
9
+ */
10
+ DEVICE_STATE_NOT_SUPPORTED = "DEVICE_STATE_NOT_SUPPORTED",
6
11
  /** No hay connector cableado para ese proveedor: reintentar nunca lo resuelve. */
7
12
  CONNECTOR_NOT_WIRED = "CONNECTOR_NOT_WIRED",
8
13
  DEVICE_NOT_FOUND = "DEVICE_NOT_FOUND",
@@ -7,6 +7,11 @@ var MdmErrorCodeEnum;
7
7
  MdmErrorCodeEnum["PROVIDER_NOT_SUPPORTED"] = "PROVIDER_NOT_SUPPORTED";
8
8
  /** El proveedor la tiene, pero ESTE equipo no la admite por cómo se enroló. No es terminal. */
9
9
  MdmErrorCodeEnum["DEVICE_CAPABILITY_NOT_SUPPORTED"] = "DEVICE_CAPABILITY_NOT_SUPPORTED";
10
+ /**
11
+ * El proveedor la tiene y el equipo la admite, pero no en el ESTADO en que está ahora. No es
12
+ * terminal ni describe cómo se enroló: el mismo equipo, en otro estado, sí acepta la operación.
13
+ */
14
+ MdmErrorCodeEnum["DEVICE_STATE_NOT_SUPPORTED"] = "DEVICE_STATE_NOT_SUPPORTED";
10
15
  /** No hay connector cableado para ese proveedor: reintentar nunca lo resuelve. */
11
16
  MdmErrorCodeEnum["CONNECTOR_NOT_WIRED"] = "CONNECTOR_NOT_WIRED";
12
17
  MdmErrorCodeEnum["DEVICE_NOT_FOUND"] = "DEVICE_NOT_FOUND";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiado/type-kit",
3
- "version": "3.408.0",
3
+ "version": "3.410.0",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "types": "bin/index.d.ts",
@@ -6,8 +6,7 @@ import { CREDIT_ID_MESSAGE, CREDIT_ID_PATTERN } from '../constants/CreditIdPatte
6
6
 
7
7
  /**
8
8
  * Ítem de notificación: a qué crédito se le avisa y con qué aviso.
9
- * El aviso viaja como `noticeType`; los tres campos de texto siguen siendo obligatorios porque
10
- * Datacultr usa el código del catálogo y Trustonic el texto crudo.
9
+ * El aviso viaja como `noticeType`; los tres campos de texto son el camino legacy.
11
10
  */
12
11
  export class LoanDeviceNotifyItem {
13
12
  @Expose()
@@ -20,32 +19,34 @@ export class LoanDeviceNotifyItem {
20
19
 
21
20
  /**
22
21
  * Id agnóstico del aviso; cada connector lo traduce a lo que su proveedor entiende.
23
- * Los connectors lo van a preferir sobre `notificationCode`/`title`/`content`;
24
- * hasta entonces esos tres siguen siendo la fuente.
22
+ * Cuando viaja, manda: los connectors ignoran `notificationCode`, `title` y `content`.
25
23
  */
26
24
  @Expose()
27
25
  @IsOptional()
28
26
  @IsEnum(MdmNoticeTypeEnum)
29
27
  noticeType?: MdmNoticeTypeEnum;
30
28
 
31
- /** Código de notificación del catálogo de Datacultr. Queda por compatibilidad durante la migración a `noticeType`. */
29
+ /** Código del catálogo de Datacultr. Camino legacy: solo se lee si no viaja `noticeType`. */
32
30
  @Expose()
31
+ @IsOptional()
33
32
  @IsString()
34
33
  @IsNotEmpty()
35
34
  @MaxLength(64)
36
- notificationCode: string;
35
+ notificationCode?: string;
37
36
 
38
- /** Título crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
37
+ /** Título crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
39
38
  @Expose()
39
+ @IsOptional()
40
40
  @IsString()
41
41
  @IsNotEmpty()
42
42
  @MaxLength(128)
43
- title: string;
43
+ title?: string;
44
44
 
45
- /** Cuerpo crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
45
+ /** Cuerpo crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
46
46
  @Expose()
47
+ @IsOptional()
47
48
  @IsString()
48
49
  @IsNotEmpty()
49
50
  @MaxLength(1024)
50
- content: string;
51
+ content?: string;
51
52
  }
@@ -47,7 +47,10 @@ export class LoanInstallment {
47
47
  @IsInt()
48
48
  totalCents!: number;
49
49
 
50
- /** Saldo insoluto de capital tras aplicar la cuota. */
50
+ /**
51
+ * Lo que debe ESTA cuota, no el insoluto del crédito: nace igual a `totalCents`. Hoy nadie lo
52
+ * decrementa — quien aplique pagos es quien lo consume.
53
+ */
51
54
  @Expose()
52
55
  @IsInt()
53
56
  outstandingBalanceCents!: number;
@@ -13,6 +13,10 @@ export interface LoanInstallmentResponse {
13
13
  interestCents: number;
14
14
  ivaCents: number;
15
15
  totalCents: number;
16
+ /**
17
+ * Lo que debe ESTA cuota, no el insoluto del crédito: nace igual a `totalCents`. Hoy nadie lo
18
+ * decrementa — quien aplique pagos es quien lo consume.
19
+ */
16
20
  outstandingBalanceCents: number;
17
21
  paidAt?: string;
18
22
  }
@@ -15,31 +15,33 @@ export class DeviceNotifyRequest {
15
15
 
16
16
  /**
17
17
  * Id agnóstico del aviso; cada connector lo traduce a lo que su proveedor entiende.
18
- * Los connectors lo van a preferir sobre `notificationCode`/`title`/`content`;
19
- * hasta entonces esos tres siguen siendo la fuente.
18
+ * Cuando viaja, manda: los connectors ignoran `notificationCode`, `title` y `content`.
20
19
  */
21
20
  @Expose()
22
21
  @IsOptional()
23
22
  @IsEnum(MdmNoticeTypeEnum)
24
23
  noticeType?: MdmNoticeTypeEnum;
25
24
 
26
- /** Código de notificación del catálogo de Datacultr. Queda por compatibilidad durante la migración a `noticeType`. */
25
+ /** Código del catálogo de Datacultr. Camino legacy: solo se lee si no viaja `noticeType`. */
27
26
  @Expose()
27
+ @IsOptional()
28
28
  @IsString()
29
29
  @IsNotEmpty()
30
- notificationCode: string;
30
+ notificationCode?: string;
31
31
 
32
- /** Título crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
32
+ /** Título crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
33
33
  @Expose()
34
+ @IsOptional()
34
35
  @IsString()
35
36
  @IsNotEmpty()
36
- title: string;
37
+ title?: string;
37
38
 
38
- /** Cuerpo crudo que exige Trustonic. Queda por compatibilidad durante la migración a `noticeType`. */
39
+ /** Cuerpo crudo para Trustonic. Camino legacy: solo se lee si no viaja `noticeType`. */
39
40
  @Expose()
41
+ @IsOptional()
40
42
  @IsString()
41
43
  @IsNotEmpty()
42
- content: string;
44
+ content?: string;
43
45
 
44
46
  @Expose()
45
47
  @IsString()
@@ -3,6 +3,11 @@ export enum MdmErrorCodeEnum {
3
3
  PROVIDER_NOT_SUPPORTED = "PROVIDER_NOT_SUPPORTED",
4
4
  /** El proveedor la tiene, pero ESTE equipo no la admite por cómo se enroló. No es terminal. */
5
5
  DEVICE_CAPABILITY_NOT_SUPPORTED = "DEVICE_CAPABILITY_NOT_SUPPORTED",
6
+ /**
7
+ * El proveedor la tiene y el equipo la admite, pero no en el ESTADO en que está ahora. No es
8
+ * terminal ni describe cómo se enroló: el mismo equipo, en otro estado, sí acepta la operación.
9
+ */
10
+ DEVICE_STATE_NOT_SUPPORTED = "DEVICE_STATE_NOT_SUPPORTED",
6
11
  /** No hay connector cableado para ese proveedor: reintentar nunca lo resuelve. */
7
12
  CONNECTOR_NOT_WIRED = "CONNECTOR_NOT_WIRED",
8
13
  DEVICE_NOT_FOUND = "DEVICE_NOT_FOUND",