@mondart/nestjs-common-module 2.1.1 → 2.1.3

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.
@@ -4,6 +4,7 @@ export declare class BaseKafkaEventDto<type> {
4
4
  model?: string;
5
5
  event_key?: string;
6
6
  data?: type;
7
+ metadata?: object;
7
8
  partition?: number;
8
9
  status?: number;
9
10
  }
@@ -37,6 +37,10 @@ __decorate([
37
37
  (0, class_validator_1.IsOptional)(),
38
38
  __metadata("design:type", Object)
39
39
  ], BaseKafkaEventDto.prototype, "data", void 0);
40
+ __decorate([
41
+ (0, class_validator_1.IsOptional)(),
42
+ __metadata("design:type", Object)
43
+ ], BaseKafkaEventDto.prototype, "metadata", void 0);
40
44
  __decorate([
41
45
  (0, class_validator_1.IsNumber)(),
42
46
  (0, class_validator_1.IsOptional)(),
@@ -1,5 +1,5 @@
1
1
  import { BaseKafkaEventDto } from '../base';
2
2
  export declare class KafkaRequestDto<type> extends BaseKafkaEventDto<type> {
3
3
  constructor({ data, event_source, topic, model, event_key, partition, status, }: BaseKafkaEventDto<type>);
4
- stringify(): string;
4
+ stringify?(): string;
5
5
  }
@@ -1,6 +1,6 @@
1
- import { KafkaSuccessResponseInterface } from '../../interfaces/kafka-success-response.interface';
1
+ import { KafkaSuccessResponseInterface } from '../../interfaces';
2
2
  import { BaseKafkaEventDto } from '../base';
3
3
  export declare class KafkaSuccessResponse<type> extends BaseKafkaEventDto<type> {
4
- constructor({ data, event_source, topic, model, event_key, partition, status, }: KafkaSuccessResponseInterface<type>);
4
+ constructor({ data, metadata, event_source, topic, model, event_key, partition, status, }: KafkaSuccessResponseInterface<type>);
5
5
  stringify(): string;
6
6
  }
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.KafkaSuccessResponse = void 0;
4
4
  const base_1 = require("../base");
5
5
  class KafkaSuccessResponse extends base_1.BaseKafkaEventDto {
6
- constructor({ data, event_source, topic, model, event_key, partition, status = 200, }) {
6
+ constructor({ data, metadata, event_source, topic, model, event_key, partition, status = 200, }) {
7
7
  super();
8
8
  this.data = data;
9
+ this.metadata = metadata;
9
10
  this.topic = topic;
10
11
  this.event_source = event_source;
11
12
  this.model = model;
@@ -1,7 +1,8 @@
1
1
  import { ArgumentsHost, ExceptionFilter } from '@nestjs/common';
2
2
  import { Response } from 'express';
3
3
  export declare class GlobalExceptionFilter implements ExceptionFilter {
4
- private sentryEnable;
4
+ private readonly logger;
5
+ private readonly sentryEnable;
5
6
  constructor(sentryEnable?: boolean);
6
7
  catch(exception: any, host: ArgumentsHost): import("rxjs").Observable<never> | Response<any, Record<string, any>>;
7
8
  private isObject;
@@ -19,18 +19,20 @@ const exceptions = require("@nestjs/common/exceptions");
19
19
  const Sentry = require("@sentry/nestjs");
20
20
  let GlobalExceptionFilter = class GlobalExceptionFilter {
21
21
  constructor(sentryEnable = false) {
22
+ this.logger = new common_1.Logger('GlobalExceptionFilter', {
23
+ timestamp: true,
24
+ });
22
25
  this.sentryEnable = sentryEnable;
23
26
  }
24
27
  catch(exception, host) {
25
28
  if (this.sentryEnable)
26
29
  Sentry.captureException(exception, exception?.response);
27
30
  const context = host.switchToHttp();
28
- const logger = new common_1.Logger('GlobalExceptionFilter', { timestamp: true });
29
31
  const type = host?.getType();
32
+ this.logger.error(`exceptionName: ${exception?.name}`, JSON.stringify(exception) ??
33
+ exception?.message ??
34
+ 'Unknown exception occurred.');
30
35
  if (type === 'rpc') {
31
- logger.error(`exceptionName: ${exception?.name}`, JSON.stringify(exception) ??
32
- exception?.message ??
33
- 'Unknown exception occurred.');
34
36
  const exceptionsName = Object.values(exceptions).map((exception) => exception.name);
35
37
  if (exceptionsName.includes(exception.name)) {
36
38
  return (0, rxjs_1.throwError)(exception);
@@ -1,5 +1,6 @@
1
1
  export interface KafkaSuccessResponseInterface<type> {
2
2
  data?: type;
3
+ metadata?: object;
3
4
  event_source: string;
4
5
  topic?: string;
5
6
  model?: string;