@hemia/common 0.0.15 → 0.0.17

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.
@@ -1,5 +1,7 @@
1
1
  import 'reflect-metadata';
2
2
  import { decorate, injectable } from 'inversify';
3
+ import { validate } from 'class-validator';
4
+ import { plainToInstance } from 'class-transformer';
3
5
 
4
6
  const METADATA_KEYS = {
5
7
  BASE_PATH: 'base_path',
@@ -378,22 +380,90 @@ function Custom(key) {
378
380
  }
379
381
 
380
382
  /**
381
- * Decorador para validar datos de entrada en un controlador.
383
+ * Decorador para validar datos de entrada usando class-validator.
382
384
  *
383
385
  * @example
384
- * // Valida el parámetro 'body' usando la función validateUser
385
- * @Validate(validateUser)
386
- * async create(@Body() body: any) {}
386
+ * // Valida el body usando un DTO
387
+ * async create(@Validate(CreateUserDto) @Body() body: CreateUserDto) {}
388
+ *
389
+ * @example
390
+ * // Valida con función personalizada
391
+ * @Validate((value) => value.age > 18)
392
+ * async create(@Body('age') age: number) {}
387
393
  *
388
- * @param validator Función de validación que recibe el valor y retorna booleano o lanza error.
394
+ * @param validatorOrDto Clase DTO o función de validación.
389
395
  */
390
- function Validate(validator) {
396
+ function Validate(validatorOrDto) {
391
397
  return (target, propertyKey, parameterIndex) => {
392
398
  const existingValidators = Reflect.getMetadata(METADATA_KEYS.VALIDATORS, target, propertyKey || '') || [];
393
- existingValidators.push({ index: parameterIndex, validator });
399
+ // Determinar si es una clase DTO o función
400
+ const isClassValidator = typeof validatorOrDto === 'function' && validatorOrDto.prototype;
401
+ const validator = isClassValidator
402
+ ? async (value) => {
403
+ const instance = plainToInstance(validatorOrDto, value);
404
+ const errors = await validate(instance, { whitelist: true, forbidNonWhitelisted: true });
405
+ if (errors.length > 0) {
406
+ throw new ValidationException(errors);
407
+ }
408
+ return true;
409
+ }
410
+ : validatorOrDto;
411
+ existingValidators.push({ index: parameterIndex, validator, dtoClass: isClassValidator ? validatorOrDto : null });
394
412
  Reflect.defineMetadata(METADATA_KEYS.VALIDATORS, existingValidators, target, propertyKey || '');
395
413
  };
396
414
  }
415
+ /**
416
+ * Decorador de método para validar todo el body con un DTO
417
+ * @example
418
+ * @Post()
419
+ * @ValidateDto(CreateUserDto)
420
+ * async create(@Body() body: CreateUserDto) {}
421
+ */
422
+ function ValidateDto(dtoClass) {
423
+ return (target, propertyKey, descriptor) => {
424
+ const existingValidators = Reflect.getMetadata(METADATA_KEYS.VALIDATORS, target, propertyKey) || [];
425
+ const validator = async (value) => {
426
+ const instance = plainToInstance(dtoClass, value);
427
+ const errors = await validate(instance, {
428
+ whitelist: true,
429
+ forbidNonWhitelisted: true
430
+ });
431
+ if (errors.length > 0) {
432
+ throw new ValidationException(errors);
433
+ }
434
+ return true;
435
+ };
436
+ const paramsMetadata = Reflect.getMetadata(METADATA_KEYS.PARAMS, target, propertyKey) || [];
437
+ const bodyParam = paramsMetadata.find((p) => p.type === ParamType.BODY);
438
+ if (bodyParam) {
439
+ existingValidators.push({
440
+ index: bodyParam.index,
441
+ validator,
442
+ dtoClass
443
+ });
444
+ Reflect.defineMetadata(METADATA_KEYS.VALIDATORS, existingValidators, target, propertyKey);
445
+ }
446
+ return descriptor;
447
+ };
448
+ }
449
+ /**
450
+ * Excepción personalizada para errores de validación
451
+ */
452
+ class ValidationException extends Error {
453
+ constructor(errors) {
454
+ super('Validation failed');
455
+ this.statusCode = 400;
456
+ this.errors = errors;
457
+ this.name = 'ValidationException';
458
+ }
459
+ toJSON() {
460
+ return this.errors.map(error => ({
461
+ property: error.property,
462
+ value: error.value,
463
+ constraints: error.constraints
464
+ }));
465
+ }
466
+ }
397
467
 
398
468
  /**
399
469
  * Decorador para transformar datos de entrada en un controlador.
@@ -466,6 +536,61 @@ class GatewayTimeoutError extends HttpError {
466
536
  super(message, 504, error);
467
537
  }
468
538
  }
539
+ class TooManyRequestsError extends HttpError {
540
+ constructor(message = 'Too Many Requests', error) {
541
+ super(message, 429, error);
542
+ }
543
+ }
544
+ class MethodNotAllowedError extends HttpError {
545
+ constructor(message = 'Method Not Allowed', error) {
546
+ super(message, 405, error);
547
+ }
548
+ }
549
+ class NotAcceptableError extends HttpError {
550
+ constructor(message = 'Not Acceptable', error) {
551
+ super(message, 406, error);
552
+ }
553
+ }
554
+ class ProxyAuthenticationRequiredError extends HttpError {
555
+ constructor(message = 'Proxy Authentication Required', error) {
556
+ super(message, 407, error);
557
+ }
558
+ }
559
+ class RequestTimeoutError extends HttpError {
560
+ constructor(message = 'Request Timeout', error) {
561
+ super(message, 408, error);
562
+ }
563
+ }
564
+ class UnsupportedMediaTypeError extends HttpError {
565
+ constructor(message = 'Unsupported Media Type', error) {
566
+ super(message, 415, error);
567
+ }
568
+ }
569
+ class PreconditionFailedError extends HttpError {
570
+ constructor(message = 'Precondition Failed', error) {
571
+ super(message, 412, error);
572
+ }
573
+ }
574
+ class PayloadTooLargeError extends HttpError {
575
+ constructor(message = 'Payload Too Large', error) {
576
+ super(message, 413, error);
577
+ }
578
+ }
579
+ class URITooLongError extends HttpError {
580
+ constructor(message = 'URI Too Long', error) {
581
+ super(message, 414, error);
582
+ }
583
+ }
584
+ class NotImplementedError extends HttpError {
585
+ constructor(message = 'Not Implemented', error) {
586
+ super(message, 501, error);
587
+ }
588
+ }
589
+ class BadGatewayError extends HttpError {
590
+ constructor(message = 'Bad Gateway', error) {
591
+ super(message, 502, error);
592
+ }
593
+ }
469
594
  class CustomHttpError extends HttpError {
470
595
  constructor(message, statusCode, error) {
471
596
  super(message, statusCode, error);
@@ -1047,4 +1172,4 @@ class ApiResponse {
1047
1172
  }
1048
1173
  }
1049
1174
 
1050
- export { AllowAny, ApiKey, ApiResponse, BackupError, BadRequestError, Body, BusinessRuleViolationError, ConfigurationError, ConflictError, ConnectionError, Controller, ControllerRegistry, Cookies, Custom, CustomHttpError, DataConflictError, DataIntegrityError, DataMigrationError, DataNotFoundError, DataValidationError, DefaultValuePipe, Delete, DependencyError, DomainError, DuplicateEntityError, EntityNotFoundError, FeatureFlag, File, Files, ForbiddenError, GatewayTimeoutError, Get, Head, Header, Headers, Host, HttpError, HttpErrorWithDetails, HttpMethod, IndexingError, InfraAuthenticationError, InfraAuthorizationError, InfraCacheConnectionError, InfraConfigurationError, InfraDataDeserializationError, InfraDataSerializationError, InfraDatabaseConnectionError, InfraExternalServiceError, InfraMessageQueueError, InfraNetworkError, InfraServiceUnavailableError, InfraTimeoutError, InfrastructureError, InternalServerError, Ip, IpWhitelist, Locale, METADATA_KEYS, ManualRegister, Module, Next, NotFoundError, OperationNotAllowedError, Options, Owner, Param, ParamType, ParseArrayPipe, ParseBoolPipe, ParseDatePipe, ParseEnumPipe, ParseFilePipe, ParseFloatPipe, ParseIntPipe, ParseUUIDPipe, Patch, Permissions, PersistenceError, PolicyBased, Post, Public, Put, Query, QueryExecutionError, RateLimit, Redirect, Repository, Req, ReqAuth, ReqContext, ReqPermissions, ReqUser, Request, Res, ResourceLimitError, ResourceLimitExceededError, Response, RestoreError, Roles, SchemaMismatchError, Scopes, Serialize, Service, ServiceUnavailableError, Session, SetMetadata, Throttle, TimeoutError, TransactionError, Transform, UnauthorizedError, UnprocessableEntityError, UseGuards, UseInterceptors, UsePipes, Validate, ValidationError, ValidationPipe, isRedirectResponse };
1175
+ export { AllowAny, ApiKey, ApiResponse, BackupError, BadGatewayError, BadRequestError, Body, BusinessRuleViolationError, ConfigurationError, ConflictError, ConnectionError, Controller, ControllerRegistry, Cookies, Custom, CustomHttpError, DataConflictError, DataIntegrityError, DataMigrationError, DataNotFoundError, DataValidationError, DefaultValuePipe, Delete, DependencyError, DomainError, DuplicateEntityError, EntityNotFoundError, FeatureFlag, File, Files, ForbiddenError, GatewayTimeoutError, Get, Head, Header, Headers, Host, HttpError, HttpErrorWithDetails, HttpMethod, IndexingError, InfraAuthenticationError, InfraAuthorizationError, InfraCacheConnectionError, InfraConfigurationError, InfraDataDeserializationError, InfraDataSerializationError, InfraDatabaseConnectionError, InfraExternalServiceError, InfraMessageQueueError, InfraNetworkError, InfraServiceUnavailableError, InfraTimeoutError, InfrastructureError, InternalServerError, Ip, IpWhitelist, Locale, METADATA_KEYS, ManualRegister, MethodNotAllowedError, Module, Next, NotAcceptableError, NotFoundError, NotImplementedError, OperationNotAllowedError, Options, Owner, Param, ParamType, ParseArrayPipe, ParseBoolPipe, ParseDatePipe, ParseEnumPipe, ParseFilePipe, ParseFloatPipe, ParseIntPipe, ParseUUIDPipe, Patch, PayloadTooLargeError, Permissions, PersistenceError, PolicyBased, Post, PreconditionFailedError, ProxyAuthenticationRequiredError, Public, Put, Query, QueryExecutionError, RateLimit, Redirect, Repository, Req, ReqAuth, ReqContext, ReqPermissions, ReqUser, Request, RequestTimeoutError, Res, ResourceLimitError, ResourceLimitExceededError, Response, RestoreError, Roles, SchemaMismatchError, Scopes, Serialize, Service, ServiceUnavailableError, Session, SetMetadata, Throttle, TimeoutError, TooManyRequestsError, TransactionError, Transform, URITooLongError, UnauthorizedError, UnprocessableEntityError, UnsupportedMediaTypeError, UseGuards, UseInterceptors, UsePipes, Validate, ValidateDto, ValidationError, ValidationException, ValidationPipe, isRedirectResponse };
@@ -2,6 +2,8 @@
2
2
 
3
3
  require('reflect-metadata');
4
4
  var inversify = require('inversify');
5
+ var classValidator = require('class-validator');
6
+ var classTransformer = require('class-transformer');
5
7
 
6
8
  const METADATA_KEYS = {
7
9
  BASE_PATH: 'base_path',
@@ -380,22 +382,90 @@ function Custom(key) {
380
382
  }
381
383
 
382
384
  /**
383
- * Decorador para validar datos de entrada en un controlador.
385
+ * Decorador para validar datos de entrada usando class-validator.
384
386
  *
385
387
  * @example
386
- * // Valida el parámetro 'body' usando la función validateUser
387
- * @Validate(validateUser)
388
- * async create(@Body() body: any) {}
388
+ * // Valida el body usando un DTO
389
+ * async create(@Validate(CreateUserDto) @Body() body: CreateUserDto) {}
390
+ *
391
+ * @example
392
+ * // Valida con función personalizada
393
+ * @Validate((value) => value.age > 18)
394
+ * async create(@Body('age') age: number) {}
389
395
  *
390
- * @param validator Función de validación que recibe el valor y retorna booleano o lanza error.
396
+ * @param validatorOrDto Clase DTO o función de validación.
391
397
  */
392
- function Validate(validator) {
398
+ function Validate(validatorOrDto) {
393
399
  return (target, propertyKey, parameterIndex) => {
394
400
  const existingValidators = Reflect.getMetadata(METADATA_KEYS.VALIDATORS, target, propertyKey || '') || [];
395
- existingValidators.push({ index: parameterIndex, validator });
401
+ // Determinar si es una clase DTO o función
402
+ const isClassValidator = typeof validatorOrDto === 'function' && validatorOrDto.prototype;
403
+ const validator = isClassValidator
404
+ ? async (value) => {
405
+ const instance = classTransformer.plainToInstance(validatorOrDto, value);
406
+ const errors = await classValidator.validate(instance, { whitelist: true, forbidNonWhitelisted: true });
407
+ if (errors.length > 0) {
408
+ throw new ValidationException(errors);
409
+ }
410
+ return true;
411
+ }
412
+ : validatorOrDto;
413
+ existingValidators.push({ index: parameterIndex, validator, dtoClass: isClassValidator ? validatorOrDto : null });
396
414
  Reflect.defineMetadata(METADATA_KEYS.VALIDATORS, existingValidators, target, propertyKey || '');
397
415
  };
398
416
  }
417
+ /**
418
+ * Decorador de método para validar todo el body con un DTO
419
+ * @example
420
+ * @Post()
421
+ * @ValidateDto(CreateUserDto)
422
+ * async create(@Body() body: CreateUserDto) {}
423
+ */
424
+ function ValidateDto(dtoClass) {
425
+ return (target, propertyKey, descriptor) => {
426
+ const existingValidators = Reflect.getMetadata(METADATA_KEYS.VALIDATORS, target, propertyKey) || [];
427
+ const validator = async (value) => {
428
+ const instance = classTransformer.plainToInstance(dtoClass, value);
429
+ const errors = await classValidator.validate(instance, {
430
+ whitelist: true,
431
+ forbidNonWhitelisted: true
432
+ });
433
+ if (errors.length > 0) {
434
+ throw new ValidationException(errors);
435
+ }
436
+ return true;
437
+ };
438
+ const paramsMetadata = Reflect.getMetadata(METADATA_KEYS.PARAMS, target, propertyKey) || [];
439
+ const bodyParam = paramsMetadata.find((p) => p.type === exports.ParamType.BODY);
440
+ if (bodyParam) {
441
+ existingValidators.push({
442
+ index: bodyParam.index,
443
+ validator,
444
+ dtoClass
445
+ });
446
+ Reflect.defineMetadata(METADATA_KEYS.VALIDATORS, existingValidators, target, propertyKey);
447
+ }
448
+ return descriptor;
449
+ };
450
+ }
451
+ /**
452
+ * Excepción personalizada para errores de validación
453
+ */
454
+ class ValidationException extends Error {
455
+ constructor(errors) {
456
+ super('Validation failed');
457
+ this.statusCode = 400;
458
+ this.errors = errors;
459
+ this.name = 'ValidationException';
460
+ }
461
+ toJSON() {
462
+ return this.errors.map(error => ({
463
+ property: error.property,
464
+ value: error.value,
465
+ constraints: error.constraints
466
+ }));
467
+ }
468
+ }
399
469
 
400
470
  /**
401
471
  * Decorador para transformar datos de entrada en un controlador.
@@ -468,6 +538,61 @@ class GatewayTimeoutError extends HttpError {
468
538
  super(message, 504, error);
469
539
  }
470
540
  }
541
+ class TooManyRequestsError extends HttpError {
542
+ constructor(message = 'Too Many Requests', error) {
543
+ super(message, 429, error);
544
+ }
545
+ }
546
+ class MethodNotAllowedError extends HttpError {
547
+ constructor(message = 'Method Not Allowed', error) {
548
+ super(message, 405, error);
549
+ }
550
+ }
551
+ class NotAcceptableError extends HttpError {
552
+ constructor(message = 'Not Acceptable', error) {
553
+ super(message, 406, error);
554
+ }
555
+ }
556
+ class ProxyAuthenticationRequiredError extends HttpError {
557
+ constructor(message = 'Proxy Authentication Required', error) {
558
+ super(message, 407, error);
559
+ }
560
+ }
561
+ class RequestTimeoutError extends HttpError {
562
+ constructor(message = 'Request Timeout', error) {
563
+ super(message, 408, error);
564
+ }
565
+ }
566
+ class UnsupportedMediaTypeError extends HttpError {
567
+ constructor(message = 'Unsupported Media Type', error) {
568
+ super(message, 415, error);
569
+ }
570
+ }
571
+ class PreconditionFailedError extends HttpError {
572
+ constructor(message = 'Precondition Failed', error) {
573
+ super(message, 412, error);
574
+ }
575
+ }
576
+ class PayloadTooLargeError extends HttpError {
577
+ constructor(message = 'Payload Too Large', error) {
578
+ super(message, 413, error);
579
+ }
580
+ }
581
+ class URITooLongError extends HttpError {
582
+ constructor(message = 'URI Too Long', error) {
583
+ super(message, 414, error);
584
+ }
585
+ }
586
+ class NotImplementedError extends HttpError {
587
+ constructor(message = 'Not Implemented', error) {
588
+ super(message, 501, error);
589
+ }
590
+ }
591
+ class BadGatewayError extends HttpError {
592
+ constructor(message = 'Bad Gateway', error) {
593
+ super(message, 502, error);
594
+ }
595
+ }
471
596
  class CustomHttpError extends HttpError {
472
597
  constructor(message, statusCode, error) {
473
598
  super(message, statusCode, error);
@@ -1053,6 +1178,7 @@ exports.AllowAny = AllowAny;
1053
1178
  exports.ApiKey = ApiKey;
1054
1179
  exports.ApiResponse = ApiResponse;
1055
1180
  exports.BackupError = BackupError;
1181
+ exports.BadGatewayError = BadGatewayError;
1056
1182
  exports.BadRequestError = BadRequestError;
1057
1183
  exports.Body = Body;
1058
1184
  exports.BusinessRuleViolationError = BusinessRuleViolationError;
@@ -1107,9 +1233,12 @@ exports.IpWhitelist = IpWhitelist;
1107
1233
  exports.Locale = Locale;
1108
1234
  exports.METADATA_KEYS = METADATA_KEYS;
1109
1235
  exports.ManualRegister = ManualRegister;
1236
+ exports.MethodNotAllowedError = MethodNotAllowedError;
1110
1237
  exports.Module = Module;
1111
1238
  exports.Next = Next;
1239
+ exports.NotAcceptableError = NotAcceptableError;
1112
1240
  exports.NotFoundError = NotFoundError;
1241
+ exports.NotImplementedError = NotImplementedError;
1113
1242
  exports.OperationNotAllowedError = OperationNotAllowedError;
1114
1243
  exports.Options = Options;
1115
1244
  exports.Owner = Owner;
@@ -1123,10 +1252,13 @@ exports.ParseFloatPipe = ParseFloatPipe;
1123
1252
  exports.ParseIntPipe = ParseIntPipe;
1124
1253
  exports.ParseUUIDPipe = ParseUUIDPipe;
1125
1254
  exports.Patch = Patch;
1255
+ exports.PayloadTooLargeError = PayloadTooLargeError;
1126
1256
  exports.Permissions = Permissions;
1127
1257
  exports.PersistenceError = PersistenceError;
1128
1258
  exports.PolicyBased = PolicyBased;
1129
1259
  exports.Post = Post;
1260
+ exports.PreconditionFailedError = PreconditionFailedError;
1261
+ exports.ProxyAuthenticationRequiredError = ProxyAuthenticationRequiredError;
1130
1262
  exports.Public = Public;
1131
1263
  exports.Put = Put;
1132
1264
  exports.Query = Query;
@@ -1140,6 +1272,7 @@ exports.ReqContext = ReqContext;
1140
1272
  exports.ReqPermissions = ReqPermissions;
1141
1273
  exports.ReqUser = ReqUser;
1142
1274
  exports.Request = Request;
1275
+ exports.RequestTimeoutError = RequestTimeoutError;
1143
1276
  exports.Res = Res;
1144
1277
  exports.ResourceLimitError = ResourceLimitError;
1145
1278
  exports.ResourceLimitExceededError = ResourceLimitExceededError;
@@ -1155,14 +1288,19 @@ exports.Session = Session;
1155
1288
  exports.SetMetadata = SetMetadata;
1156
1289
  exports.Throttle = Throttle;
1157
1290
  exports.TimeoutError = TimeoutError;
1291
+ exports.TooManyRequestsError = TooManyRequestsError;
1158
1292
  exports.TransactionError = TransactionError;
1159
1293
  exports.Transform = Transform;
1294
+ exports.URITooLongError = URITooLongError;
1160
1295
  exports.UnauthorizedError = UnauthorizedError;
1161
1296
  exports.UnprocessableEntityError = UnprocessableEntityError;
1297
+ exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
1162
1298
  exports.UseGuards = UseGuards;
1163
1299
  exports.UseInterceptors = UseInterceptors;
1164
1300
  exports.UsePipes = UsePipes;
1165
1301
  exports.Validate = Validate;
1302
+ exports.ValidateDto = ValidateDto;
1166
1303
  exports.ValidationError = ValidationError;
1304
+ exports.ValidationException = ValidationException;
1167
1305
  exports.ValidationPipe = ValidationPipe;
1168
1306
  exports.isRedirectResponse = isRedirectResponse;
@@ -1,12 +1,40 @@
1
1
  import 'reflect-metadata';
2
+ import { ValidationError } from 'class-validator';
2
3
  /**
3
- * Decorador para validar datos de entrada en un controlador.
4
+ * Decorador para validar datos de entrada usando class-validator.
4
5
  *
5
6
  * @example
6
- * // Valida el parámetro 'body' usando la función validateUser
7
- * @Validate(validateUser)
8
- * async create(@Body() body: any) {}
7
+ * // Valida el body usando un DTO
8
+ * async create(@Validate(CreateUserDto) @Body() body: CreateUserDto) {}
9
9
  *
10
- * @param validator Función de validación que recibe el valor y retorna booleano o lanza error.
10
+ * @example
11
+ * // Valida con función personalizada
12
+ * @Validate((value) => value.age > 18)
13
+ * async create(@Body('age') age: number) {}
14
+ *
15
+ * @param validatorOrDto Clase DTO o función de validación.
16
+ */
17
+ export declare function Validate(validatorOrDto: any): ParameterDecorator;
18
+ /**
19
+ * Decorador de método para validar todo el body con un DTO
20
+ * @example
21
+ * @Post()
22
+ * @ValidateDto(CreateUserDto)
23
+ * async create(@Body() body: CreateUserDto) {}
24
+ */
25
+ export declare function ValidateDto(dtoClass: any): MethodDecorator;
26
+ /**
27
+ * Excepción personalizada para errores de validación
11
28
  */
12
- export declare function Validate(validator: (value: any) => boolean | void): ParameterDecorator;
29
+ export declare class ValidationException extends Error {
30
+ errors: ValidationError[];
31
+ statusCode: number;
32
+ constructor(errors: ValidationError[]);
33
+ toJSON(): {
34
+ property: string;
35
+ value: any;
36
+ constraints: {
37
+ [type: string]: string;
38
+ } | undefined;
39
+ }[];
40
+ }
@@ -31,6 +31,39 @@ export declare class ServiceUnavailableError extends HttpError {
31
31
  export declare class GatewayTimeoutError extends HttpError {
32
32
  constructor(message?: string, error?: string);
33
33
  }
34
+ export declare class TooManyRequestsError extends HttpError {
35
+ constructor(message?: string, error?: string);
36
+ }
37
+ export declare class MethodNotAllowedError extends HttpError {
38
+ constructor(message?: string, error?: string);
39
+ }
40
+ export declare class NotAcceptableError extends HttpError {
41
+ constructor(message?: string, error?: string);
42
+ }
43
+ export declare class ProxyAuthenticationRequiredError extends HttpError {
44
+ constructor(message?: string, error?: string);
45
+ }
46
+ export declare class RequestTimeoutError extends HttpError {
47
+ constructor(message?: string, error?: string);
48
+ }
49
+ export declare class UnsupportedMediaTypeError extends HttpError {
50
+ constructor(message?: string, error?: string);
51
+ }
52
+ export declare class PreconditionFailedError extends HttpError {
53
+ constructor(message?: string, error?: string);
54
+ }
55
+ export declare class PayloadTooLargeError extends HttpError {
56
+ constructor(message?: string, error?: string);
57
+ }
58
+ export declare class URITooLongError extends HttpError {
59
+ constructor(message?: string, error?: string);
60
+ }
61
+ export declare class NotImplementedError extends HttpError {
62
+ constructor(message?: string, error?: string);
63
+ }
64
+ export declare class BadGatewayError extends HttpError {
65
+ constructor(message?: string, error?: string);
66
+ }
34
67
  export declare class CustomHttpError extends HttpError {
35
68
  constructor(message: string, statusCode: number, error?: string);
36
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hemia/common",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Paquete común para proyectos de Hemia",
5
5
  "main": "dist/hemia-common.js",
6
6
  "module": "dist/hemia-common.esm.js",
@@ -30,11 +30,17 @@
30
30
  "ts-jest": "^29.2.5",
31
31
  "ts-node": "^8.9.0",
32
32
  "typescript": "^5.5.4",
33
- "inversify": "^7.11.0"
33
+ "inversify": "^7.11.0",
34
+ "class-transformer": "^0.5.1",
35
+ "class-validator": "^0.15.1"
34
36
  },
35
37
  "peerDependencies": {
36
38
  "reflect-metadata": "^0.2.2"
37
39
  },
40
+ "optionalDependencies": {
41
+ "class-transformer": "^0.5.1",
42
+ "class-validator": "^0.15.1"
43
+ },
38
44
  "author": "Hemia Team",
39
45
  "license": "ISC",
40
46
  "files": [