@yolo-croket-dev/core 1.9.9 → 1.9.11-jun.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.
@@ -130,7 +130,7 @@ let GrpcExceptionFilter = class GrpcExceptionFilter extends microservices_1.Base
130
130
  }
131
131
  }
132
132
  };
133
- exports.GrpcExceptionFilter = GrpcExceptionFilter;
134
- exports.GrpcExceptionFilter = GrpcExceptionFilter = __decorate([
133
+ GrpcExceptionFilter = __decorate([
135
134
  (0, common_1.Catch)()
136
135
  ], GrpcExceptionFilter);
136
+ exports.GrpcExceptionFilter = GrpcExceptionFilter;
@@ -0,0 +1,17 @@
1
+ declare global {
2
+ var Promise: PromiseConstructor;
3
+ }
4
+ export declare class EnhancedPromisePatch {
5
+ private static isPatched;
6
+ private static originalPromise;
7
+ private static originalSetTimeout;
8
+ static patch(): void;
9
+ private static patchPromise;
10
+ private static patchSetTimeout;
11
+ static unpatch(): void;
12
+ /**
13
+ * 현재 패치 상태 확인
14
+ * @returns 패치 여부
15
+ */
16
+ static getPatchStatus(): boolean;
17
+ }
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnhancedPromisePatch = void 0;
4
+ const abort_1 = require("./abort");
5
+ class EnhancedPromisePatch {
6
+ static patch() {
7
+ if (this.isPatched) {
8
+ return;
9
+ }
10
+ this.patchPromise();
11
+ this.patchSetTimeout();
12
+ this.isPatched = true;
13
+ }
14
+ static patchPromise() {
15
+ this.originalPromise = global.Promise;
16
+ // Promise 생성자 패치
17
+ global.Promise = new Proxy(global.Promise, {
18
+ construct(target, args) {
19
+ const abortSignal = (0, abort_1.getCurrentAbortSignal)();
20
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
21
+ return Promise.reject(new Error('REQUEST_ABORTED: Promise가 중단되었습니다'));
22
+ }
23
+ // target은 Promise 생성자이므로, new 연산자와 함께 사용해야 하며, args는 [executor] 형태의 튜플임을 명시합니다.
24
+ const promise = Reflect.construct(target, args);
25
+ if (!abortSignal) {
26
+ return promise;
27
+ }
28
+ // Promise 체인에 중단 확인 추가
29
+ return promise.then((result) => {
30
+ if (abortSignal.aborted) {
31
+ throw new Error('REQUEST_ABORTED: Promise 실행 중 중단되었습니다');
32
+ }
33
+ return result;
34
+ }, (error) => {
35
+ if (abortSignal.aborted) {
36
+ throw new Error('REQUEST_ABORTED: Promise 실행 중 중단되었습니다');
37
+ }
38
+ throw error;
39
+ });
40
+ },
41
+ });
42
+ // Promise.resolve 패치
43
+ const originalResolve = global.Promise.resolve;
44
+ global.Promise.resolve = (value) => {
45
+ const abortSignal = (0, abort_1.getCurrentAbortSignal)();
46
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
47
+ return Promise.reject(new Error('REQUEST_ABORTED: Promise.resolve가 중단되었습니다'));
48
+ }
49
+ const promise = originalResolve.call(global.Promise, value);
50
+ if (!abortSignal) {
51
+ return promise;
52
+ }
53
+ return promise.then((result) => {
54
+ if (abortSignal.aborted) {
55
+ throw new Error('REQUEST_ABORTED: Promise.resolve 실행 중 중단되었습니다');
56
+ }
57
+ return result;
58
+ }, (error) => {
59
+ if (abortSignal.aborted) {
60
+ throw new Error('REQUEST_ABORTED: Promise.resolve 실행 중 중단되었습니다');
61
+ }
62
+ throw error;
63
+ });
64
+ };
65
+ // Promise.reject 패치
66
+ const originalReject = global.Promise.reject;
67
+ global.Promise.reject = (reason) => {
68
+ const abortSignal = (0, abort_1.getCurrentAbortSignal)();
69
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
70
+ return Promise.reject(new Error('REQUEST_ABORTED: Promise.reject가 중단되었습니다'));
71
+ }
72
+ return originalReject.call(global.Promise, reason);
73
+ };
74
+ }
75
+ static patchSetTimeout() {
76
+ this.originalSetTimeout = global.setTimeout;
77
+ // eslint-disable-next-line @typescript-eslint/ban-types
78
+ global.setTimeout = (callback, delay, ...args) => {
79
+ const abortSignal = (0, abort_1.getCurrentAbortSignal)();
80
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
81
+ throw new Error('REQUEST_ABORTED: setTimeout이 중단되었습니다');
82
+ }
83
+ const timerId = this.originalSetTimeout(() => {
84
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
85
+ throw new Error('REQUEST_ABORTED: setTimeout 콜백이 중단되었습니다');
86
+ }
87
+ callback(...args);
88
+ }, delay);
89
+ if (abortSignal) {
90
+ const abortHandler = () => {
91
+ clearTimeout(timerId);
92
+ };
93
+ abortSignal.addEventListener('abort', abortHandler, { once: true });
94
+ }
95
+ return timerId;
96
+ };
97
+ }
98
+ static unpatch() {
99
+ if (!this.isPatched) {
100
+ return;
101
+ }
102
+ global.Promise = this.originalPromise;
103
+ global.setTimeout = this.originalSetTimeout;
104
+ this.isPatched = false;
105
+ }
106
+ /**
107
+ * 현재 패치 상태 확인
108
+ * @returns 패치 여부
109
+ */
110
+ static getPatchStatus() {
111
+ return this.isPatched;
112
+ }
113
+ }
114
+ exports.EnhancedPromisePatch = EnhancedPromisePatch;
115
+ EnhancedPromisePatch.isPatched = false;
@@ -219,7 +219,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
219
219
  }));
