@yolo-croket-dev/core 1.7.25-slowquery.24 → 1.7.25-slowquery.26

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.
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 이벤트 기반으로 AbortSignal을 감지하는 데코레이터 (Interval 없음)
3
+ */
4
+ export declare function AbortEvent(): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbortEvent = void 0;
4
+ // src/modules/rpc-testing/decorators/abort-event.decorator.ts
5
+ const abort_1 = require("../functions/abort");
6
+ /**
7
+ * 이벤트 기반으로 AbortSignal을 감지하는 데코레이터 (Interval 없음)
8
+ */
9
+ function AbortEvent() {
10
+ return function (target, propertyKey, descriptor) {
11
+ const originalMethod = descriptor.value;
12
+ // eslint-disable-next-line no-param-reassign
13
+ descriptor.value = async function (...args) {
14
+ const abortSignal = (0, abort_1.getCurrentAbortSignal)();
15
+ if (!abortSignal) {
16
+ return originalMethod.apply(this, args);
17
+ }
18
+ // 이미 중단된 경우
19
+ if (abortSignal.aborted) {
20
+ throw new Error('REQUEST_ABORTED: 작업이 이미 중단되었습니다');
21
+ }
22
+ // Promise.race로 중단 감지
23
+ const workPromise = originalMethod.apply(this, args);
24
+ const abortPromise = new Promise((_, reject) => {
25
+ const abortHandler = () => {
26
+ reject(new Error('REQUEST_ABORTED: 작업이 중단되었습니다'));
27
+ };
28
+ abortSignal.addEventListener('abort', abortHandler, { once: true });
29
+ });
30
+ return Promise.race([
31
+ workPromise,
32
+ abortPromise,
33
+ ]);
34
+ };
35
+ return descriptor;
36
+ };
37
+ }
38
+ exports.AbortEvent = AbortEvent;
@@ -1,2 +1,3 @@
1
1
  export * from './rpc-interceptor-scope.decorator';
2
2
  export * from './rpc-transform.decorator';
3
+ export * from './abort-event.decorator';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./rpc-interceptor-scope.decorator"), exports);
18
18
  __exportStar(require("./rpc-transform.decorator"), exports);
19
+ __exportStar(require("./abort-event.decorator"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.25-slowquery.24",
3
+ "version": "1.7.25-slowquery.26",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",