@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.
- package/bin/account/dtos/AccountResponse.d.ts +21 -0
- package/bin/account/dtos/AccountResponse.js +85 -0
- package/bin/account/dtos/CreateAccountRequest.d.ts +14 -0
- package/bin/account/dtos/CreateAccountRequest.js +65 -0
- package/bin/account/dtos/CreatePockeRequest.d.ts +4 -0
- package/bin/account/dtos/CreatePockeRequest.js +31 -0
- package/bin/account/dtos/PocketResponse.d.ts +0 -0
- package/bin/account/dtos/PocketResponse.js +0 -0
- package/bin/account/enums/AccountStatus.d.ts +5 -0
- package/bin/account/enums/AccountStatus.js +9 -0
- package/bin/account/index.d.ts +4 -0
- package/bin/account/index.js +22 -0
- package/bin/address/dtos/AddressBase.d.ts +34 -0
- package/bin/address/dtos/AddressBase.js +163 -0
- package/bin/address/dtos/AddressResponse.d.ts +7 -0
- package/bin/address/dtos/AddressResponse.js +47 -0
- package/bin/address/dtos/CreateAddressRequest.d.ts +3 -0
- package/bin/address/dtos/CreateAddressRequest.js +7 -0
- package/bin/address/dtos/Geometry.d.ts +3 -0
- package/bin/address/dtos/Geometry.js +2 -0
- package/bin/address/dtos/Place.d.ts +21 -0
- package/bin/address/dtos/Place.js +112 -0
- package/bin/address/dtos/Shipping.d.ts +11 -0
- package/bin/address/dtos/Shipping.js +57 -0
- package/bin/address/dtos/Timezone.d.ts +4 -0
- package/bin/address/dtos/Timezone.js +2 -0
- package/bin/address/enums/AddressProvider.d.ts +9 -0
- package/bin/address/enums/AddressProvider.js +13 -0
- package/bin/address/enums/AddressStatus.d.ts +9 -0
- package/bin/address/enums/AddressStatus.js +13 -0
- package/bin/address/index.d.ts +8 -1
- package/bin/address/index.js +10 -1
- package/bin/card/dtos/CardActivateRequest.d.ts +4 -0
- package/bin/card/dtos/CardActivateRequest.js +26 -0
- package/bin/card/dtos/CardApplicationRequest.d.ts +6 -0
- package/bin/card/dtos/CardApplicationRequest.js +34 -0
- package/bin/card/dtos/CardUpdateRequest.d.ts +5 -0
- package/bin/card/dtos/CardUpdateRequest.js +28 -0
- package/bin/card/dtos/CreateCardRequest.d.ts +34 -0
- package/bin/card/dtos/CreateCardRequest.js +176 -0
- package/bin/card/index.d.ts +11 -0
- package/bin/card/index.js +8 -4
- package/bin/card/validations/CardUpdateKeyConstraint.js +1 -2
- package/bin/card/validations/IsPhoneNumberConstraint.d.ts +6 -0
- package/bin/card/validations/IsPhoneNumberConstraint.js +36 -0
- package/bin/country/enums/Country.d.ts +4 -0
- package/bin/country/enums/Country.js +8 -0
- package/bin/country/enums/CountryId.js +1 -0
- package/bin/country/index.d.ts +1 -0
- package/bin/country/index.js +3 -0
- package/bin/directory/enums/TypeOfDirectoryId.d.ts +5 -0
- package/bin/directory/enums/TypeOfDirectoryId.js +9 -0
- package/bin/directory/index.d.ts +1 -0
- package/bin/directory/index.js +19 -0
- package/bin/helpers/constans/regex.d.ts +1 -0
- package/bin/helpers/constans/regex.js +3 -1
- package/bin/index.d.ts +5 -15
- package/bin/index.js +17 -17
- package/package.json +1 -1
- package/src/account/dtos/AccountResponse.ts +60 -0
- package/src/account/dtos/CreateAccountRequest.ts +45 -0
- package/src/account/dtos/CreatePockeRequest.ts +19 -0
- package/src/account/enums/AccountStatus.ts +7 -0
- package/src/account/index.ts +11 -0
- package/src/address/dtos/AddressBase.ts +131 -0
- package/src/address/dtos/AddressResponse.ts +41 -0
- package/src/address/dtos/CreateAddressRequest.ts +7 -0
- package/src/address/dtos/Geometry.ts +5 -0
- package/src/address/dtos/Place.ts +84 -0
- package/src/address/dtos/{AddressShippingDto.ts → Shipping.ts} +1 -1
- package/src/address/dtos/Timezone.ts +6 -0
- package/src/address/enums/AddressProvider.ts +10 -0
- package/src/address/enums/AddressStatus.ts +10 -0
- package/src/address/index.ts +12 -1
- package/src/card/dtos/{CardActivateRequestDto.ts → CardActivateRequest.ts} +1 -1
- package/src/card/dtos/{CardApplicationRequestDto.ts → CardApplicationRequest.ts} +4 -4
- package/src/card/dtos/{CardUpdateRequestDto.ts → CardUpdateRequest.ts} +1 -1
- package/src/card/dtos/{CreateCardRequestDto.ts → CreateCardRequest.ts} +4 -4
- package/src/card/index.ts +15 -0
- package/src/card/validations/CardUpdateKeyConstraint.ts +3 -5
- package/src/card/validations/IsPhoneNumberConstraint.ts +26 -0
- package/src/country/enums/Country.ts +6 -0
- package/src/country/enums/CountryId.ts +3 -0
- package/src/country/index.ts +6 -1
- package/src/directory/enums/TypeOfDirectoryId.ts +7 -0
- package/src/directory/index.ts +7 -0
- package/src/helpers/constans/regex.ts +2 -0
- package/src/index.ts +5 -18
package/src/address/index.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
@@ -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 {
|
|
7
|
+
import { Shipping } from '../../address/dtos/Shipping';
|
|
8
8
|
|
|
9
|
-
export class
|
|
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(() =>
|
|
19
|
-
address:
|
|
18
|
+
@Type(() => Shipping)
|
|
19
|
+
address: Shipping;
|
|
20
20
|
}
|
|
@@ -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
|
|
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(() =>
|
|
140
|
-
shippedAddress?:
|
|
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 {
|
|
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
|
|
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
|
-
|
|
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
|
+
}
|
package/src/country/index.ts
CHANGED
|
@@ -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
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './
|
|
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
|
|