220
220
  }
221
221
  };
222
- exports.LoggingServiceInterceptor = LoggingServiceInterceptor;
223
- exports.LoggingServiceInterceptor = LoggingServiceInterceptor = __decorate([
222
+ LoggingServiceInterceptor = __decorate([
224
223
  (0, common_1.Injectable)()
225
224
  ], LoggingServiceInterceptor);
225
+ exports.LoggingServiceInterceptor = LoggingServiceInterceptor;
@@ -73,7 +73,7 @@ let RPCInterceptor = class RPCInterceptor {
73
73
  let channel;
74
74
  let isRedeliveryProcess = false;
75
75
  const AMQP_URL = process.env.AMQP_URL;
76
- if (!AMQP_URL || !AMQP_URL.length || !replyTo.length) {
76
+ if (!AMQP_URL || !AMQP_URL.length || !replyTo || !replyTo.length) {
77
77
  return false;
78
78
  }
79
79
  try {
@@ -370,9 +370,9 @@ let RPCInterceptor = class RPCInterceptor {
370
370
  })));
371
371
  }
372
372
  };
373
- exports.RPCInterceptor = RPCInterceptor;
374
- exports.RPCInterceptor = RPCInterceptor = __decorate([
373
+ RPCInterceptor = __decorate([
375
374
  (0, common_1.Injectable)(),
376
375
  __metadata("design:paramtypes", [core_1.Reflector,
377
376
  graceful_shutdown_service_1.GracefulShutdownService])
378
377
  ], RPCInterceptor);
378
+ exports.RPCInterceptor = RPCInterceptor;
@@ -18,10 +18,9 @@ var ErrActionTypeEnum;
18
18
  ErrActionTypeEnum["LEGACY_SHOW_TOAST"] = "LEGACY_SHOW_TOAST";
19
19
  ErrActionTypeEnum["FORCE_UPDATE"] = "FORCE_UPDATE";
20
20
  ErrActionTypeEnum["UPDATE_ACCESS_TOKEN"] = "UPDATE_ACCESS_TOKEN";
21
- })(ErrActionTypeEnum || (exports.ErrActionTypeEnum = ErrActionTypeEnum = {}));
21
+ })(ErrActionTypeEnum = exports.ErrActionTypeEnum || (exports.ErrActionTypeEnum = {}));
22
22
  class ErrAction {
23
23
  }
