itlab-internal-services 1.7.0 → 1.8.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.
@@ -1,5 +1,5 @@
1
- import { HttpException } from '@nestjs/common';
2
- export declare class BadBodyException extends HttpException {
3
- constructor(response?: string);
1
+ import { ErrorException } from '.';
2
+ export declare class BadBodyException extends ErrorException {
3
+ constructor(description?: string);
4
4
  }
5
- export declare const ApiBadBody: (response?: string) => MethodDecorator & ClassDecorator;
5
+ export declare const ApiBadBody: (description?: string) => MethodDecorator & ClassDecorator;
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiBadBody = exports.BadBodyException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
+ const _1 = require(".");
6
7
  const status = common_1.HttpStatus.METHOD_NOT_ALLOWED;
7
- const description = 'Bad Body';
8
- class BadBodyException extends common_1.HttpException {
9
- constructor(response = description) {
10
- super(response, status);
8
+ const error = 'Bad Body';
9
+ class BadBodyException extends _1.ErrorException {
10
+ constructor(description) {
11
+ super(error, status, description);
11
12
  }
12
13
  }
13
14
  exports.BadBodyException = BadBodyException;
14
- const ApiBadBody = (response = description) => (0, swagger_1.ApiResponse)({ status, description: response });
15
+ const ApiBadBody = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
15
16
  exports.ApiBadBody = ApiBadBody;
@@ -1,5 +1,5 @@
1
- import { HttpException } from '@nestjs/common';
2
- export declare class DuplicateException extends HttpException {
3
- constructor(response?: string);
1
+ import { ErrorException } from '.';
2
+ export declare class DuplicateException extends ErrorException {
3
+ constructor(description?: string);
4
4
  }
5
- export declare const ApiDuplicate: (response?: string) => MethodDecorator & ClassDecorator;
5
+ export declare const ApiDuplicate: (description?: string) => MethodDecorator & ClassDecorator;
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApiDuplicate = exports.DuplicateException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
+ const _1 = require(".");
6
7
  const status = common_1.HttpStatus.CONFLICT;
7
- const description = 'Duplicate';
8
- class DuplicateException extends common_1.HttpException {
9
- constructor(response = description) {
10
- super(response, status);
8
+ const error = 'Duplicate';
9
+ class DuplicateException extends _1.ErrorException {
10
+ constructor(description) {
11
+ super(error, status, description);
11
12
  }
12
13
  }
13
14
  exports.DuplicateException = DuplicateException;
14
- const ApiDuplicate = (response = description) => (0, swagger_1.ApiResponse)({ status, description: response });
15
+ const ApiDuplicate = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
15
16
  exports.ApiDuplicate = ApiDuplicate;
@@ -1,3 +1,7 @@
1
+ import { HttpException } from '@nestjs/common';
2
+ export declare class ErrorException extends HttpException {
3
+ constructor(error: string, status: number, description?: string);
4
+ }
1
5
  export * from './bad-body.exception';
2
6
  export * from './duplicate.exception';
3
7
  export * from './not-found.exception';
@@ -14,6 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ErrorException = void 0;
18
+ const common_1 = require("@nestjs/common");
19
+ class ErrorException extends common_1.HttpException {
20
+ constructor(error, status, description) {
21
+ super({ message: [description || error], status, error }, status);
22
+ }
23
+ }
24
+ exports.ErrorException = ErrorException;
17
25
  __exportStar(require("./bad-body.exception"), exports);
18
26
  __exportStar(require("./duplicate.exception"), exports);
19
27
  __exportStar(require("./not-found.exception"), exports);
@@ -1,5 +1,5 @@
1
- import { HttpException } from '@nestjs/common';
2
- export declare class NotFoundException extends HttpException {
3
- constructor(response?: string);
1
+ import { ErrorException } from '.';
2
+ export declare class NotFonudException extends ErrorException {
3
+ constructor(description?: string);
4
4
  }
5
- export declare const ApiNotFound: (response?: string) => MethodDecorator & ClassDecorator;
5
+ export declare const ApiNotFonud: (description?: string) => MethodDecorator & ClassDecorator;
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiNotFound = exports.NotFoundException = void 0;
3
+ exports.ApiNotFonud = exports.NotFonudException = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const swagger_1 = require("@nestjs/swagger");
6
+ const _1 = require(".");
6
7
  const status = common_1.HttpStatus.NOT_FOUND;
7
- const description = 'Not Found';
8
- class NotFoundException extends common_1.HttpException {
9
- constructor(response = description) {
10
- super(response, status);
8
+ const error = 'Not Found';
9
+ class NotFonudException extends _1.ErrorException {
10
+ constructor(description) {
11
+ super(error, status, description);
11
12
  }
12
13
  }
13
- exports.NotFoundException = NotFoundException;
14
- const ApiNotFound = (response = description) => (0, swagger_1.ApiResponse)({ status, description: response });
15
- exports.ApiNotFound = ApiNotFound;
14
+ exports.NotFonudException = NotFonudException;
15
+ const ApiNotFonud = (description = error) => (0, swagger_1.ApiResponse)({ status, description });
16
+ exports.ApiNotFonud = ApiNotFonud;
@@ -2,8 +2,9 @@ import { CallHandler, ExecutionContext, NestInterceptor } from '@nestjs/common';
2
2
  import { Observable } from 'rxjs';
3
3
  export declare class ErrorsInterceptor implements NestInterceptor {
4
4
  private readonly dictionary;
5
- constructor(dictionary: Record<string, string>);
5
+ constructor(dictionary?: Record<string, string>);
6
6
  protected REGEX: RegExp;
7
7
  intercept(_context: ExecutionContext, next: CallHandler): Observable<any>;
8
8
  protected transform(message: string, parent: string[]): string;
9
9
  }
10
+ export declare const UseErrorsInterceptor: (dictionary?: Record<string, string>) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -9,11 +9,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ErrorsInterceptor = void 0;
12
+ exports.UseErrorsInterceptor = exports.ErrorsInterceptor = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const rxjs_1 = require("rxjs");
15
15
  let ErrorsInterceptor = class ErrorsInterceptor {
16
- constructor(dictionary) {
16
+ constructor(dictionary = {}) {
17
17
  this.dictionary = dictionary;
18
18
  this.REGEX = /^\D+\.\d+\..+$/;
19
19
  }
@@ -56,3 +56,5 @@ ErrorsInterceptor = __decorate([
56
56
  __metadata("design:paramtypes", [Object])
57
57
  ], ErrorsInterceptor);
58
58
  exports.ErrorsInterceptor = ErrorsInterceptor;
59
+ const UseErrorsInterceptor = (dictionary) => (0, common_1.applyDecorators)((0, common_1.UseInterceptors)(new ErrorsInterceptor(dictionary)));
60
+ exports.UseErrorsInterceptor = UseErrorsInterceptor;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "timo.scheuermann@sv-informatik.de",
6
6
  "url": "https://timos.design"
7
7
  },
8
- "version": "1.7.0",
8
+ "version": "1.8.0",
9
9
  "type": "commonjs",
10
10
  "files": [
11
11
  "dist"