@fiado/type-kit 1.0.4 → 1.0.6

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 (88) hide show
  1. package/bin/account/dtos/AccountResponse.d.ts +21 -0
  2. package/bin/account/dtos/AccountResponse.js +85 -0
  3. package/bin/account/dtos/CreateAccountRequest.d.ts +14 -0
  4. package/bin/account/dtos/CreateAccountRequest.js +65 -0
  5. package/bin/account/dtos/CreatePockeRequest.d.ts +4 -0
  6. package/bin/account/dtos/CreatePockeRequest.js +31 -0
  7. package/bin/account/dtos/PocketResponse.d.ts +0 -0
  8. package/bin/account/dtos/PocketResponse.js +0 -0
  9. package/bin/account/enums/AccountStatus.d.ts +5 -0
  10. package/bin/account/enums/AccountStatus.js +9 -0
  11. package/bin/account/index.d.ts +4 -0
  12. package/bin/account/index.js +22 -0
  13. package/bin/address/dtos/AddressBase.d.ts +34 -0
  14. package/bin/address/dtos/AddressBase.js +163 -0
  15. package/bin/address/dtos/AddressResponse.d.ts +7 -0
  16. package/bin/address/dtos/AddressResponse.js +47 -0
  17. package/bin/address/dtos/CreateAddressRequest.d.ts +3 -0
  18. package/bin/address/dtos/CreateAddressRequest.js +7 -0
  19. package/bin/address/dtos/Geometry.d.ts +3 -0
  20. package/bin/address/dtos/Geometry.js +2 -0
  21. package/bin/address/dtos/Place.d.ts +21 -0
  22. package/bin/address/dtos/Place.js +112 -0
  23. package/bin/address/dtos/Shipping.d.ts +11 -0
  24. package/bin/address/dtos/Shipping.js +57 -0
  25. package/bin/address/dtos/Timezone.d.ts +4 -0
  26. package/bin/address/dtos/Timezone.js +2 -0
  27. package/bin/address/enums/AddressProvider.d.ts +9 -0
  28. package/bin/address/enums/AddressProvider.js +13 -0
  29. package/bin/address/enums/AddressStatus.d.ts +9 -0
  30. package/bin/address/enums/AddressStatus.js +13 -0
  31. package/bin/address/index.d.ts +8 -1
  32. package/bin/address/index.js +10 -1
  33. package/bin/card/dtos/CardActivateRequest.d.ts +4 -0
  34. package/bin/card/dtos/CardActivateRequest.js +26 -0
  35. package/bin/card/dtos/CardApplicationRequest.d.ts +6 -0
  36. package/bin/card/dtos/CardApplicationRequest.js +34 -0
  37. package/bin/card/dtos/CardUpdateRequest.d.ts +5 -0
  38. package/bin/card/dtos/CardUpdateRequest.js +28 -0
  39. package/bin/card/dtos/CreateCardRequest.d.ts +34 -0
  40. package/bin/card/dtos/CreateCardRequest.js +176 -0
  41. package/bin/card/index.d.ts +11 -0
  42. package/bin/card/index.js +8 -4
  43. package/bin/card/validations/CardUpdateKeyConstraint.js +1 -2
  44. package/bin/card/validations/IsPhoneNumberConstraint.d.ts +6 -0
  45. package/bin/card/validations/IsPhoneNumberConstraint.js +36 -0
  46. package/bin/country/enums/Country.d.ts +4 -0
  47. package/bin/country/enums/Country.js +8 -0
  48. package/bin/country/enums/CountryId.js +1 -0
  49. package/bin/country/index.d.ts +1 -0
  50. package/bin/country/index.js +3 -0
  51. package/bin/directory/enums/TypeOfDirectoryId.d.ts +5 -0
  52. package/bin/directory/enums/TypeOfDirectoryId.js +9 -0
  53. package/bin/directory/index.d.ts +1 -0
  54. package/bin/directory/index.js +19 -0
  55. package/bin/helpers/constans/regex.d.ts +1 -0
  56. package/bin/helpers/constans/regex.js +3 -1
  57. package/bin/index.d.ts +5 -15
  58. package/bin/index.js +17 -17
  59. package/package.json +1 -1
  60. package/src/account/dtos/AccountResponse.ts +60 -0
  61. package/src/account/dtos/CreateAccountRequest.ts +45 -0
  62. package/src/account/dtos/CreatePockeRequest.ts +19 -0
  63. package/src/account/enums/AccountStatus.ts +7 -0
  64. package/src/account/index.ts +11 -0
  65. package/src/address/dtos/AddressBase.ts +131 -0
  66. package/src/address/dtos/AddressResponse.ts +41 -0
  67. package/src/address/dtos/CreateAddressRequest.ts +7 -0
  68. package/src/address/dtos/Geometry.ts +5 -0
  69. package/src/address/dtos/Place.ts +84 -0
  70. package/src/address/dtos/{AddressShippingDto.ts → Shipping.ts} +1 -1
  71. package/src/address/dtos/Timezone.ts +6 -0
  72. package/src/address/enums/AddressProvider.ts +10 -0
  73. package/src/address/enums/AddressStatus.ts +10 -0
  74. package/src/address/index.ts +12 -1
  75. package/src/card/dtos/{CardActivateRequestDto.ts → CardActivateRequest.ts} +1 -1
  76. package/src/card/dtos/{CardApplicationRequestDto.ts → CardApplicationRequest.ts} +4 -4
  77. package/src/card/dtos/{CardUpdateRequestDto.ts → CardUpdateRequest.ts} +1 -1
  78. package/src/card/dtos/{CreateCardRequestDto.ts → CreateCardRequest.ts} +4 -4
  79. package/src/card/index.ts +15 -0
  80. package/src/card/validations/CardUpdateKeyConstraint.ts +3 -5
  81. package/src/card/validations/IsPhoneNumberConstraint.ts +26 -0
  82. package/src/country/enums/Country.ts +6 -0
  83. package/src/country/enums/CountryId.ts +3 -0
  84. package/src/country/index.ts +6 -1
  85. package/src/directory/enums/TypeOfDirectoryId.ts +7 -0
  86. package/src/directory/index.ts +7 -0
  87. package/src/helpers/constans/regex.ts +2 -0
  88. package/src/index.ts +5 -18