24
- exports.ErrAction = ErrAction;
25
24
  __decorate([
26
25
  (0, swagger_1.ApiProperty)({
27
26
  description: '액션 타입',
@@ -58,9 +57,9 @@ __decorate([
58
57
  }),
59
58
  __metadata("design:type", String)
60
59
  ], ErrAction.prototype, "webViewUrl", void 0);
60
+ exports.ErrAction = ErrAction;
61
61
  class ErrInfo {
62
62
  }
63
- exports.ErrInfo = ErrInfo;
64
63
  __decorate([
65
64
  (0, swagger_1.ApiProperty)({
66
65
  description: '에러 종류 식별자',
@@ -89,3 +88,4 @@ __decorate([
89
88
  }),
90
89
  __metadata("design:type", Object)
91
90
  ], ErrInfo.prototype, "errOption", void 0);
91
+ exports.ErrInfo = ErrInfo;
@@ -21,4 +21,4 @@ var LogLevelEnum;
21
21
  LogLevelEnum["DEBUG"] = "debug";
22
22
  LogLevelEnum["WARN"] = "warn";
23
23
  LogLevelEnum["ERROR"] = "error";
24
- })(LogLevelEnum || (exports.LogLevelEnum = LogLevelEnum = {}));
24
+ })(LogLevelEnum = exports.LogLevelEnum || (exports.LogLevelEnum = {}));
@@ -1,6 +1,10 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { LogLevelEnum } from './log-level.enum';
3
3
  import type { ErrAction } from './exception';
4
+ export declare enum MsaExceptionMessageAckBehaviorEnum {
5
+ ACK = "ACK",
6
+ NACK = "NACK"
7
+ }
4
8
  export interface MsaExceptionOption {
5
9
  /**
6
10
  * 로그 레벨
@@ -8,6 +12,12 @@ export interface MsaExceptionOption {
8
12
  * - 기본값은 ERROR 입니다.
9
13
  * */
10
14
  logErrorLevel?: LogLevelEnum;
15
+ /**
16
+ * 메시지 consumer 실패 시 ACK/NACK override 옵션
17
+ * - 현재는 amqp-rabbit-mq subscribe consumer에서만 해석합니다.
18
+ * - option이 없으면 consumer handler의 기본 errorBehavior를 따릅니다.
19
+ */
20
+ messageAckBehavior?: MsaExceptionMessageAckBehaviorEnum;
11
21
  }
12
22
  /**
13
23
  * @author jun
@@ -27,7 +37,7 @@ export interface MsaException {
27
37
  errOption?: MsaExceptionOption;
28
38
  }
29
39
  /** HttpException과 MsaException을 결합한 타입 */
