@fiado/type-kit 1.0.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 (36) hide show
  1. package/README.md +35 -0
  2. package/bin/address/dtos/AddressShippingDto.js +57 -0
  3. package/bin/address/index.js +17 -0
  4. package/bin/card/dtos/CardActivateDto.js +26 -0
  5. package/bin/card/dtos/CardRequestDto.js +34 -0
  6. package/bin/card/dtos/CreateCardDto.js +176 -0
  7. package/bin/card/enums/Brand.js +13 -0
  8. package/bin/card/enums/CardType.js +9 -0
  9. package/bin/card/enums/CardUpdateKey.js +8 -0
  10. package/bin/card/enums/IssuanceType.js +8 -0
  11. package/bin/card/enums/OwnershipType.js +8 -0
  12. package/bin/card/enums/Status.js +9 -0
  13. package/bin/card/index.js +25 -0
  14. package/bin/country/enums/CountryId.js +8 -0
  15. package/bin/country/index.js +17 -0
  16. package/bin/helpers/ValidationUtils.js +34 -0
  17. package/bin/helpers/constans/regex.js +7 -0
  18. package/bin/provider/enums/Provider.js +8 -0
  19. package/package.json +24 -0
  20. package/src/address/dtos/AddressShippingDto.ts +36 -0
  21. package/src/address/index.ts +1 -0
  22. package/src/card/dtos/CardActivateDto.ts +12 -0
  23. package/src/card/dtos/CardRequestDto.ts +20 -0
  24. package/src/card/dtos/CreateCardDto.ts +141 -0
  25. package/src/card/enums/Brand.ts +8 -0
  26. package/src/card/enums/CardType.ts +5 -0
  27. package/src/card/enums/CardUpdateKey.ts +4 -0
  28. package/src/card/enums/IssuanceType.ts +6 -0
  29. package/src/card/enums/OwnershipType.ts +4 -0
  30. package/src/card/enums/Status.ts +6 -0
  31. package/src/card/index.ts +13 -0
  32. package/src/country/enums/CountryId.ts +4 -0
  33. package/src/country/index.ts +1 -0
  34. package/src/helpers/ValidationUtils.ts +32 -0
  35. package/src/helpers/constans/regex.ts +10 -0
  36. package/src/provider/enums/Provider.ts +6 -0
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # fiado-type-kit
2
+
3
+ ## Descripción
4
+ **fiado-type-kit** es una biblioteca TypeScript diseñada para facilitar el desarrollo de funciones AWS Lambda al proporcionar un conjunto estructurado de Data Transfer Objects (DTOs), enumeraciones y constantes. Está organizada por dominios específicos (`card`, `account`, `directory`, `otros`) para mejorar la modularidad y la reutilización del código en proyectos de AWS Lambda.
5
+
6
+ ## Estructura del Proyecto
7
+
8
+ **fiado-type-kit/**
9
+ 📁 `/src` - Contiene el código fuente TypeScript, organizado por dominios.
10
+ - 📁 `card` - Funciones y tipos relacionados con tarjetas.
11
+ - 📁 `dtos` - Data Transfer Objects para `card`.
12
+ - 📄 `cardRequest.dto.ts`
13
+ - 📄 `cardResponse.dto.ts`
14
+ - 📁 `enums` - Enumeraciones específicas de `card`.
15
+ - 📄 `cardType.enum.ts`
16
+ - 📁 `constants` - Constantes de `card`.
17
+ - 📄 `cardConstants.ts`
18
+ - 📄 `index.ts` - Exporta los elementos de `card`.
19
+ - 📁 `account` - Funciones y tipos relacionados con cuentas.
20
+ - [Repita la estructura similar a `card`]
21
+ - 📁 `user` - Funciones y tipos relacionados con usuarios.
22
+ - [Repita la estructura similar a `card`]
23
+ 📁 `/dist` - Contiene los archivos transpilados y listos para producción.
24
+ 📁 `/test` - Incluye pruebas para los distintos componentes de la biblioteca.
25
+ 📄 `package.json`
26
+ 📄 `tsconfig.json`
27
+ 📄 `README.md`
28
+
29
+
30
+ ## Uso
31
+ Para utilizar **fiado-type-kit** en tu proyecto, asegúrate de importar los componentes específicos que necesitas de cada dominio. Por ejemplo:
32
+
33
+ ```typescript
34
+ import { CardRequest } from 'fiado-type-kit/dist/card/dtos/cardRequest.dto';
35
+ import { AccountType } from 'fiado-type-kit/dist/account/enums/accountType.enum';
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ShippingAddressDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const CountryId_1 = require("../../country/enums/CountryId");
15
+ class ShippingAddressDto {
16
+ }
17
+ exports.ShippingAddressDto = ShippingAddressDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsString)(),
20
+ (0, class_validator_1.Length)(2, 60),
21
+ __metadata("design:type", String)
22
+ ], ShippingAddressDto.prototype, "municipality", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ (0, class_validator_1.Length)(2, 60),
26
+ __metadata("design:type", String)
27
+ ], ShippingAddressDto.prototype, "neighborhood", void 0);
28
+ __decorate([
29
+ (0, class_validator_1.IsString)(),
30
+ (0, class_validator_1.Length)(5, 10),
31
+ __metadata("design:type", String)
32
+ ], ShippingAddressDto.prototype, "postalCode", void 0);
33
+ __decorate([
34
+ (0, class_validator_1.IsString)(),
35
+ (0, class_validator_1.Length)(2, 100),
36
+ __metadata("design:type", String)
37
+ ], ShippingAddressDto.prototype, "street", void 0);
38
+ __decorate([
39
+ (0, class_validator_1.IsString)(),
40
+ (0, class_validator_1.Length)(2, 60),
41
+ __metadata("design:type", String)
42
+ ], ShippingAddressDto.prototype, "subRegion", void 0);
43
+ __decorate([
44
+ (0, class_validator_1.IsString)(),
45
+ (0, class_validator_1.Length)(1, 10),
46
+ __metadata("design:type", String)
47
+ ], ShippingAddressDto.prototype, "addressNumber", void 0);
48
+ __decorate([
49
+ (0, class_validator_1.IsOptional)(),
50
+ (0, class_validator_1.IsString)(),
51
+ (0, class_validator_1.Length)(1, 200),
52
+ __metadata("design:type", String)
53
+ ], ShippingAddressDto.prototype, "internalNumber", void 0);
54
+ __decorate([
55
+ (0, class_validator_1.IsString)(),
56
+ __metadata("design:type", String)
57
+ ], ShippingAddressDto.prototype, "countryId", void 0);
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dtos/AddressShippingDto"), exports);
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CardActivateDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const CountryId_1 = require("../../country/enums/CountryId");
15
+ class CardActivateDto {
16
+ }
17
+ exports.CardActivateDto = CardActivateDto;
18
+ __decorate([
19
+ (0, class_validator_1.IsEnum)(CountryId_1.CountryId),
20
+ __metadata("design:type", Number)
21
+ ], CardActivateDto.prototype, "countryId", void 0);
22
+ __decorate([
23
+ (0, class_validator_1.IsString)(),
24
+ (0, class_validator_1.Matches)(/^\d{16}$/),
25
+ __metadata("design:type", String)
26
+ ], CardActivateDto.prototype, "panOrCode", void 0);
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CardRequest = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const CountryId_1 = require("../../country/enums/CountryId");
16
+ const CardType_1 = require("../enums/CardType");
17
+ const AddressShippingDto_1 = require("../../address/dtos/AddressShippingDto");
18
+ class CardRequest {
19
+ }
20
+ exports.CardRequest = CardRequest;
21
+ __decorate([
22
+ (0, class_validator_1.IsEnum)(CountryId_1.CountryId),
23
+ __metadata("design:type", Number)
24
+ ], CardRequest.prototype, "countryId", void 0);
25
+ __decorate([
26
+ (0, class_validator_1.IsEnum)(CardType_1.CardType),
27
+ __metadata("design:type", String)
28
+ ], CardRequest.prototype, "type", void 0);
29
+ __decorate([
30
+ (0, class_validator_1.IsNotEmpty)(),
31
+ (0, class_validator_1.ValidateNested)(),
32
+ (0, class_transformer_1.Type)(() => AddressShippingDto_1.ShippingAddressDto),
33
+ __metadata("design:type", AddressShippingDto_1.ShippingAddressDto)
34
+ ], CardRequest.prototype, "address", void 0);
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CreateCardDto = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ const class_transformer_1 = require("class-transformer");
15
+ const CountryId_1 = require("../../country/enums/CountryId");
16
+ const AddressShippingDto_1 = require("../../address/dtos/AddressShippingDto");
17
+ const CardType_1 = require("../enums/CardType");
18
+ const Brand_1 = require("../enums/Brand");
19
+ const OwnershipType_1 = require("../enums/OwnershipType");
20
+ const Status_1 = require("../enums/Status");
21
+ const regex_1 = require("../../helpers/constans/regex");
22
+ class CreateCardDto {
23
+ }
24
+ exports.CreateCardDto = CreateCardDto;
25
+ __decorate([
26
+ (0, class_validator_1.IsOptional)(),
27
+ (0, class_validator_1.IsString)(),
28
+ (0, class_validator_1.Matches)(regex_1.regexUuidV4, {
29
+ message: 'id must be a valid UUID v4',
30
+ }),
31
+ __metadata("design:type", String)
32
+ ], CreateCardDto.prototype, "id", void 0);
33
+ __decorate([
34
+ (0, class_validator_1.IsOptional)(),
35
+ (0, class_validator_1.IsString)(),
36
+ (0, class_validator_1.Matches)(regex_1.regexUuidV4, {
37
+ message: 'accountId must be a valid UUID v4 or null',
38
+ }),
39
+ __metadata("design:type", String)
40
+ ], CreateCardDto.prototype, "accountId", void 0);
41
+ __decorate([
42
+ (0, class_validator_1.IsOptional)(),
43
+ (0, class_validator_1.IsString)(),
44
+ (0, class_validator_1.Matches)(regex_1.regexIso8601, {
45
+ message: 'activationDate must be a valid ISO 8601 date string',
46
+ }),
47
+ __metadata("design:type", String)
48
+ ], CreateCardDto.prototype, "activationDate", void 0);
49
+ __decorate([
50
+ (0, class_validator_1.IsEnum)(CountryId_1.CountryId),
51
+ __metadata("design:type", String)
52
+ ], CreateCardDto.prototype, "countryId", void 0);
53
+ __decorate([
54
+ (0, class_validator_1.IsEnum)(CardType_1.CardType),
55
+ __metadata("design:type", String)
56
+ ], CreateCardDto.prototype, "type", void 0);
57
+ __decorate([
58
+ (0, class_validator_1.IsString)(),
59
+ (0, class_validator_1.Matches)(regex_1.regexUuidV4, {
60
+ message: 'directoryId must be a valid UUID v4',
61
+ }),
62
+ __metadata("design:type", String)
63
+ ], CreateCardDto.prototype, "directoryId", void 0);
64
+ __decorate([
65
+ (0, class_validator_1.IsString)(),
66
+ (0, class_validator_1.Length)(1, 100),
67
+ __metadata("design:type", String)
68
+ ], CreateCardDto.prototype, "externalCardId", void 0);
69
+ __decorate([
70
+ (0, class_validator_1.IsString)(),
71
+ (0, class_validator_1.Length)(1, 100),
72
+ __metadata("design:type", String)
73
+ ], CreateCardDto.prototype, "externalUserId", void 0);
74
+ __decorate([
75
+ (0, class_validator_1.IsOptional)(),
76
+ (0, class_validator_1.IsString)(),
77
+ (0, class_validator_1.Length)(1, 100),
78
+ __metadata("design:type", String)
79
+ ], CreateCardDto.prototype, "externalShipmentId", void 0);
80
+ __decorate([
81
+ (0, class_validator_1.IsOptional)(),
82
+ (0, class_validator_1.IsString)(),
83
+ (0, class_validator_1.Length)(1, 50),
84
+ __metadata("design:type", String)
85
+ ], CreateCardDto.prototype, "shipmentProvider", void 0);
86
+ __decorate([
87
+ (0, class_validator_1.IsOptional)(),
88
+ (0, class_validator_1.IsString)(),
89
+ (0, class_validator_1.Length)(1, 50),
90
+ __metadata("design:type", String)
91
+ ], CreateCardDto.prototype, "externalShipmentTrackingId", void 0);
92
+ __decorate([
93
+ (0, class_validator_1.IsOptional)(),
94
+ (0, class_validator_1.IsString)(),
95
+ (0, class_validator_1.Length)(1, 200),
96
+ __metadata("design:type", String)
97
+ ], CreateCardDto.prototype, "externalShipmentTrackingUrl", void 0);
98
+ __decorate([
99
+ (0, class_validator_1.IsOptional)(),
100
+ (0, class_validator_1.IsString)(),
101
+ (0, class_validator_1.Length)(1, 50),
102
+ __metadata("design:type", String)
103
+ ], CreateCardDto.prototype, "holderName", void 0);
104
+ __decorate([
105
+ (0, class_validator_1.IsOptional)(),
106
+ (0, class_validator_1.IsString)(),
107
+ (0, class_validator_1.Length)(1, 50),
108
+ __metadata("design:type", String)
109
+ ], CreateCardDto.prototype, "holderLastName", void 0);
110
+ __decorate([
111
+ (0, class_validator_1.IsOptional)(),
112
+ (0, class_validator_1.IsString)(),
113
+ (0, class_validator_1.Length)(1, 200),
114
+ __metadata("design:type", String)
115
+ ], CreateCardDto.prototype, "imageUrl", void 0);
116
+ __decorate([
117
+ (0, class_validator_1.IsEnum)(Brand_1.Brand),
118
+ __metadata("design:type", String)
119
+ ], CreateCardDto.prototype, "brand", void 0);
120
+ __decorate([
121
+ (0, class_validator_1.IsEnum)(OwnershipType_1.OwnershipType),
122
+ __metadata("design:type", String)
123
+ ], CreateCardDto.prototype, "ownershipType", void 0);
124
+ __decorate([
125
+ (0, class_validator_1.IsString)(),
126
+ (0, class_validator_1.Length)(4, 4),
127
+ __metadata("design:type", String)
128
+ ], CreateCardDto.prototype, "lastFour", void 0);
129
+ __decorate([
130
+ (0, class_validator_1.IsOptional)(),
131
+ (0, class_validator_1.IsString)(),
132
+ (0, class_validator_1.Length)(1, 50),
133
+ __metadata("design:type", String)
134
+ ], CreateCardDto.prototype, "providerName", void 0);
135
+ __decorate([
136
+ (0, class_validator_1.IsEnum)(Status_1.Status),
137
+ __metadata("design:type", String)
138
+ ], CreateCardDto.prototype, "status", void 0);
139
+ __decorate([
140
+ (0, class_validator_1.IsOptional)(),
141
+ (0, class_validator_1.IsString)(),
142
+ __metadata("design:type", String)
143
+ ], CreateCardDto.prototype, "statusUpdateDate", void 0);
144
+ __decorate([
145
+ (0, class_validator_1.IsOptional)(),
146
+ (0, class_validator_1.IsString)(),
147
+ (0, class_validator_1.Length)(1, 50),
148
+ __metadata("design:type", String)
149
+ ], CreateCardDto.prototype, "tenantId", void 0);
150
+ __decorate([
151
+ (0, class_validator_1.IsOptional)(),
152
+ (0, class_validator_1.IsNumber)(),
153
+ (0, class_validator_1.Min)(1),
154
+ (0, class_validator_1.Max)(9999999999),
155
+ __metadata("design:type", Number)
156
+ ], CreateCardDto.prototype, "spendLimitByTransaction", void 0);
157
+ __decorate([
158
+ (0, class_validator_1.IsOptional)(),
159
+ (0, class_validator_1.IsNumber)(),
160
+ (0, class_validator_1.Min)(1),
161
+ (0, class_validator_1.Max)(9999999999),
162
+ __metadata("design:type", Number)
163
+ ], CreateCardDto.prototype, "spendLimitByDay", void 0);
164
+ __decorate([
165
+ (0, class_validator_1.IsOptional)(),
166
+ (0, class_validator_1.IsNumber)(),
167
+ (0, class_validator_1.Min)(1),
168
+ (0, class_validator_1.Max)(9999999999),
169
+ __metadata("design:type", Number)
170
+ ], CreateCardDto.prototype, "spendLimitByMonth", void 0);
171
+ __decorate([
172
+ (0, class_validator_1.IsOptional)(),
173
+ (0, class_validator_1.ValidateNested)(),
174
+ (0, class_transformer_1.Type)(() => AddressShippingDto_1.ShippingAddressDto),
175
+ __metadata("design:type", AddressShippingDto_1.ShippingAddressDto)
176
+ ], CreateCardDto.prototype, "shippedAddress", void 0);
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Brand = void 0;
4
+ var Brand;
5
+ (function (Brand) {
6
+ Brand["VISA"] = "VISA";
7
+ Brand["MASTERCARD"] = "MASTERCARD";
8
+ Brand["AMERICAN_EXPRESS"] = "AMERICAN_EXPRESS";
9
+ Brand["DISCOVER"] = "DISCOVER";
10
+ Brand["DINERS_CLUB"] = "DINERS_CLUB";
11
+ Brand["JCB"] = "JCB";
12
+ })(Brand || (exports.Brand = Brand = {}));
13
+ ;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CardType = void 0;
4
+ var CardType;
5
+ (function (CardType) {
6
+ CardType["CREDIT"] = "CREDIT";
7
+ CardType["DEBIT"] = "DEBIT";
8
+ CardType["PREPAID"] = "PREPAID";
9
+ })(CardType || (exports.CardType = CardType = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CardUpdateKey = void 0;
4
+ var CardUpdateKey;
5
+ (function (CardUpdateKey) {
6
+ CardUpdateKey["CHANGE_STATUS"] = "CHANGE_STATUS";
7
+ CardUpdateKey["CHANGE_PIN"] = "CHANGE_PIN";
8
+ })(CardUpdateKey || (exports.CardUpdateKey = CardUpdateKey = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IssuanceType = void 0;
4
+ var IssuanceType;
5
+ (function (IssuanceType) {
6
+ IssuanceType["VIRTUAL"] = "VIRTUAL";
7
+ IssuanceType["PHYSICAL"] = "PHYSICAL";
8
+ })(IssuanceType || (exports.IssuanceType = IssuanceType = {}));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OwnershipType = void 0;
4
+ var OwnershipType;
5
+ (function (OwnershipType) {
6
+ OwnershipType["NOMINATE"] = "NOMINATE";
7
+ OwnershipType["INNOMINATE"] = "INNOMINATE";
8
+ })(OwnershipType || (exports.OwnershipType = OwnershipType = {}));
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Status = void 0;
4
+ var Status;
5
+ (function (Status) {
6
+ Status["ACTIVE"] = "ACTIVE";
7
+ Status["PENDING"] = "PENDING";
8
+ Status["PAUSED"] = "PAUSED";
9
+ })(Status || (exports.Status = Status = {}));
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dtos/CardActivateDto"), exports);
18
+ __exportStar(require("./dtos/CardRequestDto"), exports);
19
+ __exportStar(require("./dtos/CreateCardDto"), exports);
20
+ __exportStar(require("./enums/CardType"), exports);
21
+ __exportStar(require("./enums/CardUpdateKey"), exports);
22
+ __exportStar(require("./enums/IssuanceType"), exports);
23
+ __exportStar(require("./enums/Status"), exports);
24
+ __exportStar(require("./enums/IssuanceType"), exports);
25
+ __exportStar(require("./enums/OwnershipType"), exports);
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CountryId = void 0;
4
+ var CountryId;
5
+ (function (CountryId) {
6
+ CountryId["MEX"] = "484";
7
+ CountryId["USA"] = "840";
8
+ })(CountryId || (exports.CountryId = CountryId = {}));
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums/CountryId"), exports);
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationUtils = void 0;
4
+ const regex_1 = require("./constans/regex");
5
+ class ValidationUtils {
6
+ // Método estático para validar UUID v4
7
+ static validateUuidV4(value) {
8
+ if (value === null)
9
+ return true;
10
+ return regex_1.regexUuidV4.test(value);
11
+ }
12
+ // Método estático para validar la longitud de una cadena
13
+ static validateStringLength(minLength, maxLength) {
14
+ return (value) => {
15
+ if (value === null)
16
+ return true;
17
+ return value.length >= minLength && value.length <= maxLength;
18
+ };
19
+ }
20
+ // Método estático para validar el formato de fecha ISO 8601
21
+ static validateIso8601(value) {
22
+ if (value === null)
23
+ return true;
24
+ return regex_1.regexIso8601.test(value);
25
+ }
26
+ static validateNumberRange(minValue, maxValue) {
27
+ return (value) => {
28
+ if (value === null)
29
+ return true;
30
+ return value >= minValue && value <= maxValue;
31
+ };
32
+ }
33
+ }
34
+ exports.ValidationUtils = ValidationUtils;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.regexIso8601 = exports.regexUuidV4 = void 0;
4
+ // Expresión regular para validar UUID v4
5
+ exports.regexUuidV4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
6
+ // Expresión regular para validar fecha ISO 8601
7
+ exports.regexIso8601 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Provider = void 0;
4
+ var Provider;
5
+ (function (Provider) {
6
+ Provider["TERN"] = "TERN";
7
+ Provider["POMELO"] = "POMELO";
8
+ })(Provider || (exports.Provider = Provider = {}));
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@fiado/type-kit",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "bin/index.js",
6
+ "types": "bin/index.d.ts",
7
+ "scripts": {
8
+ "test": "jest",
9
+ "build": "tsc"
10
+ },
11
+ "keywords": [],
12
+ "author": "Fiado Inc",
13
+ "license": "ISC",
14
+ "devDependencies": {
15
+ "@types/node": "^20.11.20",
16
+ "install": "^0.13.0",
17
+ "npm": "^10.4.0",
18
+ "typescript": "^5.3.3"
19
+ },
20
+ "dependencies": {
21
+ "class-transformer": "^0.5.1",
22
+ "class-validator": "^0.14.1"
23
+ }
24
+ }
@@ -0,0 +1,36 @@
1
+ import { IsString, Length, IsOptional } from 'class-validator';
2
+ import { CountryId } from '../../country/enums/CountryId';
3
+
4
+ export class ShippingAddressDto {
5
+ @IsString()
6
+ @Length(2, 60)
7
+ municipality: string;
8
+
9
+ @IsString()
10
+ @Length(2, 60)
11
+ neighborhood: string;
12
+
13
+ @IsString()
14
+ @Length(5, 10)
15
+ postalCode: string;
16
+
17
+ @IsString()
18
+ @Length(2, 100)
19
+ street: string;
20
+
21
+ @IsString()
22
+ @Length(2, 60)
23
+ subRegion: string;
24
+
25
+ @IsString()
26
+ @Length(1, 10)
27
+ addressNumber: string;
28
+
29
+ @IsOptional()
30
+ @IsString()
31
+ @Length(1, 200)
32
+ internalNumber?: string;
33
+
34
+ @IsString()
35
+ countryId: CountryId;
36
+ }
@@ -0,0 +1 @@
1
+ export * from './dtos/AddressShippingDto';
@@ -0,0 +1,12 @@
1
+ import { IsEnum, IsString, Matches } from 'class-validator';
2
+ import { CountryId } from '../../country/enums/CountryId';
3
+
4
+
5
+ export class CardActivateDto {
6
+ @IsEnum(CountryId)
7
+ countryId: number;
8
+
9
+ @IsString()
10
+ @Matches(/^\d{16}$/)
11
+ panOrCode: string;
12
+ }
@@ -0,0 +1,20 @@
1
+
2
+
3
+ import { IsEnum, IsNotEmpty, ValidateNested } from 'class-validator';
4
+ import { Type } from 'class-transformer';
5
+ import { CountryId } from '../../country/enums/CountryId';
6
+ import { CardType } from '../enums/CardType';
7
+ import { ShippingAddressDto } from '../../address/dtos/AddressShippingDto';
8
+
9
+ export class CardRequest {
10
+ @IsEnum(CountryId)
11
+ countryId: number;
12
+
13
+ @IsEnum(CardType)
14
+ type: string;
15
+
16
+ @IsNotEmpty()
17
+ @ValidateNested()
18
+ @Type(() => ShippingAddressDto)
19
+ address: ShippingAddressDto;
20
+ }
@@ -0,0 +1,141 @@
1
+ import { IsString, IsOptional, IsEnum, ValidateNested, IsNumber, Min, Max, Length, Matches } from 'class-validator';
2
+ import { Type } from 'class-transformer';
3
+ import { CountryId } from '../../country/enums/CountryId';
4
+ import { ShippingAddressDto } from '../../address/dtos/AddressShippingDto';
5
+ import { CardType } from '../enums/CardType';
6
+ import { Brand } from '../enums/Brand';
7
+ import { OwnershipType } from '../enums/OwnershipType';
8
+ import { Status } from '../enums/Status';
9
+ import { regexIso8601, regexUuidV4 } from '../../helpers/constans/regex';
10
+
11
+ export class CreateCardDto {
12
+
13
+ @IsOptional()
14
+ @IsString()
15
+ @Matches(regexUuidV4,
16
+ {
17
+ message: 'id must be a valid UUID v4',
18
+ })
19
+ id?: string;
20
+
21
+ @IsOptional()
22
+ @IsString()
23
+ @Matches(regexUuidV4,
24
+ {
25
+ message: 'accountId must be a valid UUID v4 or null',
26
+ })
27
+ accountId?: string;
28
+
29
+ @IsOptional()
30
+ @IsString()
31
+ @Matches(regexIso8601, {
32
+ message: 'activationDate must be a valid ISO 8601 date string',
33
+ })
34
+ activationDate?: string;
35
+
36
+ @IsEnum(CountryId)
37
+ countryId: CountryId;
38
+
39
+ @IsEnum(CardType)
40
+ type: CardType;
41
+
42
+ @IsString()
43
+ @Matches(regexUuidV4,
44
+ {
45
+ message: 'directoryId must be a valid UUID v4',
46
+ })
47
+ directoryId?: string;
48
+
49
+ @IsString()
50
+ @Length(1, 100)
51
+ externalCardId: string;
52
+
53
+ @IsString()
54
+ @Length(1, 100)
55
+ externalUserId: string;
56
+
57
+ @IsOptional()
58
+ @IsString()
59
+ @Length(1, 100)
60
+ externalShipmentId: string;
61
+
62
+ @IsOptional()
63
+ @IsString()
64
+ @Length(1, 50)
65
+ shipmentProvider: string;
66
+
67
+ @IsOptional()
68
+ @IsString()
69
+ @Length(1, 50)
70
+ externalShipmentTrackingId: string;
71
+
72
+ @IsOptional()
73
+ @IsString()
74
+ @Length(1, 200)
75
+ externalShipmentTrackingUrl: string;
76
+
77
+ @IsOptional()
78
+ @IsString()
79
+ @Length(1, 50)
80
+ holderName: string;
81
+
82
+ @IsOptional()
83
+ @IsString()
84
+ @Length(1, 50)
85
+ holderLastName: string;
86
+
87
+ @IsOptional()
88
+ @IsString()
89
+ @Length(1, 200)
90
+ imageUrl?: string;
91
+
92
+ @IsEnum(Brand)
93
+ brand: Brand;
94
+
95
+ @IsEnum(OwnershipType)
96
+ ownershipType: OwnershipType;
97
+
98
+ @IsString()
99
+ @Length(4, 4)
100
+ lastFour: string;
101
+
102
+ @IsOptional()
103
+ @IsString()
104
+ @Length(1, 50)
105
+ providerName?: string;
106
+
107
+ @IsEnum(Status)
108
+ status: Status;
109
+
110
+ @IsOptional()
111
+ @IsString()
112
+ statusUpdateDate?: string;
113
+
114
+ @IsOptional()
115
+ @IsString()
116
+ @Length(1, 50)
117
+ tenantId?: string;
118
+
119
+ @IsOptional()
120
+ @IsNumber()
121
+ @Min(1)
122
+ @Max(9999999999)
123
+ spendLimitByTransaction?: number;
124
+
125
+ @IsOptional()
126
+ @IsNumber()
127
+ @Min(1)
128
+ @Max(9999999999)
129
+ spendLimitByDay?: number;
130
+
131
+ @IsOptional()
132
+ @IsNumber()
133
+ @Min(1)
134
+ @Max(9999999999)
135
+ spendLimitByMonth?: number;
136
+
137
+ @IsOptional()
138
+ @ValidateNested()
139
+ @Type(() => ShippingAddressDto)
140
+ shippedAddress?: ShippingAddressDto;
141
+ }
@@ -0,0 +1,8 @@
1
+ export enum Brand {
2
+ VISA = "VISA",
3
+ MASTERCARD = 'MASTERCARD',
4
+ AMERICAN_EXPRESS = 'AMERICAN_EXPRESS',
5
+ DISCOVER = 'DISCOVER',
6
+ DINERS_CLUB = 'DINERS_CLUB',
7
+ JCB = 'JCB'
8
+ };
@@ -0,0 +1,5 @@
1
+ export enum CardType {
2
+ CREDIT = 'CREDIT',
3
+ DEBIT = 'DEBIT',
4
+ PREPAID = 'PREPAID'
5
+ }
@@ -0,0 +1,4 @@
1
+ export enum CardUpdateKey {
2
+ CHANGE_STATUS = 'CHANGE_STATUS',
3
+ CHANGE_PIN = 'CHANGE_PIN',
4
+ }
@@ -0,0 +1,6 @@
1
+
2
+
3
+ export enum IssuanceType {
4
+ VIRTUAL = 'VIRTUAL',
5
+ PHYSICAL = 'PHYSICAL'
6
+ }
@@ -0,0 +1,4 @@
1
+ export enum OwnershipType {
2
+ NOMINATE = 'NOMINATE',
3
+ INNOMINATE = 'INNOMINATE',
4
+ }
@@ -0,0 +1,6 @@
1
+
2
+ export enum Status {
3
+ ACTIVE = 'ACTIVE',
4
+ PENDING = 'PENDING',
5
+ PAUSED = 'PAUSED',
6
+ }
@@ -0,0 +1,13 @@
1
+ export * from './dtos/CardActivateDto';
2
+ export * from './dtos/CardRequestDto';
3
+ export * from './dtos/CreateCardDto';
4
+
5
+ export * from './enums/CardType';
6
+ export * from './enums/CardUpdateKey';
7
+ export * from './enums/IssuanceType';
8
+ export * from './enums/Status';
9
+ export * from './enums/IssuanceType';
10
+ export * from './enums/OwnershipType';
11
+
12
+
13
+
@@ -0,0 +1,4 @@
1
+ export enum CountryId {
2
+ MEX = "484",
3
+ USA = "840"
4
+ }
@@ -0,0 +1 @@
1
+ export * from './enums/CountryId';
@@ -0,0 +1,32 @@
1
+ import { regexIso8601, regexUuidV4 } from "./constans/regex";
2
+
3
+
4
+ export class ValidationUtils {
5
+
6
+ // Método estático para validar UUID v4
7
+ public static validateUuidV4(value: any) {
8
+ if (value === null) return true;
9
+ return regexUuidV4.test(value);
10
+ }
11
+
12
+ // Método estático para validar la longitud de una cadena
13
+ public static validateStringLength(minLength: number, maxLength: number) {
14
+ return (value: string) => {
15
+ if (value === null) return true;
16
+ return value.length >= minLength && value.length <= maxLength;
17
+ };
18
+ }
19
+
20
+ // Método estático para validar el formato de fecha ISO 8601
21
+ public static validateIso8601(value: string) {
22
+ if (value === null) return true;
23
+ return regexIso8601.test(value);
24
+ }
25
+
26
+ public static validateNumberRange(minValue: number, maxValue: number) {
27
+ return (value: number | null): boolean => {
28
+ if (value === null) return true;
29
+ return value >= minValue && value <= maxValue;
30
+ };
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+
2
+
3
+ // Expresión regular para validar UUID v4
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
+ // Expresión regular para validar fecha ISO 8601
6
+ export const regexIso8601 = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
7
+
8
+
9
+
10
+
@@ -0,0 +1,6 @@
1
+
2
+
3
+ export enum Provider {
4
+ TERN = 'TERN',
5
+ POMELO = 'POMELO'
6
+ }