@@ -1 +1,12 @@
1
- export * from './dtos/AddressShippingDto';
1
+ //dtos
2
+ export * from './dtos/Shipping';
3
+ export * from './dtos/CreateAddressRequest';
4
+ export * from './dtos/AddressResponse';
5
+ export * from './dtos/Geometry';
6
+ export * from './dtos/Place';
7
+ export * from './dtos/Timezone';
8
+
9
+ //enums
10
+ export * from './enums/AddressStatus';
11
+ export * from './enums/AddressProvider';
12
+
@@ -2,7 +2,7 @@ import { IsEnum, IsString, Matches } from 'class-validator';
2
2
  import { CountryId } from '../../country/enums/CountryId';
3
3
 
4
4
 
5
- export class CardActivateRequestDto {
5
+ export class CardActivateRequest {
6
6
  @IsEnum(CountryId)
7
7
  countryId: number;
8
8
 
@@ -4,9 +4,9 @@ import { IsEnum, IsNotEmpty, ValidateNested } from 'class-validator';
4
4
  import { Type } from 'class-transformer';
5
5
  import { CountryId } from '../../country/enums/CountryId';
6
6
  import { CardType } from '../enums/CardType';
7
- import { ShippingAddressDto } from '../../address/dtos/AddressShippingDto';
7
+ import { Shipping } from '../../address/dtos/Shipping';
8
8
 
9
- export class CardApplicationRequestDto {
9
+ export class CardApplicationRequest {
10
10
  @IsEnum(CountryId)
11
11
  countryId: number;
12
12
 
@@ -15,6 +15,6 @@ export class CardApplicationRequestDto {
15
15
 
16
16
  @IsNotEmpty()
17
17
  @ValidateNested()
18
- @Type(() => ShippingAddressDto)
19
- address: ShippingAddressDto;
18
+ @Type(() => Shipping)
19
+ address: Shipping;
20
20
  }
@@ -5,7 +5,7 @@ import { IsValueValid } from "../validations/CardUpdateKeyConstraint";
5
5
 
6
6
 
7
7
 
8
- export class CardUpdateRequestDto {
8
+ export class CardUpdateRequest {
9
9
 
10
10
  @IsEnum(UpdateKey)
11
11
  type: UpdateKey;
@@ -1,14 +1,14 @@
1
1
  import { IsString, IsOptional, IsEnum, ValidateNested, IsNumber, Min, Max, Length, Matches } from 'class-validator';
2
2
  import { Type } from 'class-transformer';
3
3
  import { CountryId } from '../../country/enums/CountryId';
4
- import { ShippingAddressDto } from '../../address/dtos/AddressShippingDto';
5
4
  import { CardType } from '../enums/CardType';
6
5
  import { Brand } from '../enums/Brand';
7
6
  import { OwnershipType } from '../enums/OwnershipType';
8
7
  import { Status } from '../enums/Status';
9
8
  import { regexIso8601, regexUuidV4 } from '../../helpers/constans/regex';
9
+ import { Shipping } from '../../address';
10
10
 
11
- export class CreateCardRequestDto {
11
+ export class CreateCardRequest {
12
12
 
13
13
  @IsOptional()
14
14
  @IsString()
@@ -136,6 +136,6 @@ export class CreateCardRequestDto {
136
136
 
137
137
  @IsOptional()
138
138
  @ValidateNested()
139
- @Type(() => ShippingAddressDto)
140
- shippedAddress?: ShippingAddressDto;
139
+ @Type(() => Shipping)
140
+ shippedAddress?: Shipping;
141
141
  }
@@ -0,0 +1,15 @@
1
+
2
+ //dtos
3
+ export * from './dtos/CardActivateRequest';
4
+ export * from './dtos/CardApplicationRequest';
5
+ export * from './dtos/CreateCardRequest';
6
+ export * from './dtos/CardUpdateRequest';
7
+
8
+ //enums
9
+ export * from './enums/CardType';
10
+ export * from './enums/CardUpdateKey';
11
+ export * from './enums/IssuanceType';
12
+ export * from './enums/Status';
13
+ export * from './enums/OwnershipType';
14
+ export * from './enums/Brand';
15
+ export * from './enums/UpdateKey';
@@ -1,5 +1,5 @@
1
1
  import { ValidationArguments, ValidationOptions, ValidatorConstraint, registerDecorator } from "class-validator";
2
- import { CardUpdateRequestDto } from "../dtos/CardUpdateRequestDto";
2
+ import { CardUpdateRequest } from "../dtos/CardUpdateRequest";
3
3
  import { Status } from "../enums/Status";
4
4
  import { UpdateKey } from "../enums/UpdateKey";
5
5
 
@@ -9,7 +9,7 @@ export class CardUpdateKeyConstraint {
9
9
 
10
10
  public static validateUpdateKey(value: string | Status, arg: ValidationArguments) {
11
11
 
12
- const cardUpdateRequest = arg.object as CardUpdateRequestDto;
12
+ const cardUpdateRequest = arg.object as CardUpdateRequest;
13
13
 
14
14
  // Validar si el valor es uno de los status válidos
15
15
  if (cardUpdateRequest.type === UpdateKey.CHANGE_STATUS) {
@@ -37,10 +37,8 @@ export class CardUpdateKeyConstraint {
37
37
  }
38
38
 
39
39
  defaultMessage(args: ValidationArguments) {
40
- // Se4 puede usar args para personalizar aún más el mensaje de error basado en el valor o las propiedades.
41
- return "El valor no es adecuado para el tipo de actualización.";
40
+ return "The value is not valid for the update type.";
42
41
  }
43
-
44
42
  }
45
43
 
46
44
  export function IsValueValid(validationOptions?: ValidationOptions) {
@@ -0,0 +1,26 @@
1
+ import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments, registerDecorator, ValidationOptions } from 'class-validator';
2
+ import { regexPhoneNumber } from '../../helpers/constans/regex';
3
+
4
+ @ValidatorConstraint({ async: true })
5
+ export class IsPhoneNumberConstraint implements ValidatorConstraintInterface {
6
+ validate(phoneNumber: string, args: ValidationArguments) {
7
+ return regexPhoneNumber.test(phoneNumber);
8
+ }
9
+
10
+ defaultMessage(args: ValidationArguments) {
11
+ return "The phone number is not valid. The expected format is +############.";
12
+ }
13
+ }
14
+
15
+ // Decorador que usaremos en nuestras clases DTO
16
+ export function IsPhoneNumberFiado(validationOptions?: ValidationOptions) {
17
+ return function (object: Object, propertyName: string) {
18
+ registerDecorator({
19
+ target: object.constructor,
20
+ propertyName: propertyName,
21
+ options: validationOptions,
22
+ constraints: [],
23
+ validator: IsPhoneNumberConstraint,
24
+ });
25
+ };
26
+ }
@@ -0,0 +1,6 @@
1
+
2
+
3
+ export enum Country {
4
+ MEX = "MEX",
5
+ USA = "USA"
6
+ }
@@ -1,3 +1,6 @@
1
+
2
+ //*
3
+
1
4
  export enum CountryId {
2
5
  MEX = "484",
3
6
  USA = "840"
@@ -1 +1,6 @@
1
- export * from './enums/CountryId';
1
+ //dto
2
+
3
+
4
+ //enums
5
+ export * from './enums/CountryId';
6
+ export * from './enums/Country';
@@ -0,0 +1,7 @@
1
+
2
+
3
+ export enum TypeOfDirectoryId {
4
+ USER = "USER",
5
+ BACKOFFICE = "BACKOFFICE",
6
+ AGENT = "AGENT"
7
+ }
@@ -0,0 +1,7 @@
1
+
2
+ //dtos
3
+
4
+
5
+
6
+ //enums
7
+ export * from './enums/TypeOfDirectoryId';
@@ -4,6 +4,8 @@
4
4
  export const regexUuidV4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
5
5
  // Expresión regular para validar fecha ISO 8601
6
6
  export const regexIso8601 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
7
+ // Expresión regular para validar un número de teléfono
8
+ export const regexPhoneNumber = /^\+\d{12}$/;
7
9
 
8
10
 
9
11
 
package/src/index.ts CHANGED
@@ -1,23 +1,10 @@
1
- export * from './card/dtos/CardActivateRequestDto';
2
- export * from './card/dtos/CardApplicationRequestDto';
3
- export * from './card/dtos/CreateCardRequestDto';
4
- export * from './card/dtos/CardUpdateRequestDto';
5
1
 
6
2
 
7
-
8
-
9
- export * from './card/enums/CardType';
10
- export * from './card/enums/CardUpdateKey';
11
- export * from './card/enums/IssuanceType';
12
- export * from './card/enums/Status';
13
- export * from './card/enums/IssuanceType';
14
- export * from './card/enums/OwnershipType';
15
- export * from './card/enums/Brand';
16
- export * from './card/enums/UpdateKey';
17
- export * from './card/enums/Status';
18
- export * from './card/enums/CardType';
19
- export * from './card/enums/OwnershipType';
20
-
3
+ export * as Account from './account';
4
+ export * as Address from './address';
5
+ export * as Card from './card';
6
+ export * as Country from './country';
7
+ export * as Directory from './directory';
21
8
 
22
9
 
23
10