30
- export type MsaHttpException = MsaException & HttpException;
40
+ export declare type MsaHttpException = MsaException & HttpException;
31
41
  /**
32
42
  * @description MsaException 타입 가드
33
43
  * @param error 검사할 에러 객체
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMsaException = void 0;
3
+ exports.isMsaException = exports.MsaExceptionMessageAckBehaviorEnum = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
+ var MsaExceptionMessageAckBehaviorEnum;
6
+ (function (MsaExceptionMessageAckBehaviorEnum) {
7
+ MsaExceptionMessageAckBehaviorEnum["ACK"] = "ACK";
8
+ MsaExceptionMessageAckBehaviorEnum["NACK"] = "NACK";
9
+ })(MsaExceptionMessageAckBehaviorEnum = exports.MsaExceptionMessageAckBehaviorEnum || (exports.MsaExceptionMessageAckBehaviorEnum = {}));
5
10
  /**
6
11
  * @description MsaException 타입 가드
7
12
  * @param error 검사할 에러 객체
@@ -48,8 +48,7 @@ let GracefulShutdownModule = class GracefulShutdownModule {
48
48
  msaLogger.info('GracefulShutdownService.onModuleDestroy: all interceptors finished, shutting down', { traceId: 'ON_MODULE_DESTROY' });
49
49
  }
50
50
  };
51
- exports.GracefulShutdownModule = GracefulShutdownModule;
52
- exports.GracefulShutdownModule = GracefulShutdownModule = __decorate([
51
+ GracefulShutdownModule = __decorate([
53
52
  (0, common_1.Global)(),
54
53
  (0, common_1.Module)({
55
54
  providers: [graceful_shutdown_service_1.GracefulShutdownService],
@@ -57,3 +56,4 @@ exports.GracefulShutdownModule = GracefulShutdownModule = __decorate([
57
56
  }),
58
57
  __metadata("design:paramtypes", [graceful_shutdown_service_1.GracefulShutdownService])
59
58
  ], GracefulShutdownModule);
59
+ exports.GracefulShutdownModule = GracefulShutdownModule;
@@ -1,7 +1,7 @@
1
1
  import { RmqOptions, ServerRMQ } from '@nestjs/microservices';
2
2
  import { Channel } from 'amqp-connection-manager';
3
3
  import { ConsumeMessage } from 'amqplib';
4
- export type GracefulRmqOptions = RmqOptions['options'] & {
4
+ export declare type GracefulRmqOptions = RmqOptions['options'] & {
5
5
  waitingEndingHandlersTimeoutMs?: number;
6
6
  waitingEndingHandlersIntervalMs?: number;
7
7
  };
@@ -133,7 +133,7 @@ let GracefulShutdownService = class GracefulShutdownService {
133
133
  });
134
134
  }
135
135
  };
136
- exports.GracefulShutdownService = GracefulShutdownService;
137
- exports.GracefulShutdownService = GracefulShutdownService = __decorate([
136
+ GracefulShutdownService = __decorate([
138
137
  (0, common_1.Injectable)()
139
138
  ], GracefulShutdownService);
139
+ exports.GracefulShutdownService = GracefulShutdownService;
@@ -15,10 +15,10 @@ const redisProvider = {
15
15
  };
16
16
  let RedisModule = class RedisModule {
17
17
  };
18
- exports.RedisModule = RedisModule;
19
- exports.RedisModule = RedisModule = __decorate([
18
+ RedisModule = __decorate([
20
19
  (0, common_1.Module)({
21
20
  providers: [redisProvider],
22
21
  exports: [redisProvider],
23
22
  })
24
23
  ], RedisModule);
24
+ exports.RedisModule = RedisModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.9.9",
3
+ "version": "1.9.11-jun.0",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",
@@ -31,8 +31,8 @@ let ValidationPipe = class ValidationPipe {
31
31
  return value;
32
32
  }
33
33
  };
34
- exports.ValidationPipe = ValidationPipe;
35
- exports.ValidationPipe = ValidationPipe = __decorate([
34
+ ValidationPipe = __decorate([
36
35
  (0, common_1.Injectable)(),
37
36
  __metadata("design:paramtypes", [Object])
38
37
  ], ValidationPipe);
38
+ exports.ValidationPipe = ValidationPipe;
@@ -1,5 +0,0 @@
1
- import { HttpException } from '@nestjs/common';
2
- import { AbstractErrorResponse } from '../interfaces';
3
- export declare class CustomException extends HttpException {
4
- constructor(status: number, body: AbstractErrorResponse);
5
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomException = void 0;
4
- const common_1 = require("@nestjs/common");
5
- class CustomException extends common_1.HttpException {
6
- constructor(status, body) {
7
- super(body, status);
8
- }
9
- }
10
- exports.CustomException = CustomException;