@fiado/type-kit 3.552.0 → 3.553.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 (85) hide show
  1. package/_test_/unit/common/InputPatternValidators.test.ts +64 -0
  2. package/_test_/unit/common/InputPatterns.test.ts +104 -0
  3. package/_test_/unit/retailCatalog/backofficeRequests.test.ts +1 -1
  4. package/_test_/unit/retailOrg/dtos/requests/inputPatternRequests.test.ts +93 -0
  5. package/bin/common/constants/InputPatterns.d.ts +25 -0
  6. package/bin/common/constants/InputPatterns.js +28 -0
  7. package/bin/common/decorators/UpperCase.d.ts +2 -0
  8. package/bin/common/decorators/UpperCase.js +7 -0
  9. package/bin/common/helpers/imeiChecksum.d.ts +2 -0
  10. package/bin/common/helpers/imeiChecksum.js +20 -0
  11. package/bin/common/index.d.ts +8 -0
  12. package/bin/common/index.js +10 -0
  13. package/bin/common/validators/IsMxPhone.d.ts +3 -0
  14. package/bin/common/validators/IsMxPhone.js +8 -0
  15. package/bin/common/validators/IsMxZipCode.d.ts +3 -0
  16. package/bin/common/validators/IsMxZipCode.js +8 -0
  17. package/bin/common/validators/IsRfc.d.ts +3 -0
  18. package/bin/common/validators/IsRfc.js +8 -0
  19. package/bin/common/validators/IsSku.d.ts +3 -0
  20. package/bin/common/validators/IsSku.js +8 -0
  21. package/bin/common/validators/matchesInputPattern.d.ts +3 -0
  22. package/bin/common/validators/matchesInputPattern.js +16 -0
  23. package/bin/helpers/constans/regex.js +2 -1
  24. package/bin/loanCredit/dtos/LoanContractDetails.js +2 -2
  25. package/bin/loanCredit/dtos/LoanDeviceEnrollItem.js +4 -4
  26. package/bin/retailCatalog/constants/SkuPattern.d.ts +2 -2
  27. package/bin/retailCatalog/constants/SkuPattern.js +5 -3
  28. package/bin/retailCatalog/dtos/ProductComponent.js +1 -1
  29. package/bin/retailCatalog/dtos/requests/BackofficeCreateKitRequest.js +1 -1
  30. package/bin/retailCatalog/dtos/requests/BackofficeCreateProductRequest.js +1 -1
  31. package/bin/retailCatalog/dtos/requests/BackofficeCreateServiceRequest.js +1 -1
  32. package/bin/retailCatalog/dtos/requests/BackofficeCreateTransferRequest.js +1 -1
  33. package/bin/retailCatalog/dtos/requests/BackofficeRegisterAdjustmentRequest.js +1 -1
  34. package/bin/retailCatalog/dtos/requests/BackofficeRegisterEntryRequest.js +1 -1
  35. package/bin/retailCatalog/dtos/requests/CreateProductRequest.js +1 -1
  36. package/bin/retailCatalog/dtos/requests/ReturnPieceCondition.js +1 -1
  37. package/bin/retailCatalog/dtos/requests/SyncInventoryRequest.js +1 -1
  38. package/bin/retailIntegration/constants/retailIntegrationLimits.d.ts +1 -1
  39. package/bin/retailIntegration/constants/retailIntegrationLimits.js +2 -2
  40. package/bin/retailOrg/dtos/requests/CreateRetailUserRequest.js +2 -1
  41. package/bin/retailOrg/dtos/requests/CreateRetailerRequest.d.ts +1 -1
  42. package/bin/retailOrg/dtos/requests/CreateRetailerRequest.js +6 -2
  43. package/bin/retailOrg/dtos/requests/CreateStoreRequest.js +2 -1
  44. package/bin/retailOrg/dtos/requests/CreateSubdistributorRequest.d.ts +1 -1
  45. package/bin/retailOrg/dtos/requests/CreateSubdistributorRequest.js +6 -2
  46. package/bin/retailOrg/dtos/requests/ProvisionRetailUserRequest.js +2 -1
  47. package/bin/retailOrg/dtos/requests/RetailAddressInput.d.ts +1 -1
  48. package/bin/retailOrg/dtos/requests/RetailAddressInput.js +2 -2
  49. package/bin/retailOrg/dtos/requests/UpdateRetailUserRequest.js +2 -1
  50. package/bin/retailOrg/dtos/requests/UpdateRetailerRequest.js +2 -1
  51. package/bin/retailOrg/dtos/requests/UpdateStoreRequest.js +2 -1
  52. package/package.json +1 -1
  53. package/src/common/constants/InputPatterns.ts +32 -0
  54. package/src/common/decorators/UpperCase.ts +5 -0
  55. package/src/common/helpers/imeiChecksum.ts +16 -0
  56. package/src/common/index.ts +12 -0
  57. package/src/common/validators/IsMxPhone.ts +7 -0
  58. package/src/common/validators/IsMxZipCode.ts +7 -0
  59. package/src/common/validators/IsRfc.ts +7 -0
  60. package/src/common/validators/IsSku.ts +7 -0
  61. package/src/common/validators/matchesInputPattern.ts +24 -0
  62. package/src/helpers/constans/regex.ts +2 -1
  63. package/src/loanCredit/dtos/LoanContractDetails.ts +1 -1
  64. package/src/loanCredit/dtos/LoanDeviceEnrollItem.ts +3 -3
  65. package/src/retailCatalog/constants/SkuPattern.ts +2 -2
  66. package/src/retailCatalog/dtos/ProductComponent.ts +2 -2
  67. package/src/retailCatalog/dtos/requests/BackofficeCreateKitRequest.ts +2 -2
  68. package/src/retailCatalog/dtos/requests/BackofficeCreateProductRequest.ts +2 -2
  69. package/src/retailCatalog/dtos/requests/BackofficeCreateServiceRequest.ts +2 -2
  70. package/src/retailCatalog/dtos/requests/BackofficeCreateTransferRequest.ts +2 -2
  71. package/src/retailCatalog/dtos/requests/BackofficeRegisterAdjustmentRequest.ts +2 -2
  72. package/src/retailCatalog/dtos/requests/BackofficeRegisterEntryRequest.ts +2 -2
  73. package/src/retailCatalog/dtos/requests/CreateProductRequest.ts +2 -2
  74. package/src/retailCatalog/dtos/requests/ReturnPieceCondition.ts +2 -2
  75. package/src/retailCatalog/dtos/requests/SyncInventoryRequest.ts +2 -2
  76. package/src/retailIntegration/constants/retailIntegrationLimits.ts +2 -2
  77. package/src/retailOrg/dtos/requests/CreateRetailUserRequest.ts +2 -1
  78. package/src/retailOrg/dtos/requests/CreateRetailerRequest.ts +8 -4
  79. package/src/retailOrg/dtos/requests/CreateStoreRequest.ts +2 -1
  80. package/src/retailOrg/dtos/requests/CreateSubdistributorRequest.ts +8 -4
  81. package/src/retailOrg/dtos/requests/ProvisionRetailUserRequest.ts +2 -1
  82. package/src/retailOrg/dtos/requests/RetailAddressInput.ts +3 -3
  83. package/src/retailOrg/dtos/requests/UpdateRetailUserRequest.ts +2 -1
  84. package/src/retailOrg/dtos/requests/UpdateRetailerRequest.ts +2 -1
  85. package/src/retailOrg/dtos/requests/UpdateStoreRequest.ts +2 -1
