@fiado/type-kit 1.0.3 → 1.0.5

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 (81) 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/address/dtos/AddressBase.d.ts +34 -0
  12. package/bin/address/dtos/AddressBase.js +163 -0
  13. package/bin/address/dtos/AddressResponse.d.ts +7 -0
  14. package/bin/address/dtos/AddressResponse.js +47 -0
  15. package/bin/address/dtos/CreateAddressRequest.d.ts +3 -0
  16. package/bin/address/dtos/CreateAddressRequest.js +7 -0
  17. package/bin/address/dtos/Geometry.d.ts +3 -0
  18. package/bin/address/dtos/Geometry.js +2 -0
  19. package/bin/address/dtos/Place.d.ts +21 -0
  20. package/bin/address/dtos/Place.js +112 -0
  21. package/bin/address/dtos/Shipping.d.ts +11 -0
  22. package/bin/address/dtos/Shipping.js +57 -0
  23. package/bin/address/dtos/Timezone.d.ts +4 -0
  24. package/bin/address/dtos/Timezone.js +2 -0
  25. package/bin/address/enums/AddressProvider.d.ts +9 -0
  26. package/bin/address/enums/AddressProvider.js +13 -0
  27. package/bin/address/enums/AddressStatus.d.ts +9 -0
  28. package/bin/address/enums/AddressStatus.js +13 -0
  29. package/bin/address/index.d.ts +1 -1
  30. package/bin/address/index.js +1 -1
  31. package/bin/card/dtos/CardActivateRequest.d.ts +4 -0
  32. package/bin/card/dtos/CardActivateRequest.js +26 -0
  33. package/bin/card/dtos/CardApplicationRequest.d.ts +6 -0
  34. package/bin/card/dtos/CardApplicationRequest.js +34 -0
  35. package/bin/card/dtos/CardApplicationRequestDto.d.ts +1 -1
  36. package/bin/card/dtos/CardApplicationRequestDto.js +6 -6
  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/dtos/CreateCardRequestDto.d.ts +1 -1
  42. package/bin/card/dtos/CreateCardRequestDto.js +29 -29
  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/directory/enums/TypeOfDirectoryId.d.ts +5 -0
  50. package/bin/directory/enums/TypeOfDirectoryId.js +9 -0
  51. package/bin/helpers/constans/regex.d.ts +1 -0
  52. package/bin/helpers/constans/regex.js +3 -1
  53. package/bin/index.d.ts +9 -3
  54. package/bin/index.js +9 -3
  55. package/package.json +1 -1
  56. package/src/account/dtos/AccountResponse.ts +60 -0
  57. package/src/account/dtos/CreateAccountRequest.ts +45 -0
  58. package/src/account/dtos/CreatePockeRequest.ts +19 -0
  59. package/src/account/dtos/PocketResponse.ts +0 -0
  60. package/src/account/enums/AccountStatus.ts +7 -0
  61. package/src/address/dtos/AddressBase.ts +131 -0
  62. package/src/address/dtos/AddressResponse.ts +41 -0
  63. package/src/address/dtos/CreateAddressRequest.ts +7 -0
  64. package/src/address/dtos/Geometry.ts +5 -0
  65. package/src/address/dtos/Place.ts +84 -0
  66. package/src/address/dtos/{AddressShippingDto.ts → Shipping.ts} +1 -1
  67. package/src/address/dtos/Timezone.ts +6 -0
  68. package/src/address/enums/AddressProvider.ts +10 -0
  69. package/src/address/enums/AddressStatus.ts +10 -0
  70. package/src/address/index.ts +1 -1
  71. package/src/card/dtos/{CardActivateRequestDto.ts → CardActivateRequest.ts} +1 -1
  72. package/src/card/dtos/{CardApplicationRequestDto.ts → CardApplicationRequest.ts} +4 -4
  73. package/src/card/dtos/{CardUpdateRequestDto.ts → CardUpdateRequest.ts} +1 -1
  74. package/src/card/dtos/{CreateCardRequestDto.ts → CreateCardRequest.ts} +4 -4
  75. package/src/card/validations/CardUpdateKeyConstraint.ts +3 -5
  76. package/src/card/validations/IsPhoneNumberConstraint.ts +26 -0
  77. package/src/country/enums/Country.ts +6 -0
  78. package/src/country/enums/CountryId.ts +3 -0
  79. package/src/directory/enums/TypeOfDirectoryId.ts +7 -0
  80. package/src/helpers/constans/regex.ts +2 -0
  81. package/src/index.ts +13 -3