@@ -10,14 +10,14 @@ import {
10
10
  Validate,
11
11
  ValidateIf,
12
12
  } from 'class-validator';
13
- import { SKU_PATTERN } from '../../constants/SkuPattern';
13
+ import { SKU_MESSAGE, SKU_PATTERN } from '../../constants/SkuPattern';
14
14
  import { ReturnConditionEnum } from '../../enums/ReturnConditionEnum';
15
15
  import { IsPieceRefConstraint } from '../../validators/IsPieceRefConstraint';
16
16
 
17
17
  /** Condición de una pieza devuelta; ausente = GOOD. Un accesorio por cantidad se declara con sku + qty. */
18
18
  export class ReturnPieceCondition {
19
19
  @Expose()
20
- @Matches(SKU_PATTERN, { message: 'sku admite solo [A-Za-z0-9-]' })
20
+ @Matches(SKU_PATTERN, { message: SKU_MESSAGE })
21
21
  @Length(1, 64)
22
22
  @IsString()
23
23
  sku!: string;
@@ -12,7 +12,7 @@ import {
12
12
  Min,
13
13
  ValidateNested,
14
14
  } from 'class-validator';
15
- import { SKU_PATTERN } from '../../constants/SkuPattern';
15
+ import { SKU_MESSAGE, SKU_PATTERN } from '../../constants/SkuPattern';
16
16
  import { MdmLockModeEnum } from '../../enums/MdmLockModeEnum';
17
17
  import { MdmProviderEnum } from '../../enums/MdmProviderEnum';
18
18
  import { ProductCategoryEnum } from '../../enums/ProductCategoryEnum';
@@ -38,7 +38,7 @@ export class SyncPrice {
38
38
 
39
39
  /** Producto tal como llega de Zentral. */
40
40
  export class SyncProduct {
41
- @Matches(SKU_PATTERN, { message: 'sku admite solo [A-Za-z0-9-]' })
41
+ @Matches(SKU_PATTERN, { message: SKU_MESSAGE })
42
42
  @Length(1, 64)
43
43
  @IsString()
44
44
  sku!: string;
@@ -21,8 +21,8 @@ export const RETAIL_STORE_CODE_MAX_LENGTH = 10;
21
21
  export const RETAIL_ZIP_CODE_MIN_LENGTH = 4;
22
22
  export const RETAIL_ZIP_CODE_MAX_LENGTH = 10;
23
23
 
24
- /** SKU del catálogo del retailer. */
25
- export const RETAIL_SKU_PATTERN = /^[A-Za-z0-9-]{1,64}$/;
24
+ /** SKU del catálogo del retailer: el charset de `SKU_PATTERN` con tope de 64. */
25
+ export const RETAIL_SKU_PATTERN = /^(?=.{1,64}$)[A-Za-z0-9-]+(?: +[A-Za-z0-9-]+)*$/;
26
26
 
27
27
  /** Decimal del contrato: string con dos decimales, nunca negativo. */
28
28
  export const RETAIL_DECIMAL_PATTERN = /^\d+\.\d{2}$/;
@@ -2,6 +2,7 @@ import { Expose } from 'class-transformer';
2
2
  import { IsArray, IsEnum, IsOptional, IsString } from 'class-validator';
3
3
  import { CollectorSeniorityEnum } from '../../enums/CollectorSeniorityEnum';
4
4
  import { EmploymentTypeEnum } from '../../enums/EmploymentTypeEnum';
5
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
5
6
 
6
7
  /**
7
8
  * Body de POST /retailers/:retailerId/users — alta de usuario retail (el `retailerId` sale del path;
@@ -42,7 +43,7 @@ export class CreateRetailUserRequest {
42
43
  /** Teléfono de contacto del usuario retail; opcional. */
43
44
  @Expose()
44
45
  @IsOptional()
45
- @IsString()
46
+ @IsMxPhone()
46
47
  phone?: string;
47
48
 
48
49
  /** Seniority del cobrador; solo aplica a usuarios retail con rol de cobrador. */
@@ -1,7 +1,10 @@
1
1
  import { Expose, Type } from 'class-transformer';
2
- import { IsDefined, IsEmail, IsEnum, IsString, Length, ValidateNested } from 'class-validator';
2
+ import { IsDefined, IsEmail, IsEnum, IsString, ValidateNested } from 'class-validator';
3
3
  import { RetailerTypeEnum } from '../../enums/RetailerTypeEnum';
4
4
  import { RetailAddressInput } from './RetailAddressInput';
5
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
6
+ import { IsRfc } from '../../../common/validators/IsRfc';
7
+ import { UpperCase } from '../../../common/decorators/UpperCase';
5
8
 
6
9
  /**
7
10
  * Body de POST /retailers — alta de un retailer raíz (SureKeep Fase 1 — pista Retail).
@@ -21,10 +24,11 @@ export class CreateRetailerRequest {
21
24
  @IsString()
22
25
  legalName!: string;
23
26
 
24
- /** RFC mexicano — 12 (persona moral / empresa) o 13 (persona física). */
27
+ /** RFC — 12 (persona moral) o 13 (persona física); se pasa a mayúsculas antes de validar. */
25
28
  @Expose()
26
29
  @IsString()
27
- @Length(12, 13)
30
+ @UpperCase()
31
+ @IsRfc()
28
32
  rfc!: string;
29
33
 
30
34
  @Expose()
@@ -32,7 +36,7 @@ export class CreateRetailerRequest {
32
36
  contactEmail!: string;
33
37
 
34
38
  @Expose()
35
- @IsString()
39
+ @IsMxPhone()
36
40
  contactPhone!: string;
37
41
 
38
42
  @Expose()
@@ -9,6 +9,7 @@ import {
9
9
  } from 'class-validator';
10
10
  import { GeoLocation } from '../GeoLocation';
11
11
  import { RetailAddressInput } from './RetailAddressInput';
12
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
12
13
 
13
14
  /**
14
15
  * Body de POST /retailers/:retailerId/stores — alta de tienda física (el `retailerId` sale del path).
@@ -44,7 +45,7 @@ export class CreateStoreRequest {
44
45
  location!: GeoLocation;
45
46
 
46
47
  @Expose()
47
- @IsString()
48
+ @IsMxPhone()
48
49
  phone!: string;
49
50
 
50
51
  /** Usuario retail responsable; `null` si no hay gerente asignado. */
@@ -1,7 +1,10 @@
1
1
  import { Expose, Type } from 'class-transformer';
2
- import { IsDefined, IsEmail, IsIn, IsString, Length, ValidateNested } from 'class-validator';
2
+ import { IsDefined, IsEmail, IsIn, IsString, ValidateNested } from 'class-validator';
3
3
  import { RetailerTypeEnum } from '../../enums/RetailerTypeEnum';
4
4
  import { RetailAddressInput } from './RetailAddressInput';
5
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
6
+ import { IsRfc } from '../../../common/validators/IsRfc';
7
+ import { UpperCase } from '../../../common/decorators/UpperCase';
5
8
 
6
9
  /**
7
10
  * Body de POST /retailers/:retailerId/subdistributors — alta de un retailer hijo colgando de
@@ -23,10 +26,11 @@ export class CreateSubdistributorRequest {
23
26
  @IsString()
24
27
  legalName!: string;
25
28
 
26
- /** RFC mexicano — 12 (persona moral / empresa) o 13 (persona física). */
29
+ /** RFC — 12 (persona moral) o 13 (persona física); se pasa a mayúsculas antes de validar. */
27
30
  @Expose()
28
31
  @IsString()
29
- @Length(12, 13)
32
+ @UpperCase()
33
+ @IsRfc()
30
34
  rfc!: string;
31
35
 
32
36
  @Expose()
@@ -34,7 +38,7 @@ export class CreateSubdistributorRequest {
34
38
  contactEmail!: string;
35
39
 
36
40
  @Expose()
37
- @IsString()
41
+ @IsMxPhone()
38
42
  contactPhone!: string;
39
43
 
40
44
  @Expose()
@@ -3,6 +3,7 @@ import { IsArray, IsEmail, IsEnum, IsOptional, IsString } from 'class-validator'
3
3
  import { CollectorSeniorityEnum } from '../../enums/CollectorSeniorityEnum';
4
4
  import { EmploymentTypeEnum } from '../../enums/EmploymentTypeEnum';
5
5
  import { PermissionScope } from '../../../platformRbac/enums/PermissionScope';
6
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
6
7
 
7
8
  /**
8
9
  * Body de POST /retailers/:retailerId/users/provision — alta de usuario retail ORQUESTADA (SureKeep F1,
@@ -64,7 +65,7 @@ export class ProvisionRetailUserRequest {
64
65
  /** Teléfono de contacto del usuario retail; opcional. */
65
66
  @Expose()
66
67
  @IsOptional()
67
- @IsString()
68
+ @IsMxPhone()
68
69
  phone?: string;
69
70
 
70
71
  /** Seniority del cobrador; solo aplica a usuarios retail con rol de cobrador. */
@@ -1,5 +1,6 @@
1
1
  import { Expose } from 'class-transformer';
2
2
  import { IsOptional, IsString, Length } from 'class-validator';
3
+ import { IsMxZipCode } from '../../../common/validators/IsMxZipCode';
3
4
 
4
5
  /**
5
6
  * Dirección comercial de entrada (input validado) para los requests de creación/edición del dominio
@@ -53,10 +54,9 @@ export class RetailAddressInput {
53
54
  @Length(1, 150)
54
55
  state!: string;
55
56
 
56
- /** Código postal (espejo de `LocationAddress.zipCode`). */
57
+ /** Código postal MX de 5 dígitos (espejo de `LocationAddress.zipCode`). */
57
58
  @Expose()
58
- @IsString()
59
- @Length(4, 10)
59
+ @IsMxZipCode()
60
60
  zipCode!: string;
61
61
 
62
62
  /** País ISO. OPCIONAL — sin slot en `LocationAddress` (TD-SKF1-007). */
@@ -2,6 +2,7 @@ import { Expose } from 'class-transformer';
2
2
  import { IsArray, IsEnum, IsOptional, IsString } from 'class-validator';
3
3
  import { CollectorSeniorityEnum } from '../../enums/CollectorSeniorityEnum';
4
4
  import { EmploymentTypeEnum } from '../../enums/EmploymentTypeEnum';
5
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
5
6
 
6
7
  /**
7
8
  * Body de PUT /users/:retailUserId — edición de usuario retail (campos editables opcionales).
@@ -33,7 +34,7 @@ export class UpdateRetailUserRequest {
33
34
  /** Teléfono de contacto del usuario retail; opcional. */
34
35
  @Expose()
35
36
  @IsOptional()
36
- @IsString()
37
+ @IsMxPhone()
37
38
  phone?: string;
38
39
 
39
40
  /** Seniority del cobrador; solo aplica a usuarios retail con rol de cobrador. */
@@ -1,6 +1,7 @@
1
1
  import { Expose, Type } from 'class-transformer';
2
2
  import { IsEmail, IsOptional, IsString, ValidateNested } from 'class-validator';
3
3
  import { RetailAddressInput } from './RetailAddressInput';
4
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
4
5
 
5
6
  /**
6
7
  * Body de PUT /retailers/:retailerId — edición de campos comerciales del retailer.
@@ -25,7 +26,7 @@ export class UpdateRetailerRequest {
25
26
 
26
27
  @Expose()
27
28
  @IsOptional()
28
- @IsString()
29
+ @IsMxPhone()
29
30
  contactPhone?: string;
30
31
 
31
32
  @Expose()
@@ -2,6 +2,7 @@ import { Expose, Type } from 'class-transformer';
2
2
  import { IsNumber, IsOptional, IsString, Length, ValidateNested } from 'class-validator';
3
3
  import { GeoLocation } from '../GeoLocation';
4
4
  import { RetailAddressInput } from './RetailAddressInput';
5
+ import { IsMxPhone } from '../../../common/validators/IsMxPhone';
5
6
 
6
7
  /**
7
8
  * Body de PUT /stores/:storeId — edición de tienda (campos editables opcionales). El status se
@@ -39,7 +40,7 @@ export class UpdateStoreRequest {
39
40
 
40
41
  @Expose()
41
42
  @IsOptional()
42
- @IsString()
43
+ @IsMxPhone()
43
44
  phone?: string;
44
45
 
45
46
  @Expose()