@@ -0,0 +1,7 @@
1
+ import { AddressBase } from "./AddressBase";
2
+
3
+
4
+ export class CreateAddressRequest extends AddressBase {
5
+
6
+
7
+ }
@@ -0,0 +1,5 @@
1
+
2
+
3
+ export type Geometry = {
4
+ point: [number, number];
5
+ }
@@ -0,0 +1,84 @@
1
+ import { IsArray, IsBoolean, IsEnum, IsOptional, IsString, Length, ValidateNested } from 'class-validator';
2
+ import { Geometry } from "./Geometry";
3
+ import { Timezone } from "./Timezone";
4
+ import { Country } from '../../country/enums/Country';
5
+
6
+ export class Place {
7
+ @ValidateNested()
8
+ geometry: Geometry;
9
+
10
+ @IsOptional()
11
+ @IsString()
12
+ addressNumber?: string;
13
+
14
+ @IsOptional()
15
+ @IsArray()
16
+ @IsString({ each: true })
17
+ categories?: string[];
18
+
19
+ @IsOptional()
20
+ @IsEnum(Country)
21
+ country?: string;
22
+
23
+ @IsBoolean()
24
+ interpolated: boolean;
25
+
26
+ @IsOptional()
27
+ @IsString()
28
+ @Length(1, 300)
29
+ label?: string;
30
+
31
+ @IsOptional()
32
+ @IsString()
33
+ @Length(1, 60)
34
+ municipality?: string;
35
+
36
+ @IsOptional()
37
+ @IsString()
38
+ @Length(2, 60)
39
+ neighborhood?: string;
40
+
41
+ @IsOptional()
42
+ @IsString()
43
+ @Length(5, 10)
44
+ postalCode?: string;
45
+
46
+ @IsOptional()
47
+ @IsString()
48
+ @Length(5, 10)
49
+ region?: string;
50
+
51
+ @IsOptional()
52
+ @IsString()
53
+ @Length(1, 100)
54
+ street?: string;
55
+
56
+ @IsOptional()
57
+ @IsString()
58
+ @Length(2, 60)
59
+ subMunicipality?: string;
60
+
61
+ @IsOptional()
62
+ @IsString()
63
+ @Length(2, 60)
64
+ subRegion?: string;
65
+
66
+ @IsOptional()
67
+ @IsArray()
68
+ @IsString({ each: true })
69
+ supplementalCategories?: string[];
70
+
71
+ @IsOptional()
72
+ @ValidateNested()
73
+ timezone?: Timezone;
74
+
75
+ @IsOptional()
76
+ @IsString()
77
+ @Length(1, 10)
78
+ unitNumber?: string;
79
+
80
+ @IsOptional()
81
+ @IsString()
82
+ @Length(1, 10)
83
+ unitType?: string;
84
+ }
@@ -1,7 +1,7 @@
1
1
  import { IsString, Length, IsOptional } from 'class-validator';
2
2
  import { CountryId } from '../../country/enums/CountryId';
3
3
 
4
- export class ShippingAddressDto {
4
+ export class Shipping {
5
5
  @IsString()
6
6
  @Length(2, 60)
7
7
  municipality: string;
@@ -0,0 +1,6 @@
1
+
2
+
3
+ export type Timezone = {
4
+ name: string;
5
+ offset: string;
6
+ }
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * AddressProvider enum
4
+ * @description AddressProvider enum is used to define the address provider
5
+ * @enum {string} AddressProvider
6
+ */
7
+ export enum AddressProvider {
8
+ AWS = "AWS",
9
+ MANUAL = "MANUAL"
10
+ }
@@ -0,0 +1,10 @@
1
+
2
+ /**
3
+ * AddressProvider Status
4
+ * @description AddressProvider Status is used to define the address provider status
5
+ * @enum {string} AddressStatus
6
+ */
7
+ export enum AddressStatus {
8
+ VISIBLE = "VISIBLE",
9
+ NOT_VISIBLE = "NOT_VISIBLE"
10
+ }
@@ -1 +1 @@
1
- export * from './dtos/AddressShippingDto';
1
+ export * from './dtos/Shipping';
@@ -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 CardRequest {
9
+ export class CardApplicationRequest {
10
10
  @IsEnum(CountryId)
11
11
  countryId: number;
12
12
 
@@ -15,6 +15,6 @@ export class CardRequest {
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 CreateCardDto {
11
+ export class CreateCardRequest {
12
12
 
13
13
  @IsOptional()
14
14
  @IsString()
@@ -136,6 +136,6 @@ export class CreateCardDto {
136
136
 
137
137
  @IsOptional()
138
138
  @ValidateNested()
139
- @Type(() => ShippingAddressDto)
140
- shippedAddress?: ShippingAddressDto;
139
+ @Type(() => Shipping)
140
+ shippedAddress?: Shipping;
141
141
  }
@@ -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"
@@ -0,0 +1,7 @@
1
+
2
+
3
+ export enum TypeOfDirectoryId {
4
+ USER = "USER",
5
+ BACKOFFICE = "BACKOFFICE",
6
+ AGENT = "AGENT"
7
+ }
@@ -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,6 +1,10 @@
1
- export * from './card/dtos/CardActivateRequestDto';
2
- export * from './card/dtos/CardApplicationRequestDto';
3
- export * from './card/dtos/CreateCardRequestDto';
1
+ export * from './card/dtos/CardActivateRequest';
2
+ export * from './card/dtos/CardApplicationRequest';
3
+ export * from './card/dtos/CreateCardRequest';
4
+ export * from './card/dtos/CardUpdateRequest';
5
+
6
+
7
+
4
8
 
5
9
  export * from './card/enums/CardType';
6
10
  export * from './card/enums/CardUpdateKey';
@@ -8,6 +12,12 @@ export * from './card/enums/IssuanceType';
8
12
  export * from './card/enums/Status';
9
13
  export * from './card/enums/IssuanceType';
10
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
+
11
21
 
12
22
 